Commit Graph

2700 Commits

Author SHA1 Message Date
Keith Smiley
a9a891029d [bazel] Fix layering check violation (#137734)
I broke this in 2ce6333a41 since I only
tested with a toolchain that doesn't support layering checks
2025-04-28 16:37:51 -07:00
Keith Smiley
2ce6333a41 [bazel] Fix lldb ODR issue (#137729)
In 42622c7959, depending on the entire
utility library resulted in the lldb binary having more symbols that it
needs, duplicating those in liblldb, leading to odr violations. Now
instead we just expose the Host library's headers, which happens to be
enough for this to compile and link, referencing the symbols from
liblldb
2025-04-28 16:30:54 -07:00
Alexey Samsonov
882bae9f43 [libc][bazel] Make top section of BUILD.bazel files more uniform. (#137689)
Make sure all BUILD.bazel files under llvm-libc are specifying
package-level default_visibility and licenses.

Add top-level license notice and comment to new BUILD.bazel for
complex.h functions.
2025-04-28 12:40:24 -07:00
Jorge Gorbe Moya
4050a6a3d5 [bazel] add missing dep after a74e4ac9d5 2025-04-25 20:29:02 -07:00
Alexey Samsonov
157dfcf531 [libc][bazel] Fix BUILD.bazel after 5ff2774. (#137404)
Add a missing dependency to __support_macros_null_check.
2025-04-25 18:06:30 -04:00
Augie Fackler
119910a8f8 [bazel] catch BUILD files up to d555b9f9a0 in lldb 2025-04-25 13:03:18 -04:00
Sergei Lebedev
6d99d1a4a9 [mlir][bazel] Added a target for the CF dialect C API (#137146) 2025-04-25 06:54:12 +02:00
Keith Smiley
42622c7959 [bazel] Depend on full Utility library in lldb (#137265)
Since 6493345c5a the utility library is
needed by the driver. Since liblldb's exports are limited with
-exports_symbols_list on macOS, some symbols like
`__ZN12SelectHelper10FDSetWriteEi` are not exported from liblldb and
therefore cause linker failures on macOS only. In the cmake the driver
now depends on the full utility library, even though that leads to some
duplication of symbols, so it should be safe for us to do in bazel as
well.
2025-04-24 16:22:56 -07:00
Christian Sigg
e37c236597 [mlir][bazel] Remove unnecessary dependencies. (#136999) 2025-04-24 12:04:37 +02:00
Jorge Gorbe Moya
178cdbf746 [bazel] Add missing deps in mlir/test/BUILD.bazel after 905f1d8068 2025-04-23 18:27:49 -07:00
Jorge Gorbe Moya
adab66f7a5 [bazel] Add missing deps after 905f1d8068 2025-04-23 18:09:25 -07:00
Keith Smiley
a0fce0ba31 [bazel] Use non_arc_srcs instead of passing -fno-objc-arc (#137037)
This is the recommended way in bazel to differentiate between files that
require arc and those that require it be disabled. This matters
depending on the toolchain since the order of these flags may not have
been correct and we were relying on overwriting the default.
2025-04-23 11:37:23 -07:00
Christian Sigg
237ed0cffc [mlir][bazel] Port 0f32809139. 2025-04-23 16:12:55 +02:00
Christian Sigg
dfc60b2ceb [mlir][bazel] Also add SideEffectInterfaces dep to PtrDialect.
Fix for port of e112dcc.
2025-04-23 09:01:45 +02:00
Christian Sigg
439f16a7e1 [mlir][bazel] Port e112dccc8b. 2025-04-23 07:15:38 +02:00
Christian Sigg
7851b1bcf1 [mlir][gpu] Change GPU modules to globals (#135478)
Load/unload GPU modules in global ctors/dtors instead of each time when
launching a kernel.

Loading GPU modules is a heavy-weight operation and synchronizes the GPU
context. Now that the modules are loaded ahead of time, asynchronously
launched kernels can run concurrently, see
https://discourse.llvm.org/t/how-to-lower-the-combination-of-async-gpu-ops-in-gpu-dialect.

The implementations of `embedBinary()` and `launchKernel()` use slightly
different mechanics at the moment but I prefer to not change the latter
more than necessary as part of this PR. I will prepare a follow-up NFC
for `launchKernel()` to align them again.
2025-04-22 13:49:58 +02:00
Christian Sigg
c60f24dca9 [lldb][mlir] Fix port of a22ad65
Sorry, typo!
2025-04-22 13:47:30 +02:00
Christian Sigg
ef926e7e49 [lldb][mlir] Port a22ad659cd 2025-04-22 13:43:50 +02:00
lexi-nadia
1e803770a5 [mlir][SMT] update Bazel configuration to match 697aa99 (#136616)
Update Bazel configuration to match
697aa9995c.
2025-04-21 14:34:34 -07:00
Alexey Samsonov
863ead29e9 [libc][bazel] Add a helper library with all deps of generated headers. (#136582)
Create "public_header_deps" that is a convenient way to express
dependencies of a generated headers as a single (and same) target. It's
also convenient to use it in unit tests - which is also demonstrated in
this PR by adding the BUILD.bazel placeholder for test/include unit
tests, and creating a libc_test target for one of these tests.

See issue #134780.
2025-04-21 13:43:31 -07:00
Rahul Joshi
e1bb7f6dde [LLVM][TableGen] Parameterize NumToSkip in DecoderEmitter (#136456)
- Add command line option `num-to-skip-size` to parameterize the size of
`NumToSkip` bytes in the decoder table. Default value will be 2, and
targets that need larger size can use 3.
- Keep all existing targets, except AArch64, to use size 2, and change
AArch64 to use size 3 since it run into the "disassembler decoding table
too large" error with size 2.
- Additional fixes on top of earlier revert: mark `decodeNumToSkip` as
static (not necessary anymore as the generated code is now in anonymous
namespace, but doing it for consistency) and incorporate Bazel build
changes from https://github.com/llvm/llvm-project/pull/136212
- Following is a rough reduction in size for the decoder tables by
switching to size 2.

```
Target         Old Size   New Size   % Reduction
================================================
AArch64           153254     153254        0.00
AMDGPU            471566     412805       12.46
ARC                 5724       5061       11.58
ARM                84936      73831       13.07
AVR                 1497       1306       12.76
BPF                 2172       1927       11.28
CSKY               10064       8692       13.63
Hexagon            47967      41965       12.51
Lanai               1108        982       11.37
LoongArch          24446      21621       11.56
MSP430              4200       3716       11.52
Mips               36330      31415       13.53
PPC                31897      28098       11.91
RISCV              37979      32790       13.66
Sparc               8331       7252       12.95
SystemZ            36722      32248       12.18
VE                 48296      42873       11.23
XCore               2590       2316       10.58
Xtensa              3827       3316       13.35
```
2025-04-21 08:15:08 -07:00
Christian Sigg
71037ee9de [llvm][bazel] Port 667209e451. 2025-04-20 07:56:05 +02:00
Christian Sigg
a71a2542a1 [clang][bazel] Port d1cce66469 2025-04-19 07:59:43 +02:00
HighW4y2H3ll
ba273be3bd [Bazel] Remove redundant gtest_main from codegen_tests, codegen_globalisel_tests, mi_tests (#135316)
For codegen_tests, codegen_globalisel_tests and mi_tests, they already
have their own `main` function defined, so there should be no need to
add `gtest_main` dependency for the main function...

- codegen_tests:
https://github.com/llvm/llvm-project/blob/main/llvm/unittests/CodeGen/TargetOptionsTest.cpp#L73
- codegen_globalisel_tests:
https://github.com/llvm/llvm-project/blob/main/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp#L978
- mi_tests:
https://github.com/llvm/llvm-project/blob/main/llvm/unittests/MI/LiveIntervalTest.cpp#L933
2025-04-18 10:42:49 -07:00
Christian Sigg
1db03cab70 [mlir][bazel] Port 697aa9995c 2025-04-18 10:31:33 +02:00
Alexey Samsonov
bb67de671e [libc][bazel] Enforce that libc hand-in-hand libs are headers-only. (#136219)
Extend Bazel rule implementation to enforce that all transitive
dependencies of libc_header_library targets (used to implement
hand-in-hand code sharing via headers) indeed only contain header files.

This fixes Bazel portion of PR #133126.
2025-04-17 16:33:38 -07:00
Keith Smiley
1267facdc6 [bazel] Remove duplicate dependency (#136152)
AffineDialect was duplicated in the deps list since
47f4f39265
2025-04-17 09:06:41 -07:00
Zhuoran Yin
47f4f39265 [MLIR][AMDGPU] Fixing word alignment check for bufferload fastpath (#135982)
`delta_bytes % (32 ceilDiv elementBitwidth) != 0` condition is incorrect
in https://github.com/llvm/llvm-project/pull/135014

For example, last load is issued to load only one last element of fp16.
Then `delta bytes = 2`, `(32 ceildiv 16) = 2`. In this case it will be
judged as word aligned. It will send to fast path but get all zeros for
the fp16 because it cross the word boundary.

In reality the equation should be just `delta_bytes % 4` , since a word
is 4 bytes. This PR fix the bug by amending the mod target to 4.
2025-04-17 08:50:31 -04:00
Matthias Springer
23e3cbb2e8 [mlir][Transforms] Delete 1:N dialect conversion driver (#121389)
The 1:N dialect conversion driver has been deprecated. Use the regular
dialect conversion driver instead. This commit deletes the 1:N dialect
conversion driver.

Note for LLVM integration: If you are already using the regular dialect conversion, but still have argument materializations in your code base, simply delete all `addArgumentMaterialization` calls.

For details, see
https://discourse.llvm.org/t/rfc-merging-1-1-and-1-n-dialect-conversions/82513.
2025-04-17 14:37:20 +02:00
NAKAMURA Takumi
de893f87d2 Revert "[bazel] Fix build for 8ebdd9d8a19543992195f197de215c53d506fb72"
This reverts commit f8ea2ed598.
2025-04-17 11:31:30 +09:00
Jorge Gorbe Moya
f8ea2ed598 [bazel] Fix build for 8ebdd9d8a1 2025-04-16 16:18:34 -07:00
Benjamin Chetioui
8c04656c45 [bazel] Fix bazel build after 2b983a2458. (#135976) 2025-04-16 17:19:47 +02:00
Benjamin Chetioui
fe4a31d59d [bazel] Fix bazel build after 00eaff3e9c. (#135949) 2025-04-16 14:29:44 +02:00
Alexey Samsonov
71d091699f [libc][bazel] Fold "libc_function_deps" into "deps" for libc_tests. (#135835)
libc_function_deps and deps are now identical, as we no longer need or
have special treatment for libc_function targets. Merge these attributes
passed to the libc_test macro, and fix all relevant libc_test macro
invocations. This change is a no-op.

This concludes cleanup started in
9b13d34530.
2025-04-15 20:12:17 -07:00
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 90c001ac9e:
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 acf964b95f. 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