LLVM  13.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 
16 #include "llvm/IR/DerivedTypes.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/IRBuilder.h"
19 #include "llvm/IR/Module.h"
21 using namespace llvm;
22 
23 #define DEBUG_TYPE "moduleutils"
24 
25 static void appendToGlobalArray(const char *Array, Module &M, Function *F,
26  int Priority, Constant *Data) {
27  IRBuilder<> IRB(M.getContext());
28  FunctionType *FnTy = FunctionType::get(IRB.getVoidTy(), false);
29 
30  // Get the current set of static global constructors and add the new ctor
31  // to the list.
32  SmallVector<Constant *, 16> CurrentCtors;
33  StructType *EltTy = StructType::get(
34  IRB.getInt32Ty(), PointerType::getUnqual(FnTy), IRB.getInt8PtrTy());
35  if (GlobalVariable *GVCtor = M.getNamedGlobal(Array)) {
36  if (Constant *Init = GVCtor->getInitializer()) {
37  unsigned n = Init->getNumOperands();
38  CurrentCtors.reserve(n + 1);
39  for (unsigned i = 0; i != n; ++i)
40  CurrentCtors.push_back(cast<Constant>(Init->getOperand(i)));
41  }
42  GVCtor->eraseFromParent();
43  }
44 
45  // Build a 3 field global_ctor entry. We don't take a comdat key.
46  Constant *CSVals[3];
47  CSVals[0] = IRB.getInt32(Priority);
48  CSVals[1] = F;
51  Constant *RuntimeCtorInit =
52  ConstantStruct::get(EltTy, makeArrayRef(CSVals, EltTy->getNumElements()));
53 
54  CurrentCtors.push_back(RuntimeCtorInit);
55 
56  // Create a new initializer.
57  ArrayType *AT = ArrayType::get(EltTy, CurrentCtors.size());
58  Constant *NewInit = ConstantArray::get(AT, CurrentCtors);
59 
60  // Create the new global variable and replace all uses of
61  // the old global variable with the new one.
62  (void)new GlobalVariable(M, NewInit->getType(), false,
63  GlobalValue::AppendingLinkage, NewInit, Array);
64 }
65 
67  appendToGlobalArray("llvm.global_ctors", M, F, Priority, Data);
68 }
69 
71  appendToGlobalArray("llvm.global_dtors", M, F, Priority, Data);
72 }
73 
75  GlobalVariable *GV = M.getGlobalVariable(Name);
78  if (GV) {
79  if (GV->hasInitializer()) {
80  auto *CA = cast<ConstantArray>(GV->getInitializer());
81  for (auto &Op : CA->operands()) {
82  Constant *C = cast_or_null<Constant>(Op);
83  if (InitAsSet.insert(C).second)
84  Init.push_back(C);
85  }
86  }
87  GV->eraseFromParent();
88  }
89 
90  Type *Int8PtrTy = llvm::Type::getInt8PtrTy(M.getContext());
91  for (auto *V : Values) {
93  if (InitAsSet.insert(C).second)
94  Init.push_back(C);
95  }
96 
97  if (Init.empty())
98  return;
99 
100  ArrayType *ATy = ArrayType::get(Int8PtrTy, Init.size());
102  ConstantArray::get(ATy, Init), Name);
103  GV->setSection("llvm.metadata");
104 }
105 
107  appendToUsedList(M, "llvm.used", Values);
108 }
109 
111  appendToUsedList(M, "llvm.compiler.used", Values);
112 }
113 
116  ArrayRef<Type *> InitArgTypes) {
117  assert(!InitName.empty() && "Expected init function name");
118  return M.getOrInsertFunction(
119  InitName,
120  FunctionType::get(Type::getVoidTy(M.getContext()), InitArgTypes, false),
121  AttributeList());
122 }
123 
126  FunctionType::get(Type::getVoidTy(M.getContext()), false),
127  GlobalValue::InternalLinkage, 0, CtorName, &M);
128  Ctor->addAttribute(AttributeList::FunctionIndex, Attribute::NoUnwind);
129  BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor);
130  ReturnInst::Create(M.getContext(), CtorBB);
131  return Ctor;
132 }
133 
134 std::pair<Function *, FunctionCallee> llvm::createSanitizerCtorAndInitFunctions(
135  Module &M, StringRef CtorName, StringRef InitName,
136  ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
137  StringRef VersionCheckName) {
138  assert(!InitName.empty() && "Expected init function name");
139  assert(InitArgs.size() == InitArgTypes.size() &&
140  "Sanitizer's init function expects different number of arguments");
141  FunctionCallee InitFunction =
142  declareSanitizerInitFunction(M, InitName, InitArgTypes);
143  Function *Ctor = createSanitizerCtor(M, CtorName);
144  IRBuilder<> IRB(Ctor->getEntryBlock().getTerminator());
145  IRB.CreateCall(InitFunction, InitArgs);
146  if (!VersionCheckName.empty()) {
147  FunctionCallee VersionCheckFunction = M.getOrInsertFunction(
148  VersionCheckName, FunctionType::get(IRB.getVoidTy(), {}, false),
149  AttributeList());
150  IRB.CreateCall(VersionCheckFunction, {});
151  }
152  return std::make_pair(Ctor, InitFunction);
153 }
154 
155 std::pair<Function *, FunctionCallee>
157  Module &M, StringRef CtorName, StringRef InitName,
158  ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
159  function_ref<void(Function *, FunctionCallee)> FunctionsCreatedCallback,
160  StringRef VersionCheckName) {
161  assert(!CtorName.empty() && "Expected ctor function name");
162 
163  if (Function *Ctor = M.getFunction(CtorName))
164  // FIXME: Sink this logic into the module, similar to the handling of
165  // globals. This will make moving to a concurrent model much easier.
166  if (Ctor->arg_size() == 0 ||
167  Ctor->getReturnType() == Type::getVoidTy(M.getContext()))
168  return {Ctor, declareSanitizerInitFunction(M, InitName, InitArgTypes)};
169 
170  Function *Ctor;
171  FunctionCallee InitFunction;
172  std::tie(Ctor, InitFunction) = llvm::createSanitizerCtorAndInitFunctions(
173  M, CtorName, InitName, InitArgTypes, InitArgs, VersionCheckName);
174  FunctionsCreatedCallback(Ctor, InitFunction);
175  return std::make_pair(Ctor, InitFunction);
176 }
177 
179  assert(!Name.empty() && "Expected init function name");
180  if (Function *F = M.getFunction(Name)) {
181  if (F->arg_size() != 0 ||
182  F->getReturnType() != Type::getVoidTy(M.getContext())) {
183  std::string Err;
184  raw_string_ostream Stream(Err);
185  Stream << "Sanitizer interface function defined with wrong type: " << *F;
186  report_fatal_error(Err);
187  }
188  return F;
189  }
190  Function *F =
191  cast<Function>(M.getOrInsertFunction(Name, AttributeList(),
192  Type::getVoidTy(M.getContext()))
193  .getCallee());
194 
195  appendToGlobalCtors(M, F, 0);
196 
197  return F;
198 }
199 
201  Module &M, SmallVectorImpl<Function *> &DeadComdatFunctions) {
202  // Build a map from the comdat to the number of entries in that comdat we
203  // think are dead. If this fully covers the comdat group, then the entire
204  // group is dead. If we find another entry in the comdat group though, we'll
205  // have to preserve the whole group.
206  SmallDenseMap<Comdat *, int, 16> ComdatEntriesCovered;
207  for (Function *F : DeadComdatFunctions) {
208  Comdat *C = F->getComdat();
209  assert(C && "Expected all input GVs to be in a comdat!");
210  ComdatEntriesCovered[C] += 1;
211  }
212 
213  auto CheckComdat = [&](Comdat &C) {
214  auto CI = ComdatEntriesCovered.find(&C);
215  if (CI == ComdatEntriesCovered.end())
216  return;
217 
218  // If this could have been covered by a dead entry, just subtract one to
219  // account for it.
220  if (CI->second > 0) {
221  CI->second -= 1;
222  return;
223  }
224 
225  // If we've already accounted for all the entries that were dead, the
226  // entire comdat is alive so remove it from the map.
227  ComdatEntriesCovered.erase(CI);
228  };
229 
230  auto CheckAllComdats = [&] {
231  for (Function &F : M.functions())
232  if (Comdat *C = F.getComdat()) {
233  CheckComdat(*C);
234  if (ComdatEntriesCovered.empty())
235  return;
236  }
237  for (GlobalVariable &GV : M.globals())
238  if (Comdat *C = GV.getComdat()) {
239  CheckComdat(*C);
240  if (ComdatEntriesCovered.empty())
241  return;
242  }
243  for (GlobalAlias &GA : M.aliases())
244  if (Comdat *C = GA.getComdat()) {
245  CheckComdat(*C);
246  if (ComdatEntriesCovered.empty())
247  return;
248  }
249  };
250  CheckAllComdats();
251 
252  if (ComdatEntriesCovered.empty()) {
253  DeadComdatFunctions.clear();
254  return;
255  }
256 
257  // Remove the entries that were not covering.
258  erase_if(DeadComdatFunctions, [&](GlobalValue *GV) {
259  return ComdatEntriesCovered.find(GV->getComdat()) ==
260  ComdatEntriesCovered.end();
261  });
262 }
263 
265  MD5 Md5;
266  bool ExportsSymbols = false;
267  auto AddGlobal = [&](GlobalValue &GV) {
268  if (GV.isDeclaration() || GV.getName().startswith("llvm.") ||
269  !GV.hasExternalLinkage() || GV.hasComdat())
270  return;
271  ExportsSymbols = true;
272  Md5.update(GV.getName());
273  Md5.update(ArrayRef<uint8_t>{0});
274  };
275 
276  for (auto &F : *M)
277  AddGlobal(F);
278  for (auto &GV : M->globals())
279  AddGlobal(GV);
280  for (auto &GA : M->aliases())
281  AddGlobal(GA);
282  for (auto &IF : M->ifuncs())
283  AddGlobal(IF);
284 
285  if (!ExportsSymbols)
286  return "";
287 
288  MD5::MD5Result R;
289  Md5.final(R);
290 
291  SmallString<32> Str;
292  MD5::stringifyResult(R, Str);
293  return ("." + Str).str();
294 }
295 
297  CallInst *CI, const SmallVector<std::string, 8> &VariantMappings) {
298  if (VariantMappings.empty())
299  return;
300 
301  SmallString<256> Buffer;
302  llvm::raw_svector_ostream Out(Buffer);
303  for (const std::string &VariantMapping : VariantMappings)
304  Out << VariantMapping << ",";
305  // Get rid of the trailing ','.
306  assert(!Buffer.str().empty() && "Must have at least one char.");
307  Buffer.pop_back();
308 
309  Module *M = CI->getModule();
310 #ifndef NDEBUG
311  for (const std::string &VariantMapping : VariantMappings) {
312  LLVM_DEBUG(dbgs() << "VFABI: adding mapping '" << VariantMapping << "'\n");
313  Optional<VFInfo> VI = VFABI::tryDemangleForVFABI(VariantMapping, *M);
314  assert(VI.hasValue() && "Cannot add an invalid VFABI name.");
315  assert(M->getNamedValue(VI.getValue().VectorName) &&
316  "Cannot add variant to attribute: "
317  "vector function declaration is missing.");
318  }
319 #endif
320  CI->addAttribute(
322  Attribute::get(M->getContext(), MappingsAttrName, Buffer.str()));
323 }
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:385
llvm::IRBuilderBase::getInt32Ty
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition: IRBuilder.h:518
llvm
Definition: AllocatorList.h:23
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:66
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::MD5::update
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
Definition: MD5.cpp:190
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:366
llvm::VFABI::setVectorVariantNames
void setVectorVariantNames(CallInst *CI, const SmallVector< std::string, 8 > &VariantMappings)
Overwrite the Vector Function ABI variants attribute with the names provide in VariantMappings.
Definition: ModuleUtils.cpp:296
llvm::Type::getInt8PtrTy
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:249
llvm::filterDeadComdatFunctions
void filterDeadComdatFunctions(Module &M, SmallVectorImpl< Function * > &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive.
Definition: ModuleUtils.cpp:200
llvm::Function
Definition: Function.h:61
llvm::ConstantStruct::get
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1325
llvm::MD5::stringifyResult
static void stringifyResult(MD5Result &Result, SmallString< 32 > &Str)
Translates the bytes in Res to a hex string that is deposited into Str.
Definition: MD5.cpp:273
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:614
llvm::Attribute::get
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:92
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1167
llvm::AMDGPUISD::IF
@ IF
Definition: AMDGPUISelLowering.h:347
llvm::createSanitizerCtor
Function * createSanitizerCtor(Module &M, StringRef CtorName)
Creates sanitizer constructor function.
Definition: ModuleUtils.cpp:124
llvm::Function::getEntryBlock
const BasicBlock & getEntryBlock() const
Definition: Function.h:762
llvm::IRBuilder<>
llvm::GlobalVariable
Definition: GlobalVariable.h:40
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:1656
llvm::SmallDenseMap
Definition: DenseMap.h:880
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:321
llvm::GlobalAlias
Definition: GlobalAlias.h:27
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::erase
bool erase(const KeyT &Val)
Definition: DenseMap.h:302
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
Module.h
llvm::AttributeList
Definition: Attributes.h:385
llvm::Optional
Definition: APInt.h:33
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:359
llvm::Data
@ Data
Definition: SIMachineScheduler.h:56
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:122
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::GlobalVariable::hasInitializer
bool hasInitializer() const
Definitions have initializers, declarations don't.
Definition: GlobalVariable.h:92
llvm::ConstantExpr::getPointerCast
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition: Constants.cpp:2032
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::appendToGlobalDtors
void appendToGlobalDtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Same as appendToGlobalCtors(), but for global dtors.
Definition: ModuleUtils.cpp:70
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
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:156
llvm::MD5::final
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
Definition: MD5.cpp:235
llvm::GlobalObject::setSection
void setSection(StringRef S)
Change the section for this global.
Definition: Globals.cpp:212
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
TargetLibraryInfo.h
llvm::appendToCompilerUsed
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
Definition: ModuleUtils.cpp:110
llvm::report_fatal_error
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::Comdat
Definition: Comdat.h:31
llvm::SmallString< 32 >
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
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:136
VI
@ VI
Definition: SIInstrInfo.cpp:7494
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:653
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:134
llvm::IRBuilderBase::getInt32
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:478
llvm::MD5
Definition: MD5.h:41
llvm::declareSanitizerInitFunction
FunctionCallee declareSanitizerInitFunction(Module &M, StringRef InitName, ArrayRef< Type * > InitArgTypes)
Definition: ModuleUtils.cpp:115
appendToGlobalArray
static void appendToGlobalArray(const char *Array, Module &M, Function *F, int Priority, Constant *Data)
Definition: ModuleUtils.cpp:25
llvm::IRBuilderBase::getInt8PtrTy
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
Definition: IRBuilder.h:561
llvm::appendToUsed
void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
Definition: ModuleUtils.cpp:106
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
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:598
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::getOrCreateInitFunction
Function * getOrCreateInitFunction(Module &M, StringRef Name)
Definition: ModuleUtils.cpp:178
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:344
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:212
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:100
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.cpp:148
llvm::Init
Definition: Record.h:271
llvm::StructType::getNumElements
unsigned getNumElements() const
Random access to the elements.
Definition: DerivedTypes.h:329
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::empty
LLVM_NODISCARD bool empty() const
Definition: DenseMap.h:97
llvm::MD5::MD5Result
Definition: MD5.h:55
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::Constant::getNullValue
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Definition: Constants.cpp:346
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end
iterator end()
Definition: DenseMap.h:83
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::GlobalValue::getComdat
const Comdat * getComdat() const
Definition: Globals.cpp:172
Function.h
llvm::Function::addAttribute
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
Definition: Function.cpp:538
llvm::ReturnInst::Create
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
Definition: Instructions.h:2980
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:264
llvm::ConstantArray::get
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1261
llvm::SmallString::str
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:259
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:476
llvm::AttributeList::FunctionIndex
@ FunctionIndex
Definition: Attributes.h:389
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:180
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:2047
ModuleUtils.h
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
llvm::VFABI::MappingsAttrName
static constexpr const char * MappingsAttrName
Definition: VectorUtils.h:195
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:647
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:164
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::CallBase::addAttribute
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
Definition: InstrTypes.h:1492
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:319
DerivedTypes.h
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1478
llvm::IRBuilderBase::getVoidTy
Type * getVoidTy()
Fetch the type representing void.
Definition: IRBuilder.h:556
appendToUsedList
static void appendToUsedList(Module &M, StringRef Name, ArrayRef< GlobalValue * > Values)
Definition: ModuleUtils.cpp:74
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:66
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::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:623
llvm::IRBuilderBase::CreateCall
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2352
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:102
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:364