This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Don't merge sp decrement into later stores when using WinCFI
ClosedPublic

Authored by mstorsjo on Sep 30 2020, 1:41 AM.

Details

Summary

This matches the corresponding existing case in AArch64LoadStoreOpt::findMatchingUpdateInsnForward.

Both cases could also be modified to check MBBI->getFlag(FrameSetup/FrameDestroy) instead of forbidding any optimization involving SP, but the effect is probably pretty much the same.

Diff Detail

Event Timeline

mstorsjo created this revision.Sep 30 2020, 1:41 AM
mstorsjo requested review of this revision.Sep 30 2020, 1:41 AM
efriedma added inline comments.Sep 30 2020, 3:17 PM
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
1869

If we're using the same code to do this check in multiple places, should we factor it out?

llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
32

Technically speaking, we could do this merge, but probably not worth implementing that transform.

dnsampaio resigned from this revision.Sep 30 2020, 11:51 PM

I'm not the right reviewer for this patch.

mstorsjo added inline comments.Oct 1 2020, 1:35 AM
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
1869

I can at least factor out the whole needsWinCFI part of it, but other than that, it feels a bit obscure to factor it out further, e.g with if (shouldSkipMatchingUpdateBackwardsForwards(BaseReg, I->getMF()) return E;, even if that allows factoring out some more checks and the code comment.

mstorsjo updated this revision to Diff 295489.Oct 1 2020, 1:36 AM
mstorsjo edited the summary of this revision. (Show Details)

Factorize out a helper function needsWinCFI, to reduce the amount of duplicated code a little bit.

efriedma accepted this revision.Oct 1 2020, 7:56 AM

LGTM

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
1869

Okay, that's reasonable.

This revision is now accepted and ready to land.Oct 1 2020, 7:56 AM