1802 Commits

Author SHA1 Message Date
michaelrj-google
7a7d5481ad
[libc] add bazel support for most of unistd (#80078)
Much of unistd involves modifying files. The tests for these functions
need to use libc_make_test_file_path which didn't exist when they were
first implemented. This patch adds most of unistd to the bazel along
with the corresponding tests. Tests that modify directories had to be
disabled since bazel doesn't seem to handle them properly.
2024-02-01 12:54:01 -08:00
Benjamin Kramer
ca7fd25492 [bazel] Fix a typo from e7d40a87ff230528131541f6ac17a2e1a7dc78e1 2024-02-01 11:02:39 +01:00
Benjamin Kramer
395c8175e3 [bazel] Put back the pieces of TableGenGlobalISel that unittests depend on
This is a mess and needs to be cleaned up some day.
2024-02-01 10:56:22 +01:00
Benjamin Kramer
468b23935a [bazel] Merge TableGenGlobalISel into the tablegen target
These two are intertwined enough so it doesn't really make sense to have
it standalone and hack around it by putting headers into both.
2024-02-01 10:41:32 +01:00
Benjamin Kramer
d0dbd50cf0 [bazel] Add missing header for 7ec996d4c5c30083b070be4898140440094e6b97 2024-02-01 10:34:57 +01:00
Marius Brehler
e7d40a87ff
[mlir][EmitC] Add func, call and return operations and conversions (#79612)
This adds a `func`, `call` and `return` operation to the EmitC dialect,
closely related to the corresponding operations of the Func dialect. In
contrast to the operations of the Func dialect, the EmitC operations do
not support multiple results. The `emitc.func` op features a
`specifiers` argument that for example allows, with corresponding
support in the emitter, to emit `inline static` functions.

Furthermore, this adds patterns and a pass to convert the Func dialect
to EmitC. A `func.func` op that is `private` is converted to
`emitc.func` with a `"static"` specifier.
2024-02-01 10:04:36 +01:00
michaelrj-google
0e8eb445db
[libc] Fix read under msan (#80203)
The read function wasn't properly unpoisoning its result under msan,
causing test failures downstream when I tried to roll it out. This patch
adds the msan unpoison call that fixes the issue.
2024-01-31 16:14:49 -08:00
Benjamin Kramer
16c4843d32 [bazel] Add missing header file for 31fc0a12e1552e6bcea63ae740f284eaf74f4c17 2024-01-31 17:52:17 +01:00
Benjamin Kramer
6720e3af25 [bazel] Port 31fc0a12e1552e6bcea63ae740f284eaf74f4c17 2024-01-31 17:45:58 +01:00
Joel Wee
7e45cfda8f [mlir] Fix ab874268f636bdfc83b567429ca2d2483f7cc831 2024-01-31 13:41:36 +00:00
Joel Wee
ab874268f6 Fix after #79152 2024-01-31 13:39:10 +00:00
michaelrj-google
9f3854a01f
[reland][libc] add epoll_wait functions (#79635)
The epoll_wait functions are syscall wrappers that were requested by
upstream users. This patch adds them, as well as their header and types.

The tests are currently incomplete since they require epoll_create to
properly test epoll_wait. That will be added in a followup patch since
this one is already very large.
2024-01-30 10:07:47 -08:00
Joel Wee
fe0d16ff60 [mlir] Fix after #75103 2024-01-30 16:53:19 +00:00
Jeremy Kun
5585ddd90b
[bazel]: de-alias pybind11 headers target (#79676)
In trying to set up python headers in an out-of-tree bazel MLIR project,
I encountered the `pybind11_bazel` project, and found that the
`@python_runtime` target used here is not defined by it.

Instead, it seems that `@python_runtime` is an alias used in some
projects like Tensorflow (see

322936ffdd/third_party/python_runtime/BUILD (L7-L7)),
where it is aliased to `@local_config_python`. In fact,
`@local_config_python` is defined by `@pybind11_bazel`, and so it seems
that this layer of indirection no longer serves a purpose, and instead
just prevents anyone who doesn't clone Tensorflow's config from using
the python bindings here.

This commit updates the dependent targets to their canonical de-aliased
equivalents, and I suspect this will not even break any downstream users
since the new target is defined in those projects already.

Without this change, running, for example

```
bazel build @llvm-project//mlir:MLIRBindingsPythonCore
```

gives the error

```
no such package '@python_runtime//': The repository '@python_runtime'
could not be resolved: Repository '@python_runtime' is not defined and
referenced by '@llvm-project//mlir:MLIRBindingsPythonCore'
```

Minimal reproduction in https://github.com/j2kun/test_mlir_bazel_pybind,
which, when pointing to a local LLVM repository that has this change
(see `bazel/import_llvm.bzl` in that repository), results in that build
succeeding.

Hat tip to Maksim Levental for going on an hours-long investigation with
me to figure this out.
2024-01-26 23:27:21 -06:00
Danial Klimkin
f07eb24bb0
Minor bazel file cleanup (#79607)
this excluded file is gone.
2024-01-26 16:32:24 +01:00
Danial Klimkin
c64c789fb4
Revert "Fix bazel build past 3fdb431b636975f2062b1931158aa4dfce6a3ff1… (#79601)
… (#79599)"

This reverts commit e0e216099505bc5051ba53b2fdb8202cdde5f47e.
2024-01-26 15:47:46 +01:00
Danial Klimkin
e0e2160995
Fix bazel build past 3fdb431b636975f2062b1931158aa4dfce6a3ff1 (#79599) 2024-01-26 15:29:27 +01:00
Danial Klimkin
659a217b91
Fix bazel deps on ilogb_test_template (#79577) 2024-01-26 12:26:01 +01:00
MaheshRavishankar
76ead96c1d
[mlir][TilingInterface] Use LoopLikeOpInterface in tiling using SCF to unify tiling with scf.for and scf.forall. (#77874)
Using `LoopLikeOpInterface` as the basis for the implementation unifies
all the tiling logic for both `scf.for` and `scf.forall`. The only
difference is the actual loop generation. This is a follow up to
https://github.com/llvm/llvm-project/pull/72178
Instead of many entry points for each loop type, the loop type is now
passed as part of the options passed to the tiling method.

This is a breaking change with the following changes

1) The `scf::tileUsingSCFForOp` is renamed to `scf::tileUsingSCF`
2) The `scf::tileUsingSCFForallOp` is deprecated. The same
   functionality is obtained by using `scf::tileUsingSCF` and setting
   the loop type in `scf::SCFTilingOptions` passed into this method to
   `scf::SCFTilingOptions::LoopType::ForallOp` (using the
   `setLoopType` method).
3) The `scf::tileConsumerAndFusedProducerGreedilyUsingSCFForOp` is
   renamed to `scf::tileConsumerAndFuseProducerUsingSCF`. The use of
   the `controlFn` in `scf::SCFTileAndFuseOptions` allows implementing
   any strategy with the default callback implemeting the greedy fusion.
4) The `scf::SCFTilingResult` and `scf::SCFTileAndFuseResult` now use
   `SmallVector<LoopLikeOpInterface>`.
5) To make `scf::ForallOp` implement the parts of
   `LoopLikeOpInterface` needed, the `getOutputBlockArguments()`
   method is replaced with `getRegionIterArgs()`

These changes now bring the tiling and fusion capabilities using
`scf.forall` on par with what was already supported by `scf.for`
2024-01-25 21:26:23 -08:00
michaelrj-google
59e90609d2
Revert "[libc] add epoll_wait functions" (#79534)
Reverts llvm/llvm-project#79515

Some minor breakages. Will fix tomorrow.
2024-01-25 17:05:56 -08:00
michaelrj-google
edb720666f
[libc] add epoll_wait functions (#79515)
The epoll_wait functions are syscall wrappers that were requested by
upstream users. This patch adds them, as well as their header and types.

The tests are currently incomplete since they require epoll_create to
properly test epoll_wait. That will be added in a followup patch since
this one is already very large.
2024-01-25 17:03:18 -08:00
Augie Fackler
97ace00a56 bazel: fix build past 184ca39529a93e69eb175861d7fff5fc79988e53 2024-01-25 13:08:34 -05:00
michaelrj-google
a621198a03
[libc] Move printf long double to simple calc (#75414)
The Ryu algorithm is very fast with its table, but that table grows too
large for long doubles. This patch adds a method of calculating the
digits of long doubles using just wide integers and fast modulo
operations. This results in significant performance improvements vs the
previous int calc mode, while taking up a similar amound of peak memory.
It will be slow in some %e/%g cases, but reasonable fast for %f with no
loss of accuracy.
2024-01-25 09:35:40 -08:00
Danial Klimkin
3490f037c3
More bazel fixes past 72ce6294157964042b7ed5576ce2c99257eeea9d (#79442) 2024-01-25 14:09:37 +01:00
Danial Klimkin
f9dc0b6c8a
Fix bazel build past 3fdb431b636975f2062b1931158aa4dfce6a3ff1 (#79429) 2024-01-25 10:52:29 +01:00
Danial Klimkin
50cc07f1bc
Fix bazel build past 72ce6294157964042b7ed5576ce2c99257eeea9d (#79424) 2024-01-25 10:17:03 +01:00
Mircea Trofin
123c83ddc7
[mlgo] bazel rules for mlgo-utils (#79217)
Akin the `py_binary` rules for `lit`, these are scoped to binaries,
rather than exposing the library - binary split. The latter is available
to the package (pip package) users.

Tested:

```
cd utils/bazel
bazel build @llvm-project//llvm:extract_ir
bazel-bin/external/llvm-project/llvm/extract_ir --help
```
...and observed expected output (rather than import not found errors)

(Same for the other 2 targets).
2024-01-24 11:04:06 -08:00
Nico Weber
3135984024 Reland "[CMake/Bazel] Support usage of opt driver as a library (#79205)"
This reverts commit be08be5d5de97cd593fb99affa1fa994d104eb70.
The build error was due to a different change, apologies!
2024-01-24 13:57:07 -05:00
Nico Weber
be08be5d5d Revert "[CMake/Bazel] Support usage of opt driver as a library (#79205)"
This reverts commit 32f7922646d5903f63d16c9fbfe3d508b0f8cda7.

Doesn't build, see
https://github.com/llvm/llvm-project/pull/79205#issuecomment-1908730527
2024-01-24 13:52:10 -05:00
William Moses
32f7922646
[CMake/Bazel] Support usage of opt driver as a library (#79205)
In Bazel, Clang current separates the clang executable into a
clang-driver library, and the actual clang executable. This allows
downstream users to make their own variations of clang, without having
to redo/maintain separate build pipelines.

This adds the same for opt for both CMake and Bazel.
2024-01-24 13:39:27 -05:00
Christian Sigg
4079aab8d8
[llvm][bazel] Fix BUILD 2024-01-24 17:36:37 +01:00
Christian Sigg
611843d24b
[llvm][bazel] Fix BUILD. 2024-01-24 17:31:27 +01:00
Danial Klimkin
56aa77e119
Fix bazel build past 4a582845597e97d245e8ffdc14281f922b835e56 (#79318)
and keep things sorted.
2024-01-24 17:17:17 +01:00
Christian Sigg
8d43dad9b8
[clang][bazel] Fix BUILD after 4a582845597e97d245e8ffdc14281f922b835e56. 2024-01-24 16:54:22 +01:00
Christian Sigg
31f41f0984 [clang][bazel] Fix BUILD after 4a582845597e97d245e8ffdc14281f922b835e56. 2024-01-24 16:36:34 +01:00
Danial Klimkin
d1b473c795
Fix bazel build past 7251243315ef66f9b3f32e6f8e9536f701aa0d0a (#79282)
Fix bazel build past 7251243315ef66f9b3f32e6f8e9536f701aa0d0a
2024-01-24 14:06:14 +01:00
Adrian Kuegel
34466019e7 [mlir][Bazel] Add missing dependency after 750e90e4403df23d6b271afb90e6b4d463739965 2024-01-24 08:20:08 +00:00
Anlun Xu
d922c82447 [Blaze] Fix build file 2024-01-22 15:45:04 -08:00
Nick Desaulniers
1d5c16d780
[libc] default enable -ftrivial-auto-var-init=pattern (#78776)
Usage of uninitialized memory is a top memory safety issue in C++ codebases.
Help mitigate this somewhat by default initialize stack allocations to a
pattern (0xAA repeating).

Clang has received optimizations to sink these into control flow paths that
access such values to minimize the overhead of these added initializations.

If there's a measurable slowdown, we can add
-ftrivial-auto-var-init-max-size=<N> for some value N bytes if we have any
large stack allocations, or add attribute uninitialized to any variable
declarations.

Unsupported until GCC 12.1 / Clang 8.

Increases file size of libc.a from a full build by +8.79Ki (+0.2%).
2024-01-22 14:55:51 -08:00
Matthew Devereau
312acdfae1
[AArch64][SME] Take arm_sme.h out of draft (#78961) 2024-01-22 17:12:16 +00:00
Christian Sigg
cc38cff05c [mlir][bazel] Fix BUILD after 9f7fff7f1391ea3bec394d8251b81cea92175cca. 2024-01-22 11:39:48 +01:00
Jeremy Kun
ddad7e3097
[mlir][amdgpu] Fix bazel build (#78820)
Broken by
b7360fbe8c
2024-01-19 16:31:08 -08:00
Jeremy Kun
76ffa8f63a
[mlir][transform]: fix broken bazel build for TensorTransformOps (#78766) 2024-01-19 20:33:36 +01:00
Jeremy Kun
2521e9785d
[mlir][transform]: fix broken bazel build (#78757)
Broken by
42b160356f
2024-01-19 19:55:43 +01:00
Guillaume Chatelet
508c6aa8f3
[libc][NFC] Fix "type qualifiers ignored on cast result type" GCC warning (#78509)
GCC complains about "type qualifiers ignored on cast result type".
Upon investigation the correct fix was to remove all `volatile` and use the `-frounding-math` option.
2024-01-19 09:27:03 +01:00
denglesberg-splunk
3b54337be5
Replace exec_tools with tools in bazel genrule. (#77510)
As of the Bazel 6.x series, there is no difference between the
`exec_tools` and `tools`. Bazel 7 removes the `exec_tools` attribute
entirely. This commit updates to use the cannonical attribute name to
allow building `clang-tidy``with bazel 7.0.0, though it does not change
the default bazel version which remains at 6.1.2.

See also https://github.com/bazelbuild/bazel/issues/19132 for more
information.
2024-01-19 09:12:54 +01:00
Guillaume Chatelet
5ddd7bc38c
[reland][libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (#78465)
- [reland] #78192 
- [reland] #78447 
- Turn `as` static function into a `to_storage_type` member function.
2024-01-17 17:38:48 +01:00
Dmitry Chernenkov
58564ddf5c [bazel]Sort loads in llvm/BUILD.bazel 2024-01-17 16:04:40 +00:00
Guillaume Chatelet
d8627cb138
Revert "[reland][libc][NFC] Refactor FPBits and remove LongDoubleBits specialization" (#78457)
Reverts llvm/llvm-project#78447
This broke the gcc buildbot.
2024-01-17 16:50:52 +01:00
Guillaume Chatelet
cab041fe63
[reland][libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (#78447)
- [reland] #78192
- Make the implementation work when `__uint128_t` is not available on
the plaftorm.
2024-01-17 16:15:09 +01:00