This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Remove pipeline dependencies on StackProtector; NFC
ClosedPublic

Authored by rinon on Sep 7 2017, 12:23 PM.

Details

Reviewers
MatzeB
Summary

PrologEpilogInserter and StackColoring depend on the StackProtector analysis
being alive from the point it is run until PEI, which requires that they are all
scheduled in the same FunctionPassManager. Inserting a (machine) ModulePass
between StackProtector and PEI results in these passes being in separate
FunctionPassManagers and the StackProtector is not available for PEI.

PEI and StackColoring don't use much information from the StackProtector pass,
so transfering the required information to MachineFrameInfo is cleaner than
keeping the StackProtector pass around. This commit moves the SSP layout
information to MFI instead of keeping it in the pass.

This patch set (D37580, D37581, D37582, D37583, D37584, D37585, D37586, D37587)
is a first draft of the pagerando implementation described in
http://lists.llvm.org/pipermail/llvm-dev/2017-June/113794.html.

Diff Detail

Event Timeline

rinon created this revision.Sep 7 2017, 12:23 PM
peter.smith added inline comments.
include/llvm/CodeGen/MachineFrameInfo.h
515

typo "layou" should be "layout"?

rinon edited the summary of this revision. (Show Details)Oct 31 2017, 11:42 AM
rinon updated this revision to Diff 121097.Oct 31 2017, 6:03 PM

Fix typo

rinon marked an inline comment as done.Oct 31 2017, 6:03 PM
MatzeB accepted this revision.Jan 18 2018, 6:43 PM
MatzeB added a subscriber: MatzeB.

Ah nice, thanks for cleaning this up!
LGTM with nitpicks addressed:

  • Add a "CodeGen: " prefix and a "; NFC" suffix to the commit title.
include/llvm/CodeGen/MachineFrameInfo.h
91

Don't repeat the enum name.

This revision is now accepted and ready to land.Jan 18 2018, 6:43 PM
MatzeB added inline comments.Jan 18 2018, 6:44 PM
include/llvm/CodeGen/StackProtector.h
53

Maybe split this into a separate commit before pushing.

rinon updated this revision to Diff 130701.Jan 19 2018, 2:58 PM
  • Don't repeat enum name.
  • Remove adjustForColoring since it is now unused.
rinon marked an inline comment as done.Jan 19 2018, 2:59 PM
rinon added inline comments.
include/llvm/CodeGen/StackProtector.h
53

I believe this needs to stay atomic with the rest of the changeset to avoid a bug between the changes. StackColoring used to call adjustForColoring() which would cause the StackProtector pass to update its mapping in the SSPLayoutMap before StackColoring RAUWed the old Alloca with a BitCast. This update is now done in the MFI without changing the StackProtector mapping. Without the change to this data type, the RAUW breaks the SSPLayoutMap since it can no longer refer to the replaced Alloca.

rinon retitled this revision from Remove pipeline dependencies on StackProtector to CodeGen: Remove pipeline dependencies on StackProtector; NFC.Jan 19 2018, 3:03 PM
MatzeB added inline comments.Jan 19 2018, 3:15 PM
include/llvm/CodeGen/StackProtector.h
53

Makes sense.

(this patch is still good to go/accepted)

rinon updated this revision to Diff 144664.Apr 30 2018, 6:27 PM

Rebase onto master, rather than other pagerando commits. Should fix arc patch
not being able to apply the patch.

rinon added a comment.Apr 30 2018, 6:31 PM

Thanks. I don't have commit access, so if anyone would commit it on my behalf I'd appreciate it. Sorry, I should have mentioned this earlier.

Thanks @rinon for this. Are you still interested in committing this? I would like to get this in to fix some X86 machine verifier issues.
Some comments below, other than that it LGTM, I can commit this for you after that.

include/llvm/CodeGen/StackProtector.h
41

This is now duplicated in MachineFrameInfo.h.

71

Is this still needed now that all the info is in MFI?

Sorry this fell to the cracks. I tried comitting it yesterday, but it needs some adaptation for GlobalISel now. I'm currently making some simple changes for that and will then commit...

Thanks @rinon for this. Are you still interested in committing this? I would like to get this in to fix some X86 machine verifier issues.

Yep! I'll rebase and take a look at your MFI comments now, unless @MatzeB is already doing that.

Thanks @rinon for this. Are you still interested in committing this? I would like to get this in to fix some X86 machine verifier issues.

Yep! I'll rebase and take a look at your MFI comments now, unless @MatzeB is already doing that.

I already have it rebased and slightly cleaned up. Just investigating a few GlobalISel failures now (GlobalISel probably wasn't enabled by default when this patch was created).

Thanks @MatzeB. Yes, I believe GlobalISel wasn't enabled yet when I last touched this patch. I'd be happy to take a look at those failures now, if you want.

include/llvm/CodeGen/StackProtector.h
41

Good point, this should probably use the MFI enum.

71

Yes. initializeStackProtectorMap uses getSSPLayout which uses this map. It can be dropped when we are done with the analysis pass now, though.

rinon closed this revision.Jul 12 2018, 11:36 AM

Closing this review in favor of updated version @ D49256.