[llvm] [NFC][AsmPrinter] Refactor constructVariableDIE (PR #66435)

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 08:33:59 PDT 2023


================
@@ -740,232 +740,213 @@ DIE *DwarfCompileUnit::constructLexicalScopeDIE(LexicalScope *Scope) {
   return ScopeDIE;
 }
 
-/// constructVariableDIE - Construct a DIE for the given DbgVariable.
 DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV, bool Abstract) {
-  auto D = constructVariableDIEImpl(DV, Abstract);
-  DV.setDIE(*D);
-  return D;
+  auto *VariableDie = DIE::get(DIEValueAllocator, DV.getTag());
+  insertDIE(DV.getVariable(), VariableDie);
+  DV.setDIE(*VariableDie);
+  // Abstract variables don't get common attributes later, so apply them now.
+  if (Abstract) {
+    applyCommonDbgVariableAttributes(DV, *VariableDie);
+  } else {
+    std::visit(
+        [&](const auto &V) {
+          applyConcreteDbgVariableAttributes(V, DV, VariableDie);
----------------
felipepiovezan wrote:

Since `VariableDie` is always non-null, could you make this a reference instead?

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


More information about the llvm-commits mailing list