Age | Commit message (Collapse) | Author | Files | Lines |
|
This is a follow-up to #156140 and #160979, which deprecated one form of
write and read, respectively.
We have two forms of byte_swap:
template <typename value_type>
[[nodiscard]] inline value_type byte_swap(value_type value, endianness
endian)
template <typename value_type, endianness endian>
[[nodiscard]] inline value_type byte_swap(value_type value)
The difference is that endian is a function parameter in the former
but a template parameter in the latter.
This patch streamlines the code by migrating the use of the latter to
the former while deprecating the latter because the latter is just
forwarded to the former.
|
|
This PR updates the YAML representation of DXContainer to support Root
Signature 1.2, this also requires updating the write logic to support
testing.
|
|
SMLoc itself encapsulates just a pointer, so there is no need to pass or
return it by reference.
|
|
As in the description. Very straightforward.
|
|
Add DWO sections `.debug_loclists.dwo` and `.debug_rnglists.dwo` to the
COFF targets.
This enables building with `-DLLVM_USE_SPLIT_DWARF=ON` on the Cygwin
target, which previously failed due to compiler crashes.
|
|
(#159778)
Extract error reporting code emitted by CodeEmitterGen into
MCCodeEmitter static members functions.
Additionally, remove unused ErrorHandling.h header from several files.
|
|
[Previously reverted due to msan failures on two uninitialized padding
bits.]
This PR emits and relaxes the FREs generated in the previous PR.
After this change llvm emits usable sframe sections that can be linked
with the gnu linker. There are a few remaining cfi directives to handle
before they are generally usable, however.
The output isn't identical with gnu-gas in every case (this code
produces fewer identical FREs in a row than gas), but I'm reasonably
sure that they are correct regardless. There are even more size
optimizations that can be done later.
Also, while working on the tests, I found a few bugs in older portions
and cleaned those up.
This is a fairly big commit, but I'm not sure how to make it smaller.
|
|
Breaks some buildbots
This reverts commit c9285166214db4236f26312f68bba91f6437bd6f.
|
|
This PR emits and relaxes the FREs generated in the previous PR.
After this change llvm emits usable sframe sections that can be
linked with the gnu linker. There are a few remaining cfi directives to
handle before they are generally usable, however.
The output isn't identical with gnu-gas in every case (this code
produces
fewer identical FREs in a row than gas), but I'm reasonably sure that
they are correct regardless. There are even more size optimizations that
can be done later.
Also, while working on the tests, I found a few bugs in older portions
and cleaned those up.
This is a fairly big commit, but I'm not sure how to make it smaller.
|
|
This reverts commit aabf18d7184298566993e3141606cd79ff617d2d.
#157529 included a test that used clang, which doesn't exists in some
CI. #158343 reverts it.
This PR reapplies the original patch with the incorrect test removed.
### Context
#99710 introduced `.loc_label` so we can terminate a line sequence.
However, it did not advance PC properly. This is problematic for
1-instruction functions as it will have zero-length sequence. The test
checked in that PR shows the problem:
```
# CHECK-LINE-TABLE: Address Line Column File ISA Discriminator OpIndex Flags
# CHECK-LINE-TABLE-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
# CHECK-LINE-TABLE-NEXT: 0x00000028: 05 DW_LNS_set_column (1)
# CHECK-LINE-TABLE-NEXT: 0x0000002a: 00 DW_LNE_set_address (0x0000000000000000)
# CHECK-LINE-TABLE-NEXT: 0x00000035: 01 DW_LNS_copy
# CHECK-LINE-TABLE-NEXT: 0x0000000000000000 1 1 1 0 0 0 is_stmt
# CHECK-LINE-TABLE-NEXT: 0x00000036: 00 DW_LNE_end_sequence
# CHECK-LINE-TABLE-NEXT: 0x0000000000000000 1 1 1 0 0 0 is_stmt end_sequence
```
Both rows having PC 0x0 is incorrect, and parsers won't be able to parse
them. See more explanation why this is wrong in #154851.
### Design
This PR attempts to fix this by advancing the PC to the next available
Label, and advance to the end of the section if no Label is available.
### Implementation
- `emitDwarfLineEndEntry` will advance PC to the `CurrLabel`
- If `CurrLabel` is null, its probably a fake LineEntry we introduced in
#110192. In that case look for the next Label
- If still not label can be found, use `null` and
`emitDwarfLineEndEntry` is smart enough to advance PC to the end of the
section
- Rename `LastLabel` to `PrevLabel`, "last" can mean "previous" or
"final", this is ambigous.
- Updated the tests to emit a correct label.
### Note
This fix should render #154986 and #154851 obsolete, they were temporary
fixes and don't resolve the root cause.
|
|
The MCContext::getOrCreateSymbol change in #138817 was a workaround.
With #158106, we can replace `getOrCreateSymbol` with `parseSymbol`, in
llvm/lib/MC/MCParser to handle backslash-escaped symbols.
|
|
Reverts llvm/llvm-project#157529
Sorry, I missed that the missed that the LLVM test was using clang -
layering dictates thats not OK. Please readjust the test case to work
like the existing test coverage (or perhaps the existing test coverage
is sufficient?) and post a new PR.
|
|
### Context
#99710 introduced `.loc_label` so we can terminate a line sequence.
However, it did not advance PC properly. This is problematic for
1-instruction functions as it will have zero-length sequence. The test
checked in that PR shows the problem:
```
# CHECK-LINE-TABLE: Address Line Column File ISA Discriminator OpIndex Flags
# CHECK-LINE-TABLE-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
# CHECK-LINE-TABLE-NEXT: 0x00000028: 05 DW_LNS_set_column (1)
# CHECK-LINE-TABLE-NEXT: 0x0000002a: 00 DW_LNE_set_address (0x0000000000000000)
# CHECK-LINE-TABLE-NEXT: 0x00000035: 01 DW_LNS_copy
# CHECK-LINE-TABLE-NEXT: 0x0000000000000000 1 1 1 0 0 0 is_stmt
# CHECK-LINE-TABLE-NEXT: 0x00000036: 00 DW_LNE_end_sequence
# CHECK-LINE-TABLE-NEXT: 0x0000000000000000 1 1 1 0 0 0 is_stmt end_sequence
```
Both rows having PC 0x0 is incorrect, and parsers won't be able to parse
them. See more explanation why this is wrong in #154851.
### Design
This PR attempts to fix this by advancing the PC to the next available
Label, and advance to the end of the section if no Label is available.
### Implementation
- `emitDwarfLineEndEntry` will advance PC to the `CurrLabel`
- If `CurrLabel` is null, its probably a fake LineEntry we introduced in
#110192. In that case look for the next Label
- If still not label can be found, use `null` and
`emitDwarfLineEndEntry` is smart enough to advance PC to the end of the
section
- Rename `LastLabel` to `PrevLabel`, "last" can mean "previous" or
"final", this is ambigous.
- Updated the tests to emit a correct label.
### Note
This fix should render #154986 and #154851 obsolete, they were temporary
fixes and don't resolve the root cause.
---------
Signed-off-by: Peter Rong <PeterRong@meta.com>
|
|
This combines parseIdentifier() + getOrCreateSymbol(). This should make
it a bit easier if we want to change the parseIdentifier() API.
|
|
MC Descriptor Range Representation currently depend on Object
structures. This PR removes that dependency and in order to facilitate
removing to_underlying usage in follow-up PRs.
|
|
|
|
This PR parses CFI instructions to generate FREs.
Unfortunately, actually emitting the FREs into the object file is
somewhat involved and would make this PR quite a bit harder to review.
And the dumper itself properly errors if the FRE count is included in
the header or FDEs, but they are not actually emitted. So actually
testing that the proper FREs are generated will have to wait for a
subsequent PR.
For now, just check for common issues with CFI that sframe doesn't
support, and that proper error handling is done.
|
|
Avoids more Triple->string->Triple round trip. This
is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
|
|
RFC:
https://discourse.llvm.org/t/rfc-support-pseudo-probe-for-windows-coff/83820
Support emitting pseudo probe to .pseudo_probe and .pseudo_probe_desc
COFF sections.
|
|
|
|
* `SetFrame` does not count as a stack allocation.
* `mov` in the epilog undoes `SetFrame` (but is not required), it does
not deallocate a stack allocation.
* `mov` in the epilog MUST be before any stack deallocation or register
popping.
* Remove assert for having a prolog without any epilogs (this is
possible for `noreturn` functions, for instance).
* Improve the errors in `MC` to include the problematic function name.
|
|
closes #154331
This PR addresses all minimum changes needed to compile LLVM and MLIR
with the c++23 standard.
It is a work in progress and to be reviewed for better methods of
handling the parts of the build broken by c++23.
|
|
- The returned byte offset from `rewriteOffsetToCurrentByte` should not
be byte-swapped as it will be compared and interpreted as a uint32_t in
its uses
This commit corrects build failures that hit an assert on big-endian
builds
|
|
|
|
behaviour consistent (#155521)
This pr fixes some inconsistencies in behaviour of how we handle
`StaticSamplersOffset` with respect to DXC and `RootParameterOffset`.
Namely:
1. Make codegen of `RTS0` always compute the `StaticSamplersOffset`
regardless if there are any `StaticSampler`s. This is to be consistent
and produce an identical `DXContainer` as DXC.
2. Make the `StaticSamplersOffset` and `RootParametersOffset` optional
parameters in the yaml description. This means it will be used when it
is specified (which was not necassarily the case before).
3. Enforce that the provided `StaticSamplersOffset` and
`RootParametersOffset` in a yaml description match the computed value.
For more context see:
https://github.com/llvm/llvm-project/issues/155299.
Description of existing test updates updates:
- `CodeGen/DirectX/ContainerData`: Updated to codegen computed values
(previously unspecified)
- `llvm-objcopy/DXContainer`: Updated to `yaml2obj` computed values
(previously unspecified)
- `ObjectYAML/DXContainer`: Updated to `yaml2obj` computed values
(previously incorrect)
- `ObjectYAML/DXContainerYAMLTest`: Updated to `yaml2obj` computed
values (previously incorrect)
See newly added tests for testing of optional parameter functionality
and `StaticSamplersOffset` computation.
Resolves: https://github.com/llvm/llvm-project/issues/155299
|
|
Parameter Header (#154249)
This patch is refactoring Root Parameter Header in DX Container backend
to remove the usage of `to_underlying`. This requires some changes:
first, MC Root Signature should not depend on Object/DXContainer.h;
Second, we need to assume data to be valid in scenarios where it was
originally not expected, this made some tests be removed.
|
|
The implementation follows what is done for ELF on other targets.
Fixes #100733.
|
|
|
|
* FT_Data: skip relaxFragment
* Others: Call relaxFragment, which computes the old size, calls the
relevant relaxXXX function, then compares the size.
|
|
The tail fragment must be of type FT_Data. Reduce a computeFragmentSize
use.
|
|
This continues the sframe implementation. This change tracks and fills
out the necessary fields for FDEs, but doesn't create or add FREs.
|
|
Make it clear that other object file formats (e.g. ELF) do not use this
field.
|
|
The next change will move these methods from the base class.
|
|
This patch adds basic assembler and MC layer infrastructure for
RISC-V big-endian targets (riscv32be/riscv64be):
- Register big-endian targets in RISCVTargetMachine
- Add big-endian data layout strings
- Implement endianness-aware fixup application in assembler
backend
- Add byte swapping for data fixups on BE cores
- Update MC layer components (AsmInfo, MCTargetDesc, Disassembler,
AsmParser)
This provides the foundation for BE support but does not yet include:
- Codegen patterns for BE
- Load/store instruction handling
- BE-specific subtarget features
|
|
The next change will move it to MCSymbol{COFF,MachO,Wasm} to make it
clear that other object file formats (e.g. ELF) do not use this field.
|
|
This bit is only used by COFF/MachO. The upcoming change will move
isExported/setExported to MCSymbolCOFF/MCSymbolMachO.
|
|
These are identified by misc-include-cleaner. I've filtered out those
that break builds. Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
|
|
The name is misleading, as setting Fragment to nullptr does not
necessarily make it undefined - common and equated symbols have
a nullptr fragment as well.
|
|
The SymContentsTargetCommon kind introduced by
https://reviews.llvm.org/D61493 lackes significant and should be treated
as a regular common symbol with a different section index.
Update ELFObjectWriter to respect the specified section index.
The new representation also works with Hexagon's SHN_HEXAGON_SCOMMON.
|
|
The names "SymbolContents" and "SymContents*" members are confusing.
Rename to kind and Kind::XXX similar to lld/ELF/Symbols.h
Rename SymContentsVariable to Kind::Equated as the former term is
"equated symbol", not "variable".
|
|
Follow-up to 57b0843f68f5f349c73d1bf54e321a1a6d1800bf
The size of MCSymbol has been reduced to 24 bytes on 64-bit systems.
|
|
|
|
This continues the sframe implementation discussed previously.
Of note, this also adds some target dependent functions to the object
file. Additional fields will be needed later. It would be possible to do
all of this inside the sframe implementation itself if it feels a little
messy and specialized, but generally I think that target info goes with
target info.
Another question is if we want a sentinel value for unimplemented sframe
abi arches, or a std::optional. Both work.
|
|
Span-dependent instructions on RISC-V interact in a complex manner with
linker relaxation. The span-dependent assembler algorithm implemented in
LLVM has to start with the smallest version of an instruction and then
only make it larger, so we compress instructions before emitting them to
the streamer.
When the instruction is streamed, the information that the instruction
(or rather, the fixup on the instruction) is linker relaxable must be
accurate, even though the assembler relaxation process may transform a
not-linker-relaxable instruction/fixup into one that that is linker
relaxable, for instance `c.jal` becoming `qc.e.jal`, or `bne` getting
turned into `beq; jal` (the `jal` is linker relaxable).
In order for this to work, the following things have to happen:
- Any instruction/fixup which might be relaxed to a linker-relaxable
instruction/fixup, gets marked as `RelaxCandidate = true` in
RISCVMCCodeEmitter.
- In RISCVAsmBackend, when emitting the `R_RISCV_RELAX` relocation, we
have to check that the relocation/fixup kind is one that may need a
relax relocation, as well as that it is marked as linker relaxable (the
latter will not be set if relaxation is disabled).
- Linker Relaxable instructions streamed to a Relaxable fragment need to
mark the fragment and its section as linker relaxable.
I also added more debug output for Sections/Fixups which are marked
Linker Relaxable.
This results in more relocations, when these PC-relative fixups cross an
instruction with a fixup that is resolved as not linker-relaxable but
caused the fragment to be marked linker relaxable at streaming time
(i.e. `c.j`).
Fixes: #150071
|
|
Reverts llvm/llvm-project#152907
This is causing some build failures.
|
|
The switch statement `switch (Rmode)` is in an if-block that checks if
`Rmode != GOFF::ESD_RMODE_None` making the `case GOFF::ESD_RMODE_None:`
unnecessary.
|
|
Each section now tracks the index of the first linker-relaxable
fragment, enabling two changes:
* Delete redundant ALIGN relocations before the first linker-relaxable
instruction in a section. The primary example is the offset 0
R_RISCV_ALIGN relocation for a text section aligned by 4.
* For alignments larger than the NOP size after the first
linker-relaxable instruction, ALIGN relocations are now generated, even in
norelax regions. This fixes the issue #150159.
The new test llvm/test/MC/RISCV/Relocations/align-after-relax.s
verifies the required ALIGN in a norelax region following
linker-relaxable instructions.
By using a fragment index within the subsection (which is less than or
equal to the section's index), the implementation may generate redundant
ALIGN relocations in lower-numbered subsections before the first
linker-relaxable instruction.
align-option-relax.s demonstrates the ALIGN optimization.
Add an initial `call` to a few tests to prevent the ALIGN optimization.
---
When the alignment exceeds 2, we insert $alignment-2 bytes of NOPs, even
in non-RVC code. This enables non-RVC code following RVC code to handle
a 2-byte adjustment without requiring an additional state in MCSection
or AsmParser.
```
.globl _start
_start:
// GNU ld can relax this to 6505 lui a0, 0x1
// LLD hasn't implemented this transformation.
lui a0, %hi(foo)
.option push
.option norelax
.option norvc
// Now we generate R_RISCV_ALIGN with addend 2, even if this is a norvc region.
.balign 4
b0:
.word 0x3a393837
.option pop
foo:
```
Pull Request: https://github.com/llvm/llvm-project/pull/150816
|
|
(#147980)
We don't want that padding in a module that only contains data, not
code.
Also fix MCSection::hasInstructions() so it works with the asm streamer
too.
|
|
The fixed-size content of the MCFragment object is now stored as
trailing data, replacing ContentStart/ContentEnd with ContentSize. The
available space for trailing data is tracked using `FragSpace`. If the
available space is insufficient, a new block is allocated within the
bump allocator `MCObjectStreamer::FragStorage`.
FragList::Tail cannot be reused when switching sections or subsections,
as it is not associated with the fragment space tracked by `FragSpace`.
Instead, allocate a new fragment, which becomes less expensive after #150574.
Data can only be appended to the tail fragment of a subsection, not to
fragments in the middle. Post-assembler-layout adjustments (such as
.llvm_addrsig and .llvm.call-graph-profile) have been updated to use the
variable-size part instead.
---
This reverts commit a2fef664c29a53bfa8a66927fcf8b2e5c9da4876,
which reverted the innocent f1aa6050bd90f8ec4273da55d362e23905ad3a81 .
Commit df71243fa885cd3db701dc35a0c8d157adaf93b3, the MCOrgFragment fix,
has fixed the root cause of https://github.com/ClangBuiltLinux/linux/issues/2116
|
|
Similar to 742ecfc13e8aa34cfff2900e31838f657fcafe30 for MCFillFragment,
ensure `.org` directives with expressions are re-evaluated during
fragment relaxation, as their sizes may change. Continue iteration to
prevent stale, incorrect sizes. While I knew MCOrgFragment likely needed
to be re-evaluated at all, I did not have a motivation to add it;-)
This fixes the root cause of
https://github.com/ClangBuiltLinux/linux/issues/2116
(writeSectionData assertion failure when building the Linux kernel for arm64)
The issue cannot be reliably replicated. The specific test case would
not replicate if any of the following condition was not satisfied:
* .org was not re-evaluated. Fixed by this commit.
* clang -cc1as has a redundant `initSections` call, leading to a
redundant initial FT_Align fragment. llvm-mc -filetype=obj, lacking
the redundant `initSections`, doesn't replicate.
* faa931b717c02d57f0814caa9133219040e6a85b decreased sizeof(MCFragment).
* f1aa6050bd90f8ec4273da55d362e23905ad3a81 added more fragments
|