brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · f003ab5 Raw
31 lines · plain
1; RUN: llc -mtriple=wasm32-unknown-unknown < %s -asm-verbose=false | FileCheck -DPTR=32 %s2; RUN: llc -mtriple=wasm64-unknown-unknown < %s -asm-verbose=false | FileCheck -DPTR=64 %s3; RUN: llc -mtriple=wasm32-unknown-linux < %s -asm-verbose=false | FileCheck -DPTR=32 %s4 5; This tests the implementation of __builtin_return_address on non-Emscripten6; WebAssembly. wasm has no introspectable return address (a frame's return7; address is not addressable in linear memory), so the builtin soundly degrades8; to a null pointer rather than erroring the compile.9 10; CHECK-LABEL: test_returnaddress:11; CHECK-NEXT: .functype test_returnaddress () -> (i[[PTR]]){{$}}12; CHECK-NEXT: {{^}} i[[PTR]].const 0{{$}}13; CHECK-NEXT: {{^}} end_function{{$}}14define ptr @test_returnaddress() {15  %r = call ptr @llvm.returnaddress(i32 0)16  ret ptr %r17}18 19; A non-zero depth also degrades to null on wasm.20; CHECK-LABEL: test_returnaddress_depth:21; CHECK-NEXT: .functype test_returnaddress_depth () -> (i[[PTR]]){{$}}22; CHECK-NEXT: {{^}} i[[PTR]].const 0{{$}}23; CHECK-NEXT: {{^}} end_function{{$}}24define ptr @test_returnaddress_depth() {25  %r = call ptr @llvm.returnaddress(i32 1)26  ret ptr %r27}28 29; LLVM represents __builtin_return_address as call to this function in IR.30declare ptr @llvm.returnaddress(i32 immarg)31