xref: /llvm-project/llvm/test/Transforms/JumpTableToSwitch/max_function_size.ll (revision d26b43ff4f7396f79de4b099160262c750d6aba7)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2; RUN: opt < %s -passes=jump-table-to-switch -jump-table-to-switch-function-size-threshold=1 -verify-dom-info -S | FileCheck %s
3
4@func_array0 = constant [2 x ptr] [ptr @func0, ptr @large_func]
5
6define i32 @func0() {
7  ret i32 1
8}
9
10define i32 @large_func() {
11  %x = add i32 1, 2
12  ret i32 %x
13}
14
15define i32 @function_with_jump_table_with_large_func(i32 %index) {
16; CHECK-LABEL: define i32 @function_with_jump_table_with_large_func(
17; CHECK-SAME: i32 [[INDEX:%.*]]) {
18; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 [[INDEX]]
19; CHECK-NEXT:    [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
20; CHECK-NEXT:    [[RESULT:%.*]] = call i32 [[FUNC_PTR]]()
21; CHECK-NEXT:    ret i32 [[RESULT]]
22;
23  %gep = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 %index
24  %func_ptr = load ptr, ptr %gep, align 8
25  %result = call i32 %func_ptr()
26  ret i32 %result
27}
28
29