LLVM  15.0.0git
NVPTXLowerArgs.cpp
Go to the documentation of this file.
1 //===-- NVPTXLowerArgs.cpp - Lower arguments ------------------------------===//
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 //
10 // Arguments to kernel and device functions are passed via param space,
11 // which imposes certain restrictions:
12 // http://docs.nvidia.com/cuda/parallel-thread-execution/#state-spaces
13 //
14 // Kernel parameters are read-only and accessible only via ld.param
15 // instruction, directly or via a pointer. Pointers to kernel
16 // arguments can't be converted to generic address space.
17 //
18 // Device function parameters are directly accessible via
19 // ld.param/st.param, but taking the address of one returns a pointer
20 // to a copy created in local space which *can't* be used with
21 // ld.param/st.param.
22 //
23 // Copying a byval struct into local memory in IR allows us to enforce
24 // the param space restrictions, gives the rest of IR a pointer w/o
25 // param space restrictions, and gives us an opportunity to eliminate
26 // the copy.
27 //
28 // Pointer arguments to kernel functions need more work to be lowered:
29 //
30 // 1. Convert non-byval pointer arguments of CUDA kernels to pointers in the
31 // global address space. This allows later optimizations to emit
32 // ld.global.*/st.global.* for accessing these pointer arguments. For
33 // example,
34 //
35 // define void @foo(float* %input) {
36 // %v = load float, float* %input, align 4
37 // ...
38 // }
39 //
40 // becomes
41 //
42 // define void @foo(float* %input) {
43 // %input2 = addrspacecast float* %input to float addrspace(1)*
44 // %input3 = addrspacecast float addrspace(1)* %input2 to float*
45 // %v = load float, float* %input3, align 4
46 // ...
47 // }
48 //
49 // Later, NVPTXInferAddressSpaces will optimize it to
50 //
51 // define void @foo(float* %input) {
52 // %input2 = addrspacecast float* %input to float addrspace(1)*
53 // %v = load float, float addrspace(1)* %input2, align 4
54 // ...
55 // }
56 //
57 // 2. Convert pointers in a byval kernel parameter to pointers in the global
58 // address space. As #2, it allows NVPTX to emit more ld/st.global. E.g.,
59 //
60 // struct S {
61 // int *x;
62 // int *y;
63 // };
64 // __global__ void foo(S s) {
65 // int *b = s.y;
66 // // use b
67 // }
68 //
69 // "b" points to the global address space. In the IR level,
70 //
71 // define void @foo({i32*, i32*}* byval %input) {
72 // %b_ptr = getelementptr {i32*, i32*}, {i32*, i32*}* %input, i64 0, i32 1
73 // %b = load i32*, i32** %b_ptr
74 // ; use %b
75 // }
76 //
77 // becomes
78 //
79 // define void @foo({i32*, i32*}* byval %input) {
80 // %b_ptr = getelementptr {i32*, i32*}, {i32*, i32*}* %input, i64 0, i32 1
81 // %b = load i32*, i32** %b_ptr
82 // %b_global = addrspacecast i32* %b to i32 addrspace(1)*
83 // %b_generic = addrspacecast i32 addrspace(1)* %b_global to i32*
84 // ; use %b_generic
85 // }
86 //
87 // TODO: merge this pass with NVPTXInferAddressSpaces so that other passes don't
88 // cancel the addrspacecast pair this pass emits.
89 //===----------------------------------------------------------------------===//
90 
92 #include "NVPTX.h"
93 #include "NVPTXTargetMachine.h"
94 #include "NVPTXUtilities.h"
96 #include "llvm/IR/Function.h"
97 #include "llvm/IR/Instructions.h"
98 #include "llvm/IR/Module.h"
99 #include "llvm/IR/Type.h"
100 #include "llvm/Pass.h"
101 #include <queue>
102 
103 #define DEBUG_TYPE "nvptx-lower-args"
104 
105 using namespace llvm;
106 
107 namespace llvm {
109 }
110 
111 namespace {
112 class NVPTXLowerArgs : public FunctionPass {
113  bool runOnFunction(Function &F) override;
114 
115  bool runOnKernelFunction(Function &F);
116  bool runOnDeviceFunction(Function &F);
117 
118  // handle byval parameters
119  void handleByValParam(Argument *Arg);
120  // Knowing Ptr must point to the global address space, this function
121  // addrspacecasts Ptr to global and then back to generic. This allows
122  // NVPTXInferAddressSpaces to fold the global-to-generic cast into
123  // loads/stores that appear later.
124  void markPointerAsGlobal(Value *Ptr);
125 
126 public:
127  static char ID; // Pass identification, replacement for typeid
128  NVPTXLowerArgs(const NVPTXTargetMachine *TM = nullptr)
129  : FunctionPass(ID), TM(TM) {}
130  StringRef getPassName() const override {
131  return "Lower pointer arguments of CUDA kernels";
132  }
133 
134 private:
135  const NVPTXTargetMachine *TM;
136 };
137 } // namespace
138 
139 char NVPTXLowerArgs::ID = 1;
140 
141 INITIALIZE_PASS(NVPTXLowerArgs, "nvptx-lower-args",
142  "Lower arguments (NVPTX)", false, false)
143 
144 // =============================================================================
145 // If the function had a byval struct ptr arg, say foo(%struct.x* byval %d),
146 // and we can't guarantee that the only accesses are loads,
147 // then add the following instructions to the first basic block:
148 //
149 // %temp = alloca %struct.x, align 8
150 // %tempd = addrspacecast %struct.x* %d to %struct.x addrspace(101)*
151 // %tv = load %struct.x addrspace(101)* %tempd
152 // store %struct.x %tv, %struct.x* %temp, align 8
153 //
154 // The above code allocates some space in the stack and copies the incoming
155 // struct from param space to local space.
156 // Then replace all occurrences of %d by %temp.
157 //
158 // In case we know that all users are GEPs or Loads, replace them with the same
159 // ones in parameter AS, so we can access them using ld.param.
160 // =============================================================================
161 
162 // Replaces the \p OldUser instruction with the same in parameter AS.
163 // Only Load and GEP are supported.
164 static void convertToParamAS(Value *OldUser, Value *Param) {
165  Instruction *I = dyn_cast<Instruction>(OldUser);
166  assert(I && "OldUser must be an instruction");
167  struct IP {
170  };
173 
174  auto CloneInstInParamAS = [](const IP &I) -> Value * {
175  if (auto *LI = dyn_cast<LoadInst>(I.OldInstruction)) {
176  LI->setOperand(0, I.NewParam);
177  return LI;
178  }
179  if (auto *GEP = dyn_cast<GetElementPtrInst>(I.OldInstruction)) {
180  SmallVector<Value *, 4> Indices(GEP->indices());
181  auto *NewGEP = GetElementPtrInst::Create(GEP->getSourceElementType(),
182  I.NewParam, Indices,
183  GEP->getName(), GEP);
184  NewGEP->setIsInBounds(GEP->isInBounds());
185  return NewGEP;
186  }
187  if (auto *BC = dyn_cast<BitCastInst>(I.OldInstruction)) {
188  auto *NewBCType = PointerType::getWithSamePointeeType(
189  cast<PointerType>(BC->getType()), ADDRESS_SPACE_PARAM);
190  return BitCastInst::Create(BC->getOpcode(), I.NewParam, NewBCType,
191  BC->getName(), BC);
192  }
193  if (auto *ASC = dyn_cast<AddrSpaceCastInst>(I.OldInstruction)) {
194  assert(ASC->getDestAddressSpace() == ADDRESS_SPACE_PARAM);
195  (void)ASC;
196  // Just pass through the argument, the old ASC is no longer needed.
197  return I.NewParam;
198  }
199  llvm_unreachable("Unsupported instruction");
200  };
201 
202  while (!ItemsToConvert.empty()) {
203  IP I = ItemsToConvert.pop_back_val();
204  Value *NewInst = CloneInstInParamAS(I);
205 
206  if (NewInst && NewInst != I.OldInstruction) {
207  // We've created a new instruction. Queue users of the old instruction to
208  // be converted and the instruction itself to be deleted. We can't delete
209  // the old instruction yet, because it's still in use by a load somewhere.
211  I.OldInstruction->users(), [NewInst, &ItemsToConvert](Value *V) {
212  ItemsToConvert.push_back({cast<Instruction>(V), NewInst});
213  });
214 
215  InstructionsToDelete.push_back(I.OldInstruction);
216  }
217  }
218 
219  // Now we know that all argument loads are using addresses in parameter space
220  // and we can finally remove the old instructions in generic AS. Instructions
221  // scheduled for removal should be processed in reverse order so the ones
222  // closest to the load are deleted first. Otherwise they may still be in use.
223  // E.g if we have Value = Load(BitCast(GEP(arg))), InstructionsToDelete will
224  // have {GEP,BitCast}. GEP can't be deleted first, because it's still used by
225  // the BitCast.
227  [](Instruction *I) { I->eraseFromParent(); });
228 }
229 
230 // Adjust alignment of arguments passed byval in .param address space. We can
231 // increase alignment of such arguments in a way that ensures that we can
232 // effectively vectorize their loads. We should also traverse all loads from
233 // byval pointer and adjust their alignment, if those were using known offset.
234 // Such alignment changes must be conformed with parameter store and load in
235 // NVPTXTargetLowering::LowerCall.
236 static void adjustByValArgAlignment(Argument *Arg, Value *ArgInParamAS,
237  const NVPTXTargetLowering *TLI) {
238  Function *Func = Arg->getParent();
239  Type *StructType = Arg->getParamByValType();
240  const DataLayout DL(Func->getParent());
241 
242  uint64_t NewArgAlign =
244  uint64_t CurArgAlign =
245  Arg->getAttribute(Attribute::Alignment).getValueAsInt();
246 
247  if (CurArgAlign >= NewArgAlign)
248  return;
249 
250  LLVM_DEBUG(dbgs() << "Try to use alignment " << NewArgAlign << " instead of "
251  << CurArgAlign << " for " << *Arg << '\n');
252 
253  auto NewAlignAttr =
254  Attribute::get(Func->getContext(), Attribute::Alignment, NewArgAlign);
255  Arg->removeAttr(Attribute::Alignment);
256  Arg->addAttr(NewAlignAttr);
257 
258  struct Load {
259  LoadInst *Inst;
261  };
262 
263  struct LoadContext {
264  Value *InitialVal;
266  };
267 
268  SmallVector<Load> Loads;
269  std::queue<LoadContext> Worklist;
270  Worklist.push({ArgInParamAS, 0});
271 
272  while (!Worklist.empty()) {
273  LoadContext Ctx = Worklist.front();
274  Worklist.pop();
275 
276  for (User *CurUser : Ctx.InitialVal->users()) {
277  if (auto *I = dyn_cast<LoadInst>(CurUser)) {
278  Loads.push_back({I, Ctx.Offset});
279  continue;
280  }
281 
282  if (auto *I = dyn_cast<BitCastInst>(CurUser)) {
283  Worklist.push({I, Ctx.Offset});
284  continue;
285  }
286 
287  if (auto *I = dyn_cast<GetElementPtrInst>(CurUser)) {
288  APInt OffsetAccumulated =
289  APInt::getZero(DL.getIndexSizeInBits(ADDRESS_SPACE_PARAM));
290 
291  if (!I->accumulateConstantOffset(DL, OffsetAccumulated))
292  continue;
293 
294  uint64_t OffsetLimit = -1;
295  uint64_t Offset = OffsetAccumulated.getLimitedValue(OffsetLimit);
296  assert(Offset != OffsetLimit && "Expect Offset less than UINT64_MAX");
297 
298  Worklist.push({I, Ctx.Offset + Offset});
299  continue;
300  }
301 
302  llvm_unreachable("All users must be one of: load, "
303  "bitcast, getelementptr.");
304  }
305  }
306 
307  for (Load &CurLoad : Loads) {
308  Align NewLoadAlign(greatestCommonDivisor(NewArgAlign, CurLoad.Offset));
309  Align CurLoadAlign(CurLoad.Inst->getAlign());
310  CurLoad.Inst->setAlignment(std::max(NewLoadAlign, CurLoadAlign));
311  }
312 }
313 
314 void NVPTXLowerArgs::handleByValParam(Argument *Arg) {
315  Function *Func = Arg->getParent();
316  Instruction *FirstInst = &(Func->getEntryBlock().front());
317  Type *StructType = Arg->getParamByValType();
318  assert(StructType && "Missing byval type");
319 
320  auto IsALoadChain = [&](Value *Start) {
321  SmallVector<Value *, 16> ValuesToCheck = {Start};
322  auto IsALoadChainInstr = [](Value *V) -> bool {
323  if (isa<GetElementPtrInst>(V) || isa<BitCastInst>(V) || isa<LoadInst>(V))
324  return true;
325  // ASC to param space are OK, too -- we'll just strip them.
326  if (auto *ASC = dyn_cast<AddrSpaceCastInst>(V)) {
327  if (ASC->getDestAddressSpace() == ADDRESS_SPACE_PARAM)
328  return true;
329  }
330  return false;
331  };
332 
333  while (!ValuesToCheck.empty()) {
334  Value *V = ValuesToCheck.pop_back_val();
335  if (!IsALoadChainInstr(V)) {
336  LLVM_DEBUG(dbgs() << "Need a copy of " << *Arg << " because of " << *V
337  << "\n");
338  (void)Arg;
339  return false;
340  }
341  if (!isa<LoadInst>(V))
342  llvm::append_range(ValuesToCheck, V->users());
343  }
344  return true;
345  };
346 
347  if (llvm::all_of(Arg->users(), IsALoadChain)) {
348  // Convert all loads and intermediate operations to use parameter AS and
349  // skip creation of a local copy of the argument.
350  SmallVector<User *, 16> UsersToUpdate(Arg->users());
351  Value *ArgInParamAS = new AddrSpaceCastInst(
353  FirstInst);
354  llvm::for_each(UsersToUpdate, [ArgInParamAS](Value *V) {
355  convertToParamAS(V, ArgInParamAS);
356  });
357  LLVM_DEBUG(dbgs() << "No need to copy " << *Arg << "\n");
358 
359  // Further optimizations require target lowering info.
360  if (!TM)
361  return;
362 
363  const auto *TLI =
364  cast<NVPTXTargetLowering>(TM->getSubtargetImpl()->getTargetLowering());
365 
366  adjustByValArgAlignment(Arg, ArgInParamAS, TLI);
367 
368  return;
369  }
370 
371  // Otherwise we have to create a temporary copy.
372  const DataLayout &DL = Func->getParent()->getDataLayout();
373  unsigned AS = DL.getAllocaAddrSpace();
374  AllocaInst *AllocA = new AllocaInst(StructType, AS, Arg->getName(), FirstInst);
375  // Set the alignment to alignment of the byval parameter. This is because,
376  // later load/stores assume that alignment, and we are going to replace
377  // the use of the byval parameter with this alloca instruction.
378  AllocA->setAlignment(Func->getParamAlign(Arg->getArgNo())
379  .getValueOr(DL.getPrefTypeAlign(StructType)));
380  Arg->replaceAllUsesWith(AllocA);
381 
382  Value *ArgInParam = new AddrSpaceCastInst(
384  FirstInst);
385  // Be sure to propagate alignment to this load; LLVM doesn't know that NVPTX
386  // addrspacecast preserves alignment. Since params are constant, this load is
387  // definitely not volatile.
388  LoadInst *LI =
389  new LoadInst(StructType, ArgInParam, Arg->getName(),
390  /*isVolatile=*/false, AllocA->getAlign(), FirstInst);
391  new StoreInst(LI, AllocA, FirstInst);
392 }
393 
394 void NVPTXLowerArgs::markPointerAsGlobal(Value *Ptr) {
396  return;
397 
398  // Deciding where to emit the addrspacecast pair.
399  BasicBlock::iterator InsertPt;
400  if (Argument *Arg = dyn_cast<Argument>(Ptr)) {
401  // Insert at the functon entry if Ptr is an argument.
402  InsertPt = Arg->getParent()->getEntryBlock().begin();
403  } else {
404  // Insert right after Ptr if Ptr is an instruction.
405  InsertPt = ++cast<Instruction>(Ptr)->getIterator();
406  assert(InsertPt != InsertPt->getParent()->end() &&
407  "We don't call this function with Ptr being a terminator.");
408  }
409 
410  Instruction *PtrInGlobal = new AddrSpaceCastInst(
411  Ptr,
412  PointerType::getWithSamePointeeType(cast<PointerType>(Ptr->getType()),
414  Ptr->getName(), &*InsertPt);
415  Value *PtrInGeneric = new AddrSpaceCastInst(PtrInGlobal, Ptr->getType(),
416  Ptr->getName(), &*InsertPt);
417  // Replace with PtrInGeneric all uses of Ptr except PtrInGlobal.
418  Ptr->replaceAllUsesWith(PtrInGeneric);
419  PtrInGlobal->setOperand(0, Ptr);
420 }
421 
422 // =============================================================================
423 // Main function for this pass.
424 // =============================================================================
425 bool NVPTXLowerArgs::runOnKernelFunction(Function &F) {
426  if (TM && TM->getDrvInterface() == NVPTX::CUDA) {
427  // Mark pointers in byval structs as global.
428  for (auto &B : F) {
429  for (auto &I : B) {
430  if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
431  if (LI->getType()->isPointerTy()) {
432  Value *UO = getUnderlyingObject(LI->getPointerOperand());
433  if (Argument *Arg = dyn_cast<Argument>(UO)) {
434  if (Arg->hasByValAttr()) {
435  // LI is a load from a pointer within a byval kernel parameter.
436  markPointerAsGlobal(LI);
437  }
438  }
439  }
440  }
441  }
442  }
443  }
444 
445  LLVM_DEBUG(dbgs() << "Lowering kernel args of " << F.getName() << "\n");
446  for (Argument &Arg : F.args()) {
447  if (Arg.getType()->isPointerTy()) {
448  if (Arg.hasByValAttr())
449  handleByValParam(&Arg);
450  else if (TM && TM->getDrvInterface() == NVPTX::CUDA)
451  markPointerAsGlobal(&Arg);
452  }
453  }
454  return true;
455 }
456 
457 // Device functions only need to copy byval args into local memory.
458 bool NVPTXLowerArgs::runOnDeviceFunction(Function &F) {
459  LLVM_DEBUG(dbgs() << "Lowering function args of " << F.getName() << "\n");
460  for (Argument &Arg : F.args())
461  if (Arg.getType()->isPointerTy() && Arg.hasByValAttr())
462  handleByValParam(&Arg);
463  return true;
464 }
465 
467  return isKernelFunction(F) ? runOnKernelFunction(F) : runOnDeviceFunction(F);
468 }
469 
470 FunctionPass *
472  return new NVPTXLowerArgs(TM);
473 }
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:28
llvm::NVPTXTargetLowering::getFunctionParamOptimizedAlign
Align getFunctionParamOptimizedAlign(const Function *F, Type *ArgTy, const DataLayout &DL) const
getFunctionParamOptimizedAlign - since function arguments are passed via .param space,...
Definition: NVPTXISelLowering.cpp:4265
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:87
llvm::AllocaInst::getAlign
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Definition: Instructions.h:121
llvm::Function
Definition: Function.h:60
Pass.h
llvm::greatestCommonDivisor
T greatestCommonDivisor(T A, T B)
Return the greatest common divisor of the values using Euclid's algorithm.
Definition: MathExtras.h:648
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1185
llvm::Type::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:729
llvm::CastInst::Create
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
Definition: Instructions.cpp:3180
llvm::ADDRESS_SPACE_PARAM
@ ADDRESS_SPACE_PARAM
Definition: NVPTXBaseInfo.h:29
InstructionsToDelete
SmallVector< Instruction * > InstructionsToDelete
Definition: NVPTXLowerArgs.cpp:172
ValueTracking.h
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::reverse
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
Definition: STLExtras.h:380
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:79
IP::NewParam
Value * NewParam
Definition: NVPTXLowerArgs.cpp:169
llvm::createNVPTXLowerArgsPass
FunctionPass * createNVPTXLowerArgsPass(const NVPTXTargetMachine *TM)
Definition: NVPTXLowerArgs.cpp:471
llvm::SmallVectorImpl::pop_back_val
LLVM_NODISCARD T pop_back_val()
Definition: SmallVector.h:654
llvm::NVPTXTargetMachine
NVPTXTargetMachine.
Definition: NVPTXTargetMachine.h:25
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
F
#define F(x, y, z)
Definition: MD5.cpp:55
NVPTX.h
CloneInstInParamAS
auto CloneInstInParamAS
Definition: NVPTXLowerArgs.cpp:174
NVPTXUtilities.h
assert
assert(I &&"OldUser must be an instruction")
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:186
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
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:1607
llvm::AddrSpaceCastInst
This class represents a conversion between pointers from one address space to another.
Definition: Instructions.h:5265
llvm::User
Definition: User.h:44
llvm::ADDRESS_SPACE_GLOBAL
@ ADDRESS_SPACE_GLOBAL
Definition: NVPTXBaseInfo.h:23
Param
Value * Param
Definition: NVPTXLowerArgs.cpp:164
llvm::APInt::getLimitedValue
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
Definition: APInt.h:456
IP
Definition: NVPTXLowerArgs.cpp:167
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::Instruction
Definition: Instruction.h:42
IP::OldInstruction
Instruction * OldInstruction
Definition: NVPTXLowerArgs.cpp:168
llvm::PassRegistry
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
llvm::getUnderlyingObject
const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value,...
Definition: ValueTracking.cpp:4362
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Type.h
llvm::isKernelFunction
bool isKernelFunction(const Function &F)
Definition: NVPTXUtilities.cpp:274
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:305
uint64_t
llvm::for_each
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1600
NVPTXBaseInfo.h
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::User::setOperand
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
llvm::GetElementPtrInst::Create
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Definition: Instructions.h:955
INITIALIZE_PASS
INITIALIZE_PASS(NVPTXLowerArgs, "nvptx-lower-args", "Lower arguments (NVPTX)", false, false) static void convertToParamAS(Value *OldUser
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:58
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:529
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1813
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::ifs::IFSSymbolType::Func
@ Func
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:305
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:176
llvm::NVPTXTargetLowering
Definition: NVPTXISelLowering.h:440
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition: EntryExitInstrumenter.cpp:69
llvm::NVPTX::CUDA
@ CUDA
Definition: NVPTX.h:72
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
adjustByValArgAlignment
static void adjustByValArgAlignment(Argument *Arg, Value *ArgInParamAS, const NVPTXTargetLowering *TLI)
Definition: NVPTXLowerArgs.cpp:236
NVPTXTargetMachine.h
Function.h
llvm::AllocaInst::setAlignment
void setAlignment(Align Align)
Definition: Instructions.h:125
Instructions.h
llvm::PointerType::getWithSamePointeeType
static PointerType * getWithSamePointeeType(PointerType *PT, unsigned AddressSpace)
This constructs a pointer type with the same pointee type as input PointerType (or opaque pointer is ...
Definition: DerivedTypes.h:666
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::initializeNVPTXLowerArgsPass
void initializeNVPTXLowerArgsPass(PassRegistry &)
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
GEP
Hexagon Common GEP
Definition: HexagonCommonGEP.cpp:172
ItemsToConvert
SmallVector< IP > ItemsToConvert
Definition: NVPTXLowerArgs.cpp:171
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:58
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37