mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-26 22:45:05 +00:00
hopefully fix the buildbots: some tests have wrong definitions of malloc and were crashing this code on 64 bits machines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158923 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7f5847270a
commit
034dd6c6a1
@ -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);
|
||||
|
||||
|
13
test/Transforms/InstCombine/objsize-64.ll
Normal file
13
test/Transforms/InstCombine/objsize-64.ll
Normal 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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user