summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-05 05:21:07 +0000
committerChris Lattner <sabre@nondot.org>2009-08-05 05:21:07 +0000
commitd055488c7210469be370fa8b4d3102bb9854c784 (patch)
tree1558020b7662205780f724b4c9733a61b2ba5f62 /llvm/lib/VMCore/Verifier.cpp
parentf49573d1eedcf1e44893d5a062ac1b72c8419646 (diff)
downloadbcm5719-llvm-d055488c7210469be370fa8b4d3102bb9854c784.tar.gz
bcm5719-llvm-d055488c7210469be370fa8b4d3102bb9854c784.zip
Clarify common linkage and the requirements on it. Enforce
them in the verifier. llvm-svn: 78160
Diffstat (limited to 'llvm/lib/VMCore/Verifier.cpp')
-rw-r--r--llvm/lib/VMCore/Verifier.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index 2b832983f5c..f50299bdc0c 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud