This is an archive of the discontinued LLVM Phabricator instance.

Fixed "use POP for small post-call stack clean-up" code size optimization
ClosedPublic

Authored by aaboud on Sep 3 2015, 2:34 PM.

Details

Summary

Fixed Bug 24649.
Now the optimization will search for the right GPR type depends on the architecture size 32bit or 64bit.

Diff Detail

Repository
rL LLVM

Event Timeline

aaboud updated this revision to Diff 33975.Sep 3 2015, 2:34 PM
aaboud retitled this revision from to Fixed "use POP for small post-call stack clean-up" code size optimization.
aaboud updated this object.
aaboud added a reviewer: rnk.
aaboud set the repository for this revision to rL LLVM.
aaboud added subscribers: dvyukov, mkuper.
mkuper added a comment.Sep 3 2015, 2:54 PM

Thanks, Amjad!
Can you also fix pop-stack-cleanup.ll to also check the 64-bit case?

lib/Target/X86/X86FrameLowering.cpp
1853 ↗(On Diff #33975)

I think this should not be strictly necessary, because if it's negative, NumPops will also be negative, so it will never be 1 or 2. But if you think it makes the intent clearer, that's ok.

1877 ↗(On Diff #33975)

Argh, right, thanks. I wonder how this manages to work correctly with integrated-as...

aaboud added inline comments.Sep 6 2015, 3:54 AM
lib/Target/X86/X86FrameLowering.cpp
1853 ↗(On Diff #33975)

The % of negative numbers are not well defined, especially, as offset is an "int" and "SlotSize" is an "unsigned int".
So, I do not want to depend on that result if I know that we should not handle negative numbers.

aaboud updated this revision to Diff 34202.Sep 8 2015, 2:16 AM
aaboud removed rL LLVM as the repository for this revision.

Added a test case to cover this chang.

mkuper accepted this revision.Sep 9 2015, 10:17 AM
mkuper added a reviewer: mkuper.
mkuper added inline comments.
lib/Target/X86/X86FrameLowering.cpp
1853 ↗(On Diff #34202)

Ohhh, right, forgot the sign is implementation-defined!
Thanks a lot.

This revision is now accepted and ready to land.Sep 9 2015, 10:17 AM
This revision was automatically updated to reflect the committed changes.