[PATCH] D111703: [ARM] __cxa_end_cleanup should be called instead of _UnwindResume.

Logan Chien via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 25 09:06:35 PDT 2021


logan added a comment.

We are quite close now.  Here are my final comments.



================
Comment at: llvm/lib/CodeGen/DwarfEHPrepare.cpp:232
+        TargetTriple.isTargetEHABICompatible()) {
+      RewindName = TLI.getLibcallName(RTLIB::CXA_END_CLEANUP);
+      FTy = FunctionType::get(Type::getVoidTy(Ctx), false);
----------------
Add:

```
    RewindFunctionCallingConv = TLI.getLibcallCallingConv(RTLIB::CXA_END_CLEANUP);
```


================
Comment at: llvm/lib/CodeGen/DwarfEHPrepare.cpp:235
+    } else {
+      RewindName = TLI.getLibcallName(RTLIB::UNWIND_RESUME);
+      FTy = FunctionType::get(Type::getVoidTy(Ctx), Type::getInt8PtrTy(Ctx),
----------------
Add:

    RewindFunctionCallingConv = TLI.getLibcallCallingConv(RTLIB::UNWIND_RESUME);


================
Comment at: llvm/lib/CodeGen/DwarfEHPrepare.cpp:248-258
     Value *ExnObj = GetExceptionObject(RI);
-
-    // Call the _Unwind_Resume function.
-    CallInst *CI = CallInst::Create(RewindFunction, ExnObj, "", UnwindBB);
-    CI->setCallingConv(TLI.getLibcallCallingConv(RTLIB::UNWIND_RESUME));
+    CallInst *CI;
+    if (doesRewindFunctionNeedExceptionObject()) {
+      // Call the _Unwind_Resume function.
+      CI = CallInst::Create(RewindFunction, ExnObj, "", UnwindBB);
+      CI->setCallingConv(TLI.getLibcallCallingConv(RTLIB::UNWIND_RESUME));
+    } else {
----------------
Refine as:

```
    llvm::SmallVector<Value *, 1> RewindFunctionArgs;

    if (doesRewindFunctionNeedExceptionObject())
      RewindFunctionArgs.push_back(GetExceptionObject(RI));

    // Call the rewind function.
    CallInst *CI = CallInst::Create(RewindFunction, RewindFunctionArgs, "",
                                    UnwindBB);
    CI->setCallingConv(RewindFunctionCallingConv);
```

(Rationale: Avoid repeating `CallInst::Create(...)` and `CI->setCallingConv(...)` for two cases.)


================
Comment at: llvm/lib/CodeGen/DwarfEHPrepare.cpp:266-267
 
   std::vector<DominatorTree::UpdateType> Updates;
   Updates.reserve(Resumes.size());
+  CallInst *CI;
----------------
Move these two lines into `if (doesRewindFunctionNeedExceptionObject())` (Line 271).

Add:

```
    llvm::SmallVector<Value *, 1> RewindFunctionArgs;
```


================
Comment at: llvm/lib/CodeGen/DwarfEHPrepare.cpp:285
+      ++NumResumesLowered;
+    }
+    // Call the function.
----------------
Add:

    RewindFunctionArgs.push_back(PN);


================
Comment at: llvm/lib/CodeGen/DwarfEHPrepare.cpp:286-288
+    // Call the function.
+    CI = CallInst::Create(RewindFunction, PN, "", UnwindBB);
+    CI->setCallingConv(TLI.getLibcallCallingConv(RTLIB::UNWIND_RESUME));
----------------
Move these out of the if body:

```
  // Call the function.
  CallInst *CI = CallInst::Create(RewindFunction, RewindFunctionArgs, "",
                                  UnwindBB);
  CI->setCallingConv(RewindFunctionCallingConv);
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111703/new/

https://reviews.llvm.org/D111703



More information about the llvm-commits mailing list