LLVM  16.0.0git
ModuleUtils.cpp
Go to the documentation of this file.
1 //===-- ModuleUtils.cpp - Functions to manipulate Modules -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This family of functions perform manipulations on Modules.
10 //
11 //===----------------------------------------------------------------------===//
12 
15 #include "llvm/IR/DerivedTypes.h"
16 #include "llvm/IR/Function.h"
17 #include "llvm/IR/IRBuilder.h"
18 #include "llvm/IR/Module.h"
20 using namespace llvm;
21 
22 #define DEBUG_TYPE "moduleutils"
23 
24 static void appendToGlobalArray(const char *Array, Module &M, Function *F,
25  int Priority, Constant *Data) {
26  IRBuilder<> IRB(M.getContext());
27  FunctionType *FnTy = FunctionType::get(IRB.getVoidTy(), false);
28 
29  // Get the current set of static global constructors and add the new ctor
30  // to the list.
31  SmallVector<Constant *, 16> CurrentCtors;
32  StructType *EltTy = StructType::get(
33  IRB.getInt32Ty(), PointerType::getUnqual(FnTy), IRB.getInt8PtrTy());
34  if (GlobalVariable *GVCtor = M.getNamedGlobal(Array)) {
35  if (Constant *Init = GVCtor->getInitializer()) {
36  unsigned n = Init->getNumOperands();
37  CurrentCtors.reserve(n + 1);
38  for (unsigned i = 0; i != n; ++i)
39  CurrentCtors.push_back(cast<Constant>(Init->getOperand(i)));
40  }
41  GVCtor->eraseFromParent();
42  }
43 
44  // Build a 3 field global_ctor entry. We don't take a comdat key.
45  Constant *CSVals[3];
46  CSVals[0] = IRB.getInt32(Priority);
47  CSVals[1] = F;
50  Constant *RuntimeCtorInit =
51  ConstantStruct::get(EltTy, makeArrayRef(CSVals, EltTy->getNumElements()));
52 
53  CurrentCtors.push_back(RuntimeCtorInit);
54 
55  // Create a new initializer.
56  ArrayType *AT = ArrayType::get(EltTy, CurrentCtors.size());
57  Constant *NewInit = ConstantArray::get(AT, CurrentCtors);
58 
59  // Create the new global variable and replace all uses of
60  // the old global variable with the new one.
61  (void)new GlobalVariable(M, NewInit->getType(), false,
62  GlobalValue::AppendingLinkage, NewInit, Array);
63 }
64 
66  appendToGlobalArray("llvm.global_ctors", M, F, Priority, Data);
67 }
68 
70  appendToGlobalArray("llvm.global_dtors", M, F, Priority, Data);
71 }
72 
74  GlobalVariable *GV = M.getGlobalVariable(Name);
77  if (GV) {
78  if (GV->hasInitializer()) {
79  auto *CA = cast<ConstantArray>(GV->getInitializer());
80  for (auto &Op : CA->operands()) {
81  Constant *C = cast_or_null<Constant>(Op);
82  if (InitAsSet.insert(C).second)
83  Init.push_back(C);
84  }
85  }
86  GV->eraseFromParent();
87  }
88 
89  Type *Int8PtrTy = llvm::Type::getInt8PtrTy(M.getContext());
90  for (auto *V : Values) {
92  if (InitAsSet.insert(C).second)
93  Init.push_back(C);
94  }
95 
96  if (Init.empty())
97  return;
98 
99  ArrayType *ATy = ArrayType::get(Int8PtrTy, Init.size());
101  ConstantArray::get(ATy, Init), Name);
102  GV->setSection("llvm.metadata");
103 }
104 
106  appendToUsedList(M, "llvm.used", Values);
107 }
108 
110  appendToUsedList(M, "llvm.compiler.used", Values);
111 }
112 
115  ArrayRef<Type *> InitArgTypes) {
116  assert(!InitName.empty() && "Expected init function name");
117  return M.getOrInsertFunction(
118  InitName,
119  FunctionType::get(Type::getVoidTy(M.getContext()), InitArgTypes, false),
120  AttributeList());
121 }
122 
125  FunctionType::get(Type::getVoidTy(M.getContext()), false),
126  GlobalValue::InternalLinkage, 0, CtorName, &M);
127  Ctor->addFnAttr(Attribute::NoUnwind);
128  BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor);
129  ReturnInst::Create(M.getContext(), CtorBB);
130  // Ensure Ctor cannot be discarded, even if in a comdat.
131  appendToUsed(M, {Ctor});
132  return Ctor;
133 }
134 
135 std::pair<Function *, FunctionCallee> llvm::createSanitizerCtorAndInitFunctions(
136  Module &M, StringRef CtorName, StringRef InitName,
137  ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
138  StringRef VersionCheckName) {
139  assert(!InitName.empty() && "Expected init function name");
140  assert(InitArgs.size() == InitArgTypes.size() &&
141  "Sanitizer's init function expects different number of arguments");
142  FunctionCallee InitFunction =
143  declareSanitizerInitFunction(M, InitName, InitArgTypes);
144  Function *Ctor = createSanitizerCtor(M, CtorName);
145  IRBuilder<> IRB(Ctor->getEntryBlock().getTerminator());
146  IRB.CreateCall(InitFunction, InitArgs);
147  if (!VersionCheckName.empty()) {
148  FunctionCallee VersionCheckFunction = M.getOrInsertFunction(
149  VersionCheckName, FunctionType::get(IRB.getVoidTy(), {}, false),
150  AttributeList());
151  IRB.CreateCall(VersionCheckFunction, {});
152  }
153  return std::make_pair(Ctor, InitFunction);
154 }
155 
156 std::pair<Function *, FunctionCallee>
158  Module &M, StringRef CtorName, StringRef InitName,
159  ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
160  function_ref<void(Function *, FunctionCallee)> FunctionsCreatedCallback,
161  StringRef VersionCheckName) {
162  assert(!CtorName.empty() && "Expected ctor function name");
163 
164  if (Function *Ctor = M.getFunction(CtorName))
165  // FIXME: Sink this logic into the module, similar to the handling of
166  // globals. This will make moving to a concurrent model much easier.
167  if (Ctor->arg_empty() ||
168  Ctor->getReturnType() == Type::getVoidTy(M.getContext()))
169  return {Ctor, declareSanitizerInitFunction(M, InitName, InitArgTypes)};
170 
171  Function *Ctor;
172  FunctionCallee InitFunction;
173  std::tie(Ctor, InitFunction) = llvm::createSanitizerCtorAndInitFunctions(
174  M, CtorName, InitName, InitArgTypes, InitArgs, VersionCheckName);
175  FunctionsCreatedCallback(Ctor, InitFunction);
176  return std::make_pair(Ctor, InitFunction);
177 }
178 
180  SmallVectorImpl<Function *> &DeadComdatFunctions) {
181  SmallPtrSet<Function *, 32> MaybeDeadFunctions;
182  SmallPtrSet<Comdat *, 32> MaybeDeadComdats;
183  for (Function *F : DeadComdatFunctions) {
184  MaybeDeadFunctions.insert(F);
185  if (Comdat *C = F->getComdat())
186  MaybeDeadComdats.insert(C);
187  }
188 
189  // Find comdats for which all users are dead now.
190  SmallPtrSet<Comdat *, 32> DeadComdats;
191  for (Comdat *C : MaybeDeadComdats) {
192  auto IsUserDead = [&](GlobalObject *GO) {
193  auto *F = dyn_cast<Function>(GO);
194  return F && MaybeDeadFunctions.contains(F);
195  };
196  if (all_of(C->getUsers(), IsUserDead))
197  DeadComdats.insert(C);
198  }
199 
200  // Only keep functions which have no comdat or a dead comdat.
201  erase_if(DeadComdatFunctions, [&](Function *F) {
202  Comdat *C = F->getComdat();
203  return C && !DeadComdats.contains(C);
204  });
205 }
206 
208  MD5 Md5;
209  bool ExportsSymbols = false;
210  auto AddGlobal = [&](GlobalValue &GV) {
211  if (GV.isDeclaration() || GV.getName().startswith("llvm.") ||
212  !GV.hasExternalLinkage() || GV.hasComdat())
213  return;
214  ExportsSymbols = true;
215  Md5.update(GV.getName());
216  Md5.update(ArrayRef<uint8_t>{0});
217  };
218 
219  for (auto &F : *M)
220  AddGlobal(F);
221  for (auto &GV : M->globals())
222  AddGlobal(GV);
223  for (auto &GA : M->aliases())
224  AddGlobal(GA);
225  for (auto &IF : M->ifuncs())
226  AddGlobal(IF);
227 
228  if (!ExportsSymbols)
229  return "";
230 
231  MD5::MD5Result R;
232  Md5.final(R);
233 
234  SmallString<32> Str;
235  MD5::stringifyResult(R, Str);
236  return ("." + Str).str();
237 }
238 
240  ArrayRef<std::string> VariantMappings) {
241  if (VariantMappings.empty())
242  return;
243 
244  SmallString<256> Buffer;
245  llvm::raw_svector_ostream Out(Buffer);
246  for (const std::string &VariantMapping : VariantMappings)
247  Out << VariantMapping << ",";
248  // Get rid of the trailing ','.
249  assert(!Buffer.str().empty() && "Must have at least one char.");
250  Buffer.pop_back();
251 
252  Module *M = CI->getModule();
253 #ifndef NDEBUG
254  for (const std::string &VariantMapping : VariantMappings) {
255  LLVM_DEBUG(dbgs() << "VFABI: adding mapping '" << VariantMapping << "'\n");
256  Optional<VFInfo> VI = VFABI::tryDemangleForVFABI(VariantMapping, *M);
257  assert(VI && "Cannot add an invalid VFABI name.");
258  assert(M->getNamedValue(VI.value().VectorName) &&
259  "Cannot add variant to attribute: "
260  "vector function declaration is missing.");
261  }
262 #endif
263  CI->addFnAttr(
264  Attribute::get(M->getContext(), MappingsAttrName, Buffer.str()));
265 }
266 
268  StringRef SectionName, Align Alignment) {
269  // Embed the memory buffer into the module.
270  Constant *ModuleConstant = ConstantDataArray::get(
271  M.getContext(), makeArrayRef(Buf.getBufferStart(), Buf.getBufferSize()));
272  GlobalVariable *GV = new GlobalVariable(
273  M, ModuleConstant->getType(), true, GlobalValue::PrivateLinkage,
274  ModuleConstant, "llvm.embedded.object");
275  GV->setSection(SectionName);
276  GV->setAlignment(Alignment);
277 
278  LLVMContext &Ctx = M.getContext();
279  NamedMDNode *MD = M.getOrInsertNamedMetadata("llvm.embedded.objects");
280  Metadata *MDVals[] = {ConstantAsMetadata::get(GV),
281  MDString::get(Ctx, SectionName)};
282 
283  MD->addOperand(llvm::MDNode::get(Ctx, MDVals));
284  GV->setMetadata(LLVMContext::MD_exclude, llvm::MDNode::get(Ctx, {}));
285 
286  appendToCompilerUsed(M, GV);
287 }
i
i
Definition: README.txt:29
llvm::GlobalVariable::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:464
llvm::IRBuilderBase::getInt32Ty
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition: IRBuilder.h:509
llvm::MemoryBufferRef::getBufferStart
const char * getBufferStart() const
Definition: MemoryBufferRef.h:35
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::Instruction::getModule
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:65
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1588
llvm::MD5::update
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
Definition: MD5.cpp:189
llvm::StructType::get
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition: Type.cpp:406
llvm::Type::getInt8PtrTy
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:291
llvm::MD5::stringifyResult
static void stringifyResult(MD5Result &Result, SmallVectorImpl< char > &Str)
Translates the bytes in Res to a hex string that is deposited into Str.
Definition: MD5.cpp:287
llvm::Function
Definition: Function.h:60
llvm::ConstantStruct::get
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1306
llvm::Attribute::get
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:90
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1181
llvm::AMDGPUISD::IF
@ IF
Definition: AMDGPUISelLowering.h:358
llvm::createSanitizerCtor
Function * createSanitizerCtor(Module &M, StringRef CtorName)
Creates sanitizer constructor function.
Definition: ModuleUtils.cpp:123
llvm::Function::getEntryBlock
const BasicBlock & getEntryBlock() const
Definition: Function.h:710
llvm::IRBuilder<>
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::erase_if
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
Definition: STLExtras.h:1802
llvm::FunctionType::get
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:361
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
Module.h
llvm::AttributeList
Definition: Attributes.h:425
llvm::Optional
Definition: APInt.h:33
llvm::MemoryBufferRef::getBufferSize
size_t getBufferSize() const
Definition: MemoryBufferRef.h:37
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:420
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:159
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1400
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::GlobalVariable::hasInitializer
bool hasInitializer() const
Definitions have initializers, declarations don't.
Definition: GlobalVariable.h:91
llvm::ConstantExpr::getPointerCast
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition: Constants.cpp:2014
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::appendToGlobalDtors
void appendToGlobalDtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Same as appendToGlobalCtors(), but for global dtors.
Definition: ModuleUtils.cpp:69
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::NamedMDNode::addOperand
void addOperand(MDNode *M)
Definition: Metadata.cpp:1222
llvm::getOrCreateSanitizerCtorAndInitFunctions
std::pair< Function *, FunctionCallee > getOrCreateSanitizerCtorAndInitFunctions(Module &M, StringRef CtorName, StringRef InitName, ArrayRef< Type * > InitArgTypes, ArrayRef< Value * > InitArgs, function_ref< void(Function *, FunctionCallee)> FunctionsCreatedCallback, StringRef VersionCheckName=StringRef())
Creates sanitizer constructor function lazily.
Definition: ModuleUtils.cpp:157
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1590
llvm::MD5::final
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
Definition: MD5.cpp:234
llvm::GlobalObject::setSection
void setSection(StringRef S)
Change the section for this global.
Definition: Globals.cpp:248
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::CallBase::addFnAttr
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
Definition: InstrTypes.h:1506
llvm::appendToCompilerUsed
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
Definition: ModuleUtils.cpp:109
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::Comdat
Definition: Comdat.h:33
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::SmallString< 32 >
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
VectorUtils.h
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalVariable::getInitializer
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Definition: GlobalVariable.h:135
VI
@ VI
Definition: SIInstrInfo.cpp:7894
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::PointerType::getUnqual
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition: DerivedTypes.h:651
llvm::createSanitizerCtorAndInitFunctions
std::pair< Function *, FunctionCallee > createSanitizerCtorAndInitFunctions(Module &M, StringRef CtorName, StringRef InitName, ArrayRef< Type * > InitArgTypes, ArrayRef< Value * > InitArgs, StringRef VersionCheckName=StringRef())
Creates sanitizer constructor function, and calls sanitizer's init function from it.
Definition: ModuleUtils.cpp:135
llvm::filterDeadComdatFunctions
void filterDeadComdatFunctions(SmallVectorImpl< Function * > &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive.
Definition: ModuleUtils.cpp:179
llvm::IRBuilderBase::getInt32
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:469
llvm::MD5
Definition: MD5.h:41
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::declareSanitizerInitFunction
FunctionCallee declareSanitizerInitFunction(Module &M, StringRef InitName, ArrayRef< Type * > InitArgTypes)
Definition: ModuleUtils.cpp:114
appendToGlobalArray
static void appendToGlobalArray(const char *Array, Module &M, Function *F, int Priority, Constant *Data)
Definition: ModuleUtils.cpp:24
llvm::embedBufferInModule
void embedBufferInModule(Module &M, MemoryBufferRef Buf, StringRef SectionName, Align Alignment=Align(1))
Embed the memory buffer Buf into the module M as a global using the specified section name.
Definition: ModuleUtils.cpp:267
llvm::IRBuilderBase::getInt8PtrTy
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
Definition: IRBuilder.h:557
llvm::appendToUsed
void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
Definition: ModuleUtils.cpp:105
llvm::MDString::get
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:498
IRBuilder.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ArrayType::get
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Definition: Type.cpp:638
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::GlobalValue::AppendingLinkage
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:54
llvm::Function::createWithDefaultAttr
static Function * createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Creates a function with some attributes recorded in llvm.module.flags applied.
Definition: Function.cpp:337
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:213
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::ConstantDataArray::get
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
Definition: Constants.h:692
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:97
llvm::Init
Definition: Record.h:281
llvm::StructType::getNumElements
unsigned getNumElements() const
Random access to the elements.
Definition: DerivedTypes.h:327
llvm::MD5::MD5Result
Definition: MD5.h:43
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::Constant::getNullValue
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Definition: Constants.cpp:350
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::SectionName
Definition: DWARFSection.h:21
Function.h
llvm::VFABI::setVectorVariantNames
void setVectorVariantNames(CallInst *CI, ArrayRef< std::string > VariantMappings)
Overwrite the Vector Function ABI variants attribute with the names provide in VariantMappings.
Definition: ModuleUtils.cpp:239
llvm::ReturnInst::Create
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
Definition: Instructions.h:3079
llvm::getUniqueModuleId
std::string getUniqueModuleId(Module *M)
Produce a unique identifier for this module by taking the MD5 sum of the names of the module's strong...
Definition: ModuleUtils.cpp:207
llvm::ConstantArray::get
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1241
llvm::SmallString::str
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:260
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:222
llvm::GlobalObject::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
Definition: Metadata.cpp:1326
llvm::GlobalValue::PrivateLinkage
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:56
llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
Definition: Constants.cpp:2029
ModuleUtils.h
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
llvm::VFABI::MappingsAttrName
static constexpr const char * MappingsAttrName
Definition: VectorUtils.h:193
llvm::Function::addFnAttr
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Definition: Function.cpp:538
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:658
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:165
llvm::BasicBlock::getTerminator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.h:119
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::VFABI::tryDemangleForVFABI
Optional< VFInfo > tryDemangleForVFABI(StringRef MangledName, const Module &M)
Function to construct a VFInfo out of a mangled names in the following format:
Definition: VFABIDemangling.cpp:317
DerivedTypes.h
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1474
llvm::IRBuilderBase::getVoidTy
Type * getVoidTy()
Fetch the type representing void.
Definition: IRBuilder.h:547
appendToUsedList
static void appendToUsedList(Module &M, StringRef Name, ArrayRef< GlobalValue * > Values)
Definition: ModuleUtils.cpp:73
llvm::appendToGlobalCtors
void appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Append F to the list of global ctors of module M with the given Priority.
Definition: ModuleUtils.cpp:65
llvm::GlobalObject::setAlignment
void setAlignment(MaybeAlign Align)
Definition: Globals.cpp:126
raw_ostream.h
n
The same transformation can work with an even modulo with the addition of a and shrink the compare RHS by the same amount Unless the target supports that transformation probably isn t worthwhile The transformation can also easily be made to work with non zero equality for n
Definition: README.txt:685
llvm::SmallPtrSetImpl::contains
bool contains(ConstPtrType Ptr) const
Definition: SmallPtrSet.h:389
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:649
llvm::IRBuilderBase::CreateCall
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2268
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:365