LLVM 24.0.0git
SanitizerBinaryMetadata.cpp
Go to the documentation of this file.
1//===- SanitizerBinaryMetadata.cpp - binary analysis sanitizers metadata --===//
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 file is a part of SanitizerBinaryMetadata.
10//
11//===----------------------------------------------------------------------===//
12
15#include "llvm/ADT/SetVector.h"
17#include "llvm/ADT/Statistic.h"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/ADT/Twine.h"
24#include "llvm/IR/Constant.h"
26#include "llvm/IR/Function.h"
27#include "llvm/IR/GlobalValue.h"
29#include "llvm/IR/IRBuilder.h"
30#include "llvm/IR/Instruction.h"
32#include "llvm/IR/LLVMContext.h"
33#include "llvm/IR/MDBuilder.h"
34#include "llvm/IR/Metadata.h"
35#include "llvm/IR/Module.h"
36#include "llvm/IR/Type.h"
37#include "llvm/IR/Value.h"
45
46#include <array>
47#include <cstdint>
48#include <memory>
49
50using namespace llvm;
51
52#define DEBUG_TYPE "sanmd"
53
54namespace {
55
56//===--- Constants --------------------------------------------------------===//
57
58constexpr uint32_t kVersionBase = 2; // occupies lower 16 bits
59constexpr uint32_t kVersionPtrSizeRel = (1u << 16); // offsets are pointer-sized
60constexpr int kCtorDtorPriority = 2;
61
62// Pairs of names of initialization callback functions and which section
63// contains the relevant metadata.
64class MetadataInfo {
65public:
66 const StringRef FunctionPrefix;
67 const StringRef SectionSuffix;
68
69 static const MetadataInfo Covered;
70 static const MetadataInfo Atomics;
71
72private:
73 // Forbid construction elsewhere.
74 explicit constexpr MetadataInfo(StringRef FunctionPrefix,
75 StringRef SectionSuffix)
76 : FunctionPrefix(FunctionPrefix), SectionSuffix(SectionSuffix) {}
77};
78const MetadataInfo MetadataInfo::Covered{
79 "__sanitizer_metadata_covered", kSanitizerBinaryMetadataCoveredSection};
80const MetadataInfo MetadataInfo::Atomics{
81 "__sanitizer_metadata_atomics", kSanitizerBinaryMetadataAtomicsSection};
82
83// The only instances of MetadataInfo are the constants above, so a set of
84// them may simply store pointers to them. To deterministically generate code,
85// we need to use a set with stable iteration order, such as SetVector.
86using MetadataInfoSet = SetVector<const MetadataInfo *>;
87
88//===--- Statistics -------------------------------------------------------===//
89
90STATISTIC(NumMetadataCovered, "Metadata attached to covered functions");
91STATISTIC(NumMetadataAtomics, "Metadata attached to atomics");
92STATISTIC(NumMetadataUAR, "Metadata attached to UAR functions");
93
94//===----------------------------------------------------------------------===//
95
96// Apply opt overrides.
98transformOptionsFromCl(const InstrumentationOptions &CLOpts,
100 Opts.Covered |= CLOpts.sanitizer_metadata_covered;
101 Opts.Atomics |= CLOpts.sanitizer_metadata_atomics;
102 Opts.UAR |= CLOpts.sanitizer_metadata_uar;
103 return std::move(Opts);
104}
105
106class SanitizerBinaryMetadata {
107public:
108 SanitizerBinaryMetadata(const InstrumentationOptions &CLOpts, Module &M,
110 std::unique_ptr<SpecialCaseList> Ignorelist)
111 : CLOpts(CLOpts), Mod(M),
112 Options(transformOptionsFromCl(CLOpts, std::move(Opts))),
113 Ignorelist(std::move(Ignorelist)), TargetTriple(M.getTargetTriple()),
114 VersionStr(utostr(getVersion())), IRB(M) {
115 // FIXME: Make it work with other formats.
116 assert(TargetTriple.isOSBinFormatELF() && "ELF only");
117 assert(!TargetTriple.isGPU() && "Device targets are not supported");
118 }
119
120 bool run();
121
122private:
123 uint32_t getVersion() const {
124 uint32_t Version = kVersionBase;
125 const auto CM = Mod.getCodeModel();
126 if (CM.has_value() && (*CM == CodeModel::Medium || *CM == CodeModel::Large))
127 Version |= kVersionPtrSizeRel;
128 return Version;
129 }
130
131 void runOn(Function &F, MetadataInfoSet &MIS);
132
133 // Determines which set of metadata to collect for this instruction.
134 //
135 // Returns true if covered metadata is required to unambiguously interpret
136 // other metadata. For example, if we are interested in atomics metadata, any
137 // function with memory operations (atomic or not) requires covered metadata
138 // to determine if a memory operation is atomic or not in modules compiled
139 // with SanitizerBinaryMetadata.
140 bool runOn(Instruction &I, MetadataInfoSet &MIS, MDBuilder &MDB,
141 uint64_t &FeatureMask);
142
143 // Get start/end section marker pointer.
144 GlobalVariable *getSectionMarker(const Twine &MarkerName, Type *Ty);
145
146 // Returns the target-dependent section name.
147 StringRef getSectionName(StringRef SectionSuffix);
148
149 // Returns the section start marker name.
150 StringRef getSectionStart(StringRef SectionSuffix);
151
152 // Returns the section end marker name.
153 StringRef getSectionEnd(StringRef SectionSuffix);
154
155 // Returns true if the access to the address should be considered "atomic".
156 bool pretendAtomicAccess(const Value *Addr);
157
158 const InstrumentationOptions &CLOpts;
159 Module &Mod;
161 std::unique_ptr<SpecialCaseList> Ignorelist;
162 const Triple TargetTriple;
163 const std::string VersionStr;
164 IRBuilder<> IRB;
167};
168
169bool SanitizerBinaryMetadata::run() {
170 MetadataInfoSet MIS;
171
172 for (Function &F : Mod)
173 runOn(F, MIS);
174
175 if (MIS.empty())
176 return false;
177
178 //
179 // Setup constructors and call all initialization functions for requested
180 // metadata features.
181 //
182
183 auto *PtrTy = IRB.getPtrTy();
184 auto *Int32Ty = IRB.getInt32Ty();
185 const std::array<Type *, 3> InitTypes = {Int32Ty, PtrTy, PtrTy};
186 auto *Version = ConstantInt::get(Int32Ty, getVersion());
187
188 for (const MetadataInfo *MI : MIS) {
189 const std::array<Value *, InitTypes.size()> InitArgs = {
190 Version,
191 getSectionMarker(getSectionStart(MI->SectionSuffix), PtrTy),
192 getSectionMarker(getSectionEnd(MI->SectionSuffix), PtrTy),
193 };
194
195 // Calls to the initialization functions with different versions cannot be
196 // merged. Give the structors unique names based on the version, which will
197 // also be used as the COMDAT key.
198 const std::string StructorPrefix = (MI->FunctionPrefix + VersionStr).str();
199
200 // We declare the _add and _del functions as weak, and only call them if
201 // there is a valid symbol linked. This allows building binaries with
202 // semantic metadata, but without having callbacks. When a tool that wants
203 // the metadata is linked which provides the callbacks, they will be called.
204 auto [Ctor, CtorInitFn] = createSanitizerCtorAndInitFunctions(
205 Mod, StructorPrefix + ".module_ctor",
206 (MI->FunctionPrefix + "_add").str(), InitTypes, InitArgs,
207 /*VersionCheckName=*/StringRef(),
208 /*Weak=*/CLOpts.sanitizer_metadata_weak_callbacks);
209 auto [Dtor, DtorInitFn] = createSanitizerCtorAndInitFunctions(
210 Mod, StructorPrefix + ".module_dtor",
211 (MI->FunctionPrefix + "_del").str(), InitTypes, InitArgs,
212 /*VersionCheckName=*/StringRef(),
213 /*Weak=*/CLOpts.sanitizer_metadata_weak_callbacks);
214 const Attribute::AttrKind ExtAttr =
215 TargetLibraryInfo::getExtAttrForI32Param(TargetTriple,
216 /*Signed=*/false);
217 if (ExtAttr != Attribute::None)
218 for (FunctionCallee InitFn : {CtorInitFn, DtorInitFn})
219 cast<Function>(InitFn.getCallee())->addParamAttr(0, ExtAttr);
220 Constant *CtorComdatKey = nullptr;
221 Constant *DtorComdatKey = nullptr;
222 if (TargetTriple.supportsCOMDAT()) {
223 // Use COMDAT to deduplicate constructor/destructor function. The COMDAT
224 // key needs to be a non-local linkage.
225 Ctor->setComdat(Mod.getOrInsertComdat(Ctor->getName()));
226 Dtor->setComdat(Mod.getOrInsertComdat(Dtor->getName()));
227 Ctor->setLinkage(GlobalValue::ExternalLinkage);
228 Dtor->setLinkage(GlobalValue::ExternalLinkage);
229 // DSOs should _not_ call another constructor/destructor!
230 Ctor->setVisibility(GlobalValue::HiddenVisibility);
231 Dtor->setVisibility(GlobalValue::HiddenVisibility);
232 CtorComdatKey = Ctor;
233 DtorComdatKey = Dtor;
234 }
235 appendToGlobalCtors(Mod, Ctor, kCtorDtorPriority, CtorComdatKey);
236 appendToGlobalDtors(Mod, Dtor, kCtorDtorPriority, DtorComdatKey);
237 }
238
239 return true;
240}
241
242void SanitizerBinaryMetadata::runOn(Function &F, MetadataInfoSet &MIS) {
243 if (F.empty())
244 return;
245 // Do not apply any instrumentation for naked functions.
246 if (F.hasFnAttribute(Attribute::Naked))
247 return;
248 if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
249 return;
250 if (Ignorelist && Ignorelist->inSection("metadata", "fun", F.getName()))
251 return;
252 // Don't touch available_externally functions, their actual body is elsewhere.
253 if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage)
254 return;
255
256 MDBuilder MDB(F.getContext());
257
258 // The metadata features enabled for this function, stored along covered
259 // metadata (if enabled).
260 uint64_t FeatureMask = 0;
261 // Don't emit unnecessary covered metadata for all functions to save space.
262 bool RequiresCovered = false;
263
264 if (Options.Atomics || Options.UAR) {
265 for (BasicBlock &BB : F)
266 for (Instruction &I : BB)
267 RequiresCovered |= runOn(I, MIS, MDB, FeatureMask);
268 }
269
270 if (CLOpts.sanitizer_metadata_nosanitize_attr &&
271 F.hasFnAttribute("no_sanitize_thread"))
273 if (F.isVarArg())
274 FeatureMask &= ~kSanitizerBinaryMetadataUAR;
275 if (FeatureMask & kSanitizerBinaryMetadataUAR) {
276 RequiresCovered = true;
277 NumMetadataUAR++;
278 }
279
280 // Covered metadata is always emitted if explicitly requested, otherwise only
281 // if some other metadata requires it to unambiguously interpret it for
282 // modules compiled with SanitizerBinaryMetadata.
283 if (Options.Covered || (FeatureMask && RequiresCovered)) {
284 NumMetadataCovered++;
285 const auto *MI = &MetadataInfo::Covered;
286 MIS.insert(MI);
287 const StringRef Section = getSectionName(MI->SectionSuffix);
288 // The feature mask will be placed after the function size.
289 Constant *CFM = IRB.getInt64(FeatureMask);
290 F.setMetadata(LLVMContext::MD_pcsections,
291 MDB.createPCSections({{Section, {CFM}}}));
292 }
293}
294
295bool isUARSafeCall(CallInst *CI) {
296 auto *F = CI->getCalledFunction();
297 // There are no intrinsic functions that leak arguments.
298 // If the called function does not return, the current function
299 // does not return as well, so no possibility of use-after-return.
300 // Sanitizer function also don't leak or don't return.
301 // It's safe to both pass pointers to local variables to them
302 // and to tail-call them.
303 return F && (F->isIntrinsic() || F->doesNotReturn() ||
304 F->getName().starts_with("__asan_") ||
305 F->getName().starts_with("__hwsan_") ||
306 F->getName().starts_with("__ubsan_") ||
307 F->getName().starts_with("__msan_") ||
308 F->getName().starts_with("__tsan_"));
309}
310
311bool hasUseAfterReturnUnsafeUses(Value &V) {
312 for (User *U : V.users()) {
313 if (auto *I = dyn_cast<Instruction>(U)) {
314 if (I->isLifetimeStartOrEnd() || I->isDroppable())
315 continue;
316 if (auto *CI = dyn_cast<CallInst>(U)) {
317 if (isUARSafeCall(CI))
318 continue;
319 }
320 if (isa<LoadInst>(U))
321 continue;
322 if (auto *SI = dyn_cast<StoreInst>(U)) {
323 // If storing TO the alloca, then the address isn't taken.
324 if (SI->getOperand(1) == &V)
325 continue;
326 }
327 if (auto *GEPI = dyn_cast<GetElementPtrInst>(U)) {
328 if (!hasUseAfterReturnUnsafeUses(*GEPI))
329 continue;
330 } else if (auto *BCI = dyn_cast<BitCastInst>(U)) {
331 if (!hasUseAfterReturnUnsafeUses(*BCI))
332 continue;
333 }
334 }
335 return true;
336 }
337 return false;
338}
339
340bool useAfterReturnUnsafe(Instruction &I) {
341 if (isa<AllocaInst>(I))
342 return hasUseAfterReturnUnsafeUses(I);
343 // Tail-called functions are not necessary intercepted
344 // at runtime because there is no call instruction.
345 // So conservatively mark the caller as requiring checking.
346 else if (auto *CI = dyn_cast<CallInst>(&I))
347 return CI->isTailCall() && !isUARSafeCall(CI);
348 return false;
349}
350
351bool SanitizerBinaryMetadata::pretendAtomicAccess(const Value *Addr) {
352 if (!Addr)
353 return false;
354
355 Addr = Addr->stripInBoundsOffsets();
356 auto *GV = dyn_cast<GlobalVariable>(Addr);
357 if (!GV)
358 return false;
359
360 // Some compiler-generated accesses are known racy, to avoid false positives
361 // in data-race analysis pretend they're atomic.
362 if (GV->hasSection()) {
363 const auto OF = Mod.getTargetTriple().getObjectFormat();
364 const auto ProfSec =
365 getInstrProfSectionName(IPSK_cnts, OF, /*AddSegmentInfo=*/false);
366 if (GV->getSection().ends_with(ProfSec))
367 return true;
368 }
369 if (GV->getName().starts_with("__llvm_gcov") ||
370 GV->getName().starts_with("__llvm_gcda"))
371 return true;
372
373 return false;
374}
375
376// Returns true if the memory at `Addr` may be shared with other threads.
377bool maybeSharedMutable(const Value *Addr) {
378 // By default assume memory may be shared.
379 if (!Addr)
380 return true;
381
382 const AllocaInst *AI = findAllocaForValue(Addr);
383 if (AI && !PointerMayBeCaptured(AI, /*ReturnCaptures=*/true))
384 return false; // Object is on stack but does not escape.
385
386 Addr = Addr->stripInBoundsOffsets();
387 if (auto *GV = dyn_cast<GlobalVariable>(Addr)) {
388 if (GV->isConstant())
389 return false; // Shared, but not mutable.
390 }
391
392 return true;
393}
394
395bool SanitizerBinaryMetadata::runOn(Instruction &I, MetadataInfoSet &MIS,
396 MDBuilder &MDB, uint64_t &FeatureMask) {
398 bool RequiresCovered = false;
399
400 // Only call if at least 1 type of metadata is requested.
401 assert(Options.UAR || Options.Atomics);
402
403 if (Options.UAR && !(FeatureMask & kSanitizerBinaryMetadataUAR)) {
404 if (useAfterReturnUnsafe(I))
405 FeatureMask |= kSanitizerBinaryMetadataUAR;
406 }
407
408 if (Options.Atomics) {
409 const Value *Addr = nullptr;
410 if (auto *SI = dyn_cast<StoreInst>(&I))
411 Addr = SI->getPointerOperand();
412 else if (auto *LI = dyn_cast<LoadInst>(&I))
413 Addr = LI->getPointerOperand();
414
415 if (I.mayReadOrWriteMemory() && maybeSharedMutable(Addr)) {
416 auto SSID = getAtomicSyncScopeID(&I);
417 if ((SSID.has_value() && *SSID != SyncScope::SingleThread) ||
418 pretendAtomicAccess(Addr)) {
419 NumMetadataAtomics++;
420 InstMetadata.push_back(&MetadataInfo::Atomics);
421 }
422 FeatureMask |= kSanitizerBinaryMetadataAtomics;
423 RequiresCovered = true;
424 }
425 }
426
427 // Attach MD_pcsections to instruction.
428 if (!InstMetadata.empty()) {
429 MIS.insert_range(InstMetadata);
431 for (const auto &MI : InstMetadata)
432 Sections.push_back({getSectionName(MI->SectionSuffix), {}});
433 I.setMetadata(LLVMContext::MD_pcsections, MDB.createPCSections(Sections));
434 }
435
436 return RequiresCovered;
437}
438
439GlobalVariable *
440SanitizerBinaryMetadata::getSectionMarker(const Twine &MarkerName, Type *Ty) {
441 // Use ExternalWeak so that if all sections are discarded due to section
442 // garbage collection, the linker will not report undefined symbol errors.
443 auto *Marker = new GlobalVariable(Mod, Ty, /*isConstant=*/false,
444 GlobalVariable::ExternalWeakLinkage,
445 /*Initializer=*/nullptr, MarkerName);
446 Marker->setVisibility(GlobalValue::HiddenVisibility);
447 return Marker;
448}
449
450StringRef SanitizerBinaryMetadata::getSectionName(StringRef SectionSuffix) {
451 // FIXME: Other TargetTriples.
452 // Request ULEB128 encoding for all integer constants.
453 return StringPool.save(SectionSuffix + VersionStr + "!C");
454}
455
456StringRef SanitizerBinaryMetadata::getSectionStart(StringRef SectionSuffix) {
457 // Twine only concatenates 2 strings; with >2 strings, concatenating them
458 // creates Twine temporaries, and returning the final Twine no longer works
459 // because we'd end up with a stack-use-after-return. So here we also use the
460 // StringPool to store the new string.
461 return StringPool.save("__start_" + SectionSuffix + VersionStr);
462}
463
464StringRef SanitizerBinaryMetadata::getSectionEnd(StringRef SectionSuffix) {
465 return StringPool.save("__stop_" + SectionSuffix + VersionStr);
466}
467
468} // namespace
469
473 ArrayRef<std::string> IgnorelistFiles)
474 : Options(std::move(Opts)),
475 VFS(VFS ? std::move(VFS) : vfs::getRealFileSystem()),
476 IgnorelistFiles(std::move(IgnorelistFiles)) {}
477
480 std::unique_ptr<SpecialCaseList> Ignorelist;
481 if (!IgnorelistFiles.empty()) {
482 Ignorelist = SpecialCaseList::createOrDie(IgnorelistFiles, *VFS);
483 if (Ignorelist->inSection("metadata", "src", M.getSourceFileName()))
484 return PreservedAnalyses::all();
485 }
486
487 const InstrumentationOptions &CLOpts = getInstrumentationOptions(M);
488 SanitizerBinaryMetadata Pass(CLOpts, M, Options, std::move(Ignorelist));
489 if (Pass.run())
491 return PreservedAnalyses::all();
492}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
This file defines the BumpPtrAllocator interface.
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
print mir2vec MIR2Vec Vocabulary Printer Pass
Definition MIR2Vec.cpp:629
This file contains the declarations for metadata subclasses.
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:171
This file contains some functions that are useful when dealing with strings.
Defines the virtual file system interface vfs::FileSystem.
A container for analyses that lazily runs them and caches their results.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition Attributes.h:125
@ None
No attributes have been set.
Definition Attributes.h:127
LLVM Basic Block Representation.
Definition BasicBlock.h:62
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
bool isTailCall() const
This is an important base class in LLVM.
Definition Constant.h:44
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
@ HiddenVisibility
The GV is hidden.
Definition GlobalValue.h:69
@ ExternalLinkage
Externally visible function.
Definition GlobalValue.h:53
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition GlobalValue.h:54
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition IRBuilder.h:522
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Definition IRBuilder.h:470
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Definition IRBuilder.h:565
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2909
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
LLVM_ABI MDNode * createPCSections(ArrayRef< PCSection > Sections)
Return metadata for PC sections.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Pass interface - Implemented by all 'passes'.
Definition Pass.h:97
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
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
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI SanitizerBinaryMetadataPass(SanitizerBinaryMetadataOptions Opts={}, IntrusiveRefCntPtr< vfs::FileSystem > VFS=nullptr, ArrayRef< std::string > IgnorelistFiles={})
A vector that has set insertion semantics.
Definition SetVector.h:57
void push_back(const T &Elt)
static LLVM_ABI std::unique_ptr< SpecialCaseList > createOrDie(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS)
Parses the special case list entries from files.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition Triple.h:1279
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition StringSaver.h:45
StringRef save(const char *S)
Definition StringSaver.h:53
LLVM Value Representation.
Definition Value.h:75
LLVM_ABI const Value * stripInBoundsOffsets(function_ref< void(const Value *)> Func=[](const Value *) {}) const
Strip off pointer casts and inbounds GEPs.
Definition Value.cpp:824
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
Definition LLVMContext.h:63
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
This is an optimization pass for GlobalISel generic memory operations.
const InstrumentationOptions & getInstrumentationOptions(const LLVMContext &C)
LLVM_ABI AllocaInst * findAllocaForValue(Value *V, bool OffsetZero=false)
Returns unique alloca where the value comes from, or nullptr.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
std::string utostr(uint64_t X, bool isNeg=false)
LLVM_ABI std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
constexpr uint64_t kSanitizerBinaryMetadataUAR
LLVM_ABI std::pair< Function *, FunctionCallee > createSanitizerCtorAndInitFunctions(Module &M, StringRef CtorName, StringRef InitName, ArrayRef< Type * > InitArgTypes, ArrayRef< Value * > InitArgs, StringRef VersionCheckName=StringRef(), bool Weak=false)
Creates sanitizer constructor function, and calls sanitizer's init function from it.
std::optional< SyncScope::ID > getAtomicSyncScopeID(const Instruction *I)
A helper function that returns an atomic operation's sync scope; returns std::nullopt if it is not an...
constexpr uint64_t kSanitizerBinaryMetadataAtomics
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
constexpr char kSanitizerBinaryMetadataCoveredSection[]
@ Mod
The access may modify the value stored in memory.
Definition ModRef.h:34
LLVM_ABI bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures, unsigned MaxUsesToExplore=0)
PointerMayBeCaptured - Return true if this pointer value may be captured by the enclosing function (w...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
LLVM_ABI 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.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
constexpr char kSanitizerBinaryMetadataAtomicsSection[]
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
LLVM_ABI void appendToGlobalDtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Same as appendToGlobalCtors(), but for global dtors.
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878