[llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceToFunction.cpp TraceToFunction.h
Brian Gaeke
gaeke at cs.uiuc.edu
Thu Jan 15 13:41:38 PST 2004
Changes in directory reopt/lib/LightWtProfiling:
TraceToFunction.cpp updated: 1.20 -> 1.21
TraceToFunction.h updated: 1.2 -> 1.3
---
Log message:
Create and start using a new class called TraceFunction, so that we can
pass around all the analysis results we compute in TraceToFunction.
Rename runTraceToFunction to TraceFunction::get().
---
Diffs of the changes: (+54 -15)
Index: reopt/lib/LightWtProfiling/TraceToFunction.cpp
diff -u reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.20 reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.21
--- reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.20 Wed Jan 14 17:02:22 2004
+++ reopt/lib/LightWtProfiling/TraceToFunction.cpp Thu Jan 15 13:40:08 2004
@@ -65,7 +65,7 @@
public:
TraceToFunction () { }
virtual ~TraceToFunction () { }
- virtual Function *traceToFunction (Trace &T);
+ virtual TraceFunction *traceToFunction (Trace &T);
};
bool Trace::dominates (const BasicBlock *B1, const BasicBlock *B2,
@@ -560,30 +560,36 @@
}
}
-Function *TraceToFunction::traceToFunction (Trace &T) {
+TraceFunction *TraceToFunction::traceToFunction (Trace &T) {
+ // Create a TraceFunction object to hold the trace function along with
+ // its auxiliary data structures.
+ TraceFunction *TF = new TraceFunction (T);
+
std::string CurrentFnName = T.getFunction ()->getName ();
DEBUG(std::cerr << "In traceToFunction() for " << CurrentFnName << "\n");
// Get some information about the trace's relationship to its parent
// function.
- LiveVariableSet Si = getTraceLiveInSet (T);
- LiveVariableSet So = getTraceLiveOutSet (T);
- TypeVector P = createFunctionArgTypeVector (createLiveOutType (So), Si);
+ TF->LiveInSet = getTraceLiveInSet (T);
+ TF->LiveOutSet = getTraceLiveOutSet (T);
+ TypeVector P =
+ createFunctionArgTypeVector (createLiveOutType (TF->LiveOutSet),
+ TF->LiveInSet);
// Make a new internal Function with return type int and parameter
// list P, in the same Module as the trace's parent function.
std::string name (CurrentFnName + ".trace");
- Function *F = new Function (FunctionType::get (Type::UIntTy, P, false),
+ TF->TraceFn = new Function (FunctionType::get (Type::UIntTy, P, false),
GlobalValue::InternalLinkage, name,
T.getModule ());
- DEBUG(giveNamesToFunctionArgs (Si, F));
- fillInFunctionBody (T, F, So);
- return F;
+ DEBUG(giveNamesToFunctionArgs (TF->LiveInSet, TF->TraceFn));
+ fillInFunctionBody (T, TF->TraceFn, TF->LiveOutSet);
+ return TF;
}
/// runTraceToFunction - Entry point for TraceToFunction transformation.
-Function *runTraceToFunction (Trace &T) {
+TraceFunction *TraceFunction::get (Trace &T) {
TraceToFunction TTF;
return TTF.traceToFunction (T);
}
Index: reopt/lib/LightWtProfiling/TraceToFunction.h
diff -u reopt/lib/LightWtProfiling/TraceToFunction.h:1.2 reopt/lib/LightWtProfiling/TraceToFunction.h:1.3
--- reopt/lib/LightWtProfiling/TraceToFunction.h:1.2 Wed Nov 19 16:51:49 2003
+++ reopt/lib/LightWtProfiling/TraceToFunction.h Thu Jan 15 13:40:08 2004
@@ -8,22 +8,55 @@
#ifndef TRACETOFUNCTION_H
#define TRACETOFUNCTION_H
+#include "Trace.h"
#include "llvm/Function.h"
#include <set>
#include <map>
namespace llvm {
-class Trace;
-
typedef std::set<Value *> LiveVariableSet;
typedef std::map<BasicBlock *, BasicBlock *> BasicBlockMap;
+// FIXME: this should definitely be part of TraceFunction.
extern BasicBlockMap ReturnBlockForTraceExit;
-/// runTraceToFunction - Entry point for TraceToFunction transformation.
-///
-Function *runTraceToFunction (Trace &T);
+// It's not clear whether this should be part of Trace or not. Logically, you
+// can't have a TraceFunction without a Trace, but you might not want all the
+// TraceFunction baggage if you just want a Trace.
+struct TraceFunction {
+ /// Function that contains the trace
+ ///
+ Function *MatrixFn;
+
+ /// Trace of 'hot' basic blocks from MatrixFn
+ ///
+ Trace &T;
+
+ /// Trace created by extracting T from MatrixFn
+ ///
+ Function *TraceFn;
+
+ /// Variables live going in to TraceFn from MatrixFn
+ ///
+ LiveVariableSet LiveInSet;
+
+ /// Variables live going out from TraceFn back into MatrixFn
+ ///
+ LiveVariableSet LiveOutSet;
+
+ /// Constructor - you can't have a TraceFunction without a Trace.
+ /// This gives you a "blank" TraceFunction without a TraceFn or any
+ /// live variable sets. If you want those, use TraceFunction::get ()
+ /// instead, which performs all the expensive transformations.
+ ///
+ TraceFunction (Trace &_T) : MatrixFn (_T.getFunction ()), T (_T) { }
+
+ /// Returns a filled-in TraceFunction object with a TraceFn for T,
+ /// along with its Live-In and Live-Out variable sets.
+ ///
+ static TraceFunction *get (Trace &T);
+};
} // end namespace llvm
More information about the llvm-commits
mailing list