Open Quuxplusone opened 4 years ago
Bugzilla Link | PR45971 |
Status | CONFIRMED |
Importance | P enhancement |
Reported by | Luca Massarelli (massarelli@diag.uniroma1.it) |
Reported on | 2020-05-18 03:18:11 -0700 |
Last modified on | 2020-06-17 14:54:38 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | dblaikie@gmail.com, ditaliano@apple.com, htmldeveloper@gmail.com, jdevlieghere@apple.com, jeremy.morse.llvm@gmail.com, josh@joshmatthews.net, keith.walker@arm.com, llvm-bugs@lists.llvm.org, neeilans@live.com, paul_robinson@playstation.sony.com, richard-llvm@metafoo.co.uk |
Fixed by commit(s) | |
Attachments | |
Blocks | PR38768 |
Blocked by | |
See also |
Neat; looks like it's this [0] folding of return blocks together. SimplifyCFG replaces identical return blocks with one of them; it should also be merging the DebugLocs too.
Process 3928 launched: '/Users/davide/work/build/bin/a.out' (x86_64)
a.out was compiled with optimization - stepping may behave oddly; variables may
not be available.
Process 3928 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000f8d a.out`e at a.c:8:13 [opt]
5 void e() {
6 if (g_37[0])
7 return;
-> 8 --b &&d() || c;
9 }
10 int main() { e(); }
(lldb) frame var g_37
(int [1]) g_37 = ([0] = 1)
So, I might be wrong, but my bisection points to:
BISECT: running pass (190) Stack Slot Coloring on function (e)
BISECT: running pass (191) Machine Copy Propagation Pass on function (e)
BISECT: running pass (192) Machine Loop Invariant Code Motion on function (e)
BISECT: running pass (193) Fixup Statepoint Caller Saved on function (e)
BISECT: running pass (194) PostRA Machine Sink on function (e)
BISECT: running pass (195) Shrink Wrapping analysis on function (e)
BISECT: running pass (196) Control Flow Optimizer on function (e)
BISECT: running pass (197) Tail Duplication on function (e)
BISECT: running pass (198) Machine Copy Propagation Pass on function (e)
BISECT: running pass (199) Post RA top-down list latency scheduler on function
(e)
BISECT: running pass (200) Branch Probability Basic Block Placement on function
(e)
^----
Interesting, this calls BranchFolder, so it might be the same fix for
https://bugs.llvm.org/show_bug.cgi?id=46009
// No tail merging opportunities if the block number is less than four.
if (MF.size() > 3 && EnableTailMerge) {
unsigned TailMergeSize = TailDupSize + 1;
BranchFolder BF(/*EnableTailMerge=*/true, /*CommonHoist=*/false, *MBFI,
*MBPI, PSI, TailMergeSize);
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(),
MMIWP ? &MMIWP->getMMI() : nullptr, MLI,
/*AfterPlacement=*/true)) {
// Redo the layout if tail merging creates/removes/moves blocks.
BlockToChain.clear();
ComputedEdges.clear();
// Must redo the post-dominator tree if blocks were changed.
if (MPDT)
MPDT->runOnMachineFunction(MF);
ChainAllocator.DestroyAll();
buildCFGChains();
}
}