Non-functionality change just to make it more clear what is going on
[oota-llvm.git] / lib / Transforms / IPO / MutateStructTypes.cpp
index 2059f9f2a90fd32d365cf16adfd3b378ef150bf1..7f62f2b50e1947c086100d4d6649003bbafe7d3e 100644 (file)
 #include "llvm/Transforms/IPO/MutateStructTypes.h"
 #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 "llvm/Constants.h"
 #include "Support/STLExtras.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 #include <algorithm>
-#include <iostream>
+
 using std::map;
 using std::vector;
 
@@ -399,12 +395,14 @@ void MutateStructTypes::transformFunction(Function *m) {
         // Memory Instructions
       case Instruction::Alloca:
         NewI = 
-          new AllocaInst(ConvertType(I.getType()),
+          new MallocInst(
+                  ConvertType(cast<PointerType>(I.getType())->getElementType()),
                          I.getNumOperands() ? ConvertValue(I.getOperand(0)) :0);
         break;
       case Instruction::Malloc:
         NewI = 
-          new MallocInst(ConvertType(I.getType()),
+          new MallocInst(
+                  ConvertType(cast<PointerType>(I.getType())->getElementType()),
                          I.getNumOperands() ? ConvertValue(I.getOperand(0)) :0);
         break;
 
@@ -413,15 +411,9 @@ void MutateStructTypes::transformFunction(Function *m) {
         break;
 
       case Instruction::Load:
-        assert(cast<MemAccessInst>(I).idx_begin() ==
-               cast<MemAccessInst>(I).idx_end() &&
-               "Indexing loads not supported!");
         NewI = new LoadInst(ConvertValue(I.getOperand(0)));
         break;
       case Instruction::Store:
-        assert(cast<MemAccessInst>(I).idx_begin() ==
-               cast<MemAccessInst>(I).idx_end() &&
-               "Indexing loads not supported!");
         NewI = new StoreInst(ConvertValue(I.getOperand(0)),
                              ConvertValue(I.getOperand(1)));
         break;