Lines Matching defs:IRB
329 Value *getOpaqueNoopCast(IRBuilder<> &IRB, Value *Val);
331 Value *getDynamicShadowIfunc(IRBuilder<> &IRB);
332 Value *getShadowNonTls(IRBuilder<> &IRB);
335 Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
361 void tagAlloca(IRBuilder<> &IRB, AllocaInst *AI, Value *Tag, size_t Size);
362 Value *tagPointer(IRBuilder<> &IRB, Type *Ty, Value *PtrLong, Value *Tag);
363 Value *untagPointer(IRBuilder<> &IRB, Value *PtrLong);
368 Value *getNextTagWithCall(IRBuilder<> &IRB);
369 Value *getStackBaseTag(IRBuilder<> &IRB);
370 Value *getAllocaTag(IRBuilder<> &IRB, Value *StackTag, unsigned AllocaNo);
371 Value *getUARTag(IRBuilder<> &IRB);
373 Value *getHwasanThreadSlotPtr(IRBuilder<> &IRB);
374 Value *applyTagMask(IRBuilder<> &IRB, Value *OldTag);
377 void emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord);
382 Value *getCachedFP(IRBuilder<> &IRB);
383 Value *getFrameRecordInfo(IRBuilder<> &IRB);
684 IRBuilder<> IRB(*C);
744 IRBuilder<> IRB(*C);
814 Value *HWAddressSanitizer::getOpaqueNoopCast(IRBuilder<> &IRB, Value *Val) {
823 return IRB.CreateCall(Asm, {Val}, ".hwasan.shadow");
826 Value *HWAddressSanitizer::getDynamicShadowIfunc(IRBuilder<> &IRB) {
827 return getOpaqueNoopCast(IRB, ShadowGlobal);
830 Value *HWAddressSanitizer::getShadowNonTls(IRBuilder<> &IRB) {
833 IRB, ConstantExpr::getIntToPtr(
838 return getDynamicShadowIfunc(IRB);
841 IRB.GetInsertBlock()->getParent()->getParent()->getOrInsertGlobal(
843 return IRB.CreateLoad(PtrTy, GlobalDynamicAddress);
960 IRBuilder<> IRB(I);
961 Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
963 IRB.CreateIntToPtr(untagPointer(IRB, AddrLong), Addr->getType());
967 Value *HWAddressSanitizer::memToShadow(Value *Mem, IRBuilder<> &IRB) {
969 Value *Shadow = IRB.CreateLShr(Mem, Mapping.scale());
971 return IRB.CreateIntToPtr(Shadow, PtrTy);
973 return IRB.CreatePtrAdd(ShadowBase, Shadow);
991 IRBuilder<> IRB(InsertBefore);
993 R.PtrLong = IRB.CreatePointerCast(Ptr, IntptrTy);
995 IRB.CreateTrunc(IRB.CreateLShr(R.PtrLong, PointerTagShift), Int8Ty);
996 R.AddrLong = untagPointer(IRB, R.PtrLong);
997 Value *Shadow = memToShadow(R.AddrLong, IRB);
998 R.MemTag = IRB.CreateLoad(Int8Ty, Shadow);
999 Value *TagMismatch = IRB.CreateICmpNE(R.PtrTag, R.MemTag);
1002 Value *TagNotIgnored = IRB.CreateICmpNE(
1004 TagMismatch = IRB.CreateAnd(TagMismatch, TagNotIgnored);
1026 IRBuilder<> IRB(InsertBefore);
1042 IRB.CreateIntrinsic(
1050 IRB.CreateIntrinsic(
1067 IRBuilder<> IRB(TCI.TagMismatchTerm);
1069 IRB.CreateICmpUGT(TCI.MemTag, ConstantInt::get(Int8Ty, 15));
1074 IRB.SetInsertPoint(TCI.TagMismatchTerm);
1075 Value *PtrLowBits = IRB.CreateTrunc(IRB.CreateAnd(TCI.PtrLong, 15), Int8Ty);
1076 PtrLowBits = IRB.CreateAdd(
1078 Value *PtrLowBitsOOB = IRB.CreateICmpUGE(PtrLowBits, TCI.MemTag);
1083 IRB.SetInsertPoint(TCI.TagMismatchTerm);
1084 Value *InlineTagAddr = IRB.CreateOr(TCI.AddrLong, 15);
1085 InlineTagAddr = IRB.CreateIntToPtr(InlineTagAddr, PtrTy);
1086 Value *InlineTag = IRB.CreateLoad(Int8Ty, InlineTagAddr);
1087 Value *InlineTagMismatch = IRB.CreateICmpNE(TCI.PtrTag, InlineTag);
1092 IRB.SetInsertPoint(CheckFailTerm);
1126 IRB.CreateCall(Asm, TCI.PtrLong);
1144 IRBuilder<> IRB(MI);
1148 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)};
1152 IRB.CreateCall(isa<MemMoveInst>(MI) ? HwasanMemmove : HwasanMemcpy, Args);
1156 IRB.CreateIntCast(MI->getOperand(1), IRB.getInt32Ty(), false),
1157 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)};
1160 IRB.CreateCall(HwasanMemset, Args);
1186 IRBuilder<> IRB(O.getInsn());
1193 SmallVector<Value *, 2> Args{IRB.CreatePointerCast(Addr, IntptrTy)};
1196 IRB.CreateCall(HwasanMemoryAccessCallback[O.IsWrite][AccessSizeIndex],
1207 IRB.CreatePointerCast(Addr, IntptrTy),
1208 IRB.CreateUDiv(IRB.CreateTypeSize(IntptrTy, O.TypeStoreSize),
1212 IRB.CreateCall(HwasanMemoryAccessCallbackSized[O.IsWrite], Args);
1219 void HWAddressSanitizer::tagAlloca(IRBuilder<> &IRB, AllocaInst *AI, Value *Tag,
1225 Tag = IRB.CreateTrunc(Tag, Int8Ty);
1227 IRB.CreateCall(HwasanTagMemoryFunc,
1228 {IRB.CreatePointerCast(AI, PtrTy), Tag,
1232 Value *AddrLong = untagPointer(IRB, IRB.CreatePointerCast(AI, IntptrTy));
1233 Value *ShadowPtr = memToShadow(AddrLong, IRB);
1241 IRB.CreateMemSet(ShadowPtr, Tag, ShadowSize, Align(1));
1244 IRB.CreateStore(ConstantInt::get(Int8Ty, SizeRemainder),
1245 IRB.CreateConstGEP1_32(Int8Ty, ShadowPtr, ShadowSize));
1246 IRB.CreateStore(
1247 Tag, IRB.CreateConstGEP1_32(Int8Ty, IRB.CreatePointerCast(AI, PtrTy),
1274 Value *HWAddressSanitizer::applyTagMask(IRBuilder<> &IRB, Value *OldTag) {
1277 return IRB.CreateAnd(OldTag,
1281 Value *HWAddressSanitizer::getNextTagWithCall(IRBuilder<> &IRB) {
1282 return IRB.CreateZExt(IRB.CreateCall(HwasanGenerateTagFunc), IntptrTy);
1285 Value *HWAddressSanitizer::getStackBaseTag(IRBuilder<> &IRB) {
1293 Value *FramePointerLong = getCachedFP(IRB);
1295 applyTagMask(IRB, IRB.CreateXor(FramePointerLong,
1296 IRB.CreateLShr(FramePointerLong, 20)));
1301 Value *HWAddressSanitizer::getAllocaTag(IRBuilder<> &IRB, Value *StackTag,
1304 return getNextTagWithCall(IRB);
1305 return IRB.CreateXor(
1309 Value *HWAddressSanitizer::getUARTag(IRBuilder<> &IRB) {
1310 Value *FramePointerLong = getCachedFP(IRB);
1312 applyTagMask(IRB, IRB.CreateLShr(FramePointerLong, PointerTagShift));
1319 Value *HWAddressSanitizer::tagPointer(IRBuilder<> &IRB, Type *Ty,
1326 IRB.CreateOr(IRB.CreateShl(Tag, PointerTagShift),
1328 TaggedPtrLong = IRB.CreateAnd(PtrLong, ShiftedTag);
1331 Value *ShiftedTag = IRB.CreateShl(Tag, PointerTagShift);
1332 TaggedPtrLong = IRB.CreateOr(PtrLong, ShiftedTag);
1334 return IRB.CreateIntToPtr(TaggedPtrLong, Ty);
1338 Value *HWAddressSanitizer::untagPointer(IRBuilder<> &IRB, Value *PtrLong) {
1344 IRB.CreateOr(PtrLong, ConstantInt::get(PtrLong->getType(),
1348 UntaggedPtrLong = IRB.CreateAnd(
1355 Value *HWAddressSanitizer::getHwasanThreadSlotPtr(IRBuilder<> &IRB) {
1360 return memtag::getAndroidSlotPtr(IRB, SanitizerSlot);
1364 Value *HWAddressSanitizer::getCachedFP(IRBuilder<> &IRB) {
1366 CachedFP = memtag::getFP(IRB);
1370 Value *HWAddressSanitizer::getFrameRecordInfo(IRBuilder<> &IRB) {
1372 Value *PC = memtag::getPC(TargetTriple, IRB);
1373 Value *FP = getCachedFP(IRB);
1384 FP = IRB.CreateShl(FP, 44);
1385 return IRB.CreateOr(PC, FP);
1388 void HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) {
1390 ShadowBase = getShadowNonTls(IRB);
1392 ShadowBase = getDynamicShadowIfunc(IRB);
1403 SlotPtr = getHwasanThreadSlotPtr(IRB);
1405 ThreadLong = IRB.CreateLoad(IntptrTy, SlotPtr);
1409 : untagPointer(IRB, ThreadLong);
1417 Value *FrameRecordInfo = getFrameRecordInfo(IRB);
1418 IRB.CreateCall(HwasanRecordFrameRecordFunc, {FrameRecordInfo});
1424 StackBaseTag = IRB.CreateAShr(ThreadLong, 3);
1427 Value *FrameRecordInfo = getFrameRecordInfo(IRB);
1429 IRB.CreateIntToPtr(ThreadLongMaybeUntagged, IRB.getPtrTy(0));
1430 IRB.CreateStore(FrameRecordInfo, RecordPtr);
1432 IRB.CreateStore(memtag::incrementThreadLong(IRB, ThreadLong, 8), SlotPtr);
1449 ShadowBase = IRB.CreateAdd(
1450 IRB.CreateOr(
1454 ShadowBase = IRB.CreateIntToPtr(ShadowBase, PtrTy);
1461 IRBuilder<> IRB(LP->getNextNonDebugInstruction());
1462 IRB.CreateCall(
1465 IRB, (TargetTriple.getArch() == Triple::x86_64) ? "rsp" : "sp")});
1486 IRBuilder<> IRB(AI->getNextNonDebugInstruction());
1489 Value *Tag = getAllocaTag(IRB, StackTag, N);
1490 Value *AILong = IRB.CreatePointerCast(AI, IntptrTy);
1491 Value *AINoTagLong = untagPointer(IRB, AILong);
1492 Value *Replacement = tagPointer(IRB, AI->getType(), AINoTagLong, Tag);
1500 Value *AICast = IRB.CreatePointerCast(AI, PtrTy);
1528 IRB.SetInsertPoint(Node);
1533 tagAlloca(IRB, AI, UARTag, AlignedSize);
1546 IRB.SetInsertPoint(Start->getNextNode());
1547 tagAlloca(IRB, AI, Tag, Size);
1554 tagAlloca(IRB, AI, Tag, Size);
1894 IRBuilder<> IRB(BB);
1895 CallInst *WrapperCall = IRB.CreateCall(
1902 IRB.CreateRet(WrapperCall);