This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Do not use LOAD_STACK_GUARD with ROPI/RWPI
ClosedPublic

Authored by pzheng on Aug 8 2022, 12:46 PM.

Details

Summary

ROPI/RWPI are not supported with LOAD_STACK_GUARD currently.

Diff Detail

Event Timeline

pzheng created this revision.Aug 8 2022, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 12:46 PM
pzheng requested review of this revision.Aug 8 2022, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 12:46 PM
nickdesaulniers accepted this revision.Aug 8 2022, 1:25 PM
nickdesaulniers added a reviewer: rengolin.

Thanks for the patch! Please consider adding a test case for this.

This revision is now accepted and ready to land.Aug 8 2022, 1:26 PM
pzheng updated this revision to Diff 450988.Aug 8 2022, 4:03 PM

Add a test

pzheng added a comment.Aug 8 2022, 4:05 PM

Thanks for reviewing the patch, @nickdesaulniers. I have added a test for the change.

rengolin added inline comments.Aug 9 2022, 1:55 AM
llvm/test/CodeGen/ARM/stack-guard-rwpi.ll
2

Perhaps add a second RUN line with another relocation model showing that you do see the stack guard?

Maybe even a third, for ROPI, just to make sure neither of them are removed by accident in the future.

6

I'm not fully aware how the stack guard works in practice, is this an example of it not lowered?

pzheng added inline comments.Aug 9 2022, 11:47 AM
llvm/test/CodeGen/ARM/stack-guard-rwpi.ll
2

Makes sense to me, will add two more RUN lines as you suggested.

6

Yes, this is an example of how the stack guard is lowered when LOAD_STACK_GUARD is not used. If LOAD_STACK_GUARD is used for rwpi/ropi (which is what this patch is trying to avoid), there is an assertion coming from lvm/lib/Target/ARM/ARMBaseInstrInfo.cpp.

void llvm::ARMBaseInstrInfo::expandLoadStackGuardBase(MachineBasicBlock::iterator, unsigned int, unsigned int) const: Assertion `!Subtarget.isROPI() && !Subtarget.isRWPI() && "ROPI/RWPI not currently supported with stack guard"' failed.

This patch basically prevents the assertion from happening since we already know ropi/rwpi are not supported with LOAD_STACK_GUARD yet .

pzheng updated this revision to Diff 451240.Aug 9 2022, 12:36 PM

Update test based on review feedback

rengolin accepted this revision.Aug 9 2022, 12:41 PM
rengolin added inline comments.
llvm/test/CodeGen/ARM/stack-guard-rwpi.ll
6

Ack, makes sense, just checking, thanks!

This revision was landed with ongoing or failed builds.Aug 9 2022, 2:59 PM
This revision was automatically updated to reflect the committed changes.