summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
AgeCommit message (Collapse)Author
2022-12-13[CodeGen] llvm::Optional => std::optionalFangrui Song
2022-12-10Don't include None.h (NFC)Kazu Hirata
I've converted all known uses of None to std::nullopt, so we no longer need to include None.h. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-06[CodeView] Add support for local S_CONSTANT recordsTobias Hieta
CodeView doesn't have the ability to represent variables in other ways than as in registers or memory values, but LLVM very often transforms simple values into constants, consider this program: int f () { int i = 123; return i; } LLVM will transform `i` into a constant value and just leave behind a llvm.dbg.value, this can't be represented as a S_LOCAL record in CodeView. But we can represent it as a S_CONSTANT record. This patch checks if the location of a debug value is null, then we will insert a S_CONSTANT record instead of a S_LOCAL value with the flag "OptimizedAway". In lld we then output the S_CONSTANT in the right scope, before they where always inserted in the global stream, now we check the scope before inserting it. This has shown to improve debugging for our developers internally. Fixes to llvm/llvm-project#55958 Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D138995
2022-12-05[DebugInfo] llvm::Optional => std::optionalFangrui Song
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02[CodeGen] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-24[Alignment][NFC] Use Align in MCStreamer::emitValueToAlignmentGuillaume Chatelet
Differential Revision: https://reviews.llvm.org/D138674
2022-11-19[CodeView] Replace GHASH hasher by BLAKE3Alexandre Ganea
Previously, we used SHA-1 for hashing the CodeView type records. SHA-1 in `GloballyHashedType::hashType()` is coming top in the profiles. By simply replacing with BLAKE3, the link time is reduced in our case from 15 sec to 13 sec. I am only using MSVC .OBJs in this case. As a reference, the resulting .PDB is approx 2.1GiB and .EXE is approx 250MiB. Differential Revision: https://reviews.llvm.org/D137101
2022-11-08[clang][pdb] Don't include -fmessage-length in PDB buildinfoTobias Hieta
As discussed in https://reviews.llvm.org/D136474 -fmessage-length creates problems with reproduciability in the PDB files. This patch just drops that argument when writing the PDB file. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D137322
2022-10-07[CodeView] Avoid NULL deref of ScopeMike Hommey
Regression from D131400: cross-language LTO causes a crash in the compiler on the NULL deref of Scope in `isa` call when Rust IR is involved. Presumably, this might affect other languages too, and even Rust itself without cross-language LTO when the Rust compiler switched to LLVM 16. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D134616
2022-09-16Revert "Revert "[clang, llvm] Add __declspec(safebuffers), support it in ↵David Majnemer
CodeView"" This reverts commit cd20a1828605887699579789b5433111d5bc0319 and adds a "let Heading" to NoStackProtectorDocs.
2022-09-13Revert "[clang, llvm] Add __declspec(safebuffers), support it in CodeView"Sylvestre Ledru
Causing: https://github.com/llvm/llvm-project/issues/57709 This reverts commit ab56719acd98778fb2e48fa425ac7c8d27bdea86.
2022-09-12[clang, llvm] Add __declspec(safebuffers), support it in CodeViewDavid Majnemer
__declspec(safebuffers) is equivalent to __attribute__((no_stack_protector)). This information is recorded in CodeView. While we are here, add support for strict_gs_check.
2022-08-16[CodeView] Use non-qualified names for static local variablesSteve Merritt
Static variables declared within a routine or lexical block should be emitted with a non-qualified name. This allows the variables to be visible to the Visual Studio watch window. Differential Revision: https://reviews.llvm.org/D131400
2022-08-08[llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song
With C++17 there is no Clang pedantic warning or MSVC C5051.
2022-06-10[MC] De-capitalize SwitchSection. NFCFangrui Song
Add SwitchSection to return switchSection. The API will be removed soon.
2022-06-07[MC] De-capitalize MCStreamer functionsFangrui Song
Follow-up to c031378ce01b8485ba0ef486654bc9393c4ac024 . The class is mostly consistent now.
2022-05-26[MC] Lower case the first letter of EmitCOFF* EmitWin* EmitCV*. NFCFangrui Song
2022-05-20[CodeView] Combine variable def ranges that are continuous.Zequan Wu
It saves about 1.13% size for chrome.dll.pdb on chrome official build. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D125721
2022-05-18Reland "[dwarf] Emit a DIGlobalVariable for constant strings."Mitch Phillips
An upcoming patch will extend llvm-symbolizer to provide the source line information for global variables. The goal is to move AddressSanitizer off of internal debug info for symbolization onto the DWARF standard (and doing a clean-up in the process). Currently, ASan reports the line information for constant strings if a memory safety bug happens around them. We want to keep this behaviour, so we need to emit debuginfo for these variables as well. Reviewed By: dblaikie, rnk, aprantl Differential Revision: https://reviews.llvm.org/D123534
2022-05-16Revert "[dwarf] Emit a DIGlobalVariable for constant strings."Mitch Phillips
This reverts commit 4680982b36a84770a1600fc438be8ec090671724. Broke a fuchsia windows bot. More details in the review: https://reviews.llvm.org/D123534
2022-05-16[dwarf] Emit a DIGlobalVariable for constant strings.Mitch Phillips
An upcoming patch will extend llvm-symbolizer to provide the source line information for global variables. The goal is to move AddressSanitizer off of internal debug info for symbolization onto the DWARF standard (and doing a clean-up in the process). Currently, ASan reports the line information for constant strings if a memory safety bug happens around them. We want to keep this behaviour, so we need to emit debuginfo for these variables as well. Reviewed By: dblaikie, rnk, aprantl Differential Revision: https://reviews.llvm.org/D123534
2022-04-19MachineModuleInfo: Don't allow dynamically setting DbgInfoAvailableMatt Arsenault
This can be set up front, and used only as a cache. This avoids a field that looks like it requires MIR serialization. I believe this fixes 2 bugs for CodeView. First, this addresses a FIXME that the flag -diable-debug-info-print only works with DWARF. Second, it fixes emitting debug info with emissionKind NoDebug.
2022-03-20[CodeGen] Apply clang-tidy fixes for readability-redundant-smartptr-get (NFC)Kazu Hirata
2022-03-12Cleanup includes: DebugInfo & CodeGenserge-sans-paille
Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121332
2022-03-01[PDB] Add char8_t typeZequan Wu
Differential Revision: https://reviews.llvm.org/D120690
2022-02-10[CodeView] Avoid integer overflow while parsing long version stringsReid Kleckner
This came up on a funny vendor-provided version string that didn't have a standard dotted quad of numbers.
2022-01-20[clang-cl] Support the /HOTPATCH flagAlexandre Ganea
This patch adds support for the MSVC /HOTPATCH flag: https://docs.microsoft.com/sv-se/cpp/build/reference/hotpatch-create-hotpatchable-image?view=msvc-170&viewFallbackFrom=vs-2019 The flag is translated to a new -fms-hotpatch flag, which in turn adds a 'patchable-function' attribute for each function in the TU. This is then picked up by the PatchableFunction pass which would generate a TargetOpcode::PATCHABLE_OP of minsize = 2 (which means the target instruction must resolve to at least two bytes). TargetOpcode::PATCHABLE_OP is only implemented for x86/x64. When targetting ARM/ARM64, /HOTPATCH isn't required (instructions are always 2/4 bytes and suitable for hotpatching). Additionally, when using /Z7, we generate a 'hot patchable' flag in the CodeView debug stream, in the S_COMPILE3 record. This flag is then picked up by LLD (or link.exe) and is used in conjunction with the linker /FUNCTIONPADMIN flag to generate extra space before each function, to accommodate for live patching long jumps. Please see: https://github.com/llvm/llvm-project/blob/d703b922961e0d02a5effdd4bfbb23ad50a3cc9f/lld/COFF/Writer.cpp#L1298 The outcome is that we can finally use Live++ or Recode along with clang-cl. NOTE: It seems that MSVC cl.exe always enables /HOTPATCH on x64 by default, although if we did the same I thought we might generate sub-optimal code (if this flag was active by default). Additionally, MSVC always generates a .debug$S section and a S_COMPILE3 record, which Clang doesn't do without /Z7. Therefore, the following MSVC command-line "cl /c file.cpp" would have to be written with Clang such as "clang-cl /c file.cpp /HOTPATCH /Z7" in order to obtain the same result. Depends on D43002, D80833 and D81301 for the full feature. Differential Revision: https://reviews.llvm.org/D116511
2022-01-19Re-land [CodeView] Add full repro to LF_BUILDINFO recordAlexandre Ganea
This patch writes the full -cc1 command into the resulting .OBJ, like MSVC does. This allows for external tools (Recode, Live++) to rebuild a source file without any external dependency but the .OBJ itself (other than the compiler) and without knowledge of the build system. The LF_BUILDINFO record stores a full path to the compiler, the PWD (CWD at program startup), a relative or absolute path to the source, and the full CC1 command line. The stored command line is self-standing (does not depend on the environment). In the same way, MSVC doesn't exactly store the provided command-line, but an expanded version (a somehow equivalent of CC1) which is also self-standing. For more information see PR36198 and D43002. Differential Revision: https://reviews.llvm.org/D80833
2022-01-06Add Rust to CodeView SourceLanguage (CV_CFL_LANG) enumArlo Siemsen
Microsoft has added several new entries to the CV_CFL_LANG enum, including Rust: https://docs.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang This change adds Rust to the corresponding LLVM enum and translates `dwarf::DW_LANG_Rust` to `SourceLanguage::Rust` in the CodeView AsmPrinter. This means that Rust will no longer emit as Masm. Differential Revision: https://reviews.llvm.org/D115300
2021-12-28[CodeView] Clamp Frontend versionmodimo
D43002 introduced a test debug-info-objname.cpp that outputted the current compiler version into CodeView. Internally we appended a date to the patch version and overflowed the 16-bits allocated to that space. This change clamps the Frontend version outputted values to 16-bits like rGd1185fc081ead71a8bf239ff1814f5ff73084c15 did for the Backend version. Testing: ninja check-all newly added tests correctly clamps and no longer asserts when trying to output the field Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D116243
2021-12-21Reland - [CodeView] Emit S_OBJNAME recordAlexandre Ganea
Reland integrates build fixes & further review suggestions. Thanks to @zturner for the initial S_OBJNAME patch! Differential Revision: https://reviews.llvm.org/D43002
2021-12-21Revert [CodeView] Emit S_OBJNAME recordAlexandre Ganea
Also revert all subsequent fixes: - abd1cbf5e543f0f114d2742e109ead7d7ddbf9c4 [Clang] Disable debug-info-objname.cpp test on Unix until I sort out the issue. - 00ec441253048f5e30540ea26bb0a28c42a5fc18 [Clang] debug-info-objname.cpp test: explictly encode a x86 target when using %clang_cl to avoid falling back to a native CPU triple. - cd407f6e52b09cce2bef24c74b7f36fedc94991b [Clang] Fix build by restricting debug-info-objname.cpp test to x86.
2021-12-21[CodeView] Emit S_OBJNAME recordAlexandre Ganea
Thanks to @zturner for the initial patch! Differential Revision: https://reviews.llvm.org/D43002
2021-12-07[NFC][CodeView] Use one unified access to the module in beginModule.Chih-Ping Chen
Differential Revision: https://reviews.llvm.org/D115257
2021-11-09[CodeView] Properly handle a DISubprogram in getScopeIndex.Chih-Ping Chen
Differential Revision: https://reviews.llvm.org/D113142
2021-11-02[CodeView] Fortran debug info emission in Code View.Chih-Ping Chen
Differential Revision: https://reviews.llvm.org/D112826
2021-10-06DebugInfo: Use clang's preferred names for integer typesDavid Blaikie
This reverts c7f16ab3e3f27d944db72908c9c1b1b7366f5515 / r109694 - which suggested this was done to improve consistency with the gdb test suite. Possible that at the time GCC did not canonicalize integer types, and so matching types was important for cross-compiler validity, or that it was only a case of over-constrained test cases that printed out/tested the exact names of integer types. In any case neither issue seems to exist today based on my limited testing - both gdb and lldb canonicalize integer types (in a way that happens to match Clang's preferred naming, incidentally) and so never print the original text name produced in the DWARF by GCC or Clang. This canonicalization appears to be in `integer_types_same_name_p` for GDB and in `TypeSystemClang::GetBasicTypeEnumeration` for lldb. (I tested this with one translation unit defining 3 variables - `long`, `long (*)()`, and `int (*)()`, and another translation unit that had main, and a function that took `long (*)()` as a parameter - then compiled them with mismatched compilers (either GCC+Clang, or Clang+(Clang with this patch applied)) and no matter the combination, despite the debug info for one CU naming the type "long int" and the other naming it "long", both debuggers printed out the name as "long" and were able to correctly perform overload resolution and pass the `long int (*)()` variable to the `long (*)()` function parameter) Did find one hiccup, identified by the lldb test suite - that CodeView was relying on these names to map them to builtin types in that format. So added some handling for that in LLVM. (these could be split out into separate patches, but seems small enough to not warrant it - will do that if there ends up needing any reverti/revisiting) Differential Revision: https://reviews.llvm.org/D110455
2021-09-30[CodeView] Recognize Fortran95 as Fortran instead of MASMBrock Wyma
Map Fortran95 sources to Fortran so the CodeView language is not emitted as MASM. Differential Revision: https://reviews.llvm.org/D110330
2021-07-26[CodeView] Saturate values bigger than supported by APInt.Matheus Izvekov
This fixes an assert firing when compiling code which involves 128 bit integrals. This would trigger runtime checks similar to this: ``` Assertion failed: getMinSignedBits() <= 64 && "Too many bits for int64_t", file llvm/include/llvm/ADT/APInt.h, line 1646 ``` To get around this, we just saturate those big values. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D105320
2021-05-13[Debug-Info] change Tag type to dwarf::Tag for createAndAddDIE; NFCChen Zheng
Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D102207
2021-04-21[CodeView] Add CodeView support for PGO debug informationMichael Holman
This change adds debug information about whether PGO is being used or not. Microsoft performance tooling (e.g. xperf, WPA) uses this information to show whether functions are optimized with PGO or not, as well as whether PGO information is invalid. This information is useful for validating whether training scenarios are providing good coverage of real world scenarios, showing if profile data is out of date, etc. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D99994
2021-03-30[NFC][CodeGen] Tidy up TargetRegisterInfo stack realignment functionsTomas Matheson
Currently needsStackRealignment returns false if canRealignStack returns false. This means that the behavior of needsStackRealignment does not correspond to it's name and description; a function might need stack realignment, but if it is not possible then this function returns false. Furthermore, needsStackRealignment is not virtual and therefore some backends have made use of canRealignStack to indicate whether a function needs stack realignment. This patch attempts to clarify the situation by separating them and introducing new names: - shouldRealignStack - true if there is any reason the stack should be realigned - canRealignStack - true if we are still able to realign the stack (e.g. we can still reserve/have reserved a frame pointer) - hasStackRealignment = shouldRealignStack && canRealignStack (not target customisable) Targets can now override shouldRealignStack to indicate that stack realignment is required. This change will make it easier in a future change to handle the case where we need to realign the stack but can't do so (for example when the register allocator creates an aligned spill after the frame pointer has been eliminated). Differential Revision: https://reviews.llvm.org/D98716 Change-Id: Ib9a4d21728bf9d08a545b4365418d3ffe1af4d87
2021-02-10[AsmPrinter] Use range-based for loops (NFC)Kazu Hirata
2021-02-05[DebugInfo] Fix error from D95893, where I accidentally used anAmy Huang
unsigned int in a loop and it wraps around. Follow up to https://reviews.llvm.org/D95893
2021-02-05[CodeView][DebugInfo] Update the code for removing template arguments from ↵Amy Huang
the display name of a codeview function id. Previously the code split the string at the first '<', which incorrectly truncated names like `operator<`. Differential Revision: https://reviews.llvm.org/D95893
2020-11-25[CodeView] Avoid emitting empty debug globals subsection.Amy Huang
In https://reviews.llvm.org/D89072 I added static const data members to the debug subsection for globals. It skipped emitting an S_CONSTANT if it didn't have a value, which meant the subsection could be empty. This patch fixes the empty subsection issue. Differential Revision: https://reviews.llvm.org/D92049
2020-11-05[SVE] Return StackOffset for TargetFrameLowering::getFrameIndexReference.Sander de Smalen
To accommodate frame layouts that have both fixed and scalable objects on the stack, describing a stack location or offset using a pointer + uint64_t is not sufficient. For this reason, we've introduced the StackOffset class, which models both the fixed- and scalable sized offsets. The TargetFrameLowering::getFrameIndexReference is made to return a StackOffset, so that this can be used in other interfaces, such as to eliminate frame indices in PEI or to emit Debug locations for variables on the stack. This patch is purely mechanical and doesn't change the behaviour of how the result of this function is used for fixed-sized offsets. The patch adds various checks to assert that the offset has no scalable component, as frame offsets with a scalable component are not yet supported in various places. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D90018
2020-11-04Use isa<> instead of dyn_cast<> to avoid unused variable warning. NFCI.Simon Pilgrim
2020-11-03make the AsmPrinterHandler array publicJameson Nash
This lets external consumers customize the output, similar to how AssemblyAnnotationWriter lets the caller define callbacks when printing IR. The array of handlers already existed, this just cleans up the code so that it can be exposed publically. Replaces https://reviews.llvm.org/D74158 Differential Revision: https://reviews.llvm.org/D89613
2020-10-30[CodeView] Encode signed int values correctly when emitting S_CONSTANTsAmy Huang
Differential Revision: https://reviews.llvm.org/D90199