]> granicus.if.org Git - clang/commitdiff
Support "asm" renaming of external symbols.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 4 Mar 2009 17:31:19 +0000 (17:31 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 4 Mar 2009 17:31:19 +0000 (17:31 +0000)
 - PR3698.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66038 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/2008-07-31-asm-labels.c

index 558c940713aaa35f2b0b5f2c439ae1e4ff452b38..33aff2553fd0c599734de7721fc6ca6bf0c24cde 100644 (file)
@@ -605,6 +605,12 @@ void CodeGenModule::EmitGlobalDefinition(const ValueDecl *D) {
 
     if (D->getAttr<WeakAttr>())
       GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
+
+    if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
+      // Prefaced with special LLVM marker to indicate that the name
+      // should not be munged.
+      GV->setName("\01" + ALA->getLabel());
+    }  
   }
   
   // Make sure the result is of the correct type.
index 1b5e0ca91da1c4a11eb8f4d51067dd49c6680a65..8aba2d39a7285fcd866e4fe66f46f61e37439df0 100644 (file)
@@ -1,6 +1,8 @@
 // RUN: clang -emit-llvm -o %t %s &&
 // RUN: grep "@pipe()" %t | count 0 &&
 // RUN: grep '_thisIsNotAPipe' %t | count 3 &&
+// RUN: grep 'g0' %t | count 0 &&
+// RUN: grep '_renamed' %t | count 2 &&
 // RUN: clang -DUSE_DEF -emit-llvm -o %t %s &&
 // RUN: grep "@pipe()" %t | count 0 &&
 // RUN: grep '_thisIsNotAPipe' %t | count 3
@@ -23,3 +25,9 @@ void pipe(int arg) {
   int x = 10;
 }
 #endif
+
+// PR3698
+extern int g0 asm("_renamed");
+int f2() {
+  return g0;
+}