aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/WasmObjectWriter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-02-01[WebAssembly] Add codegen support for the import_field attributeDan Gohman1-10/+10
This adds the LLVM side of https://reviews.llvm.org/D57602 -- the import_field attribute. See that patch for details. Differential Revision: https://reviews.llvm.org/D57603 llvm-svn: 352931
2019-01-31[WebAssembly] MC: Fix for outputing wasm object to /dev/nullSam Clegg1-1/+7
Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D57479 llvm-svn: 352806
2019-01-30[WebAssembly] MC: Use WritePatchableLEB helper function. NFC.Sam Clegg1-33/+30
Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D57477 llvm-svn: 352683
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
2019-01-17[WebAssembly] Parse llvm.ident into producers sectionThomas Lively1-17/+30
llvm-svn: 351413
2019-01-17Revert "[WebAssembly] Parse llvm.ident into producers section"Thomas Lively1-30/+17
This reverts commit eccdbba3a02a33e13b5262e92200a33e2ead873d. llvm-svn: 351410
2019-01-16[WebAssembly] Parse llvm.ident into producers sectionThomas Lively1-17/+30
Summary: Everything before the word "version" is the tool, and everything after the word "version" is the version. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D56742 llvm-svn: 351399
2019-01-16[WebAssembly] Store section alignment as a power of 2Sam Clegg1-1/+1
This change bumps for version number of the wasm object file metadata. See https://github.com/WebAssembly/tool-conventions/pull/92 Differential Revision: https://reviews.llvm.org/D56758 llvm-svn: 351285
2019-01-08[WebAssembly] Massive instruction renamingThomas Lively1-1/+1
Summary: An automated renaming of all the instructions listed at https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329 as well as some similarly-named identifiers. Reviewers: aheejin, dschuff, aardappel Subscribers: sbc100, jgravelle-google, eraman, sunfish, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D56338 llvm-svn: 350609
2018-11-20[WebAssembly] Remove unused function return types (NFC)Heejin Ahn1-6/+4
Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54734 llvm-svn: 347277
2018-11-14[WebAssembly] Add support for the event sectionHeejin Ahn1-51/+140
Summary: This adds support for the 'event section' specified in the exception handling proposal. (This was named 'exception section' first, but later renamed to 'event section' to take possibilities of other kinds of events into consideration. But currently we only store exception info in this section.) The event section is added between the global section and the export section. This is for ease of validation per request of the V8 team. This patch: - Creates the event symbol type, which is a weak symbol - Makes 'throw' instruction take the event symbol '__cpp_exception' - Adds relocation support for events - Adds WasmObjectWriter / WasmObjectFile (Reader) support - Adds obj2yaml / yaml2obj support - Adds '.eventtype' printing support Reviewers: dschuff, sbc100, aardappel Subscribers: jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54096 llvm-svn: 346825
2018-11-02[WebAssembly] Change indices types to unsined int (NFC)Heejin Ahn1-4/+4
Summary: This changes int types to unsigned int in a few places: function indices and `wasm::Valtype` (which is unsigend int enum). Currently these values cannot have negative values anyway, so this should not be a functional change for now. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54044 llvm-svn: 346031
2018-10-25Reland "[WebAssembly] LSDA info generation"Heejin Ahn1-1/+3
Summary: This adds support for LSDA (exception table) generation for wasm EH. Wasm EH mostly follows the structure of Itanium-style exception tables, with one exception: a call site table entry in wasm EH corresponds to not a call site but a landing pad. In wasm EH, the VM is responsible for stack unwinding. After an exception occurs and the stack is unwound, the control flow is transferred to wasm 'catch' instruction by the VM, after which the personality function is called from the compiler-generated code. (Refer to WasmEHPrepare pass for more information on this part.) This patch: - Changes wasm.landingpad.index intrinsic to take a token argument, to make this 1:1 match with a catchpad instruction - Stores landingpad index info and catch type info MachineFunction in before instruction selection - Lowers wasm.lsda intrinsic to an MCSymbol pointing to the start of an exception table - Adds WasmException class with overridden methods for table generation - Adds support for LSDA section in Wasm object writer Reviewers: dschuff, sbc100, rnk Subscribers: mgorny, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D52748 llvm-svn: 345345
2018-10-16Revert "[WebAssembly] LSDA info generation"Krasimir Georgiev1-3/+1
This reverts commit r344575. Newly introduced test eh-lsda.ll.test fails with use-after-free under ASAN build. llvm-svn: 344639
2018-10-16[WebAssembly] LSDA info generationHeejin Ahn1-1/+3
Summary: This adds support for LSDA (exception table) generation for wasm EH. Wasm EH mostly follows the structure of Itanium-style exception tables, with one exception: a call site table entry in wasm EH corresponds to not a call site but a landing pad. In wasm EH, the VM is responsible for stack unwinding. After an exception occurs and the stack is unwound, the control flow is transferred to wasm 'catch' instruction by the VM, after which the personality function is called from the compiler-generated code. (Refer to WasmEHPrepare pass for more information on this part.) This patch: - Changes wasm.landingpad.index intrinsic to take a token argument, to make this 1:1 match with a catchpad instruction - Stores landingpad index info and catch type info MachineFunction in before instruction selection - Lowers wasm.lsda intrinsic to an MCSymbol pointing to the start of an exception table - Adds WasmException class with overridden methods for table generation - Adds support for LSDA section in Wasm object writer Reviewers: dschuff, sbc100, rnk Subscribers: mgorny, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D52748 llvm-svn: 344575
2018-10-03[WebAssembly] Refactor WasmSignature and use it for MCSymbolWasmDerek Schuff1-2/+5
MCContext does not destroy MCSymbols on shutdown. So, rather than putting SmallVectors (which may heap-allocate) inside MCSymbolWasm, use unowned pointer to a WasmSignature instead. The signatures are now owned by the AsmPrinter. Also uses WasmSignature instead of param and result vectors in TargetStreamer, and leaves some TODOs for further simplification. Differential Revision: https://reviews.llvm.org/D52580 llvm-svn: 343733
2018-09-05[WebAssembly] clang-format (NFC)Heejin Ahn1-35/+35
Summary: This patch runs clang-format on all wasm-only files. Reviewers: aardappel, dschuff, sunfish, tlively Subscribers: MatzeB, sbc100, jgravelle-google, llvm-commits Differential Revision: https://reviews.llvm.org/D51447 llvm-svn: 341439
2018-08-22[WebAssembly] Ensure relocation entries are ordered by offsetSam Clegg1-5/+17
wasm-lld expects relocation entries to be sorted by offset. In most cases llvm produces them in order, but the CODE section (which combines many MCSections) is an exception because we order the functions in Symbol order, not in section order. What is more, its not clear weather `recordRelocation` is guaranteed to be called in offset order so this sort of most likely needed in the general case too. Differential Revision: https://reviews.llvm.org/D51065 llvm-svn: 340423
2018-05-30[WebAssembly] MC: Add compile-twice test and fix corresponding bugSam Clegg1-1/+1
Differential Revision: https://reviews.llvm.org/D47398 llvm-svn: 333494
2018-05-21MC: Remove stream and output functions from MCObjectWriter. NFCI.Peter Collingbourne1-2/+1
Part of PR37466. Differential Revision: https://reviews.llvm.org/D47043 llvm-svn: 332864
2018-05-21MC: Have the object writers return the number of bytes written. NFCI.Peter Collingbourne1-3/+6
This removes the last external use of the stream. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47042 llvm-svn: 332863
2018-05-21MC: Change object writers to use endian::Writer. NFCI.Peter Collingbourne1-89/+90
Part of PR37466. Differential Revision: https://reviews.llvm.org/D47040 llvm-svn: 332861
2018-05-21MC: Change MCAssembler::writeSectionData and writeFragmentPadding to take a ↵Peter Collingbourne1-2/+2
raw_ostream. NFCI. Also clean up a couple of hacks where we were writing the section contents to another stream by setting the object writer's stream, writing and setting it back. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47038 llvm-svn: 332858
2018-05-18[MC] Relax .fill size requirementsNirav Dave1-3/+4
Avoid requirement that number of values must be known at assembler time. Fixes PR33586. Reviewers: rnk, peter.smith, echristo, jyknight Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D46703 llvm-svn: 332741
2018-05-17[WebAssembly] MC: Fix typo in commentSam Clegg1-1/+1
llvm-svn: 332632
2018-05-16[WebAssembly] MC: Ensure that FUNCTION_OFFSET relocations are always against ↵Sam Clegg1-1/+17
function symbols. The getAtom() method wasn't doing what we needed in all cases. We want the symbols for the function which defines that section. We can compute this easily enough and we know that we have at most one function in each section. Once this lands I will revert rL331412 which is no longer needed. Fixes PR37409 Differential Revision: https://reviews.llvm.org/D46970 llvm-svn: 332517
2018-05-14[WebAssembly] Move toString helpers to BinaryFormatSam Clegg1-27/+1
Subscribers: dschuff, mgorny, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D46847 llvm-svn: 332305
2018-05-14Rename DEBUG macro to LLVM_DEBUG.Nicola Zaghen1-29/+30
The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM - Manual change to APInt - Manually chage DOCS as regex doesn't match it. In the transition period the DEBUG() macro is still present and aliased to the LLVM_DEBUG() one. Differential Revision: https://reviews.llvm.org/D43624 llvm-svn: 332240
2018-05-10[WebAssembly] Create section start symbols automatically for all sectionsSam Clegg1-5/+16
These symbols only get included in the output symbols table if they are used in a relocation. This behaviour matches more closely the ELF object writer. Differential Revision: https://reviews.llvm.org/D46561 llvm-svn: 332005
2018-05-08[WebAssembly] MC: Use existing MCSymbol.Index field rather than inventing ↵Sam Clegg1-15/+11
extra mapping MCSymbol has getIndex/setIndex which are implementation defined and on other platforms are used to store the symbol table index. It makes sense to use this rather than invent a new mapping. Differential Revision: https://reviews.llvm.org/D46555 llvm-svn: 331705
2018-05-07[WebAssembly] Ensure all .debug_XXX section has proper symbol namesSam Clegg1-1/+5
Updated wasm section symbols names to match section name, and ensure all referenced sections will have a symbol (per DWARF spec v3, Figure 43) Patch by Yury Delendik! Differential Revision: https://reviews.llvm.org/D46543 llvm-svn: 331664
2018-05-02[WebAssembly] MC: Create and use first class section symbolsSam Clegg1-143/+105
Differential Revision: https://reviews.llvm.org/D46335 llvm-svn: 331413
2018-05-02Fix release build breakageSam Clegg1-0/+2
This function was added in rL331220 but wasn't testing in release configurations. llvm-svn: 331320
2018-05-01[MC] Add llvm_unreachable to toString to fix compile time warning.Florian Hahn1-2/+1
Without this change, GCC 7 raises the warning below: control reaches end of non-void function Reviewers: sbc100, andreadb Reviewed By: andreadb Differential Revision: https://reviews.llvm.org/D46304 llvm-svn: 331255
2018-05-01NFC, Avoid a warning in WasmObjectWriterGabor Buella1-0/+2
The warning was (introduced in r331220): lib/MC/WasmObjectWriter.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ llvm-svn: 331251
2018-04-30[WebAssembly] MC: Improve debug outputSam Clegg1-8/+33
llvm-svn: 331220
2018-04-30IWYU for llvm-config.h in llvm, additions.Nico Weber1-0/+1
See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
2018-04-27[WebAssembly] Section symbols must have local bindingSam Clegg1-1/+1
Summary: Also test for symbols information in test/MC/WebAssembly/debug-info.ll. Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D46160 llvm-svn: 331005
2018-04-26[WebAssembly] Write DWARF data into wasm object fileSam Clegg1-25/+164
- Writes ".debug_XXX" into corresponding custom sections. - Writes relocation records into "reloc.debug_XXX" sections. Patch by Yury Delendik! Differential Revision: https://reviews.llvm.org/D44184 llvm-svn: 330982
2018-04-26[WebAssembly] Add version to object file metadataSam Clegg1-1/+2
Summary: See https://github.com/WebAssembly/tool-conventions/issues/54 Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D46069 llvm-svn: 330969
2018-04-24[wasm] Fix uninitialized memory introduced in r330749.Chandler Carruth1-1/+1
Found with MSan. This was causing all the WASM MC tests to fail about 10% of the time. llvm-svn: 330764
2018-04-24[WebAssembly] Use section index in relocation section headerSam Clegg1-49/+31
Rather than referring to sections my their code, use the absolute index of the target section within the module. See https://github.com/WebAssembly/tool-conventions/issues/52 Differential Revision: https://reviews.llvm.org/D45980 llvm-svn: 330749
2018-04-23[WebAssembly] MC: Refactor section creation codeSam Clegg1-17/+14
Remove the use of default argument in favor of a separate startCustomSection method. Differential Revision: https://reviews.llvm.org/D45794 llvm-svn: 330632
2018-04-05[WebAssembly] Allow for the creation of user-defined custom sectionsSam Clegg1-1/+43
This patch adds a way for users to create their own custom sections to be added to wasm files. At the LLVM IR layer, they are defined through the "wasm.custom_sections" named metadata. The expected use case for this is bindings generators such as wasm-bindgen. Patch by Dan Gohman Differential Revision: https://reviews.llvm.org/D45297 llvm-svn: 329315
2018-03-09[WebAssembly] Disallow weak undefined globals in the object formatNicholas Wilson1-0/+3
This implements https://github.com/WebAssembly/tool-conventions/pull/47 Differential Revision: https://reviews.llvm.org/D44201 llvm-svn: 327146
2018-03-05[WebAssembly] Reorder reloc sections to come between symtab and nameNicholas Wilson1-1/+1
This is required in order to enable relocs to be validated as they are read in. Also update tests with new section ordering. Differential Revision: https://reviews.llvm.org/D43940 llvm-svn: 326694
2018-03-01[WebAssembly] Use uint8_t for single byte values to match the specSam Clegg1-9/+9
The original BinaryEncoding.md document used to specify that these values were `varint7`, but the official spec lists them explicitly as single byte values and not LEB. A similar change for wabt is in flight: https://github.com/WebAssembly/wabt/pull/782 Differential Revision: https://reviews.llvm.org/D43921 llvm-svn: 326454
2018-02-28[WebAssembly] Reorder symbol table to match MC orderNicholas Wilson1-41/+40
This removes a TODO introduced in rL325860 Differential Revision: https://reviews.llvm.org/D43685 llvm-svn: 326334
2018-02-27[WebAssembly] Remove DataSize from linking metadata sectionSam Clegg1-9/+3
Neither the linker nor the runtime need this information anymore. We were originally using this to model BSS size but the plan is now to use the segment metadata to allow for BSS segments. Differential Revision: https://reviews.llvm.org/D41366 llvm-svn: 326267
2018-02-23Simplify a DEBUG statement to remove a set but not used variable in release ↵Eric Christopher1-7/+4
builds. llvm-svn: 325959