[llvm] [SelectionDAG] Mark LowerTypeTests as required and remove intrinsic handling from #142939 (PR #179249)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 3 05:10:50 PST 2026
https://github.com/keremsahn updated https://github.com/llvm/llvm-project/pull/179249
>From 7af40c19286469c05cf8008aafcd08b31b04f5df Mon Sep 17 00:00:00 2001
From: keremsahn <keremsahin401 at gmail.com>
Date: Mon, 2 Feb 2026 17:36:24 +0300
Subject: [PATCH] [SelectionDAG] Mark LowerTypeTests as required and remove
intrinsic handling. Marked LowerTypeTestsPass as required to prevent it from
being skipped by pass bisection. Intrinsic from #142939 that handling
llvm.type.test is removed. Updated pr142937.ll to verify the error message
when intrinsics are not properly lowered.
---
.../llvm/Transforms/IPO/LowerTypeTests.h | 1 +
.../SelectionDAG/SelectionDAGBuilder.cpp | 3 +-
llvm/test/CodeGen/X86/pr142937.ll | 39 ++-----------------
.../test/Other/opt-bisect-new-pass-manager.ll | 12 ++++++
4 files changed, 19 insertions(+), 36 deletions(-)
diff --git a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
index a34cbaf72675b..bb8b40955077e 100644
--- a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
+++ b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
@@ -218,6 +218,7 @@ class LowerTypeTestsPass : public PassInfoMixin<LowerTypeTestsPass> {
lowertypetests::DropTestKind::None)
: ExportSummary(ExportSummary), ImportSummary(ImportSummary),
DropTypeTests(DropTypeTests) {}
+ static bool isRequired() { return true; }
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 52e0d8fefdf2f..7814b57e24890 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7524,7 +7524,8 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
case Intrinsic::type_test:
case Intrinsic::public_type_test:
- setValue(&I, getValue(ConstantInt::getTrue(I.getType())));
+ reportFatalUsageError("llvm.type.test intrinsic must be lowered by the "
+ "LowerTypeTests pass before code generation");
return;
case Intrinsic::assume:
diff --git a/llvm/test/CodeGen/X86/pr142937.ll b/llvm/test/CodeGen/X86/pr142937.ll
index 8be99e102ff5b..8001da4efcc6c 100644
--- a/llvm/test/CodeGen/X86/pr142937.ll
+++ b/llvm/test/CodeGen/X86/pr142937.ll
@@ -1,19 +1,10 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
-; RUN: llc < %s -mtriple=i686-- -O0 | FileCheck %s --check-prefix=X86
-; RUN: llc < %s -mtriple=x86_64-- -O0 | FileCheck %s --check-prefix=X64
+; RUN: not llc %s -mtriple=i686-- -O0 2>&1 | FileCheck %s
+; RUN: not llc %s -mtriple=x86_64-- -O0 2>&1 | FileCheck %s
+
+; CHECK: must be lowered by the LowerTypeTests pass
define void @public_type_test() {
-; X86-LABEL: public_type_test:
-; X86: # %bb.0: # %bb
-; X86-NEXT: movb $1, %al
-; X86-NEXT: # %bb.1: # %bb1
-; X86-NEXT: retl
-;
-; X64-LABEL: public_type_test:
-; X64: # %bb.0: # %bb
-; X64-NEXT: movb $1, %al
-; X64-NEXT: # %bb.1: # %bb1
-; X64-NEXT: retq
bb:
%call = call i1 @llvm.public.type.test(ptr null, metadata !"typeinfo")
br label %bb1
@@ -24,25 +15,6 @@ bb1:
}
define void @type_test() {
-; X86-LABEL: type_test:
-; X86: # %bb.0: # %bb
-; X86-NEXT: movb $1, %al
-; X86-NEXT: testb $1, %al
-; X86-NEXT: jne .LBB1_2
-; X86-NEXT: # %bb.1: # %bb1
-; X86-NEXT: ud1l 2(%eax), %eax
-; X86-NEXT: .LBB1_2: # %bb2
-; X86-NEXT: retl
-;
-; X64-LABEL: type_test:
-; X64: # %bb.0: # %bb
-; X64-NEXT: movb $1, %al
-; X64-NEXT: testb $1, %al
-; X64-NEXT: jne .LBB1_2
-; X64-NEXT: # %bb.1: # %bb1
-; X64-NEXT: ud1l 2(%eax), %eax
-; X64-NEXT: .LBB1_2: # %bb2
-; X64-NEXT: retq
bb:
%call = tail call i1 @llvm.type.test(ptr null, metadata !"typeinfo")
br i1 %call, label %bb2, label %bb1
@@ -56,9 +28,6 @@ bb2:
}
declare i1 @llvm.public.type.test(ptr, metadata)
-
declare void @llvm.assume(i1 noundef)
-
declare i1 @llvm.type.test(ptr, metadata)
-
declare void @llvm.ubsantrap(i8 immarg)
diff --git a/llvm/test/Other/opt-bisect-new-pass-manager.ll b/llvm/test/Other/opt-bisect-new-pass-manager.ll
index 8f8078d4d8409..8e7915bd0db75 100644
--- a/llvm/test/Other/opt-bisect-new-pass-manager.ll
+++ b/llvm/test/Other/opt-bisect-new-pass-manager.ll
@@ -90,6 +90,18 @@
; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (8) function-attrs on (f4)
; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (9) early-cse on f4
+; RUN: opt -disable-output -debug-pass-manager \
+; RUN: -passes=lowertypetests -opt-bisect-limit=-1 %s 2>&1 \
+; RUN: | FileCheck %s --check-prefix=LTT-ALL
+; LTT-ALL-NOT: BISECT: {{.*}}LowerTypeTestsPass
+; LTT-ALL: Running pass: LowerTypeTestsPass
+
+; RUN: opt -disable-output -debug-pass-manager \
+; RUN: -passes=lowertypetests -opt-bisect-limit=0 %s 2>&1 \
+; RUN: | FileCheck %s --check-prefix=LTT-REQUIRED
+; LTT-REQUIRED-NOT: BISECT: {{.*}}LowerTypeTestsPass
+; LTT-REQUIRED: Running pass: LowerTypeTestsPass
+
; Make sure we don't skip writing the output to stdout.
; RUN: opt %s -opt-bisect-limit=0 -passes=early-cse | opt -S | FileCheck %s -check-prefix=CHECK-OUTPUT
; RUN: opt %s -opt-bisect-limit=0 -passes=early-cse -S | FileCheck %s -check-prefix=CHECK-OUTPUT
More information about the llvm-commits
mailing list