Help with pass ordering

Dear llvm guys,

    I am trying to add the BreakCriticalEdges pass to my application. I
tried to add it to the PNE pass (e.g. PHIElimination.cpp -
AU.addRequiredID(BreakCriticalEdgesID); ), but I get this error:

llc -f -regalloc=simple Base1Sum.bc -o simple.s

There are a couple of problems with this. The specific reason that you're getting the assertion is because LLVM schedules the critical-edge-breaking pass before the PHI elimination pass, and LLVM cannot figure out a safe ordering of passes to get it to work. In particular, something is probably invalidating the pass before it can be used.

The bigger issue here, however, is that even if LLVM allowed you to do this, it wouldn't be what you want. This would split the critical edges of the LLVM CFG, where you (probably) want to split the critical edges of the machine code CFG.

We don't have any really good facilities for playing around with the machine code CFG. If you're interested in this, I would suggest implementing more TargetInstrInfo::xxx hooks. There is already reverseBranchCondition, it would be straight-forward to add new things.

-Chris