From 9b24eeee01a7e7225280ad90b44e06158cdb0806 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Thu, 16 Jan 2014 21:44:34 +0000 Subject: [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 --- tools/opt/opt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools') 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: " -- cgit v1.2.3