mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[WebAssembly] Add TLS data segment flag: WASM_SEG_FLAG_TLS
Previously the linker was relying solely on the name of the segment to imply TLS. Differential Revision: https://reviews.llvm.org/D102202
This commit is contained in:
parent
6ba804b88f
commit
6e585563bc
@ -359,6 +359,7 @@ enum WasmSymbolType : unsigned {
|
|||||||
|
|
||||||
enum WasmSegmentFlag : unsigned {
|
enum WasmSegmentFlag : unsigned {
|
||||||
WASM_SEG_FLAG_STRINGS = 0x1,
|
WASM_SEG_FLAG_STRINGS = 0x1,
|
||||||
|
WASM_SEG_FLAG_TLS = 0x2,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Kinds of event attributes.
|
// Kinds of event attributes.
|
||||||
|
@ -2009,11 +2009,14 @@ static const Comdat *getWasmComdat(const GlobalValue *GV) {
|
|||||||
static unsigned getWasmSectionFlags(SectionKind K) {
|
static unsigned getWasmSectionFlags(SectionKind K) {
|
||||||
unsigned Flags = 0;
|
unsigned Flags = 0;
|
||||||
|
|
||||||
// TODO(sbc): Add suport for K.isMergeableConst()
|
if (K.isThreadLocal())
|
||||||
|
Flags |= wasm::WASM_SEG_FLAG_TLS;
|
||||||
|
|
||||||
if (K.isMergeableCString())
|
if (K.isMergeableCString())
|
||||||
Flags |= wasm::WASM_SEG_FLAG_STRINGS;
|
Flags |= wasm::WASM_SEG_FLAG_STRINGS;
|
||||||
|
|
||||||
|
// TODO(sbc): Add suport for K.isMergeableConst()
|
||||||
|
|
||||||
return Flags;
|
return Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,9 @@ public:
|
|||||||
case 'G':
|
case 'G':
|
||||||
Group = true;
|
Group = true;
|
||||||
break;
|
break;
|
||||||
|
case 'T':
|
||||||
|
flags |= wasm::WASM_SEG_FLAG_TLS;
|
||||||
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
flags |= wasm::WASM_SEG_FLAG_STRINGS;
|
flags |= wasm::WASM_SEG_FLAG_STRINGS;
|
||||||
break;
|
break;
|
||||||
|
@ -69,6 +69,8 @@ void MCSectionWasm::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
|
|||||||
OS << 'G';
|
OS << 'G';
|
||||||
if (SegmentFlags & wasm::WASM_SEG_FLAG_STRINGS)
|
if (SegmentFlags & wasm::WASM_SEG_FLAG_STRINGS)
|
||||||
OS << 'S';
|
OS << 'S';
|
||||||
|
if (SegmentFlags & wasm::WASM_SEG_FLAG_TLS)
|
||||||
|
OS << 'T';
|
||||||
|
|
||||||
OS << '"';
|
OS << '"';
|
||||||
|
|
||||||
|
@ -544,6 +544,7 @@ void ScalarBitSetTraits<WasmYAML::SegmentFlags>::bitset(
|
|||||||
IO &IO, WasmYAML::SegmentFlags &Value) {
|
IO &IO, WasmYAML::SegmentFlags &Value) {
|
||||||
#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_SEG_FLAG_##X)
|
#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_SEG_FLAG_##X)
|
||||||
BCase(STRINGS);
|
BCase(STRINGS);
|
||||||
|
BCase(TLS);
|
||||||
#undef BCase
|
#undef BCase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,4 +23,4 @@ target triple = "wasm32-unknown-unknown"
|
|||||||
; BULK-MEM-NEXT: .int8 43
|
; BULK-MEM-NEXT: .int8 43
|
||||||
; BULK-MEM-NEXT: .int8 11
|
; BULK-MEM-NEXT: .int8 11
|
||||||
; BULK-MEM-NEXT: .ascii "bulk-memory"
|
; BULK-MEM-NEXT: .ascii "bulk-memory"
|
||||||
; BULK-MEM-NEXT: .tbss.foo,"",@
|
; BULK-MEM-NEXT: .tbss.foo,"T",@
|
||||||
|
@ -105,7 +105,7 @@ define void @tls_base_write(i8** %output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: .type tls,@object
|
; CHECK: .type tls,@object
|
||||||
; TLS-NEXT: .section .tbss.tls,"",@
|
; TLS-NEXT: .section .tbss.tls,"T",@
|
||||||
; NO-TLS-NEXT: .section .bss.tls,"",@
|
; NO-TLS-NEXT: .section .bss.tls,"",@
|
||||||
; CHECK-NEXT: .p2align 2
|
; CHECK-NEXT: .p2align 2
|
||||||
; CHECK-NEXT: tls:
|
; CHECK-NEXT: tls:
|
||||||
|
@ -72,7 +72,7 @@ define i32 @tls_size() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: .type tls,@object
|
; CHECK: .type tls,@object
|
||||||
; TLS-NEXT: .section .tbss.tls,"",@
|
; TLS-NEXT: .section .tbss.tls,"T",@
|
||||||
; NO-TLS-NEXT: .section .bss.tls,"",@
|
; NO-TLS-NEXT: .section .bss.tls,"",@
|
||||||
; CHECK-NEXT: .p2align 2
|
; CHECK-NEXT: .p2align 2
|
||||||
; CHECK-NEXT: tls:
|
; CHECK-NEXT: tls:
|
||||||
|
@ -5,15 +5,26 @@
|
|||||||
tls_store:
|
tls_store:
|
||||||
.functype tls_store (i32) -> ()
|
.functype tls_store (i32) -> ()
|
||||||
# CHECK: global.get __tls_base
|
# CHECK: global.get __tls_base
|
||||||
# CHECK-NEXT: i32.const tls@TLSREL
|
# CHECK-NEXT: i32.const tls1@TLSREL
|
||||||
# CHECK-NEXT: i32.add
|
# CHECK-NEXT: i32.add
|
||||||
# CHECK-NEXT: i32.store 0
|
# CHECK-NEXT: i32.store 0
|
||||||
global.get __tls_base
|
global.get __tls_base
|
||||||
i32.const tls@TLSREL
|
i32.const tls1@TLSREL
|
||||||
i32.add
|
i32.add
|
||||||
i32.store 0
|
i32.store 0
|
||||||
end_function
|
end_function
|
||||||
|
|
||||||
|
.section .tls.foo,"T",@
|
||||||
|
# CHECK: .tls.foo,"T",@
|
||||||
|
tls1:
|
||||||
|
.int32 42
|
||||||
|
.size tls1, 4
|
||||||
|
|
||||||
|
.section custom_tls,"T",@
|
||||||
|
# CHECK: custom_tls,"T",@
|
||||||
|
tls2:
|
||||||
|
.int32 43
|
||||||
|
.size tls2, 4
|
||||||
|
|
||||||
# CHECK-OBJ: - Type: CODE
|
# CHECK-OBJ: - Type: CODE
|
||||||
# CHECK-OBJ-NEXT: Relocations:
|
# CHECK-OBJ-NEXT: Relocations:
|
||||||
@ -39,5 +50,22 @@ tls_store:
|
|||||||
# CHECK-OBJ-NEXT: Flags: [ UNDEFINED ]
|
# CHECK-OBJ-NEXT: Flags: [ UNDEFINED ]
|
||||||
# CHECK-OBJ-NEXT: - Index: 2
|
# CHECK-OBJ-NEXT: - Index: 2
|
||||||
# CHECK-OBJ-NEXT: Kind: DATA
|
# CHECK-OBJ-NEXT: Kind: DATA
|
||||||
# CHECK-OBJ-NEXT: Name: tls
|
# CHECK-OBJ-NEXT: Name: tls1
|
||||||
# CHECK-OBJ-NEXT: Flags: [ UNDEFINED ]
|
# CHECK-OBJ-NEXT: Flags: [ BINDING_LOCAL ]
|
||||||
|
# CHECK-OBJ-NEXT: Segment: 0
|
||||||
|
# CHECK-OBJ-NEXT: Size: 4
|
||||||
|
# CHECK-OBJ-NEXT: - Index: 3
|
||||||
|
# CHECK-OBJ-NEXT: Kind: DATA
|
||||||
|
# CHECK-OBJ-NEXT: Name: tls2
|
||||||
|
# CHECK-OBJ-NEXT: Flags: [ BINDING_LOCAL ]
|
||||||
|
# CHECK-OBJ-NEXT: Segment: 1
|
||||||
|
# CHECK-OBJ-NEXT: Size: 4
|
||||||
|
# CHECK-OBJ-NEXT: SegmentInfo:
|
||||||
|
# CHECK-OBJ-NEXT: - Index: 0
|
||||||
|
# CHECK-OBJ-NEXT: Name: .tls.foo
|
||||||
|
# CHECK-OBJ-NEXT: Alignment: 0
|
||||||
|
# CHECK-OBJ-NEXT: Flags: [ TLS ]
|
||||||
|
# CHECK-OBJ-NEXT: - Index: 1
|
||||||
|
# CHECK-OBJ-NEXT: Name: custom_tls
|
||||||
|
# CHECK-OBJ-NEXT: Alignment: 0
|
||||||
|
# CHECK-OBJ-NEXT: Flags: [ TLS ]
|
||||||
|
Loading…
Reference in New Issue
Block a user