|
43 | 43 | #include "llvm/Support/MathExtras.h"
|
44 | 44 | #include "llvm/Support/raw_ostream.h"
|
45 | 45 | #include "llvm/Transforms/Instrumentation.h"
|
46 |
| -#include "llvm/Transforms/Utils/BasicBlockUtils.h" |
47 | 46 | #include "llvm/Transforms/Utils/EscapeEnumerator.h"
|
48 | 47 | #include "llvm/Transforms/Utils/Local.h"
|
49 | 48 | #include "llvm/Transforms/Utils/ModuleUtils.h"
|
@@ -738,8 +737,8 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
|
738 | 737 | Value *Args[] = {Addr,
|
739 | 738 | IRB.CreateBitOrPointerCast(SI->getValueOperand(), Ty),
|
740 | 739 | 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(); |
743 | 742 | } else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(I)) {
|
744 | 743 | Value *Addr = RMWI->getPointerOperand();
|
745 | 744 | int Idx =
|
@@ -795,8 +794,8 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
|
795 | 794 | FunctionCallee F = FI->getSyncScopeID() == SyncScope::SingleThread
|
796 | 795 | ? TsanAtomicSignalFence
|
797 | 796 | : TsanAtomicThreadFence;
|
798 |
| - CallInst *C = CallInst::Create(F, Args); |
799 |
| - ReplaceInstWithInst(I, C); |
| 797 | + IRB.CreateCall(F, Args); |
| 798 | + FI->eraseFromParent(); |
800 | 799 | }
|
801 | 800 | return true;
|
802 | 801 | }
|
|
0 commit comments