#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Function.h"
+#include "llvm/BasicBlock.h"
#include "llvm/GlobalVariable.h"
#include "llvm/SymbolTable.h"
#include "llvm/iPHINode.h"
#include "llvm/iMemory.h"
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
+#include "llvm/Argument.h"
#include "Support/STLExtras.h"
#include <algorithm>
using std::map;
// To enable debugging, uncomment this...
//#define DEBUG_MST(x) x
-#ifdef DEBUG_MST
-#include "llvm/Assembly/Writer.h"
-#else
+#ifndef DEBUG_MST
#define DEBUG_MST(x) // Disable debug code
#endif
if (Ty->isPrimitiveType() ||
isa<OpaqueType>(Ty)) return Ty; // Don't convert primitives
- map<const Type *, PATypeHolder<Type> >::iterator I = TypeMap.find(Ty);
+ map<const Type *, PATypeHolder>::iterator I = TypeMap.find(Ty);
if (I != TypeMap.end()) return I->second;
const Type *DestTy = 0;
- PATypeHolder<Type> PlaceHolder = OpaqueType::get();
+ PATypeHolder PlaceHolder = OpaqueType::get();
TypeMap.insert(std::make_pair(Ty, PlaceHolder.get()));
switch (Ty->getPrimitiveID()) {
}
// Create a new type that corresponds to the destination type
- PATypeHolder<StructType> NSTy = StructType::get(NewType);
+ PATypeHolder NSTy = StructType::get(NewType);
// Refine the old opaque type to the new type to properly handle recursive
// types...
cast<DerivedType>(OldTypeStub)->refineAbstractTypeTo(NSTy);
// Add the transformation to the Transforms map.
- Transforms.insert(std::make_pair(OldTy, std::make_pair(NSTy, InVec)));
+ Transforms.insert(std::make_pair(OldTy,
+ std::make_pair(cast<StructType>(NSTy.get()), InVec)));
DEBUG_MST(cerr << "Mutate " << OldTy << "\nTo " << NSTy << endl);
}
Function *NewMeth = cast<Function>(GMI->second);
// Okay, first order of business, create the arguments...
- for (unsigned i = 0; i < M->getArgumentList().size(); ++i) {
- const FunctionArgument *OMA = M->getArgumentList()[i];
- FunctionArgument *NMA = new FunctionArgument(ConvertType(OMA->getType()),
- OMA->getName());
- NewMeth->getArgumentList().push_back(NMA);
- LocalValueMap[OMA] = NMA; // Keep track of value mapping
+ for (unsigned i = 0, e = M->getArgumentList().size(); i != e; ++i) {
+ const Argument *OFA = M->getArgumentList()[i];
+ Argument *NFA = new Argument(ConvertType(OFA->getType()), OFA->getName());
+ NewMeth->getArgumentList().push_back(NFA);
+ LocalValueMap[OFA] = NFA; // Keep track of value mapping
}