[PATCH] D78932: [DSE,MSSA] Relax post-dom restriction for objs visible after return.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 14:04:10 PDT 2020


fhahn added a comment.

In D78932#2006268 <https://reviews.llvm.org/D78932#2006268>, @efriedma wrote:

> The PostDominatorTree doesn't include implicit unwind edges.  I'm not completely sure whether your change handles that correctly... but either way, please make sure we have testcases.


To double check, as I am not too familiar with the exception handling stuff, are you referring to an example like the one below, where ehcleanup exits to the caller through unwinding? IIUC the problematic scenario would be when we have a store before an invoke, which gets overwritten on the path to the regular exit, but not on the exception path. Calls to throwing function currently block DSE, and I think that would also prevent eliminating in cases mentioned before (even if it is overwritten on the unwind edges too).

  define void @test1(i32* %p, i1 %c) personality i32 (...)* @__CxxFrameHandler3 {
  entry:
    store i32 2, i32* %p
    br i1 %c, label %exit, label %invoke.cont
  
  invoke.cont:
    invoke void @throw()
    to label %exit unwind label %catch.dispatch
  
  catch.dispatch:                                   ; preds = %invoke.cont
    %cs = catchswitch within none [label %invoke.cont1] unwind label %ehcleanup
  
  invoke.cont1:                                     ; preds = %catch.dispatch
    %catch = catchpad within %cs [i8* null, i32 64, i8* null]
    invoke void @throw() [ "funclet"(token %catch) ]
    to label %exit unwind label %ehcleanup
  
  ehcleanup:                                        ; preds = %invoke.cont1, %catch.dispatch
    %cleanup = cleanuppad within none []
    call void @release(i64 0) [ "funclet"(token %cleanup) ]
    cleanupret from %cleanup unwind to caller
  
  exit:                                      ; preds = %invoke.cont1, %invoke.cont
    store i32 1, i32* %p
    ret void
  }
  
  declare i32 @__CxxFrameHandler3(...)
  
  declare void @throw()
  
  declare void @release(i64)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78932





More information about the llvm-commits mailing list