================
@@ -192,10 +195,22 @@ bool 
WebAssemblyFixBrTableDefaults::runOnMachineFunction(MachineFunction &MF) {
 
 } // end anonymous namespace
 
-INITIALIZE_PASS(WebAssemblyFixBrTableDefaults, DEBUG_TYPE,
+INITIALIZE_PASS(WebAssemblyFixBrTableDefaultsLegacy, DEBUG_TYPE,
                 "Removes range checks and sets br_table default targets", 
false,
                 false)
 
-FunctionPass *llvm::createWebAssemblyFixBrTableDefaults() {
-  return new WebAssemblyFixBrTableDefaults();
+FunctionPass *llvm::createWebAssemblyFixBrTableDefaultsLegacyPass() {
+  return new WebAssemblyFixBrTableDefaultsLegacy();
+}
+
+bool WebAssemblyFixBrTableDefaultsLegacy::runOnMachineFunction(
+    MachineFunction &MF) {
+  return fixBrTableDefaults(MF);
+}
+
+PreservedAnalyses
+WebAssemblyFixBrTableDefaultsPass::run(MachineFunction &MF,
+                                       MachineFunctionAnalysisManager &MFAM) {
+  return fixBrTableDefaults(MF) ? getMachineFunctionPassPreservedAnalyses()
+                                : PreservedAnalyses::none();
----------------
boomanaiden154 wrote:

> OK, as I said, I am not familiar with this new PM thing, so please walk me 
> through all different modes of this preserving thing.

I'm not doing a particularly great job of explaining things, so that doesn't 
help. Sorry.

> getMachineFunctionPassPreservedAnalyses()

This preserves all IR level (Function+Module) analyses and invalidates all 
MachineFunction analyses. So we would preserve something like 
`FunctionPropertiesAnalysis` or `ModuleSummaryAnalysis` (which operate over 
IR), but would invalidate something like `MachineDominatorTree` that is 
computed over MIR.

> getMachineFunctionPassPreservedAnalyses().preserveSet()

This preserves all IR level (Function+Module) analyses and invalidates all 
MachineFunction analyses minus what is preserved in the set. The most common 
set here would be CFGAnalyses. So on top of the same behavior for IR level 
analyses as above, we would invalidate something like `SlotIndexesAnalysis` 
(which depends upon individual instructions), but preserve something like 
`MachineDominatorTree` if we're marking the CFG as preserved.

> PreservedAnalyses::none().preserveSet()

This invalidates all (Function+Module+MachineFunction) analyses minus the set 
that gets preserved.

A bare `PreservedAnalyses` should only be used in `Module` or `Function` 
passes. `MachineFunction` passes cannot (or at least are not supposed) to 
modify IR. If the IR doesn't change, then any analyses over that IR also should 
not change.

> PreservedAnalyses::all()

Preserves everything (Function+Module+MachineFunction).

> PreservedAnalyses::none()

Invalidates everything (Function+Module+MachineFunction).

(I also before was saying MIR analyses which I was using to be synonymous with 
MachineFunction analyses, although in the actual code they're 
`MACHINE_FUNCTION_ANALYSIS` and I should probably stop using the term "MIR 
analysis").

https://github.com/llvm/llvm-project/pull/209882
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to