summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/eflags-copy-expansion.mir
blob: 385e3d9a67df80bf65575870b8732ad7af3dcd93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# RUN: llc -run-pass postrapseudos -mtriple=i386-apple-macosx -o - %s | FileCheck %s

# Verify that we correctly save and restore eax when copying eflags,
# even when only a smaller alias of eax is used. We used to check only
# eax and not its aliases.
# PR27624.

--- |
  target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"

  define void @foo() {
  entry:
    br label %false
  false:
    ret void
  }

...

---
name:            foo
tracksRegLiveness: true
liveins:
  - { reg: '$edi' }
body:             |
  bb.0.entry:
    liveins: $edi
    NOOP implicit-def $al

    ; The bug was triggered only when LivePhysReg is used, which
    ; happens only when the heuristic for the liveness computation
    ; failed. The liveness computation heuristic looks at 10 instructions
    ; before and after the copy. Make sure we do not reach the definition of
    ; AL in 10 instructions, otherwise the heuristic will see that it is live.
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    NOOP
    ; Save AL.
    ; CHECK: PUSH32r killed $eax

    ; Copy edi into EFLAGS
    ; CHECK-NEXT: $eax = MOV32rr $edi
    ; CHECK-NEXT: $al = ADD8ri $al, 127, implicit-def $eflags
    ; CHECK-NEXT: SAHF implicit-def $eflags, implicit $ah
    $eflags = COPY $edi

    ; Restore AL.
    ; CHECK-NEXT: $eax = POP32r
  bb.1.false:
    liveins: $al
    NOOP implicit $al
    RETQ

...
OpenPOWER on IntegriCloud