aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/testdata/pragma.ll
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-03-30 13:41:29 +0200
committerRon Evans <[email protected]>2021-06-24 15:00:30 +0200
commit293f4ea7bc9858c219c75bd3c2bc88dea1d42b99 (patch)
tree362eb8a2bdfc44fad1a0c67607745467ad5ed778 /compiler/testdata/pragma.ll
parentc3032660c9e2e1fd5a188c6ac54902637a77b975 (diff)
downloadtinygo-293f4ea7bc9858c219c75bd3c2bc88dea1d42b99.tar.gz
tinygo-293f4ea7bc9858c219c75bd3c2bc88dea1d42b99.zip
compiler: add tests for pragmas
These pragmas weren't really tested anywhere, except that some code might break if they are not properly applied. These tests make it easy to see they work correctly and also provide a logical place to add new pragma tests. I've also made a slight change to how functions and globals are created: with the change they're also created in the IR even if they're not referenced. This makes testing easier.
Diffstat (limited to 'compiler/testdata/pragma.ll')
-rw-r--r--compiler/testdata/pragma.ll43
1 files changed, 43 insertions, 0 deletions
diff --git a/compiler/testdata/pragma.ll b/compiler/testdata/pragma.ll
new file mode 100644
index 000000000..0fdc753e5
--- /dev/null
+++ b/compiler/testdata/pragma.ll
@@ -0,0 +1,43 @@
+; ModuleID = 'pragma.go'
+source_filename = "pragma.go"
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32--wasi"
+
+@extern_global = external global [0 x i8], align 1
[email protected] = hidden global [4 x i32] zeroinitializer, align 32
[email protected] = hidden global [4 x i32] zeroinitializer, align 16
+
+declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*)
+
+define hidden void @main.init(i8* %context, i8* %parentHandle) unnamed_addr {
+entry:
+ ret void
+}
+
+define void @extern_func() #0 {
+entry:
+ ret void
+}
+
+define hidden void @somepkg.someFunction1(i8* %context, i8* %parentHandle) unnamed_addr {
+entry:
+ ret void
+}
+
+declare void @somepkg.someFunction2(i8*, i8*)
+
+; Function Attrs: inlinehint
+define hidden void @main.inlineFunc(i8* %context, i8* %parentHandle) unnamed_addr #1 {
+entry:
+ ret void
+}
+
+; Function Attrs: noinline
+define hidden void @main.noinlineFunc(i8* %context, i8* %parentHandle) unnamed_addr #2 {
+entry:
+ ret void
+}
+
+attributes #0 = { "wasm-export-name"="extern_func" }
+attributes #1 = { inlinehint }
+attributes #2 = { noinline }