forked from OSchip/llvm-project
Let llvm::ReplaceInstWithInst copy debug location from old to new instruction.
Currently some users of this function do this explicitly, and all the rest forget to do this. ThreadSanitizer was one of such users, and had missing debug locations for calls into TSan runtime handling atomic operations, eventually leading to poorly symbolized stack traces and malfunctioning suppressions. This is another change relevant to PR23837. llvm-svn: 240460
This commit is contained in:
parent
5bd81f3264
commit
19ffcb900f
|
@ -64,14 +64,16 @@ void ReplaceInstWithValue(BasicBlock::InstListType &BIL,
|
|||
BasicBlock::iterator &BI, Value *V);
|
||||
|
||||
// ReplaceInstWithInst - Replace the instruction specified by BI with the
|
||||
// instruction specified by I. The original instruction is deleted and BI is
|
||||
// instruction specified by I. Copies DebugLoc from BI to I, if I doesn't
|
||||
// already have a DebugLoc. The original instruction is deleted and BI is
|
||||
// updated to point to the new instruction.
|
||||
//
|
||||
void ReplaceInstWithInst(BasicBlock::InstListType &BIL,
|
||||
BasicBlock::iterator &BI, Instruction *I);
|
||||
|
||||
// ReplaceInstWithInst - Replace the instruction specified by From with the
|
||||
// instruction specified by To.
|
||||
// instruction specified by To. Copies DebugLoc from BI to I, if I doesn't
|
||||
// already have a DebugLoc.
|
||||
//
|
||||
void ReplaceInstWithInst(Instruction *From, Instruction *To);
|
||||
|
||||
|
|
|
@ -211,6 +211,11 @@ void llvm::ReplaceInstWithInst(BasicBlock::InstListType &BIL,
|
|||
assert(I->getParent() == nullptr &&
|
||||
"ReplaceInstWithInst: Instruction already inserted into basic block!");
|
||||
|
||||
// Copy debug location to newly added instruction, if it wasn't already set
|
||||
// by the caller.
|
||||
if (!I->getDebugLoc())
|
||||
I->setDebugLoc(BI->getDebugLoc());
|
||||
|
||||
// Insert the new instruction into the basic block...
|
||||
BasicBlock::iterator New = BIL.insert(BI, I);
|
||||
|
||||
|
@ -716,7 +721,6 @@ TerminatorInst *llvm::SplitBlockAndInsertIfThen(Value *Cond,
|
|||
CheckTerm->setDebugLoc(SplitBefore->getDebugLoc());
|
||||
BranchInst *HeadNewTerm =
|
||||
BranchInst::Create(/*ifTrue*/ThenBlock, /*ifFalse*/Tail, Cond);
|
||||
HeadNewTerm->setDebugLoc(SplitBefore->getDebugLoc());
|
||||
HeadNewTerm->setMetadata(LLVMContext::MD_prof, BranchWeights);
|
||||
ReplaceInstWithInst(HeadOldTerm, HeadNewTerm);
|
||||
|
||||
|
@ -766,7 +770,6 @@ void llvm::SplitBlockAndInsertIfThenElse(Value *Cond, Instruction *SplitBefore,
|
|||
(*ElseTerm)->setDebugLoc(SplitBefore->getDebugLoc());
|
||||
BranchInst *HeadNewTerm =
|
||||
BranchInst::Create(/*ifTrue*/ThenBlock, /*ifFalse*/ElseBlock, Cond);
|
||||
HeadNewTerm->setDebugLoc(SplitBefore->getDebugLoc());
|
||||
HeadNewTerm->setMetadata(LLVMContext::MD_prof, BranchWeights);
|
||||
ReplaceInstWithInst(HeadOldTerm, HeadNewTerm);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue