Label address (taken with blockaddress) not exported to .s

Hi all,

I recently updated my LLVM tree and I have a strange issue with the use
of blockaddress. The LLVM file that I try to compile is [1].

I do:

llvm-as test_ba.ll
opt -O2 test_ba.bc -o test_ba_opt.bc
llc test_ba_opt.bc

In r159116 (committed in 24/06/2012) I get (in the end of the .s file):

  .type table_closures,@object # @table_closures
  .section .rodata,"a",@progbits
  .globl table_closures
  .align 8
table_closures:
  .quad .Ltmp0
  .quad .Ltmp1
  .size table_closures, 16

While in r164026 (committed in 17/09/2012) I get:

  .type table_closures,@object # @table_closures
  .section .rodata,"a",@progbits
  .globl table_closures
  .align 8
table_closures:
  .quad .Ltmp0
  .quad 1
  .size table_closures, 16

i.e. One label address is not properly exported in the table.

Is there something wrong here? Or am I missing something?

Best regards,
Yiannis

PS: Sorry for the poor testcase but I couldn't reduce it anymore. I'll
try harder and post again if that's needed.

[1]: Label address (taken with blockaddress) not exported to .s · GitHub

Taking the address of a block by itself has zero guarantees about whether or not that block will exist by the time the code is emitted. If the block no longer exists by the end, it gets replaced with a constant 1.

To add on to this, take a look at the LLVM blog post on this,
particularly the end:

.

In short, BlockAddress values that aren't used in an indirectbr are
not something LLVM will make any effort to preserve for you.

When the underlying block is merged/removed/etc what Joshua said above
comes into play: the address is replaced with a constant 1. Check the
BasicBlock destructor for the source of this behavior.

Hope this helps,

~Will