diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-05 05:21:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-05 05:21:07 +0000 |
commit | 26d054d903488d956c23a17d78b6bc8cbd9553cb (patch) | |
tree | 6b4c81395f4dab5e0e31865699f082c693c68d6e /lib | |
parent | 831f6f6d2ae5a1ad988c8328404b052b7985ce31 (diff) | |
download | external_llvm-26d054d903488d956c23a17d78b6bc8cbd9553cb.zip external_llvm-26d054d903488d956c23a17d78b6bc8cbd9553cb.tar.gz external_llvm-26d054d903488d956c23a17d78b6bc8cbd9553cb.tar.bz2 |
Clarify common linkage and the requirements on it. Enforce
them in the verifier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 7 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 2f56c2a..d5279ef 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -782,8 +782,13 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { if (Subtarget->isTargetELF()) O << "\t.type\t" << name << ",@object\n"; + + SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM); + + + const MCSection *TheSection = - getObjFileLowering().SectionForGlobal(GVar, Mang, TM); + getObjFileLowering().SectionForGlobal(GVar, GVKind, Mang, TM); SwitchToSection(TheSection); // FIXME: get this stuff from section kind flags. diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 2b83298..f50299b 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -378,6 +378,12 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) { "Global variable initializer type does not match global " "variable type!", &GV); + // If the global has common linkage, it must have a zero initializer. + if (GV.hasCommonLinkage()) + Assert1(GV.getInitializer()->isNullValue(), + "'common' global must have a zero initializer!", &GV); + + // Verify that any metadata used in a global initializer points only to // other globals. if (MDNode *FirstNode = dyn_cast<MDNode>(GV.getInitializer())) { @@ -544,6 +550,7 @@ void Verifier::visitFunction(Function &F) { const FunctionType *FT = F.getFunctionType(); unsigned NumArgs = F.arg_size(); + Assert1(!F.hasCommonLinkage(), "Functions may not have common linkage", &F); Assert2(FT->getNumParams() == NumArgs, "# formal arguments must match # of arguments for function type!", &F, FT); |