xref: /aosp_15_r20/external/llvm/test/CodeGen/MIR/X86/external-symbol-operands.mir (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker# RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o - %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker# This test ensures that the MIR parser parses the external symbol machine
3*9880d681SAndroid Build Coastguard Worker# operands correctly.
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker--- |
6*9880d681SAndroid Build Coastguard Worker  @__stack_chk_guard = external global i8*
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker  define i32 @test(i32 %n) #0 {
9*9880d681SAndroid Build Coastguard Worker  entry:
10*9880d681SAndroid Build Coastguard Worker    %StackGuardSlot = alloca i8*
11*9880d681SAndroid Build Coastguard Worker    %StackGuard = load i8*, i8** @__stack_chk_guard
12*9880d681SAndroid Build Coastguard Worker    call void @llvm.stackprotector(i8* %StackGuard, i8** %StackGuardSlot)
13*9880d681SAndroid Build Coastguard Worker    %a = alloca [128 x i32], align 16
14*9880d681SAndroid Build Coastguard Worker    %idxprom = sext i32 %n to i64
15*9880d681SAndroid Build Coastguard Worker    %arrayidx = getelementptr inbounds [128 x i32], [128 x i32]* %a, i64 0, i64 %idxprom
16*9880d681SAndroid Build Coastguard Worker    %0 = load i32, i32* %arrayidx, align 4
17*9880d681SAndroid Build Coastguard Worker    call void @llvm.stackprotectorcheck(i8** @__stack_chk_guard)
18*9880d681SAndroid Build Coastguard Worker    ret i32 %0
19*9880d681SAndroid Build Coastguard Worker  }
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker  declare void @llvm.stackprotector(i8*, i8**) #1
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker  declare void @llvm.stackprotectorcheck(i8**) #1
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker  attributes #0 = { ssp "stack-protector-buffer-size"="8" }
26*9880d681SAndroid Build Coastguard Worker  attributes #1 = { nounwind }
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker...
29*9880d681SAndroid Build Coastguard Worker---
30*9880d681SAndroid Build Coastguard Workername:            test
31*9880d681SAndroid Build Coastguard WorkertracksRegLiveness: true
32*9880d681SAndroid Build Coastguard Workerbody: |
33*9880d681SAndroid Build Coastguard Worker  bb.0.entry:
34*9880d681SAndroid Build Coastguard Worker    successors: %bb.1.entry, %bb.2.entry
35*9880d681SAndroid Build Coastguard Worker    liveins: %edi
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Worker    %rsp = SUB64ri32 %rsp, 520, implicit-def %eflags
38*9880d681SAndroid Build Coastguard Worker    %rcx = LOAD_STACK_GUARD
39*9880d681SAndroid Build Coastguard Worker    MOV64mr %rsp, 1, _, 512, _, %rcx
40*9880d681SAndroid Build Coastguard Worker    %rax = MOVSX64rr32 %edi
41*9880d681SAndroid Build Coastguard Worker    %eax = MOV32rm %rsp, 4, %rax, 0, _
42*9880d681SAndroid Build Coastguard Worker    CMP64rm %rcx, %rsp, 1, _, 512, _, implicit-def %eflags
43*9880d681SAndroid Build Coastguard Worker    JNE_1 %bb.2.entry, implicit %eflags
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker  bb.1.entry:
46*9880d681SAndroid Build Coastguard Worker    liveins: %eax
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Worker    %rsp = ADD64ri32 %rsp, 520, implicit-def %eflags
49*9880d681SAndroid Build Coastguard Worker    RETQ %eax
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker  bb.2.entry:
52*9880d681SAndroid Build Coastguard Worker    ; CHECK:      CALL64pcrel32 $__stack_chk_fail,
53*9880d681SAndroid Build Coastguard Worker    ; CHECK-NEXT: CALL64pcrel32 $__stack_chk_fail.09-_,
54*9880d681SAndroid Build Coastguard Worker    ; CHECK-NEXT: CALL64pcrel32 $"__stack_chk_fail$",
55*9880d681SAndroid Build Coastguard Worker    ; CHECK-NEXT: CALL64pcrel32 $"$Quoted \09 External symbol \11 ",
56*9880d681SAndroid Build Coastguard Worker    ; CHECK-NEXT: CALL64pcrel32 $__stack_chk_fail + 2,
57*9880d681SAndroid Build Coastguard Worker    ; CHECK-NEXT: CALL64pcrel32 $" check stack - 20" - 20,
58*9880d681SAndroid Build Coastguard Worker    CALL64pcrel32 $__stack_chk_fail, csr_64, implicit %rsp, implicit-def %rsp
59*9880d681SAndroid Build Coastguard Worker    CALL64pcrel32 $__stack_chk_fail.09-_, csr_64, implicit %rsp, implicit-def %rsp
60*9880d681SAndroid Build Coastguard Worker    CALL64pcrel32 $__stack_chk_fail$, csr_64, implicit %rsp, implicit-def %rsp
61*9880d681SAndroid Build Coastguard Worker    CALL64pcrel32 $"$Quoted \09 External symbol \11 ", csr_64, implicit %rsp, implicit-def %rsp
62*9880d681SAndroid Build Coastguard Worker    CALL64pcrel32 $__stack_chk_fail + 2, csr_64, implicit %rsp, implicit-def %rsp
63*9880d681SAndroid Build Coastguard Worker    CALL64pcrel32 $" check stack - 20" - 20, csr_64, implicit %rsp, implicit-def %rsp
64*9880d681SAndroid Build Coastguard Worker...
65