[llvm] 8a237ab - [TSan] Avoid use of ReplaceInstWithInst()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 01:21:35 PDT 2024
Author: Nikita Popov
Date: 2024-03-15T09:21:27+01:00
New Revision: 8a237ab7d9022d24441544ba25be480f0c944f5a
URL: https://github.com/llvm/llvm-project/commit/8a237ab7d9022d24441544ba25be480f0c944f5a
DIFF: https://github.com/llvm/llvm-project/commit/8a237ab7d9022d24441544ba25be480f0c944f5a.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
index 0f42ff79086994..956ebe8fc8b9a3 100644
--- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -43,7 +43,6 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation.h"
-#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/EscapeEnumerator.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -738,8 +737,8 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
Value *Args[] = {Addr,
IRB.CreateBitOrPointerCast(SI->getValueOperand(), Ty),
createOrdering(&IRB, SI->getOrdering())};
- CallInst *C = CallInst::Create(TsanAtomicStore[Idx], Args);
- ReplaceInstWithInst(I, C);
+ IRB.CreateCall(TsanAtomicStore[Idx], Args);
+ SI->eraseFromParent();
} else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(I)) {
Value *Addr = RMWI->getPointerOperand();
int Idx =
@@ -795,8 +794,8 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
FunctionCallee F = FI->getSyncScopeID() == SyncScope::SingleThread
? TsanAtomicSignalFence
: TsanAtomicThreadFence;
- CallInst *C = CallInst::Create(F, Args);
- ReplaceInstWithInst(I, C);
+ IRB.CreateCall(F, Args);
+ FI->eraseFromParent();
}
return true;
}
More information about the llvm-commits
mailing list