GkvJwa wrote:

> > This case(new and delete object) I think we should probably fix the EH 
> > numbering algorithm, This does not conflict with This PR
> 
> I argued throughout this PR that "fixing this in EH numbering" is not optimal 
> since mixing SEH with C++ unwinding is generally not allowed in MS C++ and 
> only seems to be supported by Borland C++. In the latter case I do not know 
> how unwinding is generated (e.g. which personality is chosen).
> 
> What i noticed though: even if we mark the dtor as virtual for the delete 
> sample there is still a scope begin+end. That is also true if we delete the 
> delete call and just have the ctor present. Since this is legal in MS C++ I 
> guess one can argue that we should indeed respect c++ scope begin/end 
> intrinsics in the `calculateSEHStateForAsynchEH` numbering algo.

I checked the IR for this case.
```
invoke.cont2:                                     ; preds = %invoke.cont1
  invoke void @llvm.seh.scope.begin()
          to label %invoke.cont3 unwind label %ehcleanup

invoke.cont3:                                     ; preds = %invoke.cont2
  store volatile ptr %call, ptr %a, align 8
  %0 = load volatile ptr, ptr %a, align 8
  %isnull = icmp eq ptr %0, null
  br i1 %isnull, label %delete.end, label %delete.notnull

delete.notnull:                                   ; preds = %invoke.cont3
  invoke void @llvm.seh.scope.begin()
          to label %invoke.cont6 unwind label %ehcleanup10

invoke.cont6:                                     ; preds = %delete.notnull
  invoke void @"??1A@@QEAA@XZ"(ptr noundef nonnull align 1 dereferenceable(1) 
%0) #9
          to label %invoke.cont7 unwind label %ehcleanup10

invoke.cont7:                                     ; preds = %invoke.cont6
  invoke void @llvm.seh.try.end()
          to label %invoke.cont8 unwind label %ehcleanup10

invoke.cont8:                                     ; preds = %invoke.cont7
  invoke void @"??3@YAXPEAX_K@Z"(ptr noundef %0, i64 noundef 1) #10
          to label %invoke.cont9 unwind label %ehcleanup14

invoke.cont9:                                     ; preds = %invoke.cont8
  br label %delete.end

delete.end:                                       ; preds = %invoke.cont9, 
%invoke.cont3
  invoke void @llvm.seh.try.end()
          to label %invoke.cont13 unwind label %ehcleanup14

invoke.cont13:                                    ; preds = %delete.end
  %1 = call ptr @llvm.localaddress()
  call void @"?fin$0@0@f@@"(i8 noundef 0, ptr noundef %1)
  ret void
```

`delete.notnull` include `llvm.seh.scope.begin`, but `delete.end` 
not(`delete.notnull` also br `delete.end` too
This prevents `new` and `delete` from being compiled into the `__try` block 
simultaneously, unlike in MSVC.

https://github.com/llvm/llvm-project/pull/172287
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to