[PATCH] D128649: [clang-cl] Handle some pragma alloc_text corner cases handled by MSVC

Stephen Long via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 27 10:26:22 PDT 2022


steplong added a comment.

> Isn't the question whether `f` is considered "extern C" in the end or not? I thought `isExternC()` checks that? Are you saying it would return false for `f` in your example?

Yup, `isExternC()` is returning false for that case because there's "static".

> I'm probably missing something. Is the "static" important in this example? Since `f` has internal linkage, I don't see why a user would care if it's "extern C" or not, and also not in which section it would go (in this case it will not be emitted at all, because it's not used).

Hmm, good point. This is the disassembly I see for:

  extern "C" { static void f(); }
  static void f();
  #pragma alloc_text(s, f)
  static void f() {}
  
  void bar() {
    f();
  }
  
  Disassembly of section .text$mn:
  ?bar@@YAXXZ:
         0:       fd 7b bf a9     stp     x29, x30, [sp, #-16]!
         4:       fd 03 00 91     mov     x29, sp
         8:       00 00 00 94     bl      #0 <?bar@@YAXXZ+0x8>
         c:       fd 7b c1 a8     ldp     x29, x30, [sp], #16
        10:       c0 03 5f d6     ret
  Disassembly of section s:
  s:
         0:       c0 03 5f d6     ret


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128649



More information about the cfe-commits mailing list