[PATCH] D43036: Use a stable topological sort instead of std::stable_sort in DIE *DwarfCompileUnit::createScopeChildrenDIE()

Volodymyr Sapsai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 16:57:14 PST 2018


vsapsai added inline comments.


================
Comment at: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:637
+      auto Var = dyn_cast_or_null<const DILocalVariable>(Dependency);
+      WorkList.push_back({DbgVar[Var], 0});
+    }
----------------
aprantl wrote:
> vsapsai wrote:
> > What would happen and if it is even possible if `Dependency` is not a local variable?
> > 
> > And in this case `dyn_cast<>` should be enough, we don't add nullptr dependencies.
> In theory a frontend could produce metadata where the count is a global variable. This doesn't make much sense in practice, but we don't reject it in the verifier, so we might as well handle it gracefully.
For those who aren't following the review closely, I think global variables are handled at
```lang=c++
    // Dependency is in a different lexical scope or a global.
    if (!Var)
      continue;
```

And no need to worry that dependencies loop has no null checks.


https://reviews.llvm.org/D43036





More information about the llvm-commits mailing list