[update_llc_test_checks] Support Windows .seh_proc for x86
authorFangrui Song <i@maskray.me>
Wed, 30 Dec 2020 20:32:46 +0000 (12:32 -0800)
committerFangrui Song <i@maskray.me>
Wed, 30 Dec 2020 20:32:47 +0000 (12:32 -0800)
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_function_name.ll
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_function_name.ll.expected
llvm/utils/UpdateTestChecks/asm.py

index 046de36137b0ff595de09f46caa549ae30085821..1488c9f5b229bfac9a898304bbc4cd8232ef1f1b 100644 (file)
@@ -4,6 +4,9 @@
 ;; Check that we accept .Ldsolocal$local: below the function label.
 ; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s --check-prefix=PIC
 
+;; Check that we accept .seh_proc below the function label.
+; RUN: llc -mtriple=x86_64-windows -relocation-model=pic < %s | FileCheck %s --check-prefix=WIN
+
 define hidden i32 @"_Z54bar$ompvariant$bar"() {
 entry:
   ret i32 2
@@ -11,5 +14,8 @@ entry:
 
 define dso_local i32 @dsolocal() {
 entry:
+  call void @ext()
   ret i32 2
 }
+
+declare void @ext()
index 64eaf90ed33ba3aa795f81d42fb8d4994e0c26a2..000e780cb59c1354aaa1b28fd6eba77d48dbdc38 100644 (file)
@@ -5,6 +5,9 @@
 ;; Check that we accept .Ldsolocal$local: below the function label.
 ; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s --check-prefix=PIC
 
+;; Check that we accept .seh_proc below the function label.
+; RUN: llc -mtriple=x86_64-windows -relocation-model=pic < %s | FileCheck %s --check-prefix=WIN
+
 define hidden i32 @"_Z54bar$ompvariant$bar"() {
 ; CHECK-LABEL: _Z54bar$ompvariant$bar:
 ; CHECK:       # %bb.0: # %entry
@@ -15,6 +18,11 @@ define hidden i32 @"_Z54bar$ompvariant$bar"() {
 ; PIC:       # %bb.0: # %entry
 ; PIC-NEXT:    movl $2, %eax
 ; PIC-NEXT:    retq
+;
+; WIN-LABEL: _Z54bar$ompvariant$bar:
+; WIN:       # %bb.0: # %entry
+; WIN-NEXT:    movl $2, %eax
+; WIN-NEXT:    retq
 entry:
   ret i32 2
 }
@@ -22,13 +30,37 @@ entry:
 define dso_local i32 @dsolocal() {
 ; CHECK-LABEL: dsolocal:
 ; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    .cfi_def_cfa_offset 16
+; CHECK-NEXT:    callq ext@PLT
 ; CHECK-NEXT:    movl $2, %eax
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    .cfi_def_cfa_offset 8
 ; CHECK-NEXT:    retq
 ;
 ; PIC-LABEL: dsolocal:
 ; PIC:       # %bb.0: # %entry
+; PIC-NEXT:    pushq %rax
+; PIC-NEXT:    .cfi_def_cfa_offset 16
+; PIC-NEXT:    callq ext@PLT
 ; PIC-NEXT:    movl $2, %eax
+; PIC-NEXT:    popq %rcx
+; PIC-NEXT:    .cfi_def_cfa_offset 8
 ; PIC-NEXT:    retq
+;
+; WIN-LABEL: dsolocal:
+; WIN:       # %bb.0: # %entry
+; WIN-NEXT:    subq $40, %rsp
+; WIN-NEXT:    .seh_stackalloc 40
+; WIN-NEXT:    .seh_endprologue
+; WIN-NEXT:    callq ext
+; WIN-NEXT:    movl $2, %eax
+; WIN-NEXT:    addq $40, %rsp
+; WIN-NEXT:    retq
+; WIN-NEXT:    .seh_endproc
 entry:
+  call void @ext()
   ret i32 2
 }
+
+declare void @ext()
index 7cfd31865a342ffe4a22bccdf42688d5b105a6a8..a42a75ed26bf2d27cc472523de26d27c38bccd9f 100644 (file)
@@ -17,7 +17,7 @@ else:
 ASM_FUNCTION_X86_RE = re.compile(
     r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*(@"?(?P=func)"?| -- Begin function (?P=func))\n(?:\s*\.?Lfunc_begin[^:\n]*:\n)?'
     r'(?:\.L[^$]+\$local:\n)?'      # drop .L<func>$local:
-    r'(?:[ \t]+.cfi_startproc\n)?'  # drop optional cfi noise
+    r'(?:[ \t]+.cfi_startproc\n|.seh_proc[^\n]+\n)?'  # drop optional cfi
     r'(?P<body>^##?[ \t]+[^:]+:.*?)\s*'
     r'^\s*(?:[^:\n]+?:\s*\n\s*\.size|\.cfi_endproc|\.globl|\.comm|\.(?:sub)?section|#+ -- End function)',
     flags=(re.M | re.S))