mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-13 03:21:07 +00:00
[SelectionDAG] Update Loop info after splitting critical edges.
The analysis is expected to be preserved by SelectionDAG. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305621 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aae294a712
commit
1cea15532e
@ -337,12 +337,13 @@ void SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
/// SplitCriticalSideEffectEdges - Look for critical edges with a PHI value that
|
||||
/// may trap on it. In this case we have to split the edge so that the path
|
||||
/// through the predecessor block that doesn't go to the phi block doesn't
|
||||
/// execute the possibly trapping instruction. If available, we pass a
|
||||
/// dominator tree to be updated when we split critical edges. This is because
|
||||
/// SelectionDAGISel preserves the DominatorTree.
|
||||
/// execute the possibly trapping instruction. If available, we pass domtree
|
||||
/// and loop info to be updated when we split critical edges. This is because
|
||||
/// SelectionDAGISel preserves these analyses.
|
||||
/// This is required for correctness, so it must be done at -O0.
|
||||
///
|
||||
static void SplitCriticalSideEffectEdges(Function &Fn, DominatorTree *DT) {
|
||||
static void SplitCriticalSideEffectEdges(Function &Fn, DominatorTree *DT,
|
||||
LoopInfo *LI) {
|
||||
// Loop for blocks with phi nodes.
|
||||
for (BasicBlock &BB : Fn) {
|
||||
PHINode *PN = dyn_cast<PHINode>(BB.begin());
|
||||
@ -368,7 +369,7 @@ static void SplitCriticalSideEffectEdges(Function &Fn, DominatorTree *DT) {
|
||||
// Okay, we have to split this edge.
|
||||
SplitCriticalEdge(
|
||||
Pred->getTerminator(), GetSuccessorNumber(Pred, &BB),
|
||||
CriticalEdgeSplittingOptions(DT).setMergeIdenticalEdges());
|
||||
CriticalEdgeSplittingOptions(DT, LI).setMergeIdenticalEdges());
|
||||
goto ReprocessBlock;
|
||||
}
|
||||
}
|
||||
@ -406,10 +407,12 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
|
||||
ORE = make_unique<OptimizationRemarkEmitter>(&Fn);
|
||||
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>();
|
||||
DominatorTree *DT = DTWP ? &DTWP->getDomTree() : nullptr;
|
||||
auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
|
||||
LoopInfo *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
|
||||
|
||||
DEBUG(dbgs() << "\n\n\n=== " << Fn.getName() << "\n");
|
||||
|
||||
SplitCriticalSideEffectEdges(const_cast<Function &>(Fn), DT);
|
||||
SplitCriticalSideEffectEdges(const_cast<Function &>(Fn), DT, LI);
|
||||
|
||||
CurDAG->init(*MF, *ORE);
|
||||
FuncInfo->set(Fn, *MF, CurDAG);
|
||||
|
27
test/CodeGen/X86/pr33396.ll
Normal file
27
test/CodeGen/X86/pr33396.ll
Normal file
@ -0,0 +1,27 @@
|
||||
; Make sure we don't crash because we have stale loop infos.
|
||||
; REQUIRES: asserts
|
||||
; RUN: llc -o /dev/null -verify-loop-info %s
|
||||
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@global = external global [2 x i8], align 2
|
||||
@global.1 = external global [2 x i8], align 2
|
||||
|
||||
define void @patatino(i8 %tinky) {
|
||||
bb:
|
||||
br label %bb1
|
||||
|
||||
bb1:
|
||||
br i1 icmp ne (i8* getelementptr ([2 x i8], [2 x i8]* @global.1, i64 0, i64 1),
|
||||
i8* getelementptr ([2 x i8], [2 x i8]* @global, i64 0, i64 1)), label %bb2, label %bb3
|
||||
|
||||
bb2:
|
||||
br label %bb3
|
||||
|
||||
bb3:
|
||||
%tmp = phi i32 [ 60, %bb2 ],
|
||||
[ sdiv (i32 60, i32 zext (i1 icmp eq (i8* getelementptr ([2 x i8], [2 x i8]* @global.1, i64 0, i64 1),
|
||||
i8* getelementptr ([2 x i8], [2 x i8]* @global, i64 0, i64 1)) to i32)), %bb1 ]
|
||||
%tmp4 = icmp slt i8 %tinky, -4
|
||||
br label %bb1
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user