This is an archive of the discontinued LLVM Phabricator instance.

[XCOFF][AIX] Enable -ffunction-sections
ClosedPublic

Authored by jasonliu on Jul 15 2020, 7:40 AM.

Details

Summary

This patch implements -ffunction-sections on AIX.
This patch focuses on assembly generation.
Follow-on patch needs to handle:

  1. -ffunction-sections implication for jump table.
  2. Object file generation path and associated testing.

Diff Detail

Event Timeline

jasonliu created this revision.Jul 15 2020, 7:40 AM
jasonliu updated this revision to Diff 278188.Jul 15 2020, 7:47 AM
hubert.reinterpretcast retitled this revision from [XCOFF][AIX] Enable -function-sections to [XCOFF][AIX] Enable -ffunction-sections.Jul 15 2020, 7:48 AM
hubert.reinterpretcast edited the summary of this revision. (Show Details)
DiggerLin added inline comments.Jul 15 2020, 12:05 PM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2167

change Func->isDeclaration() to Func->isDeclarationForLinker() ?

2169

SC only use once.

jasonliu marked 2 inline comments as done.Jul 22 2020, 12:04 PM
jasonliu added inline comments.
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2167

Sometimes I would get confused myself which query should be used.
As far as I understand, isDelcarationForLinker includes linkage that's "AvailableExternally". But when does it actually matter for a function? In other words, what would go wrong if isDeclaration() is used here?

2169

Yes, but without this named variable, the return below would get extremely long, and harder to read.

Xiangling_L added inline comments.Jul 22 2020, 12:09 PM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2167

AFAIK, this linkage only matters for global variables not for functions.

jasonliu updated this revision to Diff 279916.Jul 22 2020, 12:41 PM

Rebase with latest master.

DiggerLin added inline comments.Jul 24 2020, 12:13 PM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2167

thanks for clarification.

DiggerLin accepted this revision.Jul 27 2020, 8:14 AM

LGTM

llvm/lib/Target/PowerPC/PPCISelLowering.cpp
5381

nit: delete the space in the /* IsAlias= */.

This revision is now accepted and ready to land.Jul 27 2020, 8:14 AM
Xiangling_L added inline comments.Jul 27 2020, 8:20 AM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2088

Should we also handle this in this patch?

2164

s/Okay/okay?

jasonliu marked an inline comment as done.Jul 27 2020, 9:02 AM
jasonliu added inline comments.
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2088

I think this is fairly orthogonal and we could handle it with a follow up patch.
Noted that without handling this, we might run into asserts when using function sections with jump table.

Xiangling_L added inline comments.Jul 27 2020, 9:05 AM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
5338–5339

I am wondering why we don't just use Subtarget.getTargetMachine().getObjFileLowering().getFunctionEntryPointSymbol instead? And all the logic below about how we get the MCSymbolXCOFF should be simplified by doing this?

Xiangling_L added inline comments.Jul 27 2020, 9:10 AM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
2088

I am okay with handling this with a separate patch, but I think you may want to edit the patch description or title to indicate the limited scope of this patch.

jasonliu edited the summary of this revision. (Show Details)Jul 27 2020, 9:54 AM
jasonliu marked an inline comment as done.Jul 27 2020, 12:10 PM
jasonliu added inline comments.
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
5338–5339

Good point. I created NFC patch to address this issue: D84693.

Xiangling_L added inline comments.Jul 27 2020, 2:05 PM
llvm/test/CodeGen/PowerPC/aix-xcoff-funcsect.ll
16

Just a question here, why would we want to test hidden_foo and static_overalign_foo? I didn't see anything special about them when handling -ffunction-sections options.

jasonliu marked an inline comment as done.Jul 27 2020, 2:41 PM
jasonliu added inline comments.
llvm/test/CodeGen/PowerPC/aix-xcoff-funcsect.ll
16

I want to make sure emitLinkage and setCsectAlignment in doInitialization still works with function-sections. As some of them were accepting labels before, and setCsectAlignment was only doing csect alignment for the whole .text section.

Xiangling_L accepted this revision.Jul 27 2020, 5:15 PM

LGTM. Thanks.

This revision was automatically updated to reflect the committed changes.