platform/upstream/llvm.git
18 months ago[clang][dataflow] Only model struct fields that are used in the function being analyzed.
Yitzhak Mandelbaum [Tue, 27 Dec 2022 14:21:29 +0000 (14:21 +0000)]
[clang][dataflow] Only model struct fields that are used in the function being analyzed.

Previously, the model for structs modeled all fields in a struct when
`createValue` was called for that type. This patch adds a prepass on the
function under analysis to discover the fields referenced in the scope and then
limits modeling to only those fields.  This reduces wasted memory usage
(modeling unused fields) which can be important for programss that use large
structs.

Note: This patch obviates the need for https://reviews.llvm.org/D123032.

Differential Revision: https://reviews.llvm.org/D140694

18 months agoRevert an unintentional API ABI break
Adrian Prantl [Thu, 5 Jan 2023 21:41:33 +0000 (13:41 -0800)]
Revert an unintentional API ABI break

lldb::LanguageType is used as a parameter in
SBExpressionOptions::SetLanguage(), which actually makes this type API
too. Commit 6eaedbb52f2a616e644e5acc7279c8b07c4cfe82 added a
`: uint16_t` to it, which broke binary compatibility for the SBAPI. This
patch reverts to the original enum.

I tried moving the entire enum into include/API, but that created a
cyclic module dependency between API and Utility. To keep things
simple, this just reverts to the original code and adds a warning.

rdar://103415402

Differential Revision: https://reviews.llvm.org/D141087

18 months agoclang/AMDGPU: Remove flat-address-space from feature map
Matt Arsenault [Mon, 28 Nov 2022 22:55:17 +0000 (17:55 -0500)]
clang/AMDGPU: Remove flat-address-space from feature map

This was only used for checking if is_shared/is_private were legal,
which we're not bothering to do anymore.

This is apparently visible to more than the target attribute (which
seems to silently ignore unrecognized features), so this has the
potential to break something (i.e. see the OpenMP test change)

18 months ago[NFC] [Doc] Fix example for AnnotateTypeDocs
Xiang Li [Thu, 5 Jan 2023 21:29:09 +0000 (16:29 -0500)]
[NFC] [Doc] Fix example for AnnotateTypeDocs

Change clang::annotate into clang::annotate_type.

The example will get error like
error: 'annotate' attribute cannot be applied to types
int* [[clang::annotate("category1", "foo", 1)]] f(int[[clang::annotate("category2")]] *);

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D139935

18 months ago[AMDGPU] Add .uniform_work_group_size metadata to v5
Vang Thao [Thu, 5 Jan 2023 20:40:12 +0000 (20:40 +0000)]
[AMDGPU] Add .uniform_work_group_size metadata to v5

Amdgpu kernel with function attribute "uniform-work-group-size"="true" requires
uniform work group size (i.e. each dimension of global size is a multiple of
corresponding dimension of work group size). hipExtModuleLaunchKernel allows to
launch HIP kernel with non-uniform workgroup size, which makes it necessary for
runtime to check and enforce uniform workgroup size if kernel requires it. To
let runtime be able to enforce that, this metadata is needed to indicate that
the kernel requires uniform workgroup size.

Reviewed By: kzhuravl, arsenm

Differential Revision: https://reviews.llvm.org/D141012

18 months ago[CodeGen] Default TargetOptions::RelaxELFRelocations to true
Fangrui Song [Thu, 5 Jan 2023 21:28:48 +0000 (13:28 -0800)]
[CodeGen] Default TargetOptions::RelaxELFRelocations to true

MC and lld/ELF defaults were flipped in 2016. For Clang: CMake
ENABLE_X86_RELAX_RELOCATIONS defaults to on in 2020. It makes sense for
the TargetOptions default to be true now.

R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX require GNU ld newer than 2015-10
(subsumed by the current requirement of -fbinutils-version=).

