Lines Matching defs:IRB

706   CallInst *createRuntimeCall(IRBuilder<> &IRB, FunctionCallee Callee,
709 assert(IRB.GetInsertBlock()->getParent() == OwnerFn);
711 CallInst *Inst = IRB.CreateCall(Callee, Args, Name, nullptr);
779 Instruction *genAMDGPUReportBlock(IRBuilder<> &IRB, Value *Cond,
794 Value *createSlowPathCmp(IRBuilder<> &IRB, Value *AddrLong,
801 Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
921 void instrumentGlobals(IRBuilder<> &IRB, bool *CtorComdat);
922 void InstrumentGlobalsCOFF(IRBuilder<> &IRB,
925 void instrumentGlobalsELF(IRBuilder<> &IRB,
929 void InstrumentGlobalsMachO(IRBuilder<> &IRB,
933 InstrumentGlobalsWithMetadataArray(IRBuilder<> &IRB,
1106 IRBuilder<> IRB(InstBefore);
1107 Value *DynamicAreaPtr = IRB.CreatePtrToInt(SavedStack, IntptrTy);
1113 Value *DynamicAreaOffset = IRB.CreateIntrinsic(
1116 DynamicAreaPtr = IRB.CreateAdd(IRB.CreatePtrToInt(SavedStack, IntptrTy),
1121 IRB, AsanAllocasUnpoisonFunc,
1122 {IRB.CreateLoad(IntptrTy, DynamicAllocaLayout), DynamicAreaPtr});
1224 IRBuilder<> &IRB, Value *ShadowBase);
1226 size_t Begin, size_t End, IRBuilder<> &IRB,
1230 size_t End, IRBuilder<> &IRB, Value *ShadowBase);
1232 void poisonAlloca(Value *V, uint64_t Size, IRBuilder<> &IRB, bool DoPoison);
1234 Value *createAllocaForLayout(IRBuilder<> &IRB, const ASanStackFrameLayout &L,
1236 PHINode *createPHI(IRBuilder<> &IRB, Value *Cond, Value *ValueIfTrue,
1327 Value *AddressSanitizer::memToShadow(Value *Shadow, IRBuilder<> &IRB) {
1329 Shadow = IRB.CreateLShr(Shadow, Mapping.Scale);
1338 return IRB.CreateOr(Shadow, ShadowBase);
1340 return IRB.CreateAdd(Shadow, ShadowBase);
1346 InstrumentationIRBuilder IRB(MI);
1349 IRB, isa<MemMoveInst>(MI) ? AsanMemmove : AsanMemcpy,
1350 {IRB.CreateAddrSpaceCast(MI->getOperand(0), PtrTy),
1351 IRB.CreateAddrSpaceCast(MI->getOperand(1), PtrTy),
1352 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
1355 IRB, AsanMemset,
1356 {IRB.CreateAddrSpaceCast(MI->getOperand(0), PtrTy),
1357 IRB.CreateIntCast(MI->getOperand(1), IRB.getInt32Ty(), false),
1358 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
1594 IRBuilder<> IRB(I);
1599 i = IRB.CreatePointerCast(i, IntptrTy);
1601 RTCI.createRuntimeCall(IRB, F, Param);
1665 [&](IRBuilderBase &IRB, Value *Index) {
1666 Value *MaskElem = IRB.CreateExtractElement(Mask, Index);
1675 MaskElem, &*IRB.GetInsertPoint(), false);
1676 IRB.SetInsertPoint(ThenTerm);
1684 InstrumentedAddress = IRB.CreateExtractElement(Addr, Index);
1686 Index = IRB.CreateMul(Index, Stride);
1687 InstrumentedAddress = IRB.CreatePtrAdd(Addr, Index);
1689 InstrumentedAddress = IRB.CreateGEP(VTy, Addr, {Zero, Index});
1691 doInstrumentAddress(Pass, I, &*IRB.GetInsertPoint(), InstrumentedAddress,
1760 InstrumentationIRBuilder IRB(InsertBefore);
1761 Value *ExpVal = Exp == 0 ? nullptr : ConstantInt::get(IRB.getInt32Ty(), Exp);
1765 Call = RTCI.createRuntimeCall(IRB, AsanErrorCallbackSized[IsWrite][0],
1768 Call = RTCI.createRuntimeCall(IRB, AsanErrorCallbackSized[IsWrite][1],
1773 IRB, AsanErrorCallback[IsWrite][0][AccessSizeIndex], Addr);
1776 IRB, AsanErrorCallback[IsWrite][1][AccessSizeIndex], {Addr, ExpVal});
1783 Value *AddressSanitizer::createSlowPathCmp(IRBuilder<> &IRB, Value *AddrLong,
1789 IRB.CreateAnd(AddrLong, ConstantInt::get(IntptrTy, Granularity - 1));
1792 LastAccessedByte = IRB.CreateAdd(
1796 IRB.CreateIntCast(LastAccessedByte, ShadowValue->getType(), false);
1798 return IRB.CreateICmpSGE(LastAccessedByte, ShadowValue);
1812 IRBuilder<> IRB(InsertBefore);
1813 Value *IsShared = IRB.CreateCall(AMDGPUAddressShared, {Addr});
1814 Value *IsPrivate = IRB.CreateCall(AMDGPUAddressPrivate, {Addr});
1815 Value *IsSharedOrPrivate = IRB.CreateOr(IsShared, IsPrivate);
1816 Value *Cmp = IRB.CreateNot(IsSharedOrPrivate);
1823 Instruction *AddressSanitizer::genAMDGPUReportBlock(IRBuilder<> &IRB,
1825 Module &M = *IRB.GetInsertBlock()->getModule();
1828 auto Ballot = M.getOrInsertFunction(kAMDGPUBallotName, IRB.getInt64Ty(),
1829 IRB.getInt1Ty());
1830 ReportCond = IRB.CreateIsNotNull(IRB.CreateCall(Ballot, {Cond}));
1834 SplitBlockAndInsertIfThen(ReportCond, &*IRB.GetInsertPoint(), false,
1842 IRB.SetInsertPoint(Trm);
1843 return IRB.CreateCall(
1844 M.getOrInsertFunction(kAMDGPUUnreachableName, IRB.getVoidTy()), {});
1861 InstrumentationIRBuilder IRB(InsertBefore);
1866 IRB.CreateIntrinsic(Intrinsic::asan_check_memaccess, {},
1867 {IRB.CreatePointerCast(Addr, PtrTy),
1872 Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
1876 IRB, AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex], AddrLong);
1879 IRB, AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
1880 {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
1887 Value *ShadowPtr = memToShadow(AddrLong, IRB);
1890 Value *ShadowValue = IRB.CreateAlignedLoad(
1891 ShadowTy, IRB.CreateIntToPtr(ShadowPtr, ShadowPtrTy), Align(ShadowAlign));
1893 Value *Cmp = IRB.CreateIsNotNull(ShadowValue);
1901 auto *Cmp2 = createSlowPathCmp(IRB, AddrLong, ShadowValue, TypeStoreSize);
1902 Cmp = IRB.CreateAnd(Cmp, Cmp2);
1904 CrashTerm = genAMDGPUReportBlock(IRB, Cmp, Recover);
1912 IRB.SetInsertPoint(CheckTerm);
1913 Value *Cmp2 = createSlowPathCmp(IRB, AddrLong, ShadowValue, TypeStoreSize);
1941 InstrumentationIRBuilder IRB(InsertBefore);
1942 Value *NumBits = IRB.CreateTypeSize(IntptrTy, TypeStoreSize);
1943 Value *Size = IRB.CreateLShr(NumBits, ConstantInt::get(IntptrTy, 3));
1945 Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
1948 RTCI.createRuntimeCall(IRB, AsanMemoryAccessCallbackSized[IsWrite][0],
1952 IRB, AsanMemoryAccessCallbackSized[IsWrite][1],
1953 {AddrLong, Size, ConstantInt::get(IRB.getInt32Ty(), Exp)});
1955 Value *SizeMinusOne = IRB.CreateSub(Size, ConstantInt::get(IntptrTy, 1));
1956 Value *LastByte = IRB.CreateIntToPtr(
1957 IRB.CreateAdd(AddrLong, SizeMinusOne),
1968 IRBuilder<> IRB(&GlobalInit.front(),
1974 IRB.CreateCall(AsanPoisonGlobals, ModuleNameAddr);
2207 IRBuilder<> IRB(*C);
2211 M.getOrInsertFunction(kAsanPoisonGlobalsName, IRB.getVoidTy(), IntptrTy);
2213 M.getOrInsertFunction(kAsanUnpoisonGlobalsName, IRB.getVoidTy());
2217 kAsanRegisterGlobalsName, IRB.getVoidTy(), IntptrTy, IntptrTy);
2219 kAsanUnregisterGlobalsName, IRB.getVoidTy(), IntptrTy, IntptrTy);
2224 kAsanRegisterImageGlobalsName, IRB.getVoidTy(), IntptrTy);
2226 kAsanUnregisterImageGlobalsName, IRB.getVoidTy(), IntptrTy);
2229 M.getOrInsertFunction(kAsanRegisterElfGlobalsName, IRB.getVoidTy(),
2232 M.getOrInsertFunction(kAsanUnregisterElfGlobalsName, IRB.getVoidTy(),
2304 IRBuilder<> &IRB, ArrayRef<GlobalVariable *> ExtendedGlobals,
2336 IRBuilder<> &IRB, ArrayRef<GlobalVariable *> ExtendedGlobals,
2388 IRB.CreateCall(AsanRegisterElfGlobals,
2389 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy),
2390 IRB.CreatePointerCast(StartELFMetadata, IntptrTy),
2391 IRB.CreatePointerCast(StopELFMetadata, IntptrTy)});
2398 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy),
2399 IRB.CreatePointerCast(StartELFMetadata, IntptrTy),
2400 IRB.CreatePointerCast(StopELFMetadata, IntptrTy)});
2405 IRBuilder<> &IRB, ArrayRef<GlobalVariable *> ExtendedGlobals,
2451 IRB.CreateCall(AsanRegisterImageGlobals,
2452 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy)});
2459 {IRB.CreatePointerCast(RegisteredFlag, IntptrTy)});
2464 IRBuilder<> &IRB, ArrayRef<GlobalVariable *> ExtendedGlobals,
2481 IRB.CreateCall(AsanRegisterGlobals,
2482 {IRB.CreatePointerCast(AllGlobals, IntptrTy),
2490 {IRB.CreatePointerCast(AllGlobals, IntptrTy),
2500 void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
2555 Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize);
2589 Indices2[0] = IRB.getInt32(0);
2590 Indices2[1] = IRB.getInt32(0);
2619 new GlobalVariable(M, IRB.getInt8Ty(), false, Linkage,
2620 Constant::getNullValue(IRB.getInt8Ty()),
2663 instrumentGlobalsELF(IRB, NewGlobals, Initializers, getUniqueModuleId(&M));
2671 InstrumentGlobalsCOFF(IRB, NewGlobals, Initializers);
2673 InstrumentGlobalsMachO(IRB, NewGlobals, Initializers);
2675 InstrumentGlobalsWithMetadataArray(IRB, NewGlobals, Initializers);
2757 IRBuilder<> IRB(AsanCtorFunction->getEntryBlock().getTerminator());
2758 instrumentGlobals(IRB, &CtorComdat);
2760 IRBuilder<> IRB(*C);
2761 instrumentGlobals(IRB, &CtorComdat);
2790 IRBuilder<> IRB(*C);
2814 FunctionType::get(IRB.getVoidTy(), Args2, false), AL2);
2818 FunctionType::get(IRB.getVoidTy(), Args2, false), AL2);
2826 FunctionType::get(IRB.getVoidTy(), Args1, false), AL1);
2831 FunctionType::get(IRB.getVoidTy(), Args1, false), AL1);
2846 PtrTy, PtrTy, IRB.getInt32Ty(), IntptrTy);
2849 M.getOrInsertFunction(kAsanHandleNoReturnName, IRB.getVoidTy());
2852 M.getOrInsertFunction(kAsanPtrCmp, IRB.getVoidTy(), IntptrTy, IntptrTy);
2854 M.getOrInsertFunction(kAsanPtrSub, IRB.getVoidTy(), IntptrTy, IntptrTy);
2857 ArrayType::get(IRB.getInt8Ty(), 0));
2860 M.getOrInsertFunction(kAMDGPUAddressSharedName, IRB.getInt1Ty(), PtrTy);
2862 M.getOrInsertFunction(kAMDGPUAddressPrivateName, IRB.getInt1Ty(), PtrTy);
2876 IRBuilder<> IRB(&F.front(), F.front().begin());
2877 IRB.CreateCall(AsanInitFunction, {});
2888 IRBuilder<> IRB(&F.front().front());
2898 IRB.CreateCall(Asm, {AsanShadowGlobal}, ".asan.shadow");
2901 IRB.CreatePointerCast(AsanShadowGlobal, IntptrTy, ".asan.shadow");
2906 LocalDynamicShadow = IRB.CreateLoad(IntptrTy, GlobalDynamicAddress);
3078 IRBuilder<> IRB(CI);
3079 RTCI.createRuntimeCall(IRB, AsanHandleNoReturnFunc, {});
3110 IRBuilder<> IRB(*C);
3123 IRB.getVoidTy(), IntptrTy, IntptrTy);
3128 kAsanPoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy);
3130 kAsanUnpoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy);
3139 M.getOrInsertFunction(Name.str(), IRB.getVoidTy(), IntptrTy, IntptrTy);
3143 kAsanAllocaPoison, IRB.getVoidTy(), IntptrTy, IntptrTy);
3145 kAsanAllocasUnpoison, IRB.getVoidTy(), IntptrTy, IntptrTy);
3151 IRBuilder<> &IRB,
3191 Value *Ptr = IRB.CreateAdd(ShadowBase, ConstantInt::get(IntptrTy, i));
3192 Value *Poison = IRB.getIntN(StoreSizeInBytes * 8, Val);
3193 IRB.CreateAlignedStore(
3194 Poison, IRB.CreateIntToPtr(Ptr, PointerType::getUnqual(Poison->getContext())),
3203 IRBuilder<> &IRB, Value *ShadowBase) {
3204 copyToShadow(ShadowMask, ShadowBytes, 0, ShadowMask.size(), IRB, ShadowBase);
3210 IRBuilder<> &IRB, Value *ShadowBase) {
3227 copyToShadowInline(ShadowMask, ShadowBytes, Done, i, IRB, ShadowBase);
3229 IRB, AsanSetShadowFunc[Val],
3230 {IRB.CreateAdd(ShadowBase, ConstantInt::get(IntptrTy, i)),
3236 copyToShadowInline(ShadowMask, ShadowBytes, Done, End, IRB, ShadowBase);
3256 IRBuilder<> IRB(CopyInsertPoint);
3264 AllocaInst *AI = IRB.CreateAlloca(
3272 IRB.CreateMemCpy(AI, Alignment, &Arg, Alignment, AllocSize);
3277 PHINode *FunctionStackPoisoner::createPHI(IRBuilder<> &IRB, Value *Cond,
3281 PHINode *PHI = IRB.CreatePHI(IntptrTy, 2);
3290 IRBuilder<> &IRB, const ASanStackFrameLayout &L, bool Dynamic) {
3293 Alloca = IRB.CreateAlloca(IRB.getInt8Ty(),
3294 ConstantInt::get(IRB.getInt64Ty(), L.FrameSize),
3297 Alloca = IRB.CreateAlloca(ArrayType::get(IRB.getInt8Ty(), L.FrameSize),
3304 return IRB.CreatePointerCast(Alloca, IntptrTy);
3309 IRBuilder<> IRB(dyn_cast<Instruction>(FirstBB.begin()));
3310 DynamicAllocaLayout = IRB.CreateAlloca(IntptrTy, nullptr);
3311 IRB.CreateStore(Constant::getNullValue(IntptrTy), DynamicAllocaLayout);
3328 IRBuilder<> IRB(APC.InsBefore);
3329 poisonAlloca(APC.AI, APC.Size, IRB, APC.DoPoison);
3408 IRBuilder<> IRB(InsBefore);
3492 DoDynamicAlloca ? nullptr : createAllocaForLayout(IRB, L, false);
3501 IRB.CreateAlloca(IntptrTy, nullptr, "asan_local_stack_base");
3509 kAsanOptionDetectUseAfterReturn, IRB.getInt32Ty());
3510 Value *UseAfterReturnIsEnabled = IRB.CreateICmpNE(
3511 IRB.CreateLoad(IRB.getInt32Ty(), OptionDetectUseAfterReturn),
3512 Constant::getNullValue(IRB.getInt32Ty()));
3521 IRB.SetInsertPoint(InsBefore);
3522 FakeStack = createPHI(IRB, UseAfterReturnIsEnabled, FakeStackValue, Term,
3531 RTCI.createRuntimeCall(IRB, AsanStackMallocFunc[StackMallocIdx],
3535 IRB.CreateICmpEQ(FakeStack, Constant::getNullValue(IntptrTy));
3542 IRB.SetInsertPoint(InsBefore);
3543 LocalStackBase = createPHI(IRB, NoFakeStack, AllocaValue, Term, FakeStack);
3544 IRB.CreateStore(LocalStackBase, LocalStackBaseAlloca);
3551 DoDynamicAlloca ? createAllocaForLayout(IRB, L, true) : StaticAlloca;
3570 Value *NewAllocaPtr = IRB.CreateIntToPtr(
3571 IRB.CreateAdd(LocalStackBase, ConstantInt::get(IntptrTy, Desc.Offset)),
3578 Value *BasePlus0 = IRB.CreateIntToPtr(LocalStackBase, IntptrPtrTy);
3579 IRB.CreateStore(ConstantInt::get(IntptrTy, kCurrentStackFrameMagic),
3582 Value *BasePlus1 = IRB.CreateIntToPtr(
3583 IRB.CreateAdd(LocalStackBase,
3589 Value *Description = IRB.CreatePointerCast(StackDescriptionGlobal, IntptrTy);
3590 IRB.CreateStore(Description, BasePlus1);
3592 Value *BasePlus2 = IRB.CreateIntToPtr(
3593 IRB.CreateAdd(LocalStackBase,
3596 IRB.CreateStore(IRB.CreatePointerCast(&F, IntptrTy), BasePlus2);
3601 Value *ShadowBase = ASan.memToShadow(LocalStackBase, IRB);
3604 copyToShadow(ShadowAfterScope, ShadowAfterScope, IRB, ShadowBase);
3616 IRBuilder<> IRB(APC.InsBefore);
3619 IRB, ShadowBase);
3684 IRBuilder<> &IRB, bool DoPoison) {
3686 Value *AddrArg = IRB.CreatePointerCast(V, IntptrTy);
3689 IRB, DoPoison ? AsanPoisonStackMemoryFunc : AsanUnpoisonStackMemoryFunc,
3702 IRBuilder<> IRB(AI);
3718 IRB.CreateMul(IRB.CreateIntCast(AI->getArraySize(), IntptrTy, false),
3722 Value *PartialSize = IRB.CreateAnd(OldSize, AllocaRzMask);
3725 Value *Misalign = IRB.CreateSub(AllocaRzSize, PartialSize);
3728 Value *Cond = IRB.CreateICmpNE(Misalign, AllocaRzSize);
3729 Value *PartialPadding = IRB.CreateSelect(Cond, Misalign, Zero);
3734 Value *AdditionalChunkSize = IRB.CreateAdd(
3738 Value *NewSize = IRB.CreateAdd(OldSize, AdditionalChunkSize);
3741 AllocaInst *NewAlloca = IRB.CreateAlloca(IRB.getInt8Ty(), NewSize);
3746 IRB.CreateAdd(IRB.CreatePtrToInt(NewAlloca, IntptrTy),
3750 RTCI.createRuntimeCall(IRB, AsanAllocaPoisonFunc, {NewAddress, OldSize});
3754 IRB.CreateStore(IRB.CreatePtrToInt(NewAlloca, IntptrTy), DynamicAllocaLayout);
3756 Value *NewAddressPtr = IRB.CreateIntToPtr(NewAddress, AI->getType());