diff options
author | Kyle Butt <kyle+llvm@iteratee.net> | 2016-08-16 22:56:14 +0000 |
---|---|---|
committer | Kyle Butt <kyle+llvm@iteratee.net> | 2016-08-16 22:56:14 +0000 |
commit | 07d61425e396d4d0a2d4d75c48ce881634c6a513 (patch) | |
tree | 18c0e7fd14d4bb45047e35c540528c53c4afae53 /llvm/lib/CodeGen/TailDuplicator.cpp | |
parent | 60ea1b43d60ff72e23bf35c50d8df29c22c5476d (diff) | |
download | bcm5719-llvm-07d61425e396d4d0a2d4d75c48ce881634c6a513.tar.gz bcm5719-llvm-07d61425e396d4d0a2d4d75c48ce881634c6a513.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: 278866
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 c460a7226f0..dd84cef587e 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -518,6 +518,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 |