summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp6
-rw-r--r--clang/test/CodeGen/2008-07-31-asm-labels.c8
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 558c940713a..33aff2553fd 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -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.
diff --git a/clang/test/CodeGen/2008-07-31-asm-labels.c b/clang/test/CodeGen/2008-07-31-asm-labels.c
index 1b5e0ca91da..8aba2d39a72 100644
--- a/clang/test/CodeGen/2008-07-31-asm-labels.c
+++ b/clang/test/CodeGen/2008-07-31-asm-labels.c
@@ -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;
+}
OpenPOWER on IntegriCloud