[llvm-branch-commits] [clang] [llvm] [mlir] [OMPIRBuilder] CANCEL IF(FALSE) is still a cancellation point (PR #164587)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Oct 22 04:30:29 PDT 2025


================
@@ -1087,8 +1087,20 @@ OpenMPIRBuilder::createCancel(const LocationDescription &Loc,
   auto *UI = Builder.CreateUnreachable();
 
   Instruction *ThenTI = UI, *ElseTI = nullptr;
-  if (IfCondition)
+  if (IfCondition) {
     SplitBlockAndInsertIfThenElse(IfCondition, UI, &ThenTI, &ElseTI);
+
+    // Even if the if condition evaluates to false, this should count as a
+    // cancellation point
+    Builder.SetInsertPoint(ElseTI);
+    auto ElseIP = Builder.saveIP();
+
+    InsertPointOrErrorTy IPOrErr = createCancellationPoint(
+        LocationDescription{ElseIP, Loc.DL}, CanceledDirective);
----------------
Meinersbur wrote:

```suggestion
        LocationDescription(ElseIP, Loc.DL), CanceledDirective);
```
brace-initialization is uncommon in `/llvm`

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


More information about the llvm-branch-commits mailing list