[PATCH] D96931: [LTO] Discard non-prevailing defined symbols in module-level assembly
Yuanfang Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 16:59:21 PST 2021
ychen added a comment.
In D96931#2612602 <https://reviews.llvm.org/D96931#2612602>, @pcc wrote:
> In D96931#2612552 <https://reviews.llvm.org/D96931#2612552>, @ychen wrote:
>
>> In D96931#2612521 <https://reviews.llvm.org/D96931#2612521>, @pcc wrote:
>>
>>> This is just solving part of the problem, no? Imagine that you have a weak definition and a global definition in two object files. Then you will have the same problem.
>>
>> I would think the global one is chosen by the linker?
>
> I thought that the problem was with full LTO where the module inline asm blobs are simply concatenated. So if you have one file with
>
> .global foo
> foo:
> .byte 1
>
> and another with
>
> .weak foo
> foo:
> .byte 2
>
> then the assembler will see both `foo` labels and complain about multiple definitions.
>
>>
Not sure if I understand you correctly but I'm pretty sure this patch could address this particular example. The newly added test has a similar test case.
>>> I think that some kind of marker that we can use to mark blocks of asm as conceptually coming from different object files would be best.
>>
>> Encoded into metadata: the `map<inlineasm string offset, vector<nonprevail symbols>>` Then in the MC layer, discard the non-prevail symbols.
>
> I mean you would be able to say something like
>
> .new_module
> .global foo
> foo:
> .byte 1
>
> .new_module
> .weak foo
> foo:
> .byte 2
>
> and that would be equivalent to
>
> .global foo
> foo:
> .byte 1
> .byte 2
>
> Similarly if the second file did not provide a definition of `foo` the assembler would ignore the `.weak` directive.
I don't quite get the part that `.byte 2` is following `.byte 1`. If we don't use LTO, there should be no `.byte 2` in the final executable right?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96931/new/
https://reviews.llvm.org/D96931
More information about the llvm-commits
mailing list