From 6989859254e8ce486d21d5a981c7fddf7964c7ad Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Tue, 28 Nov 2023 14:42:30 -0600 Subject: [PATCH] [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`. --- .../Transforms/Instrumentation/HWAddressSanitizer.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index c58219aedff0e6..f7f8fed643e937 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