This should fix `rustc -Z plt=no` PIC relocatable files with GNU ld.
(See https://github.com/rust-lang/rust/pull/106380)

18 months ago[clang-format] Improve UnwrappedLineParser::mightFitOnOneLine()
Owen Pan [Mon, 2 Jan 2023 00:02:35 +0000 (16:02 -0800)]
[clang-format] Improve UnwrappedLineParser::mightFitOnOneLine()

Account for an r_brace that precedes an "else if" statement when
calculating whether the line might fit on one line if the r_brace
is removed.

Fixes #59778.

Differential Revision: https://reviews.llvm.org/D140835

18 months agoParse: handle another case of invalid handling for attributes
Saleem Abdulrasool [Thu, 22 Dec 2022 15:46:34 +0000 (15:46 +0000)]
Parse: handle another case of invalid handling for attributes

clang would improperly disallow GNU attributes before C++ standard
attributes when a declaration had a linkage specifier.  Handle this
similarly to the previous case of invalid parsing.  We now better match
the parsing rules from GCC.

Differential Revision: https://reviews.llvm.org/D140507
Reviewed By: aaron.ballman

18 months ago[AMDGPU] MachineScheduler: schedule execution metric added for the UnclusteredHighRPStage
Alexander Timofeev [Wed, 7 Dec 2022 17:36:11 +0000 (18:36 +0100)]
[AMDGPU] MachineScheduler: schedule execution metric added for the UnclusteredHighRPStage

Since the divergence-driven ISel was fully enabled we have more VGPRs available.
         MachineScheduler trying to take advantage of that bumps up the occupancy sacrificing
         the hiding of memory access latency.  This really spoils the initially good schedule.
         A new metric that reflects the latency hiding quality of the schedule has been created
         to make it to balance between occupancy and latency. The metric is based on the latency
         model which computes the bubble to working cycles ratio. Then we use this ratio to decide
         if the higher occupancy schedule is profitable as follows:

             Profit = NewOccupancy/OldOccupancy * OldMetric/NewMetric

Reviewed By: rampitec

Differential Revision: https://reviews.llvm.org/D139710

18 months ago[Fix]"[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callab...
ziqingluo-90 [Thu, 5 Jan 2023 19:48:02 +0000 (11:48 -0800)]
[Fix]"[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations"

The original patch in commit b2ac5fd724c44cf662caed84bd8f84af574b981d
causes compilation errors which can be reproduced by the
`-fdelayed-template-parsing` flag.  This commit fixes the problem.

Related differential revision: https://reviews.llvm.org/D138329

18 months agoRevert "Revert "[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that...
ziqingluo-90 [Thu, 5 Jan 2023 19:45:25 +0000 (11:45 -0800)]
Revert "Revert "[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations""

This reverts commit f58b025354ee2d3bcd7ab2399a11429ec940c1e0.

 The previous revert reverts a patch that causes compilation problem on
 windows which can be reproduced using `-fdelayed-template-parsing`.
 I'm now to revert the patch back and commit a fix next.

18 months agoVerifier: Disallow uses of intrinsic global variables
Matt Arsenault [Thu, 24 Nov 2022 21:58:49 +0000 (16:58 -0500)]
Verifier: Disallow uses of intrinsic global variables

appendToGlobalCtors implicitly assumes this is the case, since it
deletes and recreates without trying to update any uses.

This ran into an interesting problem in a few linker tests. During the
link, ConstantExpr casts were speculatively created to replace any
uses that might need them for replacement. These unused ConstantExprs
would hang around and still appear on the use list. It seems like a
bug that those stick around, but I'm not sure where those are supposed
to be cleaned up. Avoid this by not creating the casts for appending
linkage.

Delete one of the casts entirely as it breaks no tests. The verifier
has enforced a specific type for these since 2011, so I don't see why
we would need to handle linking modules with a wrong types. One test
does fail without the second cast (Linker/appending-global-proto.ll,
added by D95126). This test looks contrived; it's using appending
linkage with a regular variable. The LangRef suggests this is illegal
(and suggests another missing verifier check).

18 months agoRemove documentation about the Go bindings
Aaron Ballman [Thu, 5 Jan 2023 19:47:11 +0000 (14:47 -0500)]
Remove documentation about the Go bindings

We removed the Go bindings in https://reviews.llvm.org/D135436 but
missed documentation that talks about the bindings.

18 months ago[RISCV] Prevent constant hoisting for or/and/xor that can use bseti/bclri/binvi.
Craig Topper [Thu, 5 Jan 2023 19:18:26 +0000 (11:18 -0800)]
[RISCV] Prevent constant hoisting for or/and/xor that can use bseti/bclri/binvi.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D140928

18 months ago[test] Test __attribute__((noreturn)), _Noreturn, and [[return]] with conditional...
Fangrui Song [Thu, 5 Jan 2023 19:18:17 +0000 (11:18 -0800)]
[test] Test __attribute__((noreturn)), _Noreturn, and [[return]] with conditional operator

18 months ago[lld-macho] Don't support relocations in cstring sections
Jez Ng [Thu, 5 Jan 2023 19:14:11 +0000 (14:14 -0500)]
[lld-macho] Don't support relocations in cstring sections

We can technically handle them, but since they shouldn't come up in any
real-world programs (since ld64 dedups strings unconditionally), there's
no reason to support them.

It's a thoroughly untested code path too -- as evidenced by the fact
that the only test this change breaks is one that verifies that we
reject relocations when dedup'ing. There is no test that covers the case
where we handle relocations in cstring sections when dedup is disabled.

Reviewed By: #lld-macho, oontvoo, keith, thakis

Differential Revision: https://reviews.llvm.org/D141025

18 months ago[profile] Update test to make condition non-redundant.
Florian Hahn [Thu, 5 Jan 2023 19:03:33 +0000 (19:03 +0000)]
[profile] Update test to make condition non-redundant.

The tests contain a redundant condition in the else if branch that can
be simplified with fb13dcf3431c.

Update the condition used to prevent it from getting removed.

Alive2 proof for check removal:
https://alive2.llvm.org/ce/z/iFBnsy

18 months agoFix typos
Luke Drummond [Thu, 5 Jan 2023 18:34:55 +0000 (18:34 +0000)]
Fix typos

I found one typo of "implemnt", then some more.
s/implemnt/implement/g

18 months agoAMDGPU: Fix broken opaque pointer handling in printf pass
Matt Arsenault [Thu, 22 Dec 2022 16:49:00 +0000 (11:49 -0500)]
AMDGPU: Fix broken opaque pointer handling in printf pass

This was directly considering the pointee type, and also applying
special semantics to constant address space.

18 months ago[NFC][YAMLTraits] Use `SmallString<>`+SSO when yamlizing non-strings
Roman Lebedev [Thu, 5 Jan 2023 18:20:32 +0000 (21:20 +0300)]
[NFC][YAMLTraits] Use `SmallString<>`+SSO when yamlizing non-strings

This gets rid of basically all temporary allocations
during YAML serialization of llvm-exegesis snippets,
we go from ~1.8M temporary allocations to 13k.

18 months ago[NFC][exegesis] `SnippetGenerator::generateConfigurations()`: don't forget to `reserve()`
Roman Lebedev [Thu, 5 Jan 2023 17:51:37 +0000 (20:51 +0300)]
[NFC][exegesis] `SnippetGenerator::generateConfigurations()`: don't forget to `reserve()`

18 months ago[lld-macho][test] Simplify classrefs test
Jez Ng [Thu, 5 Jan 2023 18:29:21 +0000 (13:29 -0500)]
[lld-macho][test] Simplify classrefs test

I wasn't previously aware of the `llvm-otool -o` flag; that gives us
output that's a lot easier to parse.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D141024

18 months ago[clang] Correct -frewrite-includes generation of line control directives with mixed...
Tom Honermann [Wed, 4 Jan 2023 03:41:33 +0000 (19:41 -0800)]
[clang] Correct -frewrite-includes generation of line control directives with mixed EOL forms.

Previously, if a header file and a source file used different end of line
(EOL) forms, preprocessed output generated with the -frewrite-includes option
would, in some cases, generate line control directives with the wrong line
number due to an error in how source file lines were counted.

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

Reviewed By: cor3ntin

Differential Revision: https://reviews.llvm.org/D140984

18 months ago[AArch64] Regenerate fp16-vector-nvcast.ll check lines. NFC
David Green [Thu, 5 Jan 2023 18:16:58 +0000 (18:16 +0000)]
[AArch64] Regenerate fp16-vector-nvcast.ll check lines. NFC

18 months ago[SLP] Unify GEP cost modeling for load, store and GEP nodes.
Valery N Dmitriev [Wed, 28 Dec 2022 21:22:53 +0000 (13:22 -0800)]
[SLP] Unify GEP cost modeling for load, store and GEP nodes.

Make a separate routine for GEPs cost calculation and make
the approach uniform across load, store and GEP tree nodes.
Additional issue fixed is GEP cost savings were applied twice
for ScatterVectorize nodes (aka gather load) making them look
unrealistically profitable for vectorization.

Differential Revision: https://reviews.llvm.org/D140789

18 months ago[libc] Make the sidebar colors have a higher constract in the white background.
Siva Chandra Reddy [Thu, 5 Jan 2023 09:26:15 +0000 (01:26 -0800)]
[libc] Make the sidebar colors have a higher constract in the white background.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D141039

18 months ago[libc] Add document for a recipe to do a full standalone cross-build.
Siva Chandra Reddy [Thu, 5 Jan 2023 09:09:28 +0000 (01:09 -0800)]
[libc] Add document for a recipe to do a full standalone cross-build.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D141037

18 months ago[mlir][sparse] Add operator sparse_tensor.indices_buffer.
bixia1 [Thu, 5 Jan 2023 00:01:35 +0000 (16:01 -0800)]
[mlir][sparse] Add operator sparse_tensor.indices_buffer.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D140762

18 months ago[InstCombine] add tests for cmp of pow2 mask; NFC
Sanjay Patel [Wed, 4 Jan 2023 21:00:25 +0000 (16:00 -0500)]
[InstCombine] add tests for cmp of pow2 mask; NFC

18 months ago[libc] Add documentation on hacking with vscode
Jeff Bailey [Thu, 5 Jan 2023 17:27:16 +0000 (17:27 +0000)]
[libc] Add documentation on hacking with vscode

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D140826

18 months ago[NFC][exegesis] `BenchmarkCodeStreamer`: use existing RegNameToRegNo map
Roman Lebedev [Thu, 5 Jan 2023 17:11:38 +0000 (20:11 +0300)]
[NFC][exegesis] `BenchmarkCodeStreamer`: use existing RegNameToRegNo map

18 months ago[NFC][AttributesTest] Fix signedness warnings
Roman Lebedev [Thu, 5 Jan 2023 17:10:35 +0000 (20:10 +0300)]
[NFC][AttributesTest] Fix signedness warnings

18 months ago[RISCV][NFC] Refine the patch of D141061
Kito Cheng [Thu, 5 Jan 2023 16:48:22 +0000 (00:48 +0800)]
[RISCV][NFC] Refine the patch of D141061

Just saw Craig's comment after I commit, he has suggest a good NFC
for that change.

18 months ago[RISCV][InsertVSETVLI] Using right instruction during mutate AVL of vsetvli
Kito Cheng [Thu, 5 Jan 2023 15:10:12 +0000 (23:10 +0800)]
[RISCV][InsertVSETVLI] Using right instruction during mutate AVL of vsetvli

Fixing a crash during vsetvli insertion pass.

We have a testcase with 3 vsetvli:

1. vsetivli        zero, 2, e8, m4, ta, ma
2. li      a1, 32;  vsetvli zero, a1, e8, m4, ta, mu
3. vsetivli        zero, 2, e8, m4, ta, ma

and then we trying to optimize 2nd vsetvli since the only user is vmv.x.s, so
it could mutate the AVL operand to the AVL operand of the 3rd vsetvli.
OK, so we propagate 2 to vsetvli, BUT it's vsetvli not vsetivli, so it expect a
register rather than a immediate value, so we have to update the opcode
if needed.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D141061

18 months ago[SelectionDAG] Improve codegen for udiv by constant if any divisors are 1.
Craig Topper [Thu, 5 Jan 2023 16:20:54 +0000 (08:20 -0800)]
[SelectionDAG] Improve codegen for udiv by constant if any divisors are 1.

If the divisor is 1, the magic algorithm does not return a correct
result and we end up using a select to pick the numerator for those
elements at the end.

Therefore we can use undef for that element of the earlier operations
when the divisor is 1. We sometimes get this through SimplifyDemandedVectorElts,
but not always. Definitely seems like we don't if the NPQ fixup is used.

Unfortunately, DAGCombiner is unable to fold srl X, <0, undef> to X so
I had to add flags to avoid emitting the srl unless one of the shift
amounts is non-zero.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D141022

18 months agoAMDGPU: Switch enqueue kernel test to generated checks
Matt Arsenault [Fri, 23 Dec 2022 19:41:50 +0000 (14:41 -0500)]
AMDGPU: Switch enqueue kernel test to generated checks

18 months ago[NFC][Exegesis][X86] Test that we don't crash while coming up with snippets
Roman Lebedev [Thu, 5 Jan 2023 16:31:35 +0000 (19:31 +0300)]
[NFC][Exegesis][X86] Test that we don't crash while coming up with snippets

These tests take less than a second each,
so they are fine to have as tests.

It will be useful to add similar ones
for `prepare-and-assemble-snippet` x repetition mode,
but there we have a problem of not being truly ISA set independent...

18 months agoBy-pass some ArrayRef deduction guide
serge-sans-paille [Thu, 5 Jan 2023 16:07:13 +0000 (17:07 +0100)]
By-pass some ArrayRef deduction guide

clang-11 doesn't fully support them and requires an explicit
instantiation in some situation. This is fixed in (at least) clang-14

18 months ago[Attributes] Remove trailing empty attribute sets (PR59746)
Nikita Popov [Thu, 5 Jan 2023 16:12:31 +0000 (17:12 +0100)]
[Attributes] Remove trailing empty attribute sets (PR59746)

In setAttributesAtIndex(), remove any trailing empty attribute sets.
Also make sure that all the different attribute removal APIs go
through that method.

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

18 months ago[DebugInfo][SelectionDAGISel] Do not drop all dbg.declares if one with empty metadata...
OCHyams [Thu, 5 Jan 2023 14:55:41 +0000 (14:55 +0000)]
[DebugInfo][SelectionDAGISel] Do not drop all dbg.declares if one with empty metadata is found

This error was introduced in 1d1de7467c32d52926ca56b9167a2c65c451ecfa (by me)
about 1 month ago. Found while testing the D140901 patch stack.

Reviewed By: jryans

Differential Revision: https://reviews.llvm.org/D141052

18 months ago[clang-tidy] Fix minor bug in add_new_check.py
Chris Cotter [Thu, 5 Jan 2023 15:28:43 +0000 (15:28 +0000)]
[clang-tidy] Fix minor bug in add_new_check.py

While rebuilding the list of checks in add_new_check.py,
check is a file is a subdirectory before traversing it.

Test plan: Ran `./add_new_check.py --update-docs` and confirmed the list.rst file was unchanged.

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D140772

18 months agoVerifier: Move test from test/Analysis to test/Verifier
Matt Arsenault [Thu, 5 Jan 2023 13:13:19 +0000 (08:13 -0500)]
Verifier: Move test from test/Analysis to test/Verifier

This test was purely checking the verifier error, and had no reason
to be running instcombine.

18 months agollvm-reduce: Don't delete instructions in global variable reduction
Matt Arsenault [Wed, 4 Jan 2023 22:46:03 +0000 (17:46 -0500)]
llvm-reduce: Don't delete instructions in global variable reduction

For some reason the global variable reduction was trying to delete
use instructions. This broke the verifier if the user was a terminator,
since the block now no longer has one. It doesn't make sense for this
reduction to delete the users, so just stop doing that.

18 months agoIROutliner: Fix missing C++ mode comment
Matt Arsenault [Thu, 5 Jan 2023 13:28:00 +0000 (08:28 -0500)]
IROutliner: Fix missing C++ mode comment

18 months ago[mlir] fix out-of-bounds in reduction tiling
Alex Zinenko [Thu, 5 Jan 2023 13:37:23 +0000 (13:37 +0000)]
[mlir] fix out-of-bounds in reduction tiling

A transformation tiling a reduction dimension of a Linalg op needs a
tile size for said dimension. When an insufficient number of dimensions
was provided, it would segfault due to out-of-bounds access to a vector.

Also fix incorrect error reporting in the structured transform op
exercising this functionality.

Reviewed By: springerm, ThomasRaoux

Differential Revision: https://reviews.llvm.org/D141046

18 months ago[exegesis] "Skip codegen" dry-run mode
Roman Lebedev [Thu, 5 Jan 2023 14:38:35 +0000 (17:38 +0300)]
[exegesis] "Skip codegen" dry-run mode

While "skip measurements mode" is super useful for test coverage,
i've come to discover it's trade-offs. It still calls back-end
to actually codegen the target assembly, and that is what is taking
80%+ of the time regardless of whether or not we skip the measurements.

On the other hand, just being able to see that exegesis can come up
with a snippet to measure something, is already very useful,
and takes maybe a second for a all-opcode sweep.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D140702

18 months ago[ScalarEvolutionExpanderTest] Avoid sign warning
Roman Lebedev [Thu, 5 Jan 2023 14:38:18 +0000 (17:38 +0300)]
[ScalarEvolutionExpanderTest] Avoid sign warning

18 months agoImplement support for option 'fexcess-precision'.
Zahira Ammarguellat [Thu, 13 Oct 2022 18:40:21 +0000 (14:40 -0400)]
Implement support for option 'fexcess-precision'.

Differential revision: https://reviews.llvm.org/D136176

18 months ago[libc] get_table_negative cannot be constexpr
Guillaume Chatelet [Wed, 4 Jan 2023 12:08:06 +0000 (12:08 +0000)]
[libc] get_table_negative cannot be constexpr

GCC complains about if conditions not being constant expressions.
As-is get_table_negative cannot be marked constexpr.

Differential Revision: https://reviews.llvm.org/D140967

18 months ago[NFC] Use std::size(x) Instead of ArrayRef(x).size
serge-sans-paille [Thu, 5 Jan 2023 14:25:47 +0000 (15:25 +0100)]
[NFC] Use std::size(x) Instead of ArrayRef(x).size

This is equivalent for all kind of `x` accepted by ArrayRef.

18 months agoAMDGPU: Fix broken and permissive handling of printf format strings
Matt Arsenault [Thu, 22 Dec 2022 16:09:31 +0000 (11:09 -0500)]
AMDGPU: Fix broken and permissive handling of printf format strings

This was completely broken with opaque pointers because it was
specifically looking for a constant expression with the global
variable as the first operand. Strip casts like normal, and properly
validate all of the restrictions rather than silently ignoring any
unhandled cases. Also be stricter that we aren't calling into some
unresolved or non-constant format string.

Also converts the test to opaque pointers and generated tests. There's
more broken initializer handling for strings inside the format string
processing too, but there's just no test coverage for this at all.

18 months ago[gn build] Port b06b248ad9dc
LLVM GN Syncbot [Thu, 5 Jan 2023 14:03:43 +0000 (14:03 +0000)]
[gn build] Port b06b248ad9dc

18 months ago[libc] Fix invalid constructor declaration
Guillaume Chatelet [Thu, 5 Jan 2023 14:01:15 +0000 (14:01 +0000)]
[libc] Fix invalid constructor declaration

18 months ago[clang-tidy] Implement CppCoreGuideline CP.53
Chris Cotter [Thu, 5 Jan 2023 12:58:34 +0000 (12:58 +0000)]
[clang-tidy] Implement CppCoreGuideline CP.53

Implement CppCoreGuideline CP.53 to warn when a coroutine accepts
references parameters. Although the guideline mentions that it is safe
to access a reference parameter before suspension points, the guideline
recommends flagging all coroutine parameter references.

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D140793

18 months ago[flang][NFC] share Constant<SomeDerived> lowering
Jean Perier [Thu, 5 Jan 2023 13:45:14 +0000 (14:45 +0100)]
[flang][NFC] share Constant<SomeDerived> lowering

A previous patch (https://reviews.llvm.org/D136955) already refactored
intrinsic constant lowering to place in its own file and allow using it from
both the current lowering and the new lowering to HLFIR.

This patch does the same for derived types. The core function
"genStructComponentInInitializer" is moved from ConvertExpr.cpp and
renamed "genInlinedStructureCtorLitImpl" into ConvertConstant.cpp
without significant logic change.

Then, genScalarLit, genArrayLit (and genInlinedArrayLit/genOutlinedArrayLit)
are updated to support derived types.

The core aspect of derived type constant lowering that differs between
the current lowering and the HLFIR update is the way
addresses/initial target descriptors are built when part of a derived
type constant. This part happens in ConvertVariable.cpp (since the
address of a variable is taken in an initializer and is left TODO).

The mangling of derived type global literal constant is fixed: it did not embed
the derived type name and could cause "conflicts" between unrelated
derived types containing the same data. However, the hash remains
unstable between two compilation of the same file. This is not a
correctness issue and would require a lot of work to hash the derived
type constant data without hashing some irrelevant (but not out of bound)
data in the compile time data structure that holds derived type
constants (Constant<SomeDerived>). This may have to be revisited later.

Differential Revision: https://reviews.llvm.org/D140986

18 months ago[Examples] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 13:16:11 +0000 (14:16 +0100)]
[Examples] Convert test to opaque pointers (NFC)

18 months ago[DFSan] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 13:13:58 +0000 (14:13 +0100)]
[DFSan] Convert test to opaque pointers (NFC)

Retaining the unused bitcasts in this test, as they are required
to reproduce the test behavior for whatever reason.

18 months agoMove from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ part
serge-sans-paille [Wed, 4 Jan 2023 07:28:45 +0000 (08:28 +0100)]
Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ part

Use deduction guides instead of helper functions.

The only non-automatic changes have been:

1. ArrayRef(some_uint8_pointer, 0) needs to be changed into ArrayRef(some_uint8_pointer, (size_t)0) to avoid an ambiguous call with ArrayRef((uint8_t*), (uint8_t*))
2. CVSymbol sym(makeArrayRef(symStorage)); needed to be rewritten as CVSymbol sym{ArrayRef(symStorage)}; otherwise the compiler is confused and thinks we have a (bad) function prototype. There was a few similar situation across the codebase.
3. ADL doesn't seem to work the same for deduction-guides and functions, so at some point the llvm namespace must be explicitly stated.
4. The "reference mode" of makeArrayRef(ArrayRef<T> &) that acts as no-op is not supported (a constructor cannot achieve that).

Per reviewers' comment, some useless makeArrayRef have been removed in the process.

This is a follow-up to https://reviews.llvm.org/D140896 that introduced
the deduction guides.

Differential Revision: https://reviews.llvm.org/D140955

18 months ago[LoopSimplifyCFG] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 13:04:32 +0000 (14:04 +0100)]
[LoopSimplifyCFG] Convert test to opaque pointers (NFC)

18 months ago[NFC][NVPTX] Move a comment back to its proper place
Luke Drummond [Thu, 5 Jan 2023 13:01:28 +0000 (13:01 +0000)]
[NFC][NVPTX] Move a comment back to its proper place

The comment introduced in b94bd05b952a5 was misplaced during
f14af1621942 and no longer comments on the relevant bit of code; move it
back so it makes sense.

18 months ago[mlir] Add function_entry_count to LLVMFuncOp
Christian Ulmann [Thu, 5 Jan 2023 12:21:57 +0000 (13:21 +0100)]
[mlir] Add function_entry_count to LLVMFuncOp

This commit introduces the function_entry_count metadata field to the
LLVMFuncOp and adds both the corresponding import and export
funtionalities.
The import of the function metadata uses the same infrastructure as the
instruction metadata, i.e., it dispatches through a dialect interface.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D141001

18 months ago[X86] Support -march=emeraldrapids
Freddy Ye [Thu, 5 Jan 2023 12:27:13 +0000 (20:27 +0800)]
[X86] Support -march=emeraldrapids

Reviewed By: pengfei, skan

Differential Revision: https://reviews.llvm.org/D140950

18 months ago[CodeGen] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 12:13:06 +0000 (13:13 +0100)]
[CodeGen] Convert some tests to opaque pointers (NFC)

