This is an archive of the discontinued LLVM Phabricator instance.

[XCOFF] Use -data-sections=true as default for llc on AIX
AbandonedPublic

Authored by jasonliu on Sep 29 2020, 8:11 AM.

Details

Summary

Variables with common linkage will be emitted as a common-type csect in XCOFF. Per the assembly reference:
"Several modules can share the same common block. If any of those modules have an external Control Section (csect) with the same name and the csect with the same name has a storage mapping class other than BS or UC, then the common block is initialized and becomes that other Control Section.”

Initialization via a non-csect (i.e label-ed data) is an undefined behaviour on AIX platform, and results in a linker warning.
Therefore, we want to turn on -data-sections by default on AIX. User could still use -fdata-sections=false if they understand the potential risks.

Diff Detail

Event Timeline

jasonliu created this revision.Sep 29 2020, 8:11 AM
jasonliu requested review of this revision.Sep 29 2020, 8:11 AM

@jasonliu: There's a lot of test adjustments to explicitly use the non-default, but I am not sure there is testing here to validate that the llc default when producing XCOFF assembly/object output is with unique data sections.

llvm/lib/CodeGen/CommandFlags.cpp
481

Suggestion (see proposed edit).

Not sure if the suggested name is better. Just noting that is particular line doesn't fit the pattern for when there is a codegen::get* function.

jasonliu updated this revision to Diff 295401.Sep 30 2020, 1:57 PM

Address comments.

@jasonliu: There's a lot of test adjustments to explicitly use the non-default, but I am not sure there is testing here to validate that the llc default when producing XCOFF assembly/object output is with unique data sections.

I just added the default testing in test/CodeGen/PowerPC/aix-xcoff-data-sections.ll. Thanks!

jasonliu marked an inline comment as done.Sep 30 2020, 1:58 PM
This revision is now accepted and ready to land.Sep 30 2020, 2:12 PM
MaskRay added a subscriber: MaskRay.EditedOct 2 2020, 10:32 AM

Can D88748 avoid HasExplicitDataSections?

You can then pass Triple to InitTargetOptionsFromCodeGenFlags

User could still use -fdata-sections=false if they understand the potential risks.

-fno-data-sections

jasonliu planned changes to this revision.Oct 2 2020, 5:01 PM

This patch could be abandoned if D88737 gets acceptance.

jasonliu abandoned this revision.Oct 14 2020, 8:59 AM