Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/CodeGen/WebAssembly/tls.ll
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s | ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s | ||||
; RUN: llc -O0 < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s | |||||
tlively: It would be good to check the negative case, too, i.e with bulk-memory disabled. | |||||
Done. quantum: Done. | |||||
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" | ||||
target triple = "wasm32-unknown-unknown" | target triple = "wasm32-unknown-unknown" | ||||
; SINGLE-LABEL: address_of_tls: | ; CHECK-LABEL: address_of_tls: | ||||
Is CHECK still used as a prefix if it not listed in the invocation of FileCheck? tlively: Is `CHECK` still used as a prefix if it not listed in the invocation of FileCheck? | |||||
Yes, the default prefix is CHECK. quantum: Yes, the default prefix is `CHECK`. | |||||
define i32 @address_of_tls() { | define i32 @address_of_tls() { | ||||
; SINGLE: i32.const $push0=, tls | ; CHECK-DAG: global.get __tls_base | ||||
; SINGLE-NEXT: return $pop0 | ; CHECK-DAG: i32.const tls | ||||
; CHECK-NEXT: i32.add | |||||
; CHECK-NEXT: return | |||||
ret i32 ptrtoint(i32* @tls to i32) | ret i32 ptrtoint(i32* @tls to i32) | ||||
} | } | ||||
; SINGLE: .type tls,@object | ; CHECK-LABEL: ptr_to_tls | ||||
If the only difference of O0 and O2 results is the order of global.get and i32.const, you can use [[ https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive | CHECK-DAG ]] directive, like ; CHECK-DAG: global.get __tls_base ; CHECK-DAG: i32.const tls ... The same for other functions too. Maybe we don't need separate O0 and O2 testing in this file. aheejin: If the only difference of O0 and O2 results is the order of `global.get` and `i32.const`, you… | |||||
Will do. I didn't know CHECK-DAG existed. quantum: Will do. I didn't know `CHECK-DAG` existed. | |||||
If the point of testing with -O0 and -O2 is to test both with and without FastIsel, it might be better to pass -fast-isel to explicitly enable it instead. tlively: If the point of testing with -O0 and -O2 is to test both with and without FastIsel, it might be… | |||||
Changing to use -fast-isel. quantum: Changing to use `-fast-isel`. | |||||
; SINGLE-NEXT: .section .bss.tls,"",@ | define i32* @ptr_to_tls() { | ||||
; SINGLE-NEXT: .p2align 2 | ; CHECK-DAG: global.get __tls_base | ||||
; SINGLE-NEXT: tls: | ; CHECK-DAG: i32.const tls | ||||
; SINGLE-NEXT: .int32 0 | ; CHECK-NEXT: i32.add | ||||
@tls = internal thread_local global i32 0 | ; CHECK-NEXT: return | ||||
ret i32* @tls | |||||
} | |||||
; CHECK-LABEL: tls_load | |||||
define i32 @tls_load() { | |||||
; CHECK-DAG: global.get __tls_base | |||||
; CHECK-DAG: i32.const tls | |||||
; CHECK-NEXT: i32.add | |||||
; CHECK-NEXT: i32.load 0 | |||||
; CHECK-NEXT: return | |||||
%tmp = load i32, i32* @tls, align 4 | |||||
ret i32 %tmp | |||||
} | |||||
; CHECK-LABEL: tls_store | |||||
define void @tls_store(i32 %x) { | |||||
; CHECK-DAG: global.get __tls_base | |||||
; CHECK-DAG: i32.const tls | |||||
; CHECK-NEXT: i32.add | |||||
; CHECK-NEXT: i32.store 0 | |||||
; CHECK-NEXT: return | |||||
store i32 %x, i32* @tls, align 4 | |||||
ret void | |||||
} | |||||
; CHECK-LABEL: tls_size: | |||||
; CHECK-NEXT: .functype tls_size () -> (i32) | |||||
; CHECK-NEXT: global.get __tls_size | |||||
; CHECK-NEXT: return | |||||
declare i32 @llvm.wasm.tls.size.i32() | |||||
define i32 @tls_size() { | |||||
%1 = call i32 @llvm.wasm.tls.size.i32() | |||||
ret i32 %1 | |||||
} | |||||
; CHECK: .type tls,@object | |||||
; CHECK-NEXT: .section .tbss.tls,"",@ | |||||
; CHECK-NEXT: .p2align 2 | |||||
; CHECK-NEXT: tls: | |||||
; CHECK-NEXT: .int32 0 | |||||
@tls = internal thread_local(localexec) global i32 0 |
It would be good to check the negative case, too, i.e with bulk-memory disabled.