5739 Commits

Author SHA1 Message Date
Vladislav Dzhidzhoev
b9cecee3fb
Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical 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>
2026-02-04 00:34:52 +01:00
Prabhu Rajasekaran
b7dfc429c3
[llvm][AsmPrinter] Call graph section Flag field enum (#176309)
This enum is required in llvm-readobj ELFDumper.cpp as well for parsing
the call graph section generated. To avoid duplication of the Flag field
enum, moving this to llvm/object/ELFTypes.h.
2026-02-03 11:27:20 -08:00
Wael Yehia
e1f69ee8e8
[AIX] Implement the ifunc attribute. (#153049)
Currently, the AIX linker and loader do not provide a mechanism to
implement ifuncs similar to GNU_ifunc on ELF Linux.
On AIX, we will lower `__attribute__((ifunc("resolver"))` to the llvm
`ifunc` as other platforms do. The llvm `ifunc` in turn will get lowered
at late stages of the optimization pipeline to an AIX-specific
implementation. No special linkage or relocations are needed when
generating assembly/object output.

On AIX, a function `foo` has two symbols associated with it: a function
descriptor (`foo`) residing in the `.data` section, and an entry point
(`.foo`) residing in the `.text` section. The first field of the
descriptor is the address of the entry point. Typically, the address
field in the descriptor is initialized once: statically, at load time
(?), or at runtime if runtime linking is enabled.

Here we would like to use the address field in the descriptor to
implement the `ifunc` semantics. Specifically, the ifunc function will
become a stub that jumps to the entry point in the address field. A
constructor function is linked into every linkage module. The
constructor walks an array of `{descriptor, resolver}` pairs, calling
the resolver and saving the result in the address field in the
descriptor (thus setting `foo`'s descriptor to point to the resolved
version early during program runtime).

Known limitations:
- Due to bug #161576, which affects object generation path, you will
need either `-ffunction-sections` or `-fno-integrated-as` to generate a
correct/linkable object file.
- aliases to ifuncs are not supported, a testcase has been added and
marked XFAIL. I'm planning to address in a follow-up PR because it's not
important enough, IMHO, for this PR
- dead ifuncs in a CU that contains at least one live ifunc, will result
in all ifuncs being kept by the linker. The fix for this is common with
a similar problem we have with PGO. PR #159435 is trying to provide a
mechanism that will allow the ifunc and PGO implementations to avoid the
dead code retention at the link step.
- the resolver must return a function that is in the same DSO as the
ifunc; the compiler will try to detect if this condition is violated and
report it, but it cannot detect it in general. To be safe, all candidate
functions (returned by a particular resolver) must either be static or
have hidden/protected visibility. This is so that the ifunc stub doesn't
have to save and restore the TOC register r2. In future work, this case
will be supported and the requirement will be lifted.

---------

Co-authored-by: Wael Yehia <wyehia@ca.ibm.com>
2026-02-03 14:15:16 -05:00
Laxman Sole
1a23bca645
[DebugInfo][NVPTX] Adding support for inlined_at debug directive in NVPTX backend (#170239)
This change adds support for emitting the enhanced PTX debugging
directives `function_name` and `inlined_at` as part of the `.loc`
directive in the NVPTX backend.

`.loc` syntax - 
>.loc file_index line_number column_position

`.loc` syntax with `inlined_at` attribute - 
>.loc file_index line_number column_position,function_name label {+
immediate }, inlined_at file_index2 line_number2 column_position2

`inlined_at` attribute specified as part of the `.loc` directive
indicates PTX instructions that are generated from a function that got
inlined. It specifies the source location at which the specified
function is inlined. `file_index2`, `line_number2`, and
`column_position2` specify the location at which the function is
inlined.

The `function_name` attribute specifies an offset in the DWARF section-
`.debug_str`. Offset is specified as a label expression or a label +
immediate expression, where label is defined in the `.debug_str`
section. DWARF section `.debug_str` contains ASCII null-terminated
strings that specify the name of the function that is inlined.

These attributes were introduced in PTX ISA version 7.2 (see NVIDIA’s
documentation:
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-loc
).

To support these features, the PR introduces a new `NVPTXDwarfDebug`
class derived from `DwarfDebug`, which implements NVPTX-specific logic
for emitting these directives. The base DwarfDebug infrastructure is
extended with new virtual functions (`initializeTargetDebugInfo()` and
`recordTargetSourceLine()`) that enable the NVPTX backend to generate
this additional debug information.

The MC layer is also updated to emit the NVPTX-specific `.loc`
attributes (function_name and inlined_at). The implementation applies to
PTX ISA 7.2 and later when the debug-info emission kind is either
lineTableOnly or DebugDirectiveOnly. A new command-line option,
`--line-info-inlined-at=<true/false>`, is added to control whether the
inlined_at attribute is generated.

Note - The `NVCC` compiler already emits the `.loc` directive with
`inlined_at` when compiled with `-lineinfo` option.
2026-02-01 22:33:53 -08:00
Marina Taylor
7994daccd9
[AsmPrinter] Add a command-line option to emit stack usage files (#178908)
Preparation for #178005.

This will allow stack usage files to be requested during the linking
step in LTO builds, in a more straightforward way than via
TargetOptions.
2026-01-30 18:10:08 +00:00
Marina Taylor
2eaaaf1912
NFC: Rename CodeGenOptions::StackUsageOutput to StackUsageFile (#178898)
Preparation for #178005.

"Output" has too many different interpretations: it could be an
enabled/disabled, a file format, etc. Clarify that it's the destination
file.
2026-01-30 15:03:54 +00:00
Jameson Nash
d10b2b566a
[NFCI] replace getValueType with new getGlobalSize query (#177186)
Returns uint64_t to simplify callers. The goal is eventually replace
getValueType with this query, which should return the known minimum
reference-able size, as provided (instead of a Type) during create.
Additionally the common isSized query would be replaced with an
isExactKnownSize query to test if that size is an exact definition.
2026-01-22 13:55:53 -05:00
Jameson Nash
a28a2f6e50
[AsmPrinter] Analyze GlobalAlias more carefully with getAliaseeObject (#176996)
Move the `GA.getAliaseeObject()` call to the top of `emitGlobalAlias`
and reuse the result throughout the function. Since `getAliaseeObject()`
can return null, switch to `isa_and_nonnull<>` for correctness.

This is just a drive-by fix I noticed in reading the code, not
something I actually encountered in practice. This seems to have been
last improved in 924696d271cabdda066088c40a0fa98bd240b86a, and I think
this version now even closer matches the intent of the comment here.
2026-01-21 10:00:01 -05:00
Michael Buch
8f90efdee8
[llvm][DebugInfo][NFC] Remove DITypeRefArray in favour of DITypeArray (#177066)
`DITypeRefArray` is just an alias (since
https://github.com/llvm/llvm-project/pull/176938). Remove it in favour
of just using `DITypeArray`.
2026-01-21 01:10:58 +00:00
Nikita Popov
792670a400
[X86][WinEH] Insert nop after unwinding inline assembly (#176393)
As discussed on https://github.com/llvm/llvm-project/pull/144745, insert
a nop after unwinding inline assembly, as it may end on a call.

While the change itself is trivial, I ended up having to do two
infrastructure changes:
* The unwind flag needs to be propagated to ExtraInfo of the
MachineInstr.
* The MachineInstr needs to be passed through to emitInlineAsmEnd(), and
the method needs to be non-const.

Fixes https://github.com/llvm/llvm-project/issues/157073.
2026-01-19 09:09:04 +01:00
Daniel Paoliello
483c6834a2
[NFC][win] Use an enum for the cfguard module flag (#176461)
Currently the `cfguard` module flag can be set to 1 (emit tables only,
no checks) or 2 (emit tables and checks).

This change formalizes that definition by moving these values into an
enum, instead of just having them documented in comments.

Split out from #176276
2026-01-16 18:23:25 -08:00
David Stenberg
6fd8c36417
[DebugInfo] Drop stale entry value-limitation for call site values (#172340)
Entry value operations could previously not be combined with other
operations in debug expressions, meaning that we had to skip emitting
call site values in such cases. This DIExpression limitation was removed
in 57a371d7010802804343d17b85ac5e0d28d0f309, so we should be free to
emit call site values for such cases now, for example:

    extern void call(int, int);
    void entry_value (int param) {
        call(param + 222, param - 444);
    }

This change exposed a call site parameter entry order issue in the
dbgcall-site-expr-entry-value.mir test case. That ordering issue is
tracked in #43998, and I don't think there is anything inherent in this
patch that caused that.
2026-01-15 16:04:23 +01:00
Liu Ke
8610d359c5
[DebugInfo] Only generate template parameters in the skeleton CU for a template function/type with simplified name (3/3) (#175879)
Currently, when generating debug info for skeleton units, all template
parameters are emitted unconditionally. To optimize debug info size, the
emission should be conditional — providing parameters only for template
types/functions whose names have actually been simplified. As described
in [this
RFC](https://discourse.llvm.org/t/rfc-debuginfo-selectively-generate-template-parameters-in-the-skeleton-cu/89395).
Previous patches: #175130, #175708
2026-01-15 10:35:49 +08:00
David Stenberg
30e399a675
[DebugInfo] Find call site values for params in preserved registers (#172339)
For example, given code like this:

    int local = value();
    callee(local);
    return local;

resulting in assembly like:

    movl    %eax, %ebx // %eax = local
    movl    %eax, %edi
    callq   callee@PLT

the call site value generation did not understand that the value of
local is stored in the callee-saved %ebx during the call, and did not
emit any call site value. This patch addresses that, resulting in:

    DW_TAG_call_site_parameter
      DW_AT_location      (DW_OP_reg5 RDI)
      DW_AT_call_value    (DW_OP_breg3 RBX+0)

This code does not keep track if any succeeding instructions save
registers, meaning that it fails to emit a call site value for a case
like this:

    movq    %rax, %rdi
    movq    %rax, %rbx
    callq   callee@PLT

The test case dbgcall-site-preserved-clobbered.mir has been added for
that. This should be rather easy to address, but can be done in a
follow-up patch.

Building a clang-21 RelWithDebInfo binary for x86-64 without/with this
patch results in a ~1.8% increase of the number of call site parameter
entries with a location (from 1792876 to 1825718). This also reduces the
number of call site parameter entries using DW_OP_entry_value locations,
which are not guaranteed to be printable as they require the frame above
to provide a call site value for that parameter, from 57718 to 34871.

Fixes #43464.
2026-01-14 16:50:56 +01:00
Haohai Wen
bdc6a6778d
[PseudoProbe] Add switch to control illegal guid warnings (#174927)
Do not verify GUID existence in pseudo probe desc by default since it
generates false positive warnings with ThinLTO.
User can use -pseudo-probe-verify-guid-existence-in-desc to verify it
explicitly.
2026-01-12 11:15:54 +08:00
HighW4y2H3ll
51c37f4c1e
[CodeGen] Strip Coroutine suffixes when generating pseudo probe (#173834)
CoroSplit pass now creates separate DWARF symbols with the `.resume`,
`.destroy`, `.cleanup` suffixes.
https://github.com/llvm/llvm-project/pull/141889 But pseudo probes are
created in an earlier pass (`SampleProfileProbePass`) before the
CoroSplit, which creates a mismatch of Function GUIDs between the
original function name and the function names with the coroutine
suffixes during the CodeGen when the AsmPrinter iterates through the
`InlinedAt` chain and generates the `InlineStack`.

This will create mismatched pseudo probes in the final binary and
llvm-profgen will also fail when parsing the pseudo probe section. This
fix simply strips the coroutine suffixes from the inline callers' name,
so the CoroSplit changes will be transparent.
2026-01-08 13:46:34 -08:00
Prabhu Rajasekaran
4b31ad94e0
[UEFI] Codeview do not crash when no llvm.dbg.cu (#174460)
PR #142970 Added for Windows targets to emit minimal codeview metadata
even when debug info is disabled. This crashes the backend for UEFI
x86_64-uefi triple as llvm.dbg.cu is expected unconditionally there.
Handling it correctly in AsmPrinter and adding a regression test.
2026-01-06 09:52:24 -08:00
Rahman Lavaee
ba6c5f8e4e
Insert symbols for prefetch targets read from basic blocks section profile. (#168439)
This is the first PR to enable the prefetch optimization via Propeller
based on our
[RFC](https://discourse.llvm.org/t/rfc-code-prefetch-insertion/88668/22).
It enables emitting special symbols prefixed with
`__llvm_prefetch_target` to point to the prefetch targets as specified
via directives in the profile. A prefetch target is uniquely identified
by its function name, basic block ID, and the subblock index (used when
the target is after a call instruction).

A new pass is added which sets a field in basic blocks which have
prefetch targets. The next PR will add the prefetch insertion logic into
the same pass.
2026-01-05 15:36:59 -08:00
Rahman Lavaee
53005fd435
Use the Propeller CFG profile in the PGO analysis map if it is available. (#163252)
This PR implements the emitting of the post-link CFG information in PGO
analysis map, as explained in the
[RFC](https://discourse.llvm.org/t/rfc-extending-the-pgo-analysis-map-with-propeller-cfg-frequencies/88617).
This is enabled by a flag `pgo-analysis-map-emit-bb-sections-cfg`.

This PR bumps the SHT_LLVM_BB_ADDR_MAP version to 5.
Also includes some refactoring changes related to storing the CFG in the
Basic block sections profile reader.
2025-12-17 14:19:18 -08:00
Orlando Cazalet-Hyams
3e32735020
[DWARF] Add support for DW_GNU_call_target_clobbered (#172336)
Fixes assertion trip introduced in #172167

See https://issues.chromium.org/issues/468825583#comment2
2025-12-15 18:24:21 +00:00
Orlando Cazalet-Hyams
792704038a
[DebugInfo][DWARF] Use DW_AT_call_target_clobbered for exprs with volatile regs (#172167)
Without this patch DW_AT_call_target is used for all indirect call address
location expressions. The DWARF spec says:

    For indirect calls or jumps where the address is not computable without use
    of registers or memory locations that might be clobbered by the call the
    DW_AT_call_target_clobbered attribute is used instead of the
    DW_AT_call_target attribute.

This patch implements that behaviour.
2025-12-15 12:54:18 +00:00
Orlando Cazalet-Hyams
fa1dceb67f
[DebugInfo][DWARF] Allow memory locations in DW_AT_call_target expressions (#171183)
Fixes #70949. Prior to PR #151378 memory locations were incorrect; that
patch prevented the emission of the incorrect locations.

This patch fixes the underlying issue.
2025-12-13 17:37:35 +00:00
Jan Svoboda
8e999e3d78
[llvm][clang] Sandbox filesystem reads (#165350)
This PR introduces a new mechanism for enforcing a sandbox around
filesystem reads coming from the compiler. A fatal error is raised
whenever the `llvm::sys::fs`, `llvm::MemoryBuffer::getFile*()` APIs get
used directly instead of going through the "blessed" virtual interface
of `llvm::vfs::FileSystem`.
2025-12-11 15:42:13 -08:00
JaydeepChauhan14
9b6b52b534
[AsmPrinter][NFC] Reuse Target Triple variable (#171612) 2025-12-11 12:28:59 +01:00
Anatoly Trosinenko
c0eac77f3c
[ADT] BitVector: give subsetOf(RHS) name to !test(RHS) (NFC) (#170875)
Define `LHS.subsetOf(RHS)` as a more descriptive name for `!LHS.test(RHS)`
and update the existing callers to use that name.

Co-authored-by: Jakub Kuderski <jakub@nod-labs.com>
2025-12-09 21:00:27 +03:00
Owen Anderson
ba3208e19f
[LLVM/CodeGen] Use the correct address space when building structor tables. (#171247)
No in-tree target exercises this, but it's needed for CHERI, and I
believe its correctness is verifiable by inspection.

Co-authored-by: Alex Richardson <alexrichardson@google.com>
2025-12-08 22:44:07 -06:00
Tom Tromey
efbbca62d1
[llvm][DebugInfo] Allow DIDerivedType as a bound in DISubrangeType (#165880)
Consider this Ada type:

```
   type Array_Type is array (Natural range <>) of Integer;
   type Record_Type (L1, L2 : Natural) is record
      I1 : Integer;
      A1 : Array_Type (1 .. L1);
      I2 : Integer;
      A2 : Array_Type (1 .. L2);
      I3 : Integer;
   end record;
```

Here, the array fields have lengths that depend on the discriminants of
the record type. However, in this case the array lengths cannot be
expressed as DWARF location expressions, with the issue being that "A2"
has a non-constant offset, but an expression involving
DW_OP_push_object_address will push the address of the field -- with no
way to find the location of "L2".

In a case like this, I believe the correct DWARF is to emit the array
ranges using a direct reference to the discriminant, like:

```
 <3><1156>: Abbrev Number: 1 (DW_TAG_member)
    <1157>   DW_AT_name        : l1
...
 <3><1177>: Abbrev Number: 6 (DW_TAG_array_type)
    <1178>   DW_AT_name        : (indirect string, offset: 0x1a0b): vla__record_type__T4b
    <117c>   DW_AT_type        : <0x1287>
    <1180>   DW_AT_sibling     : <0x118e>
 <4><1184>: Abbrev Number: 7 (DW_TAG_subrange_type)
    <1185>   DW_AT_type        : <0x1280>
    <1189>   DW_AT_upper_bound : <0x1156>
```

(FWIW this is what GCC has done for years.)

This patch makes this possible in LLVM, by letting a DISubrangeType
refer to a DIDerivedType. gnat-llvm can then arrange for the DIE
reference to be correct by setting the array type's scope to be the
record.
2025-12-04 09:38:14 +09:00
daniilavdeev
cc1c41724d
[dwarf] make dwarf fission compatible with RISCV relaxations 2/2 (#164813)
This patch makes DWARF fission compatible with RISC-V relaxations by
using indirect addressing for the DW_AT_high_pc attribute. This
eliminates the remaining relocations in .dwo files.
2025-11-26 15:36:02 +03:00
daniilavdeev
5f777b2c8f
[dwarf] make dwarf fission compatible with RISCV relaxations 1/2 (#166597)
Currently, -gsplit-dwarf and -mrelax are incompatible options in Clang.
The issue is that .dwo files should not contain any relocations, as they
are not processed by the linker. However, relaxable code emits
relocations in DWARF for debug ranges that reside in the .dwo file when
DWARF fission is enabled.

This patch makes DWARF fission compatible with RISC-V relaxations. It
uses the StartxEndx DWARF forms in .debug_rnglists.dwo, which allow
referencing addresses from .debug_addr instead of using absolute
addresses. This approach eliminates relocations from .dwo files.
2025-11-26 00:52:22 +03:00
Jeremy Morse
2cf550a040
[DebugInfo] Force early line-zero calls to have meaningful locations (#156850)
In functions that have been seriously deformed during optimisation,
there can be call instructions with line-zero immediately after frame
setup (see C reproducer in the test added). Our previous algorithms for
prologue_end ignored these, meaning someone entering a function at
prologue_end would break-in after a function call had completed. Prefer
instead to place prologue_end and the function scope-line on the line
zero call: this isn't false (it's the first meaningful instruction of the
function) and is approximately true. Given a less than ideal function,
this is an OK solution.
2025-11-20 10:20:47 +00:00
Tom Tromey
1262acf4ec
Introduce DwarfUnit::addBlock helper method (#168446)
This patch is just a small cleanup that unifies the various spots that
add a DWARF expression to the output.
2025-11-18 22:59:36 +00:00
Matt Arsenault
2e489f77ba
CodeGen: Fix CodeView crashes with empty llvm.dbg.cu (#163286) 2025-11-12 14:59:42 -08:00
Sergei Barannikov
47cef55390
[AsmPrinter] Replace improper use of Register with MCRegUnit (NFC) (#167682) 2025-11-12 23:45:06 +03:00
serge-sans-paille
af146462f9
Remove unused <iterator> inclusion
Per https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible
this improves compilation time, while not being too intrusive on the
codebase.
2025-11-11 13:33:38 +01:00
serge-sans-paille
45a2320372
Remove unused <utility> inclusion
Per https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible this improves compilation time, while not being too intrusive on the codebase.
2025-11-11 13:33:33 +01:00
Vladislav Dzhidzhoev
e2a2c03eef
[DebugInfo] Add Verifier check for incorrectly-scoped retainedNodes (#166855)
These checks ensure that retained nodes of a DISubprogram belong to the
subprogram.

Tests with incorrect IR are fixed. We should not have variables of one subprogram present in retained nodes of other subprograms.

Also, interface for accessing DISubprogram's retained nodes is slightly
refactored. `DISubprogram::visitRetainedNodes` and
`DISubprogram::forEachRetainedNode` are added to avoid repeating checks
like
```
if (const auto *LV = dyn_cast<DILocalVariable>(N))
  ...
else if (const auto *L = dyn_cast<DILabel>(N))
  ...
else if (const auto *IE = dyn_cast<DIImportedEntity>(N))
  ...
```
2025-11-10 13:13:49 +01:00
Daniel Thornburgh
5f08fb4d72
[IR] llvm.reloc.none intrinsic for no-op symbol references (#147427)
This intrinsic emits a BFD_RELOC_NONE relocation at the point of call,
which allows optimizations and languages to explicitly pull in symbols
from static libraries without there being any code or data that has an
effectual relocation against such a symbol.

See issue #146159 for context.
2025-11-06 08:52:46 -08:00
Prabhu Rajasekaran
f60e69315e
[llvm] Emit canonical linkage correct function symbol (#166487)
In the call graph section, we were emitting the temporary label
pointing to the start of the function instead of the canonical linkage
correct function symbol. This patch fixes it and updates the
corresponding tests.
2025-11-05 09:22:08 -08:00
Kazu Hirata
7db6344170
[CodeGen] Remove redundant declarations (NFC) (#166105)
In C++17, static constexpr members are implicitly inline, so they no
longer require an out-of-line definition.

Identified with readability-redundant-declaration.
2025-11-02 22:42:40 -08:00
Kazu Hirata
31b8ba5670
[Analysis, CodeGen] Use ArrayRef instead of const ArrayRef (NFC) (#166026)
This patch improves readability by using "ArrayRef<T>" instead of
"const ArrayRef<T>" and "const ArrayRef<T> &" in function parameter
types.
2025-11-01 23:20:19 -07:00
Michael Buch
10fbbb62ce
[llvm][DebugInfo][ObjC] Make sure we link backing ivars to their DW_TAG_APPLE_property (#165409)
Depends on:
* https://github.com/llvm/llvm-project/pull/165373

When an Objective-C property has a backing ivar, we would previously not
add a `DW_AT_APPLE_property` to the ivar's `DW_TAG_member`. This is what
was intended based on the [Objective-C DebugInfo
docs](https://github.com/llvm/llvm-project/blob/main/llvm/docs/SourceLevelDebugging.rst#proposal)
but is not what LLVM currently generates.

LLDB currently doesn't ever try linking the `ObjCPropertyDecl`s to their
`ObjCIvarDecl`s, but if we wanted to, this debug-info patch is a
pre-requisite.
2025-10-31 10:25:58 +00:00
Rahman Lavaee
e9368a056d
[SHT_LLVM_BB_ADDR] Implement ELF and YAML support for Propeller CFG data in PGO analysis map. (#164914)
This PR implements the ELF support for PostLink CFG in PGO analysis map
as discussed in
[RFC](https://discourse.llvm.org/t/rfc-extending-the-pgo-analysis-map-with-propeller-cfg-frequencies/88617/2).

A later PR will implement the Codegen Support.
2025-10-30 13:12:06 -07:00
Orlando Cazalet-Hyams
aa5fe56db4
[DebugInfo] Add dataSize to DIBasicType to add DW_AT_bit_size to _BitInt 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 15:23:46 +00:00
Kazu Hirata
160b72787c
[CodeGen] Use DenseMap::try_emplace (NFC) (#165165)
With try_emplace, we can pass the key and the arguments for the
value's constructor, which is a lot shorter than:

  Map.insert(std::make_pair(Key, ValueType(Arg1, Arg2)))
2025-10-26 13:34:15 -07:00
wdx727
d8d80b659a
Adding Matching and Inference Functionality to Propeller-PR2 (#162963)
Adding Matching and Inference Functionality to Propeller. For detailed
information, please refer to the following RFC:
https://discourse.llvm.org/t/rfc-adding-matching-and-inference-functionality-to-propeller/86238.
This is the second PR, which includes the calculation of basic block
hashes and their emission to the ELF file. It is associated with the
previous PR at https://github.com/llvm/llvm-project/pull/160706.

co-authors: lifengxiang1025
[lifengxiang@kuaishou.com](mailto:lifengxiang@kuaishou.com); zcfh
[wuminghui03@kuaishou.com](mailto:wuminghui03@kuaishou.com)

Co-authored-by: lifengxiang1025 <lifengxiang@kuaishou.com>
Co-authored-by: zcfh <wuminghui03@kuaishou.com>
Co-authored-by: Rahman Lavaee <rahmanl@google.com>
2025-10-23 09:38:12 -07:00
Kazu Hirata
6bee6b2090
[CodeGen] Add "override" where appropriate (NFC) (#164571)
Note that "override" makes "virtual" redundant.

Identified with modernize-use-override.
2025-10-22 06:51:08 -07:00
Rahman Lavaee
d55b10a4b9
Add comment about static_cast requirement. 2025-10-21 17:42:12 -07:00
Aiden Grossman
b85733094c Revert "Remove unnecessary static_cast<bool> in AsmPrinter.cpp."
This reverts commit 0e8ee0ec78dc370a1bf2688411cf2db36c3a4cd0.

This breaks Windows premerge.
https://lab.llvm.org/staging/#/builders/21/builds/6831
2025-10-22 00:11:25 +00:00
Rahman Lavaee
0e8ee0ec78
Remove unnecessary static_cast<bool> in AsmPrinter.cpp. 2025-10-21 14:15:03 -07:00
Tom Tromey
889db04e2c
Minor optimizations to DW_OP_LLVM_extract_bits_* (#163812)
I noticed a couple more small optimization opportunities when generating
DWARF expressions from the internal
DW_OP_LLVM_extract_bits_* operations:

* DW_OP_deref can be used, rather than DW_OP_deref_size, when the deref
size is the word size.

* If the bit offset is 0 and an unsigned extraction is desired, then
sometimes the shifting can be skipped entirely, or replaced with
DW_OP_and.
2025-10-21 11:27:54 +01:00