[llvm-branch-commits] [flang] [mlir] [mlir][OpenMP] Pack task private variables into a heap-allocated context struct (PR #125307)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Feb 6 03:37:59 PST 2025
================
@@ -1415,11 +1413,13 @@ static llvm::Expected<llvm::BasicBlock *> allocateAndInitPrivateVars(
llvm::Value *llvmPrivateVar = builder.CreateAlloca(
llvmAllocType, /*ArraySize=*/nullptr, "omp.private.alloc");
- llvm::Error err = initPrivateVar(
+ llvm::Expected<llvm::Value *> privateVarOrError = initPrivateVar(
builder, moduleTranslation, privDecl, mlirPrivVar, blockArg,
- llvmPrivateVar, llvmPrivateVars, privInitBlock, mappedPrivateVars);
- if (err)
+ llvmPrivateVar, privInitBlock, mappedPrivateVars);
+ if (auto err = privateVarOrError.takeError())
----------------
skatrak wrote:
I'm not sure if this can cause issues. The documentation for `takeError` states that, after calling this function, `privateVarOrError` would be in an "indeterminate state that can only be safely destroyed". Maybe I'm misunderstanding, but to be safe, I'd suggest this alternative:
```c++
if (!privateVarOrError)
return privateVarOrError.takeError();
```
https://github.com/llvm/llvm-project/pull/125307
More information about the llvm-branch-commits
mailing list