This is an archive of the discontinued LLVM Phabricator instance.

[X86] Provide the LSDA pointer with RIP relative addressing if necessary
ClosedPublic

Authored by mstorsjo on Sep 28 2017, 12:35 AM.

Details

Summary

This makes sure the LSDA pointer isn't truncated to 32 bit.

Make LowerINTRINSIC_WO_CHAIN a member function instead of a static function, so that it can use the getGlobalWrapperKind method.

This solves the other half of the issues mentioned in PR34720.

Diff Detail

Event Timeline

mstorsjo created this revision.Sep 28 2017, 12:35 AM
compnerd accepted this revision.Sep 28 2017, 8:23 PM

LGTM with the comment adjustments.

lib/Target/X86/X86ISelLowering.cpp
20108

Im not particularly fond of this comment. Adding a comment that getGlobalWrapperKind is not suitable here is fine. But please explain why it is unsuitable. Also, it took me a moment to figure out that this is not actually dependent on the PIC mode of compilation, but rather to ensure that the generated code is PIC. A comment to that effect would be nice.

This revision is now accepted and ready to land.Sep 28 2017, 8:23 PM
mstorsjo added inline comments.Sep 28 2017, 11:01 PM
lib/Target/X86/X86ISelLowering.cpp
20108

So, something like this?

// getGlobalWrapperKind can't be used here since we're in a static function and that requires an instance of X86TargetLowering.
// If we can use RIPRel addressing, prefer that since it doesn't cost anything extra, even if the build isn't required to be PIC.
compnerd added inline comments.Oct 1 2017, 2:13 PM
lib/Target/X86/X86ISelLowering.cpp
20108

Well, just because this function is static doesnt mean that we couldnt pass it a TLI. It does technically cost a bit in code size. I was thinking something like:

// We use RIP relative addressing to generate PIC code as that is compatible across PIC and non-PIC code.  We would need to wire
// the X86TargetLowering to this function to use getGlobalWrapperKind.

Actually, how difficult would that be anyways?

mstorsjo added inline comments.Oct 1 2017, 10:27 PM
lib/Target/X86/X86ISelLowering.cpp
20108

Actually wasn't hard at all to make this a non-static function - that's probably cleaner.

mstorsjo updated this revision to Diff 117300.Oct 1 2017, 10:28 PM
mstorsjo edited the summary of this revision. (Show Details)

Simplified by making the enclosing function a member function to allow it using getGlobalWrapperKind instead.

compnerd accepted this revision.Oct 2 2017, 1:43 PM
This revision was automatically updated to reflect the committed changes.