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?
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.