summaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/WebAssembly/userstack.ll
AgeCommit message (Collapse)Author
2024-02-05[CodeGen] Convert tests to opaque pointers (NFC)Nikita Popov
2023-10-03[WebAssembly] Define local sp if `llvm.stacksave` is used (#68133)Yuta Saito
Usually `llvm.stacksave/stackrestore` are used together with `alloca` but they can appear without it (e.g. `alloca` can be optimized away). WebAssembly's function local physical user sp register, which is referenced by `llvm.stacksave` is created while frame lowering and replaced with virtual register. However the sp register was not created when `llvm.stacksave` is used without `alloca`, and it led MIR verification failure about use-before-def of sp virtual register. Resolves https://github.com/llvm/llvm-project/issues/62235
2023-08-03[PEI][WebAssembly] Switch to backwards frame index eliminationJay Foad
Backwards frame index elimination uses backwards register scavenging, which is preferred because it does not rely on accurate kill flags. Differential Revision: https://reviews.llvm.org/D156691
2023-01-26[NFC][WebAssembly] Updated testsSamuel Parker
Run update_llc_test_checks on a number of codegen tests.
2022-12-19[WebAssembly] Convert some tests to opaque pointers (NFC)Nikita Popov
2021-07-09[WebAssembly] Added initial type checker to MC AssemblerWouter van Oortmerssen
This to protect against non-sensical instruction sequences being assembled, which would either cause asserts/crashes further down, or a Wasm module being output that doesn't validate. Unlike a validator, this type checker is able to give type-errors as part of the parsing process, which makes the assembler much friendlier to be used by humans writing manual input. Because the MC system is single pass (instructions aren't even stored in MC format, they are directly output) the type checker has to be single pass as well, which means that from now on .globaltype and .functype decls must come before their use. An extra pass is added to Codegen to collect information for this purpose, since AsmPrinter is normally single pass / streaming as well, and would otherwise generate this information on the fly. A `-no-type-check` flag was added to llvm-mc (and any other tools that take asm input) that surpresses type errors, as a quick escape hatch for tests that were not intended to be type correct. This is a first version of the type checker that ignores control flow, i.e. it checks that types are correct along the linear path, but not the branch path. This will still catch most errors. Branch checking could be added in the future. Differential Revision: https://reviews.llvm.org/D104945
2020-11-03[WebAssembly] Don't fold frame offset for global addressesJulien Jorge
When machine instructions are in the form of ``` %0 = CONST_I32 @str %1 = ADD_I32 %stack.0, %0 %2 = LOAD 0, 0, %1 ``` In the `ADD_I32` instruction, it is possible to fold it if `%0` is a `CONST_I32` from an immediate number. But in this case it is a global address, so we shouldn't do that. But we haven't checked if the operand of `ADD` is an immediate so far. This fixes the problem. (The case applies the same for `ADD_I64` and `CONST_I64` instructions.) Fixes https://bugs.llvm.org/show_bug.cgi?id=47944. Patch by Julien Jorge (jjorge@quarkslab.com) Reviewed By: dschuff Differential Revision: https://reviews.llvm.org/D90577
2020-06-25[WebAssembly] Adding 64-bit versions of __stack_pointer and other globalsWouter van Oortmerssen
We have 6 globals, all of which except for __table_base are 64-bit under wasm64. Differential Revision: https://reviews.llvm.org/D82130
2019-02-23[WebAssembly] Update CodeGen test expectations after rL354697. NFCSam Clegg
llvm-svn: 354705
2019-01-08[WebAssembly] Massive instruction renamingThomas Lively
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-19[WebAssembly] replaced .param/.result by .functypeWouter van Oortmerssen
Summary: This makes it easier/cleaner to generate a single signature from this directive. Also: - Adds the symbol name, such that we don't depend on the location of this directive anymore. - Actually constructs the signature in the assembler, and make the assembler own it. - Refactor the use of MVT vs ValType in the streamer and assembler to require less conversions overall. - Changed 700 or so tests to use it. Reviewers: sbc100, dschuff Subscribers: jgravelle-google, eraman, aheejin, sunfish, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D54652 llvm-svn: 347228
2018-11-02[WebAssembly] Added a .globaltype directive to .s output.Wouter van Oortmerssen
Summary: Assembly output can use globals like __stack_pointer implicitly, but has no way of indicating the type of such a global, which makes it hard for tools processing it (such as the MC Assembler) to reconstruct this information. The improved assembler directives parsing (in progress in https://reviews.llvm.org/D53842) will make use of this information. Also deleted code for the .import_global directive which was unused. New test case in userstack.ll Reviewers: dschuff, sbc100 Subscribers: jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54012 llvm-svn: 345917
2018-08-27[WebAssembly] Added default stack-only instruction mode for MC.Wouter van Oortmerssen
Summary: Made it convert from register to stack based instructions, and removed the registers. Fixes to related code that was expecting register based instructions. Added the correct testing flag to all tests, depending on what the format they were expecting so far. Translated one test to stack format as example: reg-stackify-stack.ll tested: llvm-lit -v `find test -name WebAssembly` unittests/MC/* Reviewers: dschuff, sunfish Subscribers: sbc100, jgravelle-google, eraman, aheejin, llvm-commits, jfb Differential Revision: https://reviews.llvm.org/D51241 llvm-svn: 340750
2018-08-13Revert "[WebAssembly] Added default stack-only instruction mode for MC."Wouter van Oortmerssen
This reverts commit 917a99b71ce21c975be7bfbf66f4040f965d9f3c. llvm-svn: 339630
2018-08-10[WebAssembly] Added default stack-only instruction mode for MC.Wouter van Oortmerssen
Summary: Moved Explicit Locals pass to last. Made that pass obligatory. Made it convert from register to stack based instructions, and removed the registers. Fixes to related code that was expecting register based instructions. Added the correct testing flag to all tests, depending on what the format they were expecting so far. Translated one test to stack format as example: reg-stackify-stack.ll tested: llvm-lit -v `find test -name WebAssembly` unittests/MC/* Reviewers: dschuff, sunfish Subscribers: jfb, llvm-commits, aheejin, eraman, jgravelle-google, sbc100 Differential Revision: https://reviews.llvm.org/D50568 llvm-svn: 339474
2018-08-03[WebAssembly] Cleanup of the way globals and global flags are handledNicholas Wilson
Differential Revision: https://reviews.llvm.org/D44030 llvm-svn: 338894
2018-07-27Revert "[WebAssembly] Added default stack-only instruction mode for MC."Wouter van Oortmerssen
This reverts commit d3c9af4179eae7793d1487d652e2d4e23844555f. (SVN revision 338164) llvm-svn: 338176
2018-07-27[WebAssembly] Added default stack-only instruction mode for MC.Wouter van Oortmerssen
Summary: Moved Explicit Locals pass to last. Made that pass obligatory. Made it convert from register to stack based instructions, and removed the registers. Fixes to related code that was expecting register based instructions. Added the correct testing flag to all tests, depending on what the format they were expecting so far. Translated one test to stack format as example: reg-stackify-stack.ll tested: llvm-lit -v `find test -name WebAssembly` unittests/MC/* Reviewers: dschuff, sunfish Subscribers: sbc100, jgravelle-google, eraman, aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D49160 llvm-svn: 338164
2018-05-10[WebAsembly] Update default triple in test files to wasm32-unknown-unkown.Sam Clegg
Summary: The final -wasm component has been the default for some time now. Subscribers: jfb, dschuff, jgravelle-google, eraman, aheejin, JDevlieghere, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D46342 llvm-svn: 332007
2017-07-19Revert r308273 to reinstate part of r308100.Chandler Carruth
That part was reverted because the underlying change necessitating it (r308025) was reverted in r308271. Nirav re-landed r308025 again in r308350, so re-landing this fix. llvm-svn: 308418
2017-07-18Revert part of r308100 since the cause (r308025) was also reverted.Chandler Carruth
The commit r308100 updated WebAssembly tests for r308025. In one case it merely made the test more resilient but in another case it made a substantive update. Because r308025 was reverted in r308271, these changes to the test also need to be reverted. They should be folded into the recommit of r308025 when it is ready. llvm-svn: 308273
2017-07-15[wasm] Update two tests for r308025 which causes scheduling changes dueChandler Carruth
to the newly improved AA information. llvm-svn: 308100
2017-06-16[WebAssembly] Use __stack_pointer global when writing wasm binarySam Clegg
This ensures that symbolic relocations are generated for stack pointer manipulations. These relocations are of type R_WEBASSEMBLY_GLOBAL_INDEX_LEB. This change also adds support for reading relocations of this type in WasmObjectFile.cpp. Since its a globally imported symbol this does mean that the get_global/set_global instruction won't be valid until the objects are linked that global used in no longer an imported global. Differential Revision: https://reviews.llvm.org/D34172 llvm-svn: 305616
2017-02-28[WebAssembly] Convert the remaining unit tests to the new wasm-object-file ↵Dan Gohman
target. To facilitate this, add a new hidden command-line option to disable the explicit-locals pass. That causes llc to emit invalid code that doesn't have all locals converted to get_local/set_local, however it simplifies testwriting in many cases. llvm-svn: 296540
2016-10-06[WebAssembly] Remove the output operand from stores.Dan Gohman
Per spec changes, store instructions in WebAssembly no longer have a return value. Update the instruction descriptions. Differential Revision: https://reviews.llvm.org/D25122 llvm-svn: 283501
2016-09-30[WebAssembly] Make register stackification more conservativeDerek Schuff
Register stackification currently checks VNInfo for changes. Make that more accurate by testing each intervening instruction for any other defs to the same virtual register. Patch by Jacob Gravelle Differential Revision: https://reviews.llvm.org/D24942 llvm-svn: 282886
2016-09-26[WebAssembly] Use the frame pointer instead of the stack pointerDerek Schuff
When we have dynamic allocas we have a frame pointer, and when we're lowering frame indexes we should make sure we use it. Patch by Jacob Gravelle Differential Revision: https://reviews.llvm.org/D24889 llvm-svn: 282442
2016-08-18[WebAssembly] Disable the store-results optimization.Dan Gohman
The WebAssemly spec removing the return value from store instructions, so remove the associated optimization from LLVM. This patch leaves the store instruction operands in place for now, so stores now always write to "$drop"; these will be removed in a seperate patch. llvm-svn: 279100
2016-05-24[WebAssembly] Put __stack_pointer in the offset field of loads and stores.Dan Gohman
Instead of this: i32.const $push10=, __stack_pointer i32.load $push11=, 0($pop10) Emit this: i32.const $push10=, 0 i32.load $push11=, __stack_pointer($pop10) It's not currently clear which is better, though there's a chance the second form may be better at overall compression. We can revisit this when we have more data; for now it makes sense to make PEI consistent with isel. Differential Revision: http://reviews.llvm.org/D20411 llvm-svn: 270635
2016-05-21[WebAssembly] Optimize away return instructions using fallthroughs.Dan Gohman
This saves a small amount of code size, and is a first small step toward passing values on the stack across block boundaries. Differential Review: http://reviews.llvm.org/D20450 llvm-svn: 270294
2016-05-19[WebAssembly] Make several CHECK lines less fragile using regexes and CHECK-DAG.Dan Gohman
llvm-svn: 270011
2016-05-17[WebAssembly] Rename $discard to $drop in the assembly output.Dan Gohman
llvm-svn: 269862
2016-05-17[WebAssembly] Model the stack evaluation order more precisely.Dan Gohman
We currently don't represent get_local and set_local explicitly; they are just implied by virtual register use and def. This avoids a lot of clutter, but it does complicate stackifying: get_locals read their operands at their position in the stack evaluation order, rather than at their parent instruction. This patch adds code to walk the stack to determine the precise ordering, when needed. llvm-svn: 269854
2016-05-16[WebAssembly] Mark COPY_LOCAL and TEE_LOCAL instructions has having no side ↵Dan Gohman
effects. llvm-svn: 269683
2016-05-10[WebAssembly] Preliminary fast-isel support.Dan Gohman
llvm-svn: 269083
2016-05-10[WebAssembly] Move register stackification and coloring to a late phase.Dan Gohman
Move the register stackification and coloring passes to run very late, after PEI, tail duplication, and most other passes. This means that all code emitted and expanded by those passes is now exposed to these passes. This also eliminates the need for prologue/epilogue code to be manually stackified, which significantly simplifies the code. This does require running LiveIntervals a second time. It's useful to think of these late passes not as late optimization passes, but as a domain-specific compression algorithm based on knowledge of liveness information. It's used to compress the code after all conventional optimizations are complete, which is why it uses LiveIntervals at a phase when actual optimization passes don't typically need it. Differential Revision: http://reviews.llvm.org/D20075 llvm-svn: 269012
2016-03-17[WebAssembly] Stackify code emitted by eliminateFrameIndex and SP writebackDerek Schuff
Summary: MRI::eliminateFrameIndex can emit several instructions to do address calculations; these can usually be stackified. Because instructions with FI operands can have subsequent operands which may be expression trees, find the top of the leftmost tree and insert the code before it, to keep the LIFO property. Also use stackified registers when writing back the SP value to memory in the epilog; it's unnecessary because SP will not be used after the epilog, and it results in better code. Differential Revision: http://reviews.llvm.org/D18234 llvm-svn: 263725
2016-02-23Revert "[WebAssembly] Stackify code emitted by eliminateFrameIndex"Derek Schuff
This reverts r261685 due to wasm test breakage. llvm-svn: 261702
2016-02-23[WebAssembly] Stackify code emitted by eliminateFrameIndexDerek Schuff
llvm-svn: 261685
2016-02-23[WebAssembly] Implement red zone for user stackDerek Schuff
Implements a mostly-conventional redzone for the userspace stack. Because we have unsigned load/store offsets we continue to use a local SP subtracted from the incoming SP but do not write it back to memory. Differential Revision: http://reviews.llvm.org/D17525 llvm-svn: 261662
2016-02-22[WebAssembly] Fix writeback of stack pointer with dynamic allocaDerek Schuff
Previously the stack pointer was only written back to memory in the prolog. But this is wrong for dynamic allocas, for which target-independent codegen handles SP updates after the prolog (and possibly even in another BB). Instead update the SP global in ADJCALLSTACKDOWN which is generated after the SP update sequence. This will have further refinements when we add red zone support. llvm-svn: 261579
2016-02-21[WebAssembly] Support physical registers in the rewrite-to-discard optimization.Dan Gohman
llvm-svn: 261465
2016-02-20[WebAssembly] Handle CopyToReg nodes with flag results in LowerCopyToReg.Dan Gohman
llvm-svn: 261457
2016-02-20[WebAssembly] Write stack pointer back to memory when FP is usedDerek Schuff
The stack pointer is bumped when there is a frame pointer or when there are static-size objects, but was only getting written back when there were static-size objects. llvm-svn: 261453
2016-02-20[WebAssembly] Stackify function prologs and epilogsDerek Schuff
The instructions are the same, but fewer locals are used. Differential Revision: http://reviews.llvm.org/D17428 llvm-svn: 261452
2016-02-16[WebAssembly] Implement __builtin_frame_address.Dan Gohman
Differential Revision: http://reviews.llvm.org/D17307 llvm-svn: 261032
2016-02-16[WebAssembly] Insert COPY_LOCAL between CopyToReg and FrameIndex DAG nodesDerek Schuff
CopyToReg nodes don't support FrameIndex operands. Other targets select the FI to some LEA-like instruction, but since we don't have that, we need to insert some kind of instruction that can take an FI operand and produces a value usable by CopyToReg (i.e. in a vreg). So insert a dummy copy_local between Op and its FI operand. This results in a redundant copy which we should optimize away later (maybe in the post-FI-lowering peephole pass). Differential Revision: http://reviews.llvm.org/D17213 llvm-svn: 260987
2016-01-30[WebAssembly] Fix uses of FrameIndex as store valuesDerek Schuff
Previously the code assumed all uses of FI on loads and stores were as addresses. This checks whether the use is the address or a value and handles the latter case as it does for non-memory instructions. llvm-svn: 259306
2016-01-29[WebAssembly] Support frame pointerDerek Schuff
Add support for frame pointer use in prolog/epilog. Supports dynamic allocas but not yet over-aligned locals. Target-independend CG generates SP updates, but we still need to write back the SP value to memory when necessary. llvm-svn: 259220
2016-01-26[WebAssembly] Omit no-op adds for non-mem uses of FrameIndexDerek Schuff
Differential Revision: http://reviews.llvm.org/D16554 llvm-svn: 258872