This is an archive of the discontinued LLVM Phabricator instance.

[MachineOutliner][AArch64] Keep track of functions that use a red zone in AArch64MachineFunctionInfo and use that instead of checking for noredzone in the MachineOutliner
ClosedPublic

Authored by paquette on Apr 2 2018, 3:37 PM.

Details

Summary

This patch adds the a hasRedZone() function to AArch64MachineFunctionInfo.

Right now, to use the MachineOutliner, you have to pass -mno-red-zone to ensure that we never outline anything from a function which uses a red zone. This is kind of clunky, especially considering you have to pass -aarch64-redzone to use a red zone in the first place in AArch64.

This patch removes the -mno-red-zone requirement and teaches the outliner about which functions actually use a red zone. This would also allow for outlining from functions without red zones in the case where -aarch64-redzone is passed.

Diff Detail

Event Timeline

paquette created this revision.Apr 2 2018, 3:37 PM
thegameg added inline comments.Apr 3 2018, 1:34 AM
lib/Target/AArch64/AArch64MachineFunctionInfo.h
95

Since this is available only after PEI, I wonder if it wouldn't be safer to initialize UsesRedZone to !F.hasFnAttribute(Attribute::NoRedZone). That way if the function is called before PEI we use the attribute, and after PEI we overwrite this.

javed.absar added inline comments.Apr 3 2018, 1:48 AM
lib/Target/AArch64/AArch64MachineFunctionInfo.h
147

nitpick - should this be called 'hasRedZone' to be consistent with other namings e.g. hasStackFrame?

gberry added inline comments.Apr 3 2018, 7:26 AM
lib/Target/AArch64/AArch64MachineFunctionInfo.h
95

If the value is going to change over time, perhaps you could name the function mightUseRedZone instead?
Or you could use an Option<bool> and assert if it is queried before it is set?

test/CodeGen/AArch64/machine-outliner-noredzone.ll
8

This could use a one line description of what it is testing.

10

I assume this test needs to be this large in order to cross some threshold to trigger outlining?

gberry added a comment.Apr 3 2018, 7:34 AM

Another thought, would it be worthwhile to add a serialized MIR function property for this usesRedZone flag so you could write MIR tests for this instead?

Another thought, would it be worthwhile to add a serialized MIR function property for this usesRedZone flag so you could write MIR tests for this instead?

In that case this would have to go to MachineFrameInfo since we don't have MIR serialization for (Target)FunctionInfo.

paquette updated this revision to Diff 140853.Apr 3 2018, 1:38 PM
paquette edited the summary of this revision. (Show Details)

Updated diff to address comments.

usesRedZone is now hasRedZone.

hasRedZone is now a function that returns an optional. The optional is set either during frame lowering, or on the construction of AArch64FunctionInfo in the case where the IR-level function has the noredzone attribute.

I tried to simplify the test a little, but it needs to be somewhat long to trigger the desired outliner behaviour, unfortunately.

paquette marked 4 inline comments as done.Apr 3 2018, 1:40 PM

Marked comments, etc.

test/CodeGen/AArch64/machine-outliner-noredzone.ll
10

Yes, unfortunately. :(

thegameg accepted this revision.Apr 3 2018, 1:48 PM

LGTM, thanks!

This revision is now accepted and ready to land.Apr 3 2018, 1:48 PM
paquette closed this revision.Apr 26 2018, 3:09 PM

Committed in r329120.