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.
This commit is contained in:
Ayke van Laethem
2019-11-25 00:18:44 +01:00
committed by Ron Evans
parent 4f7a650614
commit 0db26b0662
4 changed files with 57 additions and 13 deletions
+15
View File
@@ -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
}