[LLVMdev] Section specialization & COFF.

Michael Spencer bigcheesegs at gmail.com
Mon Oct 22 14:30:37 PDT 2012


On Mon, Oct 22, 2012 at 7:53 AM, r4start <r4start at gmail.com> wrote:
> On 20/10/12 03:15, Michael Spencer wrote:
>>
>> On Fri, Oct 19, 2012 at 2:55 AM, r4start <r4start at gmail.com> wrote:
>>>
>>> Hi all.
>>>
>>> While compiling next code
>>> @A = weak unnamed_addr constant { i32, i32, i32 } { i32 0, i32 0, i32 0
>>> },
>>> section ".data"
>>> was discovered that llc ignores weak linkage if we emit it in COFF
>>> object.
>>> Attached patch solves this problem, please review.
>>>
>>> I found some similar tests in test/Objects/Inputs. Should I do something
>>> like trivial.ll checking or there is a better way
>>> to check patch behaviour?
>>>
>>>   - Dmitry Sokolov.
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>>
>> test/Object is not the right place for the test. It should probably go
>> in test/MC/COFF as a .ll file, although technically it's codegen...
>>
>> Also, I'm pretty sure this is wrong for MinGW. What do msvc and
>> mingw-gcc produce for c code that generates this?
>>
>> - Michael Spencer
>
> For this c code(see attachments) cl, mingw and clang produce different
> coff's(was used dumpbin with option /ALL):
> 1) Cl generate separate COMDAT section with linkage selection "pick any"
> 2) Mingw place this value to regular section and place special auxilary
> record to symbol table
> 3) Clang without patch just ignore weakness of this value and place it to
> regular section.
>    But for weak values without explicit section specification it use cl-like
> way. i.e. generate
>    separate COMDAT section with a little difference in naming (unique suffix
> after $)
> 4) With this patch clang will generate correct COMDAT section for values
> with explicit section specification.
>
> The problem is in backend. When we have explicit section specification
> linkage type is ignored.

Looks fine with a test in CodeGen.

- Michael Spencer



More information about the llvm-dev mailing list