Remove attribution from file headers, per discussion on llvmdev.
[oota-llvm.git] / lib / Transforms / Utils / LowerAllocations.cpp
index 0ecc775c354bb2ba1427724b7b3127bcc7bf973f..a43ec4b3573a730d222a2cdf837145ed62f676fe 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -36,8 +36,8 @@ namespace {
     Constant *FreeFunc;     // Initialized by doInitialization
     bool LowerMallocArgToInteger;
   public:
-    static const int ID; // Pass ID, replacement for typeid
-    LowerAllocations(bool LowerToInt = false)
+    static char ID; // Pass ID, replacement for typeid
+    explicit LowerAllocations(bool LowerToInt = false)
       : BasicBlockPass((intptr_t)&ID), MallocFunc(0), FreeFunc(0), 
         LowerMallocArgToInteger(LowerToInt) {}
 
@@ -68,7 +68,7 @@ namespace {
     bool runOnBasicBlock(BasicBlock &BB);
   };
 
-  const int LowerAllocations::ID = 0;
+  char LowerAllocations::ID = 0;
   RegisterPass<LowerAllocations>
   X("lowerallocs", "Lower allocations from instructions to calls");
 }
@@ -87,7 +87,7 @@ Pass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) {
 // This function is always successful.
 //
 bool LowerAllocations::doInitialization(Module &M) {
-  const Type *BPTy = PointerType::get(Type::Int8Ty);
+  const Type *BPTy = PointerType::getUnqual(Type::Int8Ty);
   // Prototype malloc as "char* malloc(...)", because we don't know in
   // doInitialization whether size_t is int or long.
   FunctionType *FT = FunctionType::get(BPTy, std::vector<const Type*>(), true);
@@ -116,7 +116,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
       // malloc(type) becomes sbyte *malloc(size)
       Value *MallocArg;
       if (LowerMallocArgToInteger)
-        MallocArg = ConstantInt::get(Type::Int64Ty, TD.getTypeSize(AllocTy));
+        MallocArg = ConstantInt::get(Type::Int64Ty, TD.getABITypeSize(AllocTy));
       else
         MallocArg = ConstantExpr::getSizeOf(AllocTy);
       MallocArg = ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg), 
@@ -158,8 +158,9 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
       Changed = true;
       ++NumLowered;
     } else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
-      Value *PtrCast = new BitCastInst(FI->getOperand(0),
-                                       PointerType::get(Type::Int8Ty), "", I);
+      Value *PtrCast = 
+        new BitCastInst(FI->getOperand(0),
+                        PointerType::getUnqual(Type::Int8Ty), "", I);
 
       // Insert a call to the free function...
       (new CallInst(FreeFunc, PtrCast, "", I))->setTailCall();