Allow CodeGen (llc) command line options to work as expected.
authorAndrew Trick <atrick@apple.com>
Wed, 15 Feb 2012 03:21:51 +0000 (03:21 +0000)
committerAndrew Trick <atrick@apple.com>
Wed, 15 Feb 2012 03:21:51 +0000 (03:21 +0000)
commit79bf288584215f3f3c49050ac1691a6b29c56fec
treedd59d6ffd51e93d13a44d60635a4b53d9c8273fa
parent5e108eeeef34dd2afa00d1da77bca47188de4244
Allow CodeGen (llc) command line options to work as expected.

The llc command line options for enabling/disabling passes are local to CodeGen/Passes.cpp. This patch associates those options with standard pass IDs so they work regardless of how the target configures the passes.

A target has two ways of overriding standard passes:
1) Redefine the pass pipeline (override TargetPassConfig::add%Stage)
2) Replace or suppress individiual passes with TargetPassConfig::substitutePass.

In both cases, the command line options associated with the pass override the target default.

For example, say a target wants to disable machine instruction scheduling by default:

- The target calls disablePass(MachineSchedulerID) but otherwise does not override any TargetPassConfig methods.

- Without any llc options, no scheduler is run.

- With -enable-misched, the standard machine scheduler is run and honors the -misched=... flag to select the scheduler variant, which may be used for performance evaluation or testing.

Sorry overridePass is ugly. I haven't thought of a better way without replacing the cl::opt framework. I hope to do that one day...

I haven't figured out why CodeGen uses char& for pass IDs. AnalysisID is much easier to use and less bug prone. I'm using it wherever I can for internal implementation. Maybe later we can change the global pass ID definitions as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150563 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/Passes.h
lib/CodeGen/Passes.cpp