[all-commits] [llvm/llvm-project] a41487: [x64][win] Add compiler support for x64 import cal...

Daniel Paoliello via All-commits all-commits at lists.llvm.org
Tue May 20 14:49:03 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a414877a7a5f000d01370acb1162eb1dea87f48c
      https://github.com/llvm/llvm-project/commit/a414877a7a5f000d01370acb1162eb1dea87f48c
  Author: Daniel Paoliello <danpao at microsoft.com>
  Date:   2025-05-20 (Tue, 20 May 2025)

  Changed paths:
    M llvm/include/llvm/Transforms/CFGuard.h
    M llvm/lib/MC/MCObjectFileInfo.cpp
    M llvm/lib/Target/X86/X86AsmPrinter.cpp
    M llvm/lib/Target/X86/X86AsmPrinter.h
    M llvm/lib/Target/X86/X86ExpandPseudo.cpp
    M llvm/lib/Target/X86/X86FastISel.cpp
    M llvm/lib/Target/X86/X86FrameLowering.cpp
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/lib/Target/X86/X86ISelLowering.h
    M llvm/lib/Target/X86/X86ISelLoweringCall.cpp
    M llvm/lib/Target/X86/X86InstrCompiler.td
    M llvm/lib/Target/X86/X86InstrControl.td
    M llvm/lib/Target/X86/X86InstrFragments.td
    M llvm/lib/Target/X86/X86InstrInfo.cpp
    M llvm/lib/Target/X86/X86InstrPredicates.td
    M llvm/lib/Target/X86/X86MCInstLower.cpp
    M llvm/lib/Target/X86/X86RegisterInfo.cpp
    M llvm/lib/Target/X86/X86RegisterInfo.td
    M llvm/lib/Transforms/CFGuard/CFGuard.cpp
    A llvm/test/CodeGen/X86/win-import-call-optimization-cfguard.ll
    A llvm/test/CodeGen/X86/win-import-call-optimization-jumptable.ll
    A llvm/test/CodeGen/X86/win-import-call-optimization-nocalls.ll
    A llvm/test/CodeGen/X86/win-import-call-optimization.ll
    A llvm/test/MC/X86/win-import-call-optimization.s

  Log Message:
  -----------
  [x64][win] Add compiler support for x64 import call optimization (equivalent to MSVC /d2guardretpoline) (#126631)

This is the x64 equivalent of #121516

Since import call optimization was originally [added to x64 Windows to
implement a more efficient retpoline
mitigation](https://techcommunity.microsoft.com/blog/windowsosplatform/mitigating-spectre-variant-2-with-retpoline-on-windows/295618)
the section and constant names relating to this all mention "retpoline"
and we need to mark indirect calls, control-flow guard calls and jumps
for jump tables in the section alongside calls to imported functions.

As with the AArch64 feature, this emits a new section into the obj which
is used by the MSVC linker to generate the Dynamic Value Relocation
Table and the section itself does not appear in the final binary.

The Windows Loader requires a specific sequence of instructions be
emitted when this feature is enabled:
* Indirect calls/jumps must have the function pointer to jump to in
`rax`.
* Calls to imported functions must use the `rex` prefix and be followed
by a 5-byte nop.
* Indirect calls must be followed by a 3-byte nop.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list