aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode
AgeCommit message (Collapse)AuthorFilesLines
2 hoursReland "[DebugMetadata][DwarfDebug] Support function-local types in lexical ↵Vladislav Dzhidzhoev1-54/+124
block scopes (4/7)" (#165032) This is an attempt to merge https://reviews.llvm.org/D144006 with LTO fix. The last merge attempt was https://github.com/llvm/llvm-project/pull/75385. The issue with it was investigated in https://github.com/llvm/llvm-project/pull/75385#issuecomment-2386684121. The problem happens when 1. Several modules are being linked. 2. There are several DISubprograms that initially belong to different modules but represent the same source code function (for example, a function included from the same source code file). 3. Some of such DISubprograms survive IR linking. It may happen if one of them is inlined somewhere or if the functions that have these DISubprograms attached have internal linkage. 4. Each of these DISubprograms has a local type that corresponds to the same source code type. These types are initially from different modules, but have the same ODR identifier. If the same (in the sense of ODR identifier/ODR uniquing rules) local type is present in two modules, and these modules are linked together, the type gets uniqued. A DIType, that happens to be loaded first, survives linking, and the references on other types with the same ODR identifier from the modules loaded later are replaced with the references on the DIType loaded first. Since defintion subprograms, in scope of which these types are located, are not deduplicated, the linker output may contain multiple DISubprogram's having the same (uniqued) type in their retainedNodes lists. Further compilation of such modules causes crashes. To tackle that, * previous solution to handle LTO linking with local types in retainedNodes is removed (cloneLocalTypes() function), * for each loaded distinct (definition) DISubprogram, its retainedNodes list is scanned after loading, and DITypes with a scope of another subprogram are removed. If something from a Function corresponding to the DISubprogram references uniqued type, we rely on cross-CU links. Additionally: * a check is added to Verifier to report about local types located in a wrong retainedNodes list, Original commit message follows. --------- RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Similar to imported declarations, the patch tracks function-local types in DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with the aforementioned metadata change and provided a support of function-local types scoped within a lexical block. The patch assumes that DICompileUnit's 'enums field' no longer tracks local types and DwarfDebug would assert if any locally-scoped types get placed there. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Co-authored-by: Jeremy Morse <jeremy.morse@sony.com>
13 days[ThinLTO] Remove unused relative block frequency support (#177215)Teresa Johnson2-57/+22
This removes most of the handling of the relative block frequency support added in 2018 in c73cec84c99e5a63dca961fef67998a677c53a3c, which was disabled by default and never utilized in the thin link as expected. Support for reading old Bitcode containing the record is maintained as required for backwards compatibility requirements, as is the support for parsing old LLVM assembly containing that information. Tests ensure that this backwards compatibility is maintained. This came up in the context of redundant BFI/DT computations which existed largely for the purpose of computing this information and are being addressed in PR176646.
13 days[IR] Make dead_on_return attribute optionally sizedAiden Grossman1-0/+5
This patch makes the dead_on_return parameter attribute optionally require a number of bytes to be passed in to specify the number of bytes known to be dead upon function return/unwind. This is aimed at enabling annotating the this pointer in C++ destructors with dead_on_return in clang. We need this to handle cases like the following: ``` struct X { int n; ~X() { this[n].n = 0; } }; void f() { X xs[] = {42, -1}; } ``` Where we only certain that sizeof(X) bytes are dead upon return of ~X. Otherwise DSE would be able to eliminate the store in ~X which would not be correct. This patch only does the wiring within IR. Future patches will make clang emit correct sizing information and update DSE to only delete stores to objects marked dead_on_return that are provably in bounds of the number of bytes specified to be dead_on_return. Reviewers: nikic, alinas, antoniofrighetto Pull Request: https://github.com/llvm/llvm-project/pull/171712
13 days[NFC] replace getValueType with more specific getFunctionType (#177175)Jameson Nash1-1/+1
When trivially valid already, use the more specific method, instead of casting the result of the less specific method.
2026-01-21[llvm][DebugInfo][NFC] Remove DITypeRefArray in favour of DITypeArray (#177066)Michael Buch1-12/+12
`DITypeRefArray` is just an alias (since https://github.com/llvm/llvm-project/pull/176938). Remove it in favour of just using `DITypeArray`.
2026-01-19[BitcodeReader] Improve error messagesNikita Popov1-137/+137
Avoid using "Invalid record" for all errors. At least mention what kind of record it is.
2025-12-11[IR] Don't store switch case values as operandsAlexis Engelke1-0/+8
SwitchInst case values must be ConstantInt, which have no use list. Therefore it is not necessary to store these as Use, instead store them more efficiently as a simple array of pointers after the uses, similar to how PHINode stores basic blocks. After this change, the successors of all terminators are stored consecutively in the operand list. This is preparatory work for improving the performance of successor access. Add new C API functions so that switch case values remain accessible from bindings for other languages. While this could also be achieved by merely changing the order of operands (i.e., first all successors, then all constants), doing so would increase the asymptotic runtime of addCase from O(1) to O(n) (i.e., adding n cases would be O(n^2)), because it would need to shift all constants by one slot. Having null/invalid operands is also a bad idea and would cause much more breakage. Pull Request: https://github.com/llvm/llvm-project/pull/170984
2025-12-09[Bitcode] Use ConstantInt::getSigned()Nikita Popov1-1/+1
This is encoded as a signed value, so use getSigned().
2025-12-08[llvm-c] Deprecate functions working on the global context (#163979)Nikita Popov1-4/+6
One of the most common mistakes when working with the LLVM C API is to mix functions that work on the global context and those that work on an explicit context. This often results in seemingly nonsensical errors because types from different contexts are mixed. We have considered the APIs working on the global context to be obsolete for a long time already, and do not add any new APIs using the global context. However, the fact that these still exist (and have shorter names) continues to cause issues. This PR proposes to deprecate these APIs, with intent to remove them at some point in the future. RFC: https://discourse.llvm.org/t/rfc-deprecate-c-api-functions-using-the-global-context/88639
2025-12-06Revert "[IR] Don't store switch case values as operands" (#170962)Vitaly Buka1-8/+0
Reverts llvm/llvm-project#166842 Breaks Mips LLVM tests, and LLD on bots. See llvm/llvm-project#166842
2025-12-05[IR] Don't store switch case values as operands (#166842)Alexis Engelke1-0/+8
SwitchInst case values must be ConstantInt, which have no use list. Therefore it is not necessary to store these as Use, instead store them more efficiently as a simple array of pointers after the uses, similar to how PHINode stores basic blocks. After this change, the successors of all terminators are stored consecutively in the operand list. This is preparatory work for improving the performance of successor access.
2025-12-02[ThinLTO] Fix parsing null aliasee in alias summary (#169490)Mingjie Xu2-11/+19
In https://github.com/llvm/llvm-project/commit/f8182f1aef5b6ec74cbe2c1618e759f0113921ba, we add support for printing "null" aliasee in AsmWriter, but missing support in LLParser.
2025-11-26Add deactivation symbol operand to ConstantPtrAuth.Peter Collingbourne2-2/+22
Deactivation symbol operands are supported in the code generator by building on the previously added support for IRELATIVE relocations. Reviewers: ojhunt, fmayer, ahmedbougacha, nikic, efriedma-quic Reviewed By: fmayer Pull Request: https://github.com/llvm/llvm-project/pull/133537
2025-11-25[LLVM] Use "syncscope" instead of "synchscope" in comments. NFC. (#134615)Jay Foad1-2/+2
This matches the spelling of the keyword in LLVM IR.
2025-11-22Add new llvm.dbg.declare_value intrinsic. (#168132)Shubham Sandeep Rastogi3-0/+12
For swift async code, we need to use a debug intrinsic that behaves like an llvm.dbg.declare but can take any location type rather than just a pointer or integer. To solve this, a new debug instrinsic called llvm.dbg.declare_value has been created, which behaves exactly like an llvm.dbg.declare but can take non pointer and integer location types. More information here: https://discourse.llvm.org/t/rfc-introduce-new-llvm-dbg-coroframe-entry-intrinsic/88269 This is the first patch as part of a stack of patches, with the one succeeding it being: https://github.com/llvm/llvm-project/pull/168134
2025-11-18[Bitcode] Use a range-based for loop (NFC) (#168489)Kazu Hirata1-3/+2
Identified with modernize-loop-convert.
2025-11-04[IR] Add new function attribute nocreateundeforpoison (#164809)Jay Foad2-0/+4
Also add a corresponding intrinsic property that can be used to mark intrinsics that do not introduce poison, for example simple arithmetic intrinsics that propagate poison just like a simple arithmetic instruction. As a smoke test this patch adds the new property to llvm.amdgcn.fmul.legacy.
2025-11-04[BitcodeReader][NFC] Tidy getEnableSplitLTOUnitAndUnifiedFlag (#165732)Andrew Ng1-25/+9
2025-10-29[DebugInfo] Add dataSize to DIBasicType to add DW_AT_bit_size to _BitInt ↵Orlando Cazalet-Hyams2-4/+5
types (#164372) DW_TAG_base_type DIEs are permitted to have both byte_size and bit_size attributes "If the value of an object of the given type does not fully occupy the storage described by a byte size attribute" * Add DataSizeInBits to DIBasicType (`DIBasicType(... dataSize: n ...)` in IR). * Change Clang to add DataSizeInBits to _BitInt type metadata. * Change LLVM to add DW_AT_bit_size to base_type DIEs that have non-zero DataSizeInBits. TODO: Do we need to emit DW_AT_data_bit_offset for big endian targets? See discussion on the PR. Fixes [#61952](https://github.com/llvm/llvm-project/issues/61952) --------- Co-authored-by: David Stenberg <david.stenberg@ericsson.com>
2025-10-29[llvm][Bitcode][ObjC] Fix order of setter/getter argument to DIObjCProperty ↵Michael Buch1-2/+3
constructor (#165421) Depends on: * https://github.com/llvm/llvm-project/pull/165401 We weren't testing `DIObjCProperty` roundtripping. So this was never caught. The consequence of this is that the `setter:` would have the getter name and `getter:` would have the setter name.
2025-10-22[ThinLTO] Add index flag for internalization/promotion status (#164530)Teresa Johnson1-1/+1
Add an index-wide flag indicating whether index-based internalization and promotion have completed. This will be used in a follow on change.
2025-10-22[ARM][AArch64] BTI,GCS,PAC Module flag update. (#86212)Daniel Kiss1-0/+2
Module flag is used to indicate the feature to be propagated to the function. As now the frontend emits all attributes accordingly let's help the auto upgrade to only do work when old and new bitcodes are merged. Depends on #82819 and #86031
2025-10-21[ThinLTO] Make SummaryList private (NFC) (#164355)Teresa Johnson1-2/+2
In preparation for a follow on change that will require checking every time a new summary is added to the SummaryList for a GUID, make the SummaryList private and require all accesses to go through one of two new interfaces. Most changes are to access the list via the read only getSummaryList() method, and the few that add new summaries (e.g. while building the combined summary) use the new addSummary() method.
2025-10-15[llvm][DebugInfo] Add 'sourceLanguageVersion' field support to DICompileUnit ↵Michael Buch2-2/+5
(#162632) Depends on: * https://github.com/llvm/llvm-project/pull/162445 In preparation to emit DWARFv6's `DW_AT_language_version`.
2025-10-11Move the preserve-{bc,ll}-uselistorder options out of individual tools, make ↵Mingjie Xu1-1/+8
them global defaults for AsmWriter and BitcodeWriter (#160079) This patch moves the `preserve-bc-uselistorder` and `preserve-ll-uselistorder` options out of individual tools(opt, llvm-as, llvm-dis, llvm-link, llvm-extract) and make them global defaults for AsmWriter and BitcodeWriter. These options are useful when we use `-print-*` options to dump LLVM IR.
2025-10-10[llvm][DebugInfo] Add 'sourceLanguageName' field support to DICompileUnit ↵Michael Buch2-6/+18
(#162445) Depends on: * https://github.com/llvm/llvm-project/pull/162255 * https://github.com/llvm/llvm-project/pull/162434 Part of a patch series to support the DWARFv6 `DW_AT_language_name`/`DW_AT_language_version` attributes.
2025-10-08[llvm][DebugInfo][NFC] Abstract DICompileUnit::SourceLanguage to allow ↵Michael Buch2-5/+8
alternate DWARF SourceLanguage encoding (#162255) This patch sets up `DICompileUnit` to support the DWARFv6 `DW_AT_language_name` and `DW_AT_language_version` attributes (which are set to replace `DW_AT_language`). This patch changes the `DICompileUnit::SourceLanguage` field type to a `DISourceLanguageName` that encapsulates the notion of "versioned vs. unversioned name". A "versioned" name is one that has an associated version stored separately in `DISourceLanguageName::Version`. This patch just changes all the clients of the `getSourceLanguage` API to the expect a `DISourceLanguageName`. Currently they all just `assert` (via `DISourceLanguageName::getUnversionedName`) that we're dealing with "unversioned names" (i.e., the pre-DWARFv6 language codes). In follow-up patches (e.g., draft is at https://github.com/llvm/llvm-project/pull/162261), when we start emitting versioned language codes, the `getUnversionedName` calls can then be adjusted to `getName`. **Implementation considerations** * We could have added a new member to `DICompileUnit` alongside the existing `SourceLanguage` field. I don't think this would have made the transition any simpler (clients would still need to be aware of "versioned" vs. "unversioned" language names). I felt that encapsulating this inside a `DISourceLanguageName` was easier to reason about for maintainers. * Currently DISourceLanguageName is a `12` byte structure. We could probably pack all the info inside a `uint64_t` (16-bits for the name, 32-bits for the version, 1-bit for answering the `hasVersionedName`). Just to keep the prototype simple I used a `std::optional`. But since the guts of the structure are hidden, we can always change the layout to a more compact representation instead. **How to review** * The new `DISourceLanguageName` structure is defined in `DebugInfoMetadata.h`. All the other changes fall out from changing the `DICompileUnit::SourceLanguage` from `unsigned` to `DISourceLanguageName`.
2025-10-07[AllocToken] Introduce sanitize_alloc_token attribute and alloc_token ↵Marco Elver2-0/+4
metadata (#160131) In preparation of adding the "AllocToken" pass, add the pre-requisite `sanitize_alloc_token` function attribute and `alloc_token` metadata. --- This change is part of the following series: 1. https://github.com/llvm/llvm-project/pull/160131 2. https://github.com/llvm/llvm-project/pull/156838 3. https://github.com/llvm/llvm-project/pull/162098 4. https://github.com/llvm/llvm-project/pull/162099 5. https://github.com/llvm/llvm-project/pull/156839 6. https://github.com/llvm/llvm-project/pull/156840 7. https://github.com/llvm/llvm-project/pull/156841 8. https://github.com/llvm/llvm-project/pull/156842
2025-09-24[IR] Introduce `llvm.errno.tbaa` metadata for errno alias disambiguationAntonio Frighetto1-1/+1
Add a new named module-level frontend-annotated metadata that specifies the TBAA node for an integer access, for which, C/C++ `errno` accesses are guaranteed to use (under strict aliasing). This should allow LLVM to prove the involved memory location/ accesses may not alias `errno`; thus, to perform optimizations around errno-writing libcalls (store-to-load forwarding amongst others). Previous discussion: https://discourse.llvm.org/t/rfc-modelling-errno-memory-effects/82972.
2025-09-19[IR] enable attaching metadata on ifuncs (#158732)Wael Yehia2-0/+9
Teach the IR parser and writer to support metadata on ifuncs, and update documentation. In PR #153049, we have a use case of attaching the `!associated` metadata to an ifunc. Since an ifunc is similar to a function declaration, it seems natural to allow metadata on ifuncs. Currently, the metadata API allows adding Metadata to llvm::GlobalObject, so the in-memory IR allows for metadata on ifuncs, but the IR reader/writer is not aware of that. --------- Co-authored-by: Wael Yehia <wyehia@ca.ibm.com>
2025-09-15[NFC][LLVM] Namespace cleanup in MetadataLoader.cpp (#157595)Rahul Joshi1-11/+5
- Remove forward declaration of `llvm::Argument` and include Argument.h instead. - Restrict scope of anonymous namespaces to just class declarations. - Move local static function out of anonymous namespace. - Remove a redundant assert when indexing a vector.
2025-09-05[LLD][COFF] Add more `--time-trace` tags for ThinLTO linking (#156471)Alexandre Ganea1-0/+2
In order to better see what's going on during ThinLTO linking, this PR adds more profile tags when using `--time-trace` on a `lld-link.exe` invocation. After PR, linking `clang.exe`: <img width="3839" height="2026" alt="Capture d’écran 2025-09-02 082021" src="https://github.com/user-attachments/assets/bf0c85ba-2f85-4bbf-a5c1-800039b56910" /> Linking a custom (Unreal Engine game) binary gives a completly different picture, probably because of using Unity files, and the sheer amount of input files (here, providing over 60 GB of .OBJs/.LIBs). <img width="1940" height="1008" alt="Capture d’écran 2025-09-02 102048" src="https://github.com/user-attachments/assets/60b28630-7995-45ce-9e8c-13f3cb5312e0" />
2025-08-26Bitcode: Stop combining function alignments into MaxAlignment.Peter Collingbourne1-9/+5
MaxAlignment is used to produce the abbreviation for MODULE_CODE_GLOBALVAR and is not used for anything related to function alignments, so stop combining function alignments and rename it to make its purpose clearer. Reviewers: teresajohnson Reviewed By: teresajohnson Pull Request: https://github.com/llvm/llvm-project/pull/155341
2025-08-08[IR] Introduce the `ptrtoaddr` instructionAlexander Richardson2-0/+2
This introduces a new `ptrtoaddr` instruction which is similar to `ptrtoint` but has two differences: 1) Unlike `ptrtoint`, `ptrtoaddr` does not capture provenance 2) `ptrtoaddr` only extracts (and then extends/truncates) the low index-width bits of the pointer For most architectures, difference 2) does not matter since index (address) width and pointer representation width are the same, but this does make a difference for architectures that have pointers that aren't just plain integer addresses such as AMDGPU fat pointers or CHERI capabilities. This commit introduces textual and bitcode IR support as well as basic code generation, but optimization passes do not handle the new instruction yet so it may result in worse code than using ptrtoint. Follow-up changes will update capture tracking, etc. for the new instruction. RFC: https://discourse.llvm.org/t/clarifiying-the-semantics-of-ptrtoint/83987/54 Reviewed By: nikic Pull Request: https://github.com/llvm/llvm-project/pull/139357
2025-08-04[llvm] using wrapper llvm::sort(nfc) (#151000)Austin1-1/+1
using wrapper llvm::sort(nfc)
2025-07-23[BitcodeReader] Avoid quadratic complexity in intrinsic upgrade (#150032)Nikita Popov1-9/+9
When materializing a function, we'd upgrade all calls to all upgraded intrinsics. However, this would operate on all calls to the intrinsic (including previously materialized ones), which leads to quadratic complexity. Instead, only upgrade the calls that are in the materialized function. This fixes a compile-time regression introduced by #149310.
2025-07-21[IR] Only allow lifetime.start/end on allocas (#149310)Nikita Popov1-3/+5
lifetime.start and lifetime.end are primarily intended for use on allocas, to enable stack coloring and other liveness optimizations. This is necessary because all (static) allocas are hoisted into the entry block, so lifetime markers are the only way to convey the actual lifetimes. However, lifetime.start and lifetime.end are currently *allowed* to be used on non-alloca pointers. We don't actually do this in practice, but just the mere fact that this is possible breaks the core purpose of the lifetime markers, which is stack coloring of allocas. Stack coloring can only work correctly if all lifetime markers for an alloca are analyzable. * If a lifetime marker may operate on multiple allocas via a select/phi, we don't know which lifetime actually starts/ends and handle it incorrectly (https://github.com/llvm/llvm-project/issues/104776). * Stack coloring operates on the assumption that all lifetime markers are visible, and not, for example, hidden behind a function call or escaped pointer. It's not possible to change this, as part of the purpose of lifetime markers is that they work even in the presence of escaped pointers, where simple use analysis is insufficient. I don't think there is any way to have coherent semantics for lifetime markers on allocas, while also permitting them on arbitrary pointer values. This PR restricts lifetimes to operate on allocas only. As a followup, I will also drop the size argument, which is superfluous if we always operate on an alloca. (This change also renders various code handling lifetime markers on non-alloca dead. I plan to clean up that kind of code after dropping the size argument as well.) In practice, I've only found a few places that currently produce lifetimes on non-allocas: * CoroEarly replaces the promise alloca with the result of an intrinsic, which will later be replaced back with an alloca. I think this is the only place where there is some legitimate loss of functionality, but I don't think this is particularly important (I don't think we'd expect the promise in a coroutine to admit useful lifetime optimization.) * SafeStack moves unsafe allocas onto a separate frame. We can safely drop lifetimes here, as SafeStack performs its own stack coloring. * Similar for AddressSanitizer, it also moves allocas into separate memory. * LSR sometimes replaces the lifetime argument with a GEP chain of the alloca (where the offsets ultimately cancel out). This is just unnecessary. (Fixed separately in https://github.com/llvm/llvm-project/pull/149492.) * InferAddrSpaces sometimes makes lifetimes operate on an addrspacecast of an alloca. I don't think this is necessary.
2025-07-21[lld] Fix -ObjC load behavior with LTO for section names with whitespace ↵Aleksandr Urakov1-3/+11
(#146654) This is a fix additional to #92162 In some cases, section names contain a whitespace between the segment name and the actual section name (e.g. `__TEXT, __swift5_proto`). It is confirmed by source code of the Swift compiler This fix allows LTO to work correctly with the `-ObjC` flag in that rare case when only a section with a whitespace in the name is present in the linked bitcode module, but there are no sections containing `__TEXT,__swift` --------- Co-authored-by: Ураков Александр Сергеевич <a.urakov@tbank.ru> Co-authored-by: Ellis Hoag <ellis.sparky.hoag@gmail.com>
2025-07-07[KeyInstr] Add bitcode support (#147260)Jeremy Morse3-15/+34
Serialise key-instruction fields of DILocations and DISubprograms into and outof bitcode, add tests. debug-info bitcode sizes grow, but it balances out given an earlier size optimisation in 51f4e2c. Co-authored-by: Orlando Cazalet-Hyams <orlando.hyams@sony.com>
2025-07-06[Bitcode][NFC] Add abbrev for FUNC_CODE_DEBUG_LOC (#147211)Jeremy Morse1-1/+16
DILocations that are not attached to instructions are encoded using METADATA_LOCATION records which have an abbrev. DILocations attached to instructions are interleaved with instruction records as FUNC_CODE_DEBUG_LOC records, which do not have an abbrev (and FUNC_CODE_DEBUG_LOC_AGAIN which have no operands). Add a new FUNCTION_BLOCK abbrev FUNCTION_DEBUG_LOC_ABBREV for FUNC_CODE_DEBUG_LOC records. This reduces the bc file size by up to 7% in CTMark, with many between 2-4% smaller. [per-file file size compile-time-tracker](https://llvm-compile-time-tracker.com/compare.php?from=75cf826849713c00829cdf657e330e24c1a2fd03&to=1e268ebd0a581016660d9d7e942495c1be041f7d&stat=size-file&details=on) (go to stage1-ReleaseLTO-g). This optimisation is motivated by #144102, which adds the new Key Instructions fields to bitcode records. The combined patches still overall look to be a slight improvement over the base. (Originally reviewed in PR #146497) Co-authored-by: Orlando Cazalet-Hyams <orlando.hyams@sony.com>
2025-07-04[NFCI][LLVM] Adopt `ArrayRef::consume_front()` in a few places (#146793)Rahul Joshi1-12/+7
2025-07-04[debuginfo][coro] Emit debug info labels for coroutine resume points (#141937)Adrian Vogelsgesang2-5/+24
RFC on discourse: https://discourse.llvm.org/t/rfc-debug-info-for-coroutine-suspension-locations-take-2/86606 With this commit, we add `DILabel` debug infos to the resume points of a coroutine. Those labels can be used by debugging scripts to figure out the exact line and column at which a coroutine was suspended by looking up current `__coro_index` value inside the coroutines frame, and then searching for the corresponding label inside the coroutine's resume function. The DWARF information generated for such a label looks like: ``` 0x00000f71: DW_TAG_label DW_AT_name ("__coro_resume_1") DW_AT_decl_file ("generator-example.cpp") DW_AT_decl_line (5) DW_AT_decl_column (3) DW_AT_artificial (true) DW_AT_LLVM_coro_suspend_idx (0x01) DW_AT_low_pc (0x00000000000019be) ``` The labels can be mapped to their corresponding `__coro_idx` values either via their naming convention `__coro_resume_<N>` or using the new `DW_AT_LLVM_coro_suspend_idx` attribute. In gdb, those line numebrs can be looked up using `info line -function my_coroutine -label __coro_resume_1`. LLDB unfortunately does not understand DW_TAG_label debug information, yet. Given this is an artificial compiler-generated label, I did apply the DW_AT_artificial tag to it. The DWARFv5 standard only allows that tag on type and variable definitions, but this is a natural extension and was also blessed in the RFC on discourse. Also, this commit adds `DW_AT_decl_column` to labels, not only for coroutines but also for normal C and C++ labels. While not strictly necessary, I am doing so now because it would be harder to do so later without breaking the binary LLVM-IR format Drive-by fixes: While reading the existing test cases to understand how to write my own test case, I did a couple of small typo fixes and comment improvements
2025-07-03[Bitcode] Add abbreviations for additional instructions (#146825)Nikita Popov1-7/+75
Add abbreviations for icmp/fcmp, store and br, which are the most common instructions that don't have abbreviations yet. This requires increasing the abbreviation size to 5 bits. This gives about 3-5% bitcode size reductions for the clang build.
2025-07-02Fix lld crash caused by dynamic bit offset patch (#146701)Tom Tromey1-2/+4
PR #141106 changed the debuginfo metdata to allow dynamic bit offsets and sizes. This caused a crash in lld when using LTO. The problem is that lazyLoadOneMetadata assumes that the metadata in question can be cast to MDNode; but in the typical case where the offset is a constant, this is not true. This patch changes this spot to allow non-MDNodes through. The included test case comes from the report in #141106.
2025-07-02[Bitcode] Extract common BitCodeAbbrevOps (NFC)Nikita Popov1-24/+25
We always use the same abbreviations for type and for value references, so avoid repeating them.
2025-07-02[IR] Introduce `dead_on_return` attributeAntonio Frighetto2-0/+4
Add `dead_on_return` attribute, which is meant to be taken advantage by the frontend, and states that the memory pointed to by the argument is dead upon function return. As with `byval`, it is supposed to be used for passing aggregates by value. The difference lies in the ABI: `byval` implies that the pointer is explicitly passed as argument to the callee (during codegen the copy is emitted as per byval contract), whereas a `dead_on_return`-marked argument implies that the copy already exists in the IR, is located at a specific stack offset within the caller, and this memory will not be read further by the caller upon callee return – or otherwise poison, if read before being written. RFC: https://discourse.llvm.org/t/rfc-add-dead-on-return-attribute/86871.
2025-06-26Triple: Forward declare Twine and remove include (#145685)Matt Arsenault1-1/+1
2025-06-25[NFC][PGO] Use constants rather than free strings for metadata labels (#145721)Mircea Trofin1-1/+1
2025-06-25Non constant size and offset in DWARF (#141106)Tom Tromey2-29/+67
In Ada, a record type can have a non-constant size, and a field can appear at a non-constant bit offset in a record. To support this, this patch changes DIType to record the size and offset using metadata, rather than plain integers. In addition to a constant offset, both DIVariable and DIExpression are now supported here. One thing of note in this patch is the choice of how exactly to represent a non-constant bit offset, with the difficulty being that DWARF 5 does not support this. DWARF 3 did have a way to support a non-constant byte offset, combined with a constant bit offset within the byte, but this was deprecated in DWARF 4 and removed from DWARF 5. This patch takes a simple approach: a DWARF extension allowing the use of an expression with DW_AT_data_bit_offset. There is a corresponding DWARF issue, see https://dwarfstd.org/issues/250501.1.html. The main reason for this approach is that it keeps API simplicity: just a single value is needed, rather than having separate data describing the byte offset and the bit within the byte.
2025-06-12[DebugInfo][RemoveDIs] Delete debug-info-format flag (#143746)Jeremy Morse1-8/+0
This flag was used to let us incrementally introduce debug records into LLVM, however everything is now using records. It serves no purpose now, so delete it.