98 changes: 46 additions & 52 deletions llvm/test/Transforms/Inline/cgscc-cycle.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,115 +10,109 @@

; The `test1_*` collection of functions form a directly cycling pattern.

define void @test1_a(i8** %ptr) {
define void @test1_a(ptr %ptr) {
; CHECK-LABEL: define void @test1_a(
entry:
call void @test1_b(i8* bitcast (void (i8*, i1, i32)* @test1_b to i8*), i1 false, i32 0)
call void @test1_b(ptr @test1_b, i1 false, i32 0)
; Inlining and simplifying this call will reliably produce the exact same call,
; over and over again. However, each inlining increments the count, and so we
; expect this test case to stop after one round of inlining with a final
; argument of '1'.
; CHECK-NOT: call
; CHECK: call void @test1_b(i8* nonnull bitcast (void (i8*, i1, i32)* @test1_b to i8*), i1 false, i32 1)
; CHECK: call void @test1_b(ptr nonnull @test1_b, i1 false, i32 1)
; CHECK-NOT: call

ret void
}

define void @test1_b(i8* %arg, i1 %flag, i32 %inline_count) {
define void @test1_b(ptr %arg, i1 %flag, i32 %inline_count) {
; CHECK-LABEL: define void @test1_b(
entry:
%a = alloca i8*
store i8* %arg, i8** %a
%a = alloca ptr
store ptr %arg, ptr %a
; This alloca and store should remain through any optimization.
; CHECK: %[[A:.*]] = alloca
; CHECK: store i8* %arg, i8** %[[A]]
; CHECK: store ptr %arg, ptr %[[A]]

br i1 %flag, label %bb1, label %bb2

bb1:
call void @test1_a(i8** %a) noinline
call void @test1_a(ptr %a) noinline
br label %bb2

bb2:
%cast = bitcast i8** %a to void (i8*, i1, i32)**
%p = load void (i8*, i1, i32)*, void (i8*, i1, i32)** %cast
%p = load ptr, ptr %a
%inline_count_inc = add i32 %inline_count, 1
call void %p(i8* %arg, i1 %flag, i32 %inline_count_inc)
call void %p(ptr %arg, i1 %flag, i32 %inline_count_inc)
; And we should continue to load and call indirectly through optimization.
; CHECK: %[[CAST:.*]] = bitcast i8** %[[A]] to void (i8*, i1, i32)**
; CHECK: %[[P:.*]] = load void (i8*, i1, i32)*, void (i8*, i1, i32)** %[[CAST]]
; CHECK: %[[P:.*]] = load ptr, ptr %[[A]]
; CHECK: call void %[[P]](

ret void
}

define void @test2_a(i8** %ptr) {
define void @test2_a(ptr %ptr) {
; CHECK-LABEL: define void @test2_a(
entry:
call void @test2_b(i8* bitcast (void (i8*, i8*, i1, i32)* @test2_b to i8*), i8* bitcast (void (i8*, i8*, i1, i32)* @test2_c to i8*), i1 false, i32 0)
call void @test2_b(ptr @test2_b, ptr @test2_c, i1 false, i32 0)
; Inlining and simplifying this call will reliably produce the exact same call,
; but only after doing two rounds if inlining, first from @test2_b then
; @test2_c. We check the exact number of inlining rounds before we cut off to
; break the cycle by inspecting the last paramater that gets incremented with
; each inlined function body.
; CHECK-NOT: call
; CHECK: call void @test2_b(i8* nonnull bitcast (void (i8*, i8*, i1, i32)* @test2_b to i8*), i8* nonnull bitcast (void (i8*, i8*, i1, i32)* @test2_c to i8*), i1 false, i32 2)
; CHECK: call void @test2_b(ptr nonnull @test2_b, ptr nonnull @test2_c, i1 false, i32 2)
; CHECK-NOT: call
ret void
}

define void @test2_b(i8* %arg1, i8* %arg2, i1 %flag, i32 %inline_count) {
define void @test2_b(ptr %arg1, ptr %arg2, i1 %flag, i32 %inline_count) {
; CHECK-LABEL: define void @test2_b(
entry:
%a = alloca i8*
store i8* %arg2, i8** %a
%a = alloca ptr
store ptr %arg2, ptr %a
; This alloca and store should remain through any optimization.
; CHECK: %[[A:.*]] = alloca
; CHECK: store i8* %arg2, i8** %[[A]]
; CHECK: store ptr %arg2, ptr %[[A]]

br i1 %flag, label %bb1, label %bb2

bb1:
call void @test2_a(i8** %a) noinline
call void @test2_a(ptr %a) noinline
br label %bb2

bb2:
%p = load i8*, i8** %a
%cast = bitcast i8* %p to void (i8*, i8*, i1, i32)*
%p = load ptr, ptr %a
%inline_count_inc = add i32 %inline_count, 1
call void %cast(i8* %arg1, i8* %arg2, i1 %flag, i32 %inline_count_inc)
call void %p(ptr %arg1, ptr %arg2, i1 %flag, i32 %inline_count_inc)
; And we should continue to load and call indirectly through optimization.
; CHECK: %[[CAST:.*]] = bitcast i8** %[[A]] to void (i8*, i8*, i1, i32)**
; CHECK: %[[P:.*]] = load void (i8*, i8*, i1, i32)*, void (i8*, i8*, i1, i32)** %[[CAST]]
; CHECK: %[[P:.*]] = load ptr, ptr %[[A]]
; CHECK: call void %[[P]](

ret void
}

define void @test2_c(i8* %arg1, i8* %arg2, i1 %flag, i32 %inline_count) {
define void @test2_c(ptr %arg1, ptr %arg2, i1 %flag, i32 %inline_count) {
; CHECK-LABEL: define void @test2_c(
entry:
%a = alloca i8*
store i8* %arg1, i8** %a
%a = alloca ptr
store ptr %arg1, ptr %a
; This alloca and store should remain through any optimization.
; CHECK: %[[A:.*]] = alloca
; CHECK: store i8* %arg1, i8** %[[A]]
; CHECK: store ptr %arg1, ptr %[[A]]

br i1 %flag, label %bb1, label %bb2

bb1:
call void @test2_a(i8** %a) noinline
call void @test2_a(ptr %a) noinline
br label %bb2

bb2:
%p = load i8*, i8** %a
%cast = bitcast i8* %p to void (i8*, i8*, i1, i32)*
%p = load ptr, ptr %a
%inline_count_inc = add i32 %inline_count, 1
call void %cast(i8* %arg1, i8* %arg2, i1 %flag, i32 %inline_count_inc)
call void %p(ptr %arg1, ptr %arg2, i1 %flag, i32 %inline_count_inc)
; And we should continue to load and call indirectly through optimization.
; CHECK: %[[CAST:.*]] = bitcast i8** %[[A]] to void (i8*, i8*, i1, i32)**
; CHECK: %[[P:.*]] = load void (i8*, i8*, i1, i32)*, void (i8*, i8*, i1, i32)** %[[CAST]]
; CHECK: %[[P:.*]] = load ptr, ptr %[[A]]
; CHECK: call void %[[P]](

ret void
Expand Down Expand Up @@ -157,32 +151,32 @@ bb2:
; CHECK-LABEL: @test3_a(
; CHECK: tail call void @test3_b()
; CHECK-NEXT: tail call void @test3_d(i32 5)
; CHECK-NEXT: %[[LD1:.*]] = load i64, i64* @a
; CHECK-NEXT: %[[LD1:.*]] = load i64, ptr @a
; CHECK-NEXT: %[[ADD1:.*]] = add nsw i64 %[[LD1]], 1
; CHECK-NEXT: store i64 %[[ADD1]], i64* @a
; CHECK-NEXT: %[[LD2:.*]] = load i64, i64* @b
; CHECK-NEXT: store i64 %[[ADD1]], ptr @a
; CHECK-NEXT: %[[LD2:.*]] = load i64, ptr @b
; CHECK-NEXT: %[[ADD2:.*]] = add nsw i64 %[[LD2]], 5
; CHECK-NEXT: store i64 %[[ADD2]], i64* @b
; CHECK-NEXT: store i64 %[[ADD2]], ptr @b
; CHECK-NEXT: ret void

; Function Attrs: noinline
define void @test3_a() #0 {
entry:
tail call void @test3_b()
tail call void @test3_c(i32 5)
%t0 = load i64, i64* @b
%t0 = load i64, ptr @b
%add = add nsw i64 %t0, 5
store i64 %add, i64* @b
store i64 %add, ptr @b
ret void
}

; Function Attrs: noinline
define void @test3_b() #0 {
entry:
tail call void @test3_a()
%t0 = load i64, i64* @a
%t0 = load i64, ptr @a
%add = add nsw i64 %t0, 2
store i64 %add, i64* @a
store i64 %add, ptr @a
ret void
}

Expand All @@ -193,17 +187,17 @@ entry:

if.then: ; preds = %entry
%call = tail call i64 @random()
%t0 = load i64, i64* @a
%t0 = load i64, ptr @a
%add = add nsw i64 %t0, %call
store i64 %add, i64* @a
store i64 %add, ptr @a
br label %if.end

if.end: ; preds = %entry, %if.then
tail call void @test3_c(i32 %i)
tail call void @test3_b()
%t6 = load i64, i64* @a
%t6 = load i64, ptr @a
%add79 = add nsw i64 %t6, 3
store i64 %add79, i64* @a
store i64 %add79, ptr @a
ret void
}

Expand All @@ -214,16 +208,16 @@ entry:

if.then: ; preds = %entry
%call = tail call i64 @random()
%t0 = load i64, i64* @a
%t0 = load i64, ptr @a
%add = add nsw i64 %t0, %call
store i64 %add, i64* @a
store i64 %add, ptr @a
br label %if.end

if.end: ; preds = %entry, %if.then
tail call void @test3_d(i32 %i)
%t6 = load i64, i64* @a
%t6 = load i64, ptr @a
%add85 = add nsw i64 %t6, 1
store i64 %add85, i64* @a
store i64 %add85, ptr @a
ret void
}

Expand Down
38 changes: 19 additions & 19 deletions llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ entry:
br i1 %flag, label %then, label %else

then:
store volatile i8 42, i8* %ptr
store volatile i8 42, ptr %ptr
br label %return

else:
store volatile i8 -42, i8* %ptr
store volatile i8 -42, ptr %ptr
br label %return

return:
Expand Down Expand Up @@ -125,56 +125,56 @@ entry:

@test2_global = external global i32, align 4

define void @test2_hoge(i1 (i32*)* %arg) {
define void @test2_hoge(ptr %arg) {
; CHECK-LABEL: define void @test2_hoge(
bb:
%tmp2 = call zeroext i1 %arg(i32* @test2_global)
%tmp2 = call zeroext i1 %arg(ptr @test2_global)
; CHECK: call zeroext i1 %arg(
br label %bb3

bb3:
%tmp5 = call zeroext i1 %arg(i32* @test2_global)
%tmp5 = call zeroext i1 %arg(ptr @test2_global)
; CHECK: call zeroext i1 %arg(
br i1 %tmp5, label %bb3, label %bb6

bb6:
ret void
}

define zeroext i1 @test2_widget(i32* %arg) {
define zeroext i1 @test2_widget(ptr %arg) {
; CHECK-LABEL: define zeroext i1 @test2_widget(
bb:
%tmp1 = alloca i8, align 1
%tmp2 = alloca i32, align 4
call void @test2_quux()
; CHECK-NOT: call
;
; CHECK: call zeroext i1 @test2_widget(i32* @test2_global)
; CHECK: call zeroext i1 @test2_widget(ptr @test2_global)
; CHECK-NEXT: br label %[[NEW_BB:.*]]
;
; CHECK: [[NEW_BB]]:
; CHECK-NEXT: call zeroext i1 @test2_widget(i32* @test2_global)
; CHECK-NEXT: call zeroext i1 @test2_widget(ptr @test2_global)
;
; CHECK: {{.*}}:

call void @test2_hoge.1(i32* %arg)
call void @test2_hoge.1(ptr %arg)
; CHECK-NEXT: call void @test2_hoge.1(

%tmp4 = call zeroext i1 @test2_barney(i32* %tmp2)
%tmp4 = call zeroext i1 @test2_barney(ptr %tmp2)
%tmp5 = zext i1 %tmp4 to i32
store i32 %tmp5, i32* %tmp2, align 4
%tmp6 = call zeroext i1 @test2_barney(i32* null)
call void @test2_ham(i8* %tmp1)
store i32 %tmp5, ptr %tmp2, align 4
%tmp6 = call zeroext i1 @test2_barney(ptr null)
call void @test2_ham(ptr %tmp1)
; CHECK: call void @test2_ham(

call void @test2_quux()
; CHECK-NOT: call
;
; CHECK: call zeroext i1 @test2_widget(i32* @test2_global)
; CHECK: call zeroext i1 @test2_widget(ptr @test2_global)
; CHECK-NEXT: br label %[[NEW_BB:.*]]
;
; CHECK: [[NEW_BB]]:
; CHECK-NEXT: call zeroext i1 @test2_widget(i32* @test2_global)
; CHECK-NEXT: call zeroext i1 @test2_widget(ptr @test2_global)
;
; CHECK: {{.*}}:
ret i1 true
Expand All @@ -184,12 +184,12 @@ bb:
define internal void @test2_quux() {
; CHECK-NOT: @test2_quux
bb:
call void @test2_hoge(i1 (i32*)* @test2_widget)
call void @test2_hoge(ptr @test2_widget)
ret void
}

declare void @test2_hoge.1(i32*)
declare void @test2_hoge.1(ptr)

declare zeroext i1 @test2_barney(i32*)
declare zeroext i1 @test2_barney(ptr)

declare void @test2_ham(i8*)
declare void @test2_ham(ptr)
44 changes: 22 additions & 22 deletions llvm/test/Transforms/Inline/cgscc-inline-replay.ll
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !6 {
entry:
%x.addr = alloca i32, align 4
%y.addr = alloca i32, align 4
store i32 %x, i32* %x.addr, align 4
store i32 %y, i32* %y.addr, align 4
%tmp = load i32, i32* %x.addr, align 4, !dbg !8
%tmp1 = load i32, i32* %y.addr, align 4, !dbg !8
store i32 %x, ptr %x.addr, align 4
store i32 %y, ptr %y.addr, align 4
%tmp = load i32, ptr %x.addr, align 4, !dbg !8
%tmp1 = load i32, ptr %y.addr, align 4, !dbg !8
%add = add nsw i32 %tmp, %tmp1, !dbg !8
%tmp2 = load i32, i32* %x.addr, align 4, !dbg !8
%tmp3 = load i32, i32* %y.addr, align 4, !dbg !8
%tmp2 = load i32, ptr %x.addr, align 4, !dbg !8
%tmp3 = load i32, ptr %y.addr, align 4, !dbg !8
%call = call i32 @_Z3subii(i32 %tmp2, i32 %tmp3), !dbg !8
ret i32 %add, !dbg !8
}
Expand All @@ -85,10 +85,10 @@ define i32 @_Z3subii(i32 %x, i32 %y) #0 !dbg !9 {
entry:
%x.addr = alloca i32, align 4
%y.addr = alloca i32, align 4
store i32 %x, i32* %x.addr, align 4
store i32 %y, i32* %y.addr, align 4
%tmp = load i32, i32* %x.addr, align 4, !dbg !10
%tmp1 = load i32, i32* %y.addr, align 4, !dbg !10
store i32 %x, ptr %x.addr, align 4
store i32 %y, ptr %y.addr, align 4
%tmp = load i32, ptr %x.addr, align 4, !dbg !10
%tmp1 = load i32, ptr %y.addr, align 4, !dbg !10
%add = sub nsw i32 %tmp, %tmp1, !dbg !10
ret i32 %add, !dbg !11
}
Expand All @@ -98,43 +98,43 @@ entry:
%retval = alloca i32, align 4
%s = alloca i32, align 4
%i = alloca i32, align 4
store i32 0, i32* %retval
store i32 0, i32* %i, align 4, !dbg !13
store i32 0, ptr %retval
store i32 0, ptr %i, align 4, !dbg !13
br label %while.cond, !dbg !14

while.cond: ; preds = %if.end, %entry
%tmp = load i32, i32* %i, align 4, !dbg !15
%tmp = load i32, ptr %i, align 4, !dbg !15
%inc = add nsw i32 %tmp, 1, !dbg !15
store i32 %inc, i32* %i, align 4, !dbg !15
store i32 %inc, ptr %i, align 4, !dbg !15
%cmp = icmp slt i32 %tmp, 400000000, !dbg !15
br i1 %cmp, label %while.body, label %while.end, !dbg !15

while.body: ; preds = %while.cond
%tmp1 = load i32, i32* %i, align 4, !dbg !17
%tmp1 = load i32, ptr %i, align 4, !dbg !17
%cmp1 = icmp ne i32 %tmp1, 100, !dbg !17
br i1 %cmp1, label %if.then, label %if.else, !dbg !17

if.then: ; preds = %while.body
%tmp2 = load i32, i32* %i, align 4, !dbg !19
%tmp3 = load i32, i32* %s, align 4, !dbg !19
%tmp2 = load i32, ptr %i, align 4, !dbg !19
%tmp3 = load i32, ptr %s, align 4, !dbg !19
%call = call i32 @_Z3sumii(i32 %tmp2, i32 %tmp3), !dbg !19
store i32 %call, i32* %s, align 4, !dbg !19
store i32 %call, ptr %s, align 4, !dbg !19
br label %if.end, !dbg !19

if.else: ; preds = %while.body
store i32 30, i32* %s, align 4, !dbg !21
store i32 30, ptr %s, align 4, !dbg !21
br label %if.end

if.end: ; preds = %if.else, %if.then
br label %while.cond, !dbg !23

while.end: ; preds = %while.cond
%tmp4 = load i32, i32* %s, align 4, !dbg !25
%call2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 %tmp4), !dbg !25
%tmp4 = load i32, ptr %s, align 4, !dbg !25
%call2 = call i32 (ptr, ...) @printf(ptr @.str, i32 %tmp4), !dbg !25
ret i32 0, !dbg !26
}

declare i32 @printf(i8*, ...)
declare i32 @printf(ptr, ...)

attributes #0 = { "use-sample-profile" }

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/Inline/cgscc-invalidate.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ entry:
br i1 %flag, label %then, label %else

then:
store volatile i8 42, i8* %ptr
store volatile i8 42, ptr %ptr
br label %return

else:
store volatile i8 -42, i8* %ptr
store volatile i8 -42, ptr %ptr
br label %return

return:
Expand Down
14 changes: 7 additions & 7 deletions llvm/test/Transforms/Inline/cgscc-update.ll
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare void @readnone() readnone nounwind

; This function should no longer exist.
; CHECK-NOT: @test1_f()
define internal void @test1_f(void()* %p) {
define internal void @test1_f(ptr %p) {
entry:
call void %p()
ret void
Expand All @@ -31,7 +31,7 @@ entry:
; CHECK-NEXT: define void @test1_g()
define void @test1_g() noinline {
entry:
call void @test1_f(void()* @test1_h)
call void @test1_f(ptr @test1_h)
ret void
}

Expand All @@ -53,17 +53,17 @@ entry:

; This function should no longer exist.
; CHECK-NOT: @test2_f()
define internal void()* @test2_f() {
define internal ptr @test2_f() {
entry:
ret void()* @test2_h
ret ptr @test2_h
}

; This function should have had 'memory(none)' deduced for its SCC.
; CHECK: Function Attrs: nofree noinline nosync nounwind memory(none)
; CHECK-NEXT: define void @test2_g()
define void @test2_g() noinline {
entry:
%p = call void()* @test2_f()
%p = call ptr @test2_f()
call void %p()
ret void
}
Expand Down Expand Up @@ -168,7 +168,7 @@ entry:
}

; CHECK-NOT: @test4_g
define internal void @test4_g(void()* %p) {
define internal void @test4_g(ptr %p) {
entry:
call void %p()
ret void
Expand All @@ -179,6 +179,6 @@ entry:
; CHECK-NEXT: define void @test4_h()
define void @test4_h() noinline {
entry:
call void @test4_g(void()* @test4_f2)
call void @test4_g(ptr @test4_f2)
ret void
}
10 changes: 5 additions & 5 deletions llvm/test/Transforms/Inline/crash-lifetime-marker.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
; there was an zero-sized AllocaInst. Check that it doesn't assert and doesn't
; leave lifetime markers in that case.

declare i32 @callee2(i8*)
declare i32 @callee2(ptr)

define i32 @callee1(i32 %count) {
%a0 = alloca i8, i32 %count, align 4
%call0 = call i32 @callee2(i8* %a0)
%call0 = call i32 @callee2(ptr %a0)
ret i32 %call0
}

; CHECK-LABEL: define i32 @caller1(
; CHECK: [[ALLOCA:%[a-z0-9\.]+]] = alloca i8
; CHECK-NOT: call void @llvm.lifetime.start.p0i8(
; CHECK: call i32 @callee2(i8* [[ALLOCA]])
; CHECK-NOT: call void @llvm.lifetime.end.p0i8(
; CHECK-NOT: call void @llvm.lifetime.start.p0(
; CHECK: call i32 @callee2(ptr [[ALLOCA]])
; CHECK-NOT: call void @llvm.lifetime.end.p0(

define i32 @caller1(i32 %count) {
%call0 = call i32 @callee1(i32 0)
Expand Down
36 changes: 18 additions & 18 deletions llvm/test/Transforms/Inline/crash.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,43 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
target triple = "i386-apple-darwin10.0"


define void @list_DeleteElement(i32 (i8*, i8*)* nocapture %Test) nounwind ssp {
define void @list_DeleteElement(ptr nocapture %Test) nounwind ssp {
entry:
%0 = call i32 %Test(i8* null, i8* undef) nounwind
%0 = call i32 %Test(ptr null, ptr undef) nounwind
ret void
}


define void @list_DeleteDuplicates(i32 (i8*, i8*)* nocapture %Test) nounwind ssp {
define void @list_DeleteDuplicates(ptr nocapture %Test) nounwind ssp {
foo:
call void @list_DeleteElement(i32 (i8*, i8*)* %Test) nounwind ssp
call void @list_DeleteElement(ptr %Test) nounwind ssp
call fastcc void @list_Rplacd1284() nounwind ssp
unreachable

}

define internal i32 @inf_LiteralsHaveSameSubtermAndAreFromSameClause(i32* nocapture %L1, i32* nocapture %L2) nounwind readonly ssp {
define internal i32 @inf_LiteralsHaveSameSubtermAndAreFromSameClause(ptr nocapture %L1, ptr nocapture %L2) nounwind readonly ssp {
entry:
unreachable
}


define internal fastcc void @inf_GetBackwardPartnerLits(i32* nocapture %Flags) nounwind ssp {
define internal fastcc void @inf_GetBackwardPartnerLits(ptr nocapture %Flags) nounwind ssp {
test:
call void @list_DeleteDuplicates(i32 (i8*, i8*)* bitcast (i32 (i32*, i32*)* @inf_LiteralsHaveSameSubtermAndAreFromSameClause to i32 (i8*, i8*)*)) nounwind
call void @list_DeleteDuplicates(ptr @inf_LiteralsHaveSameSubtermAndAreFromSameClause) nounwind
ret void
}


define void @inf_BackwardEmptySortPlusPlus() nounwind ssp {
entry:
call fastcc void @inf_GetBackwardPartnerLits(i32* null) nounwind ssp
call fastcc void @inf_GetBackwardPartnerLits(ptr null) nounwind ssp
unreachable
}

define void @inf_BackwardWeakening() nounwind ssp {
entry:
call fastcc void @inf_GetBackwardPartnerLits(i32* null) nounwind ssp
call fastcc void @inf_GetBackwardPartnerLits(ptr null) nounwind ssp
unreachable
}

Expand All @@ -59,7 +59,7 @@ declare fastcc void @list_Rplacd1284() nounwind ssp
;============================
; PR5208

define void @AAA() personality i32 (...)* @__gxx_personality_v0 {
define void @AAA() personality ptr @__gxx_personality_v0 {
entry:
%A = alloca i8, i32 undef, align 1
invoke fastcc void @XXX()
Expand All @@ -69,7 +69,7 @@ invcont98:
unreachable

lpad156:
%exn = landingpad {i8*, i32}
%exn = landingpad {ptr, i32}
cleanup
unreachable
}
Expand All @@ -78,7 +78,7 @@ declare i32 @__gxx_personality_v0(...)

declare fastcc void @YYY()

define internal fastcc void @XXX() personality i32 (...)* @__gxx_personality_v0 {
define internal fastcc void @XXX() personality ptr @__gxx_personality_v0 {
entry:
%B = alloca i8, i32 undef, align 1
invoke fastcc void @YYY()
Expand All @@ -88,30 +88,30 @@ bb260:
ret void

lpad:
%exn = landingpad {i8*, i32}
%exn = landingpad {ptr, i32}
cleanup
resume { i8*, i32 } %exn
resume { ptr, i32 } %exn
}



;; This exposed a crash handling devirtualized calls.
define void @f1(void ()* %f) ssp {
define void @f1(ptr %f) ssp {
entry:
call void %f()
ret void
}

define void @f4(i32 %size) ssp personality i32 (...)* @__gxx_personality_v0 {
define void @f4(i32 %size) ssp personality ptr @__gxx_personality_v0 {
entry:
invoke void @f1(void ()* @f3)
invoke void @f1(ptr @f3)
to label %invcont3 unwind label %lpad18

invcont3: ; preds = %bb1
ret void

lpad18: ; preds = %invcont3, %bb1
%exn = landingpad {i8*, i32}
%exn = landingpad {ptr, i32}
cleanup
unreachable
}
Expand Down
20 changes: 10 additions & 10 deletions llvm/test/Transforms/Inline/crash2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
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"
target triple = "x86_64-apple-darwin10.3"

declare i8* @f1(i8*) ssp align 2
declare ptr @f1(ptr) ssp align 2

define linkonce_odr void @f2(i8* %t) inlinehint ssp {
define linkonce_odr void @f2(ptr %t) inlinehint ssp {
entry:
unreachable
}

define linkonce_odr void @f3(void (i8*)* %__f) ssp {
define linkonce_odr void @f3(ptr %__f) ssp {
entry:
%__f_addr = alloca void (i8*)*, align 8
store void (i8*)* %__f, void (i8*)** %__f_addr
%__f_addr = alloca ptr, align 8
store ptr %__f, ptr %__f_addr

%0 = load void (i8*)*, void (i8*)** %__f_addr, align 8
call void %0(i8* undef)
call i8* @f1(i8* undef) ssp
%0 = load ptr, ptr %__f_addr, align 8
call void %0(ptr undef)
call ptr @f1(ptr undef) ssp
unreachable
}

define linkonce_odr void @f4(i8* %this) ssp align 2 {
define linkonce_odr void @f4(ptr %this) ssp align 2 {
entry:
%0 = alloca i32
call void @f3(void (i8*)* @f2) ssp
call void @f3(ptr @f2) ssp
ret void
}

4 changes: 2 additions & 2 deletions llvm/test/Transforms/Inline/debug-invoke.ll
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ define void @inl() #0 {
ret void
}

define void @caller() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
define void @caller() personality ptr @__gxx_personality_v0 {
invoke void @inl()
to label %cont unwind label %lpad, !dbg !4

cont:
ret void

lpad:
landingpad { i8*, i32 }
landingpad { ptr, i32 }
cleanup
ret void
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
; CHECK: define {{.*}}@f1
; CHECK-NOT: define

%a = type { i8*, i8* }
%a = type { ptr, ptr }

$f3 = comdat any

define linkonce_odr void @f1() {
call void @f2(void ()* @f3)
call void @f2(ptr @f3)
ret void
}

define linkonce_odr void @f2(void ()* %__f) {
call void @llvm.dbg.value(metadata void ()* %__f, metadata !2, metadata !DIExpression()), !dbg !10
define linkonce_odr void @f2(ptr %__f) {
call void @llvm.dbg.value(metadata ptr %__f, metadata !2, metadata !DIExpression()), !dbg !10
call void %__f()
ret void
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/Inline/deleted-scc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ entry:

L: ; preds = %cleanup9, %entry
%cleanup.dest.slot.0 = phi i32 [ undef, %entry ], [ %cleanup.dest.slot.3, %cleanup9 ]
store i32 0, i32* @b, align 4
store i32 0, ptr @b, align 4
%tobool.not = icmp eq i32 0, 0
br i1 %tobool.not, label %if.then, label %while.cond

while.cond: ; preds = %cleanup9, %L
%cleanup.dest.slot.2 = phi i32 [ %cleanup.dest.slot.0, %L ], [ 0, %cleanup9 ]
%0 = load i32, i32* @b, align 4
%0 = load i32, ptr @b, align 4
%tobool3.not = icmp eq i32 %0, 0
br i1 %tobool3.not, label %cleanup9, label %while.body4

Expand Down
38 changes: 19 additions & 19 deletions llvm/test/Transforms/Inline/deoptimize-intrinsic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
declare i8 @llvm.experimental.deoptimize.i8(...)
declare i32 @llvm.experimental.deoptimize.i32(...)

define i8 @callee(i1* %c) alwaysinline {
%c0 = load volatile i1, i1* %c
define i8 @callee(ptr %c) alwaysinline {
%c0 = load volatile i1, ptr %c
br i1 %c0, label %left, label %right

left:
%c1 = load volatile i1, i1* %c
%c1 = load volatile i1, ptr %c
br i1 %c1, label %lleft, label %lright

lleft:
Expand All @@ -19,55 +19,55 @@ lright:
ret i8 10

right:
%c2 = load volatile i1, i1* %c
%c2 = load volatile i1, ptr %c
br i1 %c2, label %rleft, label %rright

rleft:
%v1 = call i8(...) @llvm.experimental.deoptimize.i8(i32 1, i32 300, float 500.0, <2 x i32*> undef) [ "deopt"(i32 1) ]
%v1 = call i8(...) @llvm.experimental.deoptimize.i8(i32 1, i32 300, float 500.0, <2 x ptr> undef) [ "deopt"(i32 1) ]
ret i8 %v1

rright:
%v2 = call i8(...) @llvm.experimental.deoptimize.i8() [ "deopt"(i32 1) ]
ret i8 %v2
}

define void @caller_0(i1* %c, i8* %ptr) {
define void @caller_0(ptr %c, ptr %ptr) {
; CHECK-LABEL: @caller_0(
entry:
%v = call i8 @callee(i1* %c) [ "deopt"(i32 2) ]
store i8 %v, i8* %ptr
%v = call i8 @callee(ptr %c) [ "deopt"(i32 2) ]
store i8 %v, ptr %ptr
ret void

; CHECK: lleft.i:
; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"(i32 2, i32 1) ]
; CHECK-NEXT: ret void

; CHECK: rleft.i:
; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1, i32 300, float 5.000000e+02, <2 x i32*> undef) [ "deopt"(i32 2, i32 1) ]
; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1, i32 300, float 5.000000e+02, <2 x ptr> undef) [ "deopt"(i32 2, i32 1) ]
; CHECK-NEXT: ret void

; CHECK: rright.i:
; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"(i32 2, i32 1) ]
; CHECK-NEXT: ret void

; CHECK: callee.exit:
; CHECK-NEXT: store i8 10, i8* %ptr
; CHECK-NEXT: store i8 10, ptr %ptr
; CHECK-NEXT: ret void

}

define i32 @caller_1(i1* %c, i8* %ptr) personality i8 3 {
define i32 @caller_1(ptr %c, ptr %ptr) personality i8 3 {
; CHECK-LABEL: @caller_1(
entry:
%v = invoke i8 @callee(i1* %c) [ "deopt"(i32 3) ] to label %normal
%v = invoke i8 @callee(ptr %c) [ "deopt"(i32 3) ] to label %normal
unwind label %unwind

; CHECK: lleft.i:
; CHECK-NEXT: %0 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 1) [ "deopt"(i32 3, i32 1) ]
; CHECK-NEXT: ret i32 %0

; CHECK: rleft.i:
; CHECK-NEXT: %1 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 1, i32 300, float 5.000000e+02, <2 x i32*> undef) [ "deopt"(i32 3, i32 1) ]
; CHECK-NEXT: %1 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 1, i32 300, float 5.000000e+02, <2 x ptr> undef) [ "deopt"(i32 3, i32 1) ]
; CHECK-NEXT: ret i32 %1

; CHECK: rright.i:
Expand All @@ -78,27 +78,27 @@ entry:
; CHECK-NEXT: br label %normal

; CHECK: normal:
; CHECK-NEXT: store i8 10, i8* %ptr
; CHECK-NEXT: store i8 10, ptr %ptr
; CHECK-NEXT: ret i32 42

unwind:
%lp = landingpad i32 cleanup
ret i32 43

normal:
store i8 %v, i8* %ptr
store i8 %v, ptr %ptr
ret i32 42
}

define i8 @callee_with_alloca() alwaysinline {
%t = alloca i8
%v0 = call i8(...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(i8* %t) ]
%v0 = call i8(...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(ptr %t) ]
ret i8 %v0
}

define void @caller_with_lifetime() {
; CHECK-LABEL: @caller_with_lifetime(
; CHECK: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"(i8* %t.i) ]
; CHECK: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"(ptr %t.i) ]
; CHECK-NEXT: ret void

entry:
Expand All @@ -108,13 +108,13 @@ entry:

define i8 @callee_with_dynamic_alloca(i32 %n) alwaysinline {
%p = alloca i8, i32 %n
%v = call i8(...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(i8* %p) ]
%v = call i8(...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(ptr %p) ]
ret i8 %v
}

define void @caller_with_stacksaverestore(i32 %n) {
; CHECK-LABEL: void @caller_with_stacksaverestore(
; CHECK: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"(i8* %p.i) ]
; CHECK: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"(ptr %p.i) ]
; CHECK-NEXT: ret void

%p = alloca i32, i32 %n
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/Transforms/Inline/devirtualize-2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
; PR4834

define i32 @test1() {
%funcall1_ = call fastcc i32 ()* () @f1()
%funcall1_ = call fastcc ptr () @f1()
%executecommandptr1_ = call i32 %funcall1_()
ret i32 %executecommandptr1_
}

define internal fastcc i32 ()* @f1() nounwind readnone {
ret i32 ()* @f2
define internal fastcc ptr @f1() nounwind readnone {
ret ptr @f2
}

define internal i32 @f2() nounwind readnone {
Expand All @@ -22,21 +22,21 @@ define internal i32 @f2() nounwind readnone {



declare i8* @f1a(i8*) ssp align 2
declare ptr @f1a(ptr) ssp align 2

define internal i32 @f2a(i8* %t) inlinehint ssp {
define internal i32 @f2a(ptr %t) inlinehint ssp {
entry:
ret i32 41
}

define internal i32 @f3a(i32 (i8*)* %__f) ssp {
define internal i32 @f3a(ptr %__f) ssp {
entry:
%A = call i32 %__f(i8* undef)
%A = call i32 %__f(ptr undef)
ret i32 %A
}

define i32 @test2(i8* %this) ssp align 2 {
%X = call i32 @f3a(i32 (i8*)* @f2a) ssp
define i32 @test2(ptr %this) ssp align 2 {
%X = call i32 @f3a(ptr @f2a) ssp
ret i32 %X
}

Expand Down
82 changes: 40 additions & 42 deletions llvm/test/Transforms/Inline/devirtualize-3.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,68 @@
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"
target triple = "x86_64-apple-darwin10.0.0"

%struct.cont_t = type { void (i8*, i32)*, i8* }
%struct.foo_sf_t = type { %struct.cont_t*, i32 }
%struct.cont_t = type { ptr, ptr }
%struct.foo_sf_t = type { ptr, i32 }

define i32 @main() nounwind ssp {
entry:
%cont = alloca %struct.cont_t, align 8 ; <%struct.cont_t*> [#uses=4]
%tmp = getelementptr inbounds %struct.cont_t, %struct.cont_t* %cont, i32 0, i32 0 ; <void (i8*, i32)**> [#uses=1]
%tmp1 = getelementptr inbounds %struct.cont_t, %struct.cont_t* %cont, i32 0, i32 0 ; <void (i8*, i32)**> [#uses=2]
store void (i8*, i32)* bitcast (void (%struct.cont_t*, i32)* @quit to void (i8*, i32)*), void (i8*, i32)** %tmp1
%tmp2 = load void (i8*, i32)*, void (i8*, i32)** %tmp1 ; <void (i8*, i32)*> [#uses=1]
store void (i8*, i32)* %tmp2, void (i8*, i32)** %tmp
%tmp3 = getelementptr inbounds %struct.cont_t, %struct.cont_t* %cont, i32 0, i32 1 ; <i8**> [#uses=1]
store i8* null, i8** %tmp3
call void @foo(%struct.cont_t* %cont)
%cont = alloca %struct.cont_t, align 8 ; <ptr> [#uses=4]
%tmp = getelementptr inbounds %struct.cont_t, ptr %cont, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp1 = getelementptr inbounds %struct.cont_t, ptr %cont, i32 0, i32 0 ; <ptr> [#uses=2]
store ptr @quit, ptr %tmp1
%tmp2 = load ptr, ptr %tmp1 ; <ptr> [#uses=1]
store ptr %tmp2, ptr %tmp
%tmp3 = getelementptr inbounds %struct.cont_t, ptr %cont, i32 0, i32 1 ; <ptr> [#uses=1]
store ptr null, ptr %tmp3
call void @foo(ptr %cont)
ret i32 0
}

define internal void @quit(%struct.cont_t* %cont, i32 %rcode) nounwind ssp {
define internal void @quit(ptr %cont, i32 %rcode) nounwind ssp {
entry:
call void @exit(i32 %rcode) noreturn
unreachable
}

define internal void @foo(%struct.cont_t* %c) nounwind ssp {
define internal void @foo(ptr %c) nounwind ssp {
entry:
%sf = alloca %struct.foo_sf_t, align 8 ; <%struct.foo_sf_t*> [#uses=3]
%next = alloca %struct.cont_t, align 8 ; <%struct.cont_t*> [#uses=3]
%tmp = getelementptr inbounds %struct.foo_sf_t, %struct.foo_sf_t* %sf, i32 0, i32 0 ; <%struct.cont_t**> [#uses=1]
store %struct.cont_t* %c, %struct.cont_t** %tmp
%tmp2 = getelementptr inbounds %struct.foo_sf_t, %struct.foo_sf_t* %sf, i32 0, i32 1 ; <i32*> [#uses=1]
store i32 2, i32* %tmp2
%tmp4 = getelementptr inbounds %struct.cont_t, %struct.cont_t* %next, i32 0, i32 0 ; <void (i8*, i32)**> [#uses=1]
store void (i8*, i32)* bitcast (void (%struct.foo_sf_t*, i32)* @foo2 to void (i8*, i32)*), void (i8*, i32)** %tmp4
%tmp5 = getelementptr inbounds %struct.cont_t, %struct.cont_t* %next, i32 0, i32 1 ; <i8**> [#uses=1]
%conv = bitcast %struct.foo_sf_t* %sf to i8* ; <i8*> [#uses=1]
store i8* %conv, i8** %tmp5
call void @bar(%struct.cont_t* %next, i32 14)
%sf = alloca %struct.foo_sf_t, align 8 ; <ptr> [#uses=3]
%next = alloca %struct.cont_t, align 8 ; <ptr> [#uses=3]
%tmp = getelementptr inbounds %struct.foo_sf_t, ptr %sf, i32 0, i32 0 ; <ptr> [#uses=1]
store ptr %c, ptr %tmp
%tmp2 = getelementptr inbounds %struct.foo_sf_t, ptr %sf, i32 0, i32 1 ; <ptr> [#uses=1]
store i32 2, ptr %tmp2
%tmp4 = getelementptr inbounds %struct.cont_t, ptr %next, i32 0, i32 0 ; <ptr> [#uses=1]
store ptr @foo2, ptr %tmp4
%tmp5 = getelementptr inbounds %struct.cont_t, ptr %next, i32 0, i32 1 ; <ptr> [#uses=1]
store ptr %sf, ptr %tmp5
call void @bar(ptr %next, i32 14)
ret void
}

define internal void @foo2(%struct.foo_sf_t* %sf, i32 %y) nounwind ssp {
define internal void @foo2(ptr %sf, i32 %y) nounwind ssp {
entry:
%tmp1 = getelementptr inbounds %struct.foo_sf_t, %struct.foo_sf_t* %sf, i32 0, i32 0 ; <%struct.cont_t**> [#uses=1]
%tmp2 = load %struct.cont_t*, %struct.cont_t** %tmp1 ; <%struct.cont_t*> [#uses=1]
%tmp3 = getelementptr inbounds %struct.cont_t, %struct.cont_t* %tmp2, i32 0, i32 0 ; <void (i8*, i32)**> [#uses=1]
%tmp4 = load void (i8*, i32)*, void (i8*, i32)** %tmp3 ; <void (i8*, i32)*> [#uses=1]
%tmp6 = getelementptr inbounds %struct.foo_sf_t, %struct.foo_sf_t* %sf, i32 0, i32 0 ; <%struct.cont_t**> [#uses=1]
%tmp7 = load %struct.cont_t*, %struct.cont_t** %tmp6 ; <%struct.cont_t*> [#uses=1]
%conv = bitcast %struct.cont_t* %tmp7 to i8* ; <i8*> [#uses=1]
%tmp9 = getelementptr inbounds %struct.foo_sf_t, %struct.foo_sf_t* %sf, i32 0, i32 1 ; <i32*> [#uses=1]
%tmp10 = load i32, i32* %tmp9 ; <i32> [#uses=1]
%tmp1 = getelementptr inbounds %struct.foo_sf_t, ptr %sf, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp2 = load ptr, ptr %tmp1 ; <ptr> [#uses=1]
%tmp3 = getelementptr inbounds %struct.cont_t, ptr %tmp2, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp4 = load ptr, ptr %tmp3 ; <ptr> [#uses=1]
%tmp6 = getelementptr inbounds %struct.foo_sf_t, ptr %sf, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp7 = load ptr, ptr %tmp6 ; <ptr> [#uses=1]
%tmp9 = getelementptr inbounds %struct.foo_sf_t, ptr %sf, i32 0, i32 1 ; <ptr> [#uses=1]
%tmp10 = load i32, ptr %tmp9 ; <i32> [#uses=1]
%mul = mul i32 %tmp10, %y ; <i32> [#uses=1]
call void %tmp4(i8* %conv, i32 %mul)
call void %tmp4(ptr %tmp7, i32 %mul)
ret void
}

define internal void @bar(%struct.cont_t* %c, i32 %y) nounwind ssp {
define internal void @bar(ptr %c, i32 %y) nounwind ssp {
entry:
%tmp1 = getelementptr inbounds %struct.cont_t, %struct.cont_t* %c, i32 0, i32 0 ; <void (i8*, i32)**> [#uses=1]
%tmp2 = load void (i8*, i32)*, void (i8*, i32)** %tmp1 ; <void (i8*, i32)*> [#uses=1]
%tmp4 = getelementptr inbounds %struct.cont_t, %struct.cont_t* %c, i32 0, i32 1 ; <i8**> [#uses=1]
%tmp5 = load i8*, i8** %tmp4 ; <i8*> [#uses=1]
%tmp1 = getelementptr inbounds %struct.cont_t, ptr %c, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp2 = load ptr, ptr %tmp1 ; <ptr> [#uses=1]
%tmp4 = getelementptr inbounds %struct.cont_t, ptr %c, i32 0, i32 1 ; <ptr> [#uses=1]
%tmp5 = load ptr, ptr %tmp4 ; <ptr> [#uses=1]
%add = add nsw i32 %y, 5 ; <i32> [#uses=1]
call void %tmp2(i8* %tmp5, i32 %add)
call void %tmp2(ptr %tmp5, i32 %add)
ret void
}

Expand Down
134 changes: 60 additions & 74 deletions llvm/test/Transforms/Inline/devirtualize-4.ll
Original file line number Diff line number Diff line change
Expand Up @@ -34,76 +34,69 @@
;}

%class.Impl = type <{ %class.Interface, i32, [4 x i8] }>
%class.Interface = type { i32 (...)** }
%class.Interface = type { ptr }

@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI4Impl to i8*), i8* bitcast (void (%class.Impl*)* @_ZN4Impl3RunEv to i8*)] }, align 8
@_ZTVN10__cxxabiv120__si_class_type_infoE = external dso_local global i8*
@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI4Impl, ptr @_ZN4Impl3RunEv] }, align 8
@_ZTVN10__cxxabiv120__si_class_type_infoE = external dso_local global ptr
@_ZTS4Impl = linkonce_odr dso_local constant [6 x i8] c"4Impl\00", align 1
@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*
@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global ptr
@_ZTS9Interface = linkonce_odr dso_local constant [11 x i8] c"9Interface\00", align 1
@_ZTI9Interface = linkonce_odr dso_local constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTS9Interface, i32 0, i32 0) }, align 8
@_ZTI4Impl = linkonce_odr dso_local constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Impl, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*) }, align 8
@_ZTV9Interface = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*)] }, align 8
@_ZTI9Interface = linkonce_odr dso_local constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS9Interface }, align 8
@_ZTI4Impl = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr @_ZTS4Impl, ptr @_ZTI9Interface }, align 8
@_ZTV9Interface = linkonce_odr dso_local unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI9Interface, ptr @__cxa_pure_virtual] }, align 8

define dso_local void @_Z4Testv() local_unnamed_addr {
entry:
%o = alloca %class.Impl, align 8
%0 = bitcast %class.Impl* %o to i8*
call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0)
call void @_ZN4ImplC2Ev(%class.Impl* nonnull %o)
%1 = getelementptr inbounds %class.Impl, %class.Impl* %o, i64 0, i32 0
call fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* nonnull dereferenceable(8) %1)
call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0)
call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %o)
call void @_ZN4ImplC2Ev(ptr nonnull %o)
call fastcc void @_ZL11IndirectRunR9Interface(ptr nonnull dereferenceable(8) %o)
call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %o)
ret void
}

declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)

define linkonce_odr dso_local void @_ZN4ImplC2Ev(%class.Impl* %this) unnamed_addr align 2 {
define linkonce_odr dso_local void @_ZN4ImplC2Ev(ptr %this) unnamed_addr align 2 {
entry:
%0 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0
call void @_ZN9InterfaceC2Ev(%class.Interface* %0)
%1 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0, i32 0
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Impl, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8
%f = getelementptr inbounds %class.Impl, %class.Impl* %this, i64 0, i32 1
store i32 3, i32* %f, align 8
call void @_ZN9InterfaceC2Ev(ptr %this)
store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV4Impl, i64 0, inrange i32 0, i64 2), ptr %this, align 8
%f = getelementptr inbounds %class.Impl, ptr %this, i64 0, i32 1
store i32 3, ptr %f, align 8
ret void
}

define internal fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* dereferenceable(8) %o) unnamed_addr {
define internal fastcc void @_ZL11IndirectRunR9Interface(ptr dereferenceable(8) %o) unnamed_addr {
entry:
%0 = bitcast %class.Interface* %o to void (%class.Interface*)***
%vtable = load void (%class.Interface*)**, void (%class.Interface*)*** %0, align 8
%1 = load void (%class.Interface*)*, void (%class.Interface*)** %vtable, align 8
call void %1(%class.Interface* nonnull %o)
%vtable = load ptr, ptr %o, align 8
%0 = load ptr, ptr %vtable, align 8
call void %0(ptr nonnull %o)
ret void
}

declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)

define linkonce_odr dso_local void @_ZN9InterfaceC2Ev(%class.Interface* %this) unnamed_addr align 2 {
define linkonce_odr dso_local void @_ZN9InterfaceC2Ev(ptr %this) unnamed_addr align 2 {
entry:
%0 = getelementptr %class.Interface, %class.Interface* %this, i64 0, i32 0
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV9Interface, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV9Interface, i64 0, inrange i32 0, i64 2), ptr %this, align 8
ret void
}

define linkonce_odr dso_local void @_ZN4Impl3RunEv(%class.Impl* %this) unnamed_addr align 2 {
define linkonce_odr dso_local void @_ZN4Impl3RunEv(ptr %this) unnamed_addr align 2 {
entry:
%ref.tmp = alloca %class.Impl*, align 8
%0 = bitcast %class.Impl** %ref.tmp to i8*
call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)
store %class.Impl* %this, %class.Impl** %ref.tmp, align 8
call void @_Z13DoNotOptimizeIP4ImplEvRKT_(%class.Impl** nonnull dereferenceable(8) %ref.tmp)
call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0)
%ref.tmp = alloca ptr, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %ref.tmp)
store ptr %this, ptr %ref.tmp, align 8
call void @_Z13DoNotOptimizeIP4ImplEvRKT_(ptr nonnull dereferenceable(8) %ref.tmp)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %ref.tmp)
ret void
}

declare dso_local void @__cxa_pure_virtual() unnamed_addr

define linkonce_odr dso_local void @_Z13DoNotOptimizeIP4ImplEvRKT_(%class.Impl** dereferenceable(8) %var) local_unnamed_addr {
define linkonce_odr dso_local void @_Z13DoNotOptimizeIP4ImplEvRKT_(ptr dereferenceable(8) %var) local_unnamed_addr {
entry:
call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(%class.Impl** elementtype(%class.Impl*) nonnull %var, %class.Impl** elementtype(%class.Impl*) nonnull %var)
call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(ptr) nonnull %var, ptr elementtype(ptr) nonnull %var)
ret void
}

Expand Down Expand Up @@ -134,81 +127,74 @@ entry:
; return f(&a, &A::vf2);
;}

%struct.A = type { i32 (...)** }
%struct.A = type { ptr }

@_ZTV1A = linkonce_odr unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A3vf1Ev to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A3vf2Ev to i8*)] }, align 8
@_ZTV1A = linkonce_odr unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A3vf1Ev, ptr @_ZN1A3vf2Ev] }, align 8
@_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", align 1
@_ZTI1A = linkonce_odr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1A, i32 0, i32 0) }, align 8
@_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, align 8

define i32 @_Z1fP1AMS_FivE(%struct.A* %a, i64 %fp.coerce0, i64 %fp.coerce1) {
define i32 @_Z1fP1AMS_FivE(ptr %a, i64 %fp.coerce0, i64 %fp.coerce1) {
entry:
%0 = bitcast %struct.A* %a to i8*
%1 = getelementptr inbounds i8, i8* %0, i64 %fp.coerce1
%this.adjusted = bitcast i8* %1 to %struct.A*
%2 = and i64 %fp.coerce0, 1
%memptr.isvirtual = icmp eq i64 %2, 0
%0 = getelementptr inbounds i8, ptr %a, i64 %fp.coerce1
%1 = and i64 %fp.coerce0, 1
%memptr.isvirtual = icmp eq i64 %1, 0
br i1 %memptr.isvirtual, label %memptr.nonvirtual, label %memptr.virtual

memptr.virtual: ; preds = %entry
%3 = bitcast i8* %1 to i8**
%vtable = load i8*, i8** %3, align 8
%4 = add i64 %fp.coerce0, -1
%5 = getelementptr i8, i8* %vtable, i64 %4
%6 = bitcast i8* %5 to i32 (%struct.A*)**
%memptr.virtualfn = load i32 (%struct.A*)*, i32 (%struct.A*)** %6, align 8
%vtable = load ptr, ptr %0, align 8
%2 = add i64 %fp.coerce0, -1
%3 = getelementptr i8, ptr %vtable, i64 %2
%memptr.virtualfn = load ptr, ptr %3, align 8
br label %memptr.end

memptr.nonvirtual: ; preds = %entry
%memptr.nonvirtualfn = inttoptr i64 %fp.coerce0 to i32 (%struct.A*)*
%memptr.nonvirtualfn = inttoptr i64 %fp.coerce0 to ptr
br label %memptr.end

memptr.end: ; preds = %memptr.nonvirtual, %memptr.virtual
%7 = phi i32 (%struct.A*)* [ %memptr.virtualfn, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ]
%call = call i32 %7(%struct.A* %this.adjusted)
%4 = phi ptr [ %memptr.virtualfn, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ]
%call = call i32 %4(ptr %0)
ret i32 %call
}

define i32 @_Z2g1v() {
entry:
%a = alloca %struct.A, align 8
%0 = bitcast %struct.A* %a to i8*
call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)
call void @_ZN1AC1Ev(%struct.A* nonnull %a)
%call = call i32 @_Z1fP1AMS_FivE(%struct.A* nonnull %a, i64 1, i64 0)
call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0)
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a)
call void @_ZN1AC1Ev(ptr nonnull %a)
%call = call i32 @_Z1fP1AMS_FivE(ptr nonnull %a, i64 1, i64 0)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a)
ret i32 %call
}

define linkonce_odr void @_ZN1AC1Ev(%struct.A* %this) align 2 {
define linkonce_odr void @_ZN1AC1Ev(ptr %this) align 2 {
entry:
call void @_ZN1AC2Ev(%struct.A* %this)
call void @_ZN1AC2Ev(ptr %this)
ret void
}

define i32 @_Z2g2v() {
entry:
%a = alloca %struct.A, align 8
%0 = bitcast %struct.A* %a to i8*
call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)
call void @_ZN1AC1Ev(%struct.A* nonnull %a)
%call = call i32 @_Z1fP1AMS_FivE(%struct.A* nonnull %a, i64 9, i64 0)
call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0)
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a)
call void @_ZN1AC1Ev(ptr nonnull %a)
%call = call i32 @_Z1fP1AMS_FivE(ptr nonnull %a, i64 9, i64 0)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a)
ret i32 %call
}

define linkonce_odr void @_ZN1AC2Ev(%struct.A* %this) align 2 {
define linkonce_odr void @_ZN1AC2Ev(ptr %this) align 2 {
entry:
%0 = getelementptr %struct.A, %struct.A* %this, i64 0, i32 0
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8
ret void
}

define linkonce_odr i32 @_ZN1A3vf1Ev(%struct.A* %this) align 2 {
define linkonce_odr i32 @_ZN1A3vf1Ev(ptr %this) align 2 {
entry:
ret i32 1
}

define linkonce_odr i32 @_ZN1A3vf2Ev(%struct.A* %this) align 2 {
define linkonce_odr i32 @_ZN1A3vf2Ev(ptr %this) align 2 {
entry:
ret i32 2
}
10 changes: 5 additions & 5 deletions llvm/test/Transforms/Inline/devirtualize-5.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ define i32 @i() alwaysinline {
; CHECK-NEXT: ret i32 45

define i32 @main() {
%a = alloca i32 ()*
store i32 ()* @i, i32 ()** %a
%r = call i32 @call(i32 ()** %a)
%a = alloca ptr
store ptr @i, ptr %a
%r = call i32 @call(ptr %a)
ret i32 %r
}

define i32 @call(i32 ()** %a) alwaysinline {
%c = load i32 ()*, i32 ()** %a
define i32 @call(ptr %a) alwaysinline {
%c = load ptr, ptr %a
%r = call i32 %c()
ret i32 %r
}
156 changes: 67 additions & 89 deletions llvm/test/Transforms/Inline/devirtualize.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ target triple = "x86_64-apple-darwin10.0.0"

; Simple devirt testcase, requires iteration between inliner and GVN.
; rdar://6295824
define i32 @foo(i32 ()** noalias %p, i64* noalias %q) nounwind ssp {
define i32 @foo(ptr noalias %p, ptr noalias %q) nounwind ssp {
entry:
store i32 ()* @bar, i32 ()** %p
store i64 0, i64* %q
%tmp3 = load i32 ()*, i32 ()** %p ; <i32 ()*> [#uses=1]
store ptr @bar, ptr %p
store i64 0, ptr %q
%tmp3 = load ptr, ptr %p ; <ptr> [#uses=1]
%call = call i32 %tmp3() ; <i32> [#uses=1]
%X = add i32 %call, 4
ret i32 %X
Expand All @@ -33,151 +33,129 @@ entry:
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 7

%0 = type { i8*, i8* }
%1 = type { i8*, i8*, i32, i32, i8*, i64, i8*, i64 }
%2 = type { i8*, i8*, i8* }
%struct.A = type { i8** }
%struct.B = type { i8** }
%0 = type { ptr, ptr }
%1 = type { ptr, ptr, i32, i32, ptr, i64, ptr, i64 }
%2 = type { ptr, ptr, ptr }
%struct.A = type { ptr }
%struct.B = type { ptr }
%struct.C = type { [16 x i8] }
%struct.D = type { [16 x i8] }

@_ZTV1D = linkonce_odr constant [6 x i8*] [i8* null, i8* bitcast (%2* @_ZTI1D to i8*), i8* bitcast (i32 (%struct.C*)* @_ZN1D1fEv to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%2* @_ZTI1D to i8*), i8* bitcast (i32 (%struct.C*)* @_ZThn8_N1D1fEv to i8*)] ; <[6 x i8*]*> [#uses=2]
@_ZTVN10__cxxabiv120__si_class_type_infoE = external global i8* ; <i8**> [#uses=1]
@_ZTS1D = linkonce_odr constant [3 x i8] c"1D\00" ; <[3 x i8]*> [#uses=1]
@_ZTVN10__cxxabiv121__vmi_class_type_infoE = external global i8* ; <i8**> [#uses=1]
@_ZTS1C = linkonce_odr constant [3 x i8] c"1C\00" ; <[3 x i8]*> [#uses=1]
@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* ; <i8**> [#uses=1]
@_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00" ; <[3 x i8]*> [#uses=1]
@_ZTI1A = linkonce_odr constant %0 { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1A, i32 0, i32 0) } ; <%0*> [#uses=1]
@_ZTS1B = linkonce_odr constant [3 x i8] c"1B\00" ; <[3 x i8]*> [#uses=1]
@_ZTI1B = linkonce_odr constant %0 { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1B, i32 0, i32 0) } ; <%0*> [#uses=1]
@_ZTI1C = linkonce_odr constant %1 { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1C, i32 0, i32 0), i32 0, i32 2, i8* bitcast (%0* @_ZTI1A to i8*), i64 2, i8* bitcast (%0* @_ZTI1B to i8*), i64 2050 } ; <%1*> [#uses=1]
@_ZTI1D = linkonce_odr constant %2 { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1D, i32 0, i32 0), i8* bitcast (%1* @_ZTI1C to i8*) } ; <%2*> [#uses=1]
@_ZTV1C = linkonce_odr constant [6 x i8*] [i8* null, i8* bitcast (%1* @_ZTI1C to i8*), i8* bitcast (i32 (%struct.C*)* @_ZN1C1fEv to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%1* @_ZTI1C to i8*), i8* bitcast (i32 (%struct.C*)* @_ZThn8_N1C1fEv to i8*)] ; <[6 x i8*]*> [#uses=2]
@_ZTV1B = linkonce_odr constant [3 x i8*] [i8* null, i8* bitcast (%0* @_ZTI1B to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1B1fEv to i8*)] ; <[3 x i8*]*> [#uses=1]
@_ZTV1A = linkonce_odr constant [3 x i8*] [i8* null, i8* bitcast (%0* @_ZTI1A to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A1fEv to i8*)] ; <[3 x i8*]*> [#uses=1]
@_ZTV1D = linkonce_odr constant [6 x ptr] [ptr null, ptr @_ZTI1D, ptr @_ZN1D1fEv, ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1D, ptr @_ZThn8_N1D1fEv] ; <ptr> [#uses=2]
@_ZTVN10__cxxabiv120__si_class_type_infoE = external global ptr ; <ptr> [#uses=1]
@_ZTS1D = linkonce_odr constant [3 x i8] c"1D\00" ; <ptr> [#uses=1]
@_ZTVN10__cxxabiv121__vmi_class_type_infoE = external global ptr ; <ptr> [#uses=1]
@_ZTS1C = linkonce_odr constant [3 x i8] c"1C\00" ; <ptr> [#uses=1]
@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr ; <ptr> [#uses=1]
@_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00" ; <ptr> [#uses=1]
@_ZTI1A = linkonce_odr constant %0 { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A } ; <ptr> [#uses=1]
@_ZTS1B = linkonce_odr constant [3 x i8] c"1B\00" ; <ptr> [#uses=1]
@_ZTI1B = linkonce_odr constant %0 { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1B } ; <ptr> [#uses=1]
@_ZTI1C = linkonce_odr constant %1 { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), ptr @_ZTS1C, i32 0, i32 2, ptr @_ZTI1A, i64 2, ptr @_ZTI1B, i64 2050 } ; <ptr> [#uses=1]
@_ZTI1D = linkonce_odr constant %2 { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr @_ZTS1D, ptr @_ZTI1C } ; <ptr> [#uses=1]
@_ZTV1C = linkonce_odr constant [6 x ptr] [ptr null, ptr @_ZTI1C, ptr @_ZN1C1fEv, ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1C, ptr @_ZThn8_N1C1fEv] ; <ptr> [#uses=2]
@_ZTV1B = linkonce_odr constant [3 x ptr] [ptr null, ptr @_ZTI1B, ptr @_ZN1B1fEv] ; <ptr> [#uses=1]
@_ZTV1A = linkonce_odr constant [3 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A1fEv] ; <ptr> [#uses=1]

define i32 @_Z1gv() ssp {
entry:
%d = alloca %struct.C, align 8 ; <%struct.C*> [#uses=2]
call void @_ZN1DC1Ev(%struct.C* %d)
%call = call i32 @_Z1fP1D(%struct.C* %d) ; <i32> [#uses=1]
%d = alloca %struct.C, align 8 ; <ptr> [#uses=2]
call void @_ZN1DC1Ev(ptr %d)
%call = call i32 @_Z1fP1D(ptr %d) ; <i32> [#uses=1]
%X = add i32 %call, 3
ret i32 %X
}

define linkonce_odr void @_ZN1DC1Ev(%struct.C* %this) inlinehint ssp align 2 {
define linkonce_odr void @_ZN1DC1Ev(ptr %this) inlinehint ssp align 2 {
entry:
call void @_ZN1DC2Ev(%struct.C* %this)
call void @_ZN1DC2Ev(ptr %this)
ret void
}

define internal i32 @_Z1fP1D(%struct.C* %d) ssp {
define internal i32 @_Z1fP1D(ptr %d) ssp {
entry:
%0 = icmp eq %struct.C* %d, null ; <i1> [#uses=1]
%0 = icmp eq ptr %d, null ; <i1> [#uses=1]
br i1 %0, label %cast.end, label %cast.notnull

cast.notnull: ; preds = %entry
%1 = bitcast %struct.C* %d to i8* ; <i8*> [#uses=1]
%add.ptr = getelementptr i8, i8* %1, i64 8 ; <i8*> [#uses=1]
%2 = bitcast i8* %add.ptr to %struct.A* ; <%struct.A*> [#uses=1]
%add.ptr = getelementptr i8, ptr %d, i64 8 ; <ptr> [#uses=1]
br label %cast.end

cast.end: ; preds = %entry, %cast.notnull
%3 = phi %struct.A* [ %2, %cast.notnull ], [ null, %entry ] ; <%struct.A*> [#uses=2]
%4 = bitcast %struct.A* %3 to i32 (%struct.A*)*** ; <i32 (%struct.A*)***> [#uses=1]
%5 = load i32 (%struct.A*)**, i32 (%struct.A*)*** %4 ; <i32 (%struct.A*)**> [#uses=1]
%vfn = getelementptr inbounds i32 (%struct.A*)*, i32 (%struct.A*)** %5, i64 0 ; <i32 (%struct.A*)**> [#uses=1]
%6 = load i32 (%struct.A*)*, i32 (%struct.A*)** %vfn ; <i32 (%struct.A*)*> [#uses=1]
%call = call i32 %6(%struct.A* %3) ; <i32> [#uses=1]
%1 = phi ptr [ %add.ptr, %cast.notnull ], [ null, %entry ] ; <ptr> [#uses=2]
%2 = load ptr, ptr %1 ; <ptr> [#uses=1]
%vfn = getelementptr inbounds ptr, ptr %2, i64 0 ; <ptr> [#uses=1]
%3 = load ptr, ptr %vfn ; <ptr> [#uses=1]
%call = call i32 %3(ptr %1) ; <i32> [#uses=1]
ret i32 %call
}

define linkonce_odr i32 @_ZN1D1fEv(%struct.C* %this) ssp align 2 {
define linkonce_odr i32 @_ZN1D1fEv(ptr %this) ssp align 2 {
entry:
ret i32 4
}

define linkonce_odr i32 @_ZThn8_N1D1fEv(%struct.C* %this) ssp {
define linkonce_odr i32 @_ZThn8_N1D1fEv(ptr %this) ssp {
entry:
%0 = bitcast %struct.C* %this to i8* ; <i8*> [#uses=1]
%1 = getelementptr inbounds i8, i8* %0, i64 -8 ; <i8*> [#uses=1]
%2 = bitcast i8* %1 to %struct.C* ; <%struct.C*> [#uses=1]
%call = call i32 @_ZN1D1fEv(%struct.C* %2) ; <i32> [#uses=1]
%0 = getelementptr inbounds i8, ptr %this, i64 -8 ; <ptr> [#uses=1]
%call = call i32 @_ZN1D1fEv(ptr %0) ; <i32> [#uses=1]
ret i32 %call
}

define linkonce_odr void @_ZN1DC2Ev(%struct.C* %this) inlinehint ssp align 2 {
define linkonce_odr void @_ZN1DC2Ev(ptr %this) inlinehint ssp align 2 {
entry:
call void @_ZN1CC2Ev(%struct.C* %this)
%0 = bitcast %struct.C* %this to i8* ; <i8*> [#uses=1]
%1 = getelementptr inbounds i8, i8* %0, i64 0 ; <i8*> [#uses=1]
%2 = bitcast i8* %1 to i8*** ; <i8***> [#uses=1]
store i8** getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTV1D, i64 0, i64 2), i8*** %2
%3 = bitcast %struct.C* %this to i8* ; <i8*> [#uses=1]
%4 = getelementptr inbounds i8, i8* %3, i64 8 ; <i8*> [#uses=1]
%5 = bitcast i8* %4 to i8*** ; <i8***> [#uses=1]
store i8** getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTV1D, i64 0, i64 5), i8*** %5
call void @_ZN1CC2Ev(ptr %this)
%0 = getelementptr inbounds i8, ptr %this, i64 0 ; <ptr> [#uses=1]
store ptr getelementptr inbounds ([6 x ptr], ptr @_ZTV1D, i64 0, i64 2), ptr %0
%1 = getelementptr inbounds i8, ptr %this, i64 8 ; <ptr> [#uses=1]
store ptr getelementptr inbounds ([6 x ptr], ptr @_ZTV1D, i64 0, i64 5), ptr %1
ret void
}

define linkonce_odr void @_ZN1CC2Ev(%struct.C* %this) inlinehint ssp align 2 {
define linkonce_odr void @_ZN1CC2Ev(ptr %this) inlinehint ssp align 2 {
entry:
%0 = bitcast %struct.C* %this to %struct.A* ; <%struct.A*> [#uses=1]
call void @_ZN1AC2Ev(%struct.A* %0)
%1 = bitcast %struct.C* %this to i8* ; <i8*> [#uses=1]
%2 = getelementptr inbounds i8, i8* %1, i64 8 ; <i8*> [#uses=1]
%3 = bitcast i8* %2 to %struct.A* ; <%struct.A*> [#uses=1]
call void @_ZN1BC2Ev(%struct.A* %3)
%4 = bitcast %struct.C* %this to i8* ; <i8*> [#uses=1]
%5 = getelementptr inbounds i8, i8* %4, i64 0 ; <i8*> [#uses=1]
%6 = bitcast i8* %5 to i8*** ; <i8***> [#uses=1]
store i8** getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTV1C, i64 0, i64 2), i8*** %6
%7 = bitcast %struct.C* %this to i8* ; <i8*> [#uses=1]
%8 = getelementptr inbounds i8, i8* %7, i64 8 ; <i8*> [#uses=1]
%9 = bitcast i8* %8 to i8*** ; <i8***> [#uses=1]
store i8** getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTV1C, i64 0, i64 5), i8*** %9
call void @_ZN1AC2Ev(ptr %this)
%0 = getelementptr inbounds i8, ptr %this, i64 8 ; <ptr> [#uses=1]
call void @_ZN1BC2Ev(ptr %0)
%1 = getelementptr inbounds i8, ptr %this, i64 0 ; <ptr> [#uses=1]
store ptr getelementptr inbounds ([6 x ptr], ptr @_ZTV1C, i64 0, i64 2), ptr %1
%2 = getelementptr inbounds i8, ptr %this, i64 8 ; <ptr> [#uses=1]
store ptr getelementptr inbounds ([6 x ptr], ptr @_ZTV1C, i64 0, i64 5), ptr %2
ret void
}

define linkonce_odr i32 @_ZN1C1fEv(%struct.C* %this) ssp align 2 {
define linkonce_odr i32 @_ZN1C1fEv(ptr %this) ssp align 2 {
entry:
ret i32 3
}

define linkonce_odr i32 @_ZThn8_N1C1fEv(%struct.C* %this) {
define linkonce_odr i32 @_ZThn8_N1C1fEv(ptr %this) {
entry:
%0 = bitcast %struct.C* %this to i8* ; <i8*> [#uses=1]
%1 = getelementptr inbounds i8, i8* %0, i64 -8 ; <i8*> [#uses=1]
%2 = bitcast i8* %1 to %struct.C* ; <%struct.C*> [#uses=1]
%call = call i32 @_ZN1C1fEv(%struct.C* %2) ; <i32> [#uses=1]
%0 = getelementptr inbounds i8, ptr %this, i64 -8 ; <ptr> [#uses=1]
%call = call i32 @_ZN1C1fEv(ptr %0) ; <i32> [#uses=1]
ret i32 %call
}

define linkonce_odr void @_ZN1AC2Ev(%struct.A* %this) inlinehint ssp align 2 {
define linkonce_odr void @_ZN1AC2Ev(ptr %this) inlinehint ssp align 2 {
entry:
%0 = bitcast %struct.A* %this to i8* ; <i8*> [#uses=1]
%1 = getelementptr inbounds i8, i8* %0, i64 0 ; <i8*> [#uses=1]
%2 = bitcast i8* %1 to i8*** ; <i8***> [#uses=1]
store i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTV1A, i64 0, i64 2), i8*** %2
%0 = getelementptr inbounds i8, ptr %this, i64 0 ; <ptr> [#uses=1]
store ptr getelementptr inbounds ([3 x ptr], ptr @_ZTV1A, i64 0, i64 2), ptr %0
ret void
}

define linkonce_odr void @_ZN1BC2Ev(%struct.A* %this) inlinehint ssp align 2 {
define linkonce_odr void @_ZN1BC2Ev(ptr %this) inlinehint ssp align 2 {
entry:
%0 = bitcast %struct.A* %this to i8* ; <i8*> [#uses=1]
%1 = getelementptr inbounds i8, i8* %0, i64 0 ; <i8*> [#uses=1]
%2 = bitcast i8* %1 to i8*** ; <i8***> [#uses=1]
store i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTV1B, i64 0, i64 2), i8*** %2
%0 = getelementptr inbounds i8, ptr %this, i64 0 ; <ptr> [#uses=1]
store ptr getelementptr inbounds ([3 x ptr], ptr @_ZTV1B, i64 0, i64 2), ptr %0
ret void
}

define linkonce_odr i32 @_ZN1B1fEv(%struct.A* %this) ssp align 2 {
define linkonce_odr i32 @_ZN1B1fEv(ptr %this) ssp align 2 {
entry:
ret i32 2
}

define linkonce_odr i32 @_ZN1A1fEv(%struct.A* %this) ssp align 2 {
define linkonce_odr i32 @_ZN1A1fEv(ptr %this) ssp align 2 {
entry:
ret i32 1
}
68 changes: 33 additions & 35 deletions llvm/test/Transforms/Inline/dynamic-alloca-simplified-large.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.15.0"

define void @caller1(i8 *%p1, i1 %b) {
define void @caller1(ptr %p1, i1 %b) {
; CHECK-LABEL: @caller1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[COND:%.*]] = icmp eq i1 [[B:%.*]], true
; CHECK-NEXT: br i1 [[COND]], label [[EXIT:%.*]], label [[SPLIT:%.*]]
; CHECK: split:
; CHECK-NEXT: call void @callee(i8* [[P1:%.*]], i32 0, i32 -1)
; CHECK-NEXT: call void @callee(ptr [[P1:%.*]], i32 0, i32 -1)
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
Expand All @@ -20,36 +20,34 @@ entry:

split:
; This path may be generated from CS splitting and never taken at runtime.
call void @callee(i8* %p1, i32 0, i32 -1)
call void @callee(ptr %p1, i32 0, i32 -1)
br label %exit

exit:
ret void
}

define void @callee(i8* %p1, i32 %l1, i32 %l2) {
define void @callee(ptr %p1, i32 %l1, i32 %l2) {
entry:
%ext = zext i32 %l2 to i64
%vla = alloca float, i64 %ext, align 16
call void @extern_call(float* nonnull %vla) #3
call void @extern_call(ptr nonnull %vla) #3
ret void
}


define void @caller2_below_threshold(i8 *%p1, i1 %b) {
define void @caller2_below_threshold(ptr %p1, i1 %b) {
; CHECK-LABEL: @caller2_below_threshold(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[VLA_I:%.*]] = alloca float, i64 15000, align 16
; CHECK-NEXT: [[COND:%.*]] = icmp eq i1 [[B:%.*]], true
; CHECK-NEXT: br i1 [[COND]], label [[EXIT:%.*]], label [[SPLIT:%.*]]
; CHECK: split:
; CHECK-NEXT: [[SAVEDSTACK:%.*]] = call i8* @llvm.stacksave()
; CHECK-NEXT: [[TMP0:%.*]] = bitcast float* [[VLA_I]] to i8*
; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 60000, i8* [[TMP0]])
; CHECK-NEXT: call void @extern_call(float* nonnull [[VLA_I]]) #3
; CHECK-NEXT: [[TMP1:%.*]] = bitcast float* [[VLA_I]] to i8*
; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 60000, i8* [[TMP1]])
; CHECK-NEXT: call void @llvm.stackrestore(i8* [[SAVEDSTACK]])
; CHECK-NEXT: [[SAVEDSTACK:%.*]] = call ptr @llvm.stacksave()
; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 60000, ptr [[VLA_I]])
; CHECK-NEXT: call void @extern_call(ptr nonnull [[VLA_I]]) #3
; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 60000, ptr [[VLA_I]])
; CHECK-NEXT: call void @llvm.stackrestore(ptr [[SAVEDSTACK]])
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
Expand All @@ -59,27 +57,27 @@ entry:
br i1 %cond, label %exit, label %split

split:
call void @callee(i8* %p1, i32 0, i32 15000)
call void @callee(ptr %p1, i32 0, i32 15000)
br label %exit

exit:
ret void
}

define void @callee2_not_in_entry(i8* %p1, i32 %l1, i32 %l2) {
define void @callee2_not_in_entry(ptr %p1, i32 %l1, i32 %l2) {
entry:
%ext = zext i32 %l2 to i64
%c = icmp eq i32 %l1, 42
br i1 %c, label %bb2, label %bb3
bb2:
%vla = alloca float, i64 %ext, align 16
call void @extern_call(float* nonnull %vla) #3
call void @extern_call(ptr nonnull %vla) #3
ret void
bb3:
ret void
}

define void @caller3_alloca_not_in_entry(i8 *%p1, i1 %b) {
define void @caller3_alloca_not_in_entry(ptr %p1, i1 %b) {
; CHECK-LABEL: @caller3_alloca_not_in_entry(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[COND:%.*]] = icmp eq i1 [[B:%.*]], true
Expand All @@ -94,20 +92,20 @@ entry:
br i1 %cond, label %exit, label %split

split:
call void @callee2_not_in_entry(i8* %p1, i32 0, i32 -1)
call void @callee2_not_in_entry(ptr %p1, i32 0, i32 -1)
br label %exit

exit:
ret void
}

define void @caller4_over_threshold(i8 *%p1, i1 %b, i32 %len) {
define void @caller4_over_threshold(ptr %p1, i1 %b, i32 %len) {
; CHECK-LABEL: @caller4_over_threshold(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[COND:%.*]] = icmp eq i1 [[B:%.*]], true
; CHECK-NEXT: br i1 [[COND]], label [[EXIT:%.*]], label [[SPLIT:%.*]]
; CHECK: split:
; CHECK-NEXT: call void @callee(i8* [[P1:%.*]], i32 0, i32 16500)
; CHECK-NEXT: call void @callee(ptr [[P1:%.*]], i32 0, i32 16500)
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
Expand All @@ -117,15 +115,15 @@ entry:
br i1 %cond, label %exit, label %split

split:
call void @callee(i8* %p1, i32 0, i32 16500)
call void @callee(ptr %p1, i32 0, i32 16500)
br label %exit

exit:
ret void
}

declare noalias i8* @malloc(i64)
define i8* @stack_allocate(i32 %size) #2 {
declare noalias ptr @malloc(i64)
define ptr @stack_allocate(i32 %size) #2 {
entry:
%cmp = icmp ult i32 %size, 100
%conv = zext i32 %size to i64
Expand All @@ -136,38 +134,38 @@ if.then: ; preds = %entry
br label %return

if.end: ; preds = %entry
%call = tail call i8* @malloc(i64 %conv) #3
%call = tail call ptr @malloc(i64 %conv) #3
br label %return

return: ; preds = %if.end, %if.then
%retval.0 = phi i8* [ %0, %if.then ], [ %call, %if.end ]
ret i8* %retval.0
%retval.0 = phi ptr [ %0, %if.then ], [ %call, %if.end ]
ret ptr %retval.0
}

define i8* @test_stack_allocate_always(i32 %size) {
define ptr @test_stack_allocate_always(i32 %size) {
; CHECK-LABEL: @test_stack_allocate_always(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[SAVEDSTACK:%.*]] = call i8* @llvm.stacksave()
; CHECK-NEXT: [[SAVEDSTACK:%.*]] = call ptr @llvm.stacksave()
; CHECK-NEXT: [[CMP_I:%.*]] = icmp ult i32 [[SIZE:%.*]], 100
; CHECK-NEXT: [[CONV_I:%.*]] = zext i32 [[SIZE]] to i64
; CHECK-NEXT: br i1 [[CMP_I]], label [[IF_THEN_I:%.*]], label [[IF_END_I:%.*]]
; CHECK: if.then.i:
; CHECK-NEXT: [[TMP0:%.*]] = alloca i8, i64 [[CONV_I]], align 8
; CHECK-NEXT: br label [[STACK_ALLOCATE_EXIT:%.*]]
; CHECK: if.end.i:
; CHECK-NEXT: [[CALL_I:%.*]] = tail call i8* @malloc(i64 [[CONV_I]]) #3
; CHECK-NEXT: [[CALL_I:%.*]] = tail call ptr @malloc(i64 [[CONV_I]]) #3
; CHECK-NEXT: br label [[STACK_ALLOCATE_EXIT]]
; CHECK: stack_allocate.exit:
; CHECK-NEXT: [[RETVAL_0_I:%.*]] = phi i8* [ [[TMP0]], [[IF_THEN_I]] ], [ [[CALL_I]], [[IF_END_I]] ]
; CHECK-NEXT: call void @llvm.stackrestore(i8* [[SAVEDSTACK]])
; CHECK-NEXT: ret i8* [[RETVAL_0_I]]
; CHECK-NEXT: [[RETVAL_0_I:%.*]] = phi ptr [ [[TMP0]], [[IF_THEN_I]] ], [ [[CALL_I]], [[IF_END_I]] ]
; CHECK-NEXT: call void @llvm.stackrestore(ptr [[SAVEDSTACK]])
; CHECK-NEXT: ret ptr [[RETVAL_0_I]]
;
entry:
%call = tail call i8* @stack_allocate(i32 %size)
ret i8* %call
%call = tail call ptr @stack_allocate(i32 %size)
ret ptr %call
}

declare void @extern_call(float*)
declare void @extern_call(ptr)

attributes #1 = { argmemonly nounwind willreturn writeonly }
attributes #2 = { alwaysinline }
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/Inline/dynamic_alloca_test.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
; once that functionality is restored.
; XFAIL: *

declare void @ext(i32*)
declare void @ext(ptr)

define internal void @callee(i32 %N) {
%P = alloca i32, i32 %N
call void @ext(i32* %P)
call void @ext(ptr %P)
ret void
}

define void @foo(i32 %N) {
; CHECK-LABEL: @foo(
; CHECK: alloca i32, i32 %{{.*}}
; CHECK: call i8* @llvm.stacksave()
; CHECK: call ptr @llvm.stacksave()
; CHECK: alloca i32, i32 %{{.*}}
; CHECK: call void @ext
; CHECK: call void @llvm.stackrestore
; CHECK: ret

entry:
%P = alloca i32, i32 %N
call void @ext(i32* %P)
call void @ext(ptr %P)
br label %loop

loop:
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/Transforms/Inline/ephemeral.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
; the instructions feeding the assume.
; CHECK: Analyzing call of inner...
; CHECK: NumInstructions: 2
define i32 @inner(i8* %y) {
%a1 = load volatile i32, i32* @a
define i32 @inner(ptr %y) {
%a1 = load volatile i32, ptr @a

; Because these instructions are used only by the @llvm.assume intrinsic,
; they're free and should not be included in the instruction count when
Expand All @@ -19,7 +19,7 @@ define i32 @inner(i8* %y) {
%a5 = mul i32 %a4, %a4
%a6 = add i32 %a5, %a5
%ca = icmp sgt i32 %a6, -7
%r = call i1 @llvm.type.test(i8* %y, metadata !0)
%r = call i1 @llvm.type.test(ptr %y, metadata !0)
%ca2 = icmp eq i1 %ca, %r
tail call void @llvm.assume(i1 %ca2)

Expand All @@ -30,20 +30,20 @@ define i32 @inner(i8* %y) {
; are both ephemeral.
; CHECK: Analyzing call of inner2...
; CHECK: NumInstructions: 1
define void @inner2(i8* %y) {
%v = load i8, i8* %y
define void @inner2(ptr %y) {
%v = load i8, ptr %y
%c = icmp eq i8 %v, 42
call void @llvm.assume(i1 %c)
ret void
}

define i32 @outer(i8* %y) optsize {
%r = call i32 @inner(i8* %y)
call void @inner2(i8* %y)
define i32 @outer(ptr %y) optsize {
%r = call i32 @inner(ptr %y)
call void @inner2(ptr %y)
ret i32 %r
}

declare void @llvm.assume(i1) nounwind
declare i1 @llvm.type.test(i8*, metadata) nounwind readnone
declare i1 @llvm.type.test(ptr, metadata) nounwind readnone

!0 = !{i32 0, !"typeid1"}
23 changes: 11 additions & 12 deletions llvm/test/Transforms/Inline/frameescape.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,31 @@
; PR23216: We can't inline functions using llvm.localescape.

declare void @llvm.localescape(...)
declare i8* @llvm.frameaddress(i32)
declare i8* @llvm.localrecover(i8*, i8*, i32)
declare ptr @llvm.frameaddress(i32)
declare ptr @llvm.localrecover(ptr, ptr, i32)

define internal void @foo(i8* %fp) {
%a.i8 = call i8* @llvm.localrecover(i8* bitcast (i32 ()* @bar to i8*), i8* %fp, i32 0)
%a = bitcast i8* %a.i8 to i32*
store i32 42, i32* %a
define internal void @foo(ptr %fp) {
%a.i8 = call ptr @llvm.localrecover(ptr @bar, ptr %fp, i32 0)
store i32 42, ptr %a.i8
ret void
}

define internal i32 @bar() {
entry:
%a = alloca i32
call void (...) @llvm.localescape(i32* %a)
%fp = call i8* @llvm.frameaddress(i32 0)
tail call void @foo(i8* %fp)
%r = load i32, i32* %a
call void (...) @llvm.localescape(ptr %a)
%fp = call ptr @llvm.frameaddress(i32 0)
tail call void @foo(ptr %fp)
%r = load i32, ptr %a
ret i32 %r
}

; We even bail when someone marks it alwaysinline.
define internal i32 @bar_alwaysinline() alwaysinline {
entry:
%a = alloca i32
call void (...) @llvm.localescape(i32* %a)
tail call void @foo(i8* null)
call void (...) @llvm.localescape(ptr %a)
tail call void @foo(ptr null)
ret i32 0
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Inline/function-count-update-3.ll
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define i32 @e(i32 %c1) !prof !4 {

cond_false:
call void @ext()
%c2 = load i32, i32* @data, align 4
%c2 = load i32, ptr @data, align 4
%c3 = add i32 %c1, %c2
%c4 = mul i32 %c3, %c2
%c5 = add i32 %c4, %c2
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/Transforms/Inline/gep_from_constant.ll
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
; RUN: opt < %s -passes="print<inline-cost>" 2>&1 | FileCheck %s

; CHECK-LABEL: @foo
; CHECK: cost before = {{.*}}, cost after = {{.*}}, threshold before = {{.*}}, threshold after = {{.*}}, cost delta = {{.*}}, simplified to i8 addrspace(1)** inttoptr (i64 754974760 to i8 addrspace(1)**)
; CHECK: cost before = {{.*}}, cost after = {{.*}}, threshold before = {{.*}}, threshold after = {{.*}}, cost delta = {{.*}}, simplified to ptr inttoptr (i64 754974760 to ptr)

define i8 addrspace(1)** @foo(i64 %0) {
%2 = inttoptr i64 754974720 to i8 addrspace(1)**
%3 = getelementptr i8 addrspace(1)*, i8 addrspace(1)** %2, i64 %0
ret i8 addrspace(1)** %3
define ptr @foo(i64 %0) {
%2 = inttoptr i64 754974720 to ptr
%3 = getelementptr ptr addrspace(1), ptr %2, i64 %0
ret ptr %3
}

define i8 addrspace(1)** @main() {
%1 = call i8 addrspace(1)** @foo(i64 5)
ret i8 addrspace(1)** %1
define ptr @main() {
%1 = call ptr @foo(i64 5)
ret ptr %1
}
8 changes: 4 additions & 4 deletions llvm/test/Transforms/Inline/gvn-inline-iteration.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
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"
target triple = "x86_64-apple-darwin10.0.0"

define i32 @foo(i32 ()** noalias nocapture %p, i64* noalias nocapture %q) nounwind ssp {
define i32 @foo(ptr noalias nocapture %p, ptr noalias nocapture %q) nounwind ssp {
entry:
store i32 ()* @bar, i32 ()** %p
store i64 0, i64* %q
%tmp3 = load i32 ()*, i32 ()** %p ; <i32 ()*> [#uses=1]
store ptr @bar, ptr %p
store i64 0, ptr %q
%tmp3 = load ptr, ptr %p ; <ptr> [#uses=1]
%call = tail call i32 %tmp3() nounwind ; <i32> [#uses=1]
ret i32 %call
}
Expand Down
32 changes: 14 additions & 18 deletions llvm/test/Transforms/Inline/inalloca-not-static.ll
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ target triple = "i386-pc-windows-msvc19.0.24210"

%struct.Foo = type { i32 }

declare i8* @llvm.stacksave()
declare void @llvm.stackrestore(i8*)
declare ptr @llvm.stacksave()
declare void @llvm.stackrestore(ptr)

declare x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@XZ"(%struct.Foo* returned) unnamed_addr
declare x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(%struct.Foo*) unnamed_addr
declare x86_thiscallcc ptr @"\01??0Foo@@QAE@XZ"(ptr returned) unnamed_addr
declare x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(ptr) unnamed_addr

define void @f() {
entry:
Expand All @@ -37,29 +37,25 @@ entry:

define internal void @g() alwaysinline {
entry:
%inalloca.save = call i8* @llvm.stacksave()
%inalloca.save = call ptr @llvm.stacksave()
%argmem = alloca inalloca <{ %struct.Foo }>, align 4
%0 = getelementptr inbounds <{ %struct.Foo }>, <{ %struct.Foo }>* %argmem, i32 0, i32 0
%call = call x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@XZ"(%struct.Foo* %0)
call void @h(<{ %struct.Foo }>* inalloca(<{ %struct.Foo }>) %argmem)
call void @llvm.stackrestore(i8* %inalloca.save)
%call = call x86_thiscallcc ptr @"\01??0Foo@@QAE@XZ"(ptr %argmem)
call void @h(ptr inalloca(<{ %struct.Foo }>) %argmem)
call void @llvm.stackrestore(ptr %inalloca.save)
ret void
}

; Function Attrs: alwaysinline inlinehint nounwind
define internal void @h(<{ %struct.Foo }>* inalloca(<{ %struct.Foo }>)) alwaysinline {
define internal void @h(ptr inalloca(<{ %struct.Foo }>)) alwaysinline {
entry:
%o = getelementptr inbounds <{ %struct.Foo }>, <{ %struct.Foo }>* %0, i32 0, i32 0
call x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(%struct.Foo* %o)
call x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(ptr %0)
ret void
}

; CHECK: define void @f()
; CHECK: %[[STACKSAVE:.*]] = call i8* @llvm.stacksave()
; CHECK: %[[STACKSAVE:.*]] = call ptr @llvm.stacksave()
; CHECK: %[[ARGMEM:.*]] = alloca inalloca <{ %struct.Foo }>, align 4
; CHECK: %[[GEP1:.*]] = getelementptr inbounds <{ %struct.Foo }>, <{ %struct.Foo }>* %[[ARGMEM]], i32 0, i32 0
; CHECK: %[[CALL:.*]] = call x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@XZ"(%struct.Foo* %[[GEP1]])
; CHECK: %[[GEP2:.*]] = getelementptr inbounds <{ %struct.Foo }>, <{ %struct.Foo }>* %[[ARGMEM]], i32 0, i32 0
; CHECK: call x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(%struct.Foo* %[[GEP2]])
; CHECK: call void @llvm.stackrestore(i8* %[[STACKSAVE]])
; CHECK: %[[CALL:.*]] = call x86_thiscallcc ptr @"\01??0Foo@@QAE@XZ"(ptr %[[ARGMEM]])
; CHECK: call x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(ptr %[[ARGMEM]])
; CHECK: call void @llvm.stackrestore(ptr %[[STACKSAVE]])
; CHECK: ret void
10 changes: 5 additions & 5 deletions llvm/test/Transforms/Inline/inline-assume.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
; RUN: opt -passes='module-inline' -S < %s | FileCheck %s

%0 = type opaque
%struct.Foo = type { i32, %0* }
%struct.Foo = type { i32, ptr }

; Test that we don't crash when inlining @bar (rdar://22521387).
define void @foo(%struct.Foo* align 4 %a) {
define void @foo(ptr align 4 %a) {
entry:
call fastcc void @bar(%struct.Foo* nonnull align 4 undef)
call fastcc void @bar(ptr nonnull align 4 undef)

; CHECK: call void @llvm.assume(i1 undef)
; CHECK: unreachable

ret void
}

define fastcc void @bar(%struct.Foo* align 4 %a) {
define fastcc void @bar(ptr align 4 %a) {
; CHECK-LABEL: @bar
entry:
%b = getelementptr inbounds %struct.Foo, %struct.Foo* %a, i32 0, i32 1
%b = getelementptr inbounds %struct.Foo, ptr %a, i32 0, i32 1
br i1 undef, label %if.end, label %if.then.i.i

if.then.i.i:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ target datalayout = "e-p3:32:32-p4:64:64-n32"
@lds = internal addrspace(3) global [64 x i64] zeroinitializer

; CHECK-LABEL: @constexpr_addrspacecast_ptr_size_change(
; CHECK: load i64, i64 addrspace(4)* addrspacecast (i64 addrspace(3)* getelementptr inbounds ([64 x i64], [64 x i64] addrspace(3)* @lds, i32 0, i32 0) to i64 addrspace(4)*)
; CHECK: load i64, ptr addrspace(4) addrspacecast (ptr addrspace(3) @lds to ptr addrspace(4))
; CHECK-NEXT: br
define void @constexpr_addrspacecast_ptr_size_change() #0 {
%tmp0 = call i32 @foo(i64 addrspace(4)* addrspacecast (i64 addrspace(3)* getelementptr inbounds ([64 x i64], [64 x i64] addrspace(3)* @lds, i32 0, i32 0) to i64 addrspace(4)*)) #1
%tmp0 = call i32 @foo(ptr addrspace(4) addrspacecast (ptr addrspace(3) @lds to ptr addrspace(4))) #1
ret void
}

define i32 @foo(i64 addrspace(4)* %arg) #1 {
define i32 @foo(ptr addrspace(4) %arg) #1 {
bb:
%tmp = getelementptr i64, i64 addrspace(4)* %arg, i64 undef
%tmp1 = load i64, i64 addrspace(4)* %tmp
%tmp = getelementptr i64, ptr addrspace(4) %arg, i64 undef
%tmp1 = load i64, ptr addrspace(4) %tmp
br i1 undef, label %bb2, label %bb3

bb2:
store i64 0, i64 addrspace(4)* %tmp
store i64 0, ptr addrspace(4) %tmp
br label %bb3

bb3:
Expand Down
20 changes: 10 additions & 10 deletions llvm/test/Transforms/Inline/inline-cost-annotation-pass.ll
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
; RUN: opt < %s -passes="print<inline-cost>" 2>&1 | FileCheck %s

; CHECK: Analyzing call of foo... (caller:main)
; CHECK: define i8 addrspace(1)** @foo() {
; CHECK: define ptr @foo() {
; CHECK: cost before = {{.*}}, cost after = {{.*}}, threshold before = {{.*}}, threshold after = {{.*}}, cost delta = {{.*}}
; CHECK: %1 = inttoptr i64 754974720 to i8 addrspace(1)**
; CHECK: %1 = inttoptr i64 754974720 to ptr
; CHECK: cost before = {{.*}}, cost after = {{.*}}, threshold before = {{.*}}, threshold after = {{.*}}, cost delta = {{.*}}
; CHECK: ret i8 addrspace(1)** %1
; CHECK: ret ptr %1
; CHECK: }
; CHECK: NumConstantArgs: {{.*}}
; CHECK: NumConstantOffsetPtrArgs: {{.*}}
Expand All @@ -23,13 +23,13 @@
; CHECK-EMPTY:
; CHECK: Analyzing call of foo... (caller:main)

define i8 addrspace(1)** @foo() {
%1 = inttoptr i64 754974720 to i8 addrspace(1)**
ret i8 addrspace(1)** %1
define ptr @foo() {
%1 = inttoptr i64 754974720 to ptr
ret ptr %1
}

define i8 addrspace(1)** @main() {
%1 = call i8 addrspace(1)** @foo()
%2 = call i8 addrspace(1)** @foo()
ret i8 addrspace(1)** %1
define ptr @main() {
%1 = call ptr @foo()
%2 = call ptr @foo()
ret ptr %1
}
10 changes: 5 additions & 5 deletions llvm/test/Transforms/Inline/inline-cost-dead-users.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
%0 = type { i64, i64, i64 }
%1 = type { i64, i64, i64 }

define internal void @f(%0* align 8 %a) unnamed_addr {
define internal void @f(ptr align 8 %a) unnamed_addr {
start:
ret void
}

define internal void @g(%0* align 8 %a) unnamed_addr {
define internal void @g(ptr align 8 %a) unnamed_addr {
start:
ret void
}

define void @h(%0* align 8 %a, %1* align 8 %b) unnamed_addr {
define void @h(ptr align 8 %a, ptr align 8 %b) unnamed_addr {
start:
call void @f(%0* align 8 %a)
call void bitcast (void (%0*)* @g to void (%1*)*)(%1* align 8 %b)
call void @f(ptr align 8 %a)
call void @g(ptr align 8 %b)
ret void
}
14 changes: 7 additions & 7 deletions llvm/test/Transforms/Inline/inline-fast-math-flags.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"

define float @foo(float* %a, float %b) {
define float @foo(ptr %a, float %b) {
entry:
%a0 = load float, float* %a, align 4
%a0 = load float, ptr %a, align 4
%mul = fmul fast float %a0, %b
%tobool = fcmp une float %mul, 0.000000e+00
br i1 %tobool, label %if.then, label %if.end

if.then: ; preds = %entry
%a1 = load float, float* %a, align 8
%arrayidx1 = getelementptr inbounds float, float* %a, i64 1
%a2 = load float, float* %arrayidx1, align 4
%a1 = load float, ptr %a, align 8
%arrayidx1 = getelementptr inbounds float, ptr %a, i64 1
%a2 = load float, ptr %arrayidx1, align 4
%add = fadd fast float %a1, %a2
br label %if.end

Expand All @@ -29,8 +29,8 @@ if.end: ; preds = %if.then, %entry

; CHECK-LABEL: @boo
; CHECK-NOT: call float @foo
define float @boo(float* %a) {
define float @boo(ptr %a) {
entry:
%call = call float @foo(float* %a, float 0.000000e+00)
%call = call float @foo(ptr %a, float 0.000000e+00)
ret float %call
}
32 changes: 16 additions & 16 deletions llvm/test/Transforms/Inline/inline-funclets.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare void @g()
;;; Test with a call in a funclet that needs to remain a call
;;; when inlined because the funclet doesn't unwind to caller.
;;; CHECK-LABEL: define void @test1(
define void @test1() personality void ()* @g {
define void @test1() personality ptr @g {
entry:
; CHECK-NEXT: entry:
invoke void @test1_inlinee()
Expand All @@ -20,7 +20,7 @@ exit:
ret void
}

define void @test1_inlinee() alwaysinline personality void ()* @g {
define void @test1_inlinee() alwaysinline personality ptr @g {
entry:
invoke void @g()
to label %exit unwind label %cleanup.inner
Expand Down Expand Up @@ -59,7 +59,7 @@ exit:
;;; that needs to remain "unwind to caller" because the parent
;;; doesn't unwind to caller.
;;; CHECK-LABEL: define void @test2(
define void @test2() personality void ()* @g {
define void @test2() personality ptr @g {
entry:
; CHECK-NEXT: entry:
invoke void @test2_inlinee()
Expand All @@ -72,7 +72,7 @@ exit:
ret void
}

define void @test2_inlinee() alwaysinline personality void ()* @g {
define void @test2_inlinee() alwaysinline personality ptr @g {
entry:
invoke void @g()
to label %exit unwind label %cleanup1
Expand Down Expand Up @@ -124,7 +124,7 @@ exit:
;;; Test with a call in a cleanup that has no definitive unwind
;;; destination, that must be rewritten to an invoke.
;;; CHECK-LABEL: define void @test3(
define void @test3() personality void ()* @g {
define void @test3() personality ptr @g {
entry:
; CHECK-NEXT: entry:
invoke void @test3_inlinee()
Expand All @@ -137,7 +137,7 @@ exit:
ret void
}

define void @test3_inlinee() alwaysinline personality void ()* @g {
define void @test3_inlinee() alwaysinline personality ptr @g {
entry:
invoke void @g()
to label %exit unwind label %cleanup
Expand All @@ -164,7 +164,7 @@ exit:
;;; unwind destination, that must be rewritten to unwind to the
;;; inlined invoke's unwind dest
;;; CHECK-LABEL: define void @test4(
define void @test4() personality void ()* @g {
define void @test4() personality ptr @g {
entry:
; CHECK-NEXT: entry:
invoke void @test4_inlinee()
Expand All @@ -177,7 +177,7 @@ exit:
ret void
}

define void @test4_inlinee() alwaysinline personality void ()* @g {
define void @test4_inlinee() alwaysinline personality ptr @g {
entry:
invoke void @g()
to label %exit unwind label %cleanup
Expand Down Expand Up @@ -214,7 +214,7 @@ exit:
;;; that need to be inferred from ancestors, descendants,
;;; and cousins.
;;; CHECK-LABEL: define void @test5(
define void @test5() personality void ()* @g {
define void @test5() personality ptr @g {
entry:
; CHECK-NEXT: entry:
invoke void @test5_inlinee()
Expand All @@ -227,7 +227,7 @@ exit:
ret void
}

define void @test5_inlinee() alwaysinline personality void ()* @g {
define void @test5_inlinee() alwaysinline personality ptr @g {
entry:
invoke void @g()
to label %cont unwind label %noinfo.root
Expand Down Expand Up @@ -416,7 +416,7 @@ exit:
;;; unwinds don't trip up processing of the ancestor nodes (left and root) that
;;; ultimately have no information.
;;; CHECK-LABEL: define void @test6(
define void @test6() personality void()* @ProcessCLRException {
define void @test6() personality ptr @ProcessCLRException {
entry:
; CHECK-NEXT: entry:
invoke void @test6_inlinee()
Expand All @@ -429,7 +429,7 @@ exit:
ret void
}

define void @test6_inlinee() alwaysinline personality void ()* @ProcessCLRException {
define void @test6_inlinee() alwaysinline personality ptr @ProcessCLRException {
entry:
invoke void @g()
to label %exit unwind label %root
Expand Down Expand Up @@ -531,7 +531,7 @@ exit:
;;; unwinds to another cousin (left.right); make sure we don't trip over this
;;; when propagating unwind destination info to "right".
;;; CHECK-LABEL: define void @test7(
define void @test7() personality void()* @ProcessCLRException {
define void @test7() personality ptr @ProcessCLRException {
entry:
; CHECK-NEXT: entry:
invoke void @test7_inlinee()
Expand All @@ -544,7 +544,7 @@ exit:
ret void
}

define void @test7_inlinee() alwaysinline personality void ()* @ProcessCLRException {
define void @test7_inlinee() alwaysinline personality ptr @ProcessCLRException {
entry:
invoke void @g()
to label %exit unwind label %root
Expand Down Expand Up @@ -636,7 +636,7 @@ declare void @ProcessCLRException()
; Make sure the logic doesn't get tripped up when the inlined invoke is
; itself within a funclet in the caller.
; CHECK-LABEL: define void @test8(
define void @test8() personality void ()* @ProcessCLRException {
define void @test8() personality ptr @ProcessCLRException {
entry:
invoke void @g()
to label %exit unwind label %callsite_parent
Expand All @@ -655,7 +655,7 @@ exit:
ret void
}

define void @test8_inlinee() alwaysinline personality void ()* @ProcessCLRException {
define void @test8_inlinee() alwaysinline personality ptr @ProcessCLRException {
entry:
invoke void @g()
to label %exit unwind label %inlinee_cleanup
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/Transforms/Inline/inline-hot-callsite.ll
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ define i32 @caller2(i32 %y1) {

declare i32 @__gxx_personality_v0(...)

define i32 @invoker2(i32 %y1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
define i32 @invoker2(i32 %y1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoker2(
; CHECK: invoke i32 @callee2
; CHECK-NOT: invoke i32 @callee1
Expand All @@ -54,11 +54,11 @@ exit:
ret i32 1

lpad:
%ll = landingpad { i8*, i32 } cleanup
%ll = landingpad { ptr, i32 } cleanup
ret i32 1
}

define i32 @invoker3(i32 %y1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
define i32 @invoker3(i32 %y1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoker3(
; CHECK: invoke i32 @callee2
; CHECK-NOT: invoke i32 @callee1
Expand All @@ -74,11 +74,11 @@ exit:
ret i32 1

lpad:
%ll = landingpad { i8*, i32 } cleanup
%ll = landingpad { ptr, i32 } cleanup
ret i32 1
}

define i32 @invoker4(i32 %y1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
define i32 @invoker4(i32 %y1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoker4(
; CHECK: invoke i32 @callee2
; CHECK-NOT: invoke i32 @callee1
Expand All @@ -94,7 +94,7 @@ exit:
ret i32 1

lpad:
%ll = landingpad { i8*, i32 } cleanup
%ll = landingpad { ptr, i32 } cleanup
ret i32 1
}

Expand Down
23 changes: 8 additions & 15 deletions llvm/test/Transforms/Inline/inline-indirect-chain.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,47 @@
; This test used to crash (PR35469).

define void @func1() {
%t = bitcast void ()* @func2 to void ()*
tail call void %t()
tail call void @func2()
ret void
}

define void @func2() {
%t = bitcast void ()* @func3 to void ()*
tail call void %t()
tail call void @func3()
ret void
}

define void @func3() {
%t = bitcast void ()* @func4 to void ()*
tail call void %t()
tail call void @func4()
ret void
}

define void @func4() {
br i1 undef, label %left, label %right

left:
%t = bitcast void ()* @func5 to void ()*
tail call void %t()
tail call void @func5()
ret void

right:
ret void
}

define void @func5() {
%t = bitcast void ()* @func6 to void ()*
tail call void %t()
tail call void @func6()
ret void
}

define void @func6() {
%t = bitcast void ()* @func2 to void ()*
tail call void %t()
tail call void @func2()
ret void
}

define void @func7() {
%t = bitcast void ()* @func3 to void ()*
tail call void @func8(void()* %t)
tail call void @func8(ptr @func3)
ret void
}

define void @func8(void()* %f) {
define void @func8(ptr %f) {
tail call void %f()
ret void
}
4 changes: 2 additions & 2 deletions llvm/test/Transforms/Inline/inline-indirect.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ define void @foo() {
ret void
}

define void @bar(void ()*) {
define void @bar(ptr) {
call void @llvm.assume(i1 true)
call void %0();
ret void
}

define void @baz() {
call void @bar(void ()* @foo)
call void @bar(ptr @foo)
ret void
}
28 changes: 13 additions & 15 deletions llvm/test/Transforms/Inline/inline-invoke-tail.ll
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
; RUN: opt < %s -passes=inline -S | not grep "tail call void @llvm.memcpy.p0i8.p0i8.i32"
; RUN: opt < %s -passes=inline -S | not grep "tail call void @llvm.memcpy.p0.p0.i32"
; PR3550

define internal void @foo(i32* %p, i32* %q) {
define internal void @foo(ptr %p, ptr %q) {
; CHECK-NOT: @foo
entry:
%pp = bitcast i32* %p to i8*
%qq = bitcast i32* %q to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %pp, i8* %qq, i32 4, i1 false)
tail call void @llvm.memcpy.p0.p0.i32(ptr %p, ptr %q, i32 4, i1 false)
ret void
}

define i32 @main() personality i32 (...)* @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @main() personality i32 (...)* @__gxx_personality_v0
define i32 @main() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @main() personality ptr @__gxx_personality_v0
entry:
%a = alloca i32
%b = alloca i32
store i32 1, i32* %a, align 4
store i32 0, i32* %b, align 4
invoke void @foo(i32* %a, i32* %b)
store i32 1, ptr %a, align 4
store i32 0, ptr %b, align 4
invoke void @foo(ptr %a, ptr %b)
to label %invcont unwind label %lpad
; CHECK-NOT: invoke
; CHECK-NOT: @foo
; CHECK-NOT: tail
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
; CHECK: call void @llvm.memcpy.p0.p0.i32
; CHECK: br

invcont:
%retval = load i32, i32* %a, align 4
%retval = load i32, ptr %a, align 4
ret i32 %retval

lpad:
%exn = landingpad {i8*, i32}
catch i8* null
%exn = landingpad {ptr, i32}
catch ptr null
unreachable
}

declare i32 @__gxx_personality_v0(...)

declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i1) nounwind
declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind
6 changes: 3 additions & 3 deletions llvm/test/Transforms/Inline/inline-invoke-with-asm-call.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ target triple = "x86_64-apple-darwin"
; Make sure we are generating "call asm" instead of "invoke asm".
; CHECK: call void asm
; CHECK-LABEL: @callee_with_asm
define void @caller() personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
define void @caller() personality ptr @__objc_personality_v0 {
br i1 undef, label %1, label %4

; <label>:1
invoke void @callee_with_asm()
to label %4 unwind label %2

; <label>:2
%3 = landingpad { i8*, i32 }
%3 = landingpad { ptr, i32 }
cleanup
resume { i8*, i32 } undef
resume { ptr, i32 } undef

; <label>:4
ret void
Expand Down
10 changes: 5 additions & 5 deletions llvm/test/Transforms/Inline/inline-optsize.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
; smaller than the inline threshold for optsize (75).
define i32 @inner() {
call void @extern()
%a1 = load volatile i32, i32* @a
%a1 = load volatile i32, ptr @a
%x1 = add i32 %a1, %a1
%a2 = load volatile i32, i32* @a
%a2 = load volatile i32, ptr @a
%x2 = add i32 %x1, %a2
%a3 = load volatile i32, i32* @a
%a3 = load volatile i32, ptr @a
%x3 = add i32 %x2, %a3
%a4 = load volatile i32, i32* @a
%a4 = load volatile i32, ptr @a
%x4 = add i32 %x3, %a4
%a5 = load volatile i32, i32* @a
%a5 = load volatile i32, ptr @a
%x5 = add i32 %x3, %a5
ret i32 %x5
}
Expand Down
20 changes: 10 additions & 10 deletions llvm/test/Transforms/Inline/inline-ptrtoint-different-sizes.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@
target datalayout = "p:16:16"
target triple = "x86_64-unknown-linux-gnu"

define void @pr47969_help(i16* %p) {
%cast = ptrtoint i16* %p to i32
define void @pr47969_help(ptr %p) {
%cast = ptrtoint ptr %p to i32
%sub = sub i32 %cast, %cast
%conv = trunc i32 %sub to i16
ret void
}

define void @pr47969(i16* %x) {
call void @pr47969_help(i16* %x)
define void @pr47969(ptr %x) {
call void @pr47969_help(ptr %x)
ret void
}

; CHECK-LABEL: @pr47969(i16* %x)
; CHECK-LABEL: @pr47969(ptr %x)
; CHECK-NOT: call
; CHECK: ret void

define void @pr38500_help(i16* %p) {
%cast = ptrtoint i16* %p to i32
define void @pr38500_help(ptr %p) {
%cast = ptrtoint ptr %p to i32
%sub = sub i32 %cast, %cast
%cmp = icmp eq i32 %sub, 0
ret void
}

define void @pr38500(i16* %x) {
call void @pr38500_help(i16* %x)
define void @pr38500(ptr %x) {
call void @pr38500_help(ptr %x)
ret void
}

; CHECK-LABEL: @pr38500(i16* %x)
; CHECK-LABEL: @pr38500(ptr %x)
; CHECK-NOT: call
; CHECK: ret void
9 changes: 4 additions & 5 deletions llvm/test/Transforms/Inline/inline-recur-stacksize.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
; RUN: opt < %s -passes=inline -S | FileCheck --check-prefixes=ALL,UNLIMITED %s
; RUN: opt < %s -passes=inline -S -recursive-inline-max-stacksize=256 | FileCheck --check-prefixes=ALL,LIMITED %s

declare void @init([65 x i32]*)
declare void @init(ptr)

define internal i32 @foo() {
%1 = alloca [65 x i32], align 16
%2 = getelementptr inbounds [65 x i32], [65 x i32]* %1, i65 0, i65 0
call void @init([65 x i32]* %1)
%3 = load i32, i32* %2, align 4
ret i32 %3
call void @init(ptr %1)
%2 = load i32, ptr %1, align 4
ret i32 %2
}

define i32 @bar() {
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/Inline/inline-remark-mandatory.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
declare void @personalityFn1();
declare void @personalityFn2();

define i32 @a() personality void ()* @personalityFn1 {
define i32 @a() personality ptr @personalityFn1 {
ret i32 1
}

define i32 @b() personality void ()* @personalityFn2 {
define i32 @b() personality ptr @personalityFn2 {
%r = call i32 @a() alwaysinline
ret i32 %r
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Inline/inline-remark.ll
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ define void @noop() {
}

;; Test 2 - Printed InlineResult messages are followed by InlineCost.
define void @test2(i8*) {
define void @test2(ptr) {
; CHECK-LABEL: @test2
; CHECK-NEXT: call void @noop() [[ATTR3:#[0-9]+]] [ "CUSTOM_OPERAND_BUNDLE"() ]
; CHECK-NEXT: ret void
Expand Down
Loading