[llvm] 6989859 - [llvm][HWASan] Replace calls to Type::getPointerTo (NFC)

Youngsuk Kim via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 12:49:45 PST 2023


Author: Youngsuk Kim
Date: 2023-11-28T14:45:59-06:00
New Revision: 6989859254e8ce486d21d5a981c7fddf7964c7ad

URL: https://github.com/llvm/llvm-project/commit/6989859254e8ce486d21d5a981c7fddf7964c7ad
DIFF: https://github.com/llvm/llvm-project/commit/6989859254e8ce486d21d5a981c7fddf7964c7ad.diff

LOG: [llvm][HWASan] Replace calls to Type::getPointerTo (NFC)

If `Type::getPointerTo` is called solely to support an unnecessary
pointer-cast, remove the call entirely.

Otherwise, replace with IRB.getPtrTy().

Clean-up work towards removing method `Type::getPointerTo`.

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index c58219aedff0e6d..f7f8fed643e937e 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1217,10 +1217,8 @@ Value *HWAddressSanitizer::getHwasanThreadSlotPtr(IRBuilder<> &IRB, Type *Ty) {
     // in Bionic's libc/private/bionic_tls.h.
     Function *ThreadPointerFunc =
         Intrinsic::getDeclaration(M, Intrinsic::thread_pointer);
-    Value *SlotPtr = IRB.CreatePointerCast(
-        IRB.CreateConstGEP1_32(Int8Ty, IRB.CreateCall(ThreadPointerFunc), 0x30),
-        Ty->getPointerTo(0));
-    return SlotPtr;
+    return IRB.CreateConstGEP1_32(Int8Ty, IRB.CreateCall(ThreadPointerFunc),
+                                  0x30);
   }
   if (ThreadPtrGlobal)
     return ThreadPtrGlobal;
@@ -1305,8 +1303,8 @@ void HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) {
 
       // Store data to ring buffer.
       Value *FrameRecordInfo = getFrameRecordInfo(IRB);
-      Value *RecordPtr = IRB.CreateIntToPtr(ThreadLongMaybeUntagged,
-                                            IntptrTy->getPointerTo(0));
+      Value *RecordPtr =
+          IRB.CreateIntToPtr(ThreadLongMaybeUntagged, IRB.getPtrTy(0));
       IRB.CreateStore(FrameRecordInfo, RecordPtr);
 
       // Update the ring buffer. Top byte of ThreadLong defines the size of the


        


More information about the llvm-commits mailing list