diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-08-06 00:03:29 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-06 00:03:29 +0000 |
commit | ffc29be83f336e6da110442787c8e1ff0780e0a0 (patch) | |
tree | a880cc18b6a09ecf989eacdcdd9a18bab9eab4c5 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 9b26ca1ab4efcc225c3dc3ad8699ad74926ff55c (diff) | |
download | bcm5719-llvm-ffc29be83f336e6da110442787c8e1ff0780e0a0.tar.gz bcm5719-llvm-ffc29be83f336e6da110442787c8e1ff0780e0a0.zip |
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>
llvm-svn: 54388
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 176576acbbc..ebe75dd4a2b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -184,6 +184,12 @@ void CodeGenModule::SetGlobalValueAttributes(const FunctionDecl *FD, if (const VisibilityAttr *attr = FD->getAttr<VisibilityAttr>()) CodeGenModule::setVisibility(GV, attr->getVisibility()); // FIXME: else handle -fvisibility + + if (const AsmLabelAttr *ALA = FD->getAttr<AsmLabelAttr>()) { + // Prefaced with special LLVM marker to indicate that the name + // should not be munged. + GV->setName("\01" + ALA->getLabel()); + } } void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD, @@ -400,13 +406,8 @@ void CodeGenModule::EmitStatics() { // Check if we have used a decl with the same name // FIXME: The AST should have some sort of aggregate decls or // global symbol map. - if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { - if (!getModule().getFunction(FD->getName())) - continue; - } else { - if (!getModule().getNamedGlobal(cast<VarDecl>(D)->getName())) - continue; - } + if (!GlobalDeclMap.count(D->getName())) + continue; // Emit the definition. EmitGlobalDefinition(D); @@ -620,6 +621,12 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) setVisibility(GV, attr->getVisibility()); // FIXME: else handle -fvisibility + + 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()); + } // Set the llvm linkage type as appropriate. if (D->getStorageClass() == VarDecl::Static) |