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
llvm-svn: 366500
target triple = "wasm32-unknown-unknown"
-@tls1 = thread_local(localexec) global i32 1, align 4
@no_tls = global i32 0, align 4
+@tls1 = thread_local(localexec) global i32 1, align 4
@tls2 = thread_local(localexec) global i32 1, align 4
define i32* @tls1_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
; local.get 0
; i32.const 0
; i32.const 8
-; memory.init 0, 0
+; memory.init 1, 0
; end
; CHECK-NEXT: - Index: 2
OutputSegment *tlsSeg = nullptr;
for (auto *seg : segments) {
- if (seg->name == ".tdata")
+ if (seg->name == ".tdata") {
tlsSeg = seg;
- break;
+ break;
+ }
}
writeUleb128(os, 0, "num locals");