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);