These are mostly MIR tests, which I did not handle during previous
conversions.

18 months ago[Verifier] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 12:10:32 +0000 (13:10 +0100)]
[Verifier] Convert some tests to opaque pointers (NFC)

18 months ago[clang-format] Add an option for breaking after C++11 attributes
Owen Pan [Wed, 4 Jan 2023 07:07:15 +0000 (23:07 -0800)]
[clang-format] Add an option for breaking after C++11 attributes

Fixes #45968.
Fixes #54265.
Fixes #58102.

Differential Revision: https://reviews.llvm.org/D140956

18 months ago[X86] Modify model value of meteorlake.
Freddy Ye [Thu, 5 Jan 2023 12:07:58 +0000 (20:07 +0800)]
[X86] Modify model value of meteorlake.

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D140943

18 months ago[SCEVExpanderTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 12:01:24 +0000 (13:01 +0100)]
[SCEVExpanderTest] Convert to opaque pointers (NFC)

18 months ago[PredicateInfo] Enable test with broken REQUIRES condition (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:50:39 +0000 (12:50 +0100)]
[PredicateInfo] Enable test with broken REQUIRES condition (NFC)

Add some extra uses of the comparisons, so that these do get
visited.

18 months ago[AArch64][GlobalISel] implement GPR (U/S)(MIN/MAX) instr support
Ties Stuij [Thu, 5 Jan 2023 11:19:56 +0000 (11:19 +0000)]
[AArch64][GlobalISel] implement GPR (U/S)(MIN/MAX) instr support

