[PATCH] D53541: [COFF, ARM64] Do not emit x86_seh_recoverfp intrinsic

Mandeep Singh Grang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 15 10:24:38 PST 2019


mgrang added a comment.

In D53541#1356904 <https://reviews.llvm.org/D53541#1356904>, @rnk wrote:

> In D53541#1353251 <https://reviews.llvm.org/D53541#1353251>, @mgrang wrote:
>
> > > What about the three stack pointer case of stack realignment plus a dynamic alloca? Typically this is the case where recoverfp is necessary.
> >
> > @rnk Sorry, I missed your comment earlier. I am not sure what scenario the three stack pointer case is. Could you please give me a test case for it?
>
>
> I think you just need a local variable with an alignment greater than the ABI provides, something like:
>
>   struct Foo {
>     Foo();
>     int x, y, z;
>   };
>   int filter(int);
>   void may_throw();
>   void seh_byval(int n) {
>     Foo __declspec(align(32)) o;
>     __try {
>       may_throw();
>     } __except(filter(o.x)) {
>     }
>   }
>


We seem to be generating the same code as MSVC. Here's my test case:

  struct Foo {
    void (*ptr)();
    int x, y, z;
  };
  
  int filter(int);
  void may_throw();
  void seh_byval(int n) {
    struct Foo __declspec(align(32)) o;
    __try {
      may_throw();
    } __except(filter(o.x)) {
    }
  }

MSVC:

  |seh_byval$filt$0| PROC
      stp         fp,lr,[sp,#-0x10]!
      mov         fp,x1
  |$LN5 at seh_byval$|
      ldr         x8,[fp,#0x10]
      ldr         w0,[x8,#8]
      bl          filter
      nop
  |$LN7 at seh_byval$|
      ldp         fp,lr,[sp],#0x10
      ret

LLVM:

  .seh_proc "?filt$0 at 0@seh_byval@@"
  ; %bb.0:                                ; %entry
          movz    x8, #:abs_g1_s:.Lseh_byval$frame_escape_0
          movk    x8, #:abs_g0_nc:.Lseh_byval$frame_escape_0
          add     x8, x1, x8
          ldr     w0, [x8, #8]
          b       filter


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53541/new/

https://reviews.llvm.org/D53541





More information about the cfe-commits mailing list