Print visibility info for external variables.

llvm-svn: 128887
This commit is contained in:
Rafael Espindola 2011-04-05 15:51:32 +00:00
parent fe6e07fd8a
commit 7dd4d6e2e8
2 changed files with 17 additions and 12 deletions

View File

@ -253,22 +253,24 @@ void AsmPrinter::EmitLinkage(unsigned Linkage, MCSymbol *GVSym) const {
/// EmitGlobalVariable - Emit the specified global variable to the .s file. /// EmitGlobalVariable - Emit the specified global variable to the .s file.
void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
if (!GV->hasInitializer()) // External globals require no code. if (GV->hasInitializer()) {
return; // Check to see if this is a special global used by LLVM, if so, emit it.
if (EmitSpecialLLVMGlobal(GV))
return;
// Check to see if this is a special global used by LLVM, if so, emit it. if (isVerbose()) {
if (EmitSpecialLLVMGlobal(GV)) WriteAsOperand(OutStreamer.GetCommentOS(), GV,
return; /*PrintType=*/false, GV->getParent());
OutStreamer.GetCommentOS() << '\n';
if (isVerbose()) { }
WriteAsOperand(OutStreamer.GetCommentOS(), GV,
/*PrintType=*/false, GV->getParent());
OutStreamer.GetCommentOS() << '\n';
} }
MCSymbol *GVSym = Mang->getSymbol(GV); MCSymbol *GVSym = Mang->getSymbol(GV);
EmitVisibility(GVSym, GV->getVisibility()); EmitVisibility(GVSym, GV->getVisibility());
if (!GV->hasInitializer()) // External globals require no extra code.
return;
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective())
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject); OutStreamer.EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject);

View File

@ -1,11 +1,14 @@
; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s ; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s
@zed = external hidden constant i32
define hidden void @foo() nounwind { define hidden void @foo() nounwind {
entry: entry:
call void @bar() call void @bar(i32* @zed)
ret void ret void
} }
declare hidden void @bar() declare hidden void @bar(i32*)
;CHECK: .hidden zed
;CHECK: .hidden bar ;CHECK: .hidden bar