1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
llvm-mirror/test/Transforms/InstCombine/builtin-object-size-ptr.ll
Sanjay Patel ac7f76f5ae Revert "[InstCombine] avoid crash from deleting an instruction that still has uses (PR43723) (3rd try)"
This reverts commit 3db8a3ef86e7b3331ab466a78c10a62be9e69829.
This caused a different memory-sanitizer failure than earlier attempts,
but it's still not right.
2019-11-11 09:56:03 -05:00

34 lines
1.1 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -instcombine -S < %s | FileCheck %s
; int foo() {
; struct V { char buf1[10];
; int b;
; char buf2[10];
; } var;
;
; char *p = &var.buf1[1];
; return __builtin_object_size (p, 0);
; }
%struct.V = type { [10 x i8], i32, [10 x i8] }
define i32 @foo() #0 {
; CHECK-LABEL: @foo(
; CHECK-NEXT: ret i32 27
;
%var = alloca %struct.V, align 4
%t0 = bitcast %struct.V* %var to i8*
call void @llvm.lifetime.start.p0i8(i64 28, i8* %t0) #3
%buf1 = getelementptr inbounds %struct.V, %struct.V* %var, i32 0, i32 0
%arrayidx = getelementptr inbounds [10 x i8], [10 x i8]* %buf1, i64 0, i64 1
%t1 = call i64 @llvm.objectsize.i64.p0i8(i8* %arrayidx, i1 false)
%conv = trunc i64 %t1 to i32
call void @llvm.lifetime.end.p0i8(i64 28, i8* %t0) #3
ret i32 %conv
}
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
declare i64 @llvm.objectsize.i64.p0i8(i8*, i1) #2
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1