[lld] r319603 - [WebAssembly] Revert r319592 "Add support for visibility flag"
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 18:05:50 PST 2017
Author: aheejin
Date: Fri Dec 1 18:05:50 2017
New Revision: 319603
URL: http://llvm.org/viewvc/llvm-project?rev=319603&view=rev
Log:
[WebAssembly] Revert r319592 "Add support for visibility flag"
r319488 reportedly broke one of LLVM bots (ubuntu-gcc7.1-werror), and this patch
depends on that patch.
See http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/3369 for
details.
Removed:
lld/trunk/test/wasm/Inputs/hidden.ll
lld/trunk/test/wasm/visibility-hidden.ll
Modified:
lld/trunk/test/wasm/Inputs/call-indirect.ll
lld/trunk/test/wasm/Inputs/ret32.ll
lld/trunk/test/wasm/Inputs/ret64.ll
lld/trunk/test/wasm/Inputs/weak-alias.ll
lld/trunk/test/wasm/call-indirect.ll
lld/trunk/test/wasm/entry.ll
lld/trunk/test/wasm/weak-alias-overide.ll
lld/trunk/test/wasm/weak-alias.ll
lld/trunk/test/wasm/weak-external.ll
lld/trunk/wasm/Symbols.cpp
lld/trunk/wasm/Symbols.h
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/test/wasm/Inputs/call-indirect.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/Inputs/call-indirect.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/Inputs/call-indirect.ll (original)
+++ lld/trunk/test/wasm/Inputs/call-indirect.ll Fri Dec 1 18:05:50 2017
@@ -4,13 +4,13 @@ target triple = "wasm32-unknown-unknown-
@indirect_bar = hidden local_unnamed_addr global i32 ()* @bar, align 4
; Function Attrs: norecurse nounwind readnone
-define i32 @bar() #0 {
+define hidden i32 @bar() #0 {
entry:
ret i32 1
}
; Function Attrs: nounwind
-define void @call_bar_indirect() local_unnamed_addr #1 {
+define hidden void @call_bar_indirect() local_unnamed_addr #1 {
entry:
%0 = load i32 ()*, i32 ()** @indirect_bar, align 4
%call = tail call i32 %0() #2
Removed: lld/trunk/test/wasm/Inputs/hidden.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/Inputs/hidden.ll?rev=319602&view=auto
==============================================================================
--- lld/trunk/test/wasm/Inputs/hidden.ll (original)
+++ lld/trunk/test/wasm/Inputs/hidden.ll (removed)
@@ -1,14 +0,0 @@
-target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown-wasm"
-
-; Function Attrs: norecurse nounwind readnone
-define hidden i32 @archiveHidden() #0 {
-entry:
- ret i32 0
-}
-
-; Function Attrs: norecurse nounwind readnone
-define i32 @archiveDefault() #1 {
-entry:
- ret i32 0
-}
Modified: lld/trunk/test/wasm/Inputs/ret32.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/Inputs/ret32.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/Inputs/ret32.ll (original)
+++ lld/trunk/test/wasm/Inputs/ret32.ll Fri Dec 1 18:05:50 2017
@@ -2,7 +2,7 @@ target datalayout = "e-m:e-p:32:32-i64:6
target triple = "wasm32-unknown-unknown-wasm"
; Function Attrs: norecurse nounwind readnone
-define i32 @ret32(float %arg) #0 {
+define hidden i32 @ret32(float %arg) #0 {
entry:
ret i32 0
; ptrtoint (i32 (float)* @ret32 to i32)
Modified: lld/trunk/test/wasm/Inputs/ret64.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/Inputs/ret64.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/Inputs/ret64.ll (original)
+++ lld/trunk/test/wasm/Inputs/ret64.ll Fri Dec 1 18:05:50 2017
@@ -1,7 +1,7 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown-wasm"
-define i64 @ret64(double %arg) local_unnamed_addr #0 {
+define hidden i64 @ret64(double %arg) local_unnamed_addr #0 {
entry:
ret i64 1
}
Modified: lld/trunk/test/wasm/Inputs/weak-alias.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/Inputs/weak-alias.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/Inputs/weak-alias.ll (original)
+++ lld/trunk/test/wasm/Inputs/weak-alias.ll Fri Dec 1 18:05:50 2017
@@ -5,7 +5,7 @@ entry:
@bar = weak alias i32 (), i32 ()* @foo
-define i32 @call_bar() #0 {
+define hidden i32 @call_bar() #0 {
entry:
%call = call i32 @bar()
ret i32 %call
Modified: lld/trunk/test/wasm/call-indirect.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/call-indirect.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/call-indirect.ll (original)
+++ lld/trunk/test/wasm/call-indirect.ll Fri Dec 1 18:05:50 2017
@@ -11,16 +11,16 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown-wasm"
- at indirect_func = local_unnamed_addr global i32 ()* @foo, align 4
+ at indirect_func = hidden local_unnamed_addr global i32 ()* @foo, align 4
; Function Attrs: norecurse nounwind readnone
-define i32 @foo() #0 {
+define hidden i32 @foo() #0 {
entry:
ret i32 1
}
; Function Attrs: nounwind
-define void @_start() local_unnamed_addr #1 {
+define hidden void @_start() local_unnamed_addr #1 {
entry:
%0 = load i32 ()*, i32 ()** @indirect_func, align 4
%call = tail call i32 %0() #2
@@ -63,9 +63,6 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: _start
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Name: bar
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
@@ -75,6 +72,9 @@ entry:
; CHECK-NEXT: - Name: foo
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 2
+; CHECK-NEXT: - Name: _start
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: Index: 3
; CHECK: - Type: ELEM
; CHECK-NEXT: Segments:
; CHECK-NEXT: - Offset:
Modified: lld/trunk/test/wasm/entry.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/entry.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/entry.ll (original)
+++ lld/trunk/test/wasm/entry.ll Fri Dec 1 18:05:50 2017
@@ -7,7 +7,7 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown-wasm"
-define void @entry() local_unnamed_addr #0 {
+define hidden void @entry() local_unnamed_addr #0 {
entry:
ret void
}
Removed: lld/trunk/test/wasm/visibility-hidden.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/visibility-hidden.ll?rev=319602&view=auto
==============================================================================
--- lld/trunk/test/wasm/visibility-hidden.ll (original)
+++ lld/trunk/test/wasm/visibility-hidden.ll (removed)
@@ -1,46 +0,0 @@
-; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj -o %t.o %s
-; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj %S/Inputs/hidden.ll -o %t2.o
-; RUN: llvm-ar rcs %t2.a %t2.o
-; RUN: lld -flavor wasm %t.o %t2.a -o %t.wasm
-; RUN: obj2yaml %t.wasm | FileCheck %s
-
-; Test that hidden symbols are not exported, whether pulled in from an archive
-; or directly.
-
-define hidden i32 @objectHidden() {
-entry:
- ret i32 0
-}
-
-define i32 @objectDefault() {
-entry:
- ret i32 0
-}
-
-declare i32 @archiveHidden()
-declare i32 @archiveDefault()
-
-define i32 @_start() {
-entry:
- %call1 = call i32 @objectHidden()
- %call2 = call i32 @objectDefault()
- %call3 = call i32 @archiveHidden()
- %call4 = call i32 @archiveDefault()
- ret i32 0
-}
-
-; CHECK: - Type: EXPORT
-; CHECK-NEXT: Exports:
-; CHECK-NEXT: - Name: memory
-; CHECK-NEXT: Kind: MEMORY
-; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: _start
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 2
-; CHECK-NEXT: - Name: archiveDefault
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 4
-; CHECK-NEXT: - Name: objectDefault
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Type:
Modified: lld/trunk/test/wasm/weak-alias-overide.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-alias-overide.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-alias-overide.ll (original)
+++ lld/trunk/test/wasm/weak-alias-overide.ll Fri Dec 1 18:05:50 2017
@@ -53,12 +53,12 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: _start
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: bar
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
+; CHECK-NEXT: - Name: _start
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: foo
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 2
Modified: lld/trunk/test/wasm/weak-alias.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-alias.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-alias.ll (original)
+++ lld/trunk/test/wasm/weak-alias.ll Fri Dec 1 18:05:50 2017
@@ -47,12 +47,12 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: _start
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 0
; CHECK-NEXT: - Name: bar
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
+; CHECK-NEXT: - Name: _start
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: Index: 0
; CHECK-NEXT: - Name: foo
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
Modified: lld/trunk/test/wasm/weak-external.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-external.ll?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-external.ll (original)
+++ lld/trunk/test/wasm/weak-external.ll Fri Dec 1 18:05:50 2017
@@ -9,16 +9,16 @@
declare extern_weak i32 @foo()
-define i8* @get_address_of_foo() #0 {
+define hidden i8* @get_address_of_foo() #0 {
entry:
ret i8* bitcast (i32 ()* @foo to i8*)
}
-define i32* @get_address_of_global_var() #0 {
+define hidden i32* @get_address_of_global_var() #0 {
ret i32* @global_var
}
-define i32 @_start() #0 {
+define hidden i32 @_start() #0 {
entry:
%0 = load i32, i32* @global_var, align 4
ret i32 %0
@@ -57,15 +57,15 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: _start
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: get_address_of_foo
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
; CHECK-NEXT: - Name: get_address_of_global_var
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
+; CHECK-NEXT: - Name: _start
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Type: ELEM
; CHECK-NEXT: Segments:
; CHECK-NEXT: - Offset:
Modified: lld/trunk/wasm/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.cpp?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.cpp (original)
+++ lld/trunk/wasm/Symbols.cpp Fri Dec 1 18:05:50 2017
@@ -74,8 +74,6 @@ void Symbol::update(Kind K, InputFile *F
bool Symbol::isWeak() const { return Sym && Sym->isWeak(); }
-bool Symbol::isHidden() const { return Sym && Sym->isHidden(); }
-
std::string lld::toString(wasm::Symbol &Sym) {
return wasm::displayName(Sym.getName());
}
Modified: lld/trunk/wasm/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.h?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.h (original)
+++ lld/trunk/wasm/Symbols.h Fri Dec 1 18:05:50 2017
@@ -58,7 +58,6 @@ public:
bool isGlobal() const { return !isFunction(); }
bool isLocal() const { return IsLocal; }
bool isWeak() const;
- bool isHidden() const;
// Returns the symbol name.
StringRef getName() const { return Name; }
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=319603&r1=319602&r2=319603&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Dec 1 18:05:50 2017
@@ -259,26 +259,22 @@ void Writer::createTableSection() {
void Writer::createExportSection() {
// Memory is and main function are exported for executables.
bool ExportMemory = !Config->Relocatable && !Config->ImportMemory;
- bool ExportOther = true; // ??? TODO Config->Relocatable;
- bool ExportHidden = Config->Relocatable;
- Symbol *EntrySym = Symtab->find(Config->Entry);
- bool ExportEntry = !Config->Relocatable && EntrySym && EntrySym->isDefined();
+ bool ExportMain = !Config->Relocatable;
+ bool ExportOther = true; // Config->Relocatable;
uint32_t NumExports = 0;
if (ExportMemory)
++NumExports;
- if (ExportEntry)
+ if (ExportMain && !ExportOther)
++NumExports;
if (ExportOther) {
for (ObjFile *File : Symtab->ObjectFiles) {
for (Symbol *Sym : File->getSymbols()) {
if (!Sym->isFunction() || Sym->isLocal() || Sym->isUndefined() ||
- (Sym->isHidden() && !ExportHidden) || Sym->WrittenToSymtab)
- continue;
- if (Sym == EntrySym)
+ Sym->WrittenToSymtab)
continue;
Sym->WrittenToSymtab = true;
++NumExports;
@@ -302,21 +298,27 @@ void Writer::createExportSection() {
writeExport(OS, MemoryExport);
}
- if (ExportEntry) {
- WasmExport EntryExport;
- EntryExport.Name = Config->Entry;
- EntryExport.Kind = WASM_EXTERNAL_FUNCTION;
- EntryExport.Index = EntrySym->getOutputIndex();
- writeExport(OS, EntryExport);
+ if (ExportMain) {
+ Symbol *Sym = Symtab->find(Config->Entry);
+ if (Sym->isDefined()) {
+ if (!Sym->isFunction())
+ fatal("entry point is not a function: " + Sym->getName());
+
+ if (!ExportOther) {
+ WasmExport MainExport;
+ MainExport.Name = Config->Entry;
+ MainExport.Kind = WASM_EXTERNAL_FUNCTION;
+ MainExport.Index = Sym->getOutputIndex();
+ writeExport(OS, MainExport);
+ }
+ }
}
if (ExportOther) {
for (ObjFile *File : Symtab->ObjectFiles) {
for (Symbol *Sym : File->getSymbols()) {
- if (!Sym->isFunction() || Sym->isLocal() || Sym->isUndefined() ||
- (Sym->isHidden() && !ExportHidden) || !Sym->WrittenToSymtab)
- continue;
- if (Sym == EntrySym)
+ if (!Sym->isFunction() || Sym->isLocal() | Sym->isUndefined() ||
+ !Sym->WrittenToSymtab)
continue;
Sym->WrittenToSymtab = false;
log("Export: " + Sym->getName());
@@ -330,6 +332,9 @@ void Writer::createExportSection() {
writeExport(OS, Export);
}
}
+
+ // TODO(sbc): Export local symbols too, Even though they are not part
+ // of the symbol table?
}
}
More information about the llvm-commits
mailing list