Skip to content

Commit 7394094

Browse files
t-baydyusenovdvbuka
authored andcommitted
[llvm][llvm-dis] Fix 'llvm-dis' with '--materialize-metadata --show-annotations' crashes (llvm#164819)
1 parent b41b408 commit 7394094

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

llvm/lib/IR/AsmWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4082,10 +4082,10 @@ void AssemblyWriter::printTypeIdentities() {
40824082

40834083
/// printFunction - Print all aspects of a function.
40844084
void AssemblyWriter::printFunction(const Function *F) {
4085-
if (AnnotationWriter) AnnotationWriter->emitFunctionAnnot(F, Out);
4086-
40874085
if (F->isMaterializable())
40884086
Out << "; Materializable\n";
4087+
else if (AnnotationWriter)
4088+
AnnotationWriter->emitFunctionAnnot(F, Out);
40894089

40904090
const AttributeList &Attrs = F->getAttributes();
40914091
if (Attrs.hasFnAttrs()) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llvm-as < %s | llvm-dis --materialize-metadata --show-annotations | FileCheck %s
2+
3+
; CHECK: ; Materializable
4+
; CHECK-NEXT: define dso_local i32 @test() {}
5+
define dso_local i32 @test() {
6+
entry:
7+
ret i32 0
8+
}
9+

0 commit comments

Comments
 (0)