[llvm-commits] [llvm-mc][patch] Rename local symbols if needed

Rafael Espindola espindola at google.com
Fri Oct 8 11:59:21 PDT 2010


Currently llvm-mc will fail to assemble

----------------------------------------------------
        .size bar, . - bar
.Ltmp0:
       .size foo, .Ltmp0 - foo
--------------------------------------------------

With the interesting error message

../test.s:4:1: error: invalid symbol redefinition
.Ltmp0:

The problem is the the dot in the first size statement causes llvm-mc
to create a temporary symbol named ".Ltmp0". My first idea was to
delay assigning names to assembler created labels, but that fails when
printing assembly, since we print it as we go. What I did instead was
add support for renaming symbols that conflict with assembler created
ones. Other options I thought about

*) Use a truly invalid name for the assembler created symbols. If this
is done, then we cannot pass the output of llvm-mc to llvm-mc
*) Rename all temporaries. For example, we could add a 'a' to the end
of every label created by the assembler and a 'b' to every regular
label. I decided not to this to avoid changing the produced assembly
more than necessary.
*) Delay the printing of the assembly file so that we can select the
names of the artificial labels once every other label is known. Looked
harder than what I implemented, but might be the best solution in the
end.

So, is the attached patch OK?

Cheers,
-- 
Rafael Ávila de Espíndola
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rename.patch
Type: text/x-patch
Size: 5511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101008/7569d49e/attachment.bin>


More information about the llvm-commits mailing list