diff options
author | Bill Wendling <morbo@google.com> | 2020-02-24 18:28:32 -0800 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2020-02-24 18:29:06 -0800 |
commit | 23c2a5ce33f0f05e4cc43c2cbb9009e9b549839c (patch) | |
tree | 1cbe89bc7f44eadf08f2e60cb77c818002b3f16f /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 226bddce458b8648a16d49e6415be2ccf9592c0e (diff) | |
download | llvm-23c2a5ce33f0f05e4cc43c2cbb9009e9b549839c.zip llvm-23c2a5ce33f0f05e4cc43c2cbb9009e9b549839c.tar.gz llvm-23c2a5ce33f0f05e4cc43c2cbb9009e9b549839c.tar.bz2 |
Allow "callbr" to return non-void values
Summary:
Terminators in LLVM aren't prohibited from returning values. This means that
the "callbr" instruction, which is used for "asm goto", can support "asm goto
with outputs."
This patch removes all restrictions against "callbr" returning values. The
heavy lifting is done by the code generator. The "INLINEASM_BR" instruction's
a terminator, and the code generator doesn't allow non-terminator instructions
after a terminator. In order to correctly model the feature, we need to copy
outputs from "INLINEASM_BR" into virtual registers. Of course, those copies
aren't terminators.
To get around this issue, we split the block containing the "INLINEASM_BR"
right before the "COPY" instructions. This results in two cheats:
- Any physical registers defined by "INLINEASM_BR" need to be marked as
live-in into the block with the "COPY" instructions. This violates an
assumption that physical registers aren't marked as "live-in" until after
register allocation. But it seems as if the live-in information only
needs to be correct after register allocation. So we're able to get away
with this.
- The indirect branches from the "INLINEASM_BR" are moved to the "COPY"
block. This is to satisfy PHI nodes.
I've been told that MLIR can support this handily, but until we're able to
use it, we'll have to stick with the above.
Reviewers: jyknight, nickdesaulniers, hfinkel, MaskRay, lattner
Reviewed By: nickdesaulniers, MaskRay, lattner
Subscribers: rriddle, qcolombet, jdoerfert, MatzeB, echristo, MaskRay, xbolva00, aaron.ballman, cfe-commits, JonChesterfield, hiraditya, llvm-commits, rnk, craig.topper
Tags: #llvm, #clang
Differential Revision: https://reviews.llvm.org/D69868
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index ffa68aa..c2f459e 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -1113,8 +1113,12 @@ bool MachineBasicBlock::canSplitCriticalEdge( if (Succ->isEHPad()) return false; - const MachineFunction *MF = getParent(); + // Splitting the critical edge to a callbr's indirect block isn't advised. + // Don't do it in this generic function. + if (isInlineAsmBrIndirectTarget(Succ)) + return false; + const MachineFunction *MF = getParent(); // Performance might be harmed on HW that implements branching using exec mask // where both sides of the branches are always executed. if (MF->getTarget().requiresStructuredCFG()) |