aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineModuleInfo.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-01-16Move Personalities array from MachineModuleInfo to DwarfCFIException.James Y Knight1-12/+0
It was only ever used there, already. The previous location seems left-over from when the personality function was specified on a per-landingpad basis, instead of per-function.
2022-12-21CodeGen: Don't lazily construct MachineFunctionInfoMatt Arsenault1-0/+1
This fixes what I consider to be an API flaw I've tripped over multiple times. The point this is constructed isn't well defined, so depending on where this is first called, you can conclude different information based on the MachineFunction. For example, the AMDGPU implementation inspected the MachineFrameInfo on construction for the stack objects and if the frame has calls. This kind of worked in SelectionDAG which visited all allocas up front, but broke in GlobalISel which hasn't visited any of the IR when arguments are lowered. I've run into similar problems before with the MIR parser and trying to make use of other MachineFunction fields, so I think it's best to just categorically disallow dependency on the MachineFunction state in the constructor and to always construct this at the same time as the MachineFunction itself. A missing feature I still could use is a way to access an custom analysis pass on the IR here.
2022-06-12[MC][re-land] Omit DWARF unwind info if compact unwind is present where eligibleJez Ng1-3/+3
This reverts commit d941d597837d9e1405086f008c9bd6a71e7263c9. Differential Revision: https://reviews.llvm.org/D122258
2022-06-12Revert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"Jez Ng1-3/+3
This reverts commit ef501bf85d8c869248e51371f0e74bcec0e7b229.
2022-06-12[MC] Omit DWARF unwind info if compact unwind is present where eligibleJez Ng1-3/+3
Previously, omitting unnecessary DWARF unwinds was only done in two cases: * For Darwin + aarch64, if no DWARF unwind info is needed for all the functions in a TU, then the `__eh_frame` section would be omitted entirely. If any one function needed DWARF unwind, then MC would emit DWARF unwind entries for all the functions in the TU. * For watchOS, MC would omit DWARF unwind on a per-function basis, as long as compact unwind was available for that function. This diff makes it so that we omit DWARF unwind on a per-function basis for Darwin + aarch64 as well. In addition, we introduce the flag `--emit-dwarf-unwind=` which can toggle between `always`, `no-compact-unwind` (only emit DWARF when CU cannot be emitted for a given function), and the target platform `default`. `no-compact-unwind` is particularly useful for newer x86_64 platforms: we don't want to omit DWARF unwind for x86_64 in general due to possible backwards compat issues, but we should make it possible for people to opt into this behavior if they are only targeting newer platforms. **Motivation:** I'm working on adding support for `__eh_frame` to LLD, but I'm concerned that we would suffer a perf hit. Processing compact unwind is already expensive, and that's a simpler format than EH frames. Given that MC currently produces one EH frame entry for every compact unwind entry, I don't think processing them will be cheap. I tried to do something clever on LLD's end to drop the unnecessary EH frames at parse time, but this made the code significantly more complex. So I'm looking at fixing this at the MC level instead. **Addendum:** It turns out that there was a latent bug in the X86 backend when `OmitDwarfIfHaveCompactUnwind` is naively enabled, which is not too surprising given that this combination has not been heretofore used. For functions that have unwind info that cannot be encoded with CU, MC would end up dropping both the compact unwind entry (OK; existing behavior) as well as the DWARF entries (not OK). This diff fixes things so that we emit the DWARF entry, as well as a CU entry with encoding `UNWIND_X86_MODE_DWARF` -- this basically tells the unwinder to look for the DWARF entry. I'm not 100% sure the `UNWIND_X86_MODE_DWARF` CU entry is necessary, this was the simplest fix. ld64 seems to be able to handle both the absence and presence of this CU entry. Ultimately ld64 (and LLD) will synthesize `UNWIND_X86_MODE_DWARF` if it is absent, so there is no impact to the final binary size. Reviewed By: davide, lhames Differential Revision: https://reviews.llvm.org/D122258
2022-05-04[iwyu] Handle regressions in libLLVM header includeserge-sans-paille1-6/+0
Running iwyu-diff on LLVM codebase since fa5a4e1b95c8f37796 detected a few regressions, fixing them. Differential Revision: https://reviews.llvm.org/D124847
2022-04-27llvm-reduce: Support multiple MachineFunctionsMatt Arsenault1-0/+7
The current testcase I'm trying to reduce only reproduces with IPRA enabled and requires handling multiple functions. The only real difference vs. the IR is the extra indirect to look for the underlying MachineFunction, so treat the ReduceWorkItem as the module instead of the function. The ugliest piece of this is really the ugliness of MachineModuleInfo. It not only tracks actual module state, but has a number of transient fields used for isel and/or the asm printer. These shouldn't do any harm for the use here, though they should be separated out.
2022-04-20MachineModuleInfo: Move AddrLabelSymbols to AsmPrinterMatt Arsenault1-179/+0
This was tracking global state only used by the AsmPrinter, which can store its own module global state.
2022-04-20MachineModuleInfo: Remove UsesMorestackAddrMatt Arsenault1-2/+1
This is x86 specific, and adds statefulness to MachineModuleInfo. Instead of explicitly tracking this, infer if we need to declare the symbol based on the reference previously inserted. This produces a small change in the output due to the move from AsmPrinter::doFinalization to X86's emitEndOfAsmFile. This will now be moved relative to other end of file fields, which I'm assuming doesn't matter (e.g. the __morestack_addr declaration is now after the .note.GNU-split-stack part) This also produces another small change in code if the module happened to define/declare __morestack_addr, but I assume that's invalid and doesn't really matter.
2022-04-20MachineModuleInfo: Move HasSplitStack handling to AsmPrinterMatt Arsenault1-3/+0
This is used to emit one field in doFinalization for the module. We can accumulate this when emitting all individual functions directly in the AsmPrinter, rather than accumulating additional state in MachineModuleInfo. Move the special case behavior predicate into MachineFrameInfo to share it. This now promotes it to generic behavior. I'm assuming this is fine because no other target implements adjustForSegmentedStacks, or has tests using the split-stack attribute.
2022-04-19MachineModuleInfo: Don't allow dynamically setting DbgInfoAvailableMatt Arsenault1-2/+10
This can be set up front, and used only as a cache. This avoids a field that looks like it requires MIR serialization. I believe this fixes 2 bugs for CodeView. First, this addresses a FIXME that the flag -diable-debug-info-print only works with DWARF. Second, it fixes emitting debug info with emissionKind NoDebug.
2022-04-19[msan] Disable assert with msanVitaly Buka1-0/+4
The assert uses data from just destroyed BasicBlock.
2022-03-16Cleanup codegen includesserge-sans-paille1-5/+0
This is a (fixed) recommit of https://reviews.llvm.org/D121169 after: 1061034926 before: 1063332844 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121681
2022-03-10Revert "Cleanup codegen includes"Nico Weber1-0/+5
This reverts commit 7f230feeeac8a67b335f52bd2e900a05c6098f20. Breaks CodeGenCUDA/link-device-bitcode.cu in check-clang, and many LLVM tests, see comments on https://reviews.llvm.org/D121169
2022-03-10Cleanup codegen includesserge-sans-paille1-5/+0
after: 1061034926 before: 1063332844 Differential Revision: https://reviews.llvm.org/D121169
2022-02-23[NFC] Remove unnecessary "#include"s from header filesBill Wendling1-0/+1
2022-01-28[lld] Add module name to LTO inline asm diagnosticFangrui Song1-3/+5
Close #52781: for LTO, the inline asm diagnostic uses `<inline asm>` as the file name (lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp) and it is unclear which module has the issue. With this patch, we will see the module name (say `asm.o`) before `<inline asm>` with ThinLTO. ``` % clang -flto=thin -c asm.c && myld.lld asm.o -e f ld.lld: error: asm.o <inline asm>:1:2: invalid instruction mnemonic 'invalid' invalid ^~~~~~~ ``` For regular LTO, unfortunately the original module name is lost and we only get ld-temp.o. Reviewed By: #lld-macho, ychen, Jez Ng Differential Revision: https://reviews.llvm.org/D118434
2021-05-23[MC] Refactor MCObjectFileInfo initialization and allow targets to create ↵Philipp Krones1-6/+9
MCObjectFileInfo This makes it possible for targets to define their own MCObjectFileInfo. This MCObjectFileInfo is then used to determine things like section alignment. This is a follow up to D101462 and prepares for the RISCV backend defining the text section alignment depending on the enabled extensions. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101921
2021-05-05[MC] Untangle MCContext and MCObjectFileInfoPhilipp Krones1-6/+9
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-04-19Reset NextFnNum in MachineModuleInfo::initializeRoman Tereshin1-0/+1
In an env that reuses compiler instances for multiple compilations, this omission results in non-deterministic assembly output (names of the auto-generated labels) if the order or full set of Modules compiled varies. Differential Revision: https://reviews.llvm.org/D100797
2021-04-07Revert "[AsmPrinter] Delete dead takeDeletedSymbsForFunction()"Arthur Eubanks1-2/+47
This reverts commit 9583a3f2625818b78c0cf6d473cdedb9f23ad82c. This wasn't NFC as initially thought. Needed for D99707.
2021-03-01[Diagnose] Unify MCContext and LLVMContext diagnosingYuanfang Chen1-0/+37
The situation with inline asm/MC error reporting is kind of messy at the moment. The errors from MC layout are not reliably propagated and users have to specify an inlineasm handler separately to get inlineasm diagnose. The latter issue is not a correctness issue but could be improved. * Kill LLVMContext inlineasm diagnose handler and migrate it to use DiagnoseInfo/DiagnoseHandler. * Introduce `DiagnoseInfoSrcMgr` to diagnose SourceMgr backed errors. This covers use cases like inlineasm, MC, and any clients using SourceMgr. * Move AsmPrinter::SrcMgrDiagInfo and its instance to MCContext. The next step is to combine MCContext::SrcMgr and MCContext::InlineSrcMgr because in all use cases, only one of them is used. * If LLVMContext is available, let MCContext uses LLVMContext's diagnose handler; if LLVMContext is not available, MCContext uses its own default diagnose handler which just prints SMDiagnostic. * Change a few clients(Clang, llc, lldb) to use the new way of reporting. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D97449
2021-02-14[llvm] Use llvm::is_contained (NFC)Kazu Hirata1-4/+2
2020-12-28[CodeGen] Use llvm::append_range (NFC)Kazu Hirata1-2/+1
2020-12-21[MC] Split MCContext::createTempSymbol, default AlwaysAddSuffix to true, and ↵Fangrui Song1-1/+2
add comments CanBeUnnamed is rarely false. Splitting to a createNamedTempSymbol makes the intention clearer and matches the direction of reverted r240130 (to drop the unneeded parameters). No behavior change.
2020-11-30Add MachineModuleInfo constructor with external MCContextHendrik Greving1-1/+17
Adds a constructor to MachineModuleInfo and MachineModuleInfoWapperPass that takes an external MCContext. If provided, the external context will be used throughout codegen instead of MMI's default one. This enables external drivers to take ownership of data put on the MMI's context during codegen. The internal context is used otherwise and destroyed upon finish. Differential Revision: https://reviews.llvm.org/D91313
2020-10-16Revert "make the AsmPrinterHandler array public"Jameson Nash1-2/+2
I messed up one of the tests.
2020-10-16make the AsmPrinterHandler array publicJameson Nash1-2/+2
This lets external consumers customize the output, similar to how AssemblyAnnotationWriter lets the caller define callbacks when printing IR. The array of handlers already existed, this just cleans up the code so that it can be exposed publically. Differential Revision: https://reviews.llvm.org/D74158
2020-07-27Fix the move constructor of MMI to move MachineFunctions mapSridhar Gopinath1-1/+2
The move constructor of MachineModuleInfo currently does not copy the MachineFunctions map. This commit fixes this issue. Patch by Sridhar Gopinath. Thanks! Differential Revision: https://reviews.llvm.org/D84274
2020-04-06Allow MachineFunction to obtain non-const Function (to enable MIR-level ↵Daniel Sanders1-2/+1
debugify) Summary: To debugify MIR, we need to be able to create metadata and to do that, we need a non-const Module. However, MachineFunction only had a const reference to the Function preventing this. Reviewers: aprantl, bogner Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77439
2020-04-03[NFC][XCOFF][AIX] Refactor get/setContainingCsectjasonliu1-9/+0
Summary: For current architect, we always require setContainingCsect to be called on every MCSymbol got used in XCOFF context. This is very hard to achieve because symbols gets created everywhere and other MCSymbol types(ELF, COFF) do not have similar rules. It's very easy to miss setting the containing csect, and we would need to add a lot of XCOFF specialized code around some common code area. This patch intendeds to do 1. Rely on getFragment().getParent() to get csect from labels. 2. Only use get/setRepresentedCsect (was get/setContainingCsect) if symbol itself represents a csect. Reviewers: DiggerLin, hubert.reinterpretcast, daltenty Differential Revision: https://reviews.llvm.org/D77080
2020-01-18[AsmPrinter] Delete dead takeDeletedSymbsForFunction()Fangrui Song1-47/+2
The code added in r98579 is dead now.
2019-11-20[AIX] Lowering jump table, constant pool and block address in asmXiangling Liao1-1/+12
This patch lowering jump table, constant pool and block address in assembly. 1. On AIX, jump table index is always relative; 2. Put CPI and JTI into ReadOnlySection until we support unique data sections; 3. Create the temp symbol for block address symbol; 4. Update MIR testcases and add related assembly part; Differential Revision: https://reviews.llvm.org/D70243
2019-11-13Sink all InitializePasses.h includesReid Kleckner1-0/+1
This file lists every pass in LLVM, and is included by Pass.h, which is very popular. Every time we add, remove, or rename a pass in LLVM, it caused lots of recompilation. I found this fact by looking at this table, which is sorted by the number of times a file was changed over the last 100,000 git commits multiplied by the number of object files that depend on it in the current checkout: recompiles touches affected_files header 342380 95 3604 llvm/include/llvm/ADT/STLExtras.h 314730 234 1345 llvm/include/llvm/InitializePasses.h 307036 118 2602 llvm/include/llvm/ADT/APInt.h 213049 59 3611 llvm/include/llvm/Support/MathExtras.h 170422 47 3626 llvm/include/llvm/Support/Compiler.h 162225 45 3605 llvm/include/llvm/ADT/Optional.h 158319 63 2513 llvm/include/llvm/ADT/Triple.h 140322 39 3598 llvm/include/llvm/ADT/StringRef.h 137647 59 2333 llvm/include/llvm/Support/Error.h 131619 73 1803 llvm/include/llvm/Support/FileSystem.h Before this change, touching InitializePasses.h would cause 1345 files to recompile. After this change, touching it only causes 550 compiles in an incremental rebuild. Reviewers: bkramer, asbirlea, bollu, jdoerfert Differential Revision: https://reviews.llvm.org/D70211
2019-10-07Second attempt to add iterator_range::empty()Jordan Rose1-2/+2
Doing this makes MSVC complain that `empty(someRange)` could refer to either C++17's std::empty or LLVM's llvm::empty, which previously we avoided via SFINAE because std::empty is defined in terms of an empty member rather than begin and end. So, switch callers over to the new method as it is added. https://reviews.llvm.org/D68439 llvm-svn: 373935
2019-09-30[NewPM] Port MachineModuleInfo to the new pass manager.Yuanfang Chen1-23/+60
Existing clients are converted to use MachineModuleInfoWrapperPass. The new interface is for defining a new pass manager API in CodeGen. Reviewers: fedor.sergeev, philip.pfaffe, chandlerc, arsenm Reviewed By: arsenm, fedor.sergeev Differential Revision: https://reviews.llvm.org/D64183 llvm-svn: 373240
2019-08-09[CodeGen] Require a name for a block addr targetBill Wendling1-1/+1
Summary: A block address may be used in inline assembly. In which case it requires a name so that the asm parser has something to parse. Creating a name for every block address is a large hammer, but is necessary because at the point when a temp symbol is created we don't necessarily know if it's used in inline asm. This ensures that it exists regardless. Reviewers: nickdesaulniers, craig.topper Subscribers: nathanchance, javed.absar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65352 llvm-svn: 368478
2019-08-08[llvm-mc] Add reportWarning() to MCContextBrian Cain1-3/+3
Adding reportWarning() to MCContext, so that it can be used from the Hexagon assembler backend. llvm-svn: 368327
2019-05-29Qualify use of llvm::empty that's ambiguous with std::emptySam McCall1-1/+1
llvm-svn: 361968
2019-01-24Fix emission of _fltused for MSVC.James Y Knight1-20/+1
It should be emitted when any floating-point operations (including calls) are present in the object, not just when calls to printf/scanf with floating point args are made. The difference caused by this is very subtle: in static (/MT) builds, on x86-32, in a program that uses floating point but doesn't print it, the default x87 rounding mode may not be set properly upon initialization. This commit also removes the walk of the types pointed to by pointer arguments in calls. (To assist in opaque pointer types migration -- eventually the pointee type won't be available.) That latter implies that it will no longer consider a call like `scanf("%f", &floatvar)` as sufficient to emit _fltused on its own. And without _fltused, `scanf("%f")` will abort with error R6002. This new behavior is unlikely to bite anyone in practice (you'd have to read a float, and do nothing with it!), and also, is consistent with MSVC. Differential Revision: https://reviews.llvm.org/D56548 llvm-svn: 352076
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-11-05MachineModuleInfo: Store more specific reference to LLVMTargetMachine; NFCMatthias Braun1-1/+1
MachineModuleInfo can only be used in code using lib/CodeGen, hence we can keep a more specific reference to LLVMTargetMachine rather than just TargetMachine around. llvm-svn: 346182
2018-10-31MachineModuleInfo: Initialize DbgInfoAvailable depending on debug_cus existingMatthias Braun1-1/+2
Before this patch DbgInfoAvailable was set to true in DwarfDebug::beginModule() or CodeViewDebug::CodeViewDebug(). This made MIR testing weird since passes would suddenly stop dealing with debug info just because we stopped the pipeline before the debug printers. This patch changes the logic to initialize DbgInfoAvailable based on the fact that debug_compile_units exist in the llvm Module. The debug printers may then override it with false in case of debug printing being disabled. Differential Revision: https://reviews.llvm.org/D53885 llvm-svn: 345740
2018-07-30Remove trailing spaceFangrui Song1-2/+2
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
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
2017-12-15MachineFunction: Slight refactoring; NFCMatthias Braun1-1/+2
Slight cleanup/refactor in preparation for upcoming commit. llvm-svn: 320882
2017-12-13Remove redundant includes from lib/CodeGen.Michael Zolotukhin1-1/+0
llvm-svn: 320619
2017-11-17Fix a bunch more layering of CodeGen headers that are in TargetDavid Blaikie1-1/+1
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-09-27[CodeGen] Emit necessary .note sections for -fsplit-stackThan McIntosh1-0/+1
Summary: According to https://gcc.gnu.org/wiki/SplitStacks, the linker expects a zero-sized .note.GNU-split-stack section if split-stack is used (and also .note.GNU-no-split-stack section if it also contains non-split-stack functions), so it can handle the cases where a split-stack function calls non-split-stack function. This change adds the sections if needed. Fixes PR #34670. Reviewers: thanm, rnk, luqmana Reviewed By: rnk Subscribers: llvm-commits Patch by Cherry Zhang <cherryyz@google.com> Differential Revision: https://reviews.llvm.org/D38051 llvm-svn: 314335
2017-08-23Retire the llvm.dbg.mir hack after r311594.Adrian Prantl1-2/+0
llvm-svn: 311610