[lld] r366500 - [WebAssembly] fix bug in finding .tdata segment
Guanzhong Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 14:18:24 PDT 2019
Author: quantum
Date: Thu Jul 18 14:18:24 2019
New Revision: 366500
URL: http://llvm.org/viewvc/llvm-project?rev=366500&view=rev
Log:
[WebAssembly] fix bug in finding .tdata segment
Summary: Fix bug in `wasm-ld`'s `Writer::createInitTLSFunction` that only finds `.tdata` if it's the first section.
Reviewers: tlively, aheejin, sbc100
Reviewed By: sbc100
Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64947
Modified:
lld/trunk/test/wasm/tls.ll
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/test/wasm/tls.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/tls.ll?rev=366500&r1=366499&r2=366500&view=diff
==============================================================================
--- lld/trunk/test/wasm/tls.ll (original)
+++ lld/trunk/test/wasm/tls.ll Thu Jul 18 14:18:24 2019
@@ -2,8 +2,8 @@
target triple = "wasm32-unknown-unknown"
- at tls1 = thread_local(localexec) global i32 1, align 4
@no_tls = global i32 0, align 4
+ at tls1 = thread_local(localexec) global i32 1, align 4
@tls2 = thread_local(localexec) global i32 1, align 4
define i32* @tls1_addr() {
@@ -49,7 +49,7 @@ define i32* @tls2_addr() {
; CHECK-NEXT: Body: 0B
; CHECK-NEXT: - Index: 1
; CHECK-NEXT: Locals: []
-; CHECK-NEXT: Body: 20002401200041004108FC0800000B
+; CHECK-NEXT: Body: 20002401200041004108FC0801000B
; Expected body of __wasm_init_tls:
; local.get 0
@@ -57,7 +57,7 @@ define i32* @tls2_addr() {
; local.get 0
; i32.const 0
; i32.const 8
-; memory.init 0, 0
+; memory.init 1, 0
; end
; CHECK-NEXT: - Index: 2
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=366500&r1=366499&r2=366500&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Thu Jul 18 14:18:24 2019
@@ -771,9 +771,10 @@ void Writer::createInitTLSFunction() {
OutputSegment *tlsSeg = nullptr;
for (auto *seg : segments) {
- if (seg->name == ".tdata")
+ if (seg->name == ".tdata") {
tlsSeg = seg;
- break;
+ break;
+ }
}
writeUleb128(os, 0, "num locals");
More information about the llvm-commits
mailing list