This is an archive of the discontinued LLVM Phabricator instance.

[NFC] [PowerPC] add an routine in PPCTargetLowering to determine if a global is accessed as got-indirect or not.
ClosedPublic

Authored by steven.zhang on Nov 26 2018, 6:54 PM.

Details

Summary

In theory, we should let the PPC target to determine how to lower the TOC Entry for globals. And the PPCTargetLowering require this query to do some optimization for TOC_Entry. I will commit another patch to do that.

Diff Detail

Repository
rL LLVM

Event Timeline

steven.zhang created this revision.Nov 26 2018, 6:54 PM
sfertile added inline comments.Nov 29 2018, 10:28 AM
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
4901 ↗(On Diff #175380)

In this case we don't keep the address of the global in the .toc/.got so the comment is misleading, maybe something more like:

// Build the address relative to the TOC-pointer.
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
13730 ↗(On Diff #175380)

I believe Non-Lazy-Pointer is strictly a mac-os construct (not sure exactly what it is). I think the comment here would be less confusing if it simply mentions that the NLP flag indicates that a global access has to use an extra indirection.

llvm/lib/Target/PowerPC/PPCISelLowering.h
793 ↗(On Diff #175380)

I would prefer to keep consistent with the V2 abi naming and call this 'GotIndirect' instead of TOCIndirect, but don't feel super strongly about it.

steven.zhang marked 4 inline comments as done.
steven.zhang retitled this revision from [NFC] [PowerPC] add an routine in PPCTargetLowering to determine if a global is accessed as toc-indirect or not. to [NFC] [PowerPC] add an routine in PPCTargetLowering to determine if a global is accessed as got-indirect or not..

Update the comments.

llvm/lib/Target/PowerPC/PPCISelLowering.h
793 ↗(On Diff #175380)

I was swing between these two terms. Agree that Got would be more clear.

sfertile accepted this revision.Nov 30 2018, 6:39 AM

LGTM!

This revision is now accepted and ready to land.Nov 30 2018, 6:39 AM
This revision was automatically updated to reflect the committed changes.