150 Commits

Author SHA1 Message Date
Djordje Todorovic
742147ba1b
[llvm-objcopy][libObject] Add RISC-V big-endian support (#146913)
Add support for big-endian RISC-V ELF files:
  - Add riscv32be/riscv64be target architectures to Triple
- Support elf32-bigriscv and elf64-bigriscv output targets in
llvm-objcopy
- Update ELFObjectFile to handle BE RISC-V format strings and
architecture detection
  - Add BE RISC-V support to RelocationResolver
  - Add tests for new functionality

This is a subset of a bigger RISC-V big-endian support patch, containing
only the llvm-objcopy and libObject changes. Other changes will be added
later.
2025-07-17 10:36:31 +02:00
Rahman Lavaee
6b623a6622
[SHT_LLVM_BB_ADDR_MAP] Remove support for versions 1 and 0 (SHT_LLVM_BB_ADDR_MAP_V0). (#146186)
Version 2 was added more than two years ago
(6015a045d7).
So it should be safe to deprecate older versions.
2025-07-02 10:31:52 -07:00
joaosaffran
770d0b028a
[DirectX] Fix order of v2::DescriptorRange (#145555)
As pointed in #145438, the order of elements in `v2::DescriptorRange` is
wrong according to the root signature file format. This changes the
order and updates the code and test to continue to pass.

Closes: #145438

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-06-24 14:27:58 -07:00
Rahman Lavaee
8d7a8fcc3a
[SHT_LLVM_BB_ADDR_MAP] Encode and decode callsite offsets in a newly-introduced SHT_LLVM_BB_ADDR_MAP version. (#144426)
Recently, we have been looking at some optimizations targeting
individual calls. In particular, we plan to extend the address mapping
technique to map to individual callsites. For example, in this piece of
code for a basic blocks:

```
<BB>:
1200:    lea 0x1(%rcx), %rdx
1204:    callq foo
1209:    cmpq 0x10, %rdx
120d:    ja  L1
```

We want to emit 0x9 as the call site offset for `callq foo` (the offset
from the block entry to right after the call), so that we know if a
sampled address is before the call or after.

This PR implements the decode/encode/emit capability. The Codegen change
will be implemented in a later PR.
2025-06-23 09:25:14 -07:00
Rahman Lavaee
0058272876
[NFC] Remove unused test code from ELFObjectFileTest.cpp 2025-06-16 11:27:25 -07:00
Simon Pilgrim
8f04a246d0
DXContainerTest.cpp - fix MSVC float truncation warning. NFC. (#142349) 2025-06-02 10:47:13 +01:00
joaosaffran
c7cbaef1e9
[DirectX] Adding support for static samplers in yaml2obj/obj2yaml (#139963)
- Adds support for static samplers ins dxcontainer binary format.
- Adds writing logic to mcdxbc
- adds reading logic to Object
- adds tests
Closes: [126636](https://github.com/llvm/llvm-project/issues/126636)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-05-29 14:02:15 -07:00
joaosaffran
8e19573682
[DirectX] adding support to read/write descriptor table data using obj2yaml/yaml2obj (#138315)
Closes:
https://github.com/orgs/llvm/projects/4/views/22?sliceBy%5Bvalue%5D=joaosaffran&pane=issue&itemId=97332852&issue=llvm%7Cllvm-project%7C126635

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-05-29 12:21:20 -07:00
Walter Lee
e2f118df1d
Write file to tmp directory (#141668)
This makes the test more portable. In google, the test was failing
because a test cannot write to its own directory in a sandbox.
2025-05-27 21:15:34 -04:00
Kazu Hirata
3e3b02ff52 [Object] Fix warnings
This patch fixes:

  llvm/unittests/Object/OffloadingBundleTest.cpp:56:19: error: unused
  variable 'mbuf' [-Werror,-Wunused-variable]

  llvm/unittests/Object/OffloadingBundleTest.cpp:57:13: error: unused
  variable 'FileName' [-Werror,-Wunused-variable]

  llvm/unittests/Object/OffloadingBundleTest.cpp:72:19: error: unused
  variable 'mbuf' [-Werror,-Wunused-variable]

  llvm/unittests/Object/OffloadingBundleTest.cpp:73:13: error: unused
  variable 'FileName' [-Werror,-Wunused-variable]
2025-05-23 09:31:50 -07:00
David Salinas
51a03ed272
Extend llvm objdump fatbin (#140286)
Utilize the new extensions to the LLVM Offloading API to extend to
llvm-objdump to handle dumping fatbin offload bundles generated by HIP.
This extension to llvm-objdump adds the option --offload-fatbin.
Specifying this option will take the input object/executable and extract
all offload fatbin bundle entries into distinct code object files with
names reflecting the source file name combined with the Bundle Entry ID.
Users can also use the --arch-name option to filter offload fatbin
bundle entries by their target triple.

---------

Co-authored-by: dsalinas <dsalinas@MKM-L1-DSALINAS.amd.com>
2025-05-23 11:55:16 -04:00
Kazu Hirata
9c3ab1cfc8 Revert "Reapply: [llvm-objdump] Add support for HIP offload bundles (#140128)"
This reverts commit 910220b84fa18ce2cbb2e21dd53b9f3d0ae582a7.

Multiple buildbot failures have been reported:
https://github.com/llvm/llvm-project/pull/140128
2025-05-16 07:23:21 -07:00
David Salinas
910220b84f
Reapply: [llvm-objdump] Add support for HIP offload bundles (#140128)
Utilize the new extensions to the LLVM Offloading API to extend to
llvm-objdump to handle dumping fatbin offload bundles generated by HIP.
This extension to llvm-objdump adds the option --offload-fatbin.
Specifying this option will take the input object/executable and extract
all offload fatbin bundle entries into distinct code object files with
names reflecting the source file name combined with the Bundle Entry ID.
Users can also use the --arch-name option to filter offload fatbin
bundle entries by their target triple.

---------

Co-authored-by: dsalinas <dsalinas@MKM-L1-DSALINAS.amd.com>
2025-05-16 09:39:15 -04:00
joaosaffran
03d3e6dbe9
[DirectX] Adding support for Root Descriptors in obj2yaml/yaml2obj (#137259)
closes: [126634](https://github.com/llvm/llvm-project/issues/126634)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-05-08 23:18:26 -07:00
Kazu Hirata
2299bada9f Revert "[llvm-objdump] Add support for HIP offload bundles (#114834)"
This reverts commit 06d6623bc304d5fc2fe11b80b62b4c5d10f9eaa1.

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/145/builds/6871/steps/5/logs/stdio
2025-05-08 17:20:18 -07:00
David Salinas
06d6623bc3
[llvm-objdump] Add support for HIP offload bundles (#114834)
Utilize the new extensions to the LLVM Offloading API to extend to
llvm-objdump to handle dumping fatbin offload bundles generated by HIP.
This extension to llvm-objdump adds the option --offload-fatbin.
Specifying this option will take the input object/executable and extract
all offload fatbin bundle entries into distinct code object files with
names reflecting the source file name combined with the Bundle Entry ID.
Users can also use the --arch-name option to filter offload fatbin
bundle entries by their target triple.

---------

Co-authored-by: dsalinas <dsalinas@MKM-L1-DSALINAS.amd.com>
2025-05-08 17:32:10 -04:00
joaosaffran
53eae22e22
[DirectX] adding support in obj2yaml and yaml2obj to root constants (#127840)
Adding support for Root Constant in MC, Object and obj2yaml and
yaml2obj, this PR adds:
  - new structures to dxbc definition.
  - serialize and desirialize logic from dxcontainer to yaml
  - tests validating against dxc
  - adding support to multiple parts.

Closes: https://github.com/llvm/llvm-project/issues/126633

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-04-16 18:38:53 -07:00
joaosaffran
1ff5f328d9
[DXIL] Add support for root signature flag element in DXContainer (#123147)
Adding support for Root Signature Flags Element extraction and writing
to DXContainer.
- Adding an analysis to deal with RootSignature metadata definition
- Adding validation for Flag
- writing RootSignature blob into DXIL

Closes: [126632](https://github.com/llvm/llvm-project/issues/126632)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-02-13 14:16:01 -08:00
Aiden Grossman
808b1c11a2
[ELF] Add support for CREL to getSectionAndRelocations
This patch updates the getSectionAndRelocations function to also support
CREL relocation sections. Unit tests have been added. This patch also
updates consumers to say they explicitly do not support CREL format
relocations. Subsequent patches will make the consumers work with CREL
format relocations and also add in testing support.

Reviewers: red1bluelost, MaskRay, rlavaee

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/126445
2025-02-10 10:57:19 -08:00
David Blaikie
51e7dc8627 Use explicit unsigned literals to fix mixed sign comparisons 2025-02-07 23:47:23 +00:00
joaosaffran
76985fd7ca
[DXIL] Adding support to RootSignatureFlags in obj2yaml (#122396)
This PR adds:
- `RootSignatureFlags` extraction from DXContainer using `obj2yaml`


This PR is part of: #121493

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-02-07 14:19:19 -08:00
Bushev Dmitry
0165e3346f
[llvm][Object] Add missing const qualifier for value_type in content_iterator (#124106)
value_type was defined as non-const for content_iterator, although it's
methods returned a const pointers/references. This prevented it from
using in some algorithms from STLExtras.h
2025-01-28 13:22:48 +03:00
Lei Wang
cf83a7fdc2
[SHT_LLVM_BB_ADDR_MAP] Add an option to skip emitting bb entries (#114447)
Sometimes we want to use a `PgoAnalysisMap` feature that doesn't require
the BB entries info, e.g. only the `FuncEntryCount`, but the BB entries
is emitted by default, so I'm adding an option to skip the info for this
case to save the binary size(can save ~90% size of the section). For
implementation, it extends a new field(`OmitBBEntries`) in
`BBAddrMap::Features` for this and it's controlled by a switch
`--basic-block-address-map-skip-bb-entries`.

Note that this naturally supports backwards compatibility as the field
is zero for the old version, matches the decoding in the new version
llvm.
2024-11-22 11:51:34 -08:00
Jinsong Ji
9d7b35d4e1
[NFC][GOFF] Fix char overflow (#112826)
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on.
Built by GCC 11.

Fix warnining:

llvm/unittests/Object/GOFFObjectFileTest.cpp:511:17: error: overflow in
conversion from ‘int’ to ‘char’ changes value from ‘240’ to
‘'\37777777760'’ [-Werror=overflow]
  511 |   GOFFData[1] = 0xF0;
2024-10-18 12:16:28 -04:00
JOE1994
459a82e689 [llvm][unittests] Don't call raw_string_ostream::flush() (NFC)
raw_string_ostream::flush() is essentially a no-op (also specified in docs).
Don't call it in tests that aren't meant to test 'raw_string_ostream' itself.

p.s. remove a few redundant calls to raw_string_ostream::str()
2024-09-13 19:55:44 -04:00
Jacob Lalonde
deba134092
[Minidump] Support multiple exceptions in a minidump (#107319)
A fork of #97470, splitting off the LLVM changes from the LLDB specific
changes. This patch enables a minidump file to have multiple exceptions,
exposed via an iterator of Expected streams.
2024-09-06 09:04:12 -07:00
Xiang Li
fd0dbc7f4d
[DirectX] add enum for PSV resource type/kind/flag. (#106227)
Add ResourceType, ResourceKind and ResourceFlag enum class for PSV
resource.

This is for #103275
2024-08-29 14:02:43 -04:00
Xiang Li
531a0b67ea
[DirectX] Reapply Fix DXIL part header version encoding (#91956)
This reapplies
195d8ac26d
[DirectX] Fix DXIL part header version encoding. The endian issue was
fixed by
f42117c851.

Move MinorVersion be the lower 8 bit.
Set DXIL version in DXContainerObjectWriter::writeObject.

Fixes #89952
2024-05-13 18:50:16 -04:00
Xiang Li
f42117c851
[DirectX] Replace bitfield version in ProgramHeader. (#91797)
Avoid using bitfield in dxbc::ProgramHeader.
It could potentially be read incorrectly on any host depending on the
compiler.

From [C++17's
[class.bit]](https://timsong-cpp.github.io/cppwp/n4659/class.bit#1)
> Bit-fields are packed into some addressable allocation unit. [ Note:
Bit-fields straddle allocation units on some machines and not on others.
Bit-fields are assigned right-to-left on some machines, left-to-right on
others.  — end note ]

For #91793
2024-05-11 21:16:22 -04:00
Justin Bogner
d655054395
Revert "[DirectX] Fix DXIL part header version encoding" (#91791)
Test failures on big endian bots after this change.

Reverts llvm/llvm-project#91506
2024-05-10 12:42:17 -06:00
Xiang Li
195d8ac26d
[DirectX] Fix DXIL part header version encoding (#91506)
Move MinorVersion be the lower 8 bit.
Set DXIL version in DXContainerObjectWriter::writeObject.


Fixes #89952
2024-05-10 06:29:23 -07:00
Amir Ayupov
df6d2faa22
[Object] Provide operator< for ELFSymbolRef (#89861)
Normally, operator< accepting DataRefImpl is used when comparing
SymbolRef/ELFSymbolRef. However, it uses std::memcmp which interprets
DataRefImpl union as char string so that the result depends on host
endianness.
For ELFSymbolRef a specialized operator< can be used instead to produce
consistent ordering regardless of endianness by comparing the symbol
table index and symbol index fields separately.
2024-04-29 09:07:26 -07:00
Yusra Syeda
4c718fdbea
[SystemZ][z/OS] TXT records in the GOFF reader (#87648)
This PR adds handling for TXT records in the GOFF reader.

---------

Co-authored-by: Yusra Syeda <yusra.syeda@ibm.com>
2024-04-08 11:05:42 -04:00
Neumann Hon
aeb8628c21 Revert "[SystemZ][z/OS] TXT records in the GOFF reader (#74526)"
This reverts commit 009f88fc0e3a036be97ef7b222b90af342bae0b7.

Reverting PR due to test failure.
2024-03-27 15:15:32 -04:00
Yusra Syeda
009f88fc0e
[SystemZ][z/OS] TXT records in the GOFF reader (#74526)
This PR adds handling for TXT records in the GOFF reader.

---------

Authored-by: Yusra Syeda <yusra.syeda@ibm.com>
2024-03-27 11:31:21 -04:00
Rahman Lavaee
acec6419e8
[SHT_LLVM_BB_ADDR_MAP] Allow basic-block-sections and labels be used together by decoupling the handling of the two features. (#74128)
Today `-split-machine-functions` and `-fbasic-block-sections={all,list}`
cannot be combined with `-basic-block-sections=labels` (the labels
option will be ignored).
The inconsistency comes from the way basic block address map -- the
underlying mechanism for basic block labels -- encodes basic block
addresses
(https://lists.llvm.org/pipermail/llvm-dev/2020-July/143512.html).
Specifically, basic block offsets are computed relative to the function
begin symbol. This relies on functions being contiguous which is not the
case for MFS and basic block section binaries. This means Propeller
cannot use binary profiles collected from these binaries, which limits
the applicability of Propeller for iterative optimization.
    
To make the `SHT_LLVM_BB_ADDR_MAP` feature work with basic block section
binaries, we propose modifying the encoding of this section as follows.

First let us review the current encoding which emits the address of each
function and its number of basic blocks, followed by basic block entries
for each basic block.

| | |
|--|--|
| Address of the function | Function Address |
|  Number of basic blocks in this function | NumBlocks |
|  BB entry 1
|  BB entry 2
|   ...
|  BB entry #NumBlocks
    
To make this work for basic block sections, we treat each basic block
section similar to a function, except that basic block sections of the
same function must be encapsulated in the same structure so we can map
all of them to their single function.
    
We modify the encoding to first emit the number of basic block sections
(BB ranges) in the function. Then we emit the address map of each basic
block section section as before: the base address of the section, its
number of blocks, and BB entries for its basic block. The first section
in the BB address map is always the function entry section.
| | |
|--|--|
|  Number of sections for this function   | NumBBRanges |
| Section 1 begin address                     | BaseAddress[1]  |
| Number of basic blocks in section 1 | NumBlocks[1]    |
| BB entries for Section 1
|..................|
| Section #NumBBRanges begin address | BaseAddress[NumBBRanges] |
| Number of basic blocks in section #NumBBRanges |
NumBlocks[NumBBRanges] |
| BB entries for Section #NumBBRanges
    
The encoding of basic block entries remains as before with the minor
change that each basic block offset is now computed relative to the
begin symbol of its containing BB section.
    
This patch adds a new boolean codegen option `-basic-block-address-map`.
Correspondingly, the front-end flag `-fbasic-block-address-map` and LLD
flag `--lto-basic-block-address-map` are introduced.
Analogously, we add a new TargetOption field `BBAddrMap`. This means BB
address maps are either generated for all functions in the compiling
unit, or for none (depending on `TargetOptions::BBAddrMap`).
    
This patch keeps the functionality of the old
`-fbasic-block-sections=labels` option but does not remove it. A
subsequent patch will remove the obsolete option.

We refactor the `BasicBlockSections` pass by separating the BB address
map and BB sections handing to their own functions (named
`handleBBAddrMap` and `handleBBSections`). `handleBBSections` renumbers
basic blocks and places them in their assigned sections.
`handleBBAddrMap` is invoked after `handleBBSections` (if requested) and
only renumbers the blocks.
  - New tests added:
- Two tests basic-block-address-map-with-basic-block-sections.ll and
basic-block-address-map-with-mfs.ll to exercise the combination of
`-basic-block-address-map` with `-basic-block-sections=list` and
'-split-machine-functions`.
- A driver sanity test for the `-fbasic-block-address-map` option
(basic-block-address-map.c).
- An LLD test for testing the `--lto-basic-block-address-map` option.
This reuses the LLVM IR from `lld/test/ELF/lto/basic-block-sections.ll`.
- Renamed and modified the two existing codegen tests for basic block
address map (`basic-block-sections-labels-functions-sections.ll` and
`basic-block-sections-labels.ll`)
- Removed `SHT_LLVM_BB_ADDR_MAP_V0` tests. Full deprecation of
`SHT_LLVM_BB_ADDR_MAP_V0` and `SHT_LLVM_BB_ADDR_MAP` version less than 2
will happen in a separate PR in a few months.
2024-02-01 17:50:46 -08:00
Micah Weston
23faa81d3f
[SHT_LLVM_BB_ADDR_MAP] Avoids side-effects in addition since order is unspecified. (#79168)
Turns out the problem with
https://github.com/llvm/llvm-project/issues/60013 is due to the fact
that order of operation is unspecified in C++:
https://en.cppreference.com/w/cpp/language/eval_order. A small example
of where this manifests with MSVC can be seen here
https://ooo.godbolt.org/z/bxqKeqzqn.

This patch does the following:
* Removes the addition operations where we sequence more than one
side-effect based expression.
* Removes test guards to now run on Windows
2024-01-24 17:26:48 -05:00
Rahman Lavaee
6ba2c2bb80
[SHT_LLVM_BB_ADDR_MAP,NFC] Add SCOPED_TRACE for convenient mapping of failures to test cases. (#78335)
Although parameterized gtests are preferred for this, our tests are not
very straightforward. So I decided to add SCOPED_TRACE for different
test cases and the lambda checks as well.

Typical test failure message now looks like:

```
...llvm-project/llvm/unittests/Object/ELFObjectFileTest.cpp:737
Expected equality of these values:
  *BBAddrMaps
    Which is: { 32-byte object <11-11 01-00 00-00 00-00 C0-A9 FB-3E E4-55 00-00 D0-A9 FB-3E E4-55 00-00 D0-A9 FB-3E E4-55 00-00>, 32-byte object <22-22 02-00 00-00 00-00 F0-8E FB-3E E4-55 00-00 00-8F FB-3E E4-55 00-00 00-8F FB-3E E4-55 00-00> }
  ExpectedResult
    Which is: { 32-byte object <33-33 03-00 00-00 00-00 50-A7 FB-3E E4-55 00-00 60-A7 FB-3E E4-55 00-00 60-A7 FB-3E E4-55 00-00> }
Google Test trace:
...llvm-project/llvm/unittests/Object/ELFObjectFileTest.cpp:726: for TextSectionIndex: 1 and object yaml:

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
Sections:
  - Name: .llvm_bb_addr_map_1
    Type: SHT_LLVM_BB_ADDR_MAP
    Link: 1
    Entries:
      - Version: 2
        Address: 0x11111
        BBEntries:
          - ID:            1
            AddressOffset: 0x0
            Size:          0x1
            Metadata:      0x2
  - Name: .llvm_bb_addr_map_2
    Type: SHT_LLVM_BB_ADDR_MAP
    Link: 1
    Entries:
      - Version: 2
        Address: 0x22222
        BBEntries:
          - ID:            2
            AddressOffset: 0x0
            Size:          0x2
            Metadata:      0x4
  - Name: .llvm_bb_addr_map_3
    Type: SHT_LLVM_BB_ADDR_MAP
    Link: 2
    Entries:
      - Version: 1
        Address: 0x33333
        BBEntries:
          - ID:            0
            AddressOffset: 0x0
            Size:          0x3
            Metadata:      0x6
  - Name: .llvm_bb_addr_map_4
    Type: SHT_LLVM_BB_ADDR_MAP_V0
  # Link: 0 (by default, can be overriden)
    Entries:
      - Version: 0
        Address: 0x44444
        BBEntries:
          - ID:            0
            AddressOffset: 0x0
            Size:          0x4
            Metadata:      0x18

...llvm-project/llvm/unittests/Object/ELFObjectFileTest.cpp:757: normal sections
```
2024-01-16 14:17:10 -08:00
Micah Weston
2873060f3c
[SHT_LLVM_BB_ADDR_MAP] Fixes two bugs in decoding of PGOAnalyses in BBAddrMap. (#77139)
We had specified that `readBBAddrMap` will always keep PGOAnalyses and
BBAddrMaps the same length on success.

365fbbfbcf/llvm/include/llvm/Object/ELFObjectFile.h (L116-L117)

It turns out that this is not currently the case when no analyses exist
in a function. No test had caught it.

We also should not append PGOBBEntries when there is no BBFreq or
BrProb.

This patch adds:
* tests that PGOAnalyses and BBAddrMaps are same length even when no
analyses are enabled
* fixes decode so that PGOAnalyses and BBAddrMaps are same length
* updates test to not emit unnecessary PGOBBEntries
* fixes decode to not emit PGOBBEntries when unnecessary
2024-01-05 21:59:51 -05:00
Joseph Huber
0cb98167ec [ELF][Obvious] Last time fixing this test hopefully 2024-01-05 12:09:20 -06:00
Joseph Huber
c2f5e435a5 [ELF] Again attempt to fix test on BE architectures
Summary:
This formats something according to the style, and again attempts to fix
this failing on the BE PPC test. Sorry for the spam, these commits are
the only way I can check it because the failure isn't local.
2024-01-05 11:49:21 -06:00
Joseph Huber
dfe9bb4dc2 [ELF] Attempt to fix test on big endian architectures
Summary:
This test fails because AMDGPU has a check for little-endianness before
returning the architecture. This test attempts to force the type to be
considered little-endian for the purpose of this test.
2024-01-05 11:24:03 -06:00
Joseph Huber
3b337bbc81
[ELF] Attempt to set the OS when using 'makeTriple()' (#76992)
Summary:
This patch fixes up the `makeTriple()` interface to emit append the
operating system information when it is readily avaialble from the ELF.
The main motivation for this is so the GPU architectures can be easily
identified correctly when given and ELF. E.g. we want
`amdgpu-amd-amdhsa` as the output and not `amdgpu--`.

This required adding support for the CUDA OS/ABI, which is easily found
to be `0x33` when using `readelf`.
2024-01-05 10:24:30 -06:00
Micah Weston
105adf2cd9
[SHT_LLVM_BB_ADDR_MAP] Implements PGOAnalysisMap in Object and ObjectYAML with tests.
Reviewed in PR (#71750). A part of [RFC - PGO Accuracy Metrics: Emitting and Evaluating Branch
and Block
Analysis](https://discourse.llvm.org/t/rfc-pgo-accuracy-metrics-emitting-and-evaluating-branch-and-block-analysis/73902).

This PR adds the PGOAnalysisMap data structure and implements encoding and
decoding through Object and ObjectYAML along with associated tests. When
emitted into the bb-addr-map section, each function is followed by the associated
pgo-analysis-map for that function. The emitting of each analysis in the map is
controlled by a bit in the bb-addr-map feature byte. All existing bb-addr-map
code can ignore the pgo-analysis-map if the caller does not request the data.
2023-12-12 10:23:16 -05:00
Lu Weining
c3a9c905fb
[BinaryFormat][LoongArch] Define psABI v2.20 relocs (#73345)
psABI v2.20 added R_LARCH_CALL36 and removed R_LARCH_DELETE / R_LARCH_CFA.

R_LARCH_CALL36 was designed for function call on medium code model where
the 2 instructions (pcaddu18i + jirl) must be adjacent.
2023-12-05 09:20:48 +08:00
Rahman Lavaee
fab690d6b5
[NFC][SHT_LLVM_BB_ADDR_MAP] Define and use constructor and accessors for BBAddrMap fields. (#72689)
The fields are still kept as public for now since our tooling accesses
them. Will change them to private visibility in a later patch.
2023-11-17 11:44:06 -08:00
Chris B
9f87522b12
[DX] Add support for program signatures (#67346)
For DirectX, program signatures are encoded into three different binary
sections depending on if the signature is for inputs, outputs, or
patches. All three signature types use the same data structure encoding
so they can share a lot of logic.

This patch adds support for reading and writing program signature data
as both yaml and binary data.

Fixes #57743 and #57744
2023-10-05 10:33:15 -05:00
Fangrui Song
f93c271d4c [Object] Change OffloadBinary::write to return SmallString<0>
SmallString<0> is more flexible and avoids an unneeded copy in
ObjectYAML/OffloadEmitter.cpp.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D159335
2023-09-01 09:19:25 -07:00
Chris Bieneman
0c3f51c042 Re-land [DX] Add support for PSV signature elements
The pipeline state data captured in the PSV0 section of the DXContainer
file encodes signature elements which are read by the runtime to map
inputs and outputs from the GPU program.

This change adds support for generating and parsing signature elements
with testing driven through the ObjectYAML tooling.

Reviewed By: bogner

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

Initially landed as 8c567e64f808f7a818965c6bc123fedf7db7336f, and
reverted in 4d800633b2683304a5431d002d8ffc40a1815520.

../llvm/include/llvm/BinaryFormat/DXContainerConstants.def
../llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml
../llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml
2023-08-16 14:26:13 -05:00
Chris Bieneman
4d800633b2 Revert "[DX] Add support for PSV signature elements"
This reverts commit 8c567e64f808f7a818965c6bc123fedf7db7336f.
2023-08-16 13:52:26 -05:00