Implement GNU asm-label extension support in CodeGen. This fixes
scimark2 on Darwin.

 - Added Sema support for asm-label on variables, which I forgot before.

 - Update CodeGen to use GlobalDeclMap to determine if static Decls
   require emission (instead of LLVM module name lookup). Important
   since the Decl name and the LLVM module name can differ.

 - <rdar://problem/6116729>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54388 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 19a2c28..b513dde 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -808,6 +808,14 @@
     // Handle attributes prior to checking for duplicates in MergeVarDecl
     ProcessDeclAttributes(NewVD, D);
 
+    // Handle GNU asm-label extension (encoded as an attribute).
+    if (Expr *E = (Expr*) D.getAsmLabel()) {
+      // The parser guarantees this is a string.
+      StringLiteral *SE = cast<StringLiteral>(E);  
+      NewVD->addAttr(new AsmLabelAttr(std::string(SE->getStrData(),
+                                                  SE->getByteLength())));
+    }
+
     // Emit an error if an address space was applied to decl with local storage.
     // This includes arrays of objects with address space qualifiers, but not
     // automatic variables that point to other address spaces.