Lines Matching defs:IRB

702   CallInst *createRuntimeCall(IRBuilder<> &IRB, FunctionCallee Callee,
705 assert(IRB.GetInsertBlock()->getParent() == OwnerFn);
707 CallInst *Inst = IRB.CreateCall(Callee, Args, Name, nullptr);
774 Instruction *genAMDGPUReportBlock(IRBuilder<> &IRB, Value *Cond,
789 Value *createSlowPathCmp(IRBuilder<> &IRB, Value *AddrLong,
796 Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
914 void instrumentGlobals(IRBuilder<> &IRB, Module &M, bool *CtorComdat);
915 void InstrumentGlobalsCOFF(IRBuilder<> &IRB, Module &M,
918 void instrumentGlobalsELF(IRBuilder<> &IRB, Module &M,
922 void InstrumentGlobalsMachO(IRBuilder<> &IRB, Module &M,
926 InstrumentGlobalsWithMetadataArray(IRBuilder<> &IRB, Module &M,
1095 IRBuilder<> IRB(InstBefore);
1096 Value *DynamicAreaPtr = IRB.CreatePtrToInt(SavedStack, IntptrTy);
1106 Value *DynamicAreaOffset = IRB.CreateCall(DynamicAreaOffsetFunc, {});
1108 DynamicAreaPtr = IRB.CreateAdd(IRB.CreatePtrToInt(SavedStack, IntptrTy),
1113 IRB, AsanAllocasUnpoisonFunc,
1114 {IRB.CreateLoad(IntptrTy, DynamicAllocaLayout), DynamicAreaPtr});
1216 IRBuilder<> &IRB, Value *ShadowBase);
1218 size_t Begin, size_t End, IRBuilder<> &IRB,
1222 size_t End, IRBuilder<> &IRB, Value *ShadowBase);
1224 void poisonAlloca(Value *V, uint64_t Size, IRBuilder<> &IRB, bool DoPoison);
1226 Value *createAllocaForLayout(IRBuilder<> &IRB, const ASanStackFrameLayout &L,
1228 PHINode *createPHI(IRBuilder<> &IRB, Value *Cond, Value *ValueIfTrue,
1314 Value *AddressSanitizer::memToShadow(Value *Shadow, IRBuilder<> &IRB) {
1316 Shadow = IRB.CreateLShr(Shadow, Mapping.Scale);
1325 return IRB.CreateOr(Shadow, ShadowBase);
1327 return IRB.CreateAdd(Shadow, ShadowBase);
1333 InstrumentationIRBuilder IRB(MI);
1336 IRB, isa<MemMoveInst>(MI) ? AsanMemmove : AsanMemcpy,
1337 {IRB.CreateAddrSpaceCast(MI->getOperand(0), PtrTy),
1338 IRB.CreateAddrSpaceCast(MI->getOperand(1), PtrTy),
1339 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
1342 IRB, AsanMemset,
1343 {IRB.CreateAddrSpaceCast(MI->getOperand(0), PtrTy),
1344 IRB.CreateIntCast(MI->getOperand(1), IRB.getInt32Ty(), false),
1345 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
1581 IRBuilder<> IRB(I);
1586 i = IRB.CreatePointerCast(i, IntptrTy);
1588 RTCI.createRuntimeCall(IRB, F, Param);
1652 [&](IRBuilderBase &IRB, Value *Index) {
1653 Value *MaskElem = IRB.CreateExtractElement(Mask, Index);
1662 MaskElem, &*IRB.GetInsertPoint(), false);
1663 IRB.SetInsertPoint(ThenTerm);
1671 InstrumentedAddress = IRB.CreateExtractElement(Addr, Index);
1673 Index = IRB.CreateMul(Index, Stride);
1674 InstrumentedAddress = IRB.CreatePtrAdd(Addr, Index);
1676 InstrumentedAddress = IRB.CreateGEP(VTy, Addr, {Zero, Index});
1678 doInstrumentAddress(Pass, I, &*IRB.GetInsertPoint(), InstrumentedAddress,
1747 InstrumentationIRBuilder IRB(InsertBefore);
1748 Value *ExpVal = Exp == 0 ? nullptr : ConstantInt::get(IRB.getInt32Ty(), Exp);
1752 Call = RTCI.createRuntimeCall(IRB, AsanErrorCallbackSized[IsWrite][0],
1755 Call = RTCI.createRuntimeCall(IRB, AsanErrorCallbackSized[IsWrite][1],
1760 IRB, AsanErrorCallback[IsWrite][0][AccessSizeIndex], Addr);
1763 IRB, AsanErrorCallback[IsWrite][1][AccessSizeIndex], {Addr, ExpVal});
1770 Value *AddressSanitizer::createSlowPathCmp(IRBuilder<> &IRB, Value *AddrLong,
1776 IRB.CreateAnd(AddrLong, ConstantInt::get(IntptrTy, Granularity - 1));
1779 LastAccessedByte = IRB.CreateAdd(
1783 IRB.CreateIntCast(LastAccessedByte, ShadowValue->getType(), false);
1785 return IRB.CreateICmpSGE(LastAccessedByte, ShadowValue);
1799 IRBuilder<> IRB(InsertBefore);
1800 Value *IsShared = IRB.CreateCall(AMDGPUAddressShared, {Addr});
1801 Value *IsPrivate = IRB.CreateCall(AMDGPUAddressPrivate, {Addr});
1802 Value *IsSharedOrPrivate = IRB.CreateOr(IsShared, IsPrivate);
1803 Value *Cmp = IRB.CreateNot(IsSharedOrPrivate);
1810 Instruction *AddressSanitizer::genAMDGPUReportBlock(IRBuilder<> &IRB,
1812 Module &M = *IRB.GetInsertBlock()->getModule();
1815 auto Ballot = M.getOrInsertFunction(kAMDGPUBallotName, IRB.getInt64Ty(),
1816 IRB.getInt1Ty());
1817 ReportCond = IRB.CreateIsNotNull(IRB.CreateCall(Ballot, {Cond}));
1821 SplitBlockAndInsertIfThen(ReportCond, &*IRB.GetInsertPoint(), false,
1829 IRB.SetInsertPoint(Trm);
1830 return IRB.CreateCall(
1831 M.getOrInsertFunction(kAMDGPUUnreachableName, IRB.getVoidTy()), {});
1848 InstrumentationIRBuilder IRB(InsertBefore);
1854 Module *M = IRB.GetInsertBlock()->getParent()->getParent();
1855 IRB.CreateCall(
1857 {IRB.CreatePointerCast(Addr, PtrTy),
1862 Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
1866 IRB, AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex], AddrLong);
1869 IRB, AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
1870 {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
1877 Value *ShadowPtr = memToShadow(AddrLong, IRB);
1880 Value *ShadowValue = IRB.CreateAlignedLoad(
1881 ShadowTy, IRB.CreateIntToPtr(ShadowPtr, ShadowPtrTy), Align(ShadowAlign));
1883 Value *Cmp = IRB.CreateIsNotNull(ShadowValue);
1891 auto *Cmp2 = createSlowPathCmp(IRB, AddrLong, ShadowValue, TypeStoreSize);
1892 Cmp = IRB.CreateAnd(Cmp, Cmp2);
1894 CrashTerm = genAMDGPUReportBlock(IRB, Cmp, Recover);
1902 IRB.SetInsertPoint(CheckTerm);
1903 Value *Cmp2 = createSlowPathCmp(IRB, AddrLong, ShadowValue, TypeStoreSize);
1931 InstrumentationIRBuilder IRB(InsertBefore);
1932 Value *NumBits = IRB.CreateTypeSize(IntptrTy, TypeStoreSize);
1933 Value *Size = IRB.CreateLShr(NumBits, ConstantInt::get(IntptrTy, 3));
1935 Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
1938 RTCI.createRuntimeCall(IRB, AsanMemoryAccessCallbackSized[IsWrite][0],
1942 IRB, AsanMemoryAccessCallbackSized[IsWrite][1],
1943 {AddrLong, Size, ConstantInt::get(IRB.getInt32Ty(), Exp)});
1945 Value *SizeMinusOne = IRB.CreateSub(Size, ConstantInt::get(IntptrTy, 1));
1946 Value *LastByte = IRB.CreateIntToPtr(
1947 IRB.CreateAdd(AddrLong, SizeMinusOne),
1959 IRBuilder<> IRB(&GlobalInit.front(),
1964 IRB.CreateCall(AsanPoisonGlobals, ModuleNameAddr);
2198 IRBuilder<> IRB(*C);
2202 M.getOrInsertFunction(kAsanPoisonGlobalsName, IRB.getVoidTy(), IntptrTy);
2204 M.getOrInsertFunction(kAsanUnpoisonGlobalsName, IRB.getVoidTy());
2208 kAsanRegisterGlobalsName, IRB.getVoidTy(), IntptrTy, IntptrTy);
2210 kAsanUnregisterGlobalsName, IRB.getVoidTy(), IntptrTy, IntptrTy);
2215 kAsanRegisterImageGlobalsName, IRB.getVoidTy(), IntptrTy);
2217 kAsanUnregisterImageGlobalsName, IRB.getVoidTy(), IntptrTy);
2220 M.getOrInsertFunction(kAsanRegisterElfGlobalsName, IRB.getVoidTy(),
2223 M.getOrInsertFunction(kAsanUnregisterElfGlobalsName, IRB.getVoidTy(),
2295 IRBuilder<> &IRB, Module &M, ArrayRef<GlobalVariable *> ExtendedGlobals,
2328 IRBuilder<> &IRB, Module &M, ArrayRef<GlobalVariable *> ExtendedGlobals,
2380 IRB.CreateCall(AsanRegisterElfGlobals,
2381 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy),
2382 IRB.CreatePointerCast(StartELFMetadata, IntptrTy),
2383 IRB.CreatePointerCast(StopELFMetadata, IntptrTy)});
2390 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy),
2391 IRB.CreatePointerCast(StartELFMetadata, IntptrTy),
2392 IRB.CreatePointerCast(StopELFMetadata, IntptrTy)});
2397 IRBuilder<> &IRB, Module &M, ArrayRef<GlobalVariable *> ExtendedGlobals,
2444 IRB.CreateCall(AsanRegisterImageGlobals,
2445 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy)});
2452 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy)});
2457 IRBuilder<> &IRB, Module &M, ArrayRef<GlobalVariable *> ExtendedGlobals,
2474 IRB.CreateCall(AsanRegisterGlobals,
2475 {IRB.CreatePointerCast(AllGlobals, IntptrTy),
2483 {IRB.CreatePointerCast(AllGlobals, IntptrTy),
2493 void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB, Module &M,
2558 Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize);
2592 Indices2[0] = IRB.getInt32(0);
2593 Indices2[1] = IRB.getInt32(0);
2622 new GlobalVariable(M, IRB.getInt8Ty(), false, Linkage,
2623 Constant::getNullValue(IRB.getInt8Ty()),
2669 instrumentGlobalsELF(IRB, M, NewGlobals, Initializers,
2678 InstrumentGlobalsCOFF(IRB, M, NewGlobals, Initializers);
2680 InstrumentGlobalsMachO(IRB, M, NewGlobals, Initializers);
2682 InstrumentGlobalsWithMetadataArray(IRB, M, NewGlobals, Initializers);
2753 IRBuilder<> IRB(AsanCtorFunction->getEntryBlock().getTerminator());
2754 instrumentGlobals(IRB, M, &CtorComdat);
2756 IRBuilder<> IRB(*C);
2757 instrumentGlobals(IRB, M, &CtorComdat);
2786 IRBuilder<> IRB(*C);
2810 FunctionType::get(IRB.getVoidTy(), Args2, false), AL2);
2814 FunctionType::get(IRB.getVoidTy(), Args2, false), AL2);
2822 FunctionType::get(IRB.getVoidTy(), Args1, false), AL1);
2827 FunctionType::get(IRB.getVoidTy(), Args1, false), AL1);
2842 PtrTy, PtrTy, IRB.getInt32Ty(), IntptrTy);
2845 M.getOrInsertFunction(kAsanHandleNoReturnName, IRB.getVoidTy());
2848 M.getOrInsertFunction(kAsanPtrCmp, IRB.getVoidTy(), IntptrTy, IntptrTy);
2850 M.getOrInsertFunction(kAsanPtrSub, IRB.getVoidTy(), IntptrTy, IntptrTy);
2853 ArrayType::get(IRB.getInt8Ty(), 0));
2856 M.getOrInsertFunction(kAMDGPUAddressSharedName, IRB.getInt1Ty(), PtrTy);
2858 M.getOrInsertFunction(kAMDGPUAddressPrivateName, IRB.getInt1Ty(), PtrTy);
2872 IRBuilder<> IRB(&F.front(), F.front().begin());
2873 IRB.CreateCall(AsanInitFunction, {});
2884 IRBuilder<> IRB(&F.front().front());
2894 IRB.CreateCall(Asm, {AsanShadowGlobal}, ".asan.shadow");
2897 IRB.CreatePointerCast(AsanShadowGlobal, IntptrTy, ".asan.shadow");
2902 LocalDynamicShadow = IRB.CreateLoad(IntptrTy, GlobalDynamicAddress);
3072 IRBuilder<> IRB(CI);
3073 RTCI.createRuntimeCall(IRB, AsanHandleNoReturnFunc, {});
3104 IRBuilder<> IRB(*C);
3117 IRB.getVoidTy(), IntptrTy, IntptrTy);
3122 kAsanPoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy);
3124 kAsanUnpoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy);
3133 M.getOrInsertFunction(Name.str(), IRB.getVoidTy(), IntptrTy, IntptrTy);
3137 kAsanAllocaPoison, IRB.getVoidTy(), IntptrTy, IntptrTy);
3139 kAsanAllocasUnpoison, IRB.getVoidTy(), IntptrTy, IntptrTy);
3145 IRBuilder<> &IRB,
3185 Value *Ptr = IRB.CreateAdd(ShadowBase, ConstantInt::get(IntptrTy, i));
3186 Value *Poison = IRB.getIntN(StoreSizeInBytes * 8, Val);
3187 IRB.CreateAlignedStore(
3188 Poison, IRB.CreateIntToPtr(Ptr, PointerType::getUnqual(Poison->getContext())),
3197 IRBuilder<> &IRB, Value *ShadowBase) {
3198 copyToShadow(ShadowMask, ShadowBytes, 0, ShadowMask.size(), IRB, ShadowBase);
3204 IRBuilder<> &IRB, Value *ShadowBase) {
3221 copyToShadowInline(ShadowMask, ShadowBytes, Done, i, IRB, ShadowBase);
3223 IRB, AsanSetShadowFunc[Val],
3224 {IRB.CreateAdd(ShadowBase, ConstantInt::get(IntptrTy, i)),
3230 copyToShadowInline(ShadowMask, ShadowBytes, Done, End, IRB, ShadowBase);
3250 IRBuilder<> IRB(CopyInsertPoint);
3258 AllocaInst *AI = IRB.CreateAlloca(
3266 IRB.CreateMemCpy(AI, Alignment, &Arg, Alignment, AllocSize);
3271 PHINode *FunctionStackPoisoner::createPHI(IRBuilder<> &IRB, Value *Cond,
3275 PHINode *PHI = IRB.CreatePHI(IntptrTy, 2);
3284 IRBuilder<> &IRB, const ASanStackFrameLayout &L, bool Dynamic) {
3287 Alloca = IRB.CreateAlloca(IRB.getInt8Ty(),
3288 ConstantInt::get(IRB.getInt64Ty(), L.FrameSize),
3291 Alloca = IRB.CreateAlloca(ArrayType::get(IRB.getInt8Ty(), L.FrameSize),
3298 return IRB.CreatePointerCast(Alloca, IntptrTy);
3303 IRBuilder<> IRB(dyn_cast<Instruction>(FirstBB.begin()));
3304 DynamicAllocaLayout = IRB.CreateAlloca(IntptrTy, nullptr);
3305 IRB.CreateStore(Constant::getNullValue(IntptrTy), DynamicAllocaLayout);
3322 IRBuilder<> IRB(APC.InsBefore);
3323 poisonAlloca(APC.AI, APC.Size, IRB, APC.DoPoison);
3402 IRBuilder<> IRB(InsBefore);
3485 DoDynamicAlloca ? nullptr : createAllocaForLayout(IRB, L, false);
3494 IRB.CreateAlloca(IntptrTy, nullptr, "asan_local_stack_base");
3502 kAsanOptionDetectUseAfterReturn, IRB.getInt32Ty());
3503 Value *UseAfterReturnIsEnabled = IRB.CreateICmpNE(
3504 IRB.CreateLoad(IRB.getInt32Ty(), OptionDetectUseAfterReturn),
3505 Constant::getNullValue(IRB.getInt32Ty()));
3514 IRB.SetInsertPoint(InsBefore);
3515 FakeStack = createPHI(IRB, UseAfterReturnIsEnabled, FakeStackValue, Term,
3524 RTCI.createRuntimeCall(IRB, AsanStackMallocFunc[StackMallocIdx],
3528 IRB.CreateICmpEQ(FakeStack, Constant::getNullValue(IntptrTy));
3535 IRB.SetInsertPoint(InsBefore);
3536 LocalStackBase = createPHI(IRB, NoFakeStack, AllocaValue, Term, FakeStack);
3537 IRB.CreateStore(LocalStackBase, LocalStackBaseAlloca);
3544 DoDynamicAlloca ? createAllocaForLayout(IRB, L, true) : StaticAlloca;
3563 Value *NewAllocaPtr = IRB.CreateIntToPtr(
3564 IRB.CreateAdd(LocalStackBase, ConstantInt::get(IntptrTy, Desc.Offset)),
3571 Value *BasePlus0 = IRB.CreateIntToPtr(LocalStackBase, IntptrPtrTy);
3572 IRB.CreateStore(ConstantInt::get(IntptrTy, kCurrentStackFrameMagic),
3575 Value *BasePlus1 = IRB.CreateIntToPtr(
3576 IRB.CreateAdd(LocalStackBase,
3582 Value *Description = IRB.CreatePointerCast(StackDescriptionGlobal, IntptrTy);
3583 IRB.CreateStore(Description, BasePlus1);
3585 Value *BasePlus2 = IRB.CreateIntToPtr(
3586 IRB.CreateAdd(LocalStackBase,
3589 IRB.CreateStore(IRB.CreatePointerCast(&F, IntptrTy), BasePlus2);
3594 Value *ShadowBase = ASan.memToShadow(LocalStackBase, IRB);
3597 copyToShadow(ShadowAfterScope, ShadowAfterScope, IRB, ShadowBase);
3609 IRBuilder<> IRB(APC.InsBefore);
3612 IRB, ShadowBase);
3677 IRBuilder<> &IRB, bool DoPoison) {
3679 Value *AddrArg = IRB.CreatePointerCast(V, IntptrTy);
3682 IRB, DoPoison ? AsanPoisonStackMemoryFunc : AsanUnpoisonStackMemoryFunc,
3695 IRBuilder<> IRB(AI);
3711 IRB.CreateMul(IRB.CreateIntCast(AI->getArraySize(), IntptrTy, false),
3715 Value *PartialSize = IRB.CreateAnd(OldSize, AllocaRzMask);
3718 Value *Misalign = IRB.CreateSub(AllocaRzSize, PartialSize);
3721 Value *Cond = IRB.CreateICmpNE(Misalign, AllocaRzSize);
3722 Value *PartialPadding = IRB.CreateSelect(Cond, Misalign, Zero);
3727 Value *AdditionalChunkSize = IRB.CreateAdd(
3731 Value *NewSize = IRB.CreateAdd(OldSize, AdditionalChunkSize);
3734 AllocaInst *NewAlloca = IRB.CreateAlloca(IRB.getInt8Ty(), NewSize);
3739 IRB.CreateAdd(IRB.CreatePtrToInt(NewAlloca, IntptrTy),
3743 RTCI.createRuntimeCall(IRB, AsanAllocaPoisonFunc, {NewAddress, OldSize});
3747 IRB.CreateStore(IRB.CreatePtrToInt(NewAlloca, IntptrTy), DynamicAllocaLayout);
3749 Value *NewAddressPtr = IRB.CreateIntToPtr(NewAddress, AI->getType());