#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"
// 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
#include "llvm/Transforms/Scalar/IndVarSimplify.h"
#include "llvm/Transforms/Scalar/InstructionCombining.h"
#include "llvm/Transforms/Scalar/PromoteMemoryToRegister.h"
+#include "llvm/Transforms/Scalar/DecomposeMultiDimRefs.h"
#include "llvm/Transforms/Instrumentation/TraceValues.h"
#include "llvm/Transforms/Instrumentation/ProfilePaths.h"
#include "Support/CommandLine.h"
dce, die, constprop, inlining, constmerge, strip, mstrip, mergereturn,
// Miscellaneous Transformations
- raiseallocs, cleangcc,
+ raiseallocs, cleangcc, lowerrefs,
// Printing and verifying...
print, verify,
{ globaldce , createGlobalDCEPass },
{ swapstructs, createSwapElementsPass },
{ sortstructs, createSortElementsPass },
+ { lowerrefs, createDecomposeMultiDimRefsPass }
};
// Command line option handling code...
clEnumVal(paths , "Insert path profiling instrumentation"),
clEnumVal(print , "Print working method to stderr"),
clEnumVal(verify , "Verify module is well formed"),
+ clEnumVal(lowerrefs , "Decompose multi-dimensional structure/array refs to use one index per instruction"),
0);