aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-26TargetLibraryInfo: Delete default TargetLibraryInfoImpl constructor (#145826)Matt Arsenault1-1/+1
It should not be possible to construct one without a triple. It would also be nice to delete TargetLibraryInfoWrapperPass, but that is more difficult.
2025-06-23[TLI] Add support for pvalloc() (#144949)Marco Elver1-0/+1
While pvalloc() is a legacy POSIX function, it remains widely available in common C libraries like glibc. Model pvalloc() in TargetLibraryInfo, allowing LLVM to correctly infer its attributes.
2024-11-13[TLI] Add support for reallocarray (#114818)serge-sans-paille1-0/+1
reallocarray is available in glibc since 2.29 under _DEFAULT_SOURCE and under _GNU_SOURCE before, let's model it appropriately.
2024-11-05[IR] Disallow recursive types (#114799)Jay Foad1-1/+1
StructType::setBody is the only mechanism that can potentially create recursion in the type system. Add a runtime check that it is not actually used to create recursion. If the check fails, report an error from LLParser, BitcodeReader and IRLinker. In all other cases assert that the check succeeds. In future StructType::setBody will be removed in favor of specifying the body when the type is created, so any performance hit from this runtime check will be temporary.
2024-10-31[Reland][TLI] Add support for hypot libcall. (#114343)Kenji Mouri / 毛利 研二1-0/+3
This patch adds basic support for `hypot`. Constant folding support will be submitted in a subsequent patch. Related issue: https://github.com/llvm/llvm-project/issues/113711 Note: It's my first time contributing to the LLVM with encouragement from one of my friends, @fawdlstty. I learned a lot from https://github.com/llvm/llvm-project/pull/99611, and thanks for that. Note: I had created the same PR and merged (https://github.com/llvm/llvm-project/pull/113724), but reverted caused by the merging issue. (The CI issue happened in 3 A.M. at my timezone. So, I need to fall asleep again after I replied about why issue happened.) So, I rebased to the latest main branch and recreate the PR and hope I won't have the third time to create the same PR. I hope @arsenm can help me review the code again. I’m sorry for that. Kenji Mouri
2024-10-30Revert "[TLI] Add support for hypot libcall." (#114312)gulfemsavrun1-3/+0
Reverts llvm/llvm-project#113724
2024-10-30[TLI] Add support for hypot libcall. (#113724)Kenji Mouri / 毛利 研二1-0/+3
This patch adds basic support for `hypot`. Constant folding support will be submitted in a subsequent patch. Related issue: https://github.com/llvm/llvm-project/issues/113711 Note: It's my first time contributing to the LLVM with encouragement from one of my friends, @fawdlstty. I learned a lot from https://github.com/llvm/llvm-project/pull/99611, and thanks for that. Kenji Mouri
2024-10-29[TLI] Add support for the `tgamma` libcall. (#113791)c8ef1-0/+3
This patch adds the `tgamma` libcall.
2024-10-20[TLI] Add basic support for scalbnxx (#112936)Fawdlstty1-0/+6
This patch adds basic support for `scalbln, scalblnf, scalblnl, scalbn, scalbnf, scalbnl`. Constant folding support will be submitted in a subsequent patch. Related issue: <#112631>
2024-10-18[TLI] Add support for the `ilogb` libcall. (#112725)c8ef1-0/+3
This patch adds the `ilogb` libcall. Constant folding will be handled in subsequent patches.
2024-09-20[TLI] Add basic support for fdim libcall (#108702)braw-lee1-0/+3
first PR to fix #108695 Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-09-18[TLI] Support inferring function attributes for sincos[f|l] (#108554)Benjamin Maxwell1-0/+3
2024-09-13[llvm][unittests] Strip unneeded use of raw_string_ostream::str() (NFC)JOE19941-1/+1
Avoid excess layer of indirection.
2024-08-18[TLI] Add support for inferring attr `cold`/`noreturn` on `std::terminate` ↵Noah Goldstein1-0/+2
and `__cxa_throw` These functions are both inherently on the error path so `cold` seems appropriate. `noreturn` is definitional. Closes #101622
2024-08-15Intrinsic: introduce minimumnum and maximumnum for IR and SelectionDAG (#96649)YunQiang Su1-0/+6
C23 introduced new functions fminimum_num and fmaximum_num, and they follow the minimumNumber and maximumNumber of IEEE754-2019. Let's introduce new intrinsics to support them. This patch introduces support only support for scalar values. The support of vector (vp, vp.reduce, vector.reduce), experimental.constrained will be added in future patches. With this patch, MIPSr6 and LoongArch can work out of box with fcanonical and fmax/fmin. Aarch64/PowerPC64 can use the same login as MIPSr6 and LoongArch, while they have no fcanonical support yet. I will add it in future patches. The FMIN/FMAX of RISC-V instructions follows the minimumNumber/maximumNumber of IEEE754-2019. We can just add it in future patch. Background https://discourse.llvm.org/t/rfc-fix-llvm-min-f-and-llvm-max-f-intrinsics/79735 Currently we have fminnum/fmaxnum, which have different behavior on different platform for NUM vs sNaN: 1) Fallback to fmin(3)/fmax(3): return qNaN. 2) ARM64/ARM32+Neon: same as libc. 3) MIPSr6/LoongArch/RISC-V: return NUM. And the fix of fminnum/fmaxnum to follow minNUM/maxNUM of IEEE754-2008 will submit as separated patches.
2024-08-13Enhance TLI detection of __size_returning_new lib funcs. (#102391)Snehasish Kumar1-4/+29
Previously the return types of __size_returning_new variants were not validated based on their members. This patch checks the members manually, also generalizes the size_t checks to be based on the module instead of being hardcoded. As requested in followup comment on https://github.com/llvm/llvm-project/pull/101564.
2024-08-06Add __size_returning_new variant detection to TLI. (#101564)Snehasish Kumar1-0/+4
Add support to detect __size_returning_new variants defined inproposal P0901R5 to extend to operator new, see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0901r5.html for details. This PR matches the declarations exported by tcmalloc in https://github.com/google/tcmalloc/blob/f2516691d01051defc558679f37720bba88d9862/tcmalloc/malloc_extension.h#L707-L711
2024-08-01[TLI] Add support for nan libfunc (#101356)Yingwei Zheng1-0/+3
Reference: https://en.cppreference.com/w/cpp/numeric/math/nan
2024-07-30[TLI] Add support for inferring attr `cold` on `exit`/`abort`Noah Goldstein1-1/+5
`abort` can be assumed always cold and assume non-zero `exit` status as a `cold` path as well. Closes #101003
2024-07-19[TLI] Add basic support for remquo libcall (#99611)Yingwei Zheng1-0/+3
This patch adds basic support for `remquo`. Constant folding support will be submitted in a subsequent patch. Related issue: https://github.com/llvm/llvm-project/issues/99497
2024-06-21Revert "Intrinsic: introduce minimumnum and maximumnum (#93841)"Nikita Popov1-7/+1
As far as I can tell, this pull request was not approved, and did not go through an RFC on discourse. This reverts commit 89881480030f48f83af668175b70a9798edca2fb. This reverts commit 225d8fc8eb24fb797154c1ef6dcbe5ba033142da.
2024-06-21Intrinsic: introduce minimumnum and maximumnum (#93841)YunQiang Su1-1/+7
Currently, on different platform, the behaivor of llvm.minnum is different if one operand is sNaN: When we compare sNaN vs NUM: ARM/AArch64/PowerPC: follow the IEEE754-2008's minNUM: return qNaN. RISC-V/Hexagon follow the IEEE754-2019's minimumNumber: return NUM. X86: Returns NUM but not same with IEEE754-2019's minimumNumber as +0.0 is not always greater than -0.0. MIPS/LoongArch/Generic: return NUM. LIBCALL: returns qNaN. So, let's introduce llvm.minmumnum/llvm.maximumnum, which always follow IEEE754-2019's minimumNumber/maximumNumber. Half-fix: #93033
2024-04-29[llvm][GlobalOpt] Remove empty atexit destructors/handlers (#88836)Max Winkler1-0/+2
https://godbolt.org/z/frjhqMKqc for an example. Removal of allocations due to empty `__cxa_atexit` destructor calls is done by the following globalopt pass. This pass currently does not look for `atexit` handlers generated for platforms that do not use `__cxa_atexit`. By default Win32 and AIX use `atexit`. I don't see an easy way to only remove `atexit` calls that the compiler generated without looking at the generated mangled name of the atexit handler that is being registered. However we can easily remove all `atexit` calls that register empty handlers since it is trivial to ensure the removed call still returns `0` which is the value for success.
2024-02-24[InstCombine] Handle more even/odd math functions (#81324)Artem Tyurin1-0/+3
At the moment this PR adds support only for `erf` function. Fixes #77220.
2023-12-21[TLI] Add getLibFunc that accepts an Opcode and scalar Type. (#75919)Paschalis Mpeis1-0/+35
It sets a LibFunc similarly with the other two getLibFunc methods. Currently, it supports only the FRem Instruction. Add tests for FRem.
2023-10-15[InstCombine][TLI] Fix function prototype of `labs` (#69077)Yingwei Zheng1-0/+10
`i64 @labs(i32)` is incorrectly recognized as `LibFunc_labs` because type ID `Long` matches both `i32` and `i64`. This PR requires the type of argument to match the return value. Fixes #69059.
2023-09-12[llvm][unittests] Remove unneeded header includesBjorn Pettersson1-1/+0
2023-04-28[MemProf] Use updated version of hot/cold operator newTeresa Johnson1-8/+8
Switch to the just updated versions of the API in tcmalloc that change the name of the hot cold paramter to a reserved identifier __hot_cold_t. This was based on feedback from Richard Smith, as I also need to add some follow-on handling to clang so they are annotated properly. Differential Revision: https://reviews.llvm.org/D149475
2023-04-19[MemProf] Optionally pass hot/cold hints to operator newTeresa Johnson1-0/+10
Optionally (off by default) replace operator new() calls marked with a hot or cold memprof attribute with an operator new() call that takes a hot_cold_t parameter. Currently this is supported by the open source version of tcmalloc, see: https://github.com/google/tcmalloc/blob/master/tcmalloc/new_extension.h Differential Revision: https://reviews.llvm.org/D148718
2022-08-10[InstCombine] Tighten up known library function signature tests (PR #56463)Martin Sebor1-3/+3
Replace a switch statement used to validate arguments to known library functions with a more consistent table-driven approach and tighten it up.
2021-12-01[TLI] Add memset_pattern4, memset_pattern8 lib functions.Florian Hahn1-3/+5
Similar to memset_pattern16, memset_pattern4, memset_pattern8 are available on Darwin platforms. https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/memset_pattern4.3.html Reviewed By: ab Differential Revision: https://reviews.llvm.org/D114881
2021-10-05[llvm] Update report_fatal_error calls from raw_string_ostream to use ↵Simon Pilgrim1-1/+1
Twine(OS.str()) As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared. We can use the raw_string_ostream::str() method to perform the implicit flush() and return a reference to the std::string container that we can then wrap inside Twine().
2021-07-21[OpenMP] Change `__kmpc_free_shared` to include the paired allocation sizeJoseph Huber1-1/+1
This patch changes `__kmpc_free_shared` to take an additional argument corresponding to the associated allocation's size. This makes it easier to implement the allocator in the runtime. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D106496
2021-06-22[OpenMP] Add new OpenMP globalization functions to library infoJoseph Huber1-0/+4
Summary: The changes to globalization introduced in D97680 created two new functions to push / pop shareably memory on the GPU, __kmpc_alloc_shared and __kmpc_free_shared. This patch adds these new runtime functions to the library info so they can be used by the HeapToStack attributor interface. This optimization replaces malloc / free pairs with stack memory if legal. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D102087
2021-01-22[Analysis] Support AIX vec_malloc routinesShimin Cui1-0/+6
This is to support the memory routines vec_malloc, vec_calloc, vec_realloc, and vec_free. These routines manage memory that is 16-byte aligned. And they are only available on AIX. Differential Revision: https://reviews.llvm.org/D94710
2020-11-30Creating a named struct requires only a Context and a name, but looking up a ↵Nick Lewycky1-1/+1
struct by name requires a Module. The method on Module merely accesses the LLVMContextImpl and no data from the module itself, so this patch moves getTypeByName to a static method on StructType that takes a Context and a name. There's a small number of users of this function, they are all updated. This updates the C API adding a new method LLVMGetTypeByName2 that takes a context and a name. Differential Revision: https://reviews.llvm.org/D78793
2020-10-06[SimplifyLibCalls] Optimize mempcpy_chk to mempcpyDávid Bolvanský1-0/+1
2020-07-18[LLVM] Add libatomic load/store functions to TargetLibraryInfoGui Andrade1-0/+3
This allows treating these functions like libcalls. This patch is a prerequisite to instrumenting them in MSAN: https://reviews.llvm.org/D83337 Differential Revision: https://reviews.llvm.org/D83361
2020-06-16[TLI] Add four C++17 delete variants.Hiroshi Yamauchi1-0/+4
Summary: delete(void*, unsigned int, align_val_t) delete(void*, unsigned long, align_val_t) delete[](void*, unsigned int, align_val_t) delete[](void*, unsigned long, align_val_t) Differential Revision: https://reviews.llvm.org/D81853
2020-05-26[FPEnv] Intrinsic llvm.roundevenSerge Pavlov1-0/+3
This intrinsic implements IEEE-754 operation roundToIntegralTiesToEven, and performs rounding to the nearest integer value, rounding halfway cases to even. The intrinsic represents the missed case of IEEE-754 rounding operations and now llvm provides full support of the rounding operations defined by the standard. Differential Revision: https://reviews.llvm.org/D75670
2020-03-29Introduce support for lib function aligned_alloc in TLI / memory builtinsUday Bondhugula1-0/+1
Aligned_alloc is a standard lib function and has been in glibc since 2.16 and in the C11 standard. It has semantics similar to malloc/calloc for several analyses/transforms. This patch introduces aligned_alloc in target library info and memory builtins. Subsequent ones will make other passes aware and fix https://bugs.llvm.org/show_bug.cgi?id=44062 This change will also be useful to LLVM generators that need to allocate buffers of vector elements larger than 16 bytes (for eg. 256-bit ones), element boundary alignment for which is not typically provided by glibc malloc. Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Differential Revision: https://reviews.llvm.org/D76970
2020-02-12[unittests] Fix TargetLibraryInfoTest.ValidProtoEhud Katz1-0/+3
2020-02-08[SimplifyLibCalls] Add __strlen_chk.George Burgess IV1-0/+1
Bionic has had `__strlen_chk` for a while. Optimizing that into a constant is quite profitable, when possible. Differential Revision: https://reviews.llvm.org/D74079
2019-05-31[SimplifyLibCalls] Fold more fortified functions into non-fortified variantsErik Pilkington1-0/+11
When the object size argument is -1, no checking can be done, so calling the _chk variant is unnecessary. We already did this for a bunch of these functions. rdar://50797197 Differential revision: https://reviews.llvm.org/D62358 llvm-svn: 362272
2019-04-03Fix TargetLibraryInfoTest.ValidProto after rL357552Sam Clegg1-0/+5
llvm-svn: 357559
2019-02-01[opaque pointer types] Add a FunctionCallee wrapper type, and use it.James Y Knight1-1/+1
Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc doesn't choke on it, hopefully. Original Message: The FunctionCallee type is effectively a {FunctionType*,Value*} pair, and is a useful convenience to enable code to continue passing the result of getOrInsertFunction() through to EmitCall, even once pointer types lose their pointee-type. Then: - update the CallInst/InvokeInst instruction creation functions to take a Callee, - modify getOrInsertFunction to return FunctionCallee, and - update all callers appropriately. One area of particular note is the change to the sanitizer code. Previously, they had been casting the result of `getOrInsertFunction` to a `Function*` via `checkSanitizerInterfaceFunction`, and storing that. That would report an error if someone had already inserted a function declaraction with a mismatching signature. However, in general, LLVM allows for such mismatches, as `getOrInsertFunction` will automatically insert a bitcast if needed. As part of this cleanup, cause the sanitizer code to do the same. (It will call its functions using the expected signature, however they may have been declared.) Finally, in a small number of locations, callers of `getOrInsertFunction` actually were expecting/requiring that a brand new function was being created. In such cases, I've switched them to Function::Create instead. Differential Revision: https://reviews.llvm.org/D57315 llvm-svn: 352827
2019-01-31Revert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."James Y Knight1-1/+1
This reverts commit f47d6b38c7a61d50db4566b02719de05492dcef1 (r352791). Seems to run into compilation failures with GCC (but not clang, where I tested it). Reverting while I investigate. llvm-svn: 352800
2019-01-31[opaque pointer types] Add a FunctionCallee wrapper type, and use it.James Y Knight1-1/+1
The FunctionCallee type is effectively a {FunctionType*,Value*} pair, and is a useful convenience to enable code to continue passing the result of getOrInsertFunction() through to EmitCall, even once pointer types lose their pointee-type. Then: - update the CallInst/InvokeInst instruction creation functions to take a Callee, - modify getOrInsertFunction to return FunctionCallee, and - update all callers appropriately. One area of particular note is the change to the sanitizer code. Previously, they had been casting the result of `getOrInsertFunction` to a `Function*` via `checkSanitizerInterfaceFunction`, and storing that. That would report an error if someone had already inserted a function declaraction with a mismatching signature. However, in general, LLVM allows for such mismatches, as `getOrInsertFunction` will automatically insert a bitcast if needed. As part of this cleanup, cause the sanitizer code to do the same. (It will call its functions using the expected signature, however they may have been declared.) Finally, in a small number of locations, callers of `getOrInsertFunction` actually were expecting/requiring that a brand new function was being created. In such cases, I've switched them to Function::Create instead. Differential Revision: https://reviews.llvm.org/D57315 llvm-svn: 352791
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-07Fix unit tests after patch https://reviews.llvm.org/rL346313Calixte Denizet1-465/+474
Summary: Tests are broken so fix them. Reviewers: marco-c Reviewed By: marco-c Subscribers: sylvestre.ledru, llvm-commits Differential Revision: https://reviews.llvm.org/D54208 llvm-svn: 346318