================
@@ -309,6 +354,9 @@ void CIRGenFunction::popCleanupBlock() {
     assert(!cir::MissingFeatures::ehCleanupScopeRequiresEHCleanup());
     ehStack.popCleanup();
     scope.markEmitted();
+
+    mlir::OpBuilder::InsertionGuard guard(builder);
+    builder.setInsertionPointToStart(&cleanScope.getCleanupRegion().back());
     emitCleanup(*this, cleanup, cleanupFlags);
----------------
AmrDeveloper wrote:

I can add it with a condition, but for now, when I create a cleanup scope i 
already add a terminator, and when I insert i point to the start, the problem 
with OpenACC is that one scope has no terminator

```
cir.func no_inline @_Z10NormalFuncv() {
  cir.scope {
    %0 = cir.get_global @LocalHSE3 : !cir.ptr<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}>>
    %1 = acc.declare_link varPtr(%0 : !cir.ptr<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}>>) -> !cir.ptr<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}>> {name = "LocalHSE3"}
    %2 = cir.get_global @LocalInt3 : !cir.ptr<!cir.int<s, 32>>
    %3 = acc.declare_link varPtr(%2 : !cir.ptr<!cir.int<s, 32>>) -> 
!cir.ptr<!cir.int<s, 32>> {name = "LocalInt3"}
    %4 = cir.const #cir.int<1> : !cir.int<s, 32>
    %5 = builtin.unrealized_conversion_cast %4 : !cir.int<s, 32> to si32
    %6 = cir.const #cir.int<1> : !cir.int<s, 32>
    %7 = builtin.unrealized_conversion_cast %6 : !cir.int<s, 32> to si32
    %c0_i64 = arith.constant 0 : i64
    %c1_i64 = arith.constant 1 : i64
    %8 = acc.bounds lowerbound(%5 : si32) extent(%7 : si32) stride(%c1_i64 : 
i64) startIdx(%c0_i64 : i64)
    %9 = cir.get_global @LocalHSEArr3 : !cir.ptr<!cir.array<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}> x 5>>
    %10 = acc.declare_link varPtr(%9 : !cir.ptr<!cir.array<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}> x 5>>) bounds(%8) -> 
!cir.ptr<!cir.array<!cir.record<struct "HasSideEffects" padded {!cir.int<u, 
8>}> x 5>> {name = "LocalHSEArr3[1:1]"}
    %11 = cir.get_global @InnerHSE : !cir.ptr<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}>>
    %12 = acc.declare_link varPtr(%11 : !cir.ptr<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}>>) -> !cir.ptr<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}>> {name = "InnerHSE"}
    %13 = acc.declare_enter dataOperands(%1, %3, %10, %12 : 
!cir.ptr<!cir.record<struct "HasSideEffects" padded {!cir.int<u, 8>}>>, 
!cir.ptr<!cir.int<s, 32>>, !cir.ptr<!cir.array<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}> x 5>>, !cir.ptr<!cir.record<struct 
"HasSideEffects" padded {!cir.int<u, 8>}>>)
    cir.cleanup.scope {
      cir.call @do_thing() : () -> ()
      cir.yield
    } cleanup  normal {
      acc.declare_exit token(%13)
      cir.yield
    }
    <------------- no terminato
  }
  cir.call @do_thing() : () -> ()
  cir.return
}
```

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

Reply via email to