hopefully fix the buildbots: some tests have wrong definitions of malloc and were crashing this code on 64 bits machines

llvm-svn: 158923
This commit is contained in:
Nuno Lopes 2012-06-21 16:47:58 +00:00
parent 245f4ae59a
commit a6aa3d3b5f
2 changed files with 18 additions and 3 deletions

View File

@ -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);

View File

@ -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
}