2010-11-12 02:02:39 +00:00
|
|
|
; RUN: opt < %s -basicaa -dse -S | FileCheck %s
|
2004-07-25 07:57:50 +00:00
|
|
|
|
2010-11-12 02:02:39 +00:00
|
|
|
target datalayout = "e-p:64:64:64"
|
|
|
|
|
2011-11-05 10:48:42 +00:00
|
|
|
declare void @free(i8* nocapture)
|
|
|
|
declare noalias i8* @malloc(i64)
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test(
|
2010-11-12 02:02:39 +00:00
|
|
|
; CHECK-NEXT: bitcast
|
|
|
|
; CHECK-NEXT: @free
|
|
|
|
; CHECK-NEXT: ret void
|
2008-03-01 09:15:35 +00:00
|
|
|
define void @test(i32* %Q, i32* %P) {
|
|
|
|
%DEAD = load i32* %Q ; <i32> [#uses=1]
|
|
|
|
store i32 %DEAD, i32* %P
|
2011-06-17 03:14:27 +00:00
|
|
|
%1 = bitcast i32* %P to i8*
|
|
|
|
tail call void @free(i8* %1)
|
2008-03-01 09:15:35 +00:00
|
|
|
ret void
|
2004-07-25 07:57:50 +00:00
|
|
|
}
|
2008-12-06 00:53:22 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test2(
|
2010-11-12 02:02:39 +00:00
|
|
|
; CHECK-NEXT: bitcast
|
|
|
|
; CHECK-NEXT: @free
|
|
|
|
; CHECK-NEXT: ret void
|
2008-12-06 00:53:22 +00:00
|
|
|
define void @test2({i32, i32}* %P) {
|
|
|
|
%Q = getelementptr {i32, i32} *%P, i32 0, i32 1
|
|
|
|
store i32 4, i32* %Q
|
2011-06-17 03:14:27 +00:00
|
|
|
%1 = bitcast {i32, i32}* %P to i8*
|
|
|
|
tail call void @free(i8* %1)
|
2008-12-06 00:53:22 +00:00
|
|
|
ret void
|
|
|
|
}
|
2010-11-12 02:02:39 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test3(
|
2010-11-12 02:19:17 +00:00
|
|
|
; CHECK-NOT: store
|
|
|
|
; CHECK: ret void
|
2011-11-05 10:48:42 +00:00
|
|
|
define void @test3() {
|
2010-11-12 02:19:17 +00:00
|
|
|
%m = call i8* @malloc(i64 24)
|
|
|
|
store i8 0, i8* %m
|
|
|
|
%m1 = getelementptr i8* %m, i64 1
|
|
|
|
store i8 1, i8* %m1
|
|
|
|
call void @free(i8* %m)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2011-11-05 10:48:42 +00:00
|
|
|
; PR11240
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test4(
|
2011-11-05 10:48:42 +00:00
|
|
|
; CHECK-NOT: store
|
|
|
|
; CHECK: ret void
|
|
|
|
define void @test4(i1 %x) nounwind {
|
|
|
|
entry:
|
|
|
|
%alloc1 = tail call noalias i8* @malloc(i64 4) nounwind
|
|
|
|
br i1 %x, label %skipinit1, label %init1
|
|
|
|
|
|
|
|
init1:
|
|
|
|
store i8 1, i8* %alloc1
|
|
|
|
br label %skipinit1
|
|
|
|
|
|
|
|
skipinit1:
|
|
|
|
tail call void @free(i8* %alloc1) nounwind
|
|
|
|
ret void
|
|
|
|
}
|
2011-12-08 22:36:35 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test5(
|
2011-12-08 22:36:35 +00:00
|
|
|
define void @test5() {
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
tail call void @free(i8* undef) nounwind
|
|
|
|
br label %bb
|
|
|
|
}
|
|
|
|
|