Skip to content

Commit 2fe0feb

Browse files
authored
[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.
1 parent b62826c commit 2fe0feb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

llvm/lib/IR/AsmWriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4129,6 +4129,9 @@ void AssemblyWriter::printFunction(const Function *F) {
41294129
Out << "; Function Attrs: " << AttrStr << '\n';
41304130
}
41314131

4132+
if (F->isIntrinsic() && F->getIntrinsicID() == Intrinsic::not_intrinsic)
4133+
Out << "; Unknown intrinsic\n";
4134+
41324135
Machine.incorporateFunction(F);
41334136

41344137
if (F->isDeclaration()) {

llvm/test/Feature/intrinsics.ll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
; RUN: diff %t1.ll %t2.ll
44
; RUN: FileCheck %s < %t1.ll
55

6+
; CHECK: Unknown intrinsic
7+
; CHECK-NEXT: declare i1 @llvm.isunordered.f32(float, float)
68
declare i1 @llvm.isunordered.f32(float, float)
79

10+
; CHECK: Unknown intrinsic
11+
; CHECK-NEXT: declare i1 @llvm.isunordered.f64(double, double)
812
declare i1 @llvm.isunordered.f64(double, double)
913

1014

@@ -60,7 +64,6 @@ define void @libm() {
6064

6165
; FIXME: test ALL the intrinsics in this file.
6266

63-
; rdar://11542750
6467
; CHECK: declare void @llvm.trap() #1
6568
declare void @llvm.trap()
6669

0 commit comments

Comments
 (0)