This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC][XCOFF] Fix expansion of LWZtoc Pseudo for AIX.
ClosedPublic

Authored by sfertile on Sep 20 2019, 11:28 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

sfertile created this revision.Sep 20 2019, 11:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 20 2019, 11:28 AM
Xiangling_L added inline comments.Sep 23 2019, 12:34 PM
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
652 ↗(On Diff #221078)

As you mentioned before, should we assert Darwin target is invalid for this toc-related pseudo? Something like:

assert (!isDarwin && "TOC is an ELF/XCOFF construct");
674 ↗(On Diff #221078)

You seems miss a comment here , which matches the later "Otherwise" on line 684

// Create a reference to the GOT entry for the symbol. The GOT entry will be synthesized later.

695 ↗(On Diff #221078)

Should we be more specific?
Like:

This pseudo should only be selected for 32-bit small code model.

llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
4 ↗(On Diff #221078)

Personally, I prefer keep the testcase as minimal as possible, so maybe we can remove some attributes like:
"local_unnamed_addr",
"; Function Attrs: norecurse nounwind",
"#0",
"align 4" etc.

sfertile updated this revision to Diff 221454.Sep 23 2019, 7:06 PM
  • Added an assertion expressing the platform must not be Darwin.
  • Added missing comment
  • Fixed assertion message to be more specific
  • Cleaned up the test.
sfertile marked 6 inline comments as done.Sep 23 2019, 7:07 PM
sfertile added inline comments.
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
652 ↗(On Diff #221078)

Good idea. Added.

llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
4 ↗(On Diff #221078)

Agreed. Cleaned up.

Xiangling_L accepted this revision.Sep 24 2019, 7:40 AM

Just a minor nit:

clean up "local_unnamed_addr" in testcase? or even "dso_local"?
llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
7 ↗(On Diff #221454)

Clean up this "local_unnamed_addr" as well?

This revision is now accepted and ready to land.Sep 24 2019, 7:40 AM
This revision was automatically updated to reflect the committed changes.
sfertile marked 2 inline comments as done.
sfertile marked an inline comment as done.Sep 24 2019, 11:11 AM

Just a minor nit:

clean up "local_unnamed_addr" in testcase? or even "dso_local"?

Done, and thanks for the review.

llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
7 ↗(On Diff #221454)

I got sloppy and missed this one. I've cleaned up in the final commit.

llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
696

I would prefer if we mentioned "label" somewhere in the comment as the term that maps better in the context of AIX. The implicit property is also limited to certain contexts (the Assembler Language Reference describes the condition as use of the label as a displacement in a D-form instruction), and the comment is insufficiently qualified to make that clear.

sfertile marked an inline comment as done.Sep 25 2019, 8:45 AM
sfertile added inline comments.
llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
696

I would prefer if we mentioned "label" somewhere in the comment as the term that maps better in the context of AIX.

Can you expand on that, I'm not sure what semantic difference there is between a local symbol and a local label. I considered them equivalent, but can be wrong.

The implicit property is also limited to certain contexts (the Assembler Language Reference describes the condition as use of the label as a displacement in a D-form instruction), and the comment is insufficiently qualified to make that clear.

What about:

// AIX uses the local symbol directly for the operand; that the symbol is
 // accessed toc-relative in a lwz instruction is implicit.
llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
696

Maybe: "[ ... ] directly as the lwz displacement operand for references into the toc section. The displacement value will be generated relative to the toc-base."

As for the difference between a label and a local symbol: A label in the assembly may be used to provide a definition for a symbol, but does not itself form a symbol. When using a reference to a label that is not a symbol, the generated relocation should refer to the symbol table entry of the csect. When using a reference to a label that is a symbol, the generated relocation refers to the symbol table entry of the symbol. For toc entries, the csect is the entry itself, so a non-symbol label to the start of the entry would act like the entry symbol/csect.

Thanks for the explanation Hubert. I've updated the comments and committed.

Thanks for the explanation Hubert. I've updated the comments and committed.

Great; thanks.