[llvm] e78cea0 - [X86][test] Precommit D122541 tests for prologue/epilogue CFI

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 09:02:36 PDT 2022


Author: Fangrui Song
Date: 2022-03-30T09:02:23-07:00
New Revision: e78cea0a91e27cb75cdc4a428512d776feb16a86

URL: https://github.com/llvm/llvm-project/commit/e78cea0a91e27cb75cdc4a428512d776feb16a86
DIFF: https://github.com/llvm/llvm-project/commit/e78cea0a91e27cb75cdc4a428512d776feb16a86.diff

LOG: [X86][test] Precommit D122541 tests for prologue/epilogue CFI

Currently there is no CFI_INSTRUCTION MIR test with .ll input. This patch
adds some -stop-after=prologepilog tests.

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/cfi-xmm.ll
    llvm/test/CodeGen/X86/epilogue-cfi-fp.ll
    llvm/test/CodeGen/X86/push-cfi.ll
    llvm/test/CodeGen/X86/throws-cfi-fp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/cfi-xmm.ll b/llvm/test/CodeGen/X86/cfi-xmm.ll
index dbb8a61320dc1..e98f71d49366e 100644
--- a/llvm/test/CodeGen/X86/cfi-xmm.ll
+++ b/llvm/test/CodeGen/X86/cfi-xmm.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple x86_64-w64-windows-gnu -filetype=asm -exception-model=dwarf -o - %s | FileCheck %s
+; RUN: llc < %s -mtriple x86_64-w64-windows-gnu -exception-model=dwarf -stop-after=prologepilog | FileCheck %s --check-prefix=PEI
 
 define void @_Z1fv() {
 entry:
@@ -19,3 +20,16 @@ entry:
 ; CHECK:   addq    $40, %rsp
 ; CHECK:   retq
 ; CHECK:   .cfi_endproc
+
+; PEI-LABEL: name: _Z1fv
+; PEI:         $rsp = frame-setup SUB64ri8 $rsp, 40, implicit-def dead $eflags
+; PEI-NEXT:    frame-setup MOVAPSmr $rsp, 1, $noreg, 16, $noreg, killed $xmm15 :: (store (s128) into %fixed-stack.1)
+; PEI-NEXT:    frame-setup MOVAPSmr $rsp, 1, $noreg, 0, $noreg, killed $xmm10 :: (store (s128) into %fixed-stack.0)
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION def_cfa_offset 48
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION offset $xmm10, -48
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION offset $xmm15, -32
+; PEI-NEXT:    INLINEASM {{.*}}
+; PEI-NEXT:    $xmm10 = MOVAPSrm $rsp, 1, $noreg, 0, $noreg :: (load (s128) from %fixed-stack.0)
+; PEI-NEXT:    $xmm15 = MOVAPSrm $rsp, 1, $noreg, 16, $noreg :: (load (s128) from %fixed-stack.1)
+; PEI-NEXT:    $rsp = frame-destroy ADD64ri8 $rsp, 40, implicit-def dead $eflags
+; PEI-NEXT:    RET 0

diff  --git a/llvm/test/CodeGen/X86/epilogue-cfi-fp.ll b/llvm/test/CodeGen/X86/epilogue-cfi-fp.ll
index 972db676c527a..930b3537d4378 100644
--- a/llvm/test/CodeGen/X86/epilogue-cfi-fp.ll
+++ b/llvm/test/CodeGen/X86/epilogue-cfi-fp.ll
@@ -1,4 +1,6 @@
 ; RUN: llc -O0 %s -o - | FileCheck %s
+; RUN: llc -O0 %s -o - | FileCheck %s
+; RUN: llc < %s -stop-after=prologepilog | FileCheck %s --check-prefix=PEI
 
 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
 target triple = "i686-pc-linux"
@@ -11,6 +13,11 @@ define i32 @foo(i32 %i, i32 %j, i32 %k, i32 %l, i32 %m) #0 {
 ; CHECK-NEXT:    .cfi_def_cfa %esp, 4
 ; CHECK-NEXT:    retl
 
+; PEI-LABEL: name: foo
+; PEI:         $ebp = frame-destroy POP32r implicit-def $esp, implicit $esp
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION def_cfa $esp, 4
+; PEI-NEXT:    RET 0, killed $eax
+
 entry:
   %i.addr = alloca i32, align 4
   %j.addr = alloca i32, align 4

diff  --git a/llvm/test/CodeGen/X86/push-cfi.ll b/llvm/test/CodeGen/X86/push-cfi.ll
index d1e393053f645..670975e7c2212 100644
--- a/llvm/test/CodeGen/X86/push-cfi.ll
+++ b/llvm/test/CodeGen/X86/push-cfi.ll
@@ -1,5 +1,6 @@
 ; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s -check-prefix=LINUX -check-prefix=CHECK
 ; RUN: llc < %s -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=DARWIN -check-prefix=CHECK
+; RUN: llc < %s -mtriple=i686-pc-linux -stop-after=prologepilog | FileCheck %s --check-prefix=PEI
 
 declare i32 @__gxx_personality_v0(...)
 declare void @good(i32 %a, i32 %b, i32 %c, i32 %d)
@@ -25,6 +26,12 @@ declare void @empty()
 ; LINUX: .cfi_adjust_cfa_offset -16
 ; DARWIN-NOT: .cfi_escape
 ; DARWIN-NOT: pushl
+
+; PEI-LABEL: name: test1_nofp
+; PEI:         $esp = frame-setup SUB32ri8 $esp, 12, implicit-def dead $eflags
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION def_cfa_offset 16
+; PEI-NOT:     frame-setup CFI_INSTRUCTION
+; PEI:         ...
 define void @test1_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
 entry:
   invoke void @good(i32 1, i32 2, i32 3, i32 4)

diff  --git a/llvm/test/CodeGen/X86/throws-cfi-fp.ll b/llvm/test/CodeGen/X86/throws-cfi-fp.ll
index 16ebda9ac52f8..9a73b40ef9dd1 100644
--- a/llvm/test/CodeGen/X86/throws-cfi-fp.ll
+++ b/llvm/test/CodeGen/X86/throws-cfi-fp.ll
@@ -1,4 +1,5 @@
 ; RUN: llc %s -o - | FileCheck %s
+; RUN: llc < %s -stop-after=prologepilog | FileCheck %s --check-prefix=PEI
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
@@ -19,6 +20,22 @@ define void @_Z6throwsv() #0 personality i8* bitcast (i32 (...)* @__gxx_personal
 ; CHECK-NEXT:    .LBB0_1:
 ; CHECK-NEXT:    .cfi_def_cfa %rbp, 16
 
+; PEI-LABEL: name: _Z6throwsv
+; PEI:         frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION def_cfa_offset 16
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION offset $rbp, -16
+; PEI-NEXT:    $rbp = frame-setup MOV64rr $rsp
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION def_cfa_register $rbp
+; PEI-NEXT:    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
+; PEI-NEXT:    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
+; PEI-NEXT:    {{^ +}}CFI_INSTRUCTION offset $rbx, -24
+; PEI:         bb.4.try.cont:
+; PEI-NEXT:      $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags
+; PEI-NEXT:      $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
+; PEI-NEXT:      $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
+; PEI-NEXT:      {{^ +}}CFI_INSTRUCTION def_cfa $rsp, 8
+; PEI-NEXT:      RET 0
+
 entry:
   %.b5 = load i1, i1* @_ZL11ShouldThrow, align 1
   br i1 %.b5, label %if.then, label %try.cont


        


More information about the llvm-commits mailing list