summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-06-21 16:47:58 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-06-21 16:47:58 +0000
commita6aa3d3b5f6ccfef68d68e586ffdb76ad64f53e7 (patch)
tree89c245adc0c9d3006606f3582bac8de9dd5ef743
parent245f4ae59a3ea65d8bd022b989a8d62bbeab6f6d (diff)
downloadbcm5719-llvm-a6aa3d3b5f6ccfef68d68e586ffdb76ad64f53e7.tar.gz
bcm5719-llvm-a6aa3d3b5f6ccfef68d68e586ffdb76ad64f53e7.zip
hopefully fix the buildbots: some tests have wrong definitions of malloc and were crashing this code on 64 bits machines
llvm-svn: 158923
-rw-r--r--llvm/lib/Analysis/MemoryBuiltins.cpp8
-rw-r--r--llvm/test/Transforms/InstCombine/objsize-64.ll13
2 files changed, 18 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 2a1afdce329..436cffd6e8e 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -419,7 +419,7 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitCallSite(CallSite CS) {
if (!Arg)
return unknown();
- APInt Size = Arg->getValue();
+ APInt Size = Arg->getValue().zextOrSelf(IntTyBits);
// size determined by just 1 parameter
if (FnData->SndParam == (unsigned char)-1)
return std::make_pair(Size, Zero);
@@ -428,7 +428,7 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitCallSite(CallSite CS) {
if (!Arg)
return unknown();
- Size *= Arg->getValue();
+ Size *= Arg->getValue().zextOrSelf(IntTyBits);
return std::make_pair(Size, Zero);
// TODO: handle more standard functions (+ wchar cousins):
@@ -602,11 +602,13 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitCallSite(CallSite CS) {
return unknown();
}
- Value *FirstArg = CS.getArgument(FnData->FstParam);
+ Value *FirstArg = CS.getArgument(FnData->FstParam);
+ FirstArg = Builder.CreateZExt(FirstArg, IntTy);
if (FnData->SndParam == (unsigned char)-1)
return std::make_pair(FirstArg, Zero);
Value *SecondArg = CS.getArgument(FnData->SndParam);
+ SecondArg = Builder.CreateZExt(SecondArg, IntTy);
Value *Size = Builder.CreateMul(FirstArg, SecondArg);
return std::make_pair(Size, Zero);
diff --git a/llvm/test/Transforms/InstCombine/objsize-64.ll b/llvm/test/Transforms/InstCombine/objsize-64.ll
new file mode 100644
index 00000000000..d903f1e88f1
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/objsize-64.ll
@@ -0,0 +1,13 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+
+declare noalias i8* @malloc(i32) nounwind
+declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readonly
+
+; CHECK: @f1
+define i64 @f1() {
+ %call = call i8* @malloc(i32 4)
+ %size = call i64 @llvm.objectsize.i64(i8* %call, i1 false)
+; CHECK-NEXT: ret i64 4
+ ret i64 %size
+}
OpenPOWER on IntegriCloud