aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCContext.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-01-26Revert "Emit swift5 reflection section data in dsym bundle generated by ↵Shubham Sandeep Rastogi1-4/+4
dsymutil in the Dwarf section." This reverts commit 50f50f2582993a079dbcfb8e7ba48920f41e6be0.
2022-01-26Emit swift5 reflection section data in dsym bundle generated by dsymutil in ↵Shubham Sandeep Rastogi1-4/+4
the Dwarf section. Add support for Swift reflection metadata to dsymutil. This patch adds support for copying Swift reflection metadata (__swift5_.* sections) from .o files to into the symbol-rich binary in the output .dSYM. The functionality is automatically enabled only if a .o file has reflection metadata sections and the binary doesn't. When copying dsymutil moves the section from the __TEXT segment to the __DWARF segment. rdar://76973336 Differential Revision: https://reviews.llvm.org/D115007
2022-01-21Revert "Emit swift5 reflection section data in dsym bundle generated by ↵Shubham Sandeep Rastogi1-4/+4
dsymutil in the Dwarf section." This reverts commit d84d1135d80c1dead6564347943ba56eed5aac3b. to investigate buildbot failures
2022-01-21Emit swift5 reflection section data in dsym bundle generated by dsymutil in ↵Shubham Sandeep Rastogi1-4/+4
the Dwarf section. Add support for Swift reflection metadata to dsymutil. This patch adds support for copying Swift reflection metadata (__swift5_.* sections) from .o files to into the symbol-rich binary in the output .dSYM. The functionality is automatically enabled only if a .o file has reflection metadata sections and the binary doesn't. When copying dsymutil moves the section from the __TEXT segment to the __DWARF segment. rdar://76973336 https://reviews.llvm.org/D115007
2022-01-15[MC] Remove MCContext::reportFatalErrorFangrui Song1-10/+0
As the 10-year-old FIXME comment says, this API is not recommended.
2021-07-27[SystemZ][z/OS] Initial code to generate assembly files on z/OSAnirudh Prasad1-1/+16
- This patch consists of the bare basic code needed in order to generate some assembly for the z/OS target. - Only the .text and the .bss sections are added for now. - The relevant MCSectionGOFF/Symbol interfaces have been added. This enables us to print out the GOFF machine code sections. - This patch enables us to add simple lit tests wherever possible, and contribute to the testing coverage for the z/OS target - Further improvements and additions will be made in future patches. Reviewed By: tmatheson Differential Revision: https://reviews.llvm.org/D106380
2021-07-08PR51018: Remove explicit conversions from SmallString to StringRef to ↵David Blaikie1-2/+2
future-proof against C++23 C++23 will make these conversions ambiguous - so fix them to make the codebase forward-compatible with C++23 (& a follow-up change I've made will make this ambiguous/invalid even in <C++23 so we don't regress this & it generally improves the code anyway)
2021-05-26[MC][ELF] Emit unique sections for different flagsTomas Matheson1-1/+1
Global values imply flags such as readable, writable, executable for the sections that they will be placed in. Currently MC places all such entries into the same section, using the first set of flags seen. This can lead to situations in LTO where a writable global is placed in the same named section as a readable global from another file, and the section may not be marked writable. D72194 ensures that mergeable globals with explicit sections are placed in separate sections with compatible entry size, by emitting the `unique` assembly syntax where appropriate. This change extends that approach to include section flags, so that globals with different section flags are emitted in separate unique sections. Differential revision: https://reviews.llvm.org/D100944
2021-05-23[MC] Refactor MCObjectFileInfo initialization and allow targets to create ↵Philipp Krones1-5/+5
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-10Reland: "[lld][WebAssembly] Initial support merging string data"Sam Clegg1-3/+5
This change was originally landed in: 5000a1b4b9edeb9e994f2a5b36da8d48599bea49 It was reverted in: 061e071d8c9b98526f35cad55a918a4f1615afd4 This change adds support for a new WASM_SEG_FLAG_STRINGS flag in the object format which works in a similar fashion to SHF_STRINGS in the ELF world. Unlike the ELF linker this support is currently limited: - No support for SHF_MERGE (non-string merging) - Always do full tail merging ("lo" can be merged with "hello") - Only support single byte strings (p2align 0) Like the ELF linker merging is only performed at `-O1` and above. This fixes part of https://bugs.llvm.org/show_bug.cgi?id=48828, although crucially it doesn't not currently support debug sections because they are not represented by data segments (they are custom sections) Differential Revision: https://reviews.llvm.org/D97657
2021-05-10Revert "[lld][WebAssembly] Initial support merging string data"Nico Weber1-5/+3
This reverts commit 5000a1b4b9edeb9e994f2a5b36da8d48599bea49. Breaks tests, see https://reviews.llvm.org/D97657#2749151 Easily repros locally with `ninja check-llvm-mc-webassembly`.
2021-05-10[lld][WebAssembly] Initial support merging string dataSam Clegg1-3/+5
This change adds support for a new WASM_SEG_FLAG_STRINGS flag in the object format which works in a similar fashion to SHF_STRINGS in the ELF world. Unlike the ELF linker this support is currently limited: - No support for SHF_MERGE (non-string merging) - Always do full tail merging ("lo" can be merged with "hello") - Only support single byte strings (p2align 0) Like the ELF linker merging is only performed at `-O1` and above. This fixes part of https://bugs.llvm.org/show_bug.cgi?id=48828, although crucially it doesn't not currently support debug sections because they are not represented by data segments (they are custom sections) Differential Revision: https://reviews.llvm.org/D97657
2021-05-05[MC] Untangle MCContext and MCObjectFileInfoPhilipp Krones1-17/+46
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-04[XCOFF][DebugInfo] support DWARF for XCOFF for assembly output.Chen Zheng1-13/+32
Reviewed By: jasonliu Differential Revision: https://reviews.llvm.org/D95518
2021-03-01Fix memleak for 5de2d189e6ad4Yuanfang Chen1-1/+1
Fix typo `release` -> `reset`
2021-03-01[Diagnose] Unify MCContext and LLVMContext diagnosingYuanfang Chen1-20/+70
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-18[WebAssembly] Fix assert in lookup of section symbolsWouter van Oortmerssen1-0/+1
Fixes assert in: https://bugs.llvm.org/show_bug.cgi?id=49036 getWasmSection creates sections if they don't exist, but doesn't add them to the Symbols table. This may cause problems in subsequent calls to getOrCreateSymbol which checks this table, the calls createSymbol assuming it doesn't exist, which then checks UsedNames and finds out it does exist, causing an assert on trying to rename a non-temp symbol. I tried also fixing the somewhat unintuitive forced suffixing (adding `0`), but it turns out that WasmObjectWriter currently assumes these section symbols are unique, so that may have to be a separate fix: https://bugs.llvm.org/show_bug.cgi?id=49252 Also worth noting is that getWasmSection calling createSymbol may not be correct to start with, given that createSymbol seems to assume it is creating non-section symbols. But again, for a future fix. Related: where some of this was introduced: https://github.com/llvm/llvm-project/commit/8d396acac3bc21f688ac707bb42e4698dbdcab7e Differential Revision: https://reviews.llvm.org/D96473
2021-02-17[XCOFF][NFC] make csect properties optional for getXCOFFSectionChen Zheng1-8/+11
We are going to support debug sections for XCOFF. So the csect properties are not necessary. This patch makes these properties optional. Reviewed By: hubert.reinterpretcast Differential Revision: https://reviews.llvm.org/D95931
2021-02-16[MC][ELF] Support for zero flag section groupsPetr Hosek1-12/+16
This change introduces support for zero flag ELF section groups to LLVM. LLVM already supports COMDAT sections, which in ELF are a special type of ELF section groups. These are generally useful to enable linker GC where you want a group of sections to always travel together, that is to be either retained or discarded as a whole, but without the COMDAT semantics. Other ELF assemblers already support zero flag ELF section groups and this change helps us reach feature parity. Differential Revision: https://reviews.llvm.org/D95851
2020-12-21[MC] Split MCContext::createTempSymbol, default AlwaysAddSuffix to true, and ↵Fangrui Song1-6/+13
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-12-20MCContext::reportError: don't call report_fatal_errorFangrui Song1-2/+2
Errors from MCAssembler, MCObjectStreamer and *ObjectWriter typically cause a crash: ``` % cat c.c int bar; extern int foo __attribute__((alias("bar"))); % clang -c -fcommon c.c fatal error: error in backend: Common symbol 'bar' cannot be used in assignment expr PLEASE submit a bug report to ... Stack dump: ... ``` `LLVMTargetMachine::addPassesToEmitFile` constructs `MachineModuleInfoWrapperPass` which creates a MCContext without SourceMgr. `MCContext::reportError` calls `report_fatal_error` which gets captured by Clang `LLVMErrorHandler` and gets translated to the output above. Since `MCContext::reportError` errors indicate user errors, such a crashing style error is inappropriate. So this patch changes `report_fatal_error` to `SourceMgr().PrintMessage`. ``` % clang -c -fcommon c.c <unknown>:0: error: Common symbol 'bar' cannot be used in assignment expr ``` Ideally we should at least recover the original filename (the line information is generally lost). That requires general improvement to MC diagnostics, because currently in many cases SMLoc information is lost.
2020-12-07[WebAssembly] Add Object and ObjectWriter support for wasm COMDAT sectionsDerek Schuff1-1/+1
Allow sections to be placed into COMDAT groups, in addtion to functions and data segments. Also make section symbols unnamed, which allows sections with identical names (section names are independent of their section symbols, but previously we gave the symbols the same name as their sections, which results in collisions when sections are identically-named). Differential Revision: https://reviews.llvm.org/D92691
2020-11-09[XCOFF] Enable explicit sections on AIXjasonliu1-8/+12
Implement mechanism to allow explicit sections to be generated on AIX. Reviewed By: DiggerLin Differential Revision: https://reviews.llvm.org/D88615
2020-08-11[AIX][XCOFF] change the operand of branch instruction from symbol name to ↵diggerlin1-3/+2
qualified symbol name for function declarations SUMMARY: 1. in the patch , remove setting storageclass in function .getXCOFFSection and construct function of class MCSectionXCOFF there are XCOFF::StorageMappingClass MappingClass; XCOFF::SymbolType Type; XCOFF::StorageClass StorageClass; in the MCSectionXCOFF class, these attribute only used in the XCOFFObjectWriter, (asm path do not need the StorageClass) we need get the value of StorageClass, Type,MappingClass before we invoke the getXCOFFSection every time. actually , we can get the StorageClass of the MCSectionXCOFF from it's delegated symbol. 2. we also change the oprand of branch instruction from symbol name to qualify symbol name. for example change bl .foo extern .foo to bl .foo[PR] extern .foo[PR] 3. and if there is reference indirect call a function bar. we also add extern .bar[PR] Reviewers: Jason liu, Xiangling Liao Differential Revision: https://reviews.llvm.org/D84765
2020-08-03[MC] Fix memory leak when allocating MCInst with bump allocatorhgreving1-0/+9
Adds the function createMCInst() to MCContext that creates a MCInst using a typed bump alloctor. MCInst contains a SmallVector<MCOperand, 8>. The SmallVector is POD only for <= 8 operands. The default untyped bump pointer allocator of MCContext does not delete the MCInst, so if the SmallVector grows, it's a leak. This fixes https://bugs.llvm.org/show_bug.cgi?id=46900.
2020-07-06[XCOFF][AIX] Give symbol an internal name when desired symbol name contains ↵jasonliu1-5/+63
invalid character(s) Summary: When a desired symbol name contains invalid character that the system assembler could not process, we need to emit .rename directive in assembly path in order for that desired symbol name to appear in the symbol table. Reviewed By: hubert.reinterpretcast, DiggerLin, daltenty, Xiangling_L Differential Revision: https://reviews.llvm.org/D82481
2020-05-13[Clang] Restore replace_path_prefix instead of startswithSylvain Audi1-5/+9
In D49466, sys::path::replace_path_prefix was used instead startswith for -f[macro/debug/file]-prefix-map options. However those were reverted later (commit rG3bb24bf25767ef5bbcef958b484e7a06d8689204) due to broken Windows tests. This patch restores those replace_path_prefix calls. It also modifies the prefix matching to be case-insensitive under Windows. Differential Revision : https://reviews.llvm.org/D76869
2020-04-16[MC][ELF] Put explicit section name symbols into entry size compatible sectionsbd1976llvm1-0/+41
Ensure that symbols explicitly* assigned a section name are placed into a section with a compatible entry size. This is done by creating multiple sections with the same name** if incompatible symbols are explicitly given the name of an incompatible section, whilst: - Avoiding using uniqued sections where possible (for readability and to maximize compatibly with assemblers). - Creating as few SHF_MERGE sections as possible (for efficiency). Given that each symbol is assigned to a section in a single pass, we must decide which section each symbol is assigned to without seeing the properties of all symbols. A stable and easy to understand assignment is desirable. The following rules facilitate this: The "generic" section for a given section name will be mergeable if the name is a mergeable "default" section name (such as .debug_str), a mergeable "implicit" section name (such as .rodata.str2.2), or MC has already created a mergeable "generic" section for the given section name (e.g. in response to a section directive in inline assembly). Otherwise, the "generic" section for a given name is non-mergeable; and, non-mergeable symbols are assigned to the "generic" section, while mergeable symbols are assigned to uniqued sections. Terminology: "default" sections are those always created by MC initially, e.g. .text or .debug_str. "implicit" sections are those created normally by MC in response to the symbols that it encounters, i.e. in the absence of an explicit section name assignment on the symbol, e.g. a function foo might be placed into a .text.foo section. "generic" sections are those that are referred to when a unique section ID is not supplied, e.g. if there are multiple unique .bob sections then ".quad .bob" will reference the generic .bob section. Typically, the generic section is just the first section of a given name to be created. Default sections are always generic. * Typically, section names might be explicitly assigned in source code using a language extension e.g. a section attribute: _attribute_ ((section ("section-name"))) - https://clang.llvm.org/docs/AttributeReference.html ** I refer to such sections as unique/uniqued sections. In assembly the ", unique," assembly syntax is used to express such sections. Fixes https://bugs.llvm.org/show_bug.cgi?id=43457. See https://reviews.llvm.org/D68101 for previous discussions leading to this patch. Some minor fixes were required to LLVM's tests, for tests had been using the old behavior - which allowed for explicitly assigning globals with incompatible entry sizes to a section. This fix relies on the ",unique ," assembly feature. This feature is not available until bintuils version 2.35 (https://sourceware.org/bugzilla/show_bug.cgi?id=25380). If the integrated assembler is not being used then we avoid using this feature for compatibility and instead try to place mergeable symbols into non-mergeable sections or issue an error otherwise. Differential Revision: https://reviews.llvm.org/D72194
2020-04-15[MC] Replace MCSection*::getName() with MCSection::getName(). NFCFangrui Song1-9/+11
I plan to use MCSection::getName() in D78138. Having the function in the base class is also convenient for debugging. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D78251
2020-04-15[MC] Rename MCSection*::getSectionName() to getName(). NFCFangrui Song1-5/+5
A pending change will merge MCSection*::getName() to MCSection::getName().
2020-04-07[WebAssembly][MC] Fix leak of std::string members in MCSymbolWasmSam Clegg1-0/+10
Summary: Fixes: https://bugs.llvm.org/show_bug.cgi?id=45452 Subscribers: dschuff, jgravelle-google, hiraditya, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77627
2020-02-25[MC][ARM] Don't create multiple .ARM.exidx associated to one .textFangrui Song1-0/+1
Fixed an issue exposed by D74006. In clang cc1as, MCContext::UseNamesOnTempLabels is true. When parsing a .fnstart directive, FnStart gets redefined to a temporary symbol of a different name (.Ltmp0, .Ltmp1, ...). MCContext::getELFSection() called by SwitchToEHSection() will create a different .ARM.exidx each time. llvm-mc uses `Ctx.setUseNamesOnTempLabels(false);` and FnStart is unnamed. MCContext::getELFSection() called by SwitchToEHSection() will reuse the same .ARM.exidx . Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D75095
2020-02-14[MC] Add MCSection::NonUniqueID and delete one MCContext::getELFSection overloadFangrui Song1-2/+2
2020-02-14[MC][ELF] Make linked-to symbol name part of ELFSectionKeyFangrui Song1-6/+10
https://bugs.llvm.org/show_bug.cgi?id=44775 This rule has been implemented by GNU as https://sourceware.org/ml/binutils/2020-02/msg00028.html (binutils >= 2.35) It allows us to simplify ``` .section .foo,"o",foo,unique,0 .section .foo,"o",bar,unique,1 # different section ``` to ``` .section .foo,"o",foo .section .foo,"o",bar # different section ``` We consider the two `.foo` different even if the linked-to symbols foo and bar are defined in the same section. This is a deliberate choice so that we don't need to know the section where foo and bar are defined beforehand. Differential Revision: https://reviews.llvm.org/D74006
2020-02-14[MC] De-capitalize some MCStreamer::Emit* functionsFangrui Song1-1/+1
2020-02-06[MC][ELF] Rename MC related "Associated" to "LinkedToSym"Fangrui Song1-7/+8
"linked-to section" is used by the ELF spec. By analogy, "linked-to symbol" is a good name for the signature symbol. The word "linked-to" implies a directed edge and makes it clear its relation with "sh_link", while one can argue that "associated" means an undirected edge. Also, combine tests and add precise SMLoc to improve diagnostics. Reviewed By: eugenis, grimar, jhenderson Differential Revision: https://reviews.llvm.org/D74082
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-3/+3
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-11-08[XCOFF][AIX] Differentiate usage of label symbol and csect symbolJason Liu1-2/+5
Summary: We are using symbols to represent label and csect interchangeably before, and that could be a problem. There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect. This patch intend to do the following: 1. Construct a QualName (A name include the storage mapping class) MCSymbolXCOFF for every MCSectionXCOFF. 2. Keep a pointer to that QualName inside of MCSectionXCOFF. 3. Use that QualName whenever we need a symbol refers to that MCSectionXCOFF. 4. Adapt the snowball effect from the above changes in XCOFFObjectWriter.cpp. Reviewers: xingxue, DiggerLin, sfertile, daltenty, hubert.reinterpretcast Reviewed By: DiggerLin, daltenty Subscribers: wuzish, nemanjai, mgorny, hiraditya, kbarton, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69633
2019-08-20Adds support for writing the .bss section for XCOFF object files.Sean Fertile1-1/+2
Adds Wrapper classes for MCSymbol and MCSection into the XCOFF target object writer. Also adds a class to represent the top-level sections, which we materialize in the ObjectWriter. executePostLayoutBinding will map all csects into the appropriate container depending on its storage mapping class, and map all symbols into their containing csect. Once all symbols have been processed we - Assign addresses and symbol table indices. - Calaculte section sizes. - Build the section header table. - Assign the sections raw-pointer value for non-virtual sections. Since the .bss section is virtual, writing the header table is enough to add support. Writing of a sections raw data, or of any relocations is not included in this patch. Testing is done by dumping the section header table, but it needs to be extended to include dumping the symbol table once readobj support for dumping auxiallary entries lands. Differential Revision: https://reviews.llvm.org/D65159 llvm-svn: 369454
2019-08-09[MC] Don't recreate a label if it's already usedBill Wendling1-0/+6
Summary: This patch keeps track of MCSymbols created for blocks that were referenced in inline asm. It prevents creating a new symbol which doesn't refer to the block. Inline asm may have a reference to a label. The asm parser however doesn't recognize it as a label and tries to create a new symbol. The result being that instead of the original symbol (e.g. ".Ltmp0") the parser replaces it in the inline asm with the new one (e.g. ".Ltmp00") without updating it in the symbol table. So the machine basic block retains the "old" symbol (".Ltmp0"), but the inline asm uses the new one (".Ltmp00"). Reviewers: nickdesaulniers, craig.topper Subscribers: nathanchance, javed.absar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65304 llvm-svn: 368477
2019-08-08[llvm-mc] Add reportWarning() to MCContextBrian Cain1-2/+17
Adding reportWarning() to MCContext, so that it can be used from the Hexagon assembler backend. llvm-svn: 368327
2019-07-22Stubs out TLOF for AIX and add support for common vars in assembly output.Sean Fertile1-1/+2
Stubs out a TargetLoweringObjectFileXCOFF class, implementing only SelectSectionForGlobal for common symbols. Also adds an override of EmitGlobalVariable in PPCAIXAsmPrinter which adds a number of defensive errors and adds support for emitting common globals. llvm-svn: 366727
2019-07-09Boilerplate for producing XCOFF object files from the PowerPC backend.Sean Fertile1-0/+35
Stubs out a number of the classes needed to produce a new object file format (XCOFF) for the powerpc-aix target. For testing input is an empty module which produces an object file with just a file header. Differential Revision: https://reviews.llvm.org/D61694 llvm-svn: 365541
2019-06-18MCContext: Delete unused functionsFangrui Song1-8/+0
llvm-svn: 363674
2019-06-06[AIX] Implement function descriptor on SDAGJason Liu1-2/+2
Summary: (1) Function descriptor on AIX On AIX, a called routine may have 2 distinct symbols associated with it: * A function descriptor (Name) * A function entry point (.Name) The descriptor structure on AIX is the same as those in the ELF V1 ABI: * The address of the entry point of the function. * The TOC base address for the function. * The environment pointer. The descriptor symbol uses the same name as the source level function in C. The function entry point is analogous to the symbol we would generate for a function in a non-descriptor-based ABI, except that it is renamed by prepending a ".". Which symbol gets referenced depends on the context: * Taking the address of the function references the descriptor symbol. * Calling the function references the entry point symbol. (2) Speaking of implementation on AIX, for direct function call target, we create proper MCSymbol SDNode(e.g . ".foo") while constructing SDAG to replace original TargetGlobalAddress SDNode. Then down the path, we can take advantage of this MCSymbol. Patch by: Xiangling_L Reviewed by: sfertile, hubert.reinterpretcast, jasonliu, syzaara Differential Revision: https://reviews.llvm.org/D62532 llvm-svn: 362735
2019-05-21[DebugInfo] Handle -main-file-name correctly for asm source.Paul Robinson1-4/+15
This option provides only the base filename, not a full relative path. Part of the fix for PR41839. Differential Revision: https://reviews.llvm.org/D62071 llvm-svn: 361245
2019-04-19[llvm] Prevent duplicate files in debug line header in dwarf 5: another attemptAli Tamur1-2/+3
Another attempt to land the changes in debug line header to prevent duplicate files in Dwarf 5. I rolled back my previous commit because of a mistake in generating the object file in a test. Meanwhile, I addressed some offline comments and changed the implementation; the largest difference is that MCDwarfLineTableHeader does not keep DwarfVersion but gets it as a parameter. I also merged the patch to fix two lld tests that will strt to fail into this patch. Original Commit: https://reviews.llvm.org/D59515 Original Message: Motivation: In previous dwarf versions, file name indexes started from 1, and the primary source file was not explicit. Dwarf 5 standard (6.2.4) prescribes the primary source file to be explicitly given an entry with an index number 0. The current implementation honors the specification by just duplicating the main source file, once with index number 0, and later maybe with another index number. While this is compliant with the letter of the standard, the duplication causes problems for consumers of this information such as lldb. (Some files are duplicated, where only some of them have a line table although all refer to the same file) With this change, dwarf 5 debug line section files always start from 0, and the zeroth entry is not duplicated whenever possible. This requires different handling of dwarf 4 and dwarf 5 during generation (e.g. when a function returns an index zero for a file name, it signals an error in dwarf 4, but not in dwarf 5) However, I think the minor complication is worth it, because it enables all consumers (lldb, gdb, dwarfdump, objdump, and so on) to treat all files in the file name list homogenously. llvm-svn: 358732
2019-04-04NFC: Move API uses of MD5::MD5Result to Optional rather than a pointer.Eric Christopher1-4/+5
Differential Revision: https://reviews.llvm.org/D60290 llvm-svn: 357736
2019-03-26Revert "[llvm] Reapply "Prevent duplicate files in debug line header in ↵Ali Tamur1-3/+2
dwarf 5."" This reverts commit rL357020. The commit broke the test llvm/test/tools/llvm-objdump/embedded-source.test on some builds including clang-ppc64be-linux-multistage, clang-s390x-linux, clang-with-lto-ubuntu, clang-x64-windows-msvc, llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast (and others). llvm-svn: 357026
2019-03-26[llvm] Reapply "Prevent duplicate files in debug line header in dwarf 5."Ali Tamur1-2/+3
Reapply rL356941 after regenerating the object file in the failing test llvm/test/tools/llvm-objdump/embedded-source.test from source. Original commit message: [llvm] Prevent duplicate files in debug line header in dwarf 5. Motivation: In previous dwarf versions, file name indexes started from 1, and the primary source file was not explicit. Dwarf 5 standard (6.2.4) prescribes the primary source file to be explicitly given an entry with an index number 0. The current implementation honors the specification by just duplicating the main source file, once with index number 0, and later maybe with another index number. While this is compliant with the letter of the standard, the duplication causes problems for consumers of this information such as lldb. (Some files are duplicated, where only some of them have a line table although all refer to the same file) With this change, dwarf 5 debug line section files always start from 0, and the zeroth entry is not duplicated whenever possible. This requires different handling of dwarf 4 and dwarf 5 during generation (e.g. when a function returns an index zero for a file name, it signals an error in dwarf 4, but not in dwarf 5) However, I think the minor complication is worth it, because it enables all consumers (lldb, gdb, dwarfdump, objdump, and so on) to treat all files in the file name list homogenously. Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D59515 llvm-svn: 357018