Skip to content

Commit 8a237ab

Browse files
committed
[TSan] Avoid use of ReplaceInstWithInst()
This is mainly for consistency across code paths, but also makes sure that all calls use IRInstrumentationBuilder and its special debuginfo handling. The two remaining uses don't actually need RAUW, they just have to erase the original instruction.
1 parent e61e260 commit 8a237ab

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "llvm/Support/MathExtras.h"
4444
#include "llvm/Support/raw_ostream.h"
4545
#include "llvm/Transforms/Instrumentation.h"
46-
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
4746
#include "llvm/Transforms/Utils/EscapeEnumerator.h"
4847
#include "llvm/Transforms/Utils/Local.h"
4948
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -738,8 +737,8 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
738737
Value *Args[] = {Addr,
739738
IRB.CreateBitOrPointerCast(SI->getValueOperand(), Ty),
740739
createOrdering(&IRB, SI->getOrdering())};
741-
CallInst *C = CallInst::Create(TsanAtomicStore[Idx], Args);
742-
ReplaceInstWithInst(I, C);
740+
IRB.CreateCall(TsanAtomicStore[Idx], Args);
741+
SI->eraseFromParent();
743742
} else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(I)) {
744743
Value *Addr = RMWI->getPointerOperand();
745744
int Idx =
@@ -795,8 +794,8 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
795794
FunctionCallee F = FI->getSyncScopeID() == SyncScope::SingleThread
796795
? TsanAtomicSignalFence
797796
: TsanAtomicThreadFence;
798-
CallInst *C = CallInst::Create(F, Args);
799-
ReplaceInstWithInst(I, C);
797+
IRB.CreateCall(F, Args);
798+
FI->eraseFromParent();
800799
}
801800
return true;
802801
}

0 commit comments

Comments
 (0)