1 ; RUN: opt -S -lowertypetests < %s | llc -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s
3 ; Tests that we correctly assign indexes for control flow integrity.
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 @0 = private unnamed_addr constant [2 x void (...)*] [void (...)* bitcast (void ()* @f to void (...)*), void (...)* bitcast (void ()* @g to void (...)*)], align 16
12 define void @h() !type !0 {
18 define void @f() !type !0 {
24 define void @g() !type !1 {
28 !0 = !{i32 0, !"typeid1"}
29 !1 = !{i32 0, !"typeid2"}
31 declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
32 declare void @llvm.trap() nounwind noreturn
38 define i1 @foo(i8* %p) {
39 %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
40 br i1 %x, label %contx, label %trap
43 tail call void @llvm.trap() #1
47 %y = call i1 @llvm.type.test(i8* %p, metadata !"typeid2")
48 br i1 %y, label %conty, label %trap