[llvm] 2fe0feb - [LLVM][AsmWriter] Print a comment for unknown intrinsics (#146726)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 10:02:30 PDT 2025
Author: Rahul Joshi
Date: 2025-07-02T10:02:26-07:00
New Revision: 2fe0feb84875189478d8dd998cc992fa76562709
URL: https://github.com/llvm/llvm-project/commit/2fe0feb84875189478d8dd998cc992fa76562709
DIFF: https://github.com/llvm/llvm-project/commit/2fe0feb84875189478d8dd998cc992fa76562709.diff
LOG: [LLVM][AsmWriter] Print a comment for unknown intrinsics (#146726)
Unknown intrinsics are functions that begin with `llvm.` but are not an
intrinsic that is recognized by LLVM. Add a comment before such
functions in LLVM IR assembly to indicate that they are unknown
intrinsics.
Added:
Modified:
llvm/lib/IR/AsmWriter.cpp
llvm/test/Feature/intrinsics.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index af268b4fc6941..b21f4347f34d3 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4129,6 +4129,9 @@ void AssemblyWriter::printFunction(const Function *F) {
Out << "; Function Attrs: " << AttrStr << '\n';
}
+ if (F->isIntrinsic() && F->getIntrinsicID() == Intrinsic::not_intrinsic)
+ Out << "; Unknown intrinsic\n";
+
Machine.incorporateFunction(F);
if (F->isDeclaration()) {
diff --git a/llvm/test/Feature/intrinsics.ll b/llvm/test/Feature/intrinsics.ll
index 49fed0981bd76..b6abc0fff6db7 100644
--- a/llvm/test/Feature/intrinsics.ll
+++ b/llvm/test/Feature/intrinsics.ll
@@ -3,8 +3,12 @@
; RUN:
diff %t1.ll %t2.ll
; RUN: FileCheck %s < %t1.ll
+; CHECK: Unknown intrinsic
+; CHECK-NEXT: declare i1 @llvm.isunordered.f32(float, float)
declare i1 @llvm.isunordered.f32(float, float)
+; CHECK: Unknown intrinsic
+; CHECK-NEXT: declare i1 @llvm.isunordered.f64(double, double)
declare i1 @llvm.isunordered.f64(double, double)
@@ -60,7 +64,6 @@ define void @libm() {
; FIXME: test ALL the intrinsics in this file.
-; rdar://11542750
; CHECK: declare void @llvm.trap() #1
declare void @llvm.trap()
More information about the llvm-commits
mailing list