1 ; Test function specialization wouldn't crash due to constant expression.
2 ; Note that this test case shows that function specialization pass would
3 ; transform the function even if no specialization happened.
4 ; RUN: opt -function-specialization -S < %s | FileCheck %s
7 ; CHECK-NEXT: %{{.*}} = call i64 @func2(i64* getelementptr inbounds (%struct, %struct* @Global, i32 0, i32 3))
9 ; CHECK-NEXT: %{{.*}} = call i64 @func2(i64* getelementptr inbounds (%struct, %struct* @Global, i32 0, i32 4))
11 %struct = type { i8, i16, i32, i64, i64}
12 @Global = internal constant %struct {i8 0, i16 1, i32 2, i64 3, i64 4}
13 define internal i64 @zoo(i1 %flag) {
15 br i1 %flag, label %plus, label %minus
18 %arg = getelementptr %struct, %struct* @Global, i32 0, i32 3
19 %tmp0 = call i64 @func2(i64* %arg)
23 %arg2 = getelementptr %struct, %struct* @Global, i32 0, i32 4
24 %tmp1 = call i64 @func2(i64* %arg2)
28 %tmp2 = phi i64 [ %tmp0, %plus ], [ %tmp1, %minus]
32 define internal i64 @func2(i64 *%x) {
34 %val = ptrtoint i64* %x to i64
38 define internal i64 @func(i64 *%x, i64 (i64*)* %binop) {
40 %tmp0 = call i64 %binop(i64* %x)
45 %1 = call i64 @zoo(i1 0)
46 %2 = call i64 @zoo(i1 1)