Section specialization & COFF.

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.

section.diff (1.14 KB)

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.

1.c (175 Bytes) (3.36 KB)

1.clang.txt (1.23 KB)

1.clang.with_patch.txt (1.31 KB)

1.mingw.txt (3.05 KB)

Looks fine with a test in CodeGen.

- Michael Spencer

Was added test.
Please review.
Patch was made by Dmitry Puzirev.

weak-section.diff (2.53 KB)



- Michael Spencer

Can anybody commit patch.
I don`t have commit rights.

Ping? Can anybody commit this patch?