mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +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 {
|
||||
WASM_SEG_FLAG_STRINGS = 0x1,
|
||||
WASM_SEG_FLAG_TLS = 0x2,
|
||||
};
|
||||
|
||||
// Kinds of event attributes.
|
||||
|
@ -2009,11 +2009,14 @@ static const Comdat *getWasmComdat(const GlobalValue *GV) {
|
||||
static unsigned getWasmSectionFlags(SectionKind K) {
|
||||
unsigned Flags = 0;
|
||||
|
||||
// TODO(sbc): Add suport for K.isMergeableConst()
|
||||
if (K.isThreadLocal())
|
||||
Flags |= wasm::WASM_SEG_FLAG_TLS;
|
||||
|
||||
if (K.isMergeableCString())
|
||||
Flags |= wasm::WASM_SEG_FLAG_STRINGS;
|
||||
|
||||
// TODO(sbc): Add suport for K.isMergeableConst()
|
||||
|
||||
return Flags;
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,9 @@ public:
|
||||
case 'G':
|
||||
Group = true;
|
||||
break;
|
||||
case 'T':
|
||||
flags |= wasm::WASM_SEG_FLAG_TLS;
|
||||
break;
|
||||
case 'S':
|
||||
flags |= wasm::WASM_SEG_FLAG_STRINGS;
|
||||
break;
|
||||
|
@ -69,6 +69,8 @@ void MCSectionWasm::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
|
||||
OS << 'G';
|
||||
if (SegmentFlags & wasm::WASM_SEG_FLAG_STRINGS)
|
||||
OS << 'S';
|
||||
if (SegmentFlags & wasm::WASM_SEG_FLAG_TLS)
|
||||
OS << 'T';
|
||||
|
||||
OS << '"';
|
||||
|
||||
|
@ -544,6 +544,7 @@ void ScalarBitSetTraits<WasmYAML::SegmentFlags>::bitset(
|
||||
IO &IO, WasmYAML::SegmentFlags &Value) {
|
||||
#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_SEG_FLAG_##X)
|
||||
BCase(STRINGS);
|
||||
BCase(TLS);
|
||||
#undef BCase
|
||||
}
|
||||
|
||||
|
@ -23,4 +23,4 @@ target triple = "wasm32-unknown-unknown"
|
||||
; BULK-MEM-NEXT: .int8 43
|
||||
; BULK-MEM-NEXT: .int8 11
|
||||
; 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
|
||||
; TLS-NEXT: .section .tbss.tls,"",@
|
||||
; TLS-NEXT: .section .tbss.tls,"T",@
|
||||
; NO-TLS-NEXT: .section .bss.tls,"",@
|
||||
; CHECK-NEXT: .p2align 2
|
||||
; CHECK-NEXT: tls:
|
||||
|
@ -72,7 +72,7 @@ define i32 @tls_size() {
|
||||
}
|
||||
|
||||
; CHECK: .type tls,@object
|
||||
; TLS-NEXT: .section .tbss.tls,"",@
|
||||
; TLS-NEXT: .section .tbss.tls,"T",@
|
||||
; NO-TLS-NEXT: .section .bss.tls,"",@
|
||||
; CHECK-NEXT: .p2align 2
|
||||
; CHECK-NEXT: tls:
|
||||
|
@ -5,15 +5,26 @@
|
||||
tls_store:
|
||||
.functype tls_store (i32) -> ()
|
||||
# CHECK: global.get __tls_base
|
||||
# CHECK-NEXT: i32.const tls@TLSREL
|
||||
# CHECK-NEXT: i32.const tls1@TLSREL
|
||||
# CHECK-NEXT: i32.add
|
||||
# CHECK-NEXT: i32.store 0
|
||||
global.get __tls_base
|
||||
i32.const tls@TLSREL
|
||||
i32.const tls1@TLSREL
|
||||
i32.add
|
||||
i32.store 0
|
||||
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-NEXT: Relocations:
|
||||
@ -39,5 +50,22 @@ tls_store:
|
||||
# CHECK-OBJ-NEXT: Flags: [ UNDEFINED ]
|
||||
# CHECK-OBJ-NEXT: - Index: 2
|
||||
# CHECK-OBJ-NEXT: Kind: DATA
|
||||
# CHECK-OBJ-NEXT: Name: tls
|
||||
# CHECK-OBJ-NEXT: Flags: [ UNDEFINED ]
|
||||
# CHECK-OBJ-NEXT: Name: tls1
|
||||
# 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