This is an archive of the discontinued LLVM Phabricator instance.

Define a subtarget feature to force stack realignment
ClosedPublic

Authored by ahatanak on Aug 6 2015, 12:00 PM.

Details

Summary

This patch defines a subtarget feature to force stack realignment and removes cl::opt option force-stack-align. This change is needed to enable forcing stack realignment when doing LTO. The subtarget features each target defines should be removed in the future once we have a way to define target-independent "generic" subtarget features.

Diff Detail

Repository
rL LLVM

Event Timeline

ahatanak updated this revision to Diff 31464.Aug 6 2015, 12:00 PM
ahatanak retitled this revision from to Define a subtarget feature to force stack realignment.
ahatanak updated this object.
ahatanak added reviewers: echristo, dexonsmith.
ahatanak added a subscriber: llvm-commits.

I think we can make changes to X86TTIImpl::areInlineCompatible if we want to be stricter and reject inlining when the caller and callee disagree on "force-align-stack". The current code would allow inlining if the caller had feature "force-align-stack" and the callee did not.

hfinkel requested changes to this revision.Aug 13 2015, 5:01 PM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

I don't think this is the right design for this feature: Forcing essentially all targets to add the same subtarget feature and associated logic is not good.

Instead, please add this to include/llvm/Target/TargetOptions.h, and add default handling in lib/Target/TargetMachine.cpp (command-line options, function attributes, etc.).

This revision now requires changes to proceed.Aug 13 2015, 5:01 PM
echristo edited edge metadata.Aug 13 2015, 5:02 PM

Hi Hal,

We specifically didn't do that for soft-float. I don't know if we want to look at this as "a step too far", but that's where we've been. I'm fine with revisiting that decision - I didn't have a strong opinion either way.

-eric

ahatanak updated this revision to Diff 32590.Aug 19 2015, 12:00 PM
ahatanak edited edge metadata.

Use function attribute "force-align-stack" instead of defining a subtarget feature for each target and move cl::opt option ForceAlignStack to CommandFlags.h so that tools like llc can write the function attribute to the IR. It really should be an enum attribute because it's target independent, but I used a string attribute here to make it consistent with "no-realign-stack".

ahatanak updated this revision to Diff 33457.Aug 28 2015, 1:18 PM
ahatanak edited edge metadata.

The updated patch makes the following changes:

  • Use function attribute "stackrealign" to decide whether stack realignment should happen.
  • Rename "force-align-stack" to "stackrealign" to be consistent with the function attribute.

I also think function attribute "no-realign-stack" should be a cl::opt option since it is used for debugging purposes. I plan to make the changes in a follow-up patch.

This revision was automatically updated to reflect the committed changes.