Skip to content

Commit ebc7411

Browse files
committed
IR: Allow comdats to be applied to globals with internal linkage
Our verifier check for checking if a global has local linkage was too strict. Forbid private linkage but permit local linkage. Object file formats permit this and forbidding it prevents elimination of unused, internal, vftables under the MSVC ABI. llvm-svn: 212900
1 parent 299674e commit ebc7411

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,10 @@ void Verifier::visitComdat(const Comdat &C) {
605605
Assert1(GV,
606606
"comdat selection kind requires a global value with the same name",
607607
&C);
608-
// The Module is invalid if the GlobalValue has local linkage. Allowing
609-
// otherwise opens us up to seeing the underling global value get renamed if
610-
// collisions occur.
608+
// The Module is invalid if the GlobalValue has private linkage. Entities
609+
// with private linkage don't have entries in the symbol table.
611610
if (GV)
612-
Assert1(!GV->hasLocalLinkage(), "comdat global value has local linkage",
611+
Assert1(!GV->hasPrivateLinkage(), "comdat global value has private linkage",
613612
GV);
614613
}
615614

llvm/test/Feature/comdat.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ define void @f() comdat $f {
1616
ret void
1717
}
1818
; CHECK: define void @f() comdat $f
19+
20+
$i = comdat largest
21+
@i = internal global i32 0, comdat $i

llvm/test/Verifier/comdat2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
$v = comdat any
44
@v = private global i32 0, comdat $v
5-
; CHECK: comdat global value has local linkage
5+
; CHECK: comdat global value has private linkage

0 commit comments

Comments
 (0)