[flang-commits] [flang] fix optional wait wrongly treated as false (PR #78149)
Yi Wu via flang-commits
flang-commits at lists.llvm.org
Mon Jan 15 05:02:04 PST 2024
================
@@ -2925,9 +2926,30 @@ void IntrinsicLibrary::genExecuteCommandLine(
mlir::Type boxNoneTy = fir::BoxType::get(builder.getNoneType());
- mlir::Value waitBool = isStaticallyPresent(wait)
- ? fir::getBase(wait)
- : builder.createBool(loc, true);
+ mlir::Value waitBool;
+ if (isStaticallyAbsent(wait)) {
+ waitBool = builder.createBool(loc, true);
+ } else {
+ mlir::Type i1Ty = builder.getI1Type();
+ mlir::Value waitAddr = fir::getBase(wait);
+ mlir::Value waitIsPresentAtRuntime =
+ builder.genIsNotNullAddr(loc, waitAddr);
+ waitBool = builder
+ .genIfOp(loc, {i1Ty}, waitIsPresentAtRuntime,
+ /*withElseRegion=*/true)
+ .genThen([&]() {
+ auto waitLoad = builder.create<fir::LoadOp>(loc, waitAddr);
+ mlir::Value cast =
+ builder.createConvert(loc, i1Ty, waitLoad);
+ builder.create<fir::ResultOp>(loc, cast);
+ })
+ .genElse([&]() {
+ mlir::Value trueVal = builder.createBool(loc, true);
+ builder.create<fir::ResultOp>(loc, trueVal);
+ })
+ .getResults()[0];
+ }
----------------
yi-wu-arm wrote:
There is one for `GetEnvironmentVariable` for `trim` bool variable, https://github.com/llvm/llvm-project/blob/cfa30fa4852275eed0c59b81b5d8088d3e55f778/flang/lib/Optimizer/Builder/IntrinsicCall.cpp#L3187
https://github.com/llvm/llvm-project/pull/78149
More information about the flang-commits
mailing list