LLVM 23.0.0git
AMDGPUPrintfRuntimeBinding.cpp
Go to the documentation of this file.
1//=== AMDGPUPrintfRuntimeBinding.cpp - OpenCL printf implementation -------===//
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// \file
9//
10// The pass bind printfs to a kernel arg pointer that will be bound to a buffer
11// later by the runtime.
12//
13// This pass traverses the functions in the module and converts
14// each call to printf to a sequence of operations that
15// store the following into the printf buffer:
16// - format string (passed as a module's metadata unique ID)
17// - bitwise copies of printf arguments
18// The backend passes will need to store metadata in the kernel
19//===----------------------------------------------------------------------===//
20
21#include "AMDGPU.h"
25#include "llvm/IR/Dominators.h"
26#include "llvm/IR/IRBuilder.h"
28#include "llvm/IR/Module.h"
33
34using namespace llvm;
35
36#define DEBUG_TYPE "printfToRuntime"
37enum { DWORD_ALIGN = 4 };
38
39namespace {
40class AMDGPUPrintfRuntimeBinding final : public ModulePass {
41
42public:
43 static char ID;
44
45 explicit AMDGPUPrintfRuntimeBinding() : ModulePass(ID) {}
46
47private:
48 bool runOnModule(Module &M) override;
49};
50
51class AMDGPUPrintfRuntimeBindingImpl {
52public:
53 AMDGPUPrintfRuntimeBindingImpl() = default;
54 bool run(Module &M);
55
56private:
57 void getConversionSpecifiers(SmallVectorImpl<char> &OpConvSpecifiers,
58 StringRef fmt, size_t num_ops) const;
59
60 bool lowerPrintfForGpu(Module &M);
61
62 const DataLayout *TD;
64};
65} // namespace
66
67char AMDGPUPrintfRuntimeBinding::ID = 0;
68
69INITIALIZE_PASS_BEGIN(AMDGPUPrintfRuntimeBinding,
70 "amdgpu-printf-runtime-binding", "AMDGPU Printf lowering",
71 false, false)
74INITIALIZE_PASS_END(AMDGPUPrintfRuntimeBinding, "amdgpu-printf-runtime-binding",
75 "AMDGPU Printf lowering", false, false)
76
77char &llvm::AMDGPUPrintfRuntimeBindingID = AMDGPUPrintfRuntimeBinding::ID;
78
80 return new AMDGPUPrintfRuntimeBinding();
81}
82
83void AMDGPUPrintfRuntimeBindingImpl::getConversionSpecifiers(
84 SmallVectorImpl<char> &OpConvSpecifiers, StringRef Fmt,
85 size_t NumOps) const {
86 // not all format characters are collected.
87 // At this time the format characters of interest
88 // are %p and %s, which use to know if we
89 // are either storing a literal string or a
90 // pointer to the printf buffer.
91 static const char ConvSpecifiers[] = "cdieEfFgGaAosuxXp";
92 size_t CurFmtSpecifierIdx = 0;
93 size_t PrevFmtSpecifierIdx = 0;
94
95 while ((CurFmtSpecifierIdx = Fmt.find_first_of(
96 ConvSpecifiers, CurFmtSpecifierIdx)) != StringRef::npos) {
97 bool ArgDump = false;
98 StringRef CurFmt = Fmt.substr(PrevFmtSpecifierIdx,
99 CurFmtSpecifierIdx - PrevFmtSpecifierIdx);
100 size_t pTag = CurFmt.find_last_of('%');
101 if (pTag != StringRef::npos) {
102 ArgDump = true;
103 while (pTag && CurFmt[--pTag] == '%') {
104 ArgDump = !ArgDump;
105 }
106 }
107
108 if (ArgDump)
109 OpConvSpecifiers.push_back(Fmt[CurFmtSpecifierIdx]);
110
111 PrevFmtSpecifierIdx = ++CurFmtSpecifierIdx;
112 }
113}
114
115static bool shouldPrintAsStr(char Specifier, Type *OpType) {
116 return Specifier == 's' && isa<PointerType>(OpType);
117}
118
120static_assert(NonLiteralStr.size() == 3);
121
123 StringRef S;
124 if (!getConstantStringInfo(V, S))
125 S = NonLiteralStr;
126
127 return S;
128}
129
130static void diagnoseInvalidFormatString(const CallBase *CI) {
132 *CI->getFunction(),
133 "printf format string must be a trivially resolved constant string "
134 "global variable",
135 CI->getDebugLoc()));
136}
137
138bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
139 LLVMContext &Ctx = M.getContext();
140 IRBuilder<> Builder(Ctx);
141 Type *I32Ty = Type::getInt32Ty(Ctx);
142
143 // Instead of creating global variables, the printf format strings are
144 // extracted and passed as metadata. This avoids polluting llvm's symbol
145 // tables in this module. Metadata is going to be extracted by the backend
146 // passes and inserted into the OpenCL binary as appropriate.
147 NamedMDNode *metaD = M.getOrInsertNamedMetadata("llvm.printf.fmts");
148 unsigned UniqID = metaD->getNumOperands();
149
150 for (auto *CI : Printfs) {
151 unsigned NumOps = CI->arg_size();
152
153 SmallString<16> OpConvSpecifiers;
154 Value *Op = CI->getArgOperand(0);
155
156 StringRef FormatStr;
157 if (!getConstantStringInfo(Op, FormatStr)) {
158 Value *Stripped = Op->stripPointerCasts();
159 if (!isa<UndefValue>(Stripped) && !isa<ConstantPointerNull>(Stripped))
161 continue;
162 }
163
164 // We need this call to ascertain that we are printing a string or a
165 // pointer. It takes out the specifiers and fills up the first arg.
166 getConversionSpecifiers(OpConvSpecifiers, FormatStr, NumOps - 1);
167
168 // Add metadata for the string
169 std::string AStreamHolder;
170 raw_string_ostream Sizes(AStreamHolder);
171 int Sum = DWORD_ALIGN;
172 Sizes << CI->arg_size() - 1;
173 Sizes << ':';
174 for (unsigned ArgCount = 1;
175 ArgCount < CI->arg_size() && ArgCount <= OpConvSpecifiers.size();
176 ArgCount++) {
177 Value *Arg = CI->getArgOperand(ArgCount);
178 Type *ArgType = Arg->getType();
179 unsigned ArgSize = TD->getTypeAllocSize(ArgType);
180 //
181 // ArgSize by design should be a multiple of DWORD_ALIGN,
182 // expand the arguments that do not follow this rule.
183 //
184 if (ArgSize % DWORD_ALIGN != 0) {
185 Type *ResType = ArgType->getWithNewType(Type::getInt32Ty(Ctx));
186 Builder.SetInsertPoint(CI);
187 Builder.SetCurrentDebugLocation(CI->getDebugLoc());
188
189 if (ArgType->isFPOrFPVectorTy()) {
190 Arg = Builder.CreateFPExt(
191 Arg, ArgType->getWithNewType(Type::getFloatTy(Ctx)));
192 } else if (OpConvSpecifiers[ArgCount - 1] == 'x' ||
193 OpConvSpecifiers[ArgCount - 1] == 'X' ||
194 OpConvSpecifiers[ArgCount - 1] == 'u' ||
195 OpConvSpecifiers[ArgCount - 1] == 'o')
196 Arg = Builder.CreateZExt(Arg, ResType);
197 else
198 Arg = Builder.CreateSExt(Arg, ResType);
199 ArgType = Arg->getType();
200 ArgSize = TD->getTypeAllocSize(ArgType);
201 CI->setOperand(ArgCount, Arg);
202 }
203 if (OpConvSpecifiers[ArgCount - 1] == 'f') {
204 ConstantFP *FpCons = dyn_cast<ConstantFP>(Arg);
205 if (FpCons)
206 ArgSize = 4;
207 else {
208 FPExtInst *FpExt = dyn_cast<FPExtInst>(Arg);
209 if (FpExt && FpExt->getType()->isDoubleTy() &&
210 FpExt->getOperand(0)->getType()->isFloatTy())
211 ArgSize = 4;
212 }
213 }
214 if (shouldPrintAsStr(OpConvSpecifiers[ArgCount - 1], ArgType))
215 ArgSize = alignTo(getAsConstantStr(Arg).size() + 1, 4);
216
217 LLVM_DEBUG(dbgs() << "Printf ArgSize (in buffer) = " << ArgSize
218 << " for type: " << *ArgType << '\n');
219 Sizes << ArgSize << ':';
220 Sum += ArgSize;
221 }
222 LLVM_DEBUG(dbgs() << "Printf format string in source = " << FormatStr
223 << '\n');
224 for (char C : FormatStr) {
225 // Rest of the C escape sequences (e.g. \') are handled correctly
226 // by the MDParser
227 switch (C) {
228 case '\a':
229 Sizes << "\\a";
230 break;
231 case '\b':
232 Sizes << "\\b";
233 break;
234 case '\f':
235 Sizes << "\\f";
236 break;
237 case '\n':
238 Sizes << "\\n";
239 break;
240 case '\r':
241 Sizes << "\\r";
242 break;
243 case '\v':
244 Sizes << "\\v";
245 break;
246 case ':':
247 // ':' cannot be scanned by Flex, as it is defined as a delimiter
248 // Replace it with it's octal representation \72
249 Sizes << "\\72";
250 break;
251 default:
252 Sizes << C;
253 break;
254 }
255 }
256
257 // Insert the printf_alloc call
258 Builder.SetInsertPoint(CI);
259 Builder.SetCurrentDebugLocation(CI->getDebugLoc());
260
261 AttributeList Attr = AttributeList::get(Ctx, AttributeList::FunctionIndex,
262 Attribute::NoUnwind);
263
264 Type *SizetTy = Type::getInt32Ty(Ctx);
265
266 Type *Tys_alloc[1] = {SizetTy};
267 Type *I8Ty = Type::getInt8Ty(Ctx);
268 Type *I8Ptr = PointerType::get(Ctx, 1);
269 FunctionType *FTy_alloc = FunctionType::get(I8Ptr, Tys_alloc, false);
270 FunctionCallee PrintfAllocFn =
271 M.getOrInsertFunction(StringRef("__printf_alloc"), FTy_alloc, Attr);
272
273 LLVM_DEBUG(dbgs() << "Printf metadata = " << Sizes.str() << '\n');
274 std::string fmtstr = itostr(++UniqID) + ":" + Sizes.str();
275 MDString *fmtStrArray = MDString::get(Ctx, fmtstr);
276
277 MDNode *myMD = MDNode::get(Ctx, fmtStrArray);
278 metaD->addOperand(myMD);
279 Value *sumC = ConstantInt::get(SizetTy, Sum, false);
280 SmallVector<Value *, 1> alloc_args;
281 alloc_args.push_back(sumC);
282 CallInst *pcall = CallInst::Create(PrintfAllocFn, alloc_args,
283 "printf_alloc_fn", CI->getIterator());
284
285 //
286 // Insert code to split basicblock with a
287 // piece of hammock code.
288 // basicblock splits after buffer overflow check
289 //
290 ConstantPointerNull *zeroIntPtr =
291 ConstantPointerNull::get(PointerType::get(Ctx, 1));
292 auto *cmp = cast<ICmpInst>(Builder.CreateICmpNE(pcall, zeroIntPtr, ""));
293 if (!CI->use_empty()) {
294 Value *result =
295 Builder.CreateSExt(Builder.CreateNot(cmp), I32Ty, "printf_res");
296 CI->replaceAllUsesWith(result);
297 }
298 SplitBlock(CI->getParent(), cmp);
299 Instruction *Brnch =
300 SplitBlockAndInsertIfThen(cmp, cmp->getNextNode(), false);
301 BasicBlock::iterator BrnchPoint = Brnch->getIterator();
302
303 Builder.SetInsertPoint(Brnch);
304
305 // store unique printf id in the buffer
306 //
307 GetElementPtrInst *BufferIdx = GetElementPtrInst::Create(
308 I8Ty, pcall, ConstantInt::get(Ctx, APInt(32, 0)), "PrintBuffID",
309 BrnchPoint);
310
311 Type *idPointer = PointerType::get(Ctx, AMDGPUAS::GLOBAL_ADDRESS);
312 Value *id_gep_cast =
313 new BitCastInst(BufferIdx, idPointer, "PrintBuffIdCast", BrnchPoint);
314
315 new StoreInst(ConstantInt::get(I32Ty, UniqID), id_gep_cast, BrnchPoint);
316
317 // 1st 4 bytes hold the printf_id
318 // the following GEP is the buffer pointer
319 BufferIdx = GetElementPtrInst::Create(I8Ty, pcall,
320 ConstantInt::get(Ctx, APInt(32, 4)),
321 "PrintBuffGep", BrnchPoint);
322
323 Type *Int32Ty = Type::getInt32Ty(Ctx);
324 for (unsigned ArgCount = 1;
325 ArgCount < CI->arg_size() && ArgCount <= OpConvSpecifiers.size();
326 ArgCount++) {
327 Value *Arg = CI->getArgOperand(ArgCount);
328 Type *ArgType = Arg->getType();
329 SmallVector<Value *, 32> WhatToStore;
330 if (ArgType->isFPOrFPVectorTy() && !isa<VectorType>(ArgType)) {
331 if (OpConvSpecifiers[ArgCount - 1] == 'f') {
332 if (auto *FpCons = dyn_cast<ConstantFP>(Arg)) {
333 APFloat Val(FpCons->getValueAPF());
334 bool Lost = false;
335 Val.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven,
336 &Lost);
337 Arg = ConstantFP::get(Ctx, Val);
338 } else if (auto *FpExt = dyn_cast<FPExtInst>(Arg)) {
339 if (FpExt->getType()->isDoubleTy() &&
340 FpExt->getOperand(0)->getType()->isFloatTy()) {
341 Arg = FpExt->getOperand(0);
342 }
343 }
344 }
345 WhatToStore.push_back(Arg);
346 } else if (isa<PointerType>(ArgType)) {
347 if (shouldPrintAsStr(OpConvSpecifiers[ArgCount - 1], ArgType)) {
348 StringRef S = getAsConstantStr(Arg);
349 if (!S.empty()) {
350 const uint64_t ReadSize = 4;
351
352 DataExtractor Extractor(S, /*IsLittleEndian=*/true);
353 DataExtractor::Cursor Offset(0);
354 while (Offset && Offset.tell() < S.size()) {
355 uint64_t ReadNow = std::min(ReadSize, S.size() - Offset.tell());
356 uint64_t ReadBytes = 0;
357 switch (ReadNow) {
358 default: llvm_unreachable("min(4, X) > 4?");
359 case 1:
360 ReadBytes = Extractor.getU8(Offset);
361 break;
362 case 2:
363 ReadBytes = Extractor.getU16(Offset);
364 break;
365 case 3:
366 ReadBytes = Extractor.getU24(Offset);
367 break;
368 case 4:
369 ReadBytes = Extractor.getU32(Offset);
370 break;
371 }
372
373 cantFail(Offset.takeError(),
374 "failed to read bytes from constant array");
375
376 APInt IntVal(8 * ReadSize, ReadBytes);
377
378 // TODO: Should not bothering aligning up.
379 if (ReadNow < ReadSize)
380 IntVal = IntVal.zext(8 * ReadSize);
381
382 Type *IntTy = Type::getIntNTy(Ctx, IntVal.getBitWidth());
383 WhatToStore.push_back(ConstantInt::get(IntTy, IntVal));
384 }
385 } else {
386 // Empty string, give a hint to RT it is no NULL
387 Value *ANumV = ConstantInt::get(Int32Ty, 0xFFFFFF00, false);
388 WhatToStore.push_back(ANumV);
389 }
390 } else {
391 WhatToStore.push_back(Arg);
392 }
393 } else {
394 WhatToStore.push_back(Arg);
395 }
396 for (unsigned I = 0, E = WhatToStore.size(); I != E; ++I) {
397 Value *TheBtCast = WhatToStore[I];
398 unsigned ArgSize = TD->getTypeAllocSize(TheBtCast->getType());
399 StoreInst *StBuff = new StoreInst(TheBtCast, BufferIdx, BrnchPoint);
400 LLVM_DEBUG(dbgs() << "inserting store to printf buffer:\n"
401 << *StBuff << '\n');
402 (void)StBuff;
403 if (I + 1 == E && ArgCount + 1 == CI->arg_size())
404 break;
405 BufferIdx = GetElementPtrInst::Create(
406 I8Ty, BufferIdx, {ConstantInt::get(I32Ty, ArgSize)},
407 "PrintBuffNextPtr", BrnchPoint);
408 LLVM_DEBUG(dbgs() << "inserting gep to the printf buffer:\n"
409 << *BufferIdx << '\n');
410 }
411 }
412 }
413
414 // Erase the printf calls and replace all uses with 0, signaling success.
415 // Since OpenCL only specifies undefined behaviors and not success criteria,
416 // returning 0 sinalling success always is valid.
417 for (auto *CI : Printfs) {
418 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 0));
419 CI->eraseFromParent();
420 }
421
422 Printfs.clear();
423 return true;
424}
425
426bool AMDGPUPrintfRuntimeBindingImpl::run(Module &M) {
427 auto *PrintfFunction = M.getFunction("printf");
428 if (!PrintfFunction || !PrintfFunction->isDeclaration() ||
429 M.getModuleFlag("openmp"))
430 return false;
431
432 // Verify the signature of the printf function and skip if it isn't correct.
433 const FunctionType *PrintfFunctionTy = PrintfFunction->getFunctionType();
434 if (PrintfFunctionTy->getNumParams() != 1 || !PrintfFunctionTy->isVarArg() ||
435 !PrintfFunctionTy->getReturnType()->isIntegerTy(32))
436 return false;
437 Type *PrintfFormatArgTy = PrintfFunctionTy->getParamType(0);
438 if (!PrintfFormatArgTy->isPointerTy() ||
440 PrintfFormatArgTy->getPointerAddressSpace()))
441 return false;
442
443 for (auto &U : PrintfFunction->uses()) {
444 if (auto *CI = dyn_cast<CallInst>(U.getUser())) {
445 if (CI->isCallee(&U) && !CI->isNoBuiltin())
446 Printfs.push_back(CI);
447 }
448 }
449
450 if (Printfs.empty())
451 return false;
452
453 TD = &M.getDataLayout();
454
455 return lowerPrintfForGpu(M);
456}
457
458bool AMDGPUPrintfRuntimeBinding::runOnModule(Module &M) {
459 return AMDGPUPrintfRuntimeBindingImpl().run(M);
460}
461
462PreservedAnalyses
464 bool Changed = AMDGPUPrintfRuntimeBindingImpl().run(M);
466}
static void diagnoseInvalidFormatString(const CallBase *CI)
constexpr StringLiteral NonLiteralStr("???")
static StringRef getAsConstantStr(Value *V)
static bool shouldPrintAsStr(char Specifier, Type *OpType)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Module.h This file contains the declarations for the Module class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
#define I(x, y, z)
Definition MD5.cpp:57
Machine Check Debug Module
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
This file contains some functions that are useful when dealing with strings.
#define LLVM_DEBUG(...)
Definition Debug.h:119
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
const APFloat & getValueAPF() const
Definition Constants.h:463
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
LLVM_ABI TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Diagnostic information for unsupported feature in backend.
Legacy analysis pass which computes a DominatorTree.
Definition Dominators.h:310
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1567
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:614
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition Pass.h:255
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
LLVM_ABI unsigned getNumOperands() const
LLVM_ABI void addOperand(MDNode *M)
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition Analysis.h:115
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition StringRef.h:882
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
static constexpr size_t npos
Definition StringRef.h:58
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:591
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
size_t find_last_of(char C, size_t From=npos) const
Find the last character in the string that is C, or npos if not found.
Definition StringRef.h:421
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition StringRef.h:396
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
bool isPointerTy() const
True if this is an instance of PointerType.
Definition Type.h:282
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition Type.h:155
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVM_ABI Type * getWithNewType(Type *EltTy) const
Given vector type, change the element type, whilst keeping the old number of elements.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition Type.h:158
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition Type.h:227
Value * getOperand(unsigned i) const
Definition User.h:207
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:255
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:258
self_iterator getIterator()
Definition ilist_node.h:123
Changed
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ GLOBAL_ADDRESS
Address space for global memory (RAT0, VTX0).
bool isFlatGlobalAddrSpace(unsigned AS)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
DXILDebugInfoMap run(Module &M)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:558
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1668
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
Definition InstrProf.h:328
LLVM_ABI bool getConstantStringInfo(const Value *V, StringRef &Str, bool TrimAtNul=true)
This function computes the length of a null-terminated C string pointed to by V.
char & AMDGPUPrintfRuntimeBindingID
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:144
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
ModulePass * createAMDGPUPrintfRuntimeBinding()
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
LLVM_ABI BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the specified block at the specified instruction.
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVM_ABI Instruction * SplitBlockAndInsertIfThen(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
std::string itostr(int64_t X)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)