[llvm-commits] [llvm] r164866 - in /llvm/trunk: lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/X86/2012-09-28-CGPBug.ll

Eli Friedman eli.friedman at gmail.com
Thu Oct 18 19:02:21 PDT 2012


On Sun, Oct 7, 2012 at 11:20 AM, Benjamin Kramer <benny.kra at gmail.com> wrote:
>
> On 07.10.2012, at 20:06, Evan Cheng <evan.cheng at apple.com> wrote:
>
>> In global JT, he addresses of other blocks are used. If they are merged into other blocks, then you end up with invalid values like this:
>> _JT:
>>        .long   Ltmp2-Ltmp0
>>        .long   Ltmp1-Ltmp0
>>        .long   1-Ltmp2
>>        .long   1-Ltmp1
>
> Taking the address of a block that's not used in an indirectbr is undefined behavior (except for comparisons against null). There are many passes that can discard dead blocks and cause this kind of code to be emitted and I think the problem here is that the assembler chokes on "1-label", I see a couple of ways to fix this but none is really satisfying:
>
> - Turn the dead blockaddrs into references to the containing function. This is tricky to implement because you can't take the address of an entry block, and was discarded as a bad idea before.

A variant of this: introduce a special "undef block address" constant
which points at an arbitrary point in a given function.  Possibly more
work to implement than I'd like, but not tricky as far as I can tell.

> - Turn the dead blockaddrs into undef. I think that could work but I'm not really sure about the implications.

Overly aggressive, given that we've already made some minor
concessions that blockaddr does something useful even without an
associated indirectbr.

> - Teach the assembler to deal with this kind of thing, probably not worth it.

There isn't any way to emit "1-Ltmp2" whether or not we can parse it.

-Eli




More information about the llvm-commits mailing list