[PATCH] D113651: [DwarfCompileUnit] getOrCreateCommonBlock(): check for existing entity first. NFCI

Kristina Bessonova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 00:52:29 PST 2021


krisb updated this revision to Diff 386753.
krisb retitled this revision from "[DebugInfo] DwarfCompileUnit: Check for existing global vars after getting a context" to "[DwarfCompileUnit] getOrCreateCommonBlock(): check for existing entity first. NFCI".
krisb edited the summary of this revision.
krisb added a comment.

Make getOrCreateCommonBlock() to check for existing entity first, remove outdated comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113651/new/

https://reviews.llvm.org/D113651

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp


Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -143,8 +143,6 @@
   auto *GVContext = GV->getScope();
   const DIType *GTy = GV->getType();
 
-  // Construct the context before querying for the existence of the DIE in
-  // case such construction creates the DIE.
   auto *CB = GVContext ? dyn_cast<DICommonBlock>(GVContext) : nullptr;
   DIE *ContextDIE = CB ? getOrCreateCommonBlock(CB, GlobalExprs)
     : getOrCreateContextDIE(GVContext);
@@ -351,12 +349,10 @@
 
 DIE *DwarfCompileUnit::getOrCreateCommonBlock(
     const DICommonBlock *CB, ArrayRef<GlobalExpr> GlobalExprs) {
-  // Construct the context before querying for the existence of the DIE in case
-  // such construction creates the DIE.
-  DIE *ContextDIE = getOrCreateContextDIE(CB->getScope());
-
+  // Check for pre-existence.
   if (DIE *NDie = getDIE(CB))
     return NDie;
+  DIE *ContextDIE = getOrCreateContextDIE(CB->getScope());
   DIE &NDie = createAndAddDIE(dwarf::DW_TAG_common_block, *ContextDIE, CB);
   StringRef Name = CB->getName().empty() ? "_BLNK_" : CB->getName();
   addString(NDie, dwarf::DW_AT_name, Name);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113651.386753.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211112/5127dbc5/attachment.bin>


More information about the llvm-commits mailing list