diff options
author | Quentin Colombet <qcolombet@apple.com> | 2014-01-16 21:44:34 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2014-01-16 21:44:34 +0000 |
commit | 9b24eeee01a7e7225280ad90b44e06158cdb0806 (patch) | |
tree | 0773b72ad9486c9028e54b9f18408eeb741b7ae6 /tools | |
parent | 7c41150e851bf4e79f796e0b3a933112d78dd567 (diff) | |
download | llvm-9b24eeee01a7e7225280ad90b44e06158cdb0806.tar.gz llvm-9b24eeee01a7e7225280ad90b44e06158cdb0806.tar.bz2 llvm-9b24eeee01a7e7225280ad90b44e06158cdb0806.tar.xz |
[opt][PassInfo] Allow opt to run passes that need target machine.
When registering a pass, a pass can now specify a second construct that takes as
argument a pointer to TargetMachine.
The PassInfo class has been updated to reflect that possibility.
If such a constructor exists opt will use it instead of the default constructor
when instantiating the pass.
Since such IR passes are supposed to be rare, no specific support has been
added to this commit to allow an easy registration of such a pass.
In other words, for such pass, the initialization function has to be
hand-written (see CodeGenPrepare for instance).
Now, codegenprepare can be tested using opt:
opt -codegenprepare -mtriple=mytriple input.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/opt/opt.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index dcff891bcd..ef8c504d0f 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -795,7 +795,9 @@ int main(int argc, char **argv) { const PassInfo *PassInf = PassList[i]; Pass *P = 0; - if (PassInf->getNormalCtor()) + if (PassInf->getTargetMachineCtor()) + P = PassInf->getTargetMachineCtor()(TM.get()); + else if (PassInf->getNormalCtor()) P = PassInf->getNormalCtor()(); else errs() << argv[0] << ": cannot create pass: " |