1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --include-generated-funcs --version 2 2; RUN: opt -S -passes=lowertypetests -mtriple=aarch64-unknown-linux-gnu %s | FileCheck --check-prefixes=AARCH64 %s 3 4; Test for the jump table generation with branch protection on AArch64 5 6target datalayout = "e-p:64:64" 7 8@0 = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16 9 10 11define void @f() !type !0 { 12 ret void 13} 14 15define internal void @g() !type !0 { 16 ret void 17} 18 19!0 = !{i32 0, !"typeid1"} 20 21declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone 22 23define i1 @foo(ptr %p) { 24 %x = call i1 @llvm.type.test(ptr %p, metadata !"typeid1") 25 ret i1 %x 26} 27 28!llvm.module.flags = !{!1} 29 30!1 = !{i32 4, !"branch-target-enforcement", i32 1} 31 32 33; AARCH64-LABEL: define hidden void @f.cfi() !type !1 { 34; AARCH64-NEXT: ret void 35; 36; 37; AARCH64-LABEL: define internal void @g.cfi() !type !1 { 38; AARCH64-NEXT: ret void 39; 40; 41; AARCH64-LABEL: define i1 @foo 42; AARCH64-SAME: (ptr [[P:%.*]]) { 43; AARCH64-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[P]] to i64 44; AARCH64-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], ptrtoint (ptr @.cfi.jumptable to i64) 45; AARCH64-NEXT: [[TMP3:%.*]] = lshr i64 [[TMP2]], 3 46; AARCH64-NEXT: [[TMP4:%.*]] = shl i64 [[TMP2]], 61 47; AARCH64-NEXT: [[TMP5:%.*]] = or i64 [[TMP3]], [[TMP4]] 48; AARCH64-NEXT: [[TMP6:%.*]] = icmp ule i64 [[TMP5]], 1 49; AARCH64-NEXT: ret i1 [[TMP6]] 50; 51; 52; AARCH64: Function Attrs: naked noinline 53; AARCH64-LABEL: define private void @.cfi.jumptable 54; AARCH64-SAME: () #[[ATTR1:[0-9]+]] align 8 { 55; AARCH64-NEXT: entry: 56; AARCH64-NEXT: call void asm sideeffect "bti c\0Ab $0\0Abti c\0Ab $1\0A", "s,s"(ptr @f.cfi, ptr @g.cfi) 57; AARCH64-NEXT: unreachable 58; 59