[Mlir-commits] [clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

Tom Eccles llvmlistbot at llvm.org
Tue Oct 22 17:41:54 PDT 2024


================
@@ -1171,12 +1179,15 @@ void OpenMPIRBuilder::emitCancelationCheckImpl(Value *CancelFlag,
   // post finalization block that is known to the FiniCB callback.
   Builder.SetInsertPoint(CancellationBlock);
   if (ExitCB)
-    ExitCB(Builder.saveIP());
+    if (Error Err = ExitCB(Builder.saveIP()))
+      return std::move(Err);
----------------
tblah wrote:

nit: the compiler should automatically move from a returned value whether you specify `std::move` or not (guaranteed from C++17 onwards). In general it is unhelpful to add the `std::move` here because it can prevent the return from being optimized out entirely.
```suggestion
      return Err;
```

See https://stackoverflow.com/questions/17473753/c11-return-value-optimization-or-move and https://stackoverflow.com/questions/14856344/when-should-stdmove-be-used-on-a-function-return-value

https://github.com/llvm/llvm-project/pull/112533


More information about the Mlir-commits mailing list