[PATCH] D136202: [Arm64EC] Refer to dllimport'ed functions correctly.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 18 13:47:23 PDT 2022


efriedma created this revision.
efriedma added reviewers: DavidSpickett, bcl5980, mstorsjo.
Herald added subscribers: zzheng, hiraditya, kristof.beyls.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: LLVM.

Arm64EC has two different ways to refer to dllimport'ed functions in an object file.  One is using the usual __imp_ prefix, the other is using an Arm64EC-specific prefix __imp_aux_.  As far as I can tell, if a function is in an x64 DLL, __imp_aux_ refers to the actual x64 address, while __imp_ points to some linker-generated code that calls the exit thunk.  So __imp_aux_ is used to refer to the address in non-call contexts, while __imp_ is used for calls to avoid the indirect call checker.

One minor quirk I haven't figured out: apparently, in Arm64EC mode, MSVC prefers to use a linker-synthesized stub to call dllimport'ed functions, instead of branching directly.  The linker stub appears to do the same thing that inline code would do, so not sure if it's just a code-size optimization, or if the synthesized stub can actually do something other than just load from the import table in some circumstances.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136202

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
  llvm/test/CodeGen/AArch64/arm64ec-dllimport.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136202.468667.patch
Type: text/x-patch
Size: 5614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221018/29a4aef1/attachment.bin>


More information about the llvm-commits mailing list