Anton,<div><br></div><div>I'm afraid I really can't produce a meaningful example. The bug is extremely sensitive to code placement, optimization. I had to do a terrible amount of drugdery to find it in the first place.</div>
<div><br></div><div>Here's how I found the bug:</div><div><br></div><div>1) Stage 1: Compile LLVM with build/host x86, target ARM.</div><div>2) Stage 2: Cross-compile LLVM with host ARM, target ARM, using the stage 1 Clang/LLVM.</div>
<div>3) Use the stage 2 LLVM (in an ARM emulator) to compile an application, Foo.</div><div>4) Run Foo.</div><div>5) Foo malfunctions.</div><div><br></div><div>To find the bug, I had to do the following:</div><div><br></div>
<div><div>1) Notice that Foo does not malfunction when compiled using the stage 1 LLVM.</div><div>2) Diff between Foo.s generated by stage 1 LLVM and stage 2 LLVM. This made it obvious which instructions in Foo.s were causing the malfunction.</div>
</div><div>3) Determine why the stage 2 LLVM produced those instructions, instead of the correct ones.</div><div>5) Find the instructions (in the LLVM stage 2 executable) which are causing the incorrect behavior.</div><div>
6) Determine why the stage 1 LLVM emitted these instructions, instead of the correct ones.</div><div><br></div><div>My search ended at the ARM Load/Store rewrite pass. By scanning the debug output by hand, I determined that the bad code appeared during this pass. After I disabled this pass, all bugs in the stage 2 build went away.</div>
<div><br></div><div>Although, I can't produce a reasonable example, I think it should be obvious based on the debug output I gave above what is wrong. I did a quick review of the code in the ARM Load/store pass, and it seems to never take into account the liveness state of CPSR after ADDri. Please let me know if I'm mistaken in this assessment.</div>
<div><br></div><div>Thanks,</div><div>- pdox</div><div><br></div><div><br></div><div><div class="gmail_quote">On Sun, Feb 5, 2012 at 2:15 PM, Anton Korobeynikov <span dir="ltr"><<a href="mailto:anton@korobeynikov.info">anton@korobeynikov.info</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello David,<br>
<div class="im"><br>
> I'm seeing a case where ARM Load/Store optimizer is breaking code. I have<br>
> not had any luck trying to come up with a minimal example; it is breaking in<br>
> our stage 2 LLVM build.<br>
</div>Still, *any* testcase is better than no testcase :)<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
With best regards, Anton Korobeynikov<br>
Faculty of Mathematics and Mechanics, Saint Petersburg State University<br>
</font></span></blockquote></div><br></div>