224 lines · plain
1; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=X86_642; RUN: llc -mtriple=x86_64-unknown-unknown-gnux32 < %s | FileCheck %s --check-prefix=ALL --check-prefix=X86_643; RUN: llc -mtriple=i386-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=X864; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39439.5; RUN: llc -mtriple i386-windows-gnu -exception-model sjlj -verify-machineinstrs=0 < %s | FileCheck %s --check-prefix=SJLJ6 7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8;; Test19;; -----10;; Checks ENDBR insertion in case of switch case statement.11;; Also since the function is not internal, make sure that endbr32/64 was 12;; added at the beginning of the function.13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;14 15define i8 @test1(){16; ALL-LABEL: test117; X86_64: endbr6418; X86: endbr3219; ALL: jmp{{q|l}} *20; ALL: .LBB0_1:21; X86_64-NEXT: endbr6422; X86-NEXT: endbr3223; ALL: .LBB0_2:24; X86_64-NEXT: endbr6425; X86-NEXT: endbr3226entry:27 %0 = select i1 undef, ptr blockaddress(@test1, %bb), ptr blockaddress(@test1, %bb6) ; <ptr> [#uses=1]28 indirectbr ptr %0, [label %bb, label %bb6]29 30bb: ; preds = %entry31 ret i8 132 33bb6: ; preds = %entry34 ret i8 235}36 37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;38;; Test239;; -----40;; Checks NOTRACK insertion in case of switch case statement.41;; Check that there is no ENDBR insertion in the following case statements.42;; Also since the function is not internal, ENDBR instruction should be43;; added to its first basic block.44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;45 46define i32 @test2(i32 %a) {47; ALL-LABEL: test248; X86_64: endbr6449; X86: endbr3250; ALL: notrack jmp{{q|l}} *51; X86_64-NOT: endbr6452; X86-NOT: endbr3253entry:54 %retval = alloca i32, align 455 %a.addr = alloca i32, align 456 store i32 %a, ptr %a.addr, align 457 %0 = load i32, ptr %a.addr, align 458 switch i32 %0, label %sw.default [59 i32 0, label %sw.bb60 i32 1, label %sw.bb161 i32 2, label %sw.bb262 i32 3, label %sw.bb363 i32 4, label %sw.bb464 ]65 66sw.bb: ; preds = %entry67 store i32 5, ptr %retval, align 468 br label %return69 70sw.bb1: ; preds = %entry71 store i32 7, ptr %retval, align 472 br label %return73 74sw.bb2: ; preds = %entry75 store i32 2, ptr %retval, align 476 br label %return77 78sw.bb3: ; preds = %entry79 store i32 32, ptr %retval, align 480 br label %return81 82sw.bb4: ; preds = %entry83 store i32 73, ptr %retval, align 484 br label %return85 86sw.default: ; preds = %entry87 store i32 0, ptr %retval, align 488 br label %return89 90return: ; preds = %sw.default, %sw.bb4, %sw.bb3, %sw.bb2, %sw.bb1, %sw.bb91 %1 = load i32, ptr %retval, align 492 ret i32 %193}94 95;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;96;; Test397;; -----98;; Checks ENDBR insertion in case of indirect call instruction.99;; The new instruction should be added to the called function (test6)100;; although it is internal.101;; Also since the function is not internal, ENDBR instruction should be102;; added to its first basic block.103;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;104 105define void @test3() {106; ALL-LABEL: test3107; X86_64: endbr64108; X86: endbr32109; ALL: call{{q|l}} *110entry:111 %f = alloca ptr, align 8112 store ptr @test6, ptr %f, align 8113 %0 = load ptr, ptr %f, align 8114 %call = call i32 (...) %0()115 ret void116}117 118;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;119;; Test4120;; -----121;; Checks ENDBR insertion in case of setjmp-like function calls.122;; Also since the function is not internal, ENDBR instruction should be123;; added to its first basic block.124;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;125 126@buf = internal global [5 x ptr] zeroinitializer127declare ptr @llvm.frameaddress(i32)128declare ptr @llvm.stacksave()129declare i32 @llvm.eh.sjlj.setjmp(ptr)130 131define i32 @test4() {132; ALL-LABEL: test4133; X86_64: endbr64134; X86: endbr32135; ALL: .LBB3_3:136; X86_64-NEXT: endbr64137; X86-NEXT: endbr32138 %fp = tail call ptr @llvm.frameaddress(i32 0)139 store ptr %fp, ptr @buf, align 16140 %sp = tail call ptr @llvm.stacksave()141 store ptr %sp, ptr getelementptr inbounds ([5 x ptr], ptr @buf, i64 0, i64 2), align 16142 %r = tail call i32 @llvm.eh.sjlj.setjmp(ptr @buf)143 ret i32 %r144}145 146;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;147;; Test5148;; -----149;; Checks ENDBR insertion in case of internal function.150;; Since the function is internal and its address was not taken,151;; make sure that endbr32/64 was not added at the beginning of the 152;; function.153;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;154 155define internal i8 @test5(){156; ALL-LABEL: test5157; X86_64-NOT: endbr64158; X86-NOT: endbr32159 ret i8 1160}161 162;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;163;; Test6164;; -----165;; Checks ENDBR insertion in case of function that its was address taken.166;; Since the function's address was taken by test3() and despite being167;; internal, check for added endbr32/64 at the beginning of the function.168;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;169 170define internal i32 @test6(i32 %a) {171; ALL-LABEL: test6172; X86_64: endbr64173; X86: endbr32174 ret i32 1175}176 177;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;178;; Test7179;; -----180;; Checks ENDBR insertion in case of non-intrenal function.181;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;182 183define i32 @test7() {184; ALL-LABEL: test7185; X86_64: endbr64186; X86: endbr32187 ret i32 1188}189 190;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;191;; Test8192;; -----193;; Checks that NO TRACK prefix is not added for indirect jumps to a jump-194;; table that was created for SJLJ dispatch.195;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;196 197declare void @_Z20function_that_throwsv()198declare i32 @__gxx_personality_sj0(...)199declare ptr @__cxa_begin_catch(ptr)200declare void @__cxa_end_catch()201 202define void @test8() personality ptr @__gxx_personality_sj0 {203;SJLJ-LABEL: test8204;SJLJ-NOT: ds205entry:206 invoke void @_Z20function_that_throwsv()207 to label %try.cont unwind label %lpad208 209lpad:210 %0 = landingpad { ptr, i32 }211 catch ptr null212 %1 = extractvalue { ptr, i32 } %0, 0213 %2 = tail call ptr @__cxa_begin_catch(ptr %1)214 tail call void @__cxa_end_catch()215 br label %try.cont216 217try.cont:218 ret void219}220 221!llvm.module.flags = !{!0}222 223!0 = !{i32 8, !"cf-protection-branch", i32 1}224