From 0ccdecbdaaebbd424f8b8afad67309d8b69d4c93 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Fri, 6 Jun 2003 06:59:55 +0000 Subject: [PATCH] ::: HACK ALERT ::: HACK ALERT ::: HACK ALERT ::: HACK ALERT ::: HACK ALERT ::: The JIT is designed to code-generate a function at-a-time. That means that any pass can only make local changes to its function. Period. Because the Sparc PreSelection pass claims to be a BasicBlock pass while adding globals to the Module, it cannot be run with the other passes, because by this time, the globals have been output already by the JIT, and the addresses of any globals appearing AFTER this point are not recognized. However, the PreSelection pass is a requirement for correctness in the Sparc codegen path, so it MUST be run. ::: HACK ALERT ::: HACK ALERT ::: HACK ALERT ::: HACK ALERT ::: HACK ALERT ::: llvm-svn: 6650 --- llvm/lib/ExecutionEngine/JIT/JIT.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp index 2e7236b5d500..fd41c4c1273a 100644 --- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp @@ -11,6 +11,9 @@ #include "llvm/Module.h" #include "Support/CommandLine.h" +// FIXME: REMOVE THIS +#include "llvm/PassManager.h" + namespace { cl::opt Arch("march", cl::desc("Architecture: `x86' or `sparc'"), cl::Prefix, @@ -27,7 +30,6 @@ namespace { } - /// createJIT - Create an return a new JIT compiler if there is one available /// for the current target. Otherwise it returns null. /// @@ -65,6 +67,17 @@ VM::VM(Module *M, TargetMachine *tm) : ExecutionEngine(M), TM(*tm) { MCE = createEmitter(*this); setupPassManager(); + + // THIS GOES BEYOND UGLY HACKS + if (TM.getName() == "UltraSparc-Native") { + extern Pass *createPreSelectionPass(TargetMachine &TM); + PassManager PM; + // Specialize LLVM code for this target machine and then + // run basic dataflow optimizations on LLVM code. + PM.add(createPreSelectionPass(TM)); + PM.run(*M); + } + emitGlobals(); }