[llvm-commits] CVS: reopt/lib/TraceJIT/TraceJITGlobals.cpp TraceJIT.cpp TraceJIT.h
Brian Gaeke
gaeke at cs.uiuc.edu
Thu Jun 3 00:47:17 PDT 2004
Changes in directory reopt/lib/TraceJIT:
TraceJITGlobals.cpp added (r1.1)
TraceJIT.cpp updated: 1.1 -> 1.2
TraceJIT.h updated: 1.2 -> 1.3
---
Log message:
Read in the internalGlobals map and populate the TraceJIT's
GlobalAddress map upon construction. This makes it possible to
jit traces that access GlobalValues whose mangled names we can't reconstruct
with the current Mangler.
---
Diffs of the changes: (+52 -0)
Index: reopt/lib/TraceJIT/TraceJITGlobals.cpp
diff -c /dev/null reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.1
*** /dev/null Thu Jun 3 00:42:56 2004
--- reopt/lib/TraceJIT/TraceJITGlobals.cpp Thu Jun 3 00:42:46 2004
***************
*** 0 ****
--- 1,49 ----
+ //===-- TraceJITGlobals.cpp - Parse internal global mapping info ----------===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by the LLVM research group and is distributed under
+ // the University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // These methods allow the TraceJIT to find internal globals compiled by llc,
+ // whose names the mangler may not be able to reconstruct. This parses mapping
+ // info produced by the InternalGlobalMapper pass.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "TraceJIT.h"
+ #include "llvm/Module.h"
+ #include "Support/Debug.h"
+ using namespace llvm;
+
+ struct InternalGlobalMap {
+ unsigned int Size;
+ void *GlobalAddrs[0]; // Length is fixed but not known at compile time.
+ };
+
+ extern "C" InternalGlobalMap _llvm_internalGlobals;
+
+ namespace llvm {
+
+ void TraceJIT::maybeAddInternalGlobal (GlobalValue *GV, unsigned int &Counter) {
+ if (Counter >= _llvm_internalGlobals.Size) return;
+ void *savedAddr = _llvm_internalGlobals.GlobalAddrs[Counter];
+ ++Counter;
+ if (GV->hasInternalLinkage() && GV->hasName () && savedAddr) {
+ DEBUG (std::cerr << "Old internal global " << GV->getName ()
+ << " found at " << savedAddr << "\n");
+ addGlobalMapping (GV, savedAddr);
+ }
+ }
+
+ void TraceJIT::addInternalGlobalMappings (Module &M) {
+ unsigned Counter = 0;
+ for (Module::giterator i = M.gbegin (), e = M.gend (); i != e; ++i)
+ maybeAddInternalGlobal (i, Counter);
+ for (Module::iterator i = M.begin (), e = M.end (); i != e; ++i)
+ maybeAddInternalGlobal (i, Counter);
+ }
+
+ } // end namespace llvm
Index: reopt/lib/TraceJIT/TraceJIT.cpp
diff -u reopt/lib/TraceJIT/TraceJIT.cpp:1.1 reopt/lib/TraceJIT/TraceJIT.cpp:1.2
--- reopt/lib/TraceJIT/TraceJIT.cpp:1.1 Wed May 26 16:25:13 2004
+++ reopt/lib/TraceJIT/TraceJIT.cpp Thu Jun 3 00:42:45 2004
@@ -69,6 +69,7 @@
// Initialize MCE & trace-function unpacker
MCE = createTraceJITEmitter (this);
+ addInternalGlobalMappings (*MP->getModule ());
UTF = new UnpackTraceFunction (&TM);
PM.add (new TargetData (getTargetData ()));
Index: reopt/lib/TraceJIT/TraceJIT.h
diff -u reopt/lib/TraceJIT/TraceJIT.h:1.2 reopt/lib/TraceJIT/TraceJIT.h:1.3
--- reopt/lib/TraceJIT/TraceJIT.h:1.2 Thu May 27 16:32:10 2004
+++ reopt/lib/TraceJIT/TraceJIT.h Thu Jun 3 00:42:45 2004
@@ -99,6 +99,8 @@
MachineCodeEmitter *getEmitter() { return MCE; }
private:
void addPassesToReoptimizeTrace (FunctionPassManager &PM);
+ void maybeAddInternalGlobal (GlobalValue *GV, unsigned int &Counter);
+ void addInternalGlobalMappings (Module &M);
void runJITOnFunction (Function *F);
};
More information about the llvm-commits
mailing list