[PATCH] D53673: [COFF, ARM64] Implement Intrinsic.sponentry for AArch64

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 25 00:28:10 PDT 2018


mstorsjo added a comment.

In https://reviews.llvm.org/D53673#1275103, @yinma wrote:

> I debugged MS ARM64 setjmp/longjmp functions and ARM64 EH runtime. If you looks like assembly output from CL for ARM64, it is using SP instead of FP.


Hmm, in my test it seems like it doesn't even use the SP as it was on on entry, it uses SP on entry + 16:

  $ cat frame.c 
  #include <setjmp.h>
  void other(char* buf);
  jmp_buf jb;
  void func(int a) {
      char buf[100];
      setjmp(jb);
      other(buf);
  }
  $ cl -c frame.c -O2
  Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26726 for ARM64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  frame.c
  $ dumpbin -nologo -disasm frame.obj
  
  Dump of file frame.obj
  
  File Type: COFF OBJECT
  
  func:
    0000000000000000: F81F0FFE  str         lr,[sp,#-0x10]!
    0000000000000004: 94000000  bl          __security_push_cookie
    0000000000000008: D10183FF  sub         sp,sp,#0x60
    000000000000000C: 90000008  adrp        x8,jb
    0000000000000010: 91000100  add         x0,x8,jb
    0000000000000014: 910203E1  add         x1,sp,#0x80
    0000000000000018: 94000000  bl          _setjmpex
    000000000000001C: 910003E0  mov         x0,sp
    0000000000000020: 94000000  bl          other
    0000000000000024: 910183FF  add         sp,sp,#0x60
    0000000000000028: 94000000  bl          __security_pop_cookie
    000000000000002C: F84107FE  ldr         lr,[sp],#0x10
    0000000000000030: D65F03C0  ret

In this case, we first subtract `sp` by `0x10` and later by `0x60`, but in the parameter to `_setjmpex` we pass `sp + 0x80`.



================
Comment at: test/CodeGen/AArch64/sponentry.ll:1
+; RUN: llc -mtriple=aarch64-windows-msvc -disable-fp-elim %s -o - | FileCheck %s
+; RUN: not llc -mtriple=aarch64-windows-msvc %s -o - 2>&1 | FileCheck %s --check-prefix=NOTWORK
----------------
This test should test both with fastisel and dagisel, and should test cases both with and without fixed objects.


Repository:
  rL LLVM

https://reviews.llvm.org/D53673





More information about the llvm-commits mailing list