1; RUN: opt -instcombine -S < %s | FileCheck %s 2 3; int foo() { 4; struct V { char buf1[10]; 5; int b; 6; char buf2[10]; 7; } var; 8; 9; char *p = &var.buf1[1]; 10; return __builtin_object_size (p, 0); 11; } 12 13%struct.V = type { [10 x i8], i32, [10 x i8] } 14 15define i32 @foo() #0 { 16entry: 17 %var = alloca %struct.V, align 4 18 %0 = bitcast %struct.V* %var to i8* 19 call void @llvm.lifetime.start(i64 28, i8* %0) #3 20 %buf1 = getelementptr inbounds %struct.V, %struct.V* %var, i32 0, i32 0 21 %arrayidx = getelementptr inbounds [10 x i8], [10 x i8]* %buf1, i64 0, i64 1 22 %1 = call i64 @llvm.objectsize.i64.p0i8(i8* %arrayidx, i1 false) 23 %conv = trunc i64 %1 to i32 24 call void @llvm.lifetime.end(i64 28, i8* %0) #3 25 ret i32 %conv 26; CHECK: ret i32 27 27; CHECK-NOT: ret i32 -1 28} 29 30declare void @llvm.lifetime.start(i64, i8* nocapture) #1 31 32declare i64 @llvm.objectsize.i64.p0i8(i8*, i1) #2 33 34declare void @llvm.lifetime.end(i64, i8* nocapture) #1 35