[llvm-branch-commits] [LowerTypeTests] Add AArch64 and X86 jump table tests with debug info (PR #192735)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 17 13:54:19 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

Just precommit test to claim the space.


---
Full diff: https://github.com/llvm/llvm-project/pull/192735.diff


3 Files Affected:

- (modified) llvm/lib/Transforms/IPO/LowerTypeTests.cpp (+6) 
- (modified) llvm/test/Transforms/LowerTypeTests/aarch64-jumptable.ll (+37) 
- (modified) llvm/test/Transforms/LowerTypeTests/x86-jumptable.ll (+72) 


``````````diff
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 323df2a6a0abf..a390b983b1ded 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -35,6 +35,7 @@
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
@@ -123,6 +124,11 @@ static cl::opt<std::string> ClWriteSummary(
     cl::desc("Write summary to given YAML file after running pass"),
     cl::Hidden);
 
+static cl::opt<bool>
+    ClAnnotateDebugInfo("lowertypetests-annotate-debug-info",
+                        cl::desc("Create debug info for generate function"),
+                        cl::Hidden);
+
 bool BitSetInfo::containsGlobalOffset(uint64_t Offset) const {
   if (Offset < ByteOffset)
     return false;
diff --git a/llvm/test/Transforms/LowerTypeTests/aarch64-jumptable.ll b/llvm/test/Transforms/LowerTypeTests/aarch64-jumptable.ll
index b6dc739ce1e0c..00c11b5b85bc7 100644
--- a/llvm/test/Transforms/LowerTypeTests/aarch64-jumptable.ll
+++ b/llvm/test/Transforms/LowerTypeTests/aarch64-jumptable.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals --include-generated-funcs
 ; RUN: opt -S -passes=lowertypetests -mtriple=aarch64-unknown-linux-gnu %s | FileCheck --check-prefixes=AARCH64 %s
+; RUN: opt -S -passes=lowertypetests -lowertypetests-annotate-debug-info -mtriple=aarch64-unknown-linux-gnu %s | FileCheck --check-prefixes=AARCH64_DBG %s
 
 ; Test for the jump table generation with branch protection on AArch64
 
@@ -36,6 +37,11 @@ define i1 @foo(ptr %p) {
 ; AARCH64: @f = alias [8 x i8], ptr @.cfi.jumptable
 ; AARCH64: @g = internal alias [8 x i8], getelementptr inbounds ([2 x [8 x i8]], ptr @.cfi.jumptable, i64 0, i64 1)
 ;.
+; AARCH64_DBG: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16
+; AARCH64_DBG: @[[GLOB1:[0-9]+]] = private constant [0 x i8] zeroinitializer
+; AARCH64_DBG: @f = alias [8 x i8], ptr @.cfi.jumptable
+; AARCH64_DBG: @g = internal alias [8 x i8], getelementptr inbounds ([2 x [8 x i8]], ptr @.cfi.jumptable, i64 0, i64 1)
+;.
 ; AARCH64-LABEL: @f.cfi(
 ; AARCH64-NEXT:    ret void
 ;
@@ -59,11 +65,42 @@ define i1 @foo(ptr %p) {
 ; AARCH64-NEXT:    call void asm sideeffect "bti c\0Ab $0\0A", "s"(ptr @g.cfi)
 ; AARCH64-NEXT:    unreachable
 ;
+;
+; AARCH64_DBG-LABEL: @f.cfi(
+; AARCH64_DBG-NEXT:    ret void
+;
+;
+; AARCH64_DBG-LABEL: @g.cfi(
+; AARCH64_DBG-NEXT:    ret void
+;
+;
+; AARCH64_DBG-LABEL: @foo(
+; AARCH64_DBG-NEXT:    [[TMP1:%.*]] = ptrtoint ptr [[P:%.*]] to i64
+; AARCH64_DBG-NEXT:    [[TMP2:%.*]] = sub i64 ptrtoint (ptr getelementptr (i8, ptr @.cfi.jumptable, i64 8) to i64), [[TMP1]]
+; AARCH64_DBG-NEXT:    [[TMP3:%.*]] = call i64 @llvm.fshr.i64(i64 [[TMP2]], i64 [[TMP2]], i64 3)
+; AARCH64_DBG-NEXT:    [[TMP4:%.*]] = icmp ule i64 [[TMP3]], 1
+; AARCH64_DBG-NEXT:    ret i1 [[TMP4]]
+;
+;
+; AARCH64_DBG: Function Attrs: naked noinline
+; AARCH64_DBG-LABEL: @.cfi.jumptable(
+; AARCH64_DBG-NEXT:  entry:
+; AARCH64_DBG-NEXT:    call void asm sideeffect "bti c\0Ab $0\0A", "s"(ptr @f.cfi)
+; AARCH64_DBG-NEXT:    call void asm sideeffect "bti c\0Ab $0\0A", "s"(ptr @g.cfi)
+; AARCH64_DBG-NEXT:    unreachable
+;
 ;.
 ; AARCH64: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
 ; AARCH64: attributes #[[ATTR1:[0-9]+]] = { naked noinline }
 ; AARCH64: attributes #[[ATTR2:[0-9]+]] = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
 ;.
+; AARCH64_DBG: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+; AARCH64_DBG: attributes #[[ATTR1:[0-9]+]] = { naked noinline }
+; AARCH64_DBG: attributes #[[ATTR2:[0-9]+]] = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
+;.
 ; AARCH64: [[META0:![0-9]+]] = !{i32 4, !"branch-target-enforcement", i32 1}
 ; AARCH64: [[META1:![0-9]+]] = !{i32 0, !"typeid1"}
 ;.
+; AARCH64_DBG: [[META0:![0-9]+]] = !{i32 4, !"branch-target-enforcement", i32 1}
+; AARCH64_DBG: [[META1:![0-9]+]] = !{i32 0, !"typeid1"}
+;.
diff --git a/llvm/test/Transforms/LowerTypeTests/x86-jumptable.ll b/llvm/test/Transforms/LowerTypeTests/x86-jumptable.ll
index 74c3e2e108a5e..4a8cb0166cc12 100644
--- a/llvm/test/Transforms/LowerTypeTests/x86-jumptable.ll
+++ b/llvm/test/Transforms/LowerTypeTests/x86-jumptable.ll
@@ -2,6 +2,8 @@
 ;; Test jump table generation with Indirect Branch Tracking on x86.
 ; RUN: opt -S -passes=lowertypetests -mtriple=i686 %s | FileCheck --check-prefixes=X86_32 %s
 ; RUN: opt -S -passes=lowertypetests -mtriple=x86_64 %s | FileCheck --check-prefixes=X86_64 %s
+; RUN: opt -S -passes=lowertypetests -lowertypetests-annotate-debug-info -mtriple=i686 %s | FileCheck --check-prefixes=X86_32_DBG %s
+; RUN: opt -S -passes=lowertypetests -lowertypetests-annotate-debug-info -mtriple=x86_64 %s | FileCheck --check-prefixes=X86_64_DBG %s
 
 @0 = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16
 
@@ -36,6 +38,16 @@ define i1 @foo(ptr %p) {
 ; X86_64: @f = alias [16 x i8], ptr @.cfi.jumptable
 ; X86_64: @g = internal alias [16 x i8], getelementptr inbounds ([2 x [16 x i8]], ptr @.cfi.jumptable, i64 0, i64 1)
 ;.
+; X86_32_DBG: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16
+; X86_32_DBG: @[[GLOB1:[0-9]+]] = private constant [0 x i8] zeroinitializer
+; X86_32_DBG: @f = alias [16 x i8], ptr @.cfi.jumptable
+; X86_32_DBG: @g = internal alias [16 x i8], getelementptr inbounds ([2 x [16 x i8]], ptr @.cfi.jumptable, i32 0, i32 1)
+;.
+; X86_64_DBG: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16
+; X86_64_DBG: @[[GLOB1:[0-9]+]] = private constant [0 x i8] zeroinitializer
+; X86_64_DBG: @f = alias [16 x i8], ptr @.cfi.jumptable
+; X86_64_DBG: @g = internal alias [16 x i8], getelementptr inbounds ([2 x [16 x i8]], ptr @.cfi.jumptable, i64 0, i64 1)
+;.
 ; X86_32-LABEL: @f.cfi(
 ; X86_32-NEXT:    ret void
 ;
@@ -81,6 +93,52 @@ define i1 @foo(ptr %p) {
 ; X86_64-NEXT:    call void asm sideeffect "endbr64\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @g.cfi)
 ; X86_64-NEXT:    unreachable
 ;
+;
+; X86_32_DBG-LABEL: @f.cfi(
+; X86_32_DBG-NEXT:    ret void
+;
+;
+; X86_32_DBG-LABEL: @g.cfi(
+; X86_32_DBG-NEXT:    ret void
+;
+;
+; X86_32_DBG-LABEL: @foo(
+; X86_32_DBG-NEXT:    [[TMP1:%.*]] = ptrtoint ptr [[P:%.*]] to i32
+; X86_32_DBG-NEXT:    [[TMP2:%.*]] = sub i32 ptrtoint (ptr getelementptr (i8, ptr @.cfi.jumptable, i32 16) to i32), [[TMP1]]
+; X86_32_DBG-NEXT:    [[TMP3:%.*]] = call i32 @llvm.fshr.i32(i32 [[TMP2]], i32 [[TMP2]], i32 4)
+; X86_32_DBG-NEXT:    [[TMP4:%.*]] = icmp ule i32 [[TMP3]], 1
+; X86_32_DBG-NEXT:    ret i1 [[TMP4]]
+;
+;
+; X86_32_DBG-LABEL: @.cfi.jumptable(
+; X86_32_DBG-NEXT:  entry:
+; X86_32_DBG-NEXT:    call void asm sideeffect "endbr32\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @f.cfi)
+; X86_32_DBG-NEXT:    call void asm sideeffect "endbr32\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @g.cfi)
+; X86_32_DBG-NEXT:    unreachable
+;
+;
+; X86_64_DBG-LABEL: @f.cfi(
+; X86_64_DBG-NEXT:    ret void
+;
+;
+; X86_64_DBG-LABEL: @g.cfi(
+; X86_64_DBG-NEXT:    ret void
+;
+;
+; X86_64_DBG-LABEL: @foo(
+; X86_64_DBG-NEXT:    [[TMP1:%.*]] = ptrtoint ptr [[P:%.*]] to i64
+; X86_64_DBG-NEXT:    [[TMP2:%.*]] = sub i64 ptrtoint (ptr getelementptr (i8, ptr @.cfi.jumptable, i64 16) to i64), [[TMP1]]
+; X86_64_DBG-NEXT:    [[TMP3:%.*]] = call i64 @llvm.fshr.i64(i64 [[TMP2]], i64 [[TMP2]], i64 4)
+; X86_64_DBG-NEXT:    [[TMP4:%.*]] = icmp ule i64 [[TMP3]], 1
+; X86_64_DBG-NEXT:    ret i1 [[TMP4]]
+;
+;
+; X86_64_DBG-LABEL: @.cfi.jumptable(
+; X86_64_DBG-NEXT:  entry:
+; X86_64_DBG-NEXT:    call void asm sideeffect "endbr64\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @f.cfi)
+; X86_64_DBG-NEXT:    call void asm sideeffect "endbr64\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @g.cfi)
+; X86_64_DBG-NEXT:    unreachable
+;
 ;.
 ; X86_32: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
 ; X86_32: attributes #[[ATTR1:[0-9]+]] = { naked nocf_check noinline }
@@ -90,9 +148,23 @@ define i1 @foo(ptr %p) {
 ; X86_64: attributes #[[ATTR1:[0-9]+]] = { naked nocf_check noinline }
 ; X86_64: attributes #[[ATTR2:[0-9]+]] = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
 ;.
+; X86_32_DBG: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+; X86_32_DBG: attributes #[[ATTR1:[0-9]+]] = { naked nocf_check noinline }
+; X86_32_DBG: attributes #[[ATTR2:[0-9]+]] = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
+;.
+; X86_64_DBG: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+; X86_64_DBG: attributes #[[ATTR1:[0-9]+]] = { naked nocf_check noinline }
+; X86_64_DBG: attributes #[[ATTR2:[0-9]+]] = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
+;.
 ; X86_32: [[META0:![0-9]+]] = !{i32 8, !"cf-protection-branch", i32 1}
 ; X86_32: [[META1:![0-9]+]] = !{i32 0, !"typeid1"}
 ;.
 ; X86_64: [[META0:![0-9]+]] = !{i32 8, !"cf-protection-branch", i32 1}
 ; X86_64: [[META1:![0-9]+]] = !{i32 0, !"typeid1"}
 ;.
+; X86_32_DBG: [[META0:![0-9]+]] = !{i32 8, !"cf-protection-branch", i32 1}
+; X86_32_DBG: [[META1:![0-9]+]] = !{i32 0, !"typeid1"}
+;.
+; X86_64_DBG: [[META0:![0-9]+]] = !{i32 8, !"cf-protection-branch", i32 1}
+; X86_64_DBG: [[META1:![0-9]+]] = !{i32 0, !"typeid1"}
+;.

``````````

</details>


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


More information about the llvm-branch-commits mailing list