mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
[asan] don't unpoison redzones on function exit in use-after-return mode.
Summary:
Before this change the instrumented code before Ret instructions looked like:
<Unpoison Frame Redzones>
if (Frame != OriginalFrame) // I.e. Frame is fake
<Poison Complete Frame>
Now the instrumented code looks like:
if (Frame != OriginalFrame) // I.e. Frame is fake
<Poison Complete Frame>
else
<Unpoison Frame Redzones>
Reviewers: eugenis
Reviewed By: eugenis
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2458
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197907 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -670,6 +670,39 @@ TerminatorInst *llvm::SplitBlockAndInsertIfThen(Value *Cond,
|
||||
return CheckTerm;
|
||||
}
|
||||
|
||||
/// SplitBlockAndInsertIfThenElse is similar to SplitBlockAndInsertIfThen,
|
||||
/// but also creates the ElseBlock.
|
||||
/// Before:
|
||||
/// Head
|
||||
/// SplitBefore
|
||||
/// Tail
|
||||
/// After:
|
||||
/// Head
|
||||
/// if (Cond)
|
||||
/// ThenBlock
|
||||
/// else
|
||||
/// ElseBlock
|
||||
/// SplitBefore
|
||||
/// Tail
|
||||
void llvm::SplitBlockAndInsertIfThenElse(Value *Cond, Instruction *SplitBefore,
|
||||
TerminatorInst **ThenTerm,
|
||||
TerminatorInst **ElseTerm,
|
||||
MDNode *BranchWeights) {
|
||||
BasicBlock *Head = SplitBefore->getParent();
|
||||
BasicBlock *Tail = Head->splitBasicBlock(SplitBefore);
|
||||
TerminatorInst *HeadOldTerm = Head->getTerminator();
|
||||
LLVMContext &C = Head->getContext();
|
||||
BasicBlock *ThenBlock = BasicBlock::Create(C, "", Head->getParent(), Tail);
|
||||
BasicBlock *ElseBlock = BasicBlock::Create(C, "", Head->getParent(), Tail);
|
||||
*ThenTerm = BranchInst::Create(Tail, ThenBlock);
|
||||
*ElseTerm = BranchInst::Create(Tail, ElseBlock);
|
||||
BranchInst *HeadNewTerm =
|
||||
BranchInst::Create(/*ifTrue*/ThenBlock, /*ifFalse*/ElseBlock, Cond);
|
||||
HeadNewTerm->setMetadata(LLVMContext::MD_prof, BranchWeights);
|
||||
ReplaceInstWithInst(HeadOldTerm, HeadNewTerm);
|
||||
}
|
||||
|
||||
|
||||
/// GetIfCondition - Given a basic block (BB) with two predecessors,
|
||||
/// check to see if the merge at this block is due
|
||||
/// to an "if condition". If so, return the boolean condition that determines
|
||||
|
||||
Reference in New Issue
Block a user