[llvm] [SjLjEHPrepare] Fix callsite problem (PR #67264)
Kazushi Marukawa via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 24 07:28:29 PDT 2023
================
@@ -442,9 +442,19 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
for (BasicBlock &BB : F) {
if (&BB == &F.front())
continue;
- for (Instruction &I : BB)
- if (I.mayThrow())
- insertCallSiteStore(&I, -1);
+ for (Instruction &I : BB) {
+ // Partially revert b61fd7f modifications. Stop using "I.mayThrow()"
----------------
kaz7 wrote:
Ok. It's little tough for me. I still don't understand the detail of mayThrow. I'll try to explain the problem when I have time. Thank you.
The situation is something like this. Existing code inserts no-action mark (callsite == -1) just before "invoke __cxa_bad_cast" instructions because mayThrow function return true for such invoking instructions. As a result, following instructions sequence is generated.
```
# call _Unwind_SjLj_Register
lea %s0, _Unwind_SjLj_Register at lo
and %s0, %s0, (32)0
lea.sl %s12, _Unwind_SjLj_Register at hi(, %s0)
lea %s0, -104(, %s9)
bsic %s10, (, %s12)
...
.LBB0_1: # %dynamic_cast.bad_cast
or %s0, 1, (0)1 # store 1 by "insertCallSiteStore(Invokes[I], I + 1);" in previous loop.
st %s0, -96(, %s9)
or %s0, -1, (0)1 # store -1 by "insertCallSiteStore(&I, -1);" by loop I try to modify.
st %s0, -96(, %s9)
.Ltmp0:
lea %s0, __cxa_bad_cast at lo # callsite is -1, so nobody catch this bad cast
and %s0, %s0, (32)0
lea.sl %s12, __cxa_bad_cast at hi(, %s0)
bsic %s10, (, %s12)
```
I just notice that this problem was starting after b61fd7fc6da57c261a3d2154eecff7c59dfda9b0. It describes "No functional change is intended.", so I just thought reverting it partially is good enough. But not. I'll try to explain the problem later like I said above.
https://github.com/llvm/llvm-project/pull/67264
More information about the llvm-commits
mailing list