Skip to content

Commit

Permalink
[llvm][HWASan] Replace calls to Type::getPointerTo (NFC)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
JOE1994 committed Nov 28, 2023
1 parent 17feb33 commit 6989859
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6989859

Please sign in to comment.