Skip to content

Commit 8bd64c4

Browse files
pranavpranav
authored andcommitted
Used ltoCanOmit and modifed the InputFiles.cpp Accordingly,
Modified and added the testcase to internalize-exportdyn.ll
1 parent 1cde8af commit 8bd64c4

File tree

4 files changed

+27
-39
lines changed

4 files changed

+27
-39
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,10 +1736,9 @@ static void createBitcodeSymbol(Ctx &ctx, Symbol *&sym,
17361736
if (c != -1 && !keptComdats[c]) {
17371737
Defined newSym(ctx, &f, StringRef(), binding, visibility, type, 0, 0,
17381738
nullptr);
1739-
if (objSym.canBeOmittedFromSymbolTable())
1740-
newSym.exportDynamic = false;
1739+
sym->ltoCanOmit = objSym.canBeOmittedFromSymbolTable() &&
1740+
(!sym->isDefined() || sym->ltoCanOmit);
17411741
sym->resolve(ctx, newSym);
1742-
sym->referenced = true;
17431742
return;
17441743
}
17451744

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
target triple = "x86_64-unknown-linux-gnu"
22
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
33

4+
$f1 = comdat any
5+
$f2 = comdat any
6+
47
define weak_odr void @bah() {
58
ret void
69
}
10+
11+
define linkonce_odr void @f1() local_unnamed_addr comdat {
12+
ret void
13+
}
14+
define weak_odr void @f2() local_unnamed_addr comdat {
15+
ret void
16+
}

lld/test/ELF/lto/comdat-weakodr-linkonceodr-visibility.ll

Lines changed: 0 additions & 36 deletions
This file was deleted.

lld/test/ELF/lto/internalize-exportdyn.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
target triple = "x86_64-unknown-linux-gnu"
1010
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1111

12+
$f1 = comdat any
13+
$f2 = comdat any
14+
1215
@c = linkonce_odr constant i32 1
1316
@g = linkonce_odr global i32 1
1417
@u_c = linkonce_odr unnamed_addr constant i32 1
@@ -46,6 +49,14 @@ define linkonce_odr void @baz() {
4649

4750
@use_baz = global ptr @baz
4851

52+
define weak_odr void @f1() local_unnamed_addr comdat {
53+
ret void
54+
}
55+
56+
define linkonce_odr void @f2() local_unnamed_addr comdat {
57+
ret void
58+
}
59+
4960
; Check what gets internalized.
5061
; CHECK: @c = weak_odr dso_local constant i32 1
5162
; CHECK: @g = weak_odr dso_local global i32 1
@@ -60,6 +71,8 @@ define linkonce_odr void @baz() {
6071
; CHECK: define internal void @zed2()
6172
; CHECK: define weak_odr dso_local void @bah()
6273
; CHECK: define weak_odr dso_local void @baz()
74+
; CHECK: define weak_odr dso_local void @f1() comdat
75+
; CHECK: define weak_odr dso_local void @f2() comdat
6376

6477
; DSO: @c = weak_odr constant i32 1
6578
; DSO: @g = weak_odr global i32 1
@@ -74,3 +87,5 @@ define linkonce_odr void @baz() {
7487
; DSO: define internal void @zed2()
7588
; DSO: define weak_odr void @bah()
7689
; DSO: define weak_odr void @baz()
90+
; CHECK: define weak_odr void @f1() comdat
91+
; CHECK: define weak_odr void @f2() comdat

0 commit comments

Comments
 (0)