Make sure we or together the overflow flags of the multiply and add, so the

check is triggered appropriately.  Reported on cfe-dev.

llvm-svn: 129231
This commit is contained in:
Eli Friedman 2011-04-09 19:54:33 +00:00
parent 96d2507e79
commit db42a3e876
2 changed files with 3 additions and 2 deletions

View File

@ -595,7 +595,7 @@ static llvm::Value *EmitCXXNewAllocSize(ASTContext &Context,
Size = CGF.Builder.CreateExtractValue(AddRes, 0);
llvm::Value *AddDidOverflow = CGF.Builder.CreateExtractValue(AddRes, 1);
DidOverflow = CGF.Builder.CreateAnd(DidOverflow, AddDidOverflow);
DidOverflow = CGF.Builder.CreateOr(DidOverflow, AddDidOverflow);
}
Size = CGF.Builder.CreateSelect(DidOverflow,

View File

@ -117,7 +117,8 @@ namespace test3 {
// CHECK: [[N:%.*]] = load i32*
// CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)
// CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
// CHECK: [[SZ:%.*]] = select
// CHECK: [[OR:%.*]] = or i1
// CHECK: [[SZ:%.*]] = select i1 [[OR]]
// CHECK: call noalias i8* @_Znam(i32 [[SZ]])
// CHECK: store i32 4
// CHECK: store i32 [[N]]