diff options
author | Ayke van Laethem <[email protected]> | 2019-10-31 13:27:21 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-11-01 17:00:32 +0100 |
commit | 923a6f5873c3ae48289f9f3d092e13916b296691 (patch) | |
tree | 7ff761145a9ff8f604708e179517c8af0731dba1 /interp/testdata/scan.ll | |
parent | 071f863e5d5f28976221784efcecebd557a0a8b7 (diff) | |
download | tinygo-923a6f5873c3ae48289f9f3d092e13916b296691.tar.gz tinygo-923a6f5873c3ae48289f9f3d092e13916b296691.zip |
interp: add testing for scanning for side effects
Diffstat (limited to 'interp/testdata/scan.ll')
-rw-r--r-- | interp/testdata/scan.ll | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/interp/testdata/scan.ll b/interp/testdata/scan.ll new file mode 100644 index 000000000..33ae3001f --- /dev/null +++ b/interp/testdata/scan.ll @@ -0,0 +1,53 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64--linux" + +define i64 @returnsConst() { + ret i64 0 +} + +define i64 @returnsArg(i64 %arg) { + ret i64 %arg +} + +declare i64 @externalCall() + +define i64 @externalCallOnly() { + %result = call i64 @externalCall() + ret i64 0 +} + +define i64 @externalCallAndReturn() { + %result = call i64 @externalCall() + ret i64 %result +} + +define i64 @externalCallBranch() { + %result = call i64 @externalCall() + %zero = icmp eq i64 %result, 0 + br i1 %zero, label %if.then, label %if.done + +if.then: + ret i64 2 + +if.done: + ret i64 4 +} + +@cleanGlobalInt = global i64 5 +define i64 @readCleanGlobal() { + %global = load i64, i64* @cleanGlobalInt + ret i64 %global +} + +@dirtyGlobalInt = global i64 5 +define i64 @readDirtyGlobal() { + %global = load i64, i64* @dirtyGlobalInt + ret i64 %global +} + +@functionPointer = global i64()* null +define i64 @callFunctionPointer() { + %fp = load i64()*, i64()** @functionPointer + %result = call i64 %fp() + ret i64 %result +} |