[llvm] [PassManager] Support MachineFunctionProperties (PR #83668)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 19:43:40 PDT 2024


================
@@ -64,6 +64,8 @@ extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
 
 namespace llvm {
 
+class MachineFunction;
----------------
aeubanks wrote:

> It would be much more convenient to have something declarative

I still don't really understand this.

```
FooPass::run(MachineFunction&MF, ...) {
  verifyMachineFunctionProperties(MF, MachineFunctionProperties().set(
        MachineFunctionProperties::Property::NoVRegs));
}
```

is less code and more explicit than writing an extra method that also returns the same `MachineFunctionProperties`. Can you give an example of what you have in mind?

> and then you have to construct an empty MachineFunctionProperties, and set fields in it

`MachineFunctionProperties::set()` is like a builder, so constructing an arbitrary `MachineFunctionProperties` can be expressed in one statement

> I would prefer verify machine function properties in instrumentation (e.g. by a string map)

can you clarify what you mean by "by a string map"?

> modify properties in pass, e.g. by a Scope-Bound Resource Management object

I agree it's nice to be able to say at the beginning of `run` that some MachineFunction property will be set when the pass returns since putting the `verify` and `set` `MachineFunctionProperties` together is nice, but also I don't think it's a huge deal to have the pass manually set `MachineFunctionProperties` at the end of the pass. And IMO the boilerplate you're proposing is not worth it

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


More information about the llvm-commits mailing list