[PATCH] D108719: [asan] Removed unsed cast in the IR by moving AddrLong init after optimized callback section.
Kirill Stoimenov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 25 11:43:37 PDT 2021
kstoimenov created this revision.
Herald added a subscriber: hiraditya.
kstoimenov requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108719
Files:
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -662,6 +662,7 @@
LongSize = M.getDataLayout().getPointerSizeInBits();
IntptrTy = Type::getIntNTy(*C, LongSize);
Int8PtrTy = Type::getInt8PtrTy(*C);
+ Int32Ty = Type::getInt32Ty(*C);
TargetTriple = Triple(M.getTargetTriple());
Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -753,6 +754,7 @@
AsanDetectStackUseAfterReturnMode UseAfterReturn;
Type *IntptrTy;
Type *Int8PtrTy;
+ Type *Int32Ty;
ShadowMapping Mapping;
FunctionCallee AsanHandleNoReturnFunc;
FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1772,25 +1774,26 @@
}
IRBuilder<> IRB(InsertBefore);
- Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
- const ASanAccessInfo AccessInfo(IsWrite, CompileKernel, AccessSizeIndex);
+ if (UseCalls && ClOptimizeCallbacks) {
+ const ASanAccessInfo AccessInfo(IsWrite, CompileKernel, AccessSizeIndex);
+ Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+ IRB.CreateCall(
+ Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+ {IRB.CreatePointerCast(Addr, Int8PtrTy),
+ ConstantInt::get(Int32Ty, AccessInfo.Packed)});
+ return;
+ }
+
+ Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
if (UseCalls) {
- if (ClOptimizeCallbacks) {
- Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
- Module *M = IRB.GetInsertBlock()->getParent()->getParent();
- IRB.CreateCall(
- Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
- {Ptr8, ConstantInt::get(IRB.getInt32Ty(), AccessInfo.Packed)});
- } else {
- if (Exp == 0)
- IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
- else
- IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
- }
+ if (Exp == 0)
+ IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+ AddrLong);
+ else
+ IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+ {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108719.368692.patch
Type: text/x-patch
Size: 2560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210825/60ff1887/attachment.bin>
More information about the llvm-commits
mailing list