[all-commits] [llvm/llvm-project] b96106: [AArch64][ARM] add -Wunaligned-access only for clang

Yuanfang Chen via All-commits all-commits at lists.llvm.org
Thu Feb 10 10:26:57 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b96106af3f557da833b5e3b9ef9194c23ecd1596
      https://github.com/llvm/llvm-project/commit/b96106af3f557da833b5e3b9ef9194c23ecd1596
  Author: Yuanfang Chen <yuanfang.chen at sony.com>
  Date:   2022-02-10 (Thu, 10 Feb 2022)

  Changed paths:
    M clang/lib/Driver/ToolChains/Arch/AArch64.cpp
    M clang/lib/Driver/ToolChains/Arch/AArch64.h
    M clang/lib/Driver/ToolChains/Arch/ARM.cpp
    M clang/lib/Driver/ToolChains/Arch/ARM.h
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/Driver/arm-alignment.c

  Log Message:
  -----------
  [AArch64][ARM] add -Wunaligned-access only for clang

Reviewed By: lenary

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


  Commit: bd3a1de683f80d174ea9c97000db3ec3276bc022
      https://github.com/llvm/llvm-project/commit/bd3a1de683f80d174ea9c97000db3ec3276bc022
  Author: Yuanfang Chen <yuanfang.chen at sony.com>
  Date:   2022-02-10 (Thu, 10 Feb 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/CodeGenOptions.def
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Driver/Options.td
    M clang/lib/CodeGen/BackendUtil.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/Driver/cl-options.c
    M llvm/include/llvm/CodeGen/CommandFlags.h
    M llvm/include/llvm/CodeGen/Passes.h
    M llvm/include/llvm/InitializePasses.h
    M llvm/include/llvm/LinkAllPasses.h
    M llvm/include/llvm/Target/TargetOptions.h
    M llvm/lib/CodeGen/CMakeLists.txt
    M llvm/lib/CodeGen/CodeGen.cpp
    M llvm/lib/CodeGen/CommandFlags.cpp
    A llvm/lib/CodeGen/JMCInstrumenter.cpp
    M llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
    M llvm/lib/Target/ARM/ARMTargetMachine.cpp
    M llvm/lib/Target/X86/X86TargetMachine.cpp
    A llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
    A llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
    M llvm/tools/opt/opt.cpp

  Log Message:
  -----------
  [clang-cl] Support the /JMC flag

The introduction and some examples are on this page:
https://devblogs.microsoft.com/cppblog/announcing-jmc-stepping-in-visual-studio/

The `/JMC` flag enables these instrumentations:
- Insert at the beginning of every function immediately after the prologue with
  a call to `void __fastcall __CheckForDebuggerJustMyCode(unsigned char *JMC_flag)`.
  The argument for `__CheckForDebuggerJustMyCode` is the address of a boolean
  global variable (the global variable is initialized to 1) with the name
  convention `__<hash>_<filename>`. All such global variables are placed in
  the `.msvcjmc` section.
- The `<hash>` part of `__<hash>_<filename>` has a one-to-one mapping
  with a directory path. MSVC uses some unknown hashing function. Here I
  used DJB.
- Add a dummy/empty COMDAT function `__JustMyCode_Default`.
- Add `/alternatename:__CheckForDebuggerJustMyCode=__JustMyCode_Default` link
  option via ".drectve" section. This is to prevent failure in
  case `__CheckForDebuggerJustMyCode` is not provided during linking.

Implementation:
All the instrumentations are implemented in an IR codegen pass. The pass is placed immediately before CodeGenPrepare pass. This is to not interfere with mid-end optimizations and make the instrumentation target-independent (I'm still working on an ELF port in a separate patch).

Reviewed By: hans

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


Compare: https://github.com/llvm/llvm-project/compare/1d74b531728c...bd3a1de683f8


More information about the All-commits mailing list