Verifier: Unused comdats might not have a corresponding GV
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 20 Feb 2015 19:58:48 +0000 (19:58 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 20 Feb 2015 19:58:48 +0000 (19:58 +0000)
This fixes PR22646.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230051 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp
test/Verifier/comdat3.ll [new file with mode: 0644]

index 43a023ec7c0a50b8aedc85a54a8fe9be4f7b9eda..d01e1389436b8487143479ab076578b4efe95cb5 100644 (file)
@@ -793,16 +793,9 @@ void Verifier::visitMDImportedEntity(const MDImportedEntity &N) {
 }
 
 void Verifier::visitComdat(const Comdat &C) {
-  // All Comdat::SelectionKind values other than Comdat::Any require a
-  // GlobalValue with the same name as the Comdat.
-  const GlobalValue *GV = M->getNamedValue(C.getName());
-  if (C.getSelectionKind() != Comdat::Any)
-    Assert1(GV,
-            "comdat selection kind requires a global value with the same name",
-            &C);
   // The Module is invalid if the GlobalValue has private linkage.  Entities
   // with private linkage don't have entries in the symbol table.
-  if (GV)
+  if (const GlobalValue *GV = M->getNamedValue(C.getName()))
     Assert1(!GV->hasPrivateLinkage(), "comdat global value has private linkage",
             GV);
 }
diff --git a/test/Verifier/comdat3.ll b/test/Verifier/comdat3.ll
new file mode 100644 (file)
index 0000000..28df930
--- /dev/null
@@ -0,0 +1,5 @@
+; This used to be invalid, but now it's valid.  Ensure the verifier
+; doesn't reject it.
+; RUN: llvm-as %s -o /dev/null
+
+$v = comdat largest