[llvm] 5b4bfd8 - [DwarfCompileUnit] getOrCreateCommonBlock(): check for existing entity first. NFCI

Kristina Bessonova via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 14 01:00:35 PST 2021


Author: Kristina Bessonova
Date: 2021-11-14T10:58:24+02:00
New Revision: 5b4bfd8c2415cb38983a56007bb424e063778460

URL: https://github.com/llvm/llvm-project/commit/5b4bfd8c2415cb38983a56007bb424e063778460
DIFF: https://github.com/llvm/llvm-project/commit/5b4bfd8c2415cb38983a56007bb424e063778460.diff

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

For global variables and common blocks there is no way to create entities
through getOrCreateContextDIE(), so no need to obtain the context first.

Differential Revision: https://reviews.llvm.org/D113651

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index b1d9c0237ffd..8c0a1f672f46 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -349,12 +349,10 @@ void DwarfCompileUnit::addLocationAttribute(
 
 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);


        


More information about the llvm-commits mailing list