Page MenuHomePhabricator

[XCOFF] Enable explicit sections on AIX
ClosedPublic

Authored by jasonliu on Sep 30 2020, 2:20 PM.

Details

Summary

Implement mechanism to allow explicit sections to be generated on AIX.

Diff Detail

Event Timeline

jasonliu created this revision.Sep 30 2020, 2:20 PM
jasonliu requested review of this revision.Sep 30 2020, 2:20 PM
jasonliu updated this revision to Diff 295412.
jasonliu added inline comments.Sep 30 2020, 2:28 PM
llvm/lib/MC/MCContext.cpp
673

Maybe it's worth to discuss: is there a better way to detect and prevent this case from happening?

int b __attribute__((section("a"))) = 2;
int a = 3;

Right now, I have to add a new field to MCSectionXCOFF to see if the policy matches. Not sure if we could do it without this new field.

DiggerLin added inline comments.Oct 5 2020, 8:45 AM
llvm/include/llvm/MC/MCSectionXCOFF.h
39

Using MultiSymbolsAllowed to represent whether the section is generated for separate function or separated data variable when -function-section or -data-section .

what about to change the MultiSymbolsAllowed to IsSymbolNameAsSectionName ?

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2325

is there possible, something like ?

int b attribute((section("a"))) = 2;
void a(void) {
}
and compile with -function-section?

jasonliu added inline comments.Oct 7 2020, 10:13 AM
llvm/include/llvm/MC/MCSectionXCOFF.h
39

Anything wrong with the MultiSymbolsAllowed?
IsSymbolNameAsSectionName does not really convey what we want. As you could have
int a attribute((section("a"))) = 2;
And the symbol name is the same with section name, but I assume we don't want true here.

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2325

I don't think that would be a problem as they still belongs to different sections.
b would belong to a[RW]
and function a would belong to a[PR]

Gentle ping.

DiggerLin added inline comments.Nov 4 2020, 12:55 PM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2125–2140
/// If this global does not have a custom section, this will be empty and the
 /// default object file section (.text, .data, etc) will be used.
 StringRef getSection() const {
   return hasSection() ? getSectionImpl() : StringRef();
 }

do we need to check whether the Section Name is empty ?

2325

thanks

jasonliu added inline comments.Nov 5 2020, 6:57 AM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2125–2140

This functionality seems already handled in its caller: TargetLoweringObjectFile::SectionForGlobal, where it would return the default section if hasSection returns false.

jasonliu updated this revision to Diff 303138.Nov 5 2020, 8:58 AM
jasonliu added inline comments.
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2125–2140

Checked that it's possible for the user to get here with a pragma clang section, so I will report a fatal error as a limitation for now.

This revision is now accepted and ready to land.Nov 5 2020, 9:53 AM
This revision was automatically updated to reflect the committed changes.