Using the StructurizeCFG pass

Hi all,

I’m trying to add the StructurizeCFG pass with a legacy::PassManager:

legacy::PassManager pm;
// other passes

But I get this error when I attempt to to run it:

Pass ‘Structurize control flow’ is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
Lower SwitchInst’s to branches
Dominator Tree Construction
Assertion failed: (PI && “Expected required passes to be initialized”), function schedulePass, file /path/to/llvm/lib/IR/LegacyPassManager.cpp, line 640.

StructurizeCFG calls initializeStructurizeCFGPass from its constructor, so it would seem to me that the pass should have been initialized. Predictably, explicitly calling it myself does not change anything.

There appears to be only one use of StructurizeCFG (from the AMD GPU backend), and I’m not familiar enough with the backend architecture to figure out what it’s doing that I’m not.

Am I missing something obvious?


To anyone interested, I was apparently not initializing “hard enough”. I copied every initialize call from opt and it now works.