<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks Tim,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The -print-after-all option did help. The problem happens after Prologue/epilogue insertion</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span># *** IR Dump After Fast Register Allocator ***:<br>
</span>
<div># Machine code for function _Z16test_rotate_leftv: NoPHIs, TracksLiveness, NoVRegs<br>
</div>
<div>Frame Objects:<br>
</div>
<div>  fi#0: size=4, align=4, at location [SP]<br>
</div>
<br>
<div>  $r0 = ADDR %stack.0.a, $r0(tied-def 0), implicit-def dead $cf, implicit-def dead $nf, implicit-def dead $zf, implicit-def dead $of<br>
</div>
<div><br>
</div>
<div># End machine code for function _Z16test_rotate_leftv.<br>
</div>
<div><br>
</div>
<div># *** IR Dump After Prologue/Epilogue Insertion & Frame Finalization ***:<br>
</div>
<div># Machine code for function _Z16test_rotate_leftv: NoPHIs, TracksLiveness, NoVRegs<br>
</div>
<div>Frame Objects:<br>
</div>
<div>  fi#0: size=4, align=4, at location [SP-4]<br>
</div>
<div><br>
</div>
<div>  $r0 = ADDR $noreg, $r0(tied-def 0), implicit-def dead $cf, implicit-def dead $nf, implicit-def dead $zf, implicit-def dead $of</div>
<div><br>
</div>
<div><br>
</div>
<div>Somehow '%stack.0.a' became '$noreg'</div>
<div><br>
</div>
<div>Other than XXXSEFrameLowering::emitPrologue(), what other function is called when entering a function?</div>
<div><br>
</div>
<div>Thanks.<br>
</div>
<span></span><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Tim Northover <t.p.northover@gmail.com><br>
<b>Sent:</b> Tuesday, February 12, 2019 9:07 PM<br>
<b>To:</b> Josh Sharp<br>
<b>Cc:</b> via llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] Question about register allocation</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Tue, 12 Feb 2019 at 20:45, Josh Sharp via llvm-dev<br>
<llvm-dev@lists.llvm.org> wrote:<br>
> I'd like to understand how register allocation works in the case where an instruction is folded into another one. Where in the code would be a good place to start looking at?<br>
<br>
I don't think you've got two instructions folded together. On the<br>
output side that would just be a single instruction.<br>
<br>
> After ISEL, one of the instructions has another instruction folded into it, which looks like this<br>
><br>
> t1: i32,i1,i1,i1,i1 = ADDRR TargetFrameIndex:i32<0>, MOVRI:i32,i1,i1<br>
<br>
I've never seen anything displayed like that, and it worries me. I<br>
thought only constants of some kind were inlined, which a MOVRI<br>
instruction almost certainly doesn't qualify as.<br>
<br>
 You'll want to look at how that's serialized after the DAG phase to<br>
diagnose the issue. To the extent that it's meaningful, it ought to be<br>
entirely equivalent to:<br>
<br>
    %v0 = MOVRI [...]<br>
    %t1 = ADDRR frameindex<0>, %v0, [...]<br>
<br>
Generally, the "-print-after-all" option for llc is the quickest way<br>
to access this kind of information. The first time the ADDRR<br>
instruction occurs is just after an opaque "DAG ISel" phase that<br>
you've been introspecting.<br>
<br>
> But during the 'Assembly Printer' pass, when emitting the assembly for ADDRR, the assertion at the beginning of getRegisterName() in XXXGenAsmWriter.inc fails because RegNo is 0. I'd like to know how that happened.<br>
<br>
Assembly printer is very late. In fact it's the very last pass LLVM<br>
runs. Generally any assertion failure there can be traced to bad input<br>
(unless you're literally implementing the AsmPrinter at the time),<br>
which again points to "-print-after-all" as a diagnostic tool.<br>
<br>
There's usually something obviously wrong with the final instructions,<br>
which can be traced back to something less-obviously-but-still wrong<br>
before register allocation (often mismatched register classes). The<br>
trick is establishing the first phase were things are incorrect and<br>
working out why.<br>
<br>
>From what you've said I'd bet on ISel unfortunately (it's a big phase).<br>
<br>
Cheers.<br>
<br>
Tim.<br>
</div>
</span></font></div>
</body>
</html>