LLVM: lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

17

18using namespace llvm;

19

23 AttributeList FuncAttrs) {

24 AttributeList OldAttrs = Func->getAttributes();

25 AttributeList NewAttrs = OldAttrs;

26

27 {

28 AttrBuilder OldBuilder(Ctx, OldAttrs.getFnAttrs());

29 AttrBuilder NewBuilder(Ctx, FuncAttrs.getFnAttrs());

30 OldBuilder.merge(NewBuilder);

31 NewAttrs = NewAttrs.addFnAttributes(Ctx, OldBuilder);

32 }

33

34 {

35 AttrBuilder OldBuilder(Ctx, OldAttrs.getRetAttrs());

36 AttrBuilder NewBuilder(Ctx, FuncAttrs.getRetAttrs());

37 OldBuilder.merge(NewBuilder);

38 NewAttrs = NewAttrs.addRetAttributes(Ctx, OldBuilder);

39 }

40

41 for (unsigned I = 0, E = FuncTy->getNumParams(); I != E; ++I) {

42 AttrBuilder OldBuilder(Ctx, OldAttrs.getParamAttrs(I));

43 AttrBuilder NewBuilder(Ctx, FuncAttrs.getParamAttrs(I));

44 OldBuilder.merge(NewBuilder);

45 NewAttrs = NewAttrs.addParamAttributes(Ctx, I, OldBuilder);

46 }

47

48 Func->setAttributes(NewAttrs);

49}

50

55

58 const Triple &TT = M.getTargetTriple();

59

62 continue;

63

64 auto [FuncTy, FuncAttrs] = RTLCI.getFunctionTy(Ctx, TT, DL, Impl);

65

66

67 if (!FuncTy)

69

71

73 cast(M.getOrInsertFunction(FuncName, FuncTy).getCallee());

74 if (Func->getFunctionType() == FuncTy) {

77 }

78 }

79

81}

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

static void mergeAttributes(LLVMContext &Ctx, const Module &M, const DataLayout &DL, const Triple &TT, Function *Func, FunctionType *FuncTy, AttributeList FuncAttrs)

Definition DeclareRuntimeLibcalls.cpp:20

Module.h This file contains the declarations for the Module class.

ModuleAnalysisManager MAM

A parsed version of the target data layout string in and methods for querying it.

PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)

Definition DeclareRuntimeLibcalls.cpp:51

static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)

This static method is the primary way of constructing a FunctionType.

This is an important class for using LLVM in a threaded context.

A Module instance is used to store all the information related to an LLVM module.

A set of analyses that are preserved following a run of a transformation pass.

static PreservedAnalyses none()

Convenience factory function for the empty preserved set.

StringRef - Represent a constant reference to a string, i.e.

Triple - Helper class for working with autoconf configuration names.

static LLVM_ABI Type * getVoidTy(LLVMContext &C)

static auto libcall_impls()

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

AnalysisManager< Module > ModuleAnalysisManager

Convenience typedef for the Module analysis manager.

A simple container for information about the supported runtime calls.

CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const

Get the CallingConv that should be used for the specified libcall.

bool isAvailable(RTLIB::LibcallImpl Impl) const

std::pair< FunctionType *, AttributeList > getFunctionTy(LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, RTLIB::LibcallImpl LibcallImpl) const

static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)

Get the libcall routine name for the specified libcall implementation.