68#define DEBUG_TYPE "instrumentor"
74 "instrumentor-write-config-file",
76 "Write the instrumentor configuration into the specified JSON file"),
81 ConfigFiles(
"instrumentor-read-config-files",
82 cl::desc(
"Read the instrumentor configuration from the "
83 "specified JSON files (comma separated)"),
89 "instrumentor-read-config-paths-file",
90 cl::desc(
"Read the instrumentor configuration file "
91 "paths from the specified file (newline separated)"),
96template <
typename IRBuilderTy>
void ensureDbgLoc(IRBuilderTy &IRB) {
97 if (IRB.getCurrentDebugLocation())
99 auto *BB = IRB.GetInsertBlock();
100 if (
auto *SP = BB->getParent()->getSubprogram())
101 IRB.SetCurrentDebugLocation(
DILocation::get(BB->getContext(), 0, 0, SP));
107template <
typename IRBTy>
109 bool AllowTruncate =
false) {
112 Type *VTy = V->getType();
118 return IRB.CreatePointerBitCastOrAddrSpaceCast(V, Ty);
119 TypeSize RequestedSize =
DL.getTypeSizeInBits(Ty);
120 TypeSize ValueSize =
DL.getTypeSizeInBits(VTy);
121 bool ShouldTruncate = RequestedSize < ValueSize;
122 if (ShouldTruncate && !AllowTruncate)
124 if (ShouldTruncate && AllowTruncate) {
128 IntV = IRB.CreateBitCast(V, IRB.getIntNTy(ValueSize));
129 return tryToCast(IRB,
130 IRB.CreateIntCast(IntV, IRB.getIntNTy(RequestedSize),
132 Ty,
DL, AllowTruncate);
135 return IRB.CreateIntCast(V, Ty,
false);
139 return tryToCast(IRB, IRB.CreateBitCast(V, IRB.getIntNTy(ValueSize)), Ty,
144 if (VTy->
isIntegerTy() && Ty->isFloatingPointTy()) {
145 if (ValueSize == RequestedSize)
146 return IRB.CreateBitCast(V, Ty);
149 IRB.CreateIntCast(V, IRB.getIntNTy(RequestedSize),
false),
150 Ty,
DL, AllowTruncate);
152 return IRB.CreateBitOrPointerCast(V, Ty);
156template <
typename Ty>
158 return ConstantInt::get(
IT, Val, IsSigned);
162 switch (
OpTy.getTypeID()) {
163 case Type::TypeID::ArrayTyID:
164 case Type::TypeID::FixedVectorTyID:
165 case Type::TypeID::ScalableVectorTyID:
166 return getCI(&ReqTy,
OpTy.getContainedType(0)->getTypeID());
171 return getCI(&ReqTy, -1,
true);
176class InstrumentorImpl final {
181 : IConf(IConf), M(M), IIRB(IIRB) {}
189 InstChoicesPRE.clear();
190 InstChoicesPOST.clear();
191 ParsedFunctionRegex =
Regex();
200 bool shouldInstrumentTarget();
203 bool shouldInstrumentFunction(
Function &Fn);
211 bool instrumentFunction(
Function &Fn);
212 bool instrumentModule();
223 Regex ParsedFunctionRegex;
241 Twine(
"failed to parse ") + Name +
" regex: " + ErrMsg,
DS_Error));
249bool InstrumentorImpl::linkRuntime() {
251 if (RuntimeBitcodes.
empty())
256 for (StringRef RuntimeBitcode : RuntimeBitcodes) {
257 if (RuntimeBitcode.empty())
264 Twine(
"Failed to parse runtime bitcode file '") + RuntimeBitcode +
272 Twine(
"Failed to link in runtime bitcode file '") + RuntimeBitcode +
288 InlineFunctionInfo IFI;
290 if (!InlineResult.isSuccess()) {
292 raw_string_ostream
SS(WarnMsg);
293 SS <<
"Inlining of runtime call failed: "
294 << CI->getCalledFunction()->getName() <<
"\n";
295 SS <<
"Reason: " << InlineResult.getFailureReason() <<
"\n";
296 SS <<
"Signatures: " << *CI->getFunctionType() <<
" vs "
297 << *CI->getCalledFunction()->getFunctionType() <<
"\n";
304 auto *Fn = It.first.first;
305 DominatorTree DT(*Fn);
306 auto &Allocas = *It.second;
316bool InstrumentorImpl::shouldInstrumentTarget() {
318 const bool IsGPU =
T.
isAMDGPU() ||
T.isNVPTX();
320 bool RegexMatches =
true;
323 RegexMatches = RX.
match(
T.str());
326 return ((IsGPU && IConf.
GPUEnabled->getBool()) ||
331bool InstrumentorImpl::shouldInstrumentFunction(
Function &Fn) {
334 bool RegexMatches =
true;
335 if (ParsedFunctionRegex.
isValid())
341bool InstrumentorImpl::shouldInstrumentGlobalVariable(GlobalVariable &GV) {
346bool InstrumentorImpl::instrumentInstruction(Instruction &
I,
347 InstrumentationCaches &ICaches) {
358 if (
auto *IO = InstChoicesPRE.lookup(
I.getOpcode())) {
359 IIRB.
IRB.SetInsertPoint(&
I);
360 ensureDbgLoc(IIRB.
IRB);
361 IO->instrument(IPtr,
Changed, IConf, IIRB, ICaches);
364 if (
auto *IO = InstChoicesPOST.lookup(
I.getOpcode())) {
365 IIRB.
IRB.SetInsertPoint(
I.getNextNode());
366 ensureDbgLoc(IIRB.
IRB);
367 IO->instrument(IPtr,
Changed, IConf, IIRB, ICaches);
374bool InstrumentorImpl::instrumentFunction(
Function &Fn) {
376 if (!shouldInstrumentFunction(Fn))
379 InstrumentationCaches ICaches;
380 SmallVector<Instruction *> FinalTIs;
381 ReversePostOrderTraversal<Function *> RPOT(&Fn);
382 for (
auto &It : RPOT) {
384 Changed |= instrumentInstruction(
I, ICaches);
386 auto *TI = It->getTerminator();
387 if (!TI->getNumSuccessors())
392 for (
auto &[Name, IO] :
399 IIRB.
IRB.SetInsertPoint(
400 cast<Function>(FPtr)->getEntryBlock().getFirstNonPHIOrDbgOrAlloca());
401 ensureDbgLoc(IIRB.
IRB);
402 IO->instrument(FPtr,
Changed, IConf, IIRB, ICaches);
406 for (
auto &[Name, IO] :
413 for (Instruction *FinalTI : FinalTIs) {
414 IIRB.
IRB.SetInsertPoint(FinalTI);
415 ensureDbgLoc(IIRB.
IRB);
416 IO->instrument(FPtr,
Changed, IConf, IIRB, ICaches);
423bool InstrumentorImpl::instrumentModule() {
426 for (GlobalVariable &GV : M.
globals()) {
429 GV.
getName() ==
"llvm.global_dtors" ||
430 GV.
getName() ==
"llvm.global_ctors")
435 auto CreateYtor = [&](
bool Ctor) {
438 IConf.
getRTName(Ctor ?
"ctor" :
"dtor",
""), M);
441 IIRB.
IRB.SetInsertPoint(EntryBB->begin());
442 ensureDbgLoc(IIRB.
IRB);
443 IIRB.
IRB.CreateRetVoid();
452 InstrumentationCaches ICaches;
454 Function *CtorFn =
nullptr, *DtorFn =
nullptr;
459 Function *&YtorFn = IsPRE ? CtorFn : DtorFn;
460 for (
auto &ChoiceIt : IConf.
IChoices[Loc]) {
461 auto *IO = ChoiceIt.second;
465 YtorFn = CreateYtor(IsPRE);
468 IIRB.
IRB.SetInsertPointPastAllocas(YtorFn);
469 ensureDbgLoc(IIRB.
IRB);
470 Value *YtorPtr = YtorFn;
475 IO->instrument(YtorPtr,
Changed, IConf, IIRB, ICaches);
483 Function *&YtorFn = IsPRE ? CtorFn : DtorFn;
484 for (
auto &ChoiceIt : IConf.
IChoices[Loc]) {
485 auto *IO = ChoiceIt.second;
489 YtorFn = CreateYtor(IsPRE);
492 for (GlobalVariable *GV : Globals) {
493 if (!shouldInstrumentGlobalVariable(*GV))
498 IIRB.
IRB.SetInsertPointPastAllocas(YtorFn);
499 ensureDbgLoc(IIRB.
IRB);
505 IO->instrument(GVPtr,
Changed, IConf, IIRB, ICaches);
514bool InstrumentorImpl::instrument() {
516 if (!shouldInstrumentTarget())
519 StringRef FunctionRegexStr = IConf.
FunctionRegex->getString();
520 ParsedFunctionRegex =
createRegex(FunctionRegexStr,
"function", IIRB.
Ctx);
523 auto RegisterForAllOpcodes = [](
auto &InstChoices,
524 InstrumentationOpportunity *IO) {
525 ArrayRef<unsigned> Opcodes = IO->getAllOpcodes();
527 for (
unsigned Opcode : Opcodes)
528 InstChoices[Opcode] = IO;
531 for (
auto &[Name, IO] :
534 RegisterForAllOpcodes(InstChoicesPRE, IO);
535 for (
auto &[Name, IO] :
538 RegisterForAllOpcodes(InstChoicesPOST, IO);
542 Changed |= instrumentFunction(Fn);
550 InstrumentationConfig *IC,
551 InstrumentorIRBuilderTy *IIRB)
552 : FS(FS), UserIConf(IC), UserIIRB(IIRB) {
561 InstrumentorImpl Impl(IConf, IIRB, M);
569 bool MultipleConfigs = ConfigFiles.size() > 1;
572 std::string ConfigFile =
573 ReadConfig && !ConfigFiles.empty() ? ConfigFiles[Idx] :
"";
584 ? OutputConfigFile +
"." + std::to_string(Idx)
591 }
while (++Idx < ConfigFiles.size());
600 std::unique_ptr<InstrumentationConfig> IConfInt(
601 !UserIConf ?
new InstrumentationConfig() :
nullptr);
602 std::unique_ptr<InstrumentorIRBuilderTy> IIRBInt(
603 !UserIIRB ?
new InstrumentorIRBuilderTy(M) :
nullptr);
605 auto *IConf = IConfInt ? IConfInt.get() : UserIConf;
606 auto *IIRB = IIRBInt ? IIRBInt.get() : UserIIRB;
608 auto PA = run(M, *IConf, *IIRB, !UserIConf);
614std::unique_ptr<BaseConfigurationOption>
620 BCO->setBool(DefaultValue);
625std::unique_ptr<BaseConfigurationOption>
632 BCO->setString(DefaultValue);
637std::unique_ptr<BaseConfigurationOption>
643 BCO->setStringList(DefaultValue);
668 Twine(
"registered two instrumentation opportunities for the same "
679 Function *Fn = IIRB.
IRB.GetInsertBlock()->getParent();
695 if (!BPIO || !BPIO->Enabled) {
697 "Base pointer info disabled but required, passing nullptr.",
704 std::optional<BasicBlock::iterator> IP =
705 BasePtrI->getInsertionPointAfterDef();
707 IIRB.
IRB.SetInsertPoint(*IP);
710 "Base pointer info could not be placed, passing nullptr.",
715 IIRB.
IRB.SetInsertPointPastAllocas(IIRB.
IRB.GetInsertBlock()->getParent());
720 ensureDbgLoc(IIRB.
IRB);
726 BPI = BPIO->instrument(Obj,
Changed, *
this, IIRB, ICaches);
747 if (V.getType()->isVoidTy())
749 return tryToCast(IIRB.
IRB, &V, &Ty, IIRB.
IRB.getDataLayout());
755 if (V.getType()->isVoidTy())
758 auto *NewVCasted = &NewV;
761 IIRB.
IRB.SetInsertPoint(
I->getNextNode());
762 ensureDbgLoc(IIRB.
IRB);
763 NewVCasted = tryToCast(IIRB.
IRB, &NewV, V.
getType(), IIRB.
DL,
778 for (
auto &It :
IO.IRTArgs) {
781 NumReplaceableArgs += bool(It.Flags & IRTArg::REPLACABLE);
782 MightRequireIndirection |= It.Flags & IRTArg::POTENTIALLY_INDIRECT;
793 "Wrong indirection setting!");
796 for (
auto &It :
IO.IRTArgs) {
825 auto IP = IIRB.
IRB.GetInsertPoint();
828 for (
auto &It :
IO.IRTArgs) {
832 if (!Param || It.NoCache)
834 Param = It.GetterCB(*V, *It.Ty, IConf, IIRB);
837 if (Param->getType()->isVoidTy()) {
839 }
else if (Param->getType()->isAggregateType() ||
840 Param->getType()->isVectorTy() ||
841 DL.getTypeSizeInBits(Param->getType()) >
842 DL.getTypeSizeInBits(It.Ty)) {
845 Twine(
"indirection needed for ") + It.Name +
Twine(
" in ") +
847 Twine(
", but not indicated. Instrumentation is skipped"),
851 ForceIndirection =
true;
853 Param = tryToCast(IIRB.
IRB, Param, It.Ty,
DL);
858 if (ForceIndirection) {
859 Function *Fn = IIRB.
IRB.GetInsertBlock()->getParent();
862 for (
auto &It :
IO.IRTArgs) {
870 auto *&CallParam = CallParams[
Offset++];
872 CallParams.
insert(&CallParam + 1, IIRB.
IRB.getInt32(
DL.getTypeStoreSize(
873 CallParam->getType())));
880 CallParam = CachedParam;
885 IIRB.
IRB.CreateStore(CallParam, AI);
886 CallParam = CachedParam = tryToCast(IIRB.
IRB, AI, IIRB.
PtrTy,
DL);
890 if (!ForceIndirection)
891 IIRB.
IRB.SetInsertPoint(IP);
892 ensureDbgLoc(IIRB.
IRB);
896 IConf.
getRTName(
IO.IP.isPRE() ?
"pre_" :
"post_",
IO.getName(),
897 ForceIndirection ?
"_ind" :
"");
898 auto FC = IIRB.
IRB.getModule()->getOrInsertFunction(CompleteName, FnTy);
899 auto *CI = IIRB.
IRB.CreateCall(FC, CallParams);
902 for (
unsigned I = 0, E =
IO.IRTArgs.size();
I < E; ++
I) {
903 if (!
IO.IRTArgs[
I].Enabled)
908 Value *NewValue = FnTy->isVoidTy() || IsCustomReplaceable
913 if (ForceIndirection && !IsCustomReplaceable &&
918 NewValue = IIRB.
IRB.CreateLoad(V->getType(), Q);
920 V =
IO.IRTArgs[
I].SetterCB(*V, *NewValue, IConf, IIRB);
926 if constexpr (std::is_same<Ty, Use>::value)
927 return ValueOrUse.get();
929 return static_cast<Value *
>(&ValueOrUse);
932template <
typename Range>
935 auto *Fn = IIRB.
IRB.GetInsertBlock()->getParent();
936 auto *I32Ty = IIRB.
IRB.getInt32Ty();
942 if (!V->getType()->isSized())
945 ConstantValues.
push_back(getCI(I32Ty, VSize));
946 Types.push_back(I32Ty);
947 ConstantValues.
push_back(getCI(I32Ty, V->getType()->getTypeID()));
948 Types.push_back(I32Ty);
949 if (
uint32_t MisAlign = VSize % 8) {
953 Types.push_back(V->getType());
974 IIRB.
IRB.CreateMemCpy(AI, AI->getAlign(), GV, GV->
getAlign(),
976 for (
auto [Param, Idx] :
Values) {
977 auto *Ptr = IIRB.
IRB.CreateStructGEP(STy, AI, Idx);
978 IIRB.
IRB.CreateStore(Param, Ptr);
983template <
typename Range>
987 auto *Fn = IIRB.
IRB.GetInsertBlock()->getParent();
991 for (
const auto &[Idx, RE] :
enumerate(R)) {
993 if (!V->getType()->isSized())
996 auto VSize =
DL.getTypeAllocSize(V->getType());
997 auto Padding =
alignTo(VSize, 8) - VSize;
999 auto *Ptr = IIRB.
IRB.CreateConstInBoundsGEP1_32(IIRB.
Int8Ty, &Pack,
Offset);
1000 auto *NewV = IIRB.
IRB.CreateLoad(V->getType(), Ptr);
1001 SetterCB(Idx, NewV);
1010 return getCI(&Ty,
I.getOpcode());
1017 auto &
DL =
I.getDataLayout();
1018 return getCI(&Ty,
DL.getTypeStoreSize(V.getType()));
1025 return I.getOperand(0);
1032 if (
I.getNumOperands() > 1)
1033 return I.getOperand(1);
1040 return getCI(&Ty, V.getType()->getTypeID());
1046 return getSubTypeID(*V.getType(), Ty);
1053 using namespace std::placeholders;
1067 "Number of function arguments (without varargs).",
IRTArg::NONE,
1071 IIRB.
PtrTy,
"arguments",
"Description of the arguments.",
1079 "Flag to indicate it is the main function.",
1109 return getCI(&Ty, std::distance(FRange.begin(), FRange.end()));
1125 auto CB = [&](
int Idx,
Value *ReplV) {
1144 return getCI(&Ty, Fn.
getName() ==
"main");
1168 IRTArg(IIRB.
PtrTy,
"address",
"The allocated memory address.",
1174 IIRB.
Int64Ty,
"size",
"The allocation size.",
1189 return IIRB.
IRB.CreateAllocationSize(&Ty, &AI);
1196 auto *NewAI = IIRB.
IRB.CreateAlloca(IIRB.
IRB.getInt8Ty(),
1197 DL.getAllocaAddrSpace(), &NewV);
1198 NewAI->setAlignment(AI.getAlign());
1199 AI.replaceAllUsesWith(NewAI);
1218 IRTArg(IIRB.
PtrTy,
"pointer",
"The accessed pointer.",
1225 "The address space of the accessed pointer.",
1230 "The runtime provided base pointer info.",
1258 IIRB.
Int32Ty,
"value_sub_type_id",
1259 "The type id of the stored value (for arrays and vectors, or -1).",
1264 "The atomicity ordering of the store.",
1285 return SI.getPointerOperand();
1291 SI.setOperand(
SI.getPointerOperandIndex(), &NewV);
1298 return getCI(&Ty,
SI.getPointerAddressSpace());
1311 return SI.getValueOperand();
1317 auto &
DL =
SI.getDataLayout();
1318 return getCI(&Ty,
DL.getTypeStoreSize(
SI.getValueOperand()->getType()));
1324 return getCI(&Ty,
SI.getAlign().value());
1330 return getCI(&Ty,
SI.getValueOperand()->getType()->getTypeID());
1337 return getSubTypeID(*
SI.getValueOperand()->getType(), Ty);
1344 return getCI(&Ty,
uint64_t(
SI.getOrdering()));
1350 return getCI(&Ty,
uint64_t(
SI.getSyncScopeID()));
1356 return getCI(&Ty,
SI.isVolatile());
1366 IRTArg(IIRB.
PtrTy,
"pointer",
"The accessed pointer.",
1373 "The address space of the accessed pointer.",
1378 "The runtime provided base pointer info.",
1408 IIRB.
Int32Ty,
"value_sub_type_id",
1409 "The sub type id of the loaded value (for arrays and vectors, or -1).",
1414 "The atomicity ordering of the load.",
1435 return LI.getPointerOperand();
1441 LI.setOperand(LI.getPointerOperandIndex(), &NewV);
1448 return getCI(&Ty, LI.getPointerAddressSpace());
1466 auto &
DL = LI.getDataLayout();
1467 return getCI(&Ty,
DL.getTypeStoreSize(LI.getType()));
1473 return getCI(&Ty, LI.getAlign().value());
1479 return getCI(&Ty, LI.getType()->getTypeID());
1486 return getSubTypeID(*LI.getType(), Ty);
1493 return getCI(&Ty,
uint64_t(LI.getOrdering()));
1499 return getCI(&Ty,
uint64_t(LI.getSyncScopeID()));
1505 return getCI(&Ty, LI.isVolatile());
1514 "The base pointer in question.",
1518 IIRB.
Int32Ty,
"base_pointer_kind",
1519 "The base pointer kind (argument, global, instruction, unknown).",
1529 return getCI(&Ty, 0);
1531 return getCI(&Ty, 1);
1533 return getCI(&Ty, 2);
1534 return getCI(&Ty, 3);
1544 "The module/translation unit name.",
1575 IIRB.
PtrTy,
"address",
1576 "The address of the global (replaceable for definitions).",
1585 "The size of the declared type of the global.",
1596 IIRB.
Int64Ty,
"initial_value",
"The initial value of the global.",
1605 "Flag to indicate global definitions.",
1629 DL.getDefaultGlobalsAddressSpace());
1634 IIRB.
IRB.CreateStore(&NewV, ShadowGV);
1643 auto MakeInstForConst = [&](
Use &U) {
1649 I = CE->getAsInstruction();
1663 while (!Worklist.
empty()) {
1666 U->set(ReloadMap[
I->getFunction()]);
1669 if (
auto *CI = ConstToInstMap[*U]) {
1670 auto *CIClone = CI->clone();
1673 auto *BB =
PHI->getIncomingBlock(U->getOperandNo());
1674 CIClone->insertBefore(BB->getTerminator()->getIterator());
1676 CIClone->insertBefore(
I->getIterator());
1679 for (
auto &CICUse : CIClone->operands()) {
1687 while (!Worklist.
empty()) {
1689 if (!
Done.insert(U).second)
1691 MakeInstForConst(*U);
1702 if (
II->getIntrinsicID() == Intrinsic::eh_typeid_for)
1705 InsertConsts(
I, *U);
1708 for (
auto &It : ConstToInstMap)
1710 It.second->deleteValue();
1724 return getCI(&Ty, Alignment ? Alignment->value() : 0);
1778 IIRB.
Int32Ty,
"input_sub_type_id",
1779 "The sub type id of the input value (for arrays and vectors, or -1).",
1798 IIRB.
Int32Ty,
"result_sub_type_id",
1799 "The sub type id of the result value (for arrays and vectors, or -1).",
1807 "The opcode of the cast instruction.",
1817 return CI.getOperand(0);
1823 return getCI(&Ty, CI.getSrcTy()->getTypeID());
1830 return getSubTypeID(*CI.getSrcTy(), Ty);
1836 auto &
DL = CI.getDataLayout();
1837 return getCI(&Ty,
DL.getTypeStoreSize(CI.getSrcTy()));
1843 return getCI(&Ty, CI.getDestTy()->getTypeID());
1850 return getSubTypeID(*CI.getDestTy(), Ty);
1856 auto &
DL = CI.getDataLayout();
1857 return getCI(&Ty,
DL.getTypeStoreSize(CI.getDestTy()));
1866 switch (
I.getOpcode()) {
1867 case Instruction::Add:
1868 case Instruction::Sub:
1869 case Instruction::Mul:
1870 case Instruction::Shl:
1871 if (
I.hasNoSignedWrap())
1873 if (
I.hasNoUnsignedWrap())
1876 case Instruction::FAdd:
1877 case Instruction::FSub:
1878 case Instruction::FMul:
1879 case Instruction::FDiv:
1880 case Instruction::FNeg:
1885 if (
I.hasNoSignedZeros())
1888 case Instruction::AShr:
1889 case Instruction::LShr:
1890 case Instruction::SDiv:
1891 case Instruction::UDiv:
1898 if (DI->isDisjoint())
1901 return getCI(&Ty, Flag);
1918 const auto ValArgOpts =
1928 "The operation's sub type id (for arrays and vectors, or -1).",
1938 "The operation's left operand.", ValArgOpts,
1942 "The operation's right operand. This value is "
1943 "poison for unary operations.",
1953 "A bitmask value signaling which instruction flags are present.",
1964 return getCI(&Ty,
I.getOperand(0)->getType()->getTypeID());
1971 auto &
DL =
I.getDataLayout();
1972 return getCI(&Ty,
DL.getTypeStoreSize(
I.getOperand(0)->getType()));
1978 return getCI(&Ty, CI->getPredicate());
1993 switch (
I.getOpcode()) {
1994 case Instruction::ICmp:
1998 case Instruction::FCmp:
2003 if (
I.hasNoSignedZeros())
2008 return getCI(&Ty, Flag);
2016 const auto OperandArgOpts =
2036 "The comparison's left operand.", OperandArgOpts,
2040 "The comparison's right operand.", OperandArgOpts,
2060 "A bitmask value signaling which instruction flags are present.",
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
post inline ee instrument
static MaybeAlign getAlign(Value *Ptr)
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
@ COMPARE_FLAG_HAS_NO_NANS
@ COMPARE_FLAG_HAS_NO_INFS
@ COMPARE_FLAG_HAS_NO_SIGNED_ZEROS
@ NUMERIC_FLAG_NO_SIGNED_WRAP
@ NUMERIC_FLAG_NO_UNSIGNED_WRAP
@ NUMERIC_FLAG_HAS_NO_SIGNED_ZEROS
@ NUMERIC_FLAG_HAS_NO_INFS
@ NUMERIC_FLAG_HAS_NO_NANS
@ NUMERIC_FLAG_IS_DISJOINT
static void readValuePack(const Range &R, Value &Pack, InstrumentorIRBuilderTy &IIRB, function_ref< void(int, Value *)> SetterCB)
static constexpr Value * getValue(Ty &ValueOrUse)
static Value * createValuePack(const Range &R, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Regex createRegex(StringRef Str, StringRef Name, LLVMContext &Ctx)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
ModuleAnalysisManager MAM
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Defines the virtual file system interface vfs::FileSystem.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
LLVM_ABI const_iterator getFirstNonPHIOrDbgOrAlloca() const
Returns an iterator to the first instruction in this block that is not a PHINode, a debug intrinsic,...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
This class represents a function call, abstracting a target machine's calling convention.
static LLVM_ABI Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
This is an important base class in LLVM.
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
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 IR instrumentation reporting.
Class to represent function types.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
const BasicBlock & getEntryBlock() const
const DataLayout & getDataLayout() const
Get the data layout of the module this function belongs to.
iterator_range< arg_iterator > args()
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Argument * getArg(unsigned i) const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
StringRef getSection() const
Get the custom section of this global if it has one.
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LinkageTypes getLinkage() const
ThreadLocalMode getThreadLocalMode() const
unsigned getAddressSpace() const
Module * getParent()
Get the module that this global value is contained inside of...
PointerType * getType() const
Global values are always pointers.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ InternalLinkage
Rename collisions when linking (static functions).
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
MaybeAlign getAlign() const
Returns the alignment of the given variable.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI InstrumentorPass(IntrusiveRefCntPtr< vfs::FileSystem > FS=nullptr, InstrumentationConfig *IC=nullptr, InstrumentorIRBuilderTy *IIRB=nullptr)
Construct an instrumentor pass that will use the instrumentation configuration IC and the IR builder ...
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
static LLVM_ABI bool linkModules(Module &Dest, std::unique_ptr< Module > Src, unsigned Flags=Flags::None, std::function< void(Module &, const StringSet<> &)> InternalizeCallback={})
This function links two modules together, with the resulting Dest module modified to be the composite...
An instruction for reading from memory.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
A Module instance is used to store all the information related to an LLVM module.
const Triple & getTargetTriple() const
Get the target triple which is a string describing the target host.
LLVMContext & getContext() const
Get the global data context.
size_t global_size() const
StringRef getName() const
Get a short "name" for the module.
iterator_range< global_iterator > globals()
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
LLVM_ABI bool isValid(std::string &Error) const
isValid - returns the error encountered during regex compilation, if any.
LLVM_ABI bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
StringRef getMessage() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void reserve(size_type N)
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Class to represent struct types.
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
const std::string & getTriple() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isPointerTy() const
True if this is an instance of PointerType.
bool isAggregateType() const
Return true if the type is an aggregate type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI bool replaceUsesWithIf(Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)
Go through the uses list for this definition and make each use point to "V" if the callback ShouldRep...
iterator_range< use_iterator > uses()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
LLVM_ABI void writeConfigToJSON(InstrumentationConfig &IConf, StringRef OutputFile, LLVMContext &Ctx)
Write the configuration in /p IConf to the file with path OutputFile.
LLVM_ABI bool readConfigPathsFile(StringRef InputFile, cl::list< std::string > &Configs, LLVMContext &Ctx, vfs::FileSystem &FS)
Read the configuration paths from the file with path InputFile into Configs.
LLVM_ABI bool readConfigFromJSON(InstrumentationConfig &IConf, StringRef InputFile, LLVMContext &Ctx, vfs::FileSystem &FS)
Read the configuration from the file with path InputFile into /p IConf.
LLVM_ABI void printRuntimeStub(const InstrumentationConfig &IConf, StringRef StubRuntimeName, LLVMContext &Ctx)
Print a runtime stub file with the implementation of the instrumentation runtime functions correspond...
LLVM_ABI IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void PromoteMemToReg(ArrayRef< AllocaInst * > Allocas, DominatorTree &DT, AssumptionCache *AC=nullptr)
Promote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appro...
RelativeUniformCounterPtr Values
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
LLVM_ABI InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, bool TrackInlineHistory=false, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This function inlines the called function into the basic block of the caller.
LLVM_ABI bool isAllocaPromotable(const AllocaInst *AI)
Return true if this alloca is legal for promotion.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
LLVM_ABI const Value * getUnderlyingObjectAggressive(const Value *V, bool MustPreserveProvenance=false)
Like getUnderlyingObject(), but will try harder to find a single underlying object.
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...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
ArrayRef(const T &OneElt) -> ArrayRef< T >
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.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
LLVM_ABI std::unique_ptr< Module > parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, ParserCallbacks Callbacks={}, AsmParserContext *ParserContext=nullptr)
If the given file holds a bitcode image, return a Module for it.
LLVM_ABI void appendToGlobalDtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Same as appendToGlobalCtors(), but for global dtors.
DEMANGLE_ABI std::string demangle(std::string_view MangledName)
Attempt to demangle a string using different demangling schemes.
LLVM_ABI bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
}
BaseConfigTy< ConfigKind > ConfigTy
static LLVM_ABI Value * getSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * setSize(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI std::unique_ptr< BaseConfigurationOption > createStringListOption(InstrumentationConfig &IC, StringRef Name, StringRef Description, ArrayRef< StringRef > DefaultValue)
Create a string-list option with Name name, Description description and DefaultValue as string-list d...
static LLVM_ABI std::unique_ptr< BaseConfigurationOption > createStringOption(InstrumentationConfig &IC, StringRef Name, StringRef Description, StringRef DefaultValue)
Create a string option with Name name, Description description and DefaultValue as string default val...
static LLVM_ABI std::unique_ptr< BaseConfigurationOption > createBoolOption(InstrumentationConfig &IC, StringRef Name, StringRef Description, bool DefaultValue)
Create a boolean option with Name name, Description description and DefaultValue as boolean default v...
static LLVM_ABI Value * getOpcode(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getRightOperand(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getSubTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getTypeSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getLeftOperand(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getPointerKind(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * setValueNoop(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
This is necessary to produce a return value that can be used by other IOs.
BaseConfigTy< ConfigKind > ConfigTy
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
CastIO {.
static LLVM_ABI Value * getResultTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getInputSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getResultSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getResultSubTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getInput(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getInputSubTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
static LLVM_ABI Value * getInputTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getFlags(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getOperandSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getOperandTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
LLVM_ABI void addFlagNames()
static LLVM_ABI Value * getPredicate(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
llvm::instrumentor::FunctionIO::ConfigTy Config
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI Value * setArguments(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getFunctionAddress(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * isMainFunction(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI Value * getArguments(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI Value * getNumArguments(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getFunctionName(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
FunctionIO {.
static LLVM_ABI Value * setAddress(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
static LLVM_ABI Value * getAS(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getInitialValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * isDefinition(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getDeclaredSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getSymbolName(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getAddress(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
static LLVM_ABI Value * isConstant(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
bool isReplacable(IRTArg &IRTA) const
Return whether the IRTA argument can be replaced.
LLVM_ABI IRTCallDescription(InstrumentationOpportunity &IO, Type *RetTy=nullptr)
Construct an instrumentation function description linked to the IO instrumentation opportunity and Re...
bool MightRequireIndirection
Whether any argument may require indirection.
LLVM_ABI CallInst * createLLVMCall(Value *&V, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, const DataLayout &DL, InstrumentationCaches &ICaches)
Create a call instruction that calls to the instrumentation function and passes the corresponding arg...
Type * RetTy
The return type of the instrumentation function.
InstrumentationOpportunity & IO
The instrumentation opportunity which it is linked to.
LLVM_ABI FunctionType * createLLVMSignature(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, const DataLayout &DL, bool ForceIndirection)
Create the type of the instrumentation function.
unsigned NumReplaceableArgs
The number of arguments that can be replaced.
bool RequiresIndirection
Whether the function requires indirection in some argument.
bool isPotentiallyIndirect(IRTArg &IRTA) const
Return whether the function may have any indirect argument.
Helper that represent the caches for instrumentation call arguments.
DenseMap< std::tuple< unsigned, StringRef, StringRef >, Value * > DirectArgCache
A cache for direct and indirect arguments.
DenseMap< std::tuple< unsigned, StringRef, StringRef >, Value * > IndirectArgCache
The class that contains the configuration for the instrumentor.
virtual void populate(InstrumentorIRBuilderTy &IIRB)
Populate the instrumentation opportunities.
std::unique_ptr< BaseConfigurationOption > InlineRuntimeEagerly
void addChoice(InstrumentationOpportunity &IO, LLVMContext &Ctx)
Register instrumentation opportunity IO.
Constant * getGlobalString(StringRef S, InstrumentorIRBuilderTy &IIRB)
DenseMap< Value *, Value * > UnderlyingObjsMap
Map to remember underlying objects for pointers.
std::unique_ptr< BaseConfigurationOption > HostEnabled
std::unique_ptr< BaseConfigurationOption > DemangleFunctionNames
void init(InstrumentorIRBuilderTy &IIRB)
Initialize the config to a clean base state without loosing cached values that can be reused across c...
DenseMap< std::pair< Value *, Function * >, Value * > BasePointerInfoMap
Map to remember base pointer info for values in a specific function.
EnumeratedArray< MapVector< StringRef, InstrumentationOpportunity * >, InstrumentationLocation::KindTy > IChoices
The map registered instrumentation opportunities.
std::unique_ptr< BaseConfigurationOption > GPUEnabled
std::unique_ptr< BaseConfigurationOption > RuntimeBitcodes
DenseMap< Constant *, GlobalVariable * > ConstantGlobalsCache
Mapping from constants to globals with the constant as initializer.
Value * getBasePointerInfo(Value &V, InstrumentorIRBuilderTy &IIRB)
Return the base pointer info for V.
std::unique_ptr< BaseConfigurationOption > RuntimeStubsFile
StringRef getRTName() const
Get the runtime prefix for the instrumentation runtime functions.
void addBaseChoice(BaseConfigurationOption *BCO)
Add the base configuration option BCO into the list of base options.
std::unique_ptr< BaseConfigurationOption > FunctionRegex
std::unique_ptr< BaseConfigurationOption > TargetRegex
bool isPRE() const
Return whether the instrumentation location is before the event occurs.
Base class for instrumentation opportunities.
InstrumentationLocation::KindTy getLocationKind() const
Get the location kind of the instrumentation opportunity.
static LLVM_ABI Value * getIdPre(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Get the opportunity identifier for the pre and post positions.
static LLVM_ABI Value * forceCast(Value &V, Type &Ty, InstrumentorIRBuilderTy &IIRB)
Helpers to cast values, pass them to the runtime, and replace them.
static int32_t getIdFromEpoch(uint32_t CurrentEpoch)
}
static LLVM_ABI Value * getIdPost(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * replaceValue(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
StringMap< int32_t > FlagNames
Flag names and their integer bitmask values.
virtual StringRef getName() const =0
Get the name of the instrumentation opportunity.
SmallVector< IRTArg > IRTArgs
The list of possible arguments for the instrumentation runtime function.
void addCommonArgs(InstrumentationConfig &IConf, LLVMContext &Ctx, bool PassId)
}
An IR builder augmented with extra information for the instrumentor pass.
IRBuilder< ConstantFolder, IRBuilderCallbackInserter > IRB
The underlying IR builder with insertion callback.
unsigned Epoch
The current epoch number.
AllocaInst * getAlloca(Function *Fn, Type *Ty)
Get a temporary alloca to communicate (large) values with the runtime.
void returnAllocas()
Return the temporary allocas.
DenseMap< Instruction *, unsigned > NewInsts
A mapping from instrumentation instructions to the epoch they have been created.
DenseMap< std::pair< Function *, unsigned >, AllocaListTy * > AllocaMap
Map that holds a list of currently available allocas for a function and alloca size.
void eraseLater(Instruction *I)
Save instruction I to be erased later.
static LLVM_ABI Value * getValueSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getSyncScopeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getAtomicityOrdering(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
virtual Type * getValueType(InstrumentorIRBuilderTy &IIRB) const
}
static LLVM_ABI Value * getValueSubTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getPointer(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Getters and setters for the arguments of the instrumentation function for the load opportunity.
static LLVM_ABI Value * isVolatile(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getBasePointerInfo(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * setPointer(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
static LLVM_ABI Value * getPointerAS(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
}
static LLVM_ABI Value * getValueTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
Initialize the load opportunity using the instrumentation config IConf and the user config UserConfig...
static LLVM_ABI Value * getModuleName(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getTargetTriple(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
BaseConfigTy< ConfigKind > ConfigTy
LLVM_ABI void addFlagNames()
static LLVM_ABI Value * getFlags(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
}
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
static LLVM_ABI Value * getPointer(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Getters and setters for the arguments of the instrumentation function for the store opportunity.
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
}
static LLVM_ABI Value * getValueTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
virtual Type * getValueType(InstrumentorIRBuilderTy &IIRB) const
}
static LLVM_ABI Value * getSyncScopeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getPointerAS(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * setPointer(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * isVolatile(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getValueSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getValueSubTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
Initialize the store opportunity using the instrumentation config IConf and the user config UserConfi...
static LLVM_ABI Value * getBasePointerInfo(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static LLVM_ABI Value * getAtomicityOrdering(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
LLVM_ABI void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
UnreachableIO {.
BaseConfigTy< ConfigKind > ConfigTy