[llvm] Add a pass to convert jump tables to switches. (PR #77709)

Alexander Shaposhnikov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 03:30:17 PST 2024


================
@@ -0,0 +1,94 @@
+; RUN: opt < %s -passes=jump-table-to-switch -verify-dom-info -S | FileCheck %s
+; RUN: opt < %s -passes=jump-table-to-switch -jump-table-to-switch-size-threshold=0 -verify-dom-info -S | FileCheck %s --check-prefix=THRESHOLD-0
+
+ at func_array = global [2 x ptr] [ptr @func0, ptr @func1]
+
+define i32 @func0() {
+  ret i32 1
+}
+
+define i32 @func1() {
+  ret i32 2
+}
+
+define i32 @function_with_jump_table(i32 %index) {
+  %gep = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 %index
+  %func_ptr = load ptr, ptr %gep
----------------
alexander-shaposhnikov wrote:

Done

https://github.com/llvm/llvm-project/pull/77709


More information about the llvm-commits mailing list