1; RUN: opt -S -lowertypetests < %s | llc -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s 2 3; Tests that we correctly assign indexes for control flow integrity. 4 5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 6target triple = "wasm32-unknown-unknown" 7 8@0 = private unnamed_addr constant [2 x void (...)*] [void (...)* bitcast (void ()* @f to void (...)*), void (...)* bitcast (void ()* @g to void (...)*)], align 16 9 10; CHECK-LABEL: h: 11; CHECK-NOT: .indidx 12define void @h() !type !0 { 13 ret void 14} 15 16; CHECK-LABEL: f: 17; CHECK: .indidx 1 18define void @f() !type !0 { 19 ret void 20} 21 22; CHECK-LABEL: g: 23; CHECK: .indidx 2 24define void @g() !type !1 { 25 ret void 26} 27 28!0 = !{i32 0, !"typeid1"} 29!1 = !{i32 0, !"typeid2"} 30 31declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone 32declare void @llvm.trap() nounwind noreturn 33 34; CHECK-LABEL: foo: 35; CHECK: br_if 36; CHECK: br_if 37; CHECK: unreachable 38define i1 @foo(i8* %p) { 39 %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1") 40 br i1 %x, label %contx, label %trap 41 42trap: 43 tail call void @llvm.trap() #1 44 unreachable 45 46contx: 47 %y = call i1 @llvm.type.test(i8* %p, metadata !"typeid2") 48 br i1 %y, label %conty, label %trap 49 50conty: 51 %z = add i1 %x, %y 52 ret i1 %z 53} 54