LLVM  6.0.0svn
AMDGPURewriteOutArguments.cpp
Go to the documentation of this file.
1 //===- AMDGPURewriteOutArgumentsPass.cpp - Create struct returns ----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file This pass attempts to replace out argument usage with a return of a
11 /// struct.
12 ///
13 /// We can support returning a lot of values directly in registers, but
14 /// idiomatic C code frequently uses a pointer argument to return a second value
15 /// rather than returning a struct by value. GPU stack access is also quite
16 /// painful, so we want to avoid that if possible. Passing a stack object
17 /// pointer to a function also requires an additional address expansion code
18 /// sequence to convert the pointer to be relative to the kernel's scratch wave
19 /// offset register since the callee doesn't know what stack frame the incoming
20 /// pointer is relative to.
21 ///
22 /// The goal is to try rewriting code that looks like this:
23 ///
24 /// int foo(int a, int b, int* out) {
25 /// *out = bar();
26 /// return a + b;
27 /// }
28 ///
29 /// into something like this:
30 ///
31 /// std::pair<int, int> foo(int a, int b) {
32 /// return std::make_pair(a + b, bar());
33 /// }
34 ///
35 /// Typically the incoming pointer is a simple alloca for a temporary variable
36 /// to use the API, which if replaced with a struct return will be easily SROA'd
37 /// out when the stub function we create is inlined
38 ///
39 /// This pass introduces the struct return, but leaves the unused pointer
40 /// arguments and introduces a new stub function calling the struct returning
41 /// body. DeadArgumentElimination should be run after this to clean these up.
42 //
43 //===----------------------------------------------------------------------===//
44 
45 #include "AMDGPU.h"
46 #include "Utils/AMDGPUBaseInfo.h"
48 #include "llvm/ADT/DenseMap.h"
49 #include "llvm/ADT/STLExtras.h"
50 #include "llvm/ADT/SmallSet.h"
51 #include "llvm/ADT/SmallVector.h"
52 #include "llvm/ADT/Statistic.h"
54 #include "llvm/IR/Argument.h"
55 #include "llvm/IR/Attributes.h"
56 #include "llvm/IR/BasicBlock.h"
57 #include "llvm/IR/Constants.h"
58 #include "llvm/IR/DataLayout.h"
59 #include "llvm/IR/DerivedTypes.h"
60 #include "llvm/IR/Function.h"
61 #include "llvm/IR/IRBuilder.h"
62 #include "llvm/IR/Instructions.h"
63 #include "llvm/IR/Module.h"
64 #include "llvm/IR/Type.h"
65 #include "llvm/IR/Use.h"
66 #include "llvm/IR/User.h"
67 #include "llvm/IR/Value.h"
68 #include "llvm/Pass.h"
69 #include "llvm/Support/Casting.h"
71 #include "llvm/Support/Debug.h"
73 #include <cassert>
74 #include <utility>
75 
76 #define DEBUG_TYPE "amdgpu-rewrite-out-arguments"
77 
78 using namespace llvm;
79 
81  "amdgpu-any-address-space-out-arguments",
82  cl::desc("Replace pointer out arguments with "
83  "struct returns for non-private address space"),
84  cl::Hidden,
85  cl::init(false));
86 
88  "amdgpu-max-return-arg-num-regs",
89  cl::desc("Approximately limit number of return registers for replacing out arguments"),
90  cl::Hidden,
91  cl::init(16));
92 
93 STATISTIC(NumOutArgumentsReplaced,
94  "Number out arguments moved to struct return values");
95 STATISTIC(NumOutArgumentFunctionsReplaced,
96  "Number of functions with out arguments moved to struct return values");
97 
98 namespace {
99 
100 class AMDGPURewriteOutArguments : public FunctionPass {
101 private:
102  const DataLayout *DL = nullptr;
103  MemoryDependenceResults *MDA = nullptr;
104 
105  bool checkArgumentUses(Value &Arg) const;
106  bool isOutArgumentCandidate(Argument &Arg) const;
107 
108 #ifndef NDEBUG
109  bool isVec3ToVec4Shuffle(Type *Ty0, Type* Ty1) const;
110 #endif
111 
112 public:
113  static char ID;
114 
115  AMDGPURewriteOutArguments() : FunctionPass(ID) {}
116 
117  void getAnalysisUsage(AnalysisUsage &AU) const override {
120  }
121 
122  bool doInitialization(Module &M) override;
123  bool runOnFunction(Function &F) override;
124 };
125 
126 } // end anonymous namespace
127 
128 INITIALIZE_PASS_BEGIN(AMDGPURewriteOutArguments, DEBUG_TYPE,
129  "AMDGPU Rewrite Out Arguments", false, false)
131 INITIALIZE_PASS_END(AMDGPURewriteOutArguments, DEBUG_TYPE,
132  "AMDGPU Rewrite Out Arguments", false, false)
133 
134 char AMDGPURewriteOutArguments::ID = 0;
135 
136 bool AMDGPURewriteOutArguments::checkArgumentUses(Value &Arg) const {
137  const int MaxUses = 10;
138  int UseCount = 0;
139 
140  for (Use &U : Arg.uses()) {
141  StoreInst *SI = dyn_cast<StoreInst>(U.getUser());
142  if (UseCount > MaxUses)
143  return false;
144 
145  if (!SI) {
146  auto *BCI = dyn_cast<BitCastInst>(U.getUser());
147  if (!BCI || !BCI->hasOneUse())
148  return false;
149 
150  // We don't handle multiple stores currently, so stores to aggregate
151  // pointers aren't worth the trouble since they are canonically split up.
152  Type *DestEltTy = BCI->getType()->getPointerElementType();
153  if (DestEltTy->isAggregateType())
154  return false;
155 
156  // We could handle these if we had a convenient way to bitcast between
157  // them.
158  Type *SrcEltTy = Arg.getType()->getPointerElementType();
159  if (SrcEltTy->isArrayTy())
160  return false;
161 
162  // Special case handle structs with single members. It is useful to handle
163  // some casts between structs and non-structs, but we can't bitcast
164  // directly between them. directly bitcast between them. Blender uses
165  // some casts that look like { <3 x float> }* to <4 x float>*
166  if ((SrcEltTy->isStructTy() && (SrcEltTy->getNumContainedTypes() != 1)))
167  return false;
168 
169  // Clang emits OpenCL 3-vector type accesses with a bitcast to the
170  // equivalent 4-element vector and accesses that, and we're looking for
171  // this pointer cast.
172  if (DL->getTypeAllocSize(SrcEltTy) != DL->getTypeAllocSize(DestEltTy))
173  return false;
174 
175  return checkArgumentUses(*BCI);
176  }
177 
178  if (!SI->isSimple() ||
179  U.getOperandNo() != StoreInst::getPointerOperandIndex())
180  return false;
181 
182  ++UseCount;
183  }
184 
185  // Skip unused arguments.
186  return UseCount > 0;
187 }
188 
189 bool AMDGPURewriteOutArguments::isOutArgumentCandidate(Argument &Arg) const {
190  const unsigned MaxOutArgSizeBytes = 4 * MaxNumRetRegs;
191  PointerType *ArgTy = dyn_cast<PointerType>(Arg.getType());
192 
193  // TODO: It might be useful for any out arguments, not just privates.
194  if (!ArgTy || (ArgTy->getAddressSpace() != DL->getAllocaAddrSpace() &&
195  !AnyAddressSpace) ||
196  Arg.hasByValAttr() || Arg.hasStructRetAttr() ||
197  DL->getTypeStoreSize(ArgTy->getPointerElementType()) > MaxOutArgSizeBytes) {
198  return false;
199  }
200 
201  return checkArgumentUses(Arg);
202 }
203 
204 bool AMDGPURewriteOutArguments::doInitialization(Module &M) {
205  DL = &M.getDataLayout();
206  return false;
207 }
208 
209 #ifndef NDEBUG
210 bool AMDGPURewriteOutArguments::isVec3ToVec4Shuffle(Type *Ty0, Type* Ty1) const {
211  VectorType *VT0 = dyn_cast<VectorType>(Ty0);
212  VectorType *VT1 = dyn_cast<VectorType>(Ty1);
213  if (!VT0 || !VT1)
214  return false;
215 
216  if (VT0->getNumElements() != 3 ||
217  VT1->getNumElements() != 4)
218  return false;
219 
220  return DL->getTypeSizeInBits(VT0->getElementType()) ==
221  DL->getTypeSizeInBits(VT1->getElementType());
222 }
223 #endif
224 
226  if (skipFunction(F))
227  return false;
228 
229  // TODO: Could probably handle variadic functions.
230  if (F.isVarArg() || F.hasStructRetAttr() ||
232  return false;
233 
234  MDA = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
235 
236  unsigned ReturnNumRegs = 0;
237  SmallSet<int, 4> OutArgIndexes;
238  SmallVector<Type *, 4> ReturnTypes;
239  Type *RetTy = F.getReturnType();
240  if (!RetTy->isVoidTy()) {
241  ReturnNumRegs = DL->getTypeStoreSize(RetTy) / 4;
242 
243  if (ReturnNumRegs >= MaxNumRetRegs)
244  return false;
245 
246  ReturnTypes.push_back(RetTy);
247  }
248 
250  for (Argument &Arg : F.args()) {
251  if (isOutArgumentCandidate(Arg)) {
252  DEBUG(dbgs() << "Found possible out argument " << Arg
253  << " in function " << F.getName() << '\n');
254  OutArgs.push_back(&Arg);
255  }
256  }
257 
258  if (OutArgs.empty())
259  return false;
260 
261  using ReplacementVec = SmallVector<std::pair<Argument *, Value *>, 4>;
262 
264 
266  for (BasicBlock &BB : F) {
267  if (ReturnInst *RI = dyn_cast<ReturnInst>(&BB.back()))
268  Returns.push_back(RI);
269  }
270 
271  if (Returns.empty())
272  return false;
273 
274  bool Changing;
275 
276  do {
277  Changing = false;
278 
279  // Keep retrying if we are able to successfully eliminate an argument. This
280  // helps with cases with multiple arguments which may alias, such as in a
281  // sincos implemntation. If we have 2 stores to arguments, on the first
282  // attempt the MDA query will succeed for the second store but not the
283  // first. On the second iteration we've removed that out clobbering argument
284  // (by effectively moving it into another function) and will find the second
285  // argument is OK to move.
286  for (Argument *OutArg : OutArgs) {
287  bool ThisReplaceable = true;
289 
290  Type *ArgTy = OutArg->getType()->getPointerElementType();
291 
292  // Skip this argument if converting it will push us over the register
293  // count to return limit.
294 
295  // TODO: This is an approximation. When legalized this could be more. We
296  // can ask TLI for exactly how many.
297  unsigned ArgNumRegs = DL->getTypeStoreSize(ArgTy) / 4;
298  if (ArgNumRegs + ReturnNumRegs > MaxNumRetRegs)
299  continue;
300 
301  // An argument is convertible only if all exit blocks are able to replace
302  // it.
303  for (ReturnInst *RI : Returns) {
304  BasicBlock *BB = RI->getParent();
305 
306  MemDepResult Q = MDA->getPointerDependencyFrom(MemoryLocation(OutArg),
307  true, BB->end(), BB, RI);
308  StoreInst *SI = nullptr;
309  if (Q.isDef())
310  SI = dyn_cast<StoreInst>(Q.getInst());
311 
312  if (SI) {
313  DEBUG(dbgs() << "Found out argument store: " << *SI << '\n');
314  ReplaceableStores.emplace_back(RI, SI);
315  } else {
316  ThisReplaceable = false;
317  break;
318  }
319  }
320 
321  if (!ThisReplaceable)
322  continue; // Try the next argument candidate.
323 
324  for (std::pair<ReturnInst *, StoreInst *> Store : ReplaceableStores) {
325  Value *ReplVal = Store.second->getValueOperand();
326 
327  auto &ValVec = Replacements[Store.first];
328  if (llvm::find_if(ValVec,
329  [OutArg](const std::pair<Argument *, Value *> &Entry) {
330  return Entry.first == OutArg;}) != ValVec.end()) {
331  DEBUG(dbgs() << "Saw multiple out arg stores" << *OutArg << '\n');
332  // It is possible to see stores to the same argument multiple times,
333  // but we expect these would have been optimized out already.
334  ThisReplaceable = false;
335  break;
336  }
337 
338  ValVec.emplace_back(OutArg, ReplVal);
339  Store.second->eraseFromParent();
340  }
341 
342  if (ThisReplaceable) {
343  ReturnTypes.push_back(ArgTy);
344  OutArgIndexes.insert(OutArg->getArgNo());
345  ++NumOutArgumentsReplaced;
346  Changing = true;
347  }
348  }
349  } while (Changing);
350 
351  if (Replacements.empty())
352  return false;
353 
354  LLVMContext &Ctx = F.getParent()->getContext();
355  StructType *NewRetTy = StructType::create(Ctx, ReturnTypes, F.getName());
356 
357  FunctionType *NewFuncTy = FunctionType::get(NewRetTy,
358  F.getFunctionType()->params(),
359  F.isVarArg());
360 
361  DEBUG(dbgs() << "Computed new return type: " << *NewRetTy << '\n');
362 
363  Function *NewFunc = Function::Create(NewFuncTy, Function::PrivateLinkage,
364  F.getName() + ".body");
365  F.getParent()->getFunctionList().insert(F.getIterator(), NewFunc);
366  NewFunc->copyAttributesFrom(&F);
367  NewFunc->setComdat(F.getComdat());
368 
369  // We want to preserve the function and param attributes, but need to strip
370  // off any return attributes, e.g. zeroext doesn't make sense with a struct.
371  NewFunc->stealArgumentListFrom(F);
372 
373  AttrBuilder RetAttrs;
374  RetAttrs.addAttribute(Attribute::SExt);
375  RetAttrs.addAttribute(Attribute::ZExt);
377  NewFunc->removeAttributes(AttributeList::ReturnIndex, RetAttrs);
378  // TODO: How to preserve metadata?
379 
380  // Move the body of the function into the new rewritten function, and replace
381  // this function with a stub.
382  NewFunc->getBasicBlockList().splice(NewFunc->begin(), F.getBasicBlockList());
383 
384  for (std::pair<ReturnInst *, ReplacementVec> &Replacement : Replacements) {
385  ReturnInst *RI = Replacement.first;
386  IRBuilder<> B(RI);
388 
389  int RetIdx = 0;
390  Value *NewRetVal = UndefValue::get(NewRetTy);
391 
392  Value *RetVal = RI->getReturnValue();
393  if (RetVal)
394  NewRetVal = B.CreateInsertValue(NewRetVal, RetVal, RetIdx++);
395 
396  for (std::pair<Argument *, Value *> ReturnPoint : Replacement.second) {
397  Argument *Arg = ReturnPoint.first;
398  Value *Val = ReturnPoint.second;
399  Type *EltTy = Arg->getType()->getPointerElementType();
400  if (Val->getType() != EltTy) {
401  Type *EffectiveEltTy = EltTy;
402  if (StructType *CT = dyn_cast<StructType>(EltTy)) {
403  assert(CT->getNumContainedTypes() == 1);
404  EffectiveEltTy = CT->getContainedType(0);
405  }
406 
407  if (DL->getTypeSizeInBits(EffectiveEltTy) !=
408  DL->getTypeSizeInBits(Val->getType())) {
409  assert(isVec3ToVec4Shuffle(EffectiveEltTy, Val->getType()));
410  Val = B.CreateShuffleVector(Val, UndefValue::get(Val->getType()),
411  { 0, 1, 2 });
412  }
413 
414  Val = B.CreateBitCast(Val, EffectiveEltTy);
415 
416  // Re-create single element composite.
417  if (EltTy != EffectiveEltTy)
418  Val = B.CreateInsertValue(UndefValue::get(EltTy), Val, 0);
419  }
420 
421  NewRetVal = B.CreateInsertValue(NewRetVal, Val, RetIdx++);
422  }
423 
424  if (RetVal)
425  RI->setOperand(0, NewRetVal);
426  else {
427  B.CreateRet(NewRetVal);
428  RI->eraseFromParent();
429  }
430  }
431 
432  SmallVector<Value *, 16> StubCallArgs;
433  for (Argument &Arg : F.args()) {
434  if (OutArgIndexes.count(Arg.getArgNo())) {
435  // It's easier to preserve the type of the argument list. We rely on
436  // DeadArgumentElimination to take care of these.
437  StubCallArgs.push_back(UndefValue::get(Arg.getType()));
438  } else {
439  StubCallArgs.push_back(&Arg);
440  }
441  }
442 
443  BasicBlock *StubBB = BasicBlock::Create(Ctx, "", &F);
444  IRBuilder<> B(StubBB);
445  CallInst *StubCall = B.CreateCall(NewFunc, StubCallArgs);
446 
447  int RetIdx = RetTy->isVoidTy() ? 0 : 1;
448  for (Argument &Arg : F.args()) {
449  if (!OutArgIndexes.count(Arg.getArgNo()))
450  continue;
451 
452  PointerType *ArgType = cast<PointerType>(Arg.getType());
453 
454  auto *EltTy = ArgType->getElementType();
455  unsigned Align = Arg.getParamAlignment();
456  if (Align == 0)
457  Align = DL->getABITypeAlignment(EltTy);
458 
459  Value *Val = B.CreateExtractValue(StubCall, RetIdx++);
460  Type *PtrTy = Val->getType()->getPointerTo(ArgType->getAddressSpace());
461 
462  // We can peek through bitcasts, so the type may not match.
463  Value *PtrVal = B.CreateBitCast(&Arg, PtrTy);
464 
465  B.CreateAlignedStore(Val, PtrVal, Align);
466  }
467 
468  if (!RetTy->isVoidTy()) {
469  B.CreateRet(B.CreateExtractValue(StubCall, 0));
470  } else {
471  B.CreateRetVoid();
472  }
473 
474  // The function is now a stub we want to inline.
475  F.addFnAttr(Attribute::AlwaysInline);
476 
477  ++NumOutArgumentFunctionsReplaced;
478  return true;
479 }
480 
482  return new AMDGPURewriteOutArguments();
483 }
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Definition: Function.h:158
#define DEBUG_TYPE
Return a value (possibly void), from a function.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks &#39;this&#39; from the containing basic block and deletes it.
Definition: Instruction.cpp:69
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Provides a lazy, caching interface for making common memory aliasing information queries, backed by LLVM&#39;s alias analysis passes.
This class represents an incoming formal argument to a Function.
Definition: Argument.h:30
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
AMDGPU Rewrite Out Arguments
This class represents a function call, abstracting a target machine&#39;s calling convention.
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:57
STATISTIC(NumFunctions, "Total number of functions")
The two locations do not alias at all.
Definition: AliasAnalysis.h:85
F(f)
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
This defines the Use class.
bool hasByValAttr() const
Return true if this argument has the byval attribute.
Definition: Function.cpp:88
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
Definition: IRBuilder.h:1203
bool hasStructRetAttr() const
Determine if the function returns a structure through first or second pointer argument.
Definition: Function.h:511
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:51
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
Type * getPointerElementType() const
Definition: Type.h:373
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:361
Class to represent struct types.
Definition: DerivedTypes.h:201
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
Definition: Type.cpp:639
ReturnInst * CreateRet(Value *V)
Create a &#39;ret <val>&#39; instruction.
Definition: IRBuilder.h:754
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:668
This file contains the simple types necessary to represent the attributes associated with functions a...
uint64_t getNumElements() const
Definition: DerivedTypes.h:359
INITIALIZE_PASS_BEGIN(AMDGPURewriteOutArguments, DEBUG_TYPE, "AMDGPU Rewrite Out Arguments", false, false) INITIALIZE_PASS_END(AMDGPURewriteOutArguments
Class to represent function types.
Definition: DerivedTypes.h:103
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1448
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: Pass.cpp:91
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
void setComdat(Comdat *C)
Definition: GlobalObject.h:103
This class represents a no-op cast from one type to another.
An instruction for storing to memory.
Definition: Instructions.h:306
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Definition: IRBuilder.h:152
iterator begin()
Definition: Function.h:588
Class to represent pointers.
Definition: DerivedTypes.h:467
FunctionPass * createAMDGPURewriteOutArgumentsPass()
bool isVoidTy() const
Return true if this is &#39;void&#39;.
Definition: Type.h:141
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:406
Type * getReturnType() const
Returns the type of the ret val.
Definition: Function.h:150
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
Definition: Function.cpp:280
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const FunctionListType & getFunctionList() const
Get the Module&#39;s list of functions (constant).
Definition: Module.h:507
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
static cl::opt< bool > AnyAddressSpace("amdgpu-any-address-space-out-arguments", cl::desc("Replace pointer out arguments with " "struct returns for non-private address space"), cl::Hidden, cl::init(false))
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
static unsigned getPointerOperandIndex()
Definition: Instructions.h:400
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
Definition: Function.cpp:145
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
Definition: Type.h:336
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Definition: Function.cpp:463
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:36
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isEntryFunctionCC(CallingConv::ID CC)
Represent the analysis usage information of a pass.
void splice(iterator where, iplist_impl &L2)
Definition: ilist.h:342
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:285
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:297
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:495
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:101
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn&#39;t already there.
Definition: SmallSet.h:81
static UndefValue * get(Type *T)
Static factory methods - Return an &#39;undef&#39; object of the specified type.
Definition: Constants.cpp:1320
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition: IRBuilder.h:1755
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
A memory dependence query can return one of three different answers.
Representation for a specific memory location.
static cl::opt< unsigned > MaxNumRetRegs("amdgpu-max-return-arg-num-regs", cl::desc("Approximately limit number of return registers for replacing out arguments"), cl::Hidden, cl::init(16))
iterator end()
Definition: BasicBlock.h:254
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:194
unsigned getParamAlignment() const
If this is a byval or inalloca argument, return its alignment.
Definition: Function.cpp:113
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:864
Module.h This file contains the declarations for the Module class.
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition: Type.h:255
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Definition: IRBuilder.h:1740
void setOperand(unsigned i, Value *Val)
Definition: User.h:159
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
Class to represent vector types.
Definition: DerivedTypes.h:393
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Definition: Argument.h:48
amdgpu Simplify well known AMD library false Value Value * Arg
void removeAttributes(unsigned i, const AttrBuilder &Attrs)
removes the attributes from the list of attributes.
Definition: Function.cpp:395
ReturnInst * CreateRetVoid()
Create a &#39;ret void&#39; instruction.
Definition: IRBuilder.h:749
iterator insert(iterator where, pointer New)
Definition: ilist.h:241
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:284
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
void emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:656
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:61
This file provides utility analysis objects describing memory locations.
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:220
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:108
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
Definition: Function.h:565
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:556
LLVM Value Representation.
Definition: Value.h:73
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition: Type.cpp:424
#define DEBUG(X)
Definition: Debug.h:118
Type * getElementType() const
Definition: DerivedTypes.h:360
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
Definition: Function.h:136
bool isSimple() const
Definition: Instructions.h:387
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition: IRBuilder.h:1763
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:795
Type * getElementType() const
Definition: DerivedTypes.h:486
iterator_range< arg_iterator > args()
Definition: Function.h:621
bool isStructTy() const
True if this is an instance of StructType.
Definition: Type.h:215
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition: Type.h:218
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
Definition: Type.h:330
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1663
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
Definition: SmallSet.h:65