[llvm] [llvm][llvm-dis] Fix 'llvm-dis' with '--materialize-metadata --show-annotations' crashes (PR #167487)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 11 13:57:58 PST 2025


================
@@ -101,13 +101,28 @@ static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) {
   }
 }
 class CommentWriter : public AssemblyAnnotationWriter {
+private:
+  bool canSafelyAccessUses(const Value &V) {
+    // Can't safely access uses, if module not materialized.
+    if (!isa<GlobalValue>(&V))
+      return true;
+    const GlobalValue *GV = cast<GlobalValue>(&V);
+    return GV->getParent() && GV->getParent()->isMaterialized();
----------------
arsenm wrote:

```suggestion
    const GlobalValue *GV = dyn_cast<GlobalValue>(&V);
    return !GV || (GV->getParent() && GV->getParent()->isMaterialized());
```

https://github.com/llvm/llvm-project/pull/167487


More information about the llvm-commits mailing list