473961 Commits

Author SHA1 Message Date
Yaxun (Sam) Liu
9b7763821a
Reland "[CUDA][HIP] Fix overloading resolution in global var init" (#65606)
https://reviews.llvm.org/D158247 caused regressions for HIP on Windows
and was reverted.

A reduced test case is:

```
typedef void (__stdcall* funcTy)();
void invoke(funcTy f);

static void __stdcall callee() noexcept {
}

void foo() {
   invoke(callee);
}
```

It is due to clang missing handling host/device attributes for calling
convention at a few places

This patch fixes that.
2023-09-07 23:18:30 -04:00
Jianjian GUAN
4d2536c82f [RISCV] Enable more builtin for zvfhmin without zvfh
This patch enables some fp16 vector type builtins that don't use fp arithmetic instruction for zvfhmin without zvfh.
Include following builtins:
  vector load/store,
  vector reinterpret,
  vmerge_vvm,
  vmv_v.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D151869
2023-09-08 10:55:17 +08:00
Vitaly Buka
edb211cb78 [NFC][sanitizer] Add a few missed RTSanitizerCommonSymbolizerInternal 2023-09-07 19:36:10 -07:00
Vitaly Buka
4d14b4a872 [sanitizer] Add CMake flag to build with internal symbolizer
This intermediate result in moving internal symbolizer build
from sh script to CMake rules.

The flag is supposed to be used with:
-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" -DLLVM_ENABLE_RUNTIMES="libunwind;libcxx;libcxxabi" -Sllvm-project/llvm

After converting sh script into cmake, we may add support for other build modes.

For https://github.com/llvm/llvm-project/issues/30098

Reviewed By: kstoimenov, MaskRay

Differential Revision: https://reviews.llvm.org/D157947
2023-09-07 19:34:21 -07:00
XinWang10
99fb65fa7a
[NFC]Add assert to avoid possibly deref nullptr (#65564)
These 2 functions could be called by AsmPrinter::doInitialization in
AsmPrinter.cpp. doInitialization init MMI in the beginning`MMI = MMIWP ?
&MMIWP->getMMI() : nullptr;`, MMI has the possibility to be nullptr,
which could make the later deref crash. I think in most time MMI could
not be nullptr, but from the view of function implementation, it could
be, so I'd like to add assert to it, if this could be a problem, then we
could avoid crash.
2023-09-08 10:10:09 +08:00
Amy Kwan
23f144ec1c [NFC] Add extra documentation for GetSymbolFromOperand() in PPCMCInstLower.cpp
Add a missing comment from D155600, where we note that we get the symbol
from a global, due to XCOFF-specific intricacies.
2023-09-07 21:01:28 -05:00
Philip Reames
463c9f44dc [RISCV] Move slide and gather costing to TLI [NFC] (PR #65396)
As mentioned in TODOs from D159332.  This PR doesn't actually
common up that copy of the code because doing so is not NFC - due to
DLEN.  Fixing that will be a future PR.
2023-09-07 18:28:17 -07:00
NAKAMURA Takumi
dbd548d062 [Bazel] Update "basic_attr_gen" (D141714, 46f3ade5083b) 2023-09-08 10:17:58 +09:00
Amy Kwan
b1922e55ab [AIX][TLS][clang] Add -maix-small-local-exec-tls clang option.
This patch adds the clang portion of an AIX-specific option to inform
the compiler that it can use a faster access sequence for the local-exec
TLS model (formally named aix-small-local-exec-tls).

This patch only adds the frontend portion of the option, building upon:

Backend portion of the option (D156203)
Backend patch that utilizes this option to actually produce the faster access sequence (D155600)

Differential Revision: https://reviews.llvm.org/D155544
2023-09-07 20:05:29 -05:00
Amy Kwan
3f46e5453d [AIX][TLS] Produce a faster local-exec access sequence with -maix-small-local-exec-tls (And optimize when load/store offsets are 0)
This patch utilizes the -maix-small-local-exec-tls option added in
D155544 to produce a faster access sequence for the local-exec TLS
model, where loading from the TOC can be avoided.

The patch either produces an addi/la with a displacement off of r13
(the thread pointer) when the address is calculated, or it produces an
addi/la followed by a load/store when the address is calculated and
used for further accesses.

This patch also optimizes this sequence a bit more where we can remove
the addi/la when the load/store offset is 0. A follow up patch will
be posted to account for when the load/store offset is non-zero, and
currently in these situations we keep the addi/la that precedes the
load/store.

Furthermore, this access sequence is only performed for TLS variables
that are less than ~32KB in size.

Differential Revision: https://reviews.llvm.org/D155600
2023-09-07 20:05:29 -05:00
Amy Kwan
8bdbee8aaa [AIX][TLS] Add target attribute for -maix-small-local-exec-tls option.
This patch adds a target attribute for an AIX-specific option that
informs the compiler that it can use a faster access sequence for the
local-exec TLS model (formally named aix-small-local-exec-tls).

The Clang portion of this option is in D155544.
The initial implementation to generate the faster access sequence is in
D155600.

Differential Revision: https://reviews.llvm.org/D156203
2023-09-07 20:05:29 -05:00
Brad Smith
7e31b45d6a
[OpenMP] Use the more appropriate function to retrieve the thread id on OpenBSD (#65553)
Use the getthrid() function instead of a syscall.
2023-09-07 21:05:25 -04:00
Vitaly Buka
2f183d6efb [test][hwasan] Try to deflake release-shadow.c 2023-09-07 17:55:03 -07:00
Jan Svoboda
3b1a68655e
[clang][deps] Generate command lines lazily (#65691)
This patch makes the generation of command lines for modular
dependencies lazy/on-demand. That operation is somewhat expensive and
prior to this patch used to be performed multiple times for the
identical `ModuleDeps` (i.e. when they were imported from multiple
different TUs).
2023-09-07 17:45:53 -07:00
Marc Auberer
904ac6fe6b [InstCombine] Fold ((A&B)^A)|((A&B)^B) to A^B
Depends on D159379

((A & B) ^ A) | ((A & B) ^ B) -> A ^ B
(A ^ (A & B)) | (B ^ (A & B)) -> A ^ B
((A & B) ^ B) | ((A & B) ^ A) -> A ^ B
(B ^ (A & B)) | (A ^ (A & B)) -> A ^ B

Alive2: https://alive2.llvm.org/ce/z/i44xmq
Baseline tests: https://reviews.llvm.org/D159379

Reviewed By: huihuiz

Differential Revision: https://reviews.llvm.org/D159380
2023-09-07 17:33:06 -07:00
Amir Ayupov
04a6dc24db
[BOLT][test] Fix patch-entries for aarch64 buildbot (#65690) 2023-09-07 17:09:45 -07:00
Marc Auberer
4bbc9034d6 [InstCombine] Baseline tests for folding ((A&B)^A)|((A&B)^B) to A^B
Baseline tests for: https://reviews.llvm.org/D159380

Reviewed By: huihuiz

Differential Revision: https://reviews.llvm.org/D159379
2023-09-07 17:03:49 -07:00
Jie Fu
9168fcacd8 [flang] Fix -Wcovered-switch-default in resolve-directives.cpp (NFC)
/data/llvm-project/flang/lib/Semantics/resolve-directives.cpp:555:7: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
      default:
      ^
1 error generated.
2023-09-08 07:53:53 +08:00
Shraiysh
d211ad311e
[clang] Add error note when if clause is used on teams before 5.2. (#65686)
`if` clause is valid with openmp >= 5.2. It is not supported yet.
2023-09-07 18:51:38 -05:00
Arseny Kapoulkine
bede46f57e
[Fuzzer] Optimize UpdateFeatureFrequency (#65288)
Instead of a linear scan, use a bitset to track rarity of features. This
improves fuzzer throughput rather dramatically (close to 2x) in early
exploratory phases; in steady state this seems to improve fuzzing
throughput by ~15% according to perf.

The benchmarks are done on an executable with ~100k features, so the
results may change based on the executable that's being fuzzed.

kFeatureSetSize is 2M so the bitset is adding 256 KB to
sizeof(InputCorpus), but this should be fine since there's already three
arrays indexed by feature index for a total of 200 MB.
2023-09-07 16:51:05 -07:00
Wael Yehia
c525b8ede6 [AIX] Use llvm::get_threadid() to get a numeric ID
This should hopefully fix the Mac build break.

Differential Revision: https://reviews.llvm.org/D159319
2023-09-07 23:46:20 +00:00
Arseny Kapoulkine
d3440304b1
[Fuzzer] Update build.sh to fix build errors (#65496)
Switch from C++11 to C++14 as fuzzer requires std::chrono and stdlibc++
doesn't provide chrono literals when using -std=c++11.

Also remove 'u' from ar command to fix this warning: ar: `u' modifier
ignored since `D' is the default (see `U')
2023-09-07 16:38:28 -07:00
Jie Fu
2f62c78862 [PowerPC] Fix build error in PPCAsmPrinter.cpp (NFC)
/Users/jiefu/llvm-project/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:2753:34: error: cannot initialize a parameter of type 'int64_t' (aka 'long long') with an rvalue of type 'thread::id' (aka '_opaque_pthread_t *')
              "_" + llvm::itostr(llvm::this_thread::get_id()) + "_" +
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jiefu/llvm-project/llvm/include/llvm/ADT/StringExtras.h:315:35: note: passing argument to parameter 'X' here
inline std::string itostr(int64_t X) {
                                  ^
1 error generated.
2023-09-08 07:28:26 +08:00
Jonas Devlieghere
3aa678a777
[lldb/docs] Add section links to the top of the GDB to LLDB command map
Add section links to the top of the GDB to LLDB command map. This makes
navigating the page easier.
2023-09-07 16:26:53 -07:00
Philip Reames
b4a99f1cd6
[RISCV] Lower constant build_vectors with few non-sign bits via vsext (#65648)
If we have a build_vector such as [i64 0, i64 3, i64 1, i64 2], we
instead lower this as vsext([i8 0, i8 3, i8 1, i8 2]). For vectors with
4 or fewer elements, the resulting narrow vector can be generated via
scalar materialization.

For shuffles which get lowered to vrgathers, constant build_vectors of
small constants are idiomatic. As such, this change covers all shuffles
with an output type of 4 or less.

I deliberately started narrow here. I think it makes sense to expand
this to longer vectors, but we need a more robust profit model on the
recursive expansion. It's questionable if we want to do the zsext if
we're going to generate a constant pool load for the narrower type
anyways.

One possibility for future exploration is to allow the narrower VT to be
less than 8 bits. We can't use vsext for that, but we could use
something analogous to our widening interleave lowering with some extra
shifts and ands.
2023-09-07 16:01:16 -07:00
Jan Svoboda
9208065a7b
[clang][deps] Store common, partially-formed invocation (#65677)
We create one `CompilerInvocation` for each modular dependency we
discover. This means we create a lot of copies, even though most of the
invocation is the same between modules. This patch makes use of the
copy-on-write flavor of `CompilerInvocation` to share the common parts,
reducing memory usage and speeding up the scan.
2023-09-07 15:49:11 -07:00
Puneeth A R
ea9e47d534 ForceFunctionAttrs: support overriding attributes via csv file
Update `ForceFunctionAttrs` pass to optionally take its input from a csv file, for example, function-level optimization attributes. A subsequent patch will enable the pass pipeline to be aware of these attributes, and this pass will be used to test that is the case. Eventually, the annotations would be driven by an agent, e.g. a machine learning-based policy.

This patch is a part of GSoC 2023, more details can be found [[ https://summerofcode.withgoogle.com/programs/2023/projects/T8rB84Sr | here ]]

Reviewed By: mtrofin, aeubanks

Differential Revision: https://reviews.llvm.org/D155617
2023-09-07 18:39:19 -04:00
Fangrui Song
11c07ce3a6
Add llvm-binary-utilities to .github/CODEOWNERS (#65545)
From
https://discourse.llvm.org/t/input-needed-teams-for-pull-request-subscriptions/73116/3
2023-09-07 15:30:44 -07:00
Jeffrey Byrnes
5044531afd
[AMDGPU] Teach CalculateByteProvider about AMDGPUISD::PERM (#65547)
As a standalone patch, it has limited effect. However, it is necessary
as it supports upcoming commits.
2023-09-07 15:13:42 -07:00
Owen Pan
a8fbc16ebe Revert "[git-clang-format] Fix typo in help message"
This reverts commit d099dbb221a4c3474a15117b1658dedc5dcd6ebf as
'git clang-format' is the idiomatic way of running git-clang-format.
2023-09-07 15:05:46 -07:00
Valentin Clement (バレンタイン クレメン)
20f4a5a313
[flang][openacc][NFC] Clean up lowering api (#65678)
Remove unused argument `pft::Evaluation` from higher level lowering API.
2023-09-07 14:54:38 -07:00
Arthur Eubanks
d5c6bd1ce9 [gn build] Manually port 46f3ade 2023-09-07 14:41:16 -07:00
Markus Böck
38c5d231cb
[GitHub] Add main LLVM Dialect path to MLIR LLVM PR subscribers (#65513)
The LLVM Dialect in MLIR, which the `mlir-llvm` team is supposed to
provide notifications for, is 98% not nested in a directory called LLVM
but rather LLVMIR. The former only contains some tests.

This should make PRs such as
https://github.com/llvm/llvm-project/pull/65508 add the team as
codeowner.
2023-09-07 23:28:41 +02:00
Michael Jones
dd51ae81d8 [libc] Fix printf %p format
The %p format wasn't correctly passing along flags and modifiers to the
integer conversion behind the scenes. This patch fixes that behavior, as
well as changing the nullptr behavior to be a string conversion behind
the scenes.

Reviewed By: lntue, jhuber6

Differential Revision: https://reviews.llvm.org/D159458
2023-09-07 14:13:35 -07:00
Elvina Yakubova
6678f602c2 [BOLT][test] Fix cross-compilation tests after D151920
Fix tests that are failing in cross-compilation after D151920
(https://lab.llvm.org/buildbot/#/builders/221/builds/17715):

- instrumentation-ind-call, basic-instrumentation: add -mno-outline-atomics flag to runtime lib
- bolt-address-translation-internal-call, internal-call-instrument: add %cflags
- meta-merge-fdata: restrict to x86_64

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D159094
2023-09-08 00:05:39 +03:00
Jan Svoboda
e1cc299ec8
[clang] Introduce copy-on-write CompilerInvocation (#65412)
This PR introduces new copy-on-write `CompilerInvocation` class
(`CowCompilerInvocation`), which will be used by the dependency scanner
to reduce the number of copies performed when generating command lines
for discovered modules.
2023-09-07 14:01:40 -07:00
stefanp-ibm
0a4a8bec34
[PowerPC] Turn string pooling on by default. (#65628)
This patch turns the string pooling pass on by default. Some tests are
updated as required.
2023-09-07 16:49:31 -04:00
Raghu Maddhipatla
6d1c183c6f [Flang] [OpenMP] [Semantics] Add missing semantic check for MAP clause.
Added support for following semantic check for MAP clause.
  - A list item cannot appear in both a map clause and a data-sharing attribute clause on the same target construct.

Reviewed By: NimishMishra

Differential Revision: https://reviews.llvm.org/D158807
2023-09-07 15:42:25 -05:00
Ralf Jung
1c567a51f0
getelementptr inbounds clarifications (#65478)
- For a long time I assumed that `inbounds` means "in-bounds of a *live*
allocation". @nikic told me that is not correct. I think this definitely
needs clarification in the docs.
- The point about successively adding the offsets to the current address
confused be because it talked about the successive addition of "an"
offset -- which one? My interpretation was, the total accumulated offset
computed in the previous step. But @nikic told me that's not correct,
adding each offset individually has to stay in-bounds for each step. I
hope by saying "each offset" this becomes more clear; I then also change
the previous bullet to use the same terminology.
2023-09-07 21:40:08 +01:00
Giuliano Belinassi
46f3ade508 Fix ast print of variables with attributes
Previously clang AST prints the following declaration:

int fun_var_unused() {

  int x __attribute__((unused)) = 0;
  return x;
}

and

int __declspec(thread) x = 0;

as:

int fun_var_unused() {

  int x = 0 __attribute__((unused));
  return x;
}

and

int x = __declspec(thread) 0;

which is rejected by C/C++ parser. This patch modifies the logic to
print old C attributes for variables as:

int __attribute__((unused)) x = 0;
and the __declspec case as:

int __declspec(thread) x = 0;
Fixes: https://github.com/llvm/llvm-project/issues/59973

Previous version: D141714.

Differential Revision:https://reviews.llvm.org/D141714
2023-09-07 13:35:50 -07:00
Harald van Dijk
04224d1ae7
[InferAddressSpaces] Register pass. (#65639)
InferAddressSpaces failed to call its initialization function. It was
still called through initializeScalarOpts in llc and opt, but it was
skipped entirely in clang. When the initialization function is not
called, this results in confusing behavior where the pass appears to
run, but not entirely as it should, e.g. the pass is excluded from
-print-before-all and -print-after-all.
2023-09-07 21:35:16 +01:00
Martin Storsjö
4bba12f722 [lli] Make sure the exported __chkstk functions are included when exporting them
The trick we use (since cbc2a0623a39461b56bd9eeb308ca535f03793f8)
for exporting the __chkstk function (with various per-arch names)
that is defined in a different object file, relies on the function
already being linked in (by some function referencing it).

This function does end up referenced if there's a function that
allocates more than 4 KB on the stack. In most cases, it's referenced
somewhere, but in the case of builds with LLVM_LINK_LLVM_DYLIB
enabled (so most of the code resides in a separate libLLVM-<ver>.dll)
the only code in lli.exe is the lli tool specific code and the
mingw-w64 crt startup code. In the case of GCC based MinGW i386
builds with LLVM_LINK_LLVM_DYLIB, nothing else references it though.

Manually add a reference to the function to make sure it is linked
in (from libgcc or compiler-rt builtins) so that it can be exported.

This fixes one build issue encountered in
https://github.com/msys2/MINGW-packages/pull/18002.

Differential Revision: https://reviews.llvm.org/D159085
2023-09-07 23:32:34 +03:00
lorenzo chelini
e5137e7c33
[MLIR][Linalg] Retire tile_to_scf_for (#65633)
Both `TileOp` and `TileToScfForOp` use the tiling interface and the
`tileUsingSCFForOp` method. This duplication was introduced in
44cfea0279
as a way to retire `linalg::tileLinalgOp,` now there is not more need
for this duplication, and it seems that `tileOp` has more recent
changes, thus retire `TileToScfForOp.`
2023-09-07 16:13:23 -04:00
Jan Svoboda
62e576b454
[clang] Make the entire CompilerInvocation ref-counted (#65647)
This enables making the whole `CompilerInvocation` more efficient
through copy-on-write.
2023-09-07 13:10:30 -07:00
Jeffrey Byrnes
7fda1b74be [AMDGPU]: Allow combining into v_dot4
Differential Revision: https://reviews.llvm.org/D155995

Change-Id: I794f540217f0f84141338757b41b1be0493c7207
2023-09-07 12:58:48 -07:00
Min-Yih Hsu
a09f09c618 [TableGen] Fix incorrect handling of nested #ifndef directives
TableGen's lexer was unable to handle nested #ifndef when the outer
`#ifdef` / `#ifndef` scope is subject to skip. This was caused by returning
the canonicalized token when it should have returned the original one.

Fix #65100.

Differential Revision: https://reviews.llvm.org/D159236
2023-09-07 12:42:22 -07:00
Cyndy Ishida
f9fe6032cd [TextAPI] Support more constructors for PackedVersions
TBD files now record minimum deplyoment versions and tapi interfaces
with apple system linker by a packed version encoding. Support mapping
between that and `VersionTuple`s.
2023-09-07 12:23:12 -07:00
Emilia Kond
e9ed1aa9cd
[clang-format] Correctly annotate designated initializer with PP if (#65409)
When encountering braces, such as those of a designated initializer,
clang-format scans ahead to see what is contained within the braces. If
it found a statement, like an if-statement of for-loop, it would deem
the braces as not an initializer, but as a block instead.

However, this heuristic incorrectly included a preprocessor `#if` line
as an if-statement. This manifested in strange results and discrepancies
between `#ifdef` and `#if defined`.

With this patch, `if` is now ignored if it is preceeded by `#`.

Fixes most of https://github.com/llvm/llvm-project/issues/56685
2023-09-07 22:23:05 +03:00
Yitzhak Mandelbaum
80f0dc3aa4 [clang][dataflow] Unsoundly treat "Unknown" as "Equivalent" in widening.
This change makes widening act the same as equivalence checking. When the
analysis does not provide an answer regarding the equivalence of two distinct
values, the framework treats them as equivalent. This is an unsound choice that
enables convergence.

Differential Revision: https://reviews.llvm.org/D159355
2023-09-07 19:06:35 +00:00
Mikhail R. Gadelha
9ff0a447d0 [libc] Fix setrlimit/getrlimit on 32-bit systems
libc uses SYS_prlimit64 (which takes a struct rlimit64) to implement
setrlimt and getrlimit (which take a struct rlimit). In 64-bit bits
systems this is not an issue since the members of struct rlimit64 and
struct rlimit are 64 bits long, however, in 32-bit systems the members
of struct rlimit are only 32 bits long, causing wrong values being
passed to SYS_prlimit64.

This patch changes rlim_t to be __UINT64_TYPE__ (which also changes
rlimit as a side-effect), fixing the problem of mismatching types in
the syscall.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D159104
2023-09-07 16:02:32 -03:00