[all-commits] [llvm/llvm-project] 947786: [clang] Add support for __attribute__((guard(nocf)))

alvinhochun via All-commits all-commits at lists.llvm.org
Tue Aug 23 13:40:34 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 94778692ad25456c9042caae96c40a7c066b6249
      https://github.com/llvm/llvm-project/commit/94778692ad25456c9042caae96c40a7c066b6249
  Author: Alvin Wong <alvin at alvinhc.com>
  Date:   2022-08-23 (Tue, 23 Aug 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/Attr.td
    M clang/test/CodeGen/guard_nocf.c
    M clang/test/CodeGenCXX/guard_nocf.cpp
    M clang/test/Misc/pragma-attribute-supported-attributes-list.test
    M clang/test/Sema/attr-guard_nocf.c

  Log Message:
  -----------
  [clang] Add support for __attribute__((guard(nocf)))

To support using Control Flow Guard with mingw-w64, Clang needs to
accept `__declspec(guard(nocf))` also for the GNU target. Since mingw
has `#define __declspec(a) __attribute__((a))` as built-in, the simplest
solution is to accept `__attribute__((guard(nocf)))` to be compatible with
MSVC and Clang's msvc target.

As a side effect, this also adds `[[clang::guard(nocf)]]` for C++.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D132302


  Commit: c0214db51ad623361a59844e657748aed32f8d87
      https://github.com/llvm/llvm-project/commit/c0214db51ad623361a59844e657748aed32f8d87
  Author: Alvin Wong <alvin at alvinhc.com>
  Date:   2022-08-23 (Tue, 23 Aug 2022)

  Changed paths:
    M llvm/lib/Transforms/CFGuard/CFGuard.cpp
    M llvm/test/CodeGen/AArch64/cfguard-checks.ll
    M llvm/test/CodeGen/AArch64/cfguard-module-flag.ll
    M llvm/test/CodeGen/ARM/cfguard-checks.ll
    M llvm/test/CodeGen/ARM/cfguard-module-flag.ll
    M llvm/test/CodeGen/WinCFGuard/cfguard-cast.ll
    M llvm/test/CodeGen/WinCFGuard/cfguard-giats.ll
    A llvm/test/CodeGen/WinCFGuard/cfguard-mingw.ll
    A llvm/test/CodeGen/X86/cfguard-checks-funclet.ll
    M llvm/test/CodeGen/X86/cfguard-checks.ll
    M llvm/test/CodeGen/X86/cfguard-module-flag.ll
    M llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll
    M llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll

  Log Message:
  -----------
  [llvm] Mark CFGuard fn ptr symbol as DSO local and add tests for mingw

For mingw target, if a symbol is not marked DSO local, a `.refptr` is
generated for it. This makes CFG check calls use an extra pointer
dereference, which adds extra overhead compared to the MSVC version,
so mark the CFG guard check funciton pointer DSO local to stop it.
This should have no effect on MSVC target.

Also adapt the existing cfguard tests to run for mingw targets, so that
this change is checked.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D132331


Compare: https://github.com/llvm/llvm-project/compare/b10565620714...c0214db51ad6


More information about the All-commits mailing list