summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/JMCInstrumenter.cpp
AgeCommit message (Collapse)Author
2024-03-19[NFC][RemoveDIs] Use iterators for insertion at various call-sites (#84736)Jeremy Morse
These are the last remaining "trivial" changes to passes that use Instruction pointers for insertion. All of this should be NFC, it's just changing the spelling of how we identify a position. In one or two locations, I'm also switching uses of getNextNode etc to using std::next with iterators. This too should be NFC. --------- Merged by: Stephen Tozer <stephen.tozer@sony.com>
2023-12-12[CodeGen] Port `JMCInstrumenter` to new pass manager (#75049)paperchalice
2023-08-13[llvm] Drop some more typed pointer bitcasts etc.Bjorn Pettersson
2022-10-19[JMCInstrument] rename ELF section name from ".just.my.code" to ↵Yuanfang Chen
".data.just.my.code" This gives linker scripts a hint about where to place the section.
2022-06-04[CodeGen] Use StringRef::contains (NFC)Kazu Hirata
2022-03-10[JMCInstrument] infer proper path style based on debug infoYuanfang Chen
By default, the path style is decided by the host. This patch makes JMC uses the path style used by the SP directory. This makes JMC output host-independent. Fixes: https://github.com/llvm/llvm-project/issues/54219 Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D121236
2022-03-07Reland "[clang][debug] port clang-cl /JMC flag to ELF"Yuanfang Chen
This relands commit 731347431976509823e38329a96fcbc69fe98cd2. It failed on Windows/Mac because `-fjmc` is only checked for ELF targets. Check the flag unconditionally instead and issue a warning for non-ELF targets.
2022-03-07Revert "[clang][debug] port clang-cl /JMC flag to ELF"Yuanfang Chen
This reverts commit 731347431976509823e38329a96fcbc69fe98cd2. Break bots: http://45.33.8.238/win/54551/step_7.txt http://45.33.8.238/macm1/29590/step_7.txt
2022-03-07[clang][debug] port clang-cl /JMC flag to ELFYuanfang Chen
The motivation is to enable the MSVC-style JMC instrumentation usable by a ELF-based debugger. Since there is no prior experience implementing JMC feature for ELF-based debugger, it might be better to just reuse existing MSVC-style JMC instrumentation. For debuggers that support both ELF&COFF (like lldb), the JMC implementation might be shared between ELF&COFF. If this is found to inadequate, it is pretty low-cost switching to alternatives. Implementation: - The '-fjmc' is already a driver and cc1 flag. Wire it up for ELF in the driver. - Refactor the JMC instrumentation pass a little bit. - The ELF handling is different from MSVC in two places: * the flag section name is ".just.my.code" instead of ".msvcjmc" * the way default function is provided: MSVC uses /alternatename; ELF uses weak function. Based on D118428. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D119910
2022-02-10Reland "[clang-cl] Support the /JMC flag"Yuanfang Chen
This relands commit b380a31de084a540cfa38b72e609b25ea0569bb7. Restrict the tests to Windows only since the flag symbol hash depends on system-dependent path normalization.
2022-02-10Revert "[clang-cl] Support the /JMC flag"Yuanfang Chen
This reverts commit bd3a1de683f80d174ea9c97000db3ec3276bc022. Break bots: https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-windows-x64/b8822587673277278177/overview
2022-02-10[clang-cl] Support the /JMC flagYuanfang Chen
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