[llvm] [LLVM][AsmWriter] Print a comment for unknown intrinsics (PR #146726)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 10:00:31 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Rahul Joshi (jurahul)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/146726.diff
2 Files Affected:
- (modified) llvm/lib/IR/AsmWriter.cpp (+3)
- (modified) llvm/test/Feature/intrinsics.ll (+4-1)
``````````diff
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()
``````````
</details>
https://github.com/llvm/llvm-project/pull/146726
More information about the llvm-commits
mailing list