1; RUN: opt -S -mergefunc < %s | FileCheck %s 2 3; Minor note: functions need to be at least three instructions long 4; to be considered by -mergefunc. 5 6declare i32 @foo(...) 7 8define i32 @f() { 9; CHECK-LABEL: @f( 10 entry: 11 %v0 = call i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 12 %v1 = call i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 13 %v2 = call i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 14 15; CHECK: %v0 = call i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 16; CHECK: %v1 = call i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 17; CHECK: %v2 = call i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 18 19 ret i32 %v2 20} 21 22define i32 @g() { 23; CHECK-LABEL: @g( 24 entry: 25 %v0 = call i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 26 %v1 = call i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 27 %v2 = call i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 28 29; CHECK: %v0 = call i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 30; CHECK: %v1 = call i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 31; CHECK: %v2 = call i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 32 33 ret i32 %v2 34} 35 36define i32 @f.invoke() personality i8 3 { 37; CHECK-LABEL: @f.invoke( 38 entry: 39; CHECK: %v0 = invoke i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 40 %v0 = invoke i32 (...) @foo(i32 10) [ "foo"(i32 20) ] 41 to label %normal unwind label %exception 42 43 normal: 44 ret i32 %v0 45 46 exception: 47 %cleanup = landingpad i8 cleanup 48 ret i32 0 49} 50 51define i32 @g.invoke() personality i8 3 { 52; CHECK-LABEL: @g.invoke( 53 entry: 54; CHECK: %v0 = invoke i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 55 %v0 = invoke i32 (...) @foo() [ "foo"(i32 10, i32 20) ] 56 to label %normal unwind label %exception 57 58 normal: 59 ret i32 %v0 60 61 exception: 62 %cleanup = landingpad i8 cleanup 63 ret i32 0 64} 65