File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
clang/test/CodeGenWebAssembly Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ // REQUIRES: webassembly-registered-target
2
+ // RUN: %clang_cc1 -triple wasm32-unknown-unknown -emit-llvm -O1 -o - %s | FileCheck %s
3
+
4
+ // Basic test of function pointer usage for wasm32
5
+
6
+ #define FUNCTION_POINTER (f ) ((FunctionPointer)(f))
7
+ typedef int (* FunctionPointer )(int a , int b );
8
+
9
+ int fp_as_arg (FunctionPointer fp , int a , int b ) {
10
+ return fp (a , b );
11
+ }
12
+
13
+ int fp_less (int a ) {
14
+ return a ;
15
+ }
16
+
17
+ // CHECK-LABEL: @test
18
+ // CHECK: call i32 @fp_as_arg(ptr noundef @__fp_less_iii, i32 noundef 10, i32 noundef 20)
19
+ void test () {
20
+ return fp_as_arg (FUNCTION_POINTER (fp_less ), 10 , 20 );
21
+ }
22
+
23
+ // CHECK: define internal i32 @__fp_less_iii(i32 %0, i32 %1)
24
+ // CHECK: %2 = call i32 @fp_less(i32 %0)
25
+ // CHECK: ret i32 %2
You can’t perform that action at this time.
0 commit comments