#include "llvm/Transforms/Instrumentation/TraceValues.h"
#include "llvm/Transforms/ChangeAllocations.h"
#include "llvm/Transforms/HoistPHIConstants.h"
+#include "llvm/Transforms/Scalar/DecomposeMultiDimRefs.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Bytecode/WriteBytecodePass.h"
#include "llvm/Transforms/ConstantMerge.h"
#include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/PassManager.h"
#include "Support/CommandLine.h"
+#include "Support/Signals.h"
#include <memory>
-#include <string>
#include <fstream>
using std::string;
static cl::Flag DumpAsm ("d", "Print bytecode before native code generation", cl::Hidden);
enum TraceLevel {
- TraceOff, TraceMethods, TraceBasicBlocks
+ TraceOff, TraceFunctions, TraceBasicBlocks
};
static cl::Enum<enum TraceLevel> TraceValues("trace", cl::NoFlags,
- "Trace values through methods or basic blocks",
+ "Trace values through functions or basic blocks",
clEnumValN(TraceOff , "off", "Disable trace code"),
- clEnumValN(TraceMethods , "method", "Trace each method"),
+ clEnumValN(TraceFunctions , "function", "Trace each function"),
clEnumValN(TraceBasicBlocks, "basicblock", "Trace each basic block"), 0);
Passes.add(createHoistPHIConstantsPass());
if (TraceValues != TraceOff) { // If tracing enabled...
- // Insert trace code in all methods in the module
+ // Insert trace code in all functions in the module
if (TraceValues == TraceBasicBlocks)
Passes.add(createTraceValuesPassForBasicBlocks());
- else if (TraceValues == TraceMethods)
- Passes.add(createTraceValuesPassForMethod());
+ else if (TraceValues == TraceFunctions)
+ Passes.add(createTraceValuesPassForFunction());
else
assert(0 && "Bad value for TraceValues!");
// Eliminate duplication in constant pool
Passes.add(createDynamicConstantMergePass());
-
- // Then write out the module with tracing code before code generation
+ }
+
+ // Decompose multi-dimensional refs into a sequence of 1D refs
+ Passes.add(createDecomposeMultiDimRefsPass());
+
+ // Write out the module with tracing code just before code generation
+ if (TraceValues != TraceOff) { // If tracing enabled...
assert(InputFilename != "-" &&
"files on stdin not supported with tracing");
string traceFileName = GetFileNameRoot(InputFilename) + ".trace.bc";
<< "Use -f command line argument to force output\n";
return 1;
}
-
+
std::ostream *os = new std::ofstream(traceFileName.c_str());
if (!os->good()) {
cerr << "Error opening " << traceFileName
// If LLVM dumping after transformations is requested, add it to the pipeline
if (DumpAsm)
- Passes.add(new PrintMethodPass("Code after xformations: \n", &cerr));
+ Passes.add(new PrintFunctionPass("Code after xformations: \n", &cerr));
// Figure out where we are going to send the output...
std::ostream *Out = 0;
return 1;
}
Out = new std::ofstream(OutputFilename.c_str());
+
+ // Make sure that the Out file gets unlink'd from the disk if we get a
+ // SIGINT
+ RemoveFileOnSignal(OutputFilename);
} else {
if (InputFilename == "-") {
OutputFilename = "-";
delete Out;
return 1;
}
+ // Make sure that the Out file gets unlink'd from the disk if we get a
+ // SIGINT
+ RemoveFileOnSignal(OutputFilename);
}
}