87 "dfsan-preserve-alignment",
100 cl::desc(
"File listing native ABI functions and how the pass treats them"),
107 cl::desc(
"Use the argument ABI rather than the TLS ABI"),
113 "dfsan-combine-pointer-labels-on-load",
114 cl::desc(
"Combine the label of the pointer with the label of the data when "
115 "loading from memory."),
121 "dfsan-combine-pointer-labels-on-store",
122 cl::desc(
"Combine the label of the pointer with the label of the data when "
123 "storing in memory."),
127 "dfsan-debug-nonzero-labels",
128 cl::desc(
"Insert calls to __dfsan_nonzero_label on observing a parameter, "
129 "load or return with a nonzero label"),
139 if (
StructType *SGType = dyn_cast<StructType>(GType)) {
140 if (!SGType->isLiteral())
141 return SGType->getName();
143 return "<unknown type>";
147 std::unique_ptr<SpecialCaseList> SCL;
152 void set(std::unique_ptr<SpecialCaseList>
List) { SCL = std::move(List); }
173 SCL->inSection(
"type", GetGlobalTypeString(GA), Category);
183 friend struct DFSanFunction;
184 friend class DFSanVisitor;
191 enum InstrumentedABI {
236 void *(*GetArgTLSPtr)();
237 void *(*GetRetvalTLSPtr)();
255 DFSanABIList ABIList;
258 bool DFSanRuntimeShadowMask;
261 bool isInstrumented(
const Function *F);
266 InstrumentedABI getInstrumentedABI();
267 WrapperKind getWrapperKind(
Function *F);
276 const std::vector<std::string> &ABIListFiles = std::vector<std::string>(),
277 void *(*getArgTLS)() =
nullptr,
void *(*getRetValTLS)() =
nullptr);
279 bool doInitialization(
Module &M)
override;
280 bool runOnModule(
Module &M)
override;
283 struct DFSanFunction {
284 DataFlowSanitizer &
DFS;
287 DataFlowSanitizer::InstrumentedABI IA;
294 std::vector<std::pair<PHINode *, PHINode *> > PHIFixups;
296 std::vector<Value *> NonZeroChecks;
299 struct CachedCombinedShadow {
304 CachedCombinedShadows;
307 DFSanFunction(DataFlowSanitizer &
DFS,
Function *F,
bool IsNativeABI)
308 : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()),
309 IsNativeABI(IsNativeABI), ArgTLSPtr(nullptr), RetvalTLSPtr(nullptr),
310 LabelReturnAlloca(nullptr) {
314 AvoidNewBlocks = F->
size() > 1000;
316 Value *getArgTLSPtr();
318 Value *getRetvalTLS();
329 class DFSanVisitor :
public InstVisitor<DFSanVisitor> {
332 DFSanVisitor(DFSanFunction &DFSF) : DFSF(DFSF) {}
335 return DFSF.F->getParent()->getDataLayout();
342 void visitCmpInst(
CmpInst &CI);
348 void visitPHINode(
PHINode &PN);
364 "DataFlowSanitizer: dynamic data flow analysis.",
false,
false)
368 void *(*getArgTLS)(),
369 void *(*getRetValTLS)()) {
370 return new DataFlowSanitizer(ABIListFiles, getArgTLS, getRetValTLS);
373 DataFlowSanitizer::DataFlowSanitizer(
374 const std::vector<std::string> &ABIListFiles,
void *(*getArgTLS)(),
375 void *(*getRetValTLS)())
376 :
ModulePass(
ID), GetArgTLSPtr(getArgTLS), GetRetvalTLSPtr(getRetValTLS),
377 DFSanRuntimeShadowMask(
false) {
378 std::vector<std::string> AllABIListFiles(std::move(ABIListFiles));
379 AllABIListFiles.insert(AllABIListFiles.end(),
ClABIListFiles.begin(),
381 ABIList.set(SpecialCaseList::createOrDie(AllABIListFiles));
388 ArgTypes.push_back(ShadowPtrTy);
391 RetType = StructType::get(RetType, ShadowTy);
392 return FunctionType::get(RetType, ArgTypes, T->
isVarArg());
403 ArgTypes.push_back(ShadowPtrTy);
404 return FunctionType::get(T->
getReturnType(), ArgTypes,
false);
413 *i)->getElementType()))) {
414 ArgTypes.
push_back(getTrampolineFunctionType(FT)->getPointerTo());
415 ArgTypes.
push_back(Type::getInt8PtrTy(*Ctx));
420 for (
unsigned i = 0, e = T->
getNumParams(); i != e; ++i)
430 bool DataFlowSanitizer::doInitialization(
Module &M) {
442 ShadowTy = IntegerType::get(*Ctx, ShadowWidth);
443 ShadowPtrTy = PointerType::getUnqual(ShadowTy);
445 ZeroShadow = ConstantInt::getSigned(ShadowTy, 0);
446 ShadowPtrMul = ConstantInt::getSigned(IntptrTy, ShadowWidth / 8);
448 ShadowPtrMask = ConstantInt::getSigned(IntptrTy, ~0x700000000000LL);
450 ShadowPtrMask = ConstantInt::getSigned(IntptrTy, ~0xF000000000LL);
453 DFSanRuntimeShadowMask =
true;
457 Type *DFSanUnionArgs[2] = { ShadowTy, ShadowTy };
459 FunctionType::get(ShadowTy, DFSanUnionArgs,
false);
460 Type *DFSanUnionLoadArgs[2] = { ShadowPtrTy, IntptrTy };
462 FunctionType::get(ShadowTy, DFSanUnionLoadArgs,
false);
463 DFSanUnimplementedFnTy = FunctionType::get(
464 Type::getVoidTy(*Ctx), Type::getInt8PtrTy(*Ctx),
false);
465 Type *DFSanSetLabelArgs[3] = { ShadowTy, Type::getInt8PtrTy(*Ctx), IntptrTy };
466 DFSanSetLabelFnTy = FunctionType::get(Type::getVoidTy(*Ctx),
467 DFSanSetLabelArgs,
false);
468 DFSanNonzeroLabelFnTy = FunctionType::get(
469 Type::getVoidTy(*Ctx),
None,
false);
470 DFSanVarargWrapperFnTy = FunctionType::get(
471 Type::getVoidTy(*Ctx), Type::getInt8PtrTy(*Ctx),
false);
474 Type *ArgTLSTy = ArrayType::get(ShadowTy, 64);
476 GetArgTLS = ConstantExpr::getIntToPtr(
477 ConstantInt::get(IntptrTy, uintptr_t(GetArgTLSPtr)),
478 PointerType::getUnqual(
479 FunctionType::get(PointerType::getUnqual(ArgTLSTy),
false)));
481 if (GetRetvalTLSPtr) {
483 GetRetvalTLS = ConstantExpr::getIntToPtr(
484 ConstantInt::get(IntptrTy, uintptr_t(GetRetvalTLSPtr)),
485 PointerType::getUnqual(
486 FunctionType::get(PointerType::getUnqual(ShadowTy),
false)));
493 bool DataFlowSanitizer::isInstrumented(
const Function *F) {
494 return !ABIList.isIn(*F,
"uninstrumented");
497 bool DataFlowSanitizer::isInstrumented(
const GlobalAlias *GA) {
498 return !ABIList.isIn(*GA,
"uninstrumented");
501 DataFlowSanitizer::InstrumentedABI DataFlowSanitizer::getInstrumentedABI() {
505 DataFlowSanitizer::WrapperKind DataFlowSanitizer::getWrapperKind(
Function *F) {
506 if (ABIList.isIn(*F,
"functional"))
507 return WK_Functional;
508 if (ABIList.isIn(*F,
"discard"))
510 if (ABIList.isIn(*F,
"custom"))
516 void DataFlowSanitizer::addGlobalNamePrefix(
GlobalValue *GV) {
526 std::string SearchStr =
".symver " + GVName +
",";
527 size_t Pos = Asm.find(SearchStr);
528 if (Pos != std::string::npos) {
529 Asm.replace(Pos, SearchStr.size(),
540 Function *NewF = Function::Create(NewFT, NewFLink, NewFName,
544 AttributeList::ReturnIndex,
547 BasicBlock *BB = BasicBlock::Create(*Ctx,
"entry", NewF);
551 CallInst::Create(DFSanVarargWrapperFn,
556 std::vector<Value *>
Args;
559 Args.push_back(&*ai);
560 CallInst *CI = CallInst::Create(F, Args,
"", BB);
562 ReturnInst::Create(*Ctx, BB);
564 ReturnInst::Create(*Ctx, CI, BB);
573 Constant *
C = Mod->getOrInsertFunction(FName, FTT);
576 F->
setLinkage(GlobalValue::LinkOnceODRLinkage);
577 BasicBlock *BB = BasicBlock::Create(*Ctx,
"entry", F);
578 std::vector<Value *>
Args;
581 Args.push_back(&*AI);
585 RI = ReturnInst::Create(*Ctx, BB);
587 RI = ReturnInst::Create(*Ctx, CI, BB);
589 DFSanFunction DFSF(*
this, F,
true);
591 for (
unsigned N = FT->
getNumParams();
N != 0; ++ValAI, ++ShadowAI, --
N)
592 DFSF.ValShadowMap[&*ValAI] = &*ShadowAI;
593 DFSanVisitor(DFSF).visitCallInst(*CI);
595 new StoreInst(DFSF.getShadow(RI->getReturnValue()),
596 &*std::prev(F->
arg_end()), RI);
602 bool DataFlowSanitizer::runOnModule(
Module &M) {
603 if (ABIList.isIn(M,
"skip"))
607 Type *ArgTLSTy = ArrayType::get(ShadowTy, 64);
608 ArgTLS = Mod->getOrInsertGlobal(
"__dfsan_arg_tls", ArgTLSTy);
612 if (!GetRetvalTLSPtr) {
613 RetvalTLS = Mod->getOrInsertGlobal(
"__dfsan_retval_tls", ShadowTy);
621 DFSanUnionFn = Mod->getOrInsertFunction(
"__dfsan_union", DFSanUnionFnTy);
622 if (
Function *F = dyn_cast<Function>(DFSanUnionFn)) {
623 F->
addAttribute(AttributeList::FunctionIndex, Attribute::NoUnwind);
624 F->
addAttribute(AttributeList::FunctionIndex, Attribute::ReadNone);
625 F->
addAttribute(AttributeList::ReturnIndex, Attribute::ZExt);
629 DFSanCheckedUnionFn = Mod->getOrInsertFunction(
"dfsan_union", DFSanUnionFnTy);
630 if (
Function *F = dyn_cast<Function>(DFSanCheckedUnionFn)) {
631 F->
addAttribute(AttributeList::FunctionIndex, Attribute::NoUnwind);
632 F->
addAttribute(AttributeList::FunctionIndex, Attribute::ReadNone);
633 F->
addAttribute(AttributeList::ReturnIndex, Attribute::ZExt);
638 Mod->getOrInsertFunction(
"__dfsan_union_load", DFSanUnionLoadFnTy);
639 if (
Function *F = dyn_cast<Function>(DFSanUnionLoadFn)) {
640 F->
addAttribute(AttributeList::FunctionIndex, Attribute::NoUnwind);
641 F->
addAttribute(AttributeList::FunctionIndex, Attribute::ReadOnly);
642 F->
addAttribute(AttributeList::ReturnIndex, Attribute::ZExt);
644 DFSanUnimplementedFn =
645 Mod->getOrInsertFunction(
"__dfsan_unimplemented", DFSanUnimplementedFnTy);
647 Mod->getOrInsertFunction(
"__dfsan_set_label", DFSanSetLabelFnTy);
648 if (
Function *F = dyn_cast<Function>(DFSanSetLabelFn)) {
651 DFSanNonzeroLabelFn =
652 Mod->getOrInsertFunction(
"__dfsan_nonzero_label", DFSanNonzeroLabelFnTy);
653 DFSanVarargWrapperFn = Mod->getOrInsertFunction(
"__dfsan_vararg_wrapper",
654 DFSanVarargWrapperFnTy);
656 std::vector<Function *> FnsToInstrument;
659 if (!i.isIntrinsic() &&
660 &i != DFSanUnionFn &&
661 &i != DFSanCheckedUnionFn &&
662 &i != DFSanUnionLoadFn &&
663 &i != DFSanUnimplementedFn &&
664 &i != DFSanSetLabelFn &&
665 &i != DFSanNonzeroLabelFn &&
666 &i != DFSanVarargWrapperFn)
667 FnsToInstrument.push_back(&i);
678 bool GAInst = isInstrumented(GA), FInst = isInstrumented(F);
679 if (GAInst && FInst) {
680 addGlobalNamePrefix(GA);
681 }
else if (GAInst != FInst) {
690 FnsToInstrument.push_back(NewF);
695 ReadOnlyNoneAttrs.addAttribute(Attribute::ReadOnly)
696 .addAttribute(Attribute::ReadNone);
700 for (std::vector<Function *>::iterator i = FnsToInstrument.begin(),
701 e = FnsToInstrument.end();
709 if (isInstrumented(&F)) {
712 if (getInstrumentedABI() == IA_Args && !IsZeroArgsVoidRet) {
717 AttributeList::ReturnIndex,
722 FArg != FArgEnd; ++FArg, ++NewFArg) {
723 FArg->replaceAllUsesWith(&*NewFArg);
738 ConstantExpr::getBitCast(NewF, PointerType::getUnqual(FT)));
742 addGlobalNamePrefix(NewF);
744 addGlobalNamePrefix(&F);
746 }
else if (!IsZeroArgsVoidRet || getWrapperKind(&F) == WK_Custom) {
751 ? getArgsFunctionType(FT)
753 Function *NewF = buildWrapperFunction(
754 &F, std::string(
"dfsw$") + std::string(F.
getName()),
755 GlobalValue::LinkOnceODRLinkage, NewFT);
756 if (getInstrumentedABI() == IA_TLS)
759 Value *WrappedFnCst =
760 ConstantExpr::getBitCast(NewF, PointerType::getUnqual(FT));
763 UnwrappedFnMap[WrappedFnCst] = &
F;
771 FnsWithNativeABI.
insert(&F);
776 size_t N = i - FnsToInstrument.begin(),
777 Count = e - FnsToInstrument.begin();
778 FnsToInstrument.push_back(&F);
779 i = FnsToInstrument.begin() +
N;
780 e = FnsToInstrument.begin() + Count;
785 UnwrappedFnMap[&
F] = &
F;
790 for (
Function *i : FnsToInstrument) {
791 if (!i || i->isDeclaration())
796 DFSanFunction DFSF(*
this, i, FnsWithNativeABI.
count(i));
811 bool IsTerminator = isa<TerminatorInst>(Inst);
812 if (!DFSF.SkipInsts.count(Inst))
813 DFSanVisitor(DFSF).visit(Inst);
824 for (std::vector<std::pair<PHINode *, PHINode *> >::iterator
825 i = DFSF.PHIFixups.begin(),
826 e = DFSF.PHIFixups.end();
828 for (
unsigned val = 0, n = i->first->getNumIncomingValues(); val != n;
830 i->second->setIncomingValue(
831 val, DFSF.getShadow(i->first->getIncomingValue(val)));
840 for (
Value *V : DFSF.NonZeroChecks) {
843 Pos =
I->getNextNode();
845 Pos = &DFSF.F->getEntryBlock().front();
846 while (isa<PHINode>(Pos) || isa<AllocaInst>(Pos))
849 Value *Ne = IRB.CreateICmpNE(V, DFSF.DFS.ZeroShadow);
851 Ne, Pos,
false, ColdCallWeights));
853 ThenIRB.CreateCall(DFSF.DFS.DFSanNonzeroLabelFn, {});
861 Value *DFSanFunction::getArgTLSPtr() {
865 return ArgTLSPtr = DFS.ArgTLS;
868 return ArgTLSPtr = IRB.
CreateCall(DFS.GetArgTLS, {});
871 Value *DFSanFunction::getRetvalTLS() {
875 return RetvalTLSPtr = DFS.RetvalTLS;
878 return RetvalTLSPtr = IRB.
CreateCall(DFS.GetRetvalTLS, {});
883 return IRB.CreateConstGEP2_64(getArgTLSPtr(), 0, Idx);
887 if (!isa<Argument>(V) && !isa<Instruction>(V))
888 return DFS.ZeroShadow;
889 Value *&Shadow = ValShadowMap[V];
891 if (
Argument *
A = dyn_cast<Argument>(V)) {
893 return DFS.ZeroShadow;
895 case DataFlowSanitizer::IA_TLS: {
896 Value *ArgTLSPtr = getArgTLSPtr();
899 : cast<Instruction>(ArgTLSPtr)->getNextNode();
901 Shadow = IRB.CreateLoad(getArgTLS(
A->getArgNo(), ArgTLSPos));
904 case DataFlowSanitizer::IA_Args: {
905 unsigned ArgIdx =
A->getArgNo() + F->
arg_size() / 2;
914 NonZeroChecks.push_back(Shadow);
916 Shadow = DFS.ZeroShadow;
923 assert(!ValShadowMap.count(I));
925 ValShadowMap[
I] = Shadow;
929 assert(Addr != RetvalTLS &&
"Reinstrumenting?");
931 Value *ShadowPtrMaskValue;
932 if (DFSanRuntimeShadowMask)
933 ShadowPtrMaskValue = IRB.CreateLoad(IntptrTy, ExternalShadowMask);
935 ShadowPtrMaskValue = ShadowPtrMask;
936 return IRB.CreateIntToPtr(
938 IRB.CreateAnd(IRB.CreatePtrToInt(Addr, IntptrTy),
939 IRB.CreatePtrToInt(ShadowPtrMaskValue, IntptrTy)),
947 if (V1 == DFS.ZeroShadow)
949 if (V2 == DFS.ZeroShadow)
954 auto V1Elems = ShadowElements.find(V1);
955 auto V2Elems = ShadowElements.find(V2);
956 if (V1Elems != ShadowElements.end() && V2Elems != ShadowElements.end()) {
957 if (std::includes(V1Elems->second.begin(), V1Elems->second.end(),
958 V2Elems->second.begin(), V2Elems->second.end())) {
960 }
else if (std::includes(V2Elems->second.begin(), V2Elems->second.end(),
961 V1Elems->second.begin(), V1Elems->second.end())) {
964 }
else if (V1Elems != ShadowElements.end()) {
965 if (V1Elems->second.count(V2))
967 }
else if (V2Elems != ShadowElements.end()) {
968 if (V2Elems->second.count(V1))
972 auto Key = std::make_pair(V1, V2);
975 CachedCombinedShadow &CCS = CachedCombinedShadows[Key];
976 if (CCS.Block && DT.dominates(CCS.Block, Pos->
getParent()))
980 if (AvoidNewBlocks) {
981 CallInst *
Call = IRB.CreateCall(DFS.DFSanCheckedUnionFn, {V1, V2});
982 Call->
addAttribute(AttributeList::ReturnIndex, Attribute::ZExt);
990 Value *Ne = IRB.CreateICmpNE(V1, V2);
992 Ne, Pos,
false, DFS.ColdCallWeights, &DT));
994 CallInst *Call = ThenIRB.CreateCall(DFS.DFSanUnionFn, {V1, V2});
995 Call->
addAttribute(AttributeList::ReturnIndex, Attribute::ZExt);
1000 PHINode *Phi = PHINode::Create(DFS.ShadowTy, 2,
"", &Tail->
front());
1008 std::set<Value *> UnionElems;
1009 if (V1Elems != ShadowElements.end()) {
1010 UnionElems = V1Elems->second;
1012 UnionElems.insert(V1);
1014 if (V2Elems != ShadowElements.end()) {
1015 UnionElems.insert(V2Elems->second.begin(), V2Elems->second.end());
1017 UnionElems.insert(V2);
1019 ShadowElements[CCS.Shadow] = std::move(UnionElems);
1029 return DFS.ZeroShadow;
1033 Shadow = combineShadows(Shadow, getShadow(Inst->
getOperand(i)), Inst);
1038 void DFSanVisitor::visitOperandShadowInst(
Instruction &I) {
1039 Value *CombinedShadow = DFSF.combineOperandShadows(&I);
1040 DFSF.setShadow(&I, CombinedShadow);
1047 if (
AllocaInst *AI = dyn_cast<AllocaInst>(Addr)) {
1049 AllocaShadowMap.find(AI);
1050 if (i != AllocaShadowMap.end()) {
1052 return IRB.CreateLoad(i->second);
1056 uint64_t ShadowAlign = Align * DFS.ShadowWidth / 8;
1059 bool AllConstants =
true;
1060 for (
Value *Obj : Objs) {
1061 if (isa<Function>(Obj) || isa<BlockAddress>(Obj))
1063 if (isa<GlobalVariable>(Obj) && cast<GlobalVariable>(Obj)->
isConstant())
1066 AllConstants =
false;
1070 return DFS.ZeroShadow;
1072 Value *ShadowAddr = DFS.getShadowAddress(Addr, Pos);
1075 return DFS.ZeroShadow;
1083 Value *ShadowAddr1 = IRB.CreateGEP(DFS.ShadowTy, ShadowAddr,
1084 ConstantInt::get(DFS.IntptrTy, 1));
1085 return combineShadows(IRB.CreateAlignedLoad(ShadowAddr, ShadowAlign),
1086 IRB.CreateAlignedLoad(ShadowAddr1, ShadowAlign), Pos);
1089 if (!AvoidNewBlocks && Size % (64 / DFS.ShadowWidth) == 0) {
1093 BasicBlock *FallbackBB = BasicBlock::Create(*DFS.Ctx,
"", F);
1095 CallInst *FallbackCall = FallbackIRB.CreateCall(
1096 DFS.DFSanUnionLoadFn,
1097 {ShadowAddr, ConstantInt::get(DFS.IntptrTy, Size)});
1098 FallbackCall->
addAttribute(AttributeList::ReturnIndex, Attribute::ZExt);
1104 IRB.CreateBitCast(ShadowAddr, Type::getInt64PtrTy(*DFS.Ctx));
1105 Value *WideShadow = IRB.CreateAlignedLoad(WideAddr, ShadowAlign);
1106 Value *TruncShadow = IRB.CreateTrunc(WideShadow, DFS.ShadowTy);
1107 Value *ShlShadow = IRB.CreateShl(WideShadow, DFS.ShadowWidth);
1108 Value *ShrShadow = IRB.CreateLShr(WideShadow, 64 - DFS.ShadowWidth);
1109 Value *RotShadow = IRB.CreateOr(ShlShadow, ShrShadow);
1110 Value *ShadowsEq = IRB.CreateICmpEQ(WideShadow, RotShadow);
1116 std::vector<DomTreeNode *> Children(OldNode->begin(), OldNode->end());
1118 DomTreeNode *NewNode = DT.addNewBlock(Tail, Head);
1119 for (
auto Child : Children)
1120 DT.changeImmediateDominator(Child, NewNode);
1127 BranchInst *LastBr = BranchInst::Create(FallbackBB, FallbackBB, ShadowsEq);
1129 DT.addNewBlock(FallbackBB, Head);
1131 for (uint64_t Ofs = 64 / DFS.ShadowWidth; Ofs != Size;
1132 Ofs += 64 / DFS.ShadowWidth) {
1133 BasicBlock *NextBB = BasicBlock::Create(*DFS.Ctx,
"", F);
1134 DT.addNewBlock(NextBB, LastBr->
getParent());
1136 WideAddr = NextIRB.CreateGEP(Type::getInt64Ty(*DFS.Ctx), WideAddr,
1137 ConstantInt::get(DFS.IntptrTy, 1));
1138 Value *NextWideShadow = NextIRB.CreateAlignedLoad(WideAddr, ShadowAlign);
1139 ShadowsEq = NextIRB.CreateICmpEQ(WideShadow, NextWideShadow);
1141 LastBr = NextIRB.CreateCondBr(ShadowsEq, FallbackBB, FallbackBB);
1145 FallbackIRB.CreateBr(Tail);
1146 PHINode *Shadow = PHINode::Create(DFS.ShadowTy, 2,
"", &Tail->
front());
1153 CallInst *FallbackCall = IRB.CreateCall(
1154 DFS.DFSanUnionLoadFn, {ShadowAddr, ConstantInt::get(DFS.IntptrTy, Size)});
1155 FallbackCall->
addAttribute(AttributeList::ReturnIndex, Attribute::ZExt);
1156 return FallbackCall;
1159 void DFSanVisitor::visitLoadInst(
LoadInst &LI) {
1163 DFSF.setShadow(&LI, DFSF.DFS.ZeroShadow);
1179 Shadow = DFSF.combineShadows(Shadow, PtrShadow, &LI);
1181 if (Shadow != DFSF.DFS.ZeroShadow)
1182 DFSF.NonZeroChecks.push_back(Shadow);
1184 DFSF.setShadow(&LI, Shadow);
1187 void DFSanFunction::storeShadow(
Value *Addr, uint64_t Size, uint64_t Align,
1189 if (
AllocaInst *AI = dyn_cast<AllocaInst>(Addr)) {
1191 AllocaShadowMap.find(AI);
1192 if (i != AllocaShadowMap.end()) {
1194 IRB.CreateStore(Shadow, i->second);
1199 uint64_t ShadowAlign = Align * DFS.ShadowWidth / 8;
1201 Value *ShadowAddr = DFS.getShadowAddress(Addr, Pos);
1202 if (Shadow == DFS.ZeroShadow) {
1203 IntegerType *ShadowTy = IntegerType::get(*DFS.Ctx, Size * DFS.ShadowWidth);
1204 Value *ExtZeroShadow = ConstantInt::get(ShadowTy, 0);
1205 Value *ExtShadowAddr =
1206 IRB.CreateBitCast(ShadowAddr, PointerType::getUnqual(ShadowTy));
1207 IRB.CreateAlignedStore(ExtZeroShadow, ExtShadowAddr, ShadowAlign);
1211 const unsigned ShadowVecSize = 128 / DFS.ShadowWidth;
1213 if (Size >= ShadowVecSize) {
1214 VectorType *ShadowVecTy = VectorType::get(DFS.ShadowTy, ShadowVecSize);
1215 Value *ShadowVec = UndefValue::get(ShadowVecTy);
1216 for (
unsigned i = 0; i != ShadowVecSize; ++i) {
1217 ShadowVec = IRB.CreateInsertElement(
1218 ShadowVec, Shadow, ConstantInt::get(Type::getInt32Ty(*DFS.Ctx), i));
1220 Value *ShadowVecAddr =
1221 IRB.CreateBitCast(ShadowAddr, PointerType::getUnqual(ShadowVecTy));
1223 Value *CurShadowVecAddr =
1224 IRB.CreateConstGEP1_32(ShadowVecTy, ShadowVecAddr, Offset);
1225 IRB.CreateAlignedStore(ShadowVec, CurShadowVecAddr, ShadowAlign);
1226 Size -= ShadowVecSize;
1228 }
while (Size >= ShadowVecSize);
1229 Offset *= ShadowVecSize;
1232 Value *CurShadowAddr =
1233 IRB.CreateConstGEP1_32(DFS.ShadowTy, ShadowAddr, Offset);
1234 IRB.CreateAlignedStore(Shadow, CurShadowAddr, ShadowAlign);
1240 void DFSanVisitor::visitStoreInst(
StoreInst &
SI) {
1258 Shadow = DFSF.combineShadows(Shadow, PtrShadow, &SI);
1264 visitOperandShadowInst(BO);
1267 void DFSanVisitor::visitCastInst(
CastInst &CI) { visitOperandShadowInst(CI); }
1269 void DFSanVisitor::visitCmpInst(
CmpInst &CI) { visitOperandShadowInst(CI); }
1272 visitOperandShadowInst(GEPI);
1276 visitOperandShadowInst(I);
1280 visitOperandShadowInst(I);
1284 visitOperandShadowInst(I);
1288 visitOperandShadowInst(I);
1292 visitOperandShadowInst(I);
1295 void DFSanVisitor::visitAllocaInst(
AllocaInst &I) {
1296 bool AllLoadsStores =
true;
1298 if (isa<LoadInst>(U))
1301 if (
StoreInst *SI = dyn_cast<StoreInst>(U)) {
1306 AllLoadsStores =
false;
1309 if (AllLoadsStores) {
1311 DFSF.AllocaShadowMap[&
I] = IRB.CreateAlloca(DFSF.DFS.ShadowTy);
1313 DFSF.setShadow(&I, DFSF.DFS.ZeroShadow);
1316 void DFSanVisitor::visitSelectInst(
SelectInst &I) {
1324 DFSF.combineShadows(
1325 CondShadow, DFSF.combineShadows(TrueShadow, FalseShadow, &I), &
I));
1328 if (TrueShadow == FalseShadow) {
1329 ShadowSel = TrueShadow;
1332 SelectInst::Create(I.
getCondition(), TrueShadow, FalseShadow,
"", &
I);
1334 DFSF.setShadow(&I, DFSF.combineShadows(CondShadow, ShadowSel, &I));
1338 void DFSanVisitor::visitMemSetInst(
MemSetInst &I) {
1341 IRB.CreateCall(DFSF.DFS.DFSanSetLabelFn,
1342 {ValShadow, IRB.CreateBitCast(I.
getDest(), Type::getInt8PtrTy(
1344 IRB.CreateZExtOrTrunc(I.
getLength(), DFSF.DFS.IntptrTy)});
1349 Value *DestShadow = DFSF.DFS.getShadowAddress(I.
getDest(), &
I);
1351 Value *LenShadow = IRB.CreateMul(
1358 DFSF.DFS.ShadowWidth / 8));
1361 DFSF.DFS.ShadowWidth / 8);
1363 Type *Int8Ptr = Type::getInt8PtrTy(*DFSF.DFS.Ctx);
1364 DestShadow = IRB.CreateBitCast(DestShadow, Int8Ptr);
1365 SrcShadow = IRB.CreateBitCast(SrcShadow, Int8Ptr);
1366 IRB.CreateCall(I.
getCalledValue(), {DestShadow, SrcShadow, LenShadow,
1370 void DFSanVisitor::visitReturnInst(
ReturnInst &RI) {
1373 case DataFlowSanitizer::IA_TLS: {
1376 IRB.CreateStore(S, DFSF.getRetvalTLS());
1379 case DataFlowSanitizer::IA_Args: {
1381 Type *RT = DFSF.F->getFunctionType()->getReturnType();
1383 IRB.CreateInsertValue(UndefValue::get(RT), RI.
getReturnValue(), 0);
1385 IRB.CreateInsertValue(InsVal, DFSF.getShadow(RI.
getReturnValue()), 1);
1393 void DFSanVisitor::visitCallSite(
CallSite CS) {
1402 if (F == DFSF.DFS.DFSanVarargWrapperFn)
1409 if (i != DFSF.DFS.UnwrappedFnMap.end()) {
1411 switch (DFSF.DFS.getWrapperKind(F)) {
1412 case DataFlowSanitizer::WK_Warning: {
1414 IRB.CreateCall(DFSF.DFS.DFSanUnimplementedFn,
1415 IRB.CreateGlobalStringPtr(F->
getName()));
1419 case DataFlowSanitizer::WK_Discard: {
1424 case DataFlowSanitizer::WK_Functional: {
1429 case DataFlowSanitizer::WK_Custom: {
1435 FunctionType *CustomFT = DFSF.DFS.getCustomFunctionType(FT);
1436 std::string CustomFName =
"__dfsw_";
1439 DFSF.DFS.Mod->getOrInsertFunction(CustomFName, CustomFT);
1440 if (
Function *CustomFn = dyn_cast<Function>(CustomF)) {
1441 CustomFn->copyAttributesFrom(F);
1445 CustomFn->removeAttributes(AttributeList::FunctionIndex,
1446 DFSF.DFS.ReadOnlyNoneAttrs);
1450 std::vector<Value *>
Args;
1452 CallSite::arg_iterator i = CS.
arg_begin();
1453 for (
unsigned n = FT->
getNumParams(); n != 0; ++i, --n) {
1454 Type *T = (*i)->getType();
1456 if (isa<PointerType>(T) &&
1457 (ParamFT = dyn_cast<FunctionType>(
1458 cast<PointerType>(T)->getElementType()))) {
1459 std::string TName =
"dfst";
1463 Constant *T = DFSF.DFS.getOrBuildTrampolineFunction(ParamFT, TName);
1466 IRB.CreateBitCast(*i, Type::getInt8PtrTy(*DFSF.DFS.Ctx)));
1473 const unsigned ShadowArgStart = Args.size();
1474 for (
unsigned n = FT->
getNumParams(); n != 0; ++i, --n)
1475 Args.push_back(DFSF.getShadow(*i));
1478 auto *LabelVATy = ArrayType::get(DFSF.DFS.ShadowTy,
1481 LabelVATy, getDataLayout().getAllocaAddrSpace(),
1482 "labelva", &DFSF.F->getEntryBlock().front());
1484 for (
unsigned n = 0; i != CS.
arg_end(); ++i, ++n) {
1485 auto LabelVAPtr = IRB.CreateStructGEP(LabelVATy, LabelVAAlloca, n);
1486 IRB.CreateStore(DFSF.getShadow(*i), LabelVAPtr);
1489 Args.push_back(IRB.CreateStructGEP(LabelVATy, LabelVAAlloca, 0));
1493 if (!DFSF.LabelReturnAlloca) {
1494 DFSF.LabelReturnAlloca =
1496 getDataLayout().getAllocaAddrSpace(),
1497 "labelreturn", &DFSF.F->getEntryBlock().front());
1499 Args.push_back(DFSF.LabelReturnAlloca);
1505 CallInst *CustomCI = IRB.CreateCall(CustomF, Args);
1513 const unsigned ArgNo = ShadowArgStart + n;
1519 LoadInst *LabelLoad = IRB.CreateLoad(DFSF.LabelReturnAlloca);
1520 DFSF.setShadow(CustomCI, LabelLoad);
1534 if (DFSF.DFS.getInstrumentedABI() == DataFlowSanitizer::IA_TLS) {
1535 for (
unsigned i = 0, n = FT->
getNumParams(); i != n; ++i) {
1536 IRB.CreateStore(DFSF.getShadow(CS.
getArgument(i)),
1544 if (II->getNormalDest()->getSinglePredecessor()) {
1545 Next = &II->getNormalDest()->front();
1548 SplitEdge(II->getParent(), II->getNormalDest(), &DFSF.DT);
1549 Next = &NewBB->
front();
1553 Next = CS->getNextNode();
1556 if (DFSF.DFS.getInstrumentedABI() == DataFlowSanitizer::IA_TLS) {
1558 LoadInst *LI = NextIRB.CreateLoad(DFSF.getRetvalTLS());
1559 DFSF.SkipInsts.insert(LI);
1561 DFSF.NonZeroChecks.push_back(LI);
1567 if (DFSF.DFS.getInstrumentedABI() == DataFlowSanitizer::IA_Args) {
1568 FunctionType *NewFT = DFSF.DFS.getArgsFunctionType(FT);
1570 IRB.CreateBitCast(CS.
getCalledValue(), PointerType::getUnqual(NewFT));
1571 std::vector<Value *>
Args;
1574 for (
unsigned n = FT->
getNumParams(); n != 0; ++i, --n)
1578 for (
unsigned n = FT->
getNumParams(); n != 0; ++i, --n)
1579 Args.push_back(DFSF.getShadow(*i));
1583 ArrayType *VarArgArrayTy = ArrayType::get(DFSF.DFS.ShadowTy, VarArgSize);
1585 new AllocaInst(VarArgArrayTy, getDataLayout().getAllocaAddrSpace(),
1586 "", &DFSF.F->getEntryBlock().front());
1587 Args.push_back(IRB.CreateConstGEP2_32(VarArgArrayTy, VarArgShadow, 0, 0));
1588 for (
unsigned n = 0; i != e; ++i, ++n) {
1591 IRB.CreateConstGEP2_32(VarArgArrayTy, VarArgShadow, 0, n));
1598 NewCS = IRB.CreateInvoke(Func, II->getNormalDest(), II->getUnwindDest(),
1601 NewCS = IRB.CreateCall(Func, Args);
1605 *DFSF.DFS.Ctx, AttributeList::ReturnIndex,
1611 DFSF.SkipInsts.insert(ExVal);
1614 DFSF.SkipInsts.insert(ExShadow);
1615 DFSF.setShadow(ExVal, ExShadow);
1616 DFSF.NonZeroChecks.push_back(ExShadow);
1625 void DFSanVisitor::visitPHINode(
PHINode &PN) {
1630 Value *UndefShadow = UndefValue::get(DFSF.DFS.ShadowTy);
1636 DFSF.PHIFixups.push_back(std::make_pair(&PN, ShadowPN));
1637 DFSF.setShadow(&PN, ShadowPN);
Return a value (possibly void), from a function.
Value * getValueOperand()
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static cl::list< std::string > ClABIListFiles("dfsan-abilist", cl::desc("File listing native ABI functions and how the pass treats them"), cl::Hidden)
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
LinkageTypes getLinkage() const
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
void ReplaceInstWithInst(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Instruction *I)
Replace the instruction specified by BI with the instruction specified by I.
This class is the base class for the comparison instructions.
static bool isConstant(const MachineInstr &MI)
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
This class represents an incoming formal argument to a Function.
Base class for instruction visitors.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
ConstantInt * getAlignmentCst() const
Value * getValue() const
Return the arguments to the instruction.
Implements a dense probed hash-table based set.
unsigned getNumOperands() const
BBTy * getParent() const
Get the basic block containing the call site.
Type * getValueType() const
This class represents a function call, abstracting a target machine's calling convention.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
This instruction constructs a fixed permutation of two input vectors.
This class wraps the llvm.memset intrinsic.
const Instruction & front() const
An instruction for reading from memory.
void GetUnderlyingObjects(Value *V, SmallVectorImpl< Value * > &Objects, const DataLayout &DL, LoopInfo *LI=nullptr, unsigned MaxLookup=6)
This method is similar to GetUnderlyingObject except that it can look through phi and select instruct...
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Type * getPointerElementType() const
unsigned arg_size() const
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
StringRef getName() const
Return a constant reference to the value's name.
block_iterator block_end()
iterator begin()
Instruction iterator methods.
void setCallingConv(CallingConv::ID CC)
static cl::opt< bool > ClArgsABI("dfsan-args-abi", cl::desc("Use the argument ABI rather than the TLS ABI"), cl::Hidden)
The address of a basic block.
This class represents the LLVM 'select' instruction.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
This is the base class for all instructions that perform data casts.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Class to represent struct types.
param_iterator param_end() const
ValTy * getCalledValue() const
Return the pointer to function that is being called.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
void setThreadLocalMode(ThreadLocalMode Val)
void setModuleInlineAsm(StringRef Asm)
Set the module-scope inline assembly blocks.
void setName(const Twine &Name)
Change the name of the value.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
static cl::opt< bool > ClCombinePointerLabelsOnStore("dfsan-combine-pointer-labels-on-store", cl::desc("Combine the label of the pointer with the label of the data when ""storing in memory."), cl::Hidden, cl::init(false))
block_iterator block_begin()
Class to represent function types.
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
Class to represent array types.
BasicBlock * getSuccessor(unsigned i) const
Base class for the actual dominator tree node.
static std::string utostr(uint64_t X, bool isNeg=false)
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void takeName(Value *V)
Transfer the name from V to this value.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Class to represent pointers.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
Function Alias Analysis false
void setAttributes(AttributeList PAL)
Set the parameter attributes of the call.
initializer< Ty > init(const Ty &Val)
This instruction inserts a single (scalar) element into a VectorType value.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Conditional or Unconditional Branch instruction.
This function has undefined behavior.
This is an important base class in LLVM.
const Value * getCondition() const
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
param_iterator param_begin() const
static const char *const kDFSanExternShadowPtrMask
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
void splice(iterator where, iplist_impl &L2)
const GlobalObject * getBaseObject() const
ConstantInt * getVolatileCst() const
void setCallingConv(CallingConv::ID CC)
Set the calling convention of the call.
Value * getOperand(unsigned i) const
Value * getPointerOperand()
AttributeList getAttributes() const
Get the parameter attributes of the call.
self_iterator getIterator()
Class to represent integer types.
void setAlignment(unsigned Align)
Type * getType() const
Return the type of the instruction that generated this call site.
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight)
Return metadata containing two branch weights.
const Value * getTrueValue() const
Triple - Helper class for working with autoconf configuration names.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Iterator for intrusive lists based on ilist_node.
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
InstrTy * getInstruction() const
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions that feed it, giving the original input.
bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI=nullptr)
Remove all blocks that can not be reached from the function's entry.
ValTy * getArgument(unsigned ArgNo) const
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
Type::subtype_iterator param_iterator
static ManagedStatic< CodeViewErrorCategory > Category
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
TerminatorInst * SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
static cl::opt< bool > ClDebugNonzeroLabels("dfsan-debug-nonzero-labels", cl::desc("Insert calls to __dfsan_nonzero_label on observing a parameter, ""load or return with a nonzero label"), cl::Hidden)
Value * getLength() const
BasicBlock * getBasicBlock() const
const BasicBlock & getEntryBlock() const
void setLinkage(LinkageTypes LT)
void setOperand(unsigned i, Value *Val)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static cl::opt< bool > ClPreserveAlignment("dfsan-preserve-alignment", cl::desc("respect alignment requirements provided by input IR"), cl::Hidden, cl::init(false))
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
Class to represent vector types.
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
LinkageTypes
An enumeration for the kinds of linkage for global values.
INITIALIZE_PASS(DataFlowSanitizer,"dfsan","DataFlowSanitizer: dynamic data flow analysis.", false, false) ModulePass *llvm
iterator_range< user_iterator > users()
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
AttributeList removeAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
void removeAttributes(unsigned i, const AttrBuilder &Attrs)
removes the attributes from the list of attributes.
PointerType * getType() const
Global values are always pointers.
This class wraps the llvm.memcpy/memmove intrinsics.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
unsigned getAlignment() const
Return the alignment of the access that is being performed.
AttributeList getAttributes() const
Return the parameter attributes for this call.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
CallInst * CreateCall(Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
iterator_range< df_iterator< T > > depth_first(const T &G)
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
AttrBuilder typeIncompatible(Type *Ty)
Which attributes cannot be applied to a type.
ModulePass * createDataFlowSanitizerPass(const std::vector< std::string > &ABIListFiles=std::vector< std::string >(), void *(*getArgTLS)()=nullptr, void *(*getRetValTLS)()=nullptr)
BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
Split the edge connecting specified block.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
const Value * getFalseValue() const
StringRef - Represent a constant reference to a string, i.e.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static cl::opt< bool > ClCombinePointerLabelsOnLoad("dfsan-combine-pointer-labels-on-load", cl::desc("Combine the label of the pointer with the label of the data when ""loading from memory."), cl::Hidden, cl::init(true))
Value * getPointerOperand()
void setCalledFunction(Value *V)
Set the callee to the specified value.
const BasicBlock * getParent() const
LLVMContext & getContext() const
Get the global data context.
bool isVoidTy() const
Return true if this is 'void'.
an instruction to allocate memory on the stack
This instruction inserts a struct field of array element value into an aggregate value.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.