Change the MallocInst & AllocaInst ctors to take the allocated type, not the
authorChris Lattner <sabre@nondot.org>
Fri, 13 Sep 2002 22:28:45 +0000 (22:28 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 13 Sep 2002 22:28:45 +0000 (22:28 +0000)
pointer type returned.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3710 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/llvmAsmParser.y
lib/Transforms/ExprTypeConvert.cpp
lib/Transforms/IPO/RaiseAllocations.cpp

index 34929c0bbfb9c44e787835b88a1f500b3152e646..de5f469d11f375a4bf728aff365c6b8cc01ccc96 100644 (file)
@@ -1630,22 +1630,19 @@ IndexList : ',' ValueRefList {
 };
 
 MemoryInst : MALLOC Types {
-    $$ = new MallocInst(PointerType::get(*$2));
+    $$ = new MallocInst(*$2);
     delete $2;
   }
   | MALLOC Types ',' UINT ValueRef {
-    const Type *Ty = PointerType::get(*$2);
-    $$ = new MallocInst(Ty, getVal($4, $5));
+    $$ = new MallocInst(*$2, getVal($4, $5));
     delete $2;
   }
   | ALLOCA Types {
-    $$ = new AllocaInst(PointerType::get(*$2));
+    $$ = new AllocaInst(*$2);
     delete $2;
   }
   | ALLOCA Types ',' UINT ValueRef {
-    const Type *Ty = PointerType::get(*$2);
-    Value *ArrSize = getVal($4, $5);
-    $$ = new AllocaInst(Ty, ArrSize);
+    $$ = new AllocaInst(*$2, getVal($4, $5));
     delete $2;
   }
   | FREE ResolvedVal {
index 4abbbeb167c29eca4ff1ff32d40eee1b29547da6..ab4edf33668d73d00da82ef56705655fbd47093d 100644 (file)
@@ -125,7 +125,7 @@ static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty,
   }
 
   assert(AllocTy == Ty);
-  return new MallocInst(AllocTy, Expr.Var, Name);
+  return new MallocInst(AllocTy->getElementType(), Expr.Var, Name);
 }
 
 
index 241e1f55eeda1e8a580777765a55afcce9a3bfc4..bf8300755712a6bc64d9e6c0e00b80c5a513ad42 100644 (file)
@@ -113,7 +113,6 @@ bool RaiseAllocations::runOnBasicBlock(BasicBlock &BB) {
 
     if (CallInst *CI = dyn_cast<CallInst>(I)) {
       if (CI->getCalledValue() == MallocFunc) {      // Replace call to malloc?
-        const Type *PtrSByte = PointerType::get(Type::SByteTy);
         Value *Source = CI->getOperand(1);
         
         // If no prototype was provided for malloc, we may need to cast the
@@ -122,7 +121,7 @@ bool RaiseAllocations::runOnBasicBlock(BasicBlock &BB) {
           Source = new CastInst(Source, Type::UIntTy, "MallocAmtCast", BI);
 
         std::string Name(CI->getName()); CI->setName("");
-        BI = new MallocInst(PtrSByte, Source, Name, BI);
+        BI = new MallocInst(Type::SByteTy, Source, Name, BI);
         CI->replaceAllUsesWith(BI);
         BIL.erase(I);
         Changed = true;