Lines Matching defs:IRB

321   Value *getOpaqueNoopCast(IRBuilder<> &IRB, Value *Val);
323 Value *getDynamicShadowIfunc(IRBuilder<> &IRB);
324 Value *getShadowNonTls(IRBuilder<> &IRB);
327 Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
353 void tagAlloca(IRBuilder<> &IRB, AllocaInst *AI, Value *Tag, size_t Size);
354 Value *tagPointer(IRBuilder<> &IRB, Type *Ty, Value *PtrLong, Value *Tag);
355 Value *untagPointer(IRBuilder<> &IRB, Value *PtrLong);
360 Value *getNextTagWithCall(IRBuilder<> &IRB);
361 Value *getStackBaseTag(IRBuilder<> &IRB);
362 Value *getAllocaTag(IRBuilder<> &IRB, Value *StackTag, unsigned AllocaNo);
363 Value *getUARTag(IRBuilder<> &IRB);
365 Value *getHwasanThreadSlotPtr(IRBuilder<> &IRB);
366 Value *applyTagMask(IRBuilder<> &IRB, Value *OldTag);
369 void emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord);
374 Value *getCachedFP(IRBuilder<> &IRB);
375 Value *getFrameRecordInfo(IRBuilder<> &IRB);
611 IRBuilder<> IRB(*C);
671 IRBuilder<> IRB(*C);
741 Value *HWAddressSanitizer::getOpaqueNoopCast(IRBuilder<> &IRB, Value *Val) {
750 return IRB.CreateCall(Asm, {Val}, ".hwasan.shadow");
753 Value *HWAddressSanitizer::getDynamicShadowIfunc(IRBuilder<> &IRB) {
754 return getOpaqueNoopCast(IRB, ShadowGlobal);
757 Value *HWAddressSanitizer::getShadowNonTls(IRBuilder<> &IRB) {
760 IRB, ConstantExpr::getIntToPtr(
764 return getDynamicShadowIfunc(IRB);
767 IRB.GetInsertBlock()->getParent()->getParent()->getOrInsertGlobal(
769 return IRB.CreateLoad(PtrTy, GlobalDynamicAddress);
886 IRBuilder<> IRB(I);
887 Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
889 IRB.CreateIntToPtr(untagPointer(IRB, AddrLong), Addr->getType());
893 Value *HWAddressSanitizer::memToShadow(Value *Mem, IRBuilder<> &IRB) {
895 Value *Shadow = IRB.CreateLShr(Mem, Mapping.Scale);
897 return IRB.CreateIntToPtr(Shadow, PtrTy);
899 return IRB.CreatePtrAdd(ShadowBase, Shadow);
917 IRBuilder<> IRB(InsertBefore);
919 R.PtrLong = IRB.CreatePointerCast(Ptr, IntptrTy);
921 IRB.CreateTrunc(IRB.CreateLShr(R.PtrLong, PointerTagShift), Int8Ty);
922 R.AddrLong = untagPointer(IRB, R.PtrLong);
923 Value *Shadow = memToShadow(R.AddrLong, IRB);
924 R.MemTag = IRB.CreateLoad(Int8Ty, Shadow);
925 Value *TagMismatch = IRB.CreateICmpNE(R.PtrTag, R.MemTag);
928 Value *TagNotIgnored = IRB.CreateICmpNE(
930 TagMismatch = IRB.CreateAnd(TagMismatch, TagNotIgnored);
952 IRBuilder<> IRB(InsertBefore);
953 Module *M = IRB.GetInsertBlock()->getParent()->getParent();
968 IRB.CreateCall(
976 IRB.CreateCall(Intrinsic::getDeclaration(
993 IRBuilder<> IRB(TCI.TagMismatchTerm);
995 IRB.CreateICmpUGT(TCI.MemTag, ConstantInt::get(Int8Ty, 15));
1000 IRB.SetInsertPoint(TCI.TagMismatchTerm);
1001 Value *PtrLowBits = IRB.CreateTrunc(IRB.CreateAnd(TCI.PtrLong, 15), Int8Ty);
1002 PtrLowBits = IRB.CreateAdd(
1004 Value *PtrLowBitsOOB = IRB.CreateICmpUGE(PtrLowBits, TCI.MemTag);
1009 IRB.SetInsertPoint(TCI.TagMismatchTerm);
1010 Value *InlineTagAddr = IRB.CreateOr(TCI.AddrLong, 15);
1011 InlineTagAddr = IRB.CreateIntToPtr(InlineTagAddr, PtrTy);
1012 Value *InlineTag = IRB.CreateLoad(Int8Ty, InlineTagAddr);
1013 Value *InlineTagMismatch = IRB.CreateICmpNE(TCI.PtrTag, InlineTag);
1018 IRB.SetInsertPoint(CheckFailTerm);
1052 IRB.CreateCall(Asm, TCI.PtrLong);
1070 IRBuilder<> IRB(MI);
1074 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)};
1078 IRB.CreateCall(isa<MemMoveInst>(MI) ? HwasanMemmove : HwasanMemcpy, Args);
1082 IRB.CreateIntCast(MI->getOperand(1), IRB.getInt32Ty(), false),
1083 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)};
1086 IRB.CreateCall(HwasanMemset, Args);
1101 IRBuilder<> IRB(O.getInsn());
1108 SmallVector<Value *, 2> Args{IRB.CreatePointerCast(Addr, IntptrTy)};
1111 IRB.CreateCall(HwasanMemoryAccessCallback[O.IsWrite][AccessSizeIndex],
1122 IRB.CreatePointerCast(Addr, IntptrTy),
1123 IRB.CreateUDiv(IRB.CreateTypeSize(IntptrTy, O.TypeStoreSize),
1127 IRB.CreateCall(HwasanMemoryAccessCallbackSized[O.IsWrite], Args);
1134 void HWAddressSanitizer::tagAlloca(IRBuilder<> &IRB, AllocaInst *AI, Value *Tag,
1140 Tag = IRB.CreateTrunc(Tag, Int8Ty);
1142 IRB.CreateCall(HwasanTagMemoryFunc,
1143 {IRB.CreatePointerCast(AI, PtrTy), Tag,
1147 Value *AddrLong = untagPointer(IRB, IRB.CreatePointerCast(AI, IntptrTy));
1148 Value *ShadowPtr = memToShadow(AddrLong, IRB);
1156 IRB.CreateMemSet(ShadowPtr, Tag, ShadowSize, Align(1));
1159 IRB.CreateStore(ConstantInt::get(Int8Ty, SizeRemainder),
1160 IRB.CreateConstGEP1_32(Int8Ty, ShadowPtr, ShadowSize));
1161 IRB.CreateStore(
1162 Tag, IRB.CreateConstGEP1_32(Int8Ty, IRB.CreatePointerCast(AI, PtrTy),
1189 Value *HWAddressSanitizer::applyTagMask(IRBuilder<> &IRB, Value *OldTag) {
1192 return IRB.CreateAnd(OldTag,
1196 Value *HWAddressSanitizer::getNextTagWithCall(IRBuilder<> &IRB) {
1197 return IRB.CreateZExt(IRB.CreateCall(HwasanGenerateTagFunc), IntptrTy);
1200 Value *HWAddressSanitizer::getStackBaseTag(IRBuilder<> &IRB) {
1208 Value *FramePointerLong = getCachedFP(IRB);
1210 applyTagMask(IRB, IRB.CreateXor(FramePointerLong,
1211 IRB.CreateLShr(FramePointerLong, 20)));
1216 Value *HWAddressSanitizer::getAllocaTag(IRBuilder<> &IRB, Value *StackTag,
1219 return getNextTagWithCall(IRB);
1220 return IRB.CreateXor(
1224 Value *HWAddressSanitizer::getUARTag(IRBuilder<> &IRB) {
1225 Value *FramePointerLong = getCachedFP(IRB);
1227 applyTagMask(IRB, IRB.CreateLShr(FramePointerLong, PointerTagShift));
1234 Value *HWAddressSanitizer::tagPointer(IRBuilder<> &IRB, Type *Ty,
1241 IRB.CreateOr(IRB.CreateShl(Tag, PointerTagShift),
1243 TaggedPtrLong = IRB.CreateAnd(PtrLong, ShiftedTag);
1246 Value *ShiftedTag = IRB.CreateShl(Tag, PointerTagShift);
1247 TaggedPtrLong = IRB.CreateOr(PtrLong, ShiftedTag);
1249 return IRB.CreateIntToPtr(TaggedPtrLong, Ty);
1253 Value *HWAddressSanitizer::untagPointer(IRBuilder<> &IRB, Value *PtrLong) {
1259 IRB.CreateOr(PtrLong, ConstantInt::get(PtrLong->getType(),
1263 UntaggedPtrLong = IRB.CreateAnd(
1270 Value *HWAddressSanitizer::getHwasanThreadSlotPtr(IRBuilder<> &IRB) {
1275 return memtag::getAndroidSlotPtr(IRB, SanitizerSlot);
1279 Value *HWAddressSanitizer::getCachedFP(IRBuilder<> &IRB) {
1281 CachedFP = memtag::getFP(IRB);
1285 Value *HWAddressSanitizer::getFrameRecordInfo(IRBuilder<> &IRB) {
1287 Value *PC = memtag::getPC(TargetTriple, IRB);
1288 Value *FP = getCachedFP(IRB);
1299 FP = IRB.CreateShl(FP, 44);
1300 return IRB.CreateOr(PC, FP);
1303 void HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) {
1305 ShadowBase = getShadowNonTls(IRB);
1307 ShadowBase = getDynamicShadowIfunc(IRB);
1318 SlotPtr = getHwasanThreadSlotPtr(IRB);
1320 ThreadLong = IRB.CreateLoad(IntptrTy, SlotPtr);
1324 : untagPointer(IRB, ThreadLong);
1332 Value *FrameRecordInfo = getFrameRecordInfo(IRB);
1333 IRB.CreateCall(HwasanRecordFrameRecordFunc, {FrameRecordInfo});
1339 StackBaseTag = IRB.CreateAShr(ThreadLong, 3);
1342 Value *FrameRecordInfo = getFrameRecordInfo(IRB);
1344 IRB.CreateIntToPtr(ThreadLongMaybeUntagged, IRB.getPtrTy(0));
1345 IRB.CreateStore(FrameRecordInfo, RecordPtr);
1370 Value *WrapMask = IRB.CreateXor(
1371 IRB.CreateShl(IRB.CreateAShr(ThreadLong, 56), 12, "", true, true),
1373 Value *ThreadLongNew = IRB.CreateAnd(
1374 IRB.CreateAdd(ThreadLong, ConstantInt::get(IntptrTy, 8)), WrapMask);
1375 IRB.CreateStore(ThreadLongNew, SlotPtr);
1392 ShadowBase = IRB.CreateAdd(
1393 IRB.CreateOr(
1397 ShadowBase = IRB.CreateIntToPtr(ShadowBase, PtrTy);
1404 IRBuilder<> IRB(LP->getNextNonDebugInstruction());
1405 IRB.CreateCall(
1408 IRB, (TargetTriple.getArch() == Triple::x86_64) ? "rsp" : "sp")});
1429 IRBuilder<> IRB(AI->getNextNonDebugInstruction());
1432 Value *Tag = getAllocaTag(IRB, StackTag, N);
1433 Value *AILong = IRB.CreatePointerCast(AI, IntptrTy);
1434 Value *AINoTagLong = untagPointer(IRB, AILong);
1435 Value *Replacement = tagPointer(IRB, AI->getType(), AINoTagLong, Tag);
1443 Value *AICast = IRB.CreatePointerCast(AI, PtrTy);
1471 IRB.SetInsertPoint(Node);
1476 tagAlloca(IRB, AI, UARTag, AlignedSize);
1489 IRB.SetInsertPoint(Start->getNextNode());
1490 tagAlloca(IRB, AI, Tag, Size);
1497 tagAlloca(IRB, AI, Tag, Size);
1835 IRBuilder<> IRB(BB);
1836 CallInst *WrapperCall = IRB.CreateCall(
1843 IRB.CreateRet(WrapperCall);