2677 Commits

Author SHA1 Message Date
Zhuoran Yin
2b983a2458
[MLIR][AMDGPU] Adding dynamic size check to avoid subword buffer load (#135014)
Motivation: amdgpu buffer load instruction will return all zeros when
loading sub-word values. For example, assuming the buffer size is
exactly one word and we attempt to invoke
`llvm.amdgcn.raw.ptr.buffer.load.v2i32` starting from byte 2 of the
word, we will not receive the actual value of the buffer but all zeros
for the first word. This is because the boundary has been crossed for
the first word.

This PR come up with a fix to this problem, such that, it creates a
bounds check against the buffer load instruction. It will compare the
offset + vector size to see if the upper bound of the address will
exceed the buffer size. If it does, masked transfer read will be
optimized to `vector.load` + `arith.select`, else, it will continue to
fall back to default lowering of the masked vector load.
2025-04-15 16:36:25 -04:00
Alexey Samsonov
9b13d34530
[libc][bazel] Remove a no-op libc_internal_target macro. (#135818)
This macro is a no-op after 90c001ac9e1d92a1a95d191d1640ab5337a937e5:
libc_function macro now produce a "regular" cc_library target, without
modifying its name, and this target is intended to only be used in
tests.

Thus, libc_internal_target macro is no longer needed, and we can safely
treat libc_function rules and libc_support_library rules identically for
test purposes.

`libc_function_deps` attribute of a `libc_test` macro can also be
cleaned up, but I plan to do this in a subsequent change.
2025-04-15 10:49:52 -07:00
Christian Sigg
12a7155ee2 [mlir][bazel] Port mlir-translate bits of acf964b95f54. 2025-04-13 09:13:17 +02:00
Pranav Kant
a4fbc6f78f
[bazel] Fix a typo (#135460) 2025-04-11 17:05:52 -07:00
Pranav Kant
b74dbf7fb2
[bazel] Add support for SMT Dialect (#135454)
This fixes #131480
2025-04-11 16:34:49 -07:00
Pranav Kant
22c3dac454
[bazel] Fix for #134956 (#135233) 2025-04-10 11:52:33 -07:00
Pranav Kant
02fde3a651
[bazel] Fix for #134298 (#135114) 2025-04-09 18:54:48 -07:00
Pranav Kant
4d06d22da0
[bazel] Fix after #133692 (#135098)
Avoid failures like these:
https://buildkite.com/llvm-project/upstream-bazel/builds/131707#01961bb5-2a7b-4dea-a387-cdfd8bb4db48
2025-04-09 16:22:31 -07:00
Alexey Samsonov
90c001ac9e
[libc][bazel] Use Bazel aspects to implement libc_release_library. (#134948)
Instead of creating hundreds of implicit "filegroup" targets to keep
track of sources and textual headers required to build each libc
function or helper library, use Bazel aspects (see
https://bazel.build/versions/8.0.0/extending/aspects), which enable
transparent collection of transitive sources / textual headers while
walking the dependency DAG, and minimizes the Starlark overhead.

Co-authored-by: Jordan Rupprecht <rupprecht@google.com>
2025-04-09 15:36:48 -07:00
Jakub Kuderski
b92f4d4c33
[bazel][mlir] Add missing dep for X86Vector (#135069)
Follow up fix to https://github.com/llvm/llvm-project/pull/133692
2025-04-09 15:25:44 -04:00
Adam Siemieniuk
0c2a6f2d62
[mlir][x86vector] Simplify intrinsic generation (#133692)
Replaces separate x86vector named intrinsic operations with direct calls
to LLVM intrinsic functions.
    
This rework reduces the number of named ops leaving only high-level MLIR
equivalents of whole intrinsic classes e.g., variants of AVX512 dot on
BF16 inputs. Dialect conversion applies LLVM intrinsic name mangling
further simplifying lowering logic.
    
The separate conversion step translating x86vector intrinsics into LLVM
IR is also eliminated. Instead, this step is now performed by the
existing llvm dialect infrastructure.

RFC:
https://discourse.llvm.org/t/rfc-simplify-x86-intrinsic-generation/85581
2025-04-09 19:59:37 +02:00
lntue
c5e07fb861
[libc] Use correct instruction for arm32 sqrt inline asm. (#134968)
https://godbolt.org/z/3jT7jdrs9
2025-04-09 00:01:45 -04:00
lntue
cf7d34a54d
[libc] Extend fputil::sqrt to use floating point instructions for arm32. (#134499) 2025-04-08 22:14:38 -04:00
Yijia Gu
836476660e [mlir][bazel] add missing deps for LLVMOpsTdFiles 2025-04-08 11:36:18 -07:00
Yijia Gu
3b84b1e163 [clang][bazel] fix typo 2025-04-08 11:13:07 -07:00
Yijia Gu
a557550fa4 [clang][bazel] add missing target 2025-04-08 11:06:52 -07:00
Christian Sigg
4e9cfcf6af [llvm][bazel] Fix BUILD after 561506144531cf0a760bb437fd74c683931c60ae. 2025-04-08 17:28:20 +02:00
Christian Sigg
3a6b9b3a87 [mlir][bazel] Fix after dae0ef53a0b99c6c2b74143baee5896e8bc5c8e7
Remove unnecessary include.
2025-04-08 15:47:14 +02:00
Jorge Gorbe Moya
99d12ac172 [bazel] Fix build after 65813e0e94c0403dad61e8365b39d76d7b3bfc14 2025-04-07 17:03:30 -07:00
Pranav Kant
4607d39c7e
[bazel] Fix build (#134697)
Fixes fallback from #134439
2025-04-07 10:36:38 -07:00
Christian Sigg
9fe6f6a0d4
[bazel] Change gentbl_cc_library(tbl_outs) to dicts (#134349)
Follow up from https://github.com/llvm/llvm-project/pull/134271
2025-04-07 14:23:22 +02:00
Jorge Gorbe Moya
109566a3d0
[bazel] Fold "${Target}Analysis" targets into their respective CodeGen targets. (#134312)
After 3801bf6164f570a145e3ebd20cf9114782ae0329, SPIRVAnalysis needs to
include SPIRV.h provided by SPIRVCodegen, but the CodeGen target already
depends on Analysis, so that would cause a circular dependency.

Analysis is a subdirectory of CodeGen so it makes sense as a part of the
main CodeGen target too.
2025-04-03 15:21:26 -07:00
Jorge Gorbe Moya
158684a80f [bazel] Add missing dep after 586c5e3083428e7473e880dafd5939e8707bc1c9 2025-04-03 11:25:44 -07:00
Christian Sigg
6ddf7cf780
[mlir][bazel] Allow gentbl_cc_library(tbl_outs) to be a dict. (#134271)
This makes the BUILD file shorter and more readable.
I will follow up with converting the other instances.
2025-04-03 18:47:56 +02:00
Jorge Gorbe Moya
990a086d9d [bazel] Add missing dep after 51d1c7288662ea801b07133fd2d22aff6bac50e2 2025-04-02 15:17:06 -07:00
Amy Huang
f475ccd379
Fix to the libc BUILD.bazel file after changing atan_utils.h deps. (#134128)
Additional fix for libc BUILD.bazel after commit 8741412 (#133980)

This seems to match libc/src/math/generic/CMakeLists.txt.
2025-04-02 11:05:36 -07:00
NAKAMURA Takumi
3cc7148fe0 [bazel] Update for #134043 2025-04-02 20:29:52 +09:00
Alexey Samsonov
07504afc42
[libc] Stop depending on .cpp files in libcxx_shared_headers library. (#133999)
Fix two instances of libcxx_shared_headers depending on .cpp files (in
Bazel build):

* Don't depend on exit syscall in LIBC_ASSERT implementation. This
dependency is not used, since LIBC_ASSERT always uses system <assert.h>
in the overlay mode, which is the only mode supported by Bazel.
* Don't depend on libc_errno in str-to-float and str-to-integer
conversions. We only need the ERANGE value, which can be obtained from
the proxy header instead.
2025-04-01 16:23:19 -07:00
Amy Huang
537b6541e8
Fix libc BUILD.bazel after commit 8741412 (#133980)
Recent changes add dependencies to some atan functions. Edit bazel build
file to look more like the CMake file.


See
8741412bdf
2025-04-01 13:32:43 -07:00
Jeremy Kun
179062b2dc
[mlir][bazel] add alwayslink=True to mlir-runner utils (#133787)
MacOS platforms using mlir-runner in lit tests consistently hit the
following error:

```
# .---command stderr------------
# | JIT session error: Symbols not found: [ __mlir_ciface_printMemrefI32 ]
# | Error: Failed to materialize symbols: { (main, { __mlir_printMemrefI32, ... }) }
# `-----------------------------
```

https://github.com/google/heir/issues/1521#issuecomment-2751303404
confirms the issue is fixed by using `alwayslink` on these two targets,
and I confirmed on a separate Apple M1 (OSX version Sequoia 15.3.2.).

I'm not an expert on the mlir runner internals, but given the
mlir-runner is purely for testing, and alwayslink at worst adds some
overhead by not removing symbols, it seems low risk.
2025-04-01 08:58:32 -07:00
Keith Smiley
f30c6a047d
[bazel] Format BUILD files with buildifier (#133802) 2025-03-31 14:38:58 -07:00
Jorge Gorbe Moya
514536731f [bazel] Add missing dep after e4b9486056fab7a262fdafbe70acf393c9767d12 2025-03-31 11:29:09 -07:00
Benjamin Kramer
10dd404d9f [bazel] Make DeltaPasses.def available for fea6b388055284f37852e615fbf5b40a3ba34249 2025-03-30 13:12:18 +02:00
Alexey Samsonov
d724bab806
[libc][bazel] Create a libc_header_library macro for hand-in-hand. (#133131)
Create a proper way to build header-only libraries for llvm-libc code
sharing. Use it to group headers that can be shared with libcxx for
std::from_chars() implementation.

It mostly works, though the macro needs to be updated to enforce that no
.cpp files are listed in dependencies (it's not the case now) - see PR
#133126.
2025-03-26 14:10:41 -07:00
Alexey Samsonov
f0b752e921
[libc][bazel] Stop creatng "public" library targets in libc_function. (#132995)
All downstream users are migrated, so we no longer need to produce
"public"/"release" cc_library target for each libc_function macro
invocation. Instead, we only create internal target (for testing), and
some filegroups, which will be picked up by the libc_release_library
invocation.

This allows us to get rid of "weak" argument to libc_function - this
decision is also postponed to libc_release_library configuration.

Fixes #130327.
2025-03-25 14:38:37 -07:00
Walter Lee
6ddc07163d
Disable some tests on bazel (#132951)
These tests failed at Google after #130757. Disable them in bazel for the time being.
2025-03-25 13:06:20 -04:00
Karlo Basioli
cca9b55f54
Fix bazel test errors caused by #131462 (#132929) 2025-03-25 12:57:09 +00:00
Karlo Basioli
36b36060a1
[mlir][spirv] Fix cyclical dependency in bazel (#132785) 2025-03-25 10:39:04 +00:00
Alexey Samsonov
5a668bdb98
[libc] Migrate sys/epoll tests to use ErrnoCheckingTest. (#132823)
This is similar to PR #132107 but for tests for sys/epoll.h functions.

ErrnoCheckingTest ensures that errno is properly reset at the beginning
of the test case, and is validated at the end of it, so that the manual
code such as the one proposed in PR #131650 would not be necessary.
2025-03-24 13:54:46 -07:00
Karlo Basioli
6c68cc4df1
Fix bazel demangle include error caused by #126688 (#132790) 2025-03-24 17:48:01 +00:00
Karlo Basioli
63e0da45a1
Fix bazel DWARF include error caused by #131645 (#132789) 2025-03-24 17:47:47 +00:00
Jordan Rupprecht
c7e6ee7b9f
[bazel] Port 3aa20c266c97a638c63b5368d89fe25757885178 (#132774) 2025-03-24 11:39:09 -05:00
Karlo Basioli
2f2c02e671
Fix bazel build unique function test caused by #ef3e521 (#132726) 2025-03-24 12:31:16 +00:00
Karlo Basioli
997707172f
Fix blaze build caused by commit #5d8e8e8 (#132719) 2025-03-24 12:04:43 +00:00
Karlo Basioli
ad9630d5ee
Fix bazel build for QuantDialectBytecodeGen (caused by #120172) (#132716) 2025-03-24 11:22:40 +00:00
Harrison Hao
445837a363
[libc][math][c23] Add fmaf16 C23 math function. (#130757)
Implementation of fmaf16 function for 16-bit inputs.
2025-03-23 10:48:56 +08:00
lntue
a17b03f0e4
[libc][math] Implement fast pass for double precision atan function. (#132333)
Implement fast pass for double precision `atan` using range reduction
modulo 1/64 and degree-9 Taylor polynomial.
Relative error is bounded by 2^-66.
2025-03-21 14:12:06 -04:00
Michael Jones
fe6bced9e4
[libc][bazel] fix scanf after #131043 (#132305)
The scanf and fscanf implementations were moved into /generic, update
the bazel targets.
2025-03-20 17:04:45 -07:00
Michael Jones
09ff6db0dc
[bazel] add missing dep to errno_test_helpers (#132278)
Bazel doesn't complain, but downstream it's causing build failures.
2025-03-20 14:13:12 -07:00
Benjamin Kramer
dd3addf954 [bazel] Add missing dependency for ff3341ca35fe4ce05b52e89d654ff4c696d3602e 2025-03-20 19:02:19 +01:00