aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-07-18 00:18:01 +0000
committerChris Lattner <sabre@nondot.org>2002-07-18 00:18:01 +0000
commit0b5909e6ae3d31c3e6c1379f61d7b038f225a620 (patch)
tree8ff69e0c6030e19cdb407728320a28cccf87ff80 /lib/Transforms
parentd6c68c417b13e66f3205551708022ef08e43ecf6 (diff)
downloadexternal_llvm-0b5909e6ae3d31c3e6c1379f61d7b038f225a620.zip
external_llvm-0b5909e6ae3d31c3e6c1379f61d7b038f225a620.tar.gz
external_llvm-0b5909e6ae3d31c3e6c1379f61d7b038f225a620.tar.bz2
* Correctly get prototype for void*malloc(size_t)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2951 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 42e1a28..9ab3d5f 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -61,18 +61,27 @@ bool RaiseAllocations::doInitialization(Module &M) {
//
const FunctionType *MallocType = // Get the type for malloc
FunctionType::get(PointerType::get(Type::SByteTy),
- std::vector<const Type*>(1, Type::UIntTy), false);
+ std::vector<const Type*>(1, Type::ULongTy), false);
const FunctionType *FreeType = // Get the type for free
FunctionType::get(Type::VoidTy,
std::vector<const Type*>(1, PointerType::get(Type::SByteTy)),
false);
+ // Get Malloc and free prototypes if they exist!
MallocFunc = M.getFunction("malloc", MallocType);
FreeFunc = M.getFunction("free" , FreeType);
+ // Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
+ // This handles the common declaration of: 'void *malloc(unsigned);'
+ if (MallocFunc == 0) {
+ MallocType = FunctionType::get(PointerType::get(Type::SByteTy),
+ std::vector<const Type*>(1, Type::UIntTy), false);
+ MallocFunc = M.getFunction("malloc", MallocType);
+ }
+
// Check to see if the prototype is missing, giving us sbyte*(...) * malloc
- // This handles the common declaration of: 'char *malloc();'
+ // This handles the common declaration of: 'void *malloc();'
if (MallocFunc == 0) {
MallocType = FunctionType::get(PointerType::get(Type::SByteTy),
std::vector<const Type*>(), true);