Support "asm" renaming of external symbols.

- PR3698.

llvm-svn: 66038
This commit is contained in:
Daniel Dunbar 2009-03-04 17:31:19 +00:00
parent 3e2cbc3161
commit 5b9e9682f1
2 changed files with 14 additions and 0 deletions

View 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.

View 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;
}