aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCStreamer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-01-18Revert "[BOLT] Fix unconditional output of boltedcollection in merge-fdata ↵Amir Ayupov1-2/+0
(#78653)" This reverts commit 82bc33ea3f1a539be50ed46919dc53fc6b685da9. Accidentally pushed unrelated changes.
2024-01-18[BOLT] Fix unconditional output of boltedcollection in merge-fdata (#78653)Amir Ayupov1-0/+2
Fix the bug where merge-fdata unconditionally outputs boltedcollection line, regardless of whether input files have it set. Test Plan: Added bolt/test/X86/merge-fdata-nobat-mode.test which fails without this fix.
2024-01-17 [llvm] Teach MachO about XROS (#78373)Cyndy Ishida1-0/+9
Add support for XROS to encode in Mach-O file formats.
2023-12-04[AIX] In assembly file, create a dummy text renamed to an empty string (#73052)stephenpeckham1-4/+1
This works around an AIX assembler and linker bug. If the -fno-integrated-as and -frecord-command-line options are used but there's no actual code in the source file, the assembler creates an object file with only an .info section. The AIX linker rejects such an object file.
2023-10-12Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata1-1/+1
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
2023-07-10Implement -frecord-command-line for XCOFFJake Egan1-0/+5
This patch extends support of the option `-frecord-command-line` to XCOFF. XCOFF doesn’t have custom sections like ELF, so the command line data is emitted to a .info section instead. A C_INFO symbol is generated with the .info section to preserve the command line data past the link step. Multiple command lines are separated by newlines and null bytes. The command line data can be retrieved on AIX with command `what file_name`. Reviewed By: scott.linder Differential Revision: https://reviews.llvm.org/D153600
2023-06-26[MC] Add SMLoc to MCCFIInstructionFangrui Song1-34/+38
to help debug and report better diagnostics for functions like relaxDwarfCallFrameFragment (D153167). In MCStreamer, some emitCFI* functions already take a SMLoc argument. Add a SMLoc argument to the remaining functions that generate a MCCFIInstruction.
2023-06-07Reland "D144999 [MC][MachO]Only emits compact-unwind format for "canonical" ↵Vy Nguyen1-1/+1
personality symbols. For the rest, use DWARFs." Reasons for rolling forward: - the crash reported from Chromium was fixed in D151824 (not related to this patch at all) - since D152824 was committed, it should now be safe to roll this forward. New change: - add an additional _ in name check This reverts commit 4980eead4d0b4666d53dad07afb091375b3a13a0.
2023-05-19Revert "[RFC][MC][MachO]Only emits compact-unwind format for "canonical" ↵Nico Weber1-1/+1
personality symbols. For the rest, use DWARFs." This reverts commit 09aaf53a05e3786eea374f3ce57574225036412d. Causes toolchain asserts building libc++ for x86_64, see https://reviews.llvm.org/D144999#4356215
2023-05-18[RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality ↵Vy Nguyen1-1/+1
symbols. For the rest, use DWARFs. Details: https://github.com/rust-lang/rust/issues/102754 The MachO format uses 2 bits to encode these personality funtions, with 0 reserved for "no-personality". This means we can only have up to 3 personality. There are already three popular personalities: __gxx_personality_v0, __gcc_personality_v0, and __objc_personality_v0. As a result, any system that needs custom-personality will run into a problem. This patch implemented jyknight's proposal to simply force DWARFs for all non-canonical personality functions. Differential Revision: https://reviews.llvm.org/D144999
2023-05-10[PseudoProbe] Encode/Decode FS discriminatorHongtao Yu1-3/+3
Encoding FS discriminators for block probes. Decoding them correspondingly. The encoding/decoding of FS discriminators are conditional, only for probes with a non-zero discriminator. This saves encoding size, also ensures downwards-compatiblity. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D147651
2023-04-25[MC] Eagerly skip zero-sized .fill fragmentsBenjamin Kramer1-1/+2
This doesn't change the output in any way, but we have a bunch of emitFill for padding. When emitting an array of floats we'd end up with DataFragment float1 FillFragment 0 DataFragment float2 FillFragment 0 ... and so on We never actually emit anything for those fills, neither in asm nor obj emission mode, they just consume RAM for no reason.
2023-03-23[XCOFF] support the ref directive for object generation.esmeyi1-1/+1
Summary: A R_REF relocation as a non-relocating reference is required to prevent garbage collection (by the binder) of the ref symbol in object generation. Reviewed By: shchenz Differential Revision: https://reviews.llvm.org/D144356
2023-01-30[MC] Allow .pushsection between .cfi_startproc/.cfi_endprocAlex Brachet1-3/+6
This follows the behavior of gnu assemblers. This is useful when writing inline assembly. Differential Revision: https://reviews.llvm.org/D141893
2022-12-21[DWARFv4][DWARFv5][DWARFLinker] support debug_macinfo/debug_macro tables.Alexey Lapshin1-2/+4
This patch adds handling of debug_macinfo/debug_macro tables to the DWARFLinker. It uses already existing code for reading tables from DWARFDebugMacro.h. It adds new code writing tables into the DwarfStreamer::emitMacroTables. Differential Revision: https://reviews.llvm.org/D140223
2022-12-08[Alignment] Use Align in MCStreamer::emitTBSSSymbolGuillaume Chatelet1-1/+1
In the same vein as D139439, the patch is not NFC as there is no way to check all downstream implementations but the patch seems pretty safe. Differential Revision: https://reviews.llvm.org/D139548
2022-12-07[reland][Alignment] Use Align in MCStreamer emitZeroFill/emitLocalCommonSymbolGuillaume Chatelet1-1/+1
Before performing this change, I checked that `ByteAlignment` was never `0` inside `MCAsmStreamer:emitZeroFill` and `MCAsmStreamer::emitLocalCommonSymbol`. I believe it is NFC as `0` values are illegal in `emitZeroFill` anyways, `Log2(ByteAlignment)` would be undefined. And currently, all calls to `emitLocalCommonSymbol` are provably `>0`. Differential Revision: https://reviews.llvm.org/D139439
2022-12-07Revert D139439 "[Alignment] Use Align in MCStreamer ↵Guillaume Chatelet1-1/+1
emitZeroFill/emitLocalCommonSymbol" This breaks Windows bots with `warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)` Some shift operators are lacking a proper literal unit ('1ULL' instead of '1'). Will reland once fixed. This reverts commit c621c1a8e81856e6bf2be79714767d80466e9ede.
2022-12-07[Alignment] Use Align in MCStreamer emitZeroFill/emitLocalCommonSymbolGuillaume Chatelet1-1/+1
Before performing this change, I checked that `ByteAlignment` was never `0` inside `MCAsmStreamer:emitZeroFill` and `MCAsmStreamer::emitLocalCommonSymbol`. I believe it is NFC as `0` values are illegal in `emitZeroFill` anyways, `Log2(ByteAlignment)` would be undefined. And currently, all calls to `emitLocalCommonSymbol` are provably `>0`. Differential Revision: https://reviews.llvm.org/D139439
2022-12-05Remove unused #include "llvm/ADT/Optional.h"Fangrui Song1-1/+0
2022-12-04[MC] llvm::Optional => std::optionalFangrui Song1-7/+5
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04DebugInfoMetadata: convert Optional to std::optionalKrzysztof Parzyszek1-2/+3
2022-11-24[Alignment][NFC] Use Align in MCStreamer::emitValueToAlignmentGuillaume Chatelet1-1/+1
Differential Revision: https://reviews.llvm.org/D138674
2022-11-24[Alignment][NFC] Use Align for MCStreamer::emitXCOFFLocalCommonSymbolGuillaume Chatelet1-1/+1
Differential Revision: https://reviews.llvm.org/D138669
2022-11-24[Alignment][NFC] Use Align in MCStreamer::emitCodeAlignmentGuillaume Chatelet1-2/+1
This patch makes code less readable but it will clean itself after all functions are converted. Differential Revision: https://reviews.llvm.org/D138665
2022-11-24[Alignment][NFC] Use Align in MCStreamer::emitBundleAlignModeGuillaume Chatelet1-1/+1
Summary: Reviewers: courbet Subscribers:
2022-11-21[PowerPC] XCOFF exception section support on the integrated assembler pathPaul Scoropan1-2/+2
Continuation of https://reviews.llvm.org/D132146 (direct assembly path support, needs to merge first). Adds support to the integrated assembler path for emitting XCOFF exception sections. Both features need https://reviews.llvm.org/D133030 to merge first Reviewed By: shchenz, DiggerLin Differential Revision: https://reviews.llvm.org/D134195
2022-10-27[PseudoProbe] Replace relocation with offset for entry probe.Hongtao Yu1-2/+3
Currently pseudo probe encoding for a function is like: - For the first probe, a relocation from it to its physical position in the code body - For subsequent probes, an incremental offset from the current probe to the previous probe The relocation could potentially cause relocation overflow during link time. I'm now replacing it with an offset from the first probe to the function start address. A source function could be lowered into multiple binary functions due to outlining (e.g, coro-split). Since those binary function have independent link-time layout, to really avoid relocations from .pseudo_probe sections to .text sections, the offset to replace with should really be the offset from the probe's enclosing binary function, rather than from the entry of the source function. This requires some changes to previous section-based emission scheme which now switches to be function-based. The assembly form of pseudo probe directive is also changed correspondingly, i.e, reflecting the binary function name. Most of the source functions end up with only one binary function. For those don't, a sentinel probe is emitted for each of the binary functions with a different name from the source. The sentinel probe indicates the binary function name to differentiate subsequent probes from the ones from a different binary function. For examples, given source function ``` Foo() { … Probe 1 … Probe 2 } ``` If it is transformed into two binary functions: ``` Foo: … Foo.outlined: … ``` The encoding for the two binary functions will be separate: ``` GUID of Foo Probe 1 GUID of Foo Sentinel probe of Foo.outlined Probe 2 ``` Then probe1 will be decoded against binary `Foo`'s address, and Probe 2 will be decoded against `Foo.outlined`. The sentinel probe of `Foo.outlined` makes sure there's not accidental relocation from `Foo.outlined`'s probes to `Foo`'s entry address. On the BOLT side, to be minimal intrusive, the pseudo probe re-encoding sticks with the old encoding format. This is fine since unlike linker, Bolt processes the pseudo probe section as a whole and it is free from relocation overflow issues. The change is downwards compatible as long as there's no mixed use of the old encoding and the new encoding. Reviewed By: wenlei, maksfb Differential Revision: https://reviews.llvm.org/D135912 Differential Revision: https://reviews.llvm.org/D135914 Differential Revision: https://reviews.llvm.org/D136394
2022-09-26[PowerPC] XCOFF exception section support on the direct assembler pathPaul Scoropan1-0/+9
This feature implements support for making entries in the exception section on XCOFF on the direct assembly path using the ".except" pseudo-op. It also provides functionality to lower entries (comprised of language and reason codes) into the exception section through the use of annotation metadata attached to llvm.ppc.trap/trapd/tw/tdw intrinsics. Integrated assembler support will be provided in another review. https://reviews.llvm.org/D133030 needs to merge first for LIT tests Reviewed By: shchenz, RKSimon Differential Revision: https://reviews.llvm.org/D132146
2022-08-08[llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song1-1/+1
With C++17 there is no Clang pedantic warning or MSVC C5051.
2022-07-11Revert "Rebase: [Facebook] [MC] Introduce NeverAlign fragment type"spupyrev1-2/+0
This reverts commit 6d0528636ae54fba75938a79ae7a98dfcc949f72.
2022-07-11Rebase: [Facebook] [MC] Introduce NeverAlign fragment typeRafael Auler1-0/+2
Summary: Introduce NeverAlign fragment type. The intended usage of this fragment is to insert it before a pair of macro-op fusion eligible instructions. NeverAlign fragment ensures that the next fragment (first instruction in the pair) does not end at a given alignment boundary by emitting a minimal size nop if necessary. In effect, it ensures that a pair of macro-fusible instructions is not split by a given alignment boundary, which is a precondition for macro-op fusion in modern Intel Cores (64B = cache line size, see Intel Architecture Optimization Reference Manual, 2.3.2.1 Legacy Decode Pipeline: Macro-Fusion). This patch introduces functionality used by BOLT when emitting code with MacroFusion alignment already in place. The use case is different from BoundaryAlign and instruction bundling: - BoundaryAlign can be extended to perform the desired alignment for the first instruction in the macro-op fusion pair (D101817). However, this approach has higher overhead due to reliance on relaxation as BoundaryAlign requires in the general case - see https://reviews.llvm.org/D97982#2710638. - Instruction bundling: the intent of NeverAlign fragment is to prevent the first instruction in a pair ending at a given alignment boundary, by inserting at most one minimum size nop. It's OK if either instruction crosses the cache line. Padding both instructions using bundles to not cross the alignment boundary would result in excessive padding. There's no straightforward way to request instruction bundling to avoid a given end alignment for the first instruction in the bundle. LLVM: https://reviews.llvm.org/D97982 Manual rebase conflict history: https://phabricator.intern.facebook.com/D30142613 Test Plan: sandcastle Reviewers: #llvm-bolt Subscribers: phabricatorlinter Differential Revision: https://phabricator.intern.facebook.com/D31361547
2022-06-18[llvm] Use value_or instead of getValueOr (NFC)Kazu Hirata1-9/+8
2022-06-10[MC] De-capitalize SwitchSection. NFCFangrui Song1-4/+4
Add SwitchSection to return switchSection. The API will be removed soon.
2022-06-08[MC] Add 'G' to augmentation string for MTE instrumented functionsFlorian Mayer1-0/+7
This was agreed on in https://lists.llvm.org/pipermail/llvm-dev/2020-May/141345.html The thread proposed two options * add a character to augmentation string and handle in libuwind * use a separate personality function. It was determined that this is the simpler and better option. This is part of ARM's Aarch64 ABI: https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#id22 The next step after this is teaching libunwind to untag when this augmentation character is set. Reviewed By: MaskRay, eugenis Differential Revision: https://reviews.llvm.org/D127007
2022-06-07[MC] De-capitalize MCStreamer functionsFangrui Song1-5/+5
Follow-up to c031378ce01b8485ba0ef486654bc9393c4ac024 . The class is mostly consistent now.
2022-05-26[MC] Lower case the first letter of EmitCOFF* EmitWin* EmitCV*. NFCFangrui Song1-30/+28
2022-03-11[MC] Fix letter case of some MCSection member functionsFangrui Song1-1/+1
2022-02-22Add DriverKit supportEgor Zhdan1-0/+8
This patch is the first in a series of patches to upstream the support for Apple's DriverKit. Once complete, it will allow targeting DriverKit platform with Clang similarly to AppleClang. This code was originally authored by JF Bastien. Differential Revision: https://reviews.llvm.org/D118046
2022-02-09Cleanup LLVMMC headersserge-sans-paille1-0/+1
There's a few relevant forward declarations in there that may require downstream adding explicit includes: llvm/MC/MCContext.h no longer includes llvm/BinaryFormat/ELF.h, llvm/MC/MCSubtargetInfo.h, llvm/MC/MCTargetOptions.h llvm/MC/MCObjectStreamer.h no longer include llvm/MC/MCAssembler.h llvm/MC/MCAssembler.h no longer includes llvm/MC/MCFixup.h, llvm/MC/MCFragment.h Counting preprocessed lines required to rebuild llvm-project on my setup: before: 1052436830 after: 1049293745 Which is significant and backs up the change in addition to the usual benefits of decreasing coupling between headers and compilation units. Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D119244
2022-02-06[llvm] Use = default (NFC)Kazu Hirata1-1/+1
2022-02-05[AIX][PowerPC][PGO] Generate .ref for some PGO sectionsWael Yehia1-0/+4
For PGO on AIX, when we switch to the linux-style PGO variable access (via _start and _stop labels), we need the compiler to generate a .ref assembly for each of the three csects: - __llvm_prf_data[RW] - __llvm_prf_names[RO] - __llvm_prf_vnds[RW] We insert the .ref inside the __llvm_prf_cnts[RW] csect so that if it's live then the 3 csects are live. For example, for a testcase with at least one function definition, when compiled with -fprofile-generate we should generate: .csect __llvm_prf_cnts[RW],3 .ref __llvm_prf_data[RW] <<============ needs to be inserted .ref __llvm_prf_names[RO] <<=========== the __llvm_prf_vnds is not always present, so we reference it only when it's present. Reviewed By: sfertile, daltenty Differential Revision: https://reviews.llvm.org/D116607
2022-01-08[llvm] Fix bugprone argument comments (NFC)Kazu Hirata1-2/+2
Identified with bugprone-argument-comment.
2021-12-10[ThinLTO][MC] Use conditional assignments for promotion aliasesSami Tolvanen1-0/+3
Inline assembly refererences to static functions with ThinLTO+CFI were fixed in D104058 by creating aliases for promoted functions. Creating the aliases unconditionally resulted in an unexpected size increase in a Chrome helper binary: https://bugs.chromium.org/p/chromium/issues/detail?id=1261715 This is caused by the compiler being unable to drop unused code now referenced by the alias in module-level inline assembly. This change adds a .set_conditional assembly extension, which emits an assignment only if the target symbol is also emitted, avoiding phantom references to functions that could have otherwise been dropped. This is an alternative to the solution proposed in D112761. Reviewed By: pcc, nickdesaulniers, MaskRay Differential Revision: https://reviews.llvm.org/D113613
2021-12-07[macho] add support for emitting macho files with two build version load ↵Alex Lorenz1-8/+42
commands This patch extends LLVM IR to add metadata that can be used to emit macho files with two build version load commands. It utilizes "darwin.target_variant.triple" and "darwin.target_variant.SDK Version" metadata names for that, which will be set by a future patch in clang. MachO uses two build version load commands to represent an object file / binary that is targeting both the macOS target, and the Mac Catalyst target. At runtime, a dynamic library that supports both targets can be loaded from either a native macOS or a Mac Catalyst app on a macOS system. We want to add support to this to upstream to LLVM to be able to build compiler-rt for both targets, to finish the complete support for the Mac Catalyst platform, which is right now targetable by upstream clang, but the compiler-rt bits aren't supported because of the lack of this multiple build version support. Differential Revision: https://reviews.llvm.org/D112189
2021-12-07Revert "Revert "Use VersionTuple for parsing versions in Triple, fixing ↵James Farrell1-13/+12
issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible."" This reverts commit 63a6348cad6caccf285c1661bc60d8ba5a40c972. Differential Revision: https://reviews.llvm.org/D115254
2021-12-06Revert "Use VersionTuple for parsing versions in Triple, fixing issues that ↵James Farrell1-12/+13
caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible." This reverts commit 50324670342d9391f62671685f4d6b4880a4ea9a.
2021-12-06Use VersionTuple for parsing versions in Triple, fixing issues that caused ↵James Farrell1-13/+12
the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible. This reverts commit 40d5eeac6cd89a2360c3ba997cbaa816abca828c. Differential Revision: https://reviews.llvm.org/D114885
2021-11-30Revert "Use VersionTuple for parsing versions in Triple. This makes it ↵Nikita Popov1-7/+9
possible to distinguish between "16" and "16.0" after parsing, which previously was not possible." This reverts commit 1e8286467036d8ef1a972de723f805a4981b2692. llvm/test/Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll fails with assertion failure: llc: /home/nikic/llvm-project/llvm/include/llvm/ADT/Optional.h:196: T& llvm::optional_detail::OptionalStorage<T, true>::getValue() & [with T = unsigned int]: Assertion `hasVal' failed. ... #8 0x00005633843af5cb llvm::MCStreamer::emitVersionForTarget(llvm::Triple const&, llvm::VersionTuple const&) #9 0x0000563383b47f14 llvm::AsmPrinter::doInitialization(llvm::Module&)
2021-11-30Use VersionTuple for parsing versions in Triple. This makes it possible to ↵James Farrell1-9/+7
distinguish between "16" and "16.0" after parsing, which previously was not possible. See also https://github.com/android/ndk/issues/1455. Differential Revision: https://reviews.llvm.org/D114163