aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/TargetLoweringObjectFile.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-08-13[llvm] Qualify auto in range-based for loops (NFC)Kazu Hirata1-1/+1
Identified with readability-qualified-auto.
2022-07-07[Metadata] Add 'exclude' metadata to add the exclude flags on globalsJoseph Huber1-0/+7
This patchs adds a new metadata kind `exclude` which implies that the global variable should be given the necessary flags during code generation to not be included in the final executable. This is done using the ``SHF_EXCLUDE`` flag on ELF for example. This should make it easier to specify this flag on a variable without needing to explicitly check the section name in the target backend. Depends on D129053 D129052 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D129151
2022-03-10Cleanup includes: LLVMTargetserge-sans-paille1-2/+0
Most notably, Pass.h is no longer included by TargetMachine.h before: 1063570306 after: 1063332844 Differential Revision: https://reviews.llvm.org/D121168
2021-05-05[MC] Untangle MCContext and MCObjectFileInfoPhilipp Krones1-1/+1
This untangles the MCContext and the MCObjectFileInfo. There is a circular dependency between MCContext and MCObjectFileInfo. Currently this dependency also exists during construction: You can't contruct a MOFI without a MCContext without constructing the MCContext with a dummy version of that MOFI first. This removes this dependency during construction. In a perfect world, MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the MCContext, like other MC information. This is future work. This also shifts/adds more information to the MCContext making it more available to the different targets. Namely: - TargetTriple - ObjectFileType - SubtargetInfo Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101462
2021-03-02[AIX][TLS] Generate TLS variables in assembly filesVictor Huang1-1/+7
This patch allows generating TLS variables in assembly files on AIX. Initialized and external uninitialized variables are generated with the .csect pseudo-op and local uninitialized variables are generated with the .comm/.lcomm pseudo-ops. The patch also adds a check to explicitly say that TLS is not yet supported on AIX. Reviewed by: daltenty, jasonliu, lei, nemanjai, sfertile Originally patched by: bsaleil Commandeered by: NeHuang Differential Revision: https://reviews.llvm.org/D96184
2021-02-18[llvm][IR] Do not place constants with static relocations in a mergeable sectionLeonard Chan1-1/+2
This patch provides two major changes: 1. Add getRelocationInfo to check if a constant will have static, dynamic, or no relocations. (Also rename the original needsRelocation to needsDynamicRelocation.) 2. Only allow a constant with no relocations (static or dynamic) to be placed in a mergeable section. This will allow unused symbols that contain static relocations and happen to fit in mergeable constant sections (.rodata.cstN) to instead be placed in unique-named sections if -fdata-sections is used and subsequently garbage collected by --gc-sections. See https://lists.llvm.org/pipermail/llvm-dev/2021-February/148281.html. Differential Revision: https://reviews.llvm.org/D95960
2021-02-16Basic block sections should enable function sections implicitly.Sriraman Tallam1-0/+5
Basic block sections enables function sections implicitly, this is not needed and is inefficient with "=list" option. We had basic block sections enable function sections implicitly in clang. This is particularly inefficient with "=list" option as it places functions that do not have any basic block sections in separate sections. This causes unnecessary object file overhead for large applications. This patch disables this implicit behavior. It only creates function sections for those functions that require basic block sections. Further, there was an inconistent behavior with llc as llc was not turning on function sections by default. This patch makes llc and clang consistent and tests are added to check the new behavior. This is the first of two patches and this adds functionality in LLVM to create a new section for the entry block if function sections is not enabled. Differential Revision: https://reviews.llvm.org/D93876
2020-12-14[NFC] cleanup cg-profile emission on TargetLowerinngZequan Wu1-0/+48
Differential Revision: https://reviews.llvm.org/D93150
2020-12-02[XCOFF][AIX] Alternative path in EHStreamer for platforms do not have ↵jasonliu1-0/+10
uleb128 support Summary: Not all system assembler supports `.uleb128 label2 - label1` form. When the target do not support this form, we have to take alternative manual calculation to get the offsets from them. Reviewed By: hubert.reinterpretcast Diffierential Revision: https://reviews.llvm.org/D92058
2020-09-27Revert "Reland [CodeGen] emit CG profile for COFF object file"Arthur Eubanks1-48/+0
This reverts commit 506b6170cb513f1cb6e93a3b690c758f9ded18ac. This still causes link errors, see https://crbug.com/1130780.
2020-09-24Reland [CodeGen] emit CG profile for COFF object fileZequan Wu1-0/+48
This reverts commit 90242caca2074dab5a9b76e5bc36d9fafd2179a7. Error fixed at f5435399e823746bbe1737b95c853d77a42e1ac3 Differential Revision: https://reviews.llvm.org/D87811
2020-09-22Revert "[CodeGen] emit CG profile for COFF object file"Reid Kleckner1-46/+0
This reverts commit 91aed9bf975f1e4346cc8f4bdefc98436386ced2, it is causing link errors.
2020-09-18[CodeGen] emit CG profile for COFF object fileZequan Wu1-0/+46
I forgot to add emission of CG profile for COFF object file, when adding the support (https://reviews.llvm.org/D81775) Differential Revision: https://reviews.llvm.org/D87811
2020-05-29[AIX] Emit AvailableExternally Linkage on AIXXiangling Liao1-1/+1
Since on AIX, our strategy is to not use -u to suppress any undefined symbols, we need to emit .extern for the symbols with AvailableExternally linkage. Differential Revision: https://reviews.llvm.org/D80642
2020-05-21[Target] Use Align in TargetLoweringObjectFile::getSectionForConstant.Craig Topper1-3/+3
Differential Revision: https://reviews.llvm.org/D80363
2020-05-19TargetLoweringObjectFile.h - remove unnecessary includes. NFCI.Simon Pilgrim1-0/+11
Replace with forward declarations and move includes down to source files where required. I also needed to move the TargetLoweringObjectFile::SectionForGlobal wrapper implementation down into TargetLoweringObjectFile.cpp
2020-04-13Extend BasicBlock sections to allow specifying clusters of basic blocks in ↵Rahman Lavaee1-6/+0
the same section. Differential Revision: https://reviews.llvm.org/D76954
2020-04-13Revert "Extend BasicBlock sections to allow specifying clusters of basic blocks"Rahman Lavaee1-0/+6
This reverts commit 0d4ec16d3db3a92514e14101f635e8536c208c4f Because tests were not added to the commit.
2020-04-13Extend BasicBlock sections to allow specifying clusters of basic blocksRahman Lavaee1-6/+0
in the same section. This allows specifying BasicBlock clusters like the following example: !foo !!0 1 2 !!4 This places basic blocks 0, 1, and 2 in one section in this order, and places basic block #4 in a single section of its own.
2020-03-21Delete TargetLoweringObjectFile::CtxFangrui Song1-4/+3
We can use the parent MCObjectFileInfo::Ctx which has the same value.
2020-03-16Basic Block Sections support in LLVM.Sriraman Tallam1-0/+16
This is the second patch in a series of patches to enable basic block sections support. This patch adds support for: * Creating direct jumps at the end of basic blocks that have fall through instructions. * New pass, bbsections-prepare, that analyzes placement of basic blocks in sections. * Actual placing of a basic block in a unique section with special handling of exception handling blocks. * Supports placing a subset of basic blocks in a unique section. * Support for MIR serialization and deserialization with basic block sections. Parent patch : D68063 Differential Revision: https://reviews.llvm.org/D73674
2020-02-14[MC] De-capitalize another set of MCStreamer::Emit* functionsFangrui Song1-1/+1
Emit{ValueTo,Code}Alignment Emit{DTP,TP,GP}* EmitSymbolValue etc
2019-10-15Added support for "#pragma clang section relro=<name>"Dmitry Mikulin1-0/+1
Differential Revision: https://reviews.llvm.org/D68806 llvm-svn: 374934
2019-07-17[AsmPrinter] Make the encoding of call sites in .gcc_except_table ↵Alex Bradbury1-0/+1
configurable and use for RISC-V The original behavior was to always emit the offsets to each call site in the call site table as uleb128 values, however on some architectures (eg RISCV) these uleb128 offsets into the code cannot always be resolved until link time (because relaxation will invalidate any calculated offsets), and there are no appropriate relocations for uleb128 values. As a consequence it needs to be possible to specify an alternative. This also switches RISCV to use DW_EH_PE_udata4 for call side encodings in .gcc_except_table Differential Revision: https://reviews.llvm.org/D63415 Patch by Edward Jones. llvm-svn: 366329
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-08-09[MC] Move EH DWARF encodings from MC to CodeGen, NFCReid Kleckner1-0/+3
Summary: The TType encoding, LSDA encoding, and personality encoding are all passed explicitly by CodeGen to the assembler through .cfi_* directives, so only the AsmPrinter needs to know about them. The FDE CFI encoding however, controls the encoding of the label implicitly created by the .cfi_startproc directive. That directive seems to be special in that it doesn't take an encoding, so the assembler just has to know how to encode one DSO-local label reference from .eh_frame to .text. As a result, it looks like MC will continue to have to know when the large code model is in use. Perhaps we could invent a '.cfi_startproc [large]' flag so that this knowledge doesn't need to pollute the assembler. Reviewers: davide, lliu0, JDevlieghere Subscribers: hiraditya, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D50533 llvm-svn: 339397
2018-07-30Remove trailing spaceFangrui Song1-2/+2
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
2018-05-27Remove boolean argument from isSuitableFromBSS.Eric Christopher1-8/+5
The argument was used as an additional negative condition and can be expressed in the if conditional without needing to pass it down. Update bss commentary around main use. llvm-svn: 333357
2018-05-27Cleanups for getKindForGlobal:Eric Christopher1-11/+10
- Clarify block comment - Make Function/GlobalVariable split more explicit. - Move locals closer to uses. llvm-svn: 333356
2018-03-26Remove an unneeded (& mislayered) include from ↵David Blaikie1-1/+0
Target/TargetLoweringObjectFile on a CodeGen header llvm-svn: 328549
2018-03-23Move TargetLoweringObjectFile from CodeGen to Target to fix layeringDavid Blaikie1-1/+1
It's implemented in Target & include from other Target headers, so the header should be in Target. llvm-svn: 328392
2018-02-06Place undefined globals in .bss instead of .dataEli Friedman1-1/+14
Following up on the discussion from http://lists.llvm.org/pipermail/llvm-dev/2017-April/112305.html, undef values are now placed in the .bss as well as null values. This prevents undef global values taking up potentially huge amounts of space in the .data section. The following two lines now both generate equivalent .bss data: @vals1 = internal unnamed_addr global [20000000 x i32] zeroinitializer, align 4 @vals2 = internal unnamed_addr global [20000000 x i32] undef, align 4 ; previously unaccounted for This is primarily motivated by the corresponding issue in the Rust compiler (https://github.com/rust-lang/rust/issues/41315). Differential Revision: https://reviews.llvm.org/D41705 Patch by varkor! llvm-svn: 324424
2017-12-13Remove redundant includes from lib/Target/*.cpp.Michael Zolotukhin1-2/+0
llvm-svn: 320633
2017-11-17Fix a bunch more layering of CodeGen headers that are in TargetDavid Blaikie1-3/+3
All these headers already depend on CodeGen headers so moving them into CodeGen fixes the layering (since CodeGen depends on Target, not the other way around). llvm-svn: 318490
2017-08-02Don't pass the code model to MCRafael Espindola1-2/+2
I was surprised to see the code model being passed to MC. After all, it assembles code, it doesn't create it. The one place it is used is in the expansion of .cfi directives to handle .eh_frame being more that 2gb away from the code. As far as I can tell, gnu assembler doesn't even have an option to enable this. Compiling a c file with gcc -mcmodel=large produces a regular looking .eh_frame. This is probably because in practice linker parse and recreate .eh_frames. In llvm this is used because the JIT can place the code and .eh_frame very far apart. Ideally we would fix the jit and delete this option. This is hard. Apart from confusion another problem with the current interface is that most callers pass CodeModel::Default, which is bad since MC has no way to map it to the target default if it actually needed to. This patch then replaces the argument with a boolean with a default value. The vast majority of users don't ever need to look at it. In fact, only CodeGen and llvm-mc use it and llvm-mc just to enable more testing. llvm-svn: 309884
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner1-1/+1
This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
2017-06-05Add support for #pragma clang sectionJaved Absar1-0/+14
This patch provides a means to specify section-names for global variables, functions and static variables, using #pragma directives. This feature is only defined to work sensibly for ELF targets. One can specify section names as: #pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText" One can "unspecify" a section name with empty string e.g. #pragma clang section bss="" data="" text="" rodata="" Reviewers: Roger Ferrer, Jonathan Roelofs, Reid Kleckner Differential Revision: https://reviews.llvm.org/D33413 llvm-svn: 304704
2017-05-01Remove unnecessary conditions as suggested by clang-tidy. NFCGabor Horvath1-1/+1
Patch by: Gergely Angeli! Differential Revision: https://reviews.llvm.org/D31936 llvm-svn: 301807
2017-01-14[TargetLowering] Simplfiy a bit. NFCI.Davide Italiano1-4/+1
llvm-svn: 292024
2016-11-22CodeGen: simplify TargetMachine::getSymbol interface. NFC.Tim Northover1-2/+2
No-one actually had a mangler handy when calling this function, and getSymbol itself went most of the way towards getting its own mangler (with a local TLOF variable) so forcing all callers to supply one was just extra complication. llvm-svn: 287645
2016-10-24Target: Change various section classifiers in TargetLoweringObjectFile to ↵Peter Collingbourne1-8/+9
take a GlobalObject. These functions are about classifying a global which will actually be emitted, so it does not make sense for them to take a GlobalValue which may for example be an alias. Change the Mach-O object writer and the Hexagon, Lanai and MIPS backends to look through aliases before using TargetLoweringObjectFile interfaces. These are functional changes but all appear to be bug fixes. Differential Revision: https://reviews.llvm.org/D25917 llvm-svn: 285006
2016-09-16Trying to fix Mangler memory leak in TargetLoweringObjectFile.Eric Liu1-0/+2
Summary: `TargetLoweringObjectFile` can be re-used and thus `TargetLoweringObjectFile::Initialize()` can be called multiple times causing `Mang` pointer memory leak. Reviewers: echristo Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D24659 llvm-svn: 281718
2016-09-16Move the Mangler from the AsmPrinter down to TLOF and clean up theEric Christopher1-19/+16
TLOF API accordingly. llvm-svn: 281708
2016-08-08[ARM] Add support for embedded position-independent codeOliver Stannard1-6/+7
This patch adds support for some new relocation models to the ARM backend: * Read-only position independence (ROPI): Code and read-only data is accessed PC-relative. The offsets between all code and RO data sections are known at static link time. This does not affect read-write data. * Read-write position independence (RWPI): Read-write data is accessed relative to the static base register (r9). The offsets between all writeable data sections are known at static link time. This does not affect read-only data. These two modes are independent (they specify how different objects should be addressed), so they can be used individually or together. They are otherwise the same as the "static" relocation model, and are not compatible with SysV-style PIC using a global offset table. These modes are normally used by bare-metal systems or systems with small real-time operating systems. They are designed to avoid the need for a dynamic linker, the only initialisation required is setting r9 to an appropriate value for RWPI code. I have only added support to SelectionDAG, not FastISel, because FastISel is currently disabled for bare-metal targets where these modes would be used. Differential Revision: https://reviews.llvm.org/D23195 llvm-svn: 278015
2016-06-28Use isPositionIndependent(). NFC.Rafael Espindola1-2/+1
llvm-svn: 274005
2016-06-24Simplify. NFC.Rafael Espindola1-10/+1
Also delete out of date comment. This code was always returning .data since r253436. llvm-svn: 273739
2016-06-14IR: Introduce local_unnamed_addr attribute.Peter Collingbourne1-1/+1
If a local_unnamed_addr attribute is attached to a global, the address is known to be insignificant within the module. It is distinct from the existing unnamed_addr attribute in that it only describes a local property of the module rather than a global property of the symbol. This attribute is intended to be used by the code generator and LTO to allow the linker to decide whether the global needs to be in the symbol table. It is possible to exclude a global from the symbol table if three things are true: - This attribute is present on every instance of the global (which means that the normal rule that the global must have a unique address can be broken without being observable by the program by performing comparisons against the global's address) - The global has linkonce_odr linkage (which means that each linkage unit must have its own copy of the global if it requires one, and the copy in each linkage unit must be the same) - It is a constant or a function (which means that the program cannot observe that the unique-address rule has been broken by writing to the global) Although this attribute could in principle be computed from the module contents, LTO clients (i.e. linkers) will normally need to be able to compute this property as part of symbol resolution, and it would be inefficient to materialize every module just to compute it. See: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/356401.html http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356738.html for earlier discussion. Part of the fix for PR27553. Differential Revision: http://reviews.llvm.org/D20348 llvm-svn: 272709
2016-05-18Don't pass a Reloc::Model to MC.Rafael Espindola1-1/+2
MC only needs to know if the output is PIC or not. It never has to decide about creating GOTs and PLTs for example. The only thing that MC itself uses this information for is expanding "macros" in sparc and mips. The rest I am pretty sure could be moved to CodeGen. This is a cleanup and isolates the code from future changes to Reloc::Model. llvm-svn: 269909
2016-02-22[X86] Create mergeable constant pool entries for AVXDavid Majnemer1-0/+1
We supported creating mergeable constant pool entries for smaller constants but not for 32-byte AVX constants. llvm-svn: 261584
2016-02-21[X86] Use the correct alignment for COMDAT constant pool entriesDavid Majnemer1-2/+5
COFF doesn't have sections with mergeable contents. Instead, each constant pool entry ends up in a COMDAT section. The linker, when choosing between COMDAT sections, doesn't choose the max alignment of the two sections. You just get whatever alignment was on the section. If one constant needed a higher alignment in one object file from another one, then we will get into trouble if the linker chooses the lower alignment one. Instead, lets promote the alignment of the constant pool entry to make sure we don't use an under aligned constant with an instruction which assumed otherwise. This fixes PR26680. llvm-svn: 261462