[llvm] [MIR] Allow overriding isSSA, noPhis, noVRegs in MIR input (PR #108546)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 23 05:04:42 PDT 2024


================
@@ -398,21 +400,61 @@ void MIRParserImpl::computeFunctionProperties(MachineFunction &MF) {
       }
     }
   }
-  if (!HasPHI)
-    Properties.set(MachineFunctionProperties::Property::NoPHIs);
+
+  // Helper function to sanity-check and set properties that are computed, but
+  // may be explicitly set from the input MIR
+  auto ComputedPropertyHelper =
+      [&Properties](std::optional<bool> ExplicitProp, bool ComputedProp,
+                    MachineFunctionProperties::Property P) -> bool {
+    // Prefer whatever is set explicitly by the input MIR
+    if (ExplicitProp.has_value()) {
+      if (*ExplicitProp) {
+        // Check for conflicts with the computed value
+        if (!ComputedProp)
+          return true;
+
+        Properties.set(P);
+      } else
+        Properties.reset(P);
+
+      return false;
+    }
+
+    // No explicit value given, so use computed value
+    if (ComputedProp)
+      Properties.set(P);
+    else
+      Properties.reset(P);
+
+    return false;
----------------
arsenm wrote:

```suggestion
    // No explicit value given, so use computed value
    if (ComputedProp)
      Properties.set(P);
    else
      Properties.reset(P);

    // Check for conflicts with the computed value
    return ExplicitProp && *ExplicitProp && !Properties.hasProperty(P);
 
```

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


More information about the llvm-commits mailing list