diff options
author | Kyle Butt <kyle+llvm@iteratee.net> | 2016-08-10 21:03:27 +0000 |
---|---|---|
committer | Kyle Butt <kyle+llvm@iteratee.net> | 2016-08-10 21:03:27 +0000 |
commit | 81d32846b03a7de6dd7cfe699093ac23bdb237c3 (patch) | |
tree | 15c65a50cb31199b66780f0d9ccf415346469006 /llvm/lib/CodeGen/TailDuplicator.cpp | |
parent | e1c931b171288a42f9d65035a7e91b4e52d91643 (diff) | |
download | bcm5719-llvm-81d32846b03a7de6dd7cfe699093ac23bdb237c3.tar.gz bcm5719-llvm-81d32846b03a7de6dd7cfe699093ac23bdb237c3.zip |
Codegen: Don't tail-duplicate blocks with un-analyzable fallthrough.
If AnalyzeBranch can't analyze a block and it is possible to
fallthrough, then duplicating the block doesn't make sense, as only one
block can be the layout predecessor for the un-analyzable fallthrough.
Submitted wit a test case, but NOTE: the test case doesn't currently
fail. However, the test case fails with D20505 and would have saved me
some time debugging.
llvm-svn: 278288
Diffstat (limited to 'llvm/lib/CodeGen/TailDuplicator.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TailDuplicator.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index 059c1dc5483..029bd138f53 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -525,6 +525,16 @@ bool TailDuplicator::shouldTailDuplicate(const MachineFunction &MF, else MaxDuplicateCount = TailDuplicateSize; + // If the block to be duplicated ends in an unanalyzable fallthrough, don't + // duplicate it. + // A similar check is necessary in MachineBlockPlacement to make sure pairs of + // blocks with unanalyzable fallthrough get layed out contiguously. + MachineBasicBlock *PredTBB = nullptr, *PredFBB = nullptr; + SmallVector<MachineOperand, 4> PredCond; + if (TII->analyzeBranch(TailBB, PredTBB, PredFBB, PredCond, true) + && TailBB.canFallThrough()) + return false; + // If the target has hardware branch prediction that can handle indirect // branches, duplicating them can often make them predictable when there // are common paths through the code. The limit needs to be high enough |