aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-20WebAssembly: Stop directly using RuntimeLibcalls.def (#143054)Matt Arsenault1-17/+11
Construct RuntimeLibcallsInfo instead of manually creating a map. This was repeating the setting of the RETURN_ADDRESS. This removes an obstacle to generating libcall information with tablegen. This is also not great, since it's setting a static map which would be broken if there were ever a triple with a different libcall configuration.
2025-06-16[aarch64] Fix Arm64EC libcall lowering after recent refactoring. (#143977)Eli Friedman1-0/+2
The refactored code accidentally tokenized a string instead of just concatenating it. Add a regression test and some assertions to ensure consistency. Fixes #143890 .
2025-03-31[WebAssembly] Fix signatures of frexpf family of libcalls (#133289)Sam Clegg1-3/+3
Fixes: https://github.com/emscripten-core/emscripten/issues/23997
2025-03-06[WebAssembly] Add Libcall signatures for modf and variants (#130201)Derek Schuff1-0/+27
Clang now lowers modf/modff/modfl as builtins using the llvm.modf intrinsic.
2025-02-19[CodeGen] Use __extendhfsf2 and __truncsfhf2 by default (#126880)Nikita Popov1-4/+0
The standard libcalls for half to float and float to half conversion are __extendhfsf2 and __truncsfhf2. However, LLVM currently uses __gnu_h2f_ieee and __gnu_f2h_ieee instead. As far as I can tell, these libcalls are an ARM-ism and only provided by libgcc on that platform. compiler-rt always provides both libcalls. Use the standard libcalls by default, and only use the __gnu libcalls on ARM.
2024-11-15[WebAssembly] Remove unused includes (NFC) (#116318)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-10-17[WebAssembly] Add atan2 to RuntimeLibcallSignatureTable (#112613)Tex Riddell1-0/+3
This change is part of this proposal: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 - `WebAssemblyRuntimeLibcallSignatures.cpp`: Add `RTLIB::ATAN2*` to RuntimeLibcallSignatureTable - Add atan2 calls to `CodeGen/WebAssembly/libcalls-trig.ll` and update test checks Part of: Implement the atan2 HLSL Function #70096.
2024-07-20Reapply "[LLVM][LTO] Factor out RTLib calls and allow them to be dropped ↵Joseph Huber1-1/+1
(#98512)" This reverts commit 740161a9b98c9920dedf1852b5f1c94d0a683af5. I moved the `ISD` dependencies into the CodeGen portion of the handling, it's a little awkward but it's the easiest solution I can think of for now.
2024-07-20Revert "[LLVM][LTO] Factor out RTLib calls and allow them to be dropped ↵NAKAMURA Takumi1-1/+1
(#98512)" This reverts commit c05126bdfc3b02daa37d11056fa43db1a6cdef69. (llvmorg-19-init-17714-gc05126bdfc3b) See #99610
2024-07-19[WebAssembly] Add Support for Arc and Hyperbolic trig llvm intrinsics (#98755)Farzon Lotfi1-0/+18
## Change: - WebAssemblyRuntimeLibcallSignatures.cpp: Expose the RTLIB's for use by WASM - Add trig specific test cases ## History This change is part of an implementation of https://github.com/llvm/llvm-project/issues/87367's investigation on supporting IEEE math operations as intrinsics. Which was discussed in this RFC: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 This change adds wasm lowering cases for `acos`, `asin`, `atan`, `cosh`, `sinh`, and `tanh`. https://github.com/llvm/llvm-project/issues/70079 https://github.com/llvm/llvm-project/issues/70080 https://github.com/llvm/llvm-project/issues/70081 https://github.com/llvm/llvm-project/issues/70083 https://github.com/llvm/llvm-project/issues/70084 https://github.com/llvm/llvm-project/issues/95966 ## Why Web Assembly? From past changes to try and support constraint intrinsics the changes to the trig builtins to emit intrinsics\constraint intrinsics broke the WASM build. This is an attempt to preempt any such build break. - https://github.com/llvm/llvm-project/pull/95082 - https://github.com/llvm/llvm-project/pull/94559#issuecomment-2159923215
2024-07-16[LLVM][LTO] Factor out RTLib calls and allow them to be dropped (#98512)Joseph Huber1-1/+1
Summary: The LTO pass and LLD linker have logic in them that forces extraction and prevent internalization of needed runtime calls. However, these currently take all RTLibcalls into account, even if the target does not support them. The target opts-out of a libcall if it sets its name to nullptr. This patch pulls this logic out into a class in the header so that LTO / lld can use it to determine if a symbol actually needs to be kept. This is important for targets like AMDGPU that want to be able to use `lld` to perform the final link step, but does not want the overhead of uncalled functions. (This adds like a second to the link time trivially)
2024-06-11[WASM] Fix for wasi libc build break add tan to RuntimeLibcallSignatureTable ↵Farzon Lotfi1-0/+3
(#95082) The wasm backend fetches the tan runtime lib call in `llvm/include/llvm/IR/RuntimeLibcalls.def` via `StaticLibcallNameMap()`, but ignores the runtime function because a function sinature mapping is not specified in RuntimeLibcallSignatureTable(). The fix is to specify the function signatures for float32-128. This is a fix for a build break reported on PR https://github.com/llvm/llvm-project/pull/94559#issuecomment-2159923215.
2024-04-23[WebAssembly] Enable multivalue return when multivalue ABI is used (#88492)Heejin Ahn1-12/+13
Multivalue feature of WebAssembly has been standardized for several years now. I think it makes sense to be able to enable it in the feature section by default for our clang/llvm-produced binaries so that the multivalue feature can be used as necessary when necessary within our toolchain and also when running other optimizers (e.g. wasm-opt) after the LLVM code generation. But some WebAssembly toolchains, such as Emscripten, do not provide both mulvalue-returning and not-multivalue-returning versions of libraries. Also allowing the uses of multivalue in the features section does not necessarily mean we generate them whenever we can to the fullest, which is a different code generation / optimization option. So this makes the lowering of multivalue returns conditional on the use of 'experimental-mv' target ABI. This ABI is turned off by default and turned on by passing `-Xclang -target-abi -Xclang experimental-mv` to `clang`, or `-target-abi experimental-mv` to `clang -cc1` or `llc`. But the purpose of this PR is not tying the multivalue lowering to this specific 'experimental-mv'. 'experimental-mv' is just one multivalue ABI we currently have, and it is still experimental, meaning it is not very well optimized or tuned for performance. (e.g. it does not have the limitation of the max number of multivalue-lowered values, which can be detrimental to performance.) We may change the name of this ABI, or improve it, or add a new multivalue ABI in the future. Also I heard that WASI is planning to add their multivalue ABI soon. So the plan is, whenever any one of multivalue ABIs is enabled, we enable the lowering of multivalue returns in the backend. We currently have only 'experimental-mv' in the repo so we only check for that in this PR. Related past discussions: #82714 https://github.com/WebAssembly/tool-conventions/pull/223#issuecomment-2008298652
2024-03-14[WebAssembly] Move getLibcallSignature into WebAssembly namespace (NFC) (#85171)Heejin Ahn1-8/+8
These are Wasm only functions so they are better be within `WebAssembly` namespace rather than the `llvm` namespace which includes the whole LLVM. Also this removes `extern` keywords which are not strictly necessary.
2024-02-28Revert "[WebAssembly] Disable multivalue emission temporarily (#82714)"Heejin Ahn1-14/+12
This reverts commit 6e6bf9f81756ba6655b4eea8dc45469a47f89b39. It turned out the multivalue feature had active outside users and it could cause some disruptions to them, so I'd like to investigate more about the workarounds before doing this.
2024-02-22[WebAssembly] Disable multivalue emission temporarily (#82714)Heejin Ahn1-12/+14
We plan to enable multivalue in the features section soon (#80923) for other reasons, such as the feature having been standardized for many years and other features being developed (e.g. EH) depending on it. This is separate from enabling Clang experimental multivalue ABI (`-Xclang -target-abi -Xclang experimental-mv`), but it turned out we generate some multivalue code in the backend as well if it is enabled in the features section. Given that our backend multivalue generation still has not been much used nor tested, and enabling the feature in the features section can be a separate decision from how much multialue (including none) we decide to generate for now, I'd like to temporarily disable the actual generation of multivalue in our backend. To do that, this adds an internal flag `-wasm-emit-multivalue` that defaults to false. All our existing multivalue tests can use this to test multivalue code. This flag can be removed later when we are confident the multivalue generation is well tested.
2023-10-20[WebAssembly] Add exp10 libcall signatures (#69661)Ashley Nelson1-0/+3
The llvm.exp.* family of intrinsics and their corresponding libcalls were recently added, which means we need to know their signatures.
2023-07-06[WebAssembly] Add frexp{f,l} libcall signaturesDerek Schuff1-0/+3
The llvm.frexp.* family of intrinsics and their corresponding libcalls were recently added, which means we need to know their signatures. Differential Revision: https://reviews.llvm.org/D154639 Fixed: https://github.com/llvm/llvm-project/issues/63657
2023-06-07[WebAssembly] Add ldexp{,f,l} libcall signaturesDerek Schuff1-0/+3
llvm.ldexp.* intrinsics were recently added to LLVM, which means wasm now needs to know the signatures of the corresponding libcalls. Differential Revision: https://reviews.llvm.org/D152385 Fixes: #63164
2023-04-04[WebAssembly] Add libcall signatures for roundevenThomas Lively1-0/+3
Since clang started emitting roundeven intrinsics in a7d6593a0a17, they would cause a crash in the WebAssembly backend because it did not know the roundeven library function signatures. Fix the crash by adding the signatures. Differential Revision: https://reviews.llvm.org/D147476
2023-03-22[WebAssembly] Fix i64_i64_func_i64_i64_i32 type signature when multivalue ↵Congcong Cai1-2/+0
feature is enabled Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D146533
2023-03-22[Webassembly][multivalue] update libcall signature for f128 when multivalue ↵Congcong Cai1-85/+69
feature enabled further update for [D146271](https://reviews.llvm.org/D146271) Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D146499
2023-03-21[Webassembly][NFC] Fix typo in commentCongcong Cai1-3/+3
2023-03-21[Webassembly][multivalue] update libcall signature when multivalue feature ↵Congcong Cai1-60/+60
enabled fixed: #59095 Update libcall signatures to use multivalue return rather than returning via a pointer when the multivalue features is enabled in the WebAssembly backend. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D146271
2023-03-15[llvm] Use *{Map,Set}::contains (NFC)Kazu Hirata1-1/+1
2022-10-03[WebAssembly] Fix return type of __builtin_return_address under wasm64Sam Clegg1-1/+6
Differential Revision: https://reviews.llvm.org/D135005
2022-07-10ManagedStatic: remove many straightforward uses in llvmNicolai Hähnle1-7/+10
(Reapply after revert in e9ce1a588030d8d4004f5d7e443afe46245e9a92 due to Fuchsia test failures. Removed changes in lib/ExecutionEngine/ other than error categories, to be checked in more detail and reapplied separately.) Bulk remove many of the more trivial uses of ManagedStatic in the llvm directory, either by defining a new getter function or, in many cases, moving the static variable directly into the only function that uses it. Differential Revision: https://reviews.llvm.org/D129120
2022-07-10Revert "ManagedStatic: remove many straightforward uses in llvm"Nicolai Hähnle1-10/+7
This reverts commit e6f1f062457c928c18a88c612f39d9e168f65a85. Reverting due to a failure on the fuchsia-x86_64-linux buildbot.
2022-07-10ManagedStatic: remove many straightforward uses in llvmNicolai Hähnle1-7/+10
Bulk remove many of the more trivial uses of ManagedStatic in the llvm directory, either by defining a new getter function or, in many cases, moving the static variable directly into the only function that uses it. Differential Revision: https://reviews.llvm.org/D129120
2021-07-09[WebAssembly] Added initial type checker to MC AssemblerWouter van Oortmerssen1-2/+3
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-02-13[WebAssembly] Add cbrt function signaturesThomas Lively1-0/+3
Summary: Fixes a crash in the backend where optimizations produce calls to the cbrt runtime functions. Fixes PR 44227. Reviewers: aheejin Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74259
2020-02-07[WebAssembly] Fix signature of __powitf2 libcallSam Clegg1-1/+8
Add tests for @llvm.powi.f64/f128. See: https://llvm.org/docs/LangRef.html#llvm-powi-intrinsic Differential Revision: https://reviews.llvm.org/D74274
2020-01-10[TargetLowering][ARM][Mips][WebAssembly] Remove the ordered FP compare from ↵Craig Topper1-6/+0
RunttimeLibcalls.def and all associated usages Summary: This always just used the same libcall as unordered, but the comparison predicate was different. This change appears to have been made when targets were given the ability to override the predicates. Before that they were hardcoded into the type legalizer. At that time we never inverted predicates and we handled ugt/ult/uge/ule compares by emitting an unordered check ORed with a ogt/olt/oge/ole checks. So only ordered needed an inverted predicate. Later ugt/ult/uge/ule were optimized to only call a single libcall and invert the compare. This patch removes the ordered entries and just uses the inverting logic that is now present. This removes some odd things in both the Mips and WebAssembly code. Reviewers: efriedma, ABataev, uweigand, cameron.mcinally, kpn Reviewed By: efriedma Subscribers: dschuff, sdardis, sbc100, arichardson, jgravelle-google, kristof.beyls, hiraditya, aheejin, sunfish, atanasyan, Petar.Avramovic, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72536
2019-05-29[WebAssembly] Add signatures for RINT builtinsThomas Lively1-0/+6
Reviewers: azakai, dschuff Subscribers: sbc100, jgravelle-google, hiraditya, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62564 llvm-svn: 361904
2019-05-23[WebAssembly] Implement __builtin_return_address for emscriptenThomas Lively1-0/+5
Summary: In this patch, `ISD::RETURNADDR` is lowered on the emscripten target to the new Emscripten runtime function `emscripten_return_address`, which implements the functionality. Patch by Guanzhong Chen Reviewers: tlively, aheejin Reviewed By: tlively Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62210 llvm-svn: 361454
2019-05-21[WebAssembly] Add the signature for the new llround builtin functionDan Gohman1-0/+22
r360889 added new llround builtin functions. This patch adds their signatures for the WebAssembly backend. It also adds wasm32 support to utils/update_llc_test_checks.py, since that's the script other targets are using for their testcases for this feature. Differential Revision: https://reviews.llvm.org/D62207 llvm-svn: 361327
2019-04-30[WebAssembly] Support f16 libcallsDan Gohman1-1/+18
Add support for f16 libcalls in WebAssembly. This entails adding signatures for the remaining F16 libcalls, and renaming gnu_f2h_ieee/gnu_h2f_ieee to truncsfhf2/extendhfsf2 for consistency between f32 and f64/f128 (compiler-rt already supports this). Differential Revision: https://reviews.llvm.org/D61287 Reviewer: dschuff llvm-svn: 359600
2019-04-29[WebAssembly] Make an assertion message prettier. NFC.Dan Gohman1-2/+2
This is a follow-up to https://reviews.llvm.org/D59521. llvm-svn: 359509
2019-04-29[WebAssembly] Define the signature for __stack_chk_failDan Gohman1-1/+9
The WebAssembly backend needs to know the signatures of all runtime libcall functions. This adds the signature for __stack_chk_fail which was previously missing. Also, make the error message for a missing libcall include the name of the function. Differential Revision: https://reviews.llvm.org/D59521 Reviewed By: sbc100 llvm-svn: 359505
2019-02-04[WebAssembly] clang-tidy (NFC)Heejin Ahn1-38/+38
Summary: This patch fixes clang-tidy warnings on wasm-only files. The list of checks used is: `-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,modernize-*` (LLVM's default .clang-tidy list is the same except it does not have `modernize-*`. But I've seen in multiple CLs in LLVM the modernize style was recommended and code was fixed based on the style, so I added it as well.) The common fixes are: - Variable names start with an uppercase letter - Function names start with a lowercase letter - Use `auto` when you use casts so the type is evident - Use inline initialization for class member variables - Use `= default` for empty constructors / destructors - Use `using` in place of `typedef` Reviewers: sbc100, tlively, aardappel Subscribers: dschuff, sunfish, jgravelle-google, yurydelendik, kripken, MatzeB, mgorny, rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D57500 llvm-svn: 353075
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-09-27WebAssembly: Rename GetSignature to GetLibcallSignature [NFC]Derek Schuff1-7/+9
llvm-svn: 343275
2018-09-05[WebAssembly] clang-format (NFC)Heejin Ahn1-5/+2
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-07-24Put "built-in" function definitions in global Used list, for LTO. (fix bug ↵Peter Collingbourne1-1/+1
34169) When building with LTO, builtin functions that are defined but whose calls have not been inserted yet, get internalized. The Global Dead Code Elimination phase in the new LTO implementation then removes these function definitions. Later optimizations add calls to those functions, and the linker then dies complaining that there are no definitions. This CL fixes the new LTO implementation to check if a function is builtin, and if so, to not internalize (and later DCE) the function. As part of this fix I needed to move the RuntimeLibcalls.{def,h} files from the CodeGen subidrectory to the IR subdirectory. I have updated all the files that accessed those two files to access their new location. Fixes PR34169 Patch by Caroline Tice! Differential Revision: https://reviews.llvm.org/D49434 llvm-svn: 337847
2018-05-31[WebAssembly] Fix the signatures for the __mulo* libcalls.Dan Gohman1-3/+31
The __mulo* libcalls have an extra i32* to return the overflow value. Fixes PR37401. llvm-svn: 333706
2018-05-01Remove \brief commands from doxygen comments.Adrian Prantl1-1/+1
We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 llvm-svn: 331272
2018-03-02[WebAssembly] Avoid cast ExprType to wasm::ValTypeSam Clegg1-31/+30
This cast was causing invalid signatures to be written for libcall functions. Add an MC test which includes a call to builtin memcpy. Differential Revision: https://reviews.llvm.org/D44037 llvm-svn: 326618
2018-02-26[WebAssembly] Relax constexpr for old standard libraries.Benjamin Kramer1-1/+1
This will still be constexpr when the standard library supports it, but doesn't force constexpr. Old libraries will get a global constructor, which is not too bad. llvm-svn: 326080
2018-02-23[WebAssembly] Fix macro metaprogram to not duplicate code as much.Benjamin Kramer1-7/+11
No functionality change intended. llvm-svn: 325947
2018-01-20[WebAssembly] Fix MSVC buildDerek Schuff1-5/+6
nullptr_t can't be used left of boolean && llvm-svn: 323012