diff options
| author | Timur Baydyusenov <t.baydyusenov@syntacore.com> | 2025-11-12 05:29:40 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-11 18:29:40 -0800 |
| commit | a100a6c97be0259c8d0b5758830cba14d4eb5c4d (patch) | |
| tree | 3c13b923c303fafa74c59c7b048f63883fe0b45f /llvm/lib | |
| parent | c1f18a2518898e5f593ce1341d19f61b5ee58cdd (diff) | |
| download | llvm-a100a6c97be0259c8d0b5758830cba14d4eb5c4d.zip llvm-a100a6c97be0259c8d0b5758830cba14d4eb5c4d.tar.gz llvm-a100a6c97be0259c8d0b5758830cba14d4eb5c4d.tar.bz2 | |
[llvm][llvm-dis] Fix 'llvm-dis' with '--materialize-metadata --show-annotations' crashes (#167487)
Added handling the case of a non-materialized module, also don't call
printInfoComment for immaterializable values
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 0c8565c..4d4ffe93 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -2931,7 +2931,7 @@ private: // printInfoComment - Print a little comment after the instruction indicating // which slot it occupies. - void printInfoComment(const Value &V); + void printInfoComment(const Value &V, bool isMaterializable = false); // printGCRelocateComment - print comment after call to the gc.relocate // intrinsic indicating base and derived pointer names. @@ -3963,7 +3963,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) { if (Attrs.hasAttributes()) Out << " #" << Machine.getAttributeGroupSlot(Attrs); - printInfoComment(*GV); + printInfoComment(*GV, GV->isMaterializable()); } void AssemblyWriter::printAlias(const GlobalAlias *GA) { @@ -4001,7 +4001,7 @@ void AssemblyWriter::printAlias(const GlobalAlias *GA) { Out << '"'; } - printInfoComment(*GA); + printInfoComment(*GA, GA->isMaterializable()); Out << '\n'; } @@ -4040,7 +4040,7 @@ void AssemblyWriter::printIFunc(const GlobalIFunc *GI) { printMetadataAttachments(MDs, ", "); } - printInfoComment(*GI); + printInfoComment(*GI, GI->isMaterializable()); Out << '\n'; } @@ -4319,13 +4319,12 @@ void AssemblyWriter::printGCRelocateComment(const GCRelocateInst &Relocate) { /// printInfoComment - Print a little comment after the instruction indicating /// which slot it occupies. -void AssemblyWriter::printInfoComment(const Value &V) { +void AssemblyWriter::printInfoComment(const Value &V, bool isMaterializable) { if (const auto *Relocate = dyn_cast<GCRelocateInst>(&V)) printGCRelocateComment(*Relocate); - if (AnnotationWriter) { + if (AnnotationWriter && !isMaterializable) AnnotationWriter->printInfoComment(V, Out); - } if (PrintInstDebugLocs) { if (auto *I = dyn_cast<Instruction>(&V)) { |
