[lld] 025b309 - Revert D126950 "[lld][WebAssembly] Retain data segments referenced via __start/__stop"
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 22:18:11 PDT 2022
Author: Fangrui Song
Date: 2022-06-03T22:18:06-07:00
New Revision: 025b309631e996f48b8367a7a2fa1032fa04a77c
URL: https://github.com/llvm/llvm-project/commit/025b309631e996f48b8367a7a2fa1032fa04a77c
DIFF: https://github.com/llvm/llvm-project/commit/025b309631e996f48b8367a7a2fa1032fa04a77c.diff
LOG: Revert D126950 "[lld][WebAssembly] Retain data segments referenced via __start/__stop"
This reverts commit dcf3368e33c3a01bd21b692d3be5dc1ecee587f4.
It breaks -DLLVM_ENABLE_ASSERTIONS=on builds. In addition, the description is
incorrect about ld.lld behavior. For wasm, there should be justification to add
the new mode.
Added:
Modified:
lld/wasm/MarkLive.cpp
Removed:
lld/test/wasm/gc-sections-startstop.s
################################################################################
diff --git a/lld/test/wasm/gc-sections-startstop.s b/lld/test/wasm/gc-sections-startstop.s
deleted file mode 100644
index f90164d743a9c..0000000000000
--- a/lld/test/wasm/gc-sections-startstop.s
+++ /dev/null
@@ -1,89 +0,0 @@
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o %s
-# RUN: wasm-ld %t.o -o %t.wasm
-# RUN: llvm-objdump -d --no-show-raw-insn %t.wasm | FileCheck %s
-
-# FOO_MD symbol is not used directly, but is referenced through __start/__stop_foo_md
-foo_md_size:
- .functype foo_md_size () -> (i32)
- i32.const __stop_foo_md
- i32.const __start_foo_md
- i32.sub
- end_function
-
-# CHECK: <foo_md_size>:
-# CHECK-EMPTY:
-# CHECK-NEXT: i32.const [[#STOP_ADDR:]]
-# CHECK-NEXT: i32.const [[#STOP_ADDR - 4]]
-# CHECK-NEXT: i32.sub
-
-# All segments in concat_section section are marked as live.
-concat_section_size:
- .functype concat_section_size () -> (i32)
- i32.const __stop_concat_section
- i32.const __start_concat_section
- i32.sub
- end_function
-
-# CHECK: <concat_section_size>:
-# CHECK-EMPTY:
-# CHECK-NEXT: i32.const [[#STOP_ADDR:]]
-# CHECK-NEXT: i32.const [[#STOP_ADDR - 8]]
-# CHECK-NEXT: i32.sub
-
-
-# __start/__stop symbols don't retain invalid C name sections
-invalid_name_section_size:
- .functype invalid_name_section_size () -> (i32)
- i32.const __stop_invalid.dot.name
- i32.const __start_invalid.dot.name
- i32.sub
- end_function
-
-# CHECK: <invalid_name_section_size>:
-# CHECK-EMPTY:
-# CHECK-NEXT: i32.const 0
-# CHECK-NEXT: i32.const 0
-# CHECK-NEXT: i32.sub
-
-
- .globl _start
-_start:
- .functype _start () -> ()
- call foo_md_size
- drop
- call concat_section_size
- drop
- call invalid_name_section_size
- drop
- end_function
-
-
- .section foo_md,"",@
-FOO_MD:
- .asciz "bar"
- .size FOO_MD, 4
-
- .size __start_foo_md, 4
- .size __stop_foo_md, 4
-
-
- .section concat_section,"",@
-concat_segment_1:
- .asciz "xxx"
- .size concat_segment_1, 4
-
-concat_segment_2:
- .asciz "yyy"
- .size concat_segment_2, 4
-
- .size __start_concat_section, 4
- .size __stop_concat_section, 4
-
-
- .section invalid.dot.name,"",@
-invalid_name_section:
- .asciz "fizz"
- .size invalid_name_section, 5
-
- .weak __start_invalid.dot.name
- .weak __stop_invalid.dot.name
diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp
index c811dd4d2226b..3e5d234eeccc0 100644
--- a/lld/wasm/MarkLive.cpp
+++ b/lld/wasm/MarkLive.cpp
@@ -24,7 +24,6 @@
#include "InputElement.h"
#include "SymbolTable.h"
#include "Symbols.h"
-#include "lld/Common/Strings.h"
#define DEBUG_TYPE "lld"
@@ -42,7 +41,6 @@ class MarkLive {
private:
void enqueue(Symbol *sym);
- void enqueue(InputChunk *chunk);
void enqueueInitFunctions(const ObjFile *sym);
void mark();
bool isCallCtorsLive();
@@ -86,12 +84,6 @@ void MarkLive::enqueueInitFunctions(const ObjFile *obj) {
}
}
-void MarkLive::enqueue(InputChunk *chunk) {
- LLVM_DEBUG(dbgs() << "markLive: " << chunk->getName() << "\n");
- chunk->live = true;
- queue.push_back(chunk);
-}
-
void MarkLive::run() {
// Add GC root symbols.
if (!config->entry.empty())
@@ -105,24 +97,10 @@ void MarkLive::run() {
if (WasmSym::callDtors)
enqueue(WasmSym::callDtors);
- for (const ObjFile *obj : symtab->objectFiles) {
- if (!obj->isLive()) {
- continue;
- }
- // Enqueue constructors in objects explicitly live from the command-line.
- enqueueInitFunctions(obj);
-
- // Enqueue data segments referenced through __start/__stop symbols.
- for (InputChunk *segment : obj->segments) {
- auto name = segment->name;
- if (!isValidCIdentifier(name))
- continue;
- if (symtab->find(("__start_" + name).str()) ||
- symtab->find(("__stop_" + name).str())) {
- enqueue(segment);
- }
- }
- }
+ // Enqueue constructors in objects explicitly live from the command-line.
+ for (const ObjFile *obj : symtab->objectFiles)
+ if (obj->isLive())
+ enqueueInitFunctions(obj);
mark();
More information about the llvm-commits
mailing list