Lower umin, umax, smin, smax intrinsics to corresponding UMIN, UMAX, SMIN, SMAX
instructions when feat CSSC is available.

Reviewed By: aemerson

Differential Revision: https://reviews.llvm.org/D139420

18 months ago[Transforms] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:35:52 +0000 (12:35 +0100)]
[Transforms] Convert some tests to opaque pointers (NFC)

These are all tests where conversion worked automatically, and
required no manual fixup.

18 months ago[LoopVectorizer] Fix inloop reductions mask placement
David Green [Thu, 5 Jan 2023 11:37:37 +0000 (11:37 +0000)]
[LoopVectorizer] Fix inloop reductions mask placement

The validation of vplans could fail if an inloop reduction was created
with a block-in mask that did not dominate the reduction. This makes
sure that the insert point is set when creating the mask, to ensure it
dominates the reduction.

Differential Revision: https://reviews.llvm.org/D141003

18 months ago[CVP] Convert tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:34:36 +0000 (12:34 +0100)]
[CVP] Convert tests to opaque pointers (NFC)

18 months ago[SLPVectorizer] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:32:44 +0000 (12:32 +0100)]
[SLPVectorizer] Convert test to opaque pointers (NFC)

18 months ago[llvm-reduce] Remove typed pointer test (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:26:39 +0000 (12:26 +0100)]
[llvm-reduce] Remove typed pointer test (NFC)

There already is a test using opaque pointers instead.

18 months ago[UpdateTestChecks] Convert tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:19:16 +0000 (12:19 +0100)]
[UpdateTestChecks] Convert tests to opaque pointers (NFC)

18 months ago[Driver] move NetBSD header search path management to the driver
Brad Smith [Thu, 5 Jan 2023 11:08:42 +0000 (06:08 -0500)]
[Driver] move NetBSD header search path management to the driver

This matches OpenBSD and FreeBSD. https://reviews.llvm.org/D138183

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D140817

18 months ago[GlobalISel] New combine to commute constant operands to the RHS
Jay Foad [Tue, 3 Jan 2023 17:06:59 +0000 (17:06 +0000)]
[GlobalISel] New combine to commute constant operands to the RHS

Differential Revision: https://reviews.llvm.org/D140907

18 months ago[LinkModulesTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:11:12 +0000 (12:11 +0100)]
[LinkModulesTest] Convert to opaque pointers (NFC)

This requires switching to the ssa.copy intrinsic, otherwise
we don't preserve test intent.

18 months agoUse --pass-pipeline syntax for mlir/test/Dialect/LLVMIR/canonicalize.mlir (NFC)
Mehdi Amini [Wed, 4 Jan 2023 21:52:39 +0000 (21:52 +0000)]
Use --pass-pipeline syntax for mlir/test/Dialect/LLVMIR/canonicalize.mlir (NFC)

This is just a cleanup to make the scheduling of the pass pipeline
explicit.

18 months ago[OperationsTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 10:14:31 +0000 (11:14 +0100)]
[OperationsTest] Convert to opaque pointers (NFC)

18 months ago[RandomIRBuilderTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 10:08:23 +0000 (11:08 +0100)]
[RandomIRBuilderTest] Convert to opaque pointers (NFC)

The FirstClassTypes test is no longer relevant with opaque pointers,
or at least not in that form.

18 months ago[CodeGenOpenCLCXX] Convert tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:59:37 +0000 (10:59 +0100)]
[CodeGenOpenCLCXX] Convert tests to opaque pointers (NFC)

18 months ago[libc][NFC] Use a function instead of templated static member functions for TYPE_DESC
Guillaume Chatelet [Wed, 4 Jan 2023 12:48:01 +0000 (12:48 +0000)]
[libc][NFC] Use a function instead of templated static member functions for TYPE_DESC

I'm surprised that clang accepts the current code.
It seems odd to me to specialize templated static member variables.

GCC rejects them: https://godbolt.org/z/3ecE9Ps7T

This patch is in the context of https://github.com/llvm/llvm-project/issues/59368

Differential Revision: https://reviews.llvm.org/D140981

18 months agoApply clang-tidy fixes for performance-unnecessary-value-param in AffineCanonicalizat...
Mehdi Amini [Thu, 5 Jan 2023 00:58:52 +0000 (00:58 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in AffineCanonicalizationUtils.cpp (NFC)

18 months ago[CodeGenOpenCL] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:57:30 +0000 (10:57 +0100)]
[CodeGenOpenCL] Convert some tests to opaque pointers (NFC)

18 months ago[AsmParserTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:53:37 +0000 (10:53 +0100)]
[AsmParserTest] Convert to opaque pointers (NFC)

18 months ago[IVDescriptorsTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:48:29 +0000 (10:48 +0100)]
[IVDescriptorsTest] Convert to opaque pointers (NFC)

The LoopWithScalableTypes test is removed, because it is testing
a situation that cannot occur with opaque pointers. If we convert
this test to opaque pointers, it will not contain any scalable
types at all.

18 months ago[Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Brad Smith [Thu, 5 Jan 2023 09:39:46 +0000 (04:39 -0500)]
[Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Reviewed By: kparzysz, aheejin, MaskRay

Differential Revision: https://reviews.llvm.org/D140757

18 months ago[NFC][Coroutines] Build DominatorTree only once before collecting frame allocas ...
Dawid Jurczak [Sun, 1 Jan 2023 12:18:58 +0000 (13:18 +0100)]
[NFC][Coroutines] Build DominatorTree only once before collecting frame allocas (PR58650)

Assuming that collecting frame allocas doesn't modify CFG we can safely
move DominatorTree construction outside loop and avoid expensive computations.

Differential Revision: https://reviews.llvm.org/D140818

18 months ago[GlobalISel] Add G_BUILD_VECTOR[_TRUNC] to CSE
Diana Picus [Wed, 4 Jan 2023 10:58:58 +0000 (11:58 +0100)]
[GlobalISel] Add G_BUILD_VECTOR[_TRUNC] to CSE

Add G_BUILD_VECTOR and G_BUILD_VECTOR_TRUNC to the list of opcodes in
`shouldCSEOpc`. This simplifies the code generated for vector splats.

Differential Revision: https://reviews.llvm.org/D140965

18 months ago[GlobalISel] Don't switch opcodes in MIRBuilder::buildInstr
Diana Picus [Wed, 4 Jan 2023 10:59:49 +0000 (11:59 +0100)]
[GlobalISel] Don't switch opcodes in MIRBuilder::buildInstr

At the moment, `MachineIRBuilder::buildInstr` may build an instruction
with a different opcode than the one passed in as parameter. This may
cause confusion for its consumers, such as `CSEMIRBuilder`, which will
memoize the instruction based on the new opcode, but will search
through the memoized instructions based on the original one (resulting
in missed CSE opportunities). This is all the more unpleasant since
buildInstr is virtual and may call itself recursively both directly
and via buildCast, so it's not always easy to follow what's going on.

This patch simplifies the API of `MachineIRBuilder` so that the `buildInstr`
method does the least surprising thing (i.e. builds an instruction with
the specified opcode) and only the convenience `buildX` methods
(`buildMerge` etc) are allowed freedom over which opcode to use. This can
still be confusing (e.g. one might write a unit test using
`buildBuildVectorTrunc` but instead get a plain `G_BUILD_VECTOR`), but at
least it's explained in the comments.

In practice, this boils down to 3 changes:
* `buildInstr(G_MERGE_VALUES)` will no longer call itself with
`G_BUILD_VECTOR` or `G_CONCAT_VECTORS`; this functionality is moved to
`buildMerge` and replaced with an assert;
* `buildInstr(G_BUILD_VECTOR_TRUNC)` will no longer call itself with
`G_BUILD_VECTOR`; this functionality is moved to `buildBuildVectorTrunc`
and replaced with an assert;
* `buildInstr(G_MERGE_VALUES)` will no longer call `buildCast` and will
instead assert if we're trying to merge a single value; no change is
needed in `buildMerge` since it was already asserting more than one
source operand.

This change is NFC for users of the `buildX` methods, but users that
call `buildInstr` with relaxed parameters will have to update their code
(such instances will hopefully be easy to find thanks to the asserts).

Differential Revision: https://reviews.llvm.org/D140964

18 months ago[GlobalISel] Precommit a test for D140965
Diana Picus [Wed, 4 Jan 2023 13:15:31 +0000 (14:15 +0100)]
[GlobalISel] Precommit a test for D140965

Add a test for CSE-ing G_BUILD_VECTOR. This will be enabled in D140965.

18 months ago[NVPTX] Fix NVPTX lowering of frem when denominator is infinite.
Benjamin Chetioui [Thu, 5 Jan 2023 08:26:13 +0000 (09:26 +0100)]
[NVPTX] Fix NVPTX lowering of frem when denominator is infinite.

`frem x, {+,-}inf` must return x to match the specification of LLVM's frem.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D140846

18 months agoIntroduce environment variables to deal with JIT IR
Johannes Doerfert [Wed, 28 Dec 2022 07:50:42 +0000 (23:50 -0800)]
Introduce environment variables to deal with JIT IR

We can now dump the IR before and after JIT optimizations into the
files passed via `LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE` and
`LIBOMPTARGET_JIT_POST_OPT_IR_MODULE`, respectively.

Similarly, users can set `LIBOMPTARGET_JIT_REPLACEMENT_MODULE` to
replace the IR in the image with a custom IR module in a file.
All options take file paths, documentation was added.

Reviewed by: tianshilei1992

Differential revision: https://reviews.llvm.org/D140945

18 months ago[LoopUnrollAndJam] Visit phi operand dependencies in post-order
Joshua Cao [Fri, 16 Dec 2022 09:00:56 +0000 (04:00 -0500)]
[LoopUnrollAndJam] Visit phi operand dependencies in post-order

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

The previous implementation visits operands in pre-order, but this does
not guarantee an instruction is visited before its uses. This can cause
instructions to be copied in the incorrect order. For example:

```
a = ...
b = add a, 1
c = add a, b
d = add b, a
```

Pre-order visits does not guarantee the order in which `a` and `b` are
visited. LoopUnrollAndJam may incorrectly insert `b` before `a`.

This patch implements post-order visits. By visiting dependencies first,
we guarantee that an instruction's dependencies are visited first.

Differential Revision: https://reviews.llvm.org/D140255

18 months ago1: use class instead of MVT
Chen Zheng [Thu, 5 Jan 2023 07:53:59 +0000 (07:53 +0000)]
1: use class instead of MVT
2: minor fix for the comments

18 months ago[PowerPC][GISel]fcmp support
Chen Zheng [Tue, 3 Jan 2023 09:44:03 +0000 (09:44 +0000)]
[PowerPC][GISel]fcmp support

This patch also includes:
1: CRRegBank support
2: Some workarounds in PPC table gen for anyext/setcc patterns
   selection.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D140878

18 months ago[InstCombine][NFC] Regenerate test cases by update_test_checks.py
luxufan [Thu, 5 Jan 2023 06:38:08 +0000 (14:38 +0800)]
[InstCombine][NFC] Regenerate test cases by update_test_checks.py

18 months ago[InstCombine][NFC] Regenerate test cases by update_test_checks.py
luxufan [Thu, 5 Jan 2023 06:20:41 +0000 (14:20 +0800)]
[InstCombine][NFC] Regenerate test cases by update_test_checks.py

18 months ago[lldb] Remove unneeded .get() NFC
Fangrui Song [Thu, 5 Jan 2023 06:05:40 +0000 (22:05 -0800)]
[lldb] Remove unneeded .get() NFC