[PATCH] D36487: Emit section information for extern variables.

Elizabeth Andrews via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 8 14:39:27 PDT 2017


eandrews added inline comments.


================
Comment at: lib/CodeGen/CodeGenModule.cpp:2434
+    // Emit section information for extern variables.
+    if (D->hasExternalStorage() && !D->isThisDeclarationADefinition()) {
+      if (const SectionAttr *SA = D->getAttr<SectionAttr>())
----------------
efriedma wrote:
> Why do you specifically check "D->hasExternalStorage() && !D->isThisDeclarationADefinition()", instead of just setting the section unconditionally?
I noticed that you enter GetOrCreateLLVMGlobal( ) whenever the extern variable is declared as well as when it is defined. The flow of the program is different in each case. When the variable is defined, it also enters EmitGlobalVarDefinition( ). There is existing code handling section information here. I added the check in GetOrCreateLLVMGlobal( ) so the block gets skipped for variable definition, since its already handled elsewhere.


https://reviews.llvm.org/D36487





More information about the cfe-commits mailing list