[PATCH] D51114: [WebAssembly] Don't write SP back when prolog is generated only for EH
Derek Schuff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 22 11:26:10 PDT 2018
dschuff added inline comments.
================
Comment at: lib/Target/WebAssembly/WebAssemblyEHRestoreStackPointer.cpp:73
+ // Here it is safe to assume that SP32 holds the latest value of
+ // __stack_poiner, because the only exception for this case is when a
+ // function uses the red zone, but that only happens with leaf functions,
----------------
__stack_pointer
================
Comment at: lib/Target/WebAssembly/WebAssemblyEHRestoreStackPointer.cpp:75
+ // function uses the red zone, but that only happens with leaf functions,
+ // and leaf functions can't catch exceptions anyway.
auto InsertPos = MBB.begin();
----------------
can't leaf functions have try/catch blocks, even if there are no calls? I think the real issue is that leaf functions do not to restore the stack pointer on catch, because it won't have been updated by any callees.
================
Comment at: lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp:115
+ bool NeedsSPOnlyForEH = !MFI.getStackSize() && !MFI.adjustsStack() &&
+ !hasFP(MF) && needsPrologForEH(MF);
+ bool CanUseRedZone = MFI.getStackSize() <= RedZoneSize && !MFI.hasCalls() &&
----------------
Another possible way:
`bool NeedsSPForLocalFrame = MFI.getStackSize() || !MFI.adjustsStack() || hasFP(MF);`
which would avoid so many nots...
Actually, even better may be to turn `NeedsSPForLocalFrame()` into a function (that can be called by `needsSP()`). Then you can reuse it here instead of duplicating the logic?
Repository:
rL LLVM
https://reviews.llvm.org/D51114
More information about the llvm-commits
mailing list