[PATCH] D75098: Add TCOPY, a terminator form of the COPY instr
Bill Wendling via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 19:32:40 PDT 2020
void added a comment.
In D75098#2021573 <https://reviews.llvm.org/D75098#2021573>, @qcolombet wrote:
> Thanks Bill for the detailed explanations. A couple more questions.
>
> > CodeGen wants registers to be spilled at the end of a block.
>
> That's fast reg alloc only. What is happening with the other allocators?
They don't appear to use the correct registers for the defined values.
>> The spill slot is recorded and used later on when accessing the value. If we just add a COPY into the default block it won't have the necessary information available to load the correct value.
>
> Why is that? (Why doesn't it have the necessary information to load the correct value.)
>
> I feel that we are trying to work around a bug/limitation in the fast register allocator where physreg are assumed not to cross basic block boundaries. I wonder if it wouldn't be easier to fix fast reg alloc if that is the problem.
It's not so much working around a bug/limitation in any of the register allocators. What I'm most concerned about is having to specify live-ins to MBBs before register allocation. That invariant was a huge sticking point in the review process for this feature. We're currently violating it because it "seems to work", but I don't want to rely on that.
Because of the live-ins restriction, all live physical registers at the end of an MBB need to be "spilled", or at least recorded in a way so that other blocks can access the information without having their live-ins set. (This is my understanding, it may be inaccurate). The `SelectionDAGBuilder::CopyToExportRegsIfNeeded()` function is one of the ways this is done.
> Out-of-curiosity, how do we deal with invoke? I would expect we have the exact same problems.
Invoke is turned into a regular call with exception handling stuff around it. E.g.:
$ cat ex.cpp:
void g();
int f() {
try {
g();
} catch (int&) {
return 37;
}
return 1;
}
$ clang++ -mllvm -print-after-all ex.cpp -c -o /dev/null
...
bb.0 (%ir-block.0):
successors: %bb.1, %bb.2
EH_LABEL <mcsymbol .Ltmp0>
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
CALL64pcrel32 @_Z1gv, <regmask $bh $bl $bp $bph $bpl $bx $ebp $ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh $r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and 3 more...>, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp
ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
EH_LABEL <mcsymbol .Ltmp1>
JMP_1 %bb.1
...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75098/new/
https://reviews.llvm.org/D75098
More information about the llvm-commits
mailing list