14183 Commits

Author SHA1 Message Date
Rahul Joshi
d7da79f2cd
[NFC][SetTheory] Refactor to use const pointers and range loops (#105544)
- Refactor SetTheory code to use const pointers when possible.
- Use auto for variables initialized using dyn_cast<>.
- Use range based for loops and early continue.
2024-08-22 05:47:31 -07:00
Martin Storsjö
51ca2354d0
[lit] Fix substitutions containing backslashes (#103042)
Substitutions can be added in a couple different ways; they can be added
via the calling python scripts by adding entries to the
config.substitutions dictionary, or via DEFINE lines in the scripts
themselves.

The substitution strings passed to Python's re classes are interpreted
so that backslashes expand to escape sequences, and literal backslashes
need to be escaped.

On Unix, the script defined substitutions don't (usually, so far)
contain backslashes - but on Windows, they often do, due to paths
containing backslashes. This lead to a Windows specific escaping of
backslashes before doing Python re substitutions - since
7c9eab8fef0ed79a5911d21eb97b6b0fa9d39f82. There's nothing inherently
Windows specific about this though - any intended literal backslashes in
the substitution strings need to be escaped; this is how the Python re
API works.

The DEFINE lines were added later, and in order to cope with
backslashes, escaping of backslashes was added in the SubstDirective
class in TestRunner, applying to DEFINE lines in the tests only.

The fact that the escaping right before passing to the Python re API was
done conditionally on Windows led to two inconsistencies:

- DEFINE lines in the tests that contain backslashes got double
backslashes on Windows. (This was visible as a FIXME in
llvm/utils/lit/tests/Inputs/shtest-define/value-escaped.txt.)

- Script provided substitutions containing backslashes did not work on
Unix, but they did work on Windows.

By removing the escaping from SubstDirective and escaping it
unconditionally in the processLine function, before feeding the
substitutions to Python's re classes, we should have consistent
behaviour across platforms, and get rid of the FIXME in the lit test.

This fixes issues with substitutions containing backslashes on Unix
platforms, as encountered in PR #86649.
2024-08-22 12:57:39 +03:00
Rahul Joshi
9ebe8b9abd
[NFC][TableGen] Change global variables from anonymous NS to static (#105504)
- Move global variables in TableGen.cpp out of anonymous namespace and
make them static, per LLVM coding standards.
2024-08-21 15:27:00 -07:00
LLVM GN Syncbot
47e0212f00 [gn build] Port a6bae5cb3791 2024-08-21 18:11:13 +00:00
Nico Weber
8d4891591f [gn] port 7ad7f8f7a3d4 2024-08-21 10:35:10 -04:00
LLVM GN Syncbot
2644fe4858 [gn build] Port 0cff3e85db00 2024-08-21 11:28:32 +00:00
LLVM GN Syncbot
6b8c194f85 [gn build] Port 6c189eaea994 2024-08-21 09:03:31 +00:00
LLVM GN Syncbot
25ffd2efb3 [gn build] Port 7c4cadfc4333 2024-08-21 07:57:15 +00:00
LLVM GN Syncbot
d9b6e9f1c1 [gn build] Port c8a678b1e486 2024-08-21 02:33:50 +00:00
LLVM GN Syncbot
64d75bd100 [gn build] Port 55d744eea361 2024-08-21 02:33:50 +00:00
Nico Weber
04ebae907a [gn] tblgen opts for llvm-cgdata
This should have been part of 5ec73b7dcf7f232.
2024-08-20 22:15:03 -04:00
Nico Weber
5ec73b7dcf Reland "[gn build] Port d3fb41dddc11 (llvm-cgdata)"
This reverts commit 6476a1d6865fc3a4c0fa3e436174a9a99a6ffedb.
d3fb41dddc11 relanded in 9bb555688caf6a.

...amended to incorporate changes from the reland.
2024-08-20 21:33:05 -04:00
Rahul Joshi
389f339c11
[TableGen] Rework EmitIntrinsicToBuiltinMap (#104681)
Rework `IntrinsicEmitter::EmitIntrinsicToBuiltinMap` for improved
    peformance as well as refactor the code.

    Performance:
    - Current generated code does a linear search on the TargetPrefix,
      followed by a binary search on the builtin names for that
      target's builtins.
    - Improve the performance of this code in 2 ways:
      (a) Use binary search on the target prefix to lookup the builtin
          table for the target.
      (b) Improve the (common) case of when all builtins for a target
          share a common prefix.  Check this common prefix first, and
then do the binary search in the builtin table using the builtin
          name with the common prefix removed. This should help
          both data size (by creating a smaller static string table) and
          runtime (by reducing the cost of binary search on smaller
          strings).

    Refactor:
    - Use range based for loops for iterating over maps.
- Use formatv() and C++ raw string literals to simplify the emission
code.
    - Change the generated `getIntrinsicForClangBuiltin` and 
      `getIntrinsicForMSBuiltin`  to take a `StringRef` instead of 
      `const char *` for the prefix.
2024-08-20 14:22:48 -07:00
Connie Zhu
349d76d490
[llvm-lit][test] Updated built-in cat command tests (#104473)
This patch makes changes to improve syntax in tests and to add more
strict checks on cat output. This is a prequisite for
https://github.com/llvm/llvm-project/pull/101530.
2024-08-20 11:50:50 -07:00
Fangrui Song
7c06786479
[CMake] Remove HAVE_LINK_H
We can remove the variable from https://reviews.llvm.org/D5610 since
link.h is available on Linux (glibc/musl/Bionic), FreeBSD, and NetBSD.
Use `__has_include(<link.h>)` before including it.

Pull Request: https://github.com/llvm/llvm-project/pull/104893
2024-08-20 08:50:24 -07:00
LLVM GN Syncbot
21de04918e [gn build] Port 42067f26cd08 2024-08-20 10:57:39 +00:00
David Spickett
5adbce072c [llvm][GitHub] Fix formatting of new contributor comments
GitHub won't reflow the text unless we put it all on one line.

If we try to make our own paragrpahs it comes out too narrow or
too wide.
2024-08-20 09:26:09 +00:00
Justin Bogner
f357fe371d
[DirectX] Disentangle DXIL.td's op types from LLVMType. NFC
LLVMType is both too broad and too narrow for defining DXIL operations, in
different ways. It's too broad in the sense that we don't need the full set of
MVTs - the set of types DXIL operations work on is much smaller. It's too
narrow in the sense that it's difficult to use it for the various fixed
structure types in DXIL, like `%dx.types.Handle` or `%dx.Types.ResRet.f32`.

Replace the usage of LLVMType in DXIL.td with DXILOpParamType, a simple class
that we can define an enum of types from. Further, use this to replace the
"ParameterKind" enum in DXILABI.h that has nothing to do with DXIL's ABI.

Pull Request: https://github.com/llvm/llvm-project/pull/104247
2024-08-19 10:09:46 -07:00
LLVM GN Syncbot
c6d6186b58 [gn build] Port a56663591573 2024-08-19 15:53:48 +00:00
LLVM GN Syncbot
fade54ac66 [gn build] Port a449b857241d 2024-08-19 15:53:47 +00:00
LLVM GN Syncbot
a28c202442 [gn build] Port 0d150db214e2 2024-08-18 16:47:14 +00:00
LLVM GN Syncbot
addeb22f10 [gn build] Port 27a62ec72aed 2024-08-18 01:34:59 +00:00
Tomas Matheson
362142c4bb
[AArch64] Add a check for invalid default features (#104435)
This adds a check that all ExtensionWithMArch which are marked as
implied features for an architecture are also present in the list of
default features. It doesn't make sense to have something mandatory but
not on by default.

There were a number of existing cases that violated this rule, and some
changes to which features are mandatory (indicated by the Implies
field).

This resulted in a bug where if a feature was marked as `Implies` but
was not added to `DefaultExt`, then for `-march=base_arch+nofeat` the
Driver would consider `feat` to have never been added and therefore
would do nothing to disable it (no `-target-feature -feat` would be
added, but the backend would enable the feature by default because of
`Implies`). See
clang/test/Driver/aarch64-negative-modifiers-for-default-features.c.

Note that the processor definitions do not respect the architecture
DefaultExts. These apply only when specifying `-march=<some architecture
version>`. So when a feature is moved from `Implies` to `DefaultExts` on
the Architecture definition, the feature needs to be added to all
processor definitions (that are based on that architecture) in order to
preserve the existing behaviour. I have checked the TRMs for many cases
(see specific commit messages) but in other cases I have just kept the
current behaviour and not tried to fix it.
2024-08-17 13:36:40 +01:00
LLVM GN Syncbot
0e4f7c7207 [gn build] Port 7ff377ba60bf 2024-08-16 19:34:46 +00:00
Kendal Harland
9f89d31d51
[lldb][test] Mark gtest cases as XFAIL if the test suite is XFAIL (#102986)
When a test case inside of a gtest suite fails, we report a failure
which causes the entire `ninja check-lldb` invocation to fail, even if
the outer test case is marked as XFAIL - each test case result is
reported as its own lit test run. This PR updates lit so it checks
whether each test case's parent test suite is XFAIL before setting the
status to FAIL.

This is especially problematic because the failing tests can't manually
be marked as XFAIL, due to
https://github.com/llvm/llvm-project/issues/102264.

Fixes https://github.com/llvm/llvm-project/issues/102265

### Repro instructions

1. Modify any gtest test case to generate a failure.
2. Mark the outer lit test with XFAIL using either `--xfail-tests` flag
or `LIT_XFAIL` env var.
3. Run the tests
4. Observe the lit test is XFAIL as expected, but the failed child test
cases show up as separate failures.

Co-authored-by: kendal <kendal@thebrowser.company>
2024-08-16 10:54:25 -07:00
Rahul Joshi
ddda37a6c7
[TableGen] Refactor Intrinsic handling in TableGen (#103980)
CodeGenIntrinsic changes:
  - Use `const` Record pointers, and `StringRef` when possible.
  - Default initialize several fields with their definition instead of in
 the constructor.
- Simplify various string checks in the constructor using StringRef
starts_with()/ends_with() functions.
- Eliminate first argument to `setDefaultProperties` and use `TheDef`
class member instead.

IntrinsicEmitter changes:
  - Emit `namespace llvm::Intrinsic` instead of nested namespaces.
  - End generated comments with a .
  - Use range based for loops, and early continue within loops.
  - Emit `static constexpr` instead of `static const` for arrays.
- Change `compareFnAttributes` to use std::tie() to compare intrinsic
attributes and return a default value when all attributes are equal.

STLExtras:
  - Add std::replace wrapper which takes a range.
2024-08-16 09:26:57 -07:00
Craig Topper
ce88ca928a
[TableGen] Sign extend constants based on size for EmitIntegerMatcher. (#104550)
I'm planning to add a getSignedConstant to SelectionDAG and use it for
EmitInteger in SelectionDAGISel which already uses int64_t.
getSignedConstant will assert that the constant has the correct number
of significant bits for the VT.

This patch ensures that tablegen emits constants in this form.
2024-08-16 08:43:54 -07:00
Fangrui Song
82fe79357f [gn] Port AST/ByteCode #104552 2024-08-16 08:43:02 -07:00
LLVM GN Syncbot
4695c16a62 [gn build] Port 3e1d4ec671c5 2024-08-16 00:17:51 +00:00
LLVM GN Syncbot
7ab2d504a1 [gn build] Port 47721d46187f 2024-08-15 18:26:52 +00:00
pcc
564efe2674
utils/git: Add linkify script.
This script linkifies (i.e. makes clickable in the terminal) text that appears
to be a pull request or issue reference (e.g. #12345 or PR12345) or a
40-character commit hash (e.g. abc123). You can configure git to automatically
send the output of commands that pipe their output through a pager, such as
`git log` and `git show`, through this script by running this command from
within your LLVM checkout:

git config core.pager 'llvm/utils/git/linkify | pager'

The pager command is run from the root of the repository even if the git
command is run from a subdirectory, so the relative path should always work.

It requires OSC 8 support in the terminal. For a list of compatible terminals,
see https://github.com/Alhadis/OSC8-Adoption

Reviewers: MaskRay

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/103496
2024-08-14 17:25:28 -07:00
Harini0924
e9b7983fc6
[llvm-lit] Fix Unhashable TypeError when using lit's internal shell (#101590)
When using the lit internal shell with the command:
```
LIT_USE_INTERNAL_SHELL=1 ninja check-compiler-rt
```
The follow error is encountered:
```
File "TestRunner.py", line 770, in _executeShCmd
    inproc_builtin = inproc_builtins.get(args[0], None)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'GlobItem'
```
This error is in a compiler-rt file:
```
TestCases/Linux/long-object-path.cpp
```
This error occurs because `args[0]` is of type `GlobItem`, which is not
hashable, leading to a `TypeError` when it is passed in
`inproc_builtins.get()`. To resolve this issue, I have updated the
implementation to ensure that `args[0]` is hashable before it is used in
`inproc_builtins`.
fixes: #102389
[link to
RFC](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
2024-08-14 14:49:19 -07:00
Connie
4bac8fd890
[llvm-lit][test][NFC] Moved cat command tests into separate lit test file (#102366)
This patch separates the lit tests that check for the functionality of
lit's built-in cat command into its own test file and folder. This is a
prerequisite for https://github.com/llvm/llvm-project/pull/101530.
2024-08-14 14:45:02 -07:00
LLVM GN Syncbot
cba9166c0f [gn build] Port 486adc500c8e 2024-08-14 13:33:42 +00:00
Donát Nagy
340be6cb79
[analyzer] Delete alpha.security.MallocOverflow (#103059)
...because it is too noisy to be useful right now, and its architecture
is terrible, so it can't act a starting point of future development.

The main problem with this checker is that it tries to do (or at least
fake) path-sensitive analysis without actually using the established
path-sensitive analysis engine.

Instead of actually tracking the symbolic values and the known
constraints on them, this checker blindly gropes the AST and uses
heuristics like "this variable was seen in a comparison operator
expression that is not a loop condition, so it's probably not too large"
(which was improved in a separate commit to at least ignore comparison
operators that appear after the actual `malloc()` call).

This might have been acceptable in 2011 (when this checker was added),
but since then we developed a significantly better standard approach for
analysis and this old relic doesn't deserve to remain in the codebase.

Needless to say, this primitive approach causes lots of false positives
(and presumably false negatives as well), which ensures that this alpha
checker won't be missed by the users.

Moreover, the goals of this checker would be questionable even if it had
a perfect implementation. It's very aggressive to assume that the
argument of malloc can overflow by default (unless the checker sees a
bounds check); and this produces too many false positives -- perhaps
even for an optin checker. It may be possible to eventually create a
useful (and properly path-sensitive) optin checker for these kinds of
suspicious code, but this is a very low priority goal.

Also note that we already have `alpha.security.TaintedAlloc` which
provides more practical heuristics for detecting somewhat similar
"argument of malloc may be too large" vulnerabilities.
2024-08-14 15:07:42 +02:00
LLVM GN Syncbot
f5ba3f6740 [gn build] Port 2d53f0aab785 2024-08-13 07:18:54 +00:00
LLVM GN Syncbot
f8f34c7e49 [gn build] Port 80525dfcde5b 2024-08-13 00:45:34 +00:00
LLVM GN Syncbot
d5849af68e [gn build] Port 03e6675fc787 2024-08-12 18:00:25 +00:00
LLVM GN Syncbot
d1957dda16 [gn build] Port d2336fd75cc9 2024-08-11 15:26:55 +00:00
Tobias Hieta
f3e950a2fe
[Utils] Add new merge-release-pr.py script. (#101630)
This script helps the release managers merge backport PR's.

It does the following things:

* Validate the PR, checks approval, target branch and many other things.
* Rebases the PR
* Checkout the PR locally
* Pushes the PR to the release branch
* Deletes the local branch

I have found the script very helpful to merge the PR's.
2024-08-10 21:02:38 +02:00
Rahul Joshi
8a61bfcf8f
[NFC] Fix TableGen include guards to match paths (#102746)
- Fix include guards for headers under utils/TableGen to match their
paths.
2024-08-10 17:35:03 +03:00
Kazu Hirata
e9a47a664a
[llvm] Construct SmallVector with ArrayRef (NFC) (#102712)
Without this patch, the constructor arguments come from
SmallVectorImpl, not ArrayRef.  This patch switches them to ArrayRef
so that we can construct SmallVector with a single argument.

Note that LLVM Programmer’s Manual prefers ArrayRef to SmallVectorImpl
for flexibility.
2024-08-09 21:39:13 -07:00
Samira Bazuzi
e5697d7f99
Return available function types for BindingDecls. (#102196)
Only return nullptr when we don't have an available QualType.
2024-08-09 21:09:55 +02:00
Joel E. Denny
1ea0865dd6
[Clang] Add env var for nvptx-arch/amdgpu-arch timeout (#102521)
When working on very busy systems, check-offload frequently fails many
tests with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: /tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via '-march'
```

This patch accepts the environment variable
`CLANG_TOOLCHAIN_PROGRAM_TIMEOUT` to set the timeout. It also increases
the timeout from 10 to 60 seconds.
2024-08-09 13:39:29 -04:00
Nico Weber
f4d5b14dcc [gn] Give two scripts argparse.RawDescriptionHelpFormatter
Without this, the doc string is put in a single line. These
scripts have multi-line docstrings, so this makes their --help
output look much nicer.

Otherwise, no behavior change.
2024-08-09 11:10:12 -04:00
Juan Manuel Martinez Caamaño
d38bae3c77
[update_llc_test_checks][AMDGPU] Update AMDGPU regexp in update_llc_test_checks.py (#102480)
Updating `llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll` with
`update_llc_test_checks.py` ended with several kernels with no checks.

Llc's output contained the line ".amdgpu_hsa_kernel <funcname>" after
the ".type <funcname>,@function" entry which was not considered by the
regexp.
2024-08-09 09:33:31 +02:00
LLVM GN Syncbot
9428631d76 [gn build] Port 8acf8852e9d4 2024-08-08 23:33:12 +00:00
hev
b2e69f52bb
[LoongArch] Add machine function pass to merge base + offset (#101139)
This commit references RISC-V to add a machine function pass to merge
the base address and offset.
2024-08-08 23:05:38 +08:00
Jerry Zhang Jian
b24737d3ac
[NFC][RISCV] use OS.indent() to replace spaces (#102429) 2024-08-08 23:04:39 +08:00
LLVM GN Syncbot
42937b6f8e [gn build] Port e80d8e1b421b 2024-08-08 06:19:53 +00:00