diff options
author | Ayke van Laethem <[email protected]> | 2019-11-25 00:18:44 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-11-26 14:43:05 +0100 |
commit | 0db26b06624f566790eb799f0252d6a50817e7fd (patch) | |
tree | 9b544725c42706bca37d7cd35f59448a379568dc /interp/testdata | |
parent | 4f7a650614b3d7f6372e0f30d35b14c0b2eba515 (diff) | |
download | tinygo-0db26b06624f566790eb799f0252d6a50817e7fd.tar.gz tinygo-0db26b06624f566790eb799f0252d6a50817e7fd.zip |
interp: support integer icmp of ptrtoint
This kind of code might be generated by the switch implementation of
func values. The func value is represented as a ptrtoint, and before
calling it, it is compared against 0.
Diffstat (limited to 'interp/testdata')
-rw-r--r-- | interp/testdata/consteval.ll | 15 | ||||
-rw-r--r-- | interp/testdata/consteval.out.ll | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/interp/testdata/consteval.ll b/interp/testdata/consteval.ll index 7b2b1e1c1..b3f664dee 100644 --- a/interp/testdata/consteval.ll +++ b/interp/testdata/consteval.ll @@ -2,6 +2,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64--linux" @intToPtrResult = global i8 0 +@ptrToIntResult = global i8 0 define void @runtime.initAll() { call void @main.init() @@ -10,6 +11,7 @@ define void @runtime.initAll() { define internal void @main.init() { call void @testIntToPtr() + call void @testPtrToInt() ret void } @@ -25,3 +27,16 @@ b: store i8 2, i8* @intToPtrResult ret void } + +define internal void @testPtrToInt() { + %zero = icmp eq i64 ptrtoint (i8* @ptrToIntResult to i64), 0 + br i1 %zero, label %a, label %b +a: + ; should not be reached + store i8 1, i8* @ptrToIntResult + ret void +b: + ; should be reached + store i8 2, i8* @ptrToIntResult + ret void +} diff --git a/interp/testdata/consteval.out.ll b/interp/testdata/consteval.out.ll index f1fc91558..175babbf7 100644 --- a/interp/testdata/consteval.out.ll +++ b/interp/testdata/consteval.out.ll @@ -2,6 +2,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64--linux" @intToPtrResult = local_unnamed_addr global i8 2 +@ptrToIntResult = local_unnamed_addr global i8 2 define void @runtime.initAll() local_unnamed_addr { ret void |