platform/upstream/llvm.git
22 months ago[StackLifetime] Fix sign compare warning (NFC)
Nikita Popov [Fri, 6 Jan 2023 15:10:47 +0000 (16:10 +0100)]
[StackLifetime] Fix sign compare warning (NFC)

22 months ago[MemCpyOpt] Extract processStoreOfLoad() method (NFC)
Nikita Popov [Fri, 6 Jan 2023 14:58:49 +0000 (15:58 +0100)]
[MemCpyOpt] Extract processStoreOfLoad() method (NFC)

22 months ago[Libomptarget] Add more moves to expected conversion
Joseph Huber [Fri, 6 Jan 2023 15:09:18 +0000 (09:09 -0600)]
[Libomptarget] Add more moves to expected conversion

Summary:
Fixes other instances of the same problem in the previous patch.

22 months ago[Libomptarget] Add move to expected conversion
Joseph Huber [Fri, 6 Jan 2023 14:56:31 +0000 (08:56 -0600)]
[Libomptarget] Add move to expected conversion

Summary:
These implicit conversions from move-only types to expected seem to only
work with newer compilers. This should hopefully fix it.

22 months ago[mlir] fix use-after-free on error path in transform dialect
Alex Zinenko [Fri, 6 Jan 2023 15:02:14 +0000 (16:02 +0100)]
[mlir] fix use-after-free on error path in transform dialect

22 months ago[clang-format] fix template closer followed by >
Backl1ght [Fri, 6 Jan 2023 13:05:15 +0000 (21:05 +0800)]
[clang-format] fix template closer followed by >

fix https://github.com/llvm/llvm-project/issues/59785

Reviewed By: HazardyKnusperkeks, MyDeveloperDay, owenpan

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

22 months ago[IR] Use isEntryBlock() API (NFC)
Nikita Popov [Fri, 6 Jan 2023 14:43:02 +0000 (15:43 +0100)]
[IR] Use isEntryBlock() API (NFC)

22 months ago[IR] Add AllocaInst::getAllocationSize() (NFC)
Nikita Popov [Fri, 6 Jan 2023 14:33:39 +0000 (15:33 +0100)]
[IR] Add AllocaInst::getAllocationSize() (NFC)

When fetching allocation sizes, we almost always want to have the
size in bytes, but we were only providing an InBits API. Also add
the corresponding byte-based conjugate to save some *8 and /8
juggling everywhere.

22 months ago[SDAG] try to avoid multiply for X*Y==0
Sanjay Patel [Fri, 6 Jan 2023 13:49:19 +0000 (08:49 -0500)]
[SDAG] try to avoid multiply for X*Y==0

Forking this off from D140850 -
https://alive2.llvm.org/ce/z/TgBeK_
https://alive2.llvm.org/ce/z/STVD7d

We could almost justify doing this in IR, but consideration for
"minsize" requires that we only try it in codegen -- the
transform is not reversible.

In all other cases, avoiding multiply should be a win because a
mul is more expensive than simple/parallelizable compares. AArch
even has a trick to keep instruction count even for some types.

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

22 months agoAMDGPU/GlobalISel: Add missing test for implicit_def regbankselect
Matt Arsenault [Fri, 30 Dec 2022 14:45:32 +0000 (09:45 -0500)]
AMDGPU/GlobalISel: Add missing test for implicit_def regbankselect

22 months agoAMDGPU/GlobalISel: Add wave32 checks to bool test
Matt Arsenault [Tue, 27 Dec 2022 23:26:54 +0000 (18:26 -0500)]
AMDGPU/GlobalISel: Add wave32 checks to bool test

22 months ago[C++20] Determine the dependency of unevaluated lambdas more accurately
Liming Liu [Fri, 6 Jan 2023 13:56:25 +0000 (05:56 -0800)]
[C++20] Determine the dependency of unevaluated lambdas more accurately

During template instantiation, the instantiator will enter constant
evaluated
context before instantiate a template argument originated from an
expression,
and this impedes the instantiator from creating lambdas with independent
types.

This patch solves the problem via widening the condition that the
instantiator
marks lambdas as never dependent, and fixes the issue #57960

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

22 months ago[AMDGPU] Add a feature for VALUTransUseHazard
Jay Foad [Fri, 6 Jan 2023 11:09:36 +0000 (11:09 +0000)]
[AMDGPU] Add a feature for VALUTransUseHazard

NFCI. This just allows us to experiment with enabling/disabling the
workaround on different subtargets.

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

22 months ago[llvm-exegesis][NFC] Update benchmark phase naming to match documentation
Guillaume Chatelet [Fri, 6 Jan 2023 13:24:44 +0000 (13:24 +0000)]
[llvm-exegesis][NFC] Update benchmark phase naming to match documentation

22 months ago[mlir][memref] Add runtime verification for memref::CastOp
Matthias Springer [Fri, 6 Jan 2023 13:24:30 +0000 (14:24 +0100)]
[mlir][memref] Add runtime verification for memref::CastOp

Verify unranked -> ranked casts and casts of dynamic sizes/offset/strides to static ones.

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

22 months ago[AArch64] add tests for x*y == 0; NFC
Sanjay Patel [Thu, 5 Jan 2023 20:35:24 +0000 (15:35 -0500)]
[AArch64] add tests for x*y == 0; NFC

22 months ago[x86] add tests for x*y == 0; NFC
Sanjay Patel [Thu, 5 Jan 2023 19:58:56 +0000 (14:58 -0500)]
[x86] add tests for x*y == 0; NFC

22 months ago[UpdateTestChecks] Do not add --force-update to UTC_ARGS
Alex Richardson [Fri, 6 Jan 2023 13:23:10 +0000 (13:23 +0000)]
[UpdateTestChecks] Do not add --force-update to UTC_ARGS

Persisting this flag only introduces test churn.

Reviewed By: nikic

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

22 months agoMake switch-to-lookup-large-types.ll more reliable
Alex Richardson [Fri, 6 Jan 2023 13:20:11 +0000 (13:20 +0000)]
Make switch-to-lookup-large-types.ll more reliable

When larger integer types are natively supported simplifycfg will use an
inline constant instead of a global variable for this transform. I noticed
this while trying to automatically infer the datalayout from the target
triple in opt if it is not explicitly specified. Since the x86_64
datalayout includes "n8:16:32:64", this test started failing.

While touching this file also change i128 to i64 in the first test since
this was intended behaviour in the original commit.

Reviewed By: spatel, fhahn

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

22 months ago[CallSiteSplitting] Convert test to opaque pointers (NFC)
Nikita Popov [Fri, 6 Jan 2023 13:34:41 +0000 (14:34 +0100)]
[CallSiteSplitting] Convert test to opaque pointers (NFC)

Keeping the bitcasts here because this is in part testing the
(legal) bitcast after a musttail call, even though it's no longer
really relevant.

22 months ago[gn build] Port 4670d5ece57d
LLVM GN Syncbot [Fri, 6 Jan 2023 13:20:13 +0000 (13:20 +0000)]
[gn build] Port 4670d5ece57d

22 months ago[NFC] Vastly simplifies TypeSize
Guillaume Chatelet [Sat, 17 Dec 2022 17:48:36 +0000 (17:48 +0000)]
[NFC] Vastly simplifies TypeSize

Simplifies the implementation of `TypeSize` while retaining its interface.
There is no need for abstract concepts like `LinearPolyBase`, `UnivariateLinearPolyBase` or `LinearPolySize`.

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

22 months ago[WebAssembly] Explicitly add {z,s}ext so extends are selected
Luke Lau [Tue, 3 Jan 2023 19:37:16 +0000 (19:37 +0000)]
[WebAssembly] Explicitly add {z,s}ext so extends are selected

During DAG legalization, {u,s}itofp instructions on v2i8, v2i16, v4i8
and v4i16 types ended up being legalized into scalar instructions, when
they could just be extended to v2i32/v4i32 instead.

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

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

22 months ago[mlir] adapt TransformEachOpTrait to parameter values
Alex Zinenko [Tue, 3 Jan 2023 16:01:07 +0000 (16:01 +0000)]
[mlir] adapt TransformEachOpTrait to parameter values

Adapt the implementation of TransformEachOpTrait to the existence of
parameter values recently introduced into the transform dialect. In
particular, allow `applyToOne` hooks to return a list containing a mix
of `Operation *` that will be associated with handles and `Attribute`
that will be associated with parameter values by the trait
implementation of the transform interface's `apply` method.

Disentangle the "transposition" of the list of per-payload op partial
results to decrease its overall complexity and detemplatize the code
that doesn't really need templates. This removes the poorly documented
special handling for single-result ops with TransformEachOpTrait that
could have assigned null pointer values to handles.

Reviewed By: springerm

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

22 months ago[mlir] NFC: move DiagnosedSilenceableFailure to Utils in Transform dialect
Alex Zinenko [Mon, 2 Jan 2023 17:11:40 +0000 (17:11 +0000)]
[mlir] NFC: move DiagnosedSilenceableFailure to Utils in Transform dialect

It was originally placed in TransformInterfaces for convenience, but it
is really a generic utility. It may also create an include cycle between
TransformTypes and TransformInterfaces if the latter needs to include
the former because the former uses the failure util.

Reviewed By: springerm

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

22 months ago[mlir] NFC: rename TransformTypeInterface to TransformHandleTypeInterface
Alex Zinenko [Mon, 2 Jan 2023 13:58:53 +0000 (13:58 +0000)]
[mlir] NFC: rename TransformTypeInterface to TransformHandleTypeInterface

This makes it more consistent with the recently added
TransformParamTypeInterface.

Reviewed By: springerm

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

22 months ago[mlir] introduce parameters into the transofrm dialect
Alex Zinenko [Mon, 2 Jan 2023 13:07:02 +0000 (13:07 +0000)]
[mlir] introduce parameters into the transofrm dialect

Introduce a new kind of values into the transform dialect -- parameter
values. These values have a type implementing the new
`TransformParamTypeInterface` and are associated with lists of
attributes rather than lists of payload operations. This mechanism
allows one to wrap numeric calculations, typically heuristics, into
transform operations separate from those at actually applying the
transformation. For example, tile size computation can be now separated
from tiling itself, and not hardcoded in the transform dialect. This
further improves the separation of concerns between transform choice and
implementation.

Reviewed By: springerm

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

22 months ago[bazel] Add missing :Support dependency after 1b8224537070
Benjamin Kramer [Fri, 6 Jan 2023 11:51:01 +0000 (12:51 +0100)]
[bazel] Add missing :Support dependency after 1b8224537070

22 months ago[mlir][tensor] Support parallel_insert_slice in MergeConsecutiveInsertExtractSlicePat...
Matthias Springer [Fri, 6 Jan 2023 10:59:30 +0000 (11:59 +0100)]
[mlir][tensor] Support parallel_insert_slice in MergeConsecutiveInsertExtractSlicePatterns.cpp

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

22 months ago[mlir][linalg] Swap extract_slice(fill(x)) ops
Matthias Springer [Fri, 6 Jan 2023 10:59:41 +0000 (11:59 +0100)]
[mlir][linalg] Swap extract_slice(fill(x)) ops

This pattern is similar to `FoldFillWithTensorReshape`, which performs the same swapping with reshapes.

Fill the smaller extracted tensor slice instead of `x`. This allows for additional simplifications in case `x` is the result of another extract_slice.

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

22 months ago[clang][analyzer] Extend StreamChecker with some new functions.
Balázs Kéri [Fri, 6 Jan 2023 10:21:41 +0000 (11:21 +0100)]
[clang][analyzer] Extend StreamChecker with some new functions.

The stream handling functions `ftell`, `rewind`, `fgetpos`, `fsetpos`
are evaluated in the checker more exactly than before.
New tests are added to test behavior of the checker together with
StdLibraryFunctionsChecker. The option ModelPOSIX of that checker
affects if (most of) the stream functions are recognized, and checker
StdLibraryFunctionArgs generates warnings if constraints for arguments
are not satisfied. The state of `errno` is set by StdLibraryFunctionsChecker
too for every case in the stream functions.
StreamChecker works with the stream state only, does not set the errno state,
and is not dependent on other checkers.

Reviewed By: Szelethus

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

22 months ago[Transforms] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 6 Jan 2023 11:09:52 +0000 (12:09 +0100)]
[Transforms] Convert some tests to opaque pointers (NFC)

22 months ago[AArch64] add GlobalIsel support for scalar CNT instruction
Ties Stuij [Fri, 6 Jan 2023 10:09:46 +0000 (10:09 +0000)]
[AArch64] add GlobalIsel support for scalar CNT instruction

When feature CSSC is available we should use instruction CNT for s32, s64 and
s128 types in GlobalIsel's G_CTPOP.

spec:
https://developer.arm.com/documentation/ddi0602/2022-09/Base-Instructions/CNT--Count-bits-

Reviewed By: aemerson

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

22 months ago[GlobalSplit] Convert test to opaque pointers (NFC)
Nikita Popov [Fri, 6 Jan 2023 11:07:06 +0000 (12:07 +0100)]
[GlobalSplit] Convert test to opaque pointers (NFC)

22 months ago[ConstantFold] Don't drop zero index gep with inrange attribute
Nikita Popov [Fri, 6 Jan 2023 11:02:52 +0000 (12:02 +0100)]
[ConstantFold] Don't drop zero index gep with inrange attribute

This may cause GlobalSplit to fail if opaque pointers are used.

inrange really needs a new representation, but for now restore the
pre-opaque pointers status.

22 months agoNFC Address review comment for D140905
OCHyams [Fri, 6 Jan 2023 10:58:12 +0000 (10:58 +0000)]
NFC Address review comment for D140905

22 months ago[LV] Disable runtime unrolling for vectorized loops.
Florian Hahn [Fri, 6 Jan 2023 10:56:17 +0000 (10:56 +0000)]
[LV] Disable runtime unrolling for vectorized loops.

This patch adds metadata to disable runtime unrolling to the vectorized
loop. If runtime unrolling/interleaving is considered profitable, LV
will interleave the loop directly. There should be no need to perform
runtime unrolling at a later stage.

Note that we already add metadata to disable runtime unrolling to the
scalar loop after vectorization.

The additional unrolling unnecessarily increases code size and compile
time. In addition to that we have several bug reports of unncessary
runtime unrolling for vectorized loops, e.g. PR40961

Compile-time improvements:

  NewPM-O3: -1.04%
  NewPM-ReleaseThinLTO: -0.59%
  NewPM-ReleaseLTO-g: -0.97%

https://llvm-compile-time-tracker.com/compare.php?from=ce1be13a868d0f8afa367975558c1a6175cce33a&to=78bc2e67f22e9e10e61cdb6cdac4bb857d95eb1b&stat=instructions:u

Fixes #40306.

Reviewed By: lebedev.ri, nikic

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

22 months ago[DebugInfo] Replace UndefValue with PoisonValue in setKillLocation
OCHyams [Fri, 6 Jan 2023 10:49:13 +0000 (10:49 +0000)]
[DebugInfo] Replace UndefValue with PoisonValue in setKillLocation

This helps towards the effort to remove UndefValue from LLVM.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: nlopes

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

22 months ago[LoopUnroll] Convert test to opaque pointers (NFC)
Nikita Popov [Fri, 6 Jan 2023 10:47:32 +0000 (11:47 +0100)]
[LoopUnroll] Convert test to opaque pointers (NFC)

22 months ago[LoopUnroll] Name instructions in test (NFC)
Nikita Popov [Fri, 6 Jan 2023 10:46:59 +0000 (11:46 +0100)]
[LoopUnroll] Name instructions in test (NFC)

22 months agoApply clang-tidy fixes for performance-unnecessary-value-param in SparseTensorCodegen...
Mehdi Amini [Thu, 5 Jan 2023 19:28:48 +0000 (19:28 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in SparseTensorCodegen.cpp (NFC)

22 months ago[LoopIdiom] Convert tests to opaque pointers (NFC)
Nikita Popov [Fri, 6 Jan 2023 10:19:48 +0000 (11:19 +0100)]
[LoopIdiom] Convert tests to opaque pointers (NFC)

The differences here are due to SCEVExpander producing GEPs with
explicit offset calculation, a known difference with opaque pointers.

22 months ago[cmake] Add llvm-debuginfod as test dependency
Luke Lau [Thu, 5 Jan 2023 17:46:22 +0000 (17:46 +0000)]
[cmake] Add llvm-debuginfod as test dependency

llvm-debuginfod is used by llvm-lit as of
36f01909a0e29c1014301ed6835687a84bf0e9fa, so adding this dependency
fixes a "note: Did not find llvm-debuginfod" warning from showing up
when running tests.

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

22 months ago[DebugInfo] Prefer setKillLocation rather than replacing operands with undef
OCHyams [Fri, 6 Jan 2023 09:16:50 +0000 (09:16 +0000)]
[DebugInfo] Prefer setKillLocation rather than replacing operands with undef

NFC-ish. There is a functional change but the outputs are semantically
identical. Where we might've before replaced one operand with undef (which
means "this is a kill location marker") the use of `setKillLocation` will
replace all location operands with `undef` (which also means "this is a kill
location marker").

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: StephenTozer

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

22 months ago[LoopIdiom] Name instructions in test (NFC)
Nikita Popov [Fri, 6 Jan 2023 10:07:42 +0000 (11:07 +0100)]
[LoopIdiom] Name instructions in test (NFC)

22 months ago[clang][analyzer] Add stream related functions to StdLibraryFunctionsChecker.
Balázs Kéri [Fri, 6 Jan 2023 08:57:37 +0000 (09:57 +0100)]
[clang][analyzer] Add stream related functions to StdLibraryFunctionsChecker.

Additional stream handling functions are added.
These are partially evaluated by StreamChecker, result of the addition is
check for more preconditions and construction of success and failure branches
with specific errno handling.

Reviewed By: Szelethus

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

22 months ago[X86] Add tests for atomic bittest with register/memory operands
Noah Goldstein [Fri, 6 Jan 2023 07:24:15 +0000 (15:24 +0800)]
[X86] Add tests for atomic bittest with register/memory operands

Reviewed By: pengfei

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

22 months ago[libc] Add a section about supported compilers in the documentation
Guillaume Chatelet [Thu, 5 Jan 2023 13:35:09 +0000 (13:35 +0000)]
[libc] Add a section about supported compilers in the documentation

Context https://github.com/llvm/llvm-project/issues/59368

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

22 months ago[DebugInfo][NFC] Rename is/setUndef to is/setKilllocation
OCHyams [Fri, 6 Jan 2023 08:42:18 +0000 (08:42 +0000)]
[DebugInfo][NFC] Rename is/setUndef to is/setKilllocation

These names better reflect the semantics and also the implementation, since
it's not just "undef" operands that are sentinels used to signal that the debug
intrinsic terminates dominating locations definitions.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: StephenTozer

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

22 months ago[lldb] Allow configuring on Windows with python interpreter within a junction
Markus Böck [Fri, 6 Jan 2023 08:54:55 +0000 (09:54 +0100)]
[lldb] Allow configuring on Windows with python interpreter within a junction

The current implementation nicely takes into account when the python interpreter is symlinked (or transitively within a symlinked directory). Sadly, `os.path.islink` returns `false` on Windows if instead of Windows symlinks, junctions are used. This has caused me issues after I started using `scoop` as my package manager on Windows, which creates junctions instead of symlinks.
The fix proposed in this patch is to check whether `realpath` returns a different path to `exe`, and if it does, to simply try again with that path.
The code could also be simplified since `sys.executable` is guaranteed to be absolute, and `os.readlink`, which can return a relative path, is no longer used.

Tested on Windows 11 with Python 3.11 as interpreter and Ubuntu 18.04 with Python 3.6

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

22 months ago[flang] add hlfir.null to implement NULL()
Jean Perier [Fri, 6 Jan 2023 08:57:08 +0000 (09:57 +0100)]
[flang] add hlfir.null to implement NULL()

In HLFIR, the address of a Fortran entity in lowering must be defined
by an operation that has the FortranVariableOpInterface (it is a sanity
requirement to ensure that the mlir::Value propagated in certain places
of lowering can be reasoned about).
fir.zero_bits does not have this interface and it makes little sense to
add it since it can "zero initialize" more types than just addresses.

Creating an hlfir.declare for null addresses is a bit too much (what
would be the name), and it would be noisy in the IR.

Instead add a small hlfir.null operation whose codegen is simply a
replacement by fir.zero_bits.

It may also later help dealing with the NULL(MOLD) cases in a nicer
way (the current lowering of this uses special handling it).

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

22 months ago[CodeGen][AMDGPU] EXTRACT_VECTOR_ELT: input vector element type can differ from outpu...
Juan Manuel MARTINEZ CAAMAÑO [Fri, 6 Jan 2023 08:45:36 +0000 (09:45 +0100)]
[CodeGen][AMDGPU] EXTRACT_VECTOR_ELT: input vector element type can differ from output type

In function SITargetLowering::performExtractVectorElt,
the output type was not considered which could lead to type mismatches
later.

Reviewed By: arsenm

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

22 months agoRevert "CodingStandards: restrict CamelCase variable names guideline to llvm/clang...
Nikita Popov [Fri, 6 Jan 2023 08:44:27 +0000 (09:44 +0100)]
Revert "CodingStandards: restrict CamelCase variable names guideline to llvm/clang/clang-tools-extra/polly/bolt"

This reverts commit ee9ccb11036ac46ff9b9f3fa2d459d9d2bce5509.

See https://reviews.llvm.org/D140585#4019417 and following.
Multiple people requested a revert of this change pending further
discussion.

22 months agoRevert "[X86] Revert -fno-plt __tls_get_addr workaround for old GNU ld"
Nikita Popov [Fri, 6 Jan 2023 08:37:45 +0000 (09:37 +0100)]
Revert "[X86] Revert -fno-plt __tls_get_addr workaround for old GNU ld"

This reverts commit 2679e8bba3e166e3174971d040b9457ec7b7d768.

This change is a significant backwards-compatibility break, which
does in fact break the entire Rust ecosystem, which uses an
-fno-plt -mrelax-relocations=0 default.

Please go through pre-commit review for this change in order to
gain broader consensus.

22 months ago[NFC] [Coroutines] Move collectFrameAlloca to decrease the times to iterate the function
Chuanqi Xu [Fri, 6 Jan 2023 08:34:48 +0000 (16:34 +0800)]
[NFC] [Coroutines] Move collectFrameAlloca to decrease the times to iterate the function

Previously in collectFrameAllocas, we will iterate every instruction in
the Function and we will iterate the function again later. It is
redundnt.

22 months ago[Sema] Fix crash when evaluating nested call with value-dependent arg
Pierre van Houtryve [Tue, 13 Dec 2022 08:50:41 +0000 (03:50 -0500)]
[Sema] Fix crash when evaluating nested call with value-dependent arg

Fix an edge case `ExprConstant.cpp`'s `EvaluateWithSubstitution` when called by `CheckEnableIf`

The assertion in `CallStackFrame::getTemporary`
could fail during evaluation of nested calls to a function
using `enable_if` when the second argument was a
value-dependent expression.

This caused a temporary to be created for the second
argument with a given version during the
evaluation of the inner call, but we bailed out
when evaluating the second argument of the
outer call due to the expression being value-dependent.
After bailing out, we tried to clean up the argument's value slot but it
caused an assertion to trigger in `getTemporary` as
a temporary for the second argument existed, but only for the inner call and not the outer call.

See the test case for a more complete description of the issue.

Reviewed By: ahatanak

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

22 months ago[NFC] Test commit.
Benjamin Chetioui [Fri, 6 Jan 2023 07:25:44 +0000 (07:25 +0000)]
[NFC] Test commit.

22 months ago[VP][RISCV] Add vp.abs and RISC-V support.
Yeting Kuo [Thu, 5 Jan 2023 07:01:16 +0000 (15:01 +0800)]
[VP][RISCV] Add vp.abs and RISC-V support.

RISC-V uses ISD::ABS lower method (abs x) -> (smax_vl x (sub_vl 0, x)) for ISD::VP_ABS.

Reviewed By: craig.topper

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

22 months agoSave the result of getenv() to a string
Akira Hatanaka [Fri, 6 Jan 2023 06:06:50 +0000 (22:06 -0800)]
Save the result of getenv() to a string

The result has to be saved to a string as the result might be
overwritten by subsequent calls to getenv.

https://pubs.opengroup.org/onlinepubs/009696899/functions/getenv.html

See the discussion here: https://reviews.llvm.org/D137996#4029305

22 months ago[X86] Add additional tests to no-shift.ll
Noah Goldstein [Fri, 6 Jan 2023 06:08:25 +0000 (14:08 +0800)]
[X86] Add additional tests to no-shift.ll

Reviewed By: pengfei

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

22 months ago[Driver] Simplify -fsanitize-memory-track-origins handling. NFC
Fangrui Song [Fri, 6 Jan 2023 06:21:13 +0000 (22:21 -0800)]
[Driver] Simplify -fsanitize-memory-track-origins handling. NFC

22 months agoRevert "[Fix]"[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that...
ziqingluo-90 [Fri, 6 Jan 2023 06:02:43 +0000 (22:02 -0800)]
Revert "[Fix]"[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations""

This reverts commit ef47a0a711f12add401394f7af07a0b4d1635b56.

Revert "[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations"

This reverts commit b2ac5fd724c44cf662caed84bd8f84af574b981d.

This patch is causing failure in some Sanitizer tests
(https://lab.llvm.org/buildbot/#/builders/5/builds/30522/steps/13/logs/stdio).  Reverting the patch and its' fix.

22 months ago[RegAllocFast] Handle new debug values for spills
Josh Stone [Wed, 4 Jan 2023 00:04:45 +0000 (16:04 -0800)]
[RegAllocFast] Handle new debug values for spills

These new debug values get inserted after the place where the spill
happens, which means they won't be reached by the reverse traversal of
basic block instructions. This would crash or fail assertions if they
contained any virtual registers to be replaced. We can manually handle
the new debug values right away to resolve this.

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

Reviewed By: StephenTozer

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

22 months ago[Sema] Fix a bug where clang doesn't detect uses of unavailable decls
Akira Hatanaka [Fri, 6 Jan 2023 04:09:56 +0000 (20:09 -0800)]
[Sema] Fix a bug where clang doesn't detect uses of unavailable decls
in C++ base or member initializers

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

22 months ago[CodeGen][ObjC] Fix a memory leak that occurs when a non-trivial C
Akira Hatanaka [Fri, 6 Jan 2023 03:48:25 +0000 (19:48 -0800)]
[CodeGen][ObjC] Fix a memory leak that occurs when a non-trivial C
struct property is set using dot notation

Make sure the destructor is called if needed.

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

22 months ago[LoongArch] Add intrinsics for CACOP instruction
Xiaodong Liu [Fri, 6 Jan 2023 01:32:20 +0000 (09:32 +0800)]
[LoongArch] Add intrinsics for CACOP instruction

The CACOP instruction is mainly used for cache initialization
and cache-consistency maintenance.

Depends on D140872

Reviewed By: SixWeining

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

22 months ago[mlir] Fix build error due to -Wsign-compare after revision D140871
Jie Fu [Fri, 6 Jan 2023 03:36:13 +0000 (19:36 -0800)]
[mlir] Fix build error due to -Wsign-compare after revision D140871

This patch fixes build failure due to -Wsign-compare in sparse2SparseRewrite(...) after https://reviews.llvm.org/D140871.

```
llvm-project/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp:842:32: error: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long') and 'int64_t' (aka 'long') [-Werror,-Wsign-compare]
        for (uint64_t i = 0; i < rank; i++) {
                             ~ ^ ~~~~
1 error generated.
```

Reviewed By: MaskRay

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

22 months ago[clang-format] Disallow decltype in the middle of constraints
Emilia Dreamer [Fri, 6 Jan 2023 03:18:19 +0000 (05:18 +0200)]
[clang-format] Disallow decltype in the middle of constraints

If a function with a `requires` clause as a constraint has a decltype
return type, such as `decltype(auto)`, the decltype was seen to be part
of the constraint clause, rather than as part of the function
declaration, causing it to be placed on the wrong line.

This patch disallows decltype to be a part of these clauses

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

Depends on D140339

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

22 months ago[clang-format] Remove special logic for parsing concept definitions.
Emilia Dreamer [Fri, 6 Jan 2023 03:13:58 +0000 (05:13 +0200)]
[clang-format] Remove special logic for parsing concept definitions.

Previously, clang-format relied on a special method to parse concept
definitions, `UnwrappedLineParser::parseConcept()`, which deferred to
`UnwrappedLineParser::parseConstraintExpression()`. This is problematic,
because the C++ grammar treats concepts and requires clauses
differently, causing issues such as https://github.com/llvm/llvm-project/issues/55898 and https://github.com/llvm/llvm-project/issues/58130.

This patch removes `parseConcept`, letting the formatter parse concept
definitions as more like what they actually are, fancy bool definitions.

NOTE that because of this, some long concept definitions change in their
formatting, as can be seen in the changed tests. This is because of a
change in split penalties, caused by a change in MightBeFunctionDecl on
the concept definition line, which was previously `true` but with this
patch is now `false`.

One might argue that `false` is a more "correct" value for concept
definitions, but I'd be fine with setting it to `true` again to maintain
compatibility with previous versions.

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

Depends on D140330

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

22 months ago[clang-format] Require space before noexcept qualifier
Emilia Dreamer [Fri, 6 Jan 2023 03:03:29 +0000 (05:03 +0200)]
[clang-format] Require space before noexcept qualifier

This brings the noexcept qualifier more visually in line with the other
keyword qualifiers, such as "final" and "override".

Originally reported as https://github.com/llvm/llvm-project/issues/44542,
it was closed as "working by design" and reinforcing tests were added
as part of a218706cba90248be0c60bd6a8f10dbcf0270955. The exact spacing
depended on the `PointerAlignment` option, where the default value of
`Right` would leave no space.

This patch seeks to change this behaviour, regardless of the configured
`PointerAlignment` option (matching the previous behaviour of the `Left`
option).

Closes https://github.com/llvm/llvm-project/issues/59729

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

22 months agoFix for tests on Windows buildbot
Brad Smith [Fri, 6 Jan 2023 02:24:36 +0000 (21:24 -0500)]
Fix for tests on Windows buildbot

22 months ago[PowerPC] remove the ctr clobbers check related to TLS access
Chen Zheng [Fri, 6 Jan 2023 02:22:18 +0000 (21:22 -0500)]
[PowerPC] remove the ctr clobbers check related to TLS access

Dynamic tls access model will be lowered to MI which clobbers CTR in
the loop in ISEL(ADDItlsgdLADDR) and post-isel CTR loop pass will revert
the loop to a normal compare + branch form.

So no need to add this clobber check in hardware loop insertion pass now.

Reviewed By: nemanjai

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

22 months ago[Driver] move Fuchsia header search path management to the driver
Brad Smith [Fri, 6 Jan 2023 02:18:12 +0000 (21:18 -0500)]
[Driver] move Fuchsia header search path management to the driver

Fuchsia already implements AddClangSystemIncludeArgs(). So it looks like we
just have to switch over to using it.

Reviewed By: phosek

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

22 months ago[PowerPC][NFC] add an option to keep the test point
Chen Zheng [Fri, 6 Jan 2023 01:46:52 +0000 (20:46 -0500)]
[PowerPC][NFC] add an option to keep the test point

Passes before hardware loop insertion change the loop to a form which
is not a hardware loop candidate (return early before checking the ctr clobbers).
And the PHI in the loop exit block is also optimized away. This breaks the
previous test point when the case was committed. Fixing this by running this
case just before hardware loop insertion pass.

Reviewed By: nemanjai

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

22 months ago[LoongArch] Add "32bit" target feature
Xiaodong Liu [Fri, 6 Jan 2023 01:18:11 +0000 (09:18 +0800)]
[LoongArch] Add "32bit" target feature

There are a few intrinsics or instructions on LoongArch
that are only appropriate for loongarch32 target. So the
feature "32bit" is added to implement it.

Reviewed By: SixWeining

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

22 months ago[LoongArch] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Brad Smith [Fri, 6 Jan 2023 01:18:59 +0000 (20:18 -0500)]
[LoongArch] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Reviewed By: SixWeining, MaskRay

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

22 months ago[mlir][spirv] Add smul_extended expansion for WebGPU
Jakub Kuderski [Fri, 6 Jan 2023 01:11:46 +0000 (20:11 -0500)]
[mlir][spirv] Add smul_extended expansion for WebGPU

We need this because WGSL does not support extended multiplication ops.

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

Reviewed By: antiagainst

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

22 months agoRevert "[clang][dataflow] Only model struct fields that are used in the function...
Yitzhak Mandelbaum [Fri, 6 Jan 2023 01:07:28 +0000 (01:07 +0000)]
Revert "[clang][dataflow] Only model struct fields that are used in the function being analyzed."

This reverts commit 5e8f597c2fedc740b71f07dfdb1ef3c2d348b193. It caused msan and ubsan breakages.

22 months ago[RISCV] Rename SDT_RISCVVecCvtX2FOp_VL->SDT_RISCVVecCvtF2XOp_VL. NFC
Craig Topper [Fri, 6 Jan 2023 00:35:59 +0000 (16:35 -0800)]
[RISCV] Rename SDT_RISCVVecCvtX2FOp_VL->SDT_RISCVVecCvtF2XOp_VL. NFC

The instruction name is x.f with the destination type first. The
template name was intended as "convert F to X". So the F comes first.

22 months ago[LSAN][NFC] Removed FinishThreadLocked from the LSAN interface.
Kirill Stoimenov [Fri, 6 Jan 2023 00:08:59 +0000 (00:08 +0000)]
[LSAN][NFC] Removed FinishThreadLocked from the LSAN interface.

It is only used in the LSAN specific part.

Reviewed By: vitalybuka

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

22 months ago[AMDGPU] Switch to autogenerated checks
Jeffrey Byrnes [Fri, 6 Jan 2023 00:22:04 +0000 (16:22 -0800)]
[AMDGPU] Switch to autogenerated checks

22 months ago[NFC][MLIR] Adding better names to lit test for pooling vectorization
Murali Vijayaraghavan [Thu, 5 Jan 2023 23:50:05 +0000 (23:50 +0000)]
[NFC][MLIR] Adding better names to lit test for pooling vectorization

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

22 months ago[mlir][sparse] Replace sparse_tensor.sort with sparse_tensor.sort_coo for sorting...
bixia1 [Thu, 5 Jan 2023 17:39:23 +0000 (09:39 -0800)]
[mlir][sparse] Replace sparse_tensor.sort with sparse_tensor.sort_coo for sorting COO tensors.

Add codegen pattern for sparse_tensor.indices_buffer.

Reviewed By: aartbik

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

22 months ago[mlir][spirv] Fix extended umul expansion for WebGPU
Jakub Kuderski [Thu, 5 Jan 2023 23:37:49 +0000 (18:37 -0500)]
[mlir][spirv] Fix extended umul expansion for WebGPU

Fix an off-by-one error in extended umul extension for WebGPU.
Revert to the long multiplication algorithm originally added to wide
integer emulation, which was deleted in D139776. It is much easier
to see why it is correct.

Add runtime tests based on the mlir-vulkan-runner. These run both with
and without umul extension.

Issue: https://github.com/llvm/llvm-project/issues/59563

Reviewed By: antiagainst

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

22 months ago[clang-format] Add an option to insert a newline at EOF if missing
Owen Pan [Thu, 5 Jan 2023 07:55:10 +0000 (23:55 -0800)]
[clang-format] Add an option to insert a newline at EOF if missing

Closes #38042.

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

22 months ago[mlir][linalg] Vectorize 1D convolution
Murali Vijayaraghavan [Thu, 5 Jan 2023 23:08:11 +0000 (23:08 +0000)]
[mlir][linalg] Vectorize 1D convolution

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

22 months ago[LVI] Look through negations when evaluating conditions
Keno Fischer [Wed, 4 Jan 2023 01:49:17 +0000 (01:49 +0000)]
[LVI] Look through negations when evaluating conditions

This teaches LVI (and thus CVP) to extract range information
from branches whose condition is negated using (`xor %c, true`).
On the implementation side, we switch the cache to additionally
track whether we're looking for the inverted value or not and
otherwise using the existing support for computing inverted
conditions.

I think the biggest question here is why this negation shows up
here at all. After all, it should always be possible for some
other pass to fold such a negation into a branch, comparison or
some other logical operation. Indeed, instcombine does just that.
However, these negations can be otherwise fairly persistent, e.g.
instsimplify is not able to exchange branch conditions from
negations. In addition, jumpthreading, which sits at the same
point in default pass pipeline also handles this pattern, which
adds further evidence that we might expect these negations to
not have been canonicalized away yet at this point in the pass
pipeline.

In the particular case I was looking at there was a bit of a
circular dependency where flags computed by cvp were needed
by instcombine, and incstombine's folding of the negation was
needed for cvp. Adding a second instombine pass would have
worked of course, but instcombine can be somewhat expensive,
so it appeared desirable to not require it to have run
before cvp (as is the case in the default pass pipeline).

Reviewed By: nikic

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

22 months ago[C] Make (c ? e1 : e2) noreturn only if both e1 and e2 are noreturn
Fangrui Song [Thu, 5 Jan 2023 22:36:36 +0000 (14:36 -0800)]
[C] Make (c ? e1 : e2) noreturn only if both e1 and e2 are noreturn

In C mode, if e1 has __attribute__((noreturn)) but e2 doesn't, `(c ? e1 : e2)`
is incorrectly noreturn and Clang codegen produces `unreachable`
which may lead to miscompiles (see [1] `gawk/support/dfa.c`).
This problem has been known since
8c6b56f39d967347f28dd9c93f1cffddf6d7e4cd (2010) or earlier.

Fix this by making the result type noreturn only if both e1 and e2 are
noreturn, matching GCC.

`_Noreturn` and `[[noreturn]]` do not have the aforementioned problem.

Fix https://github.com/llvm/llvm-project/issues/59792 [1]

Reviewed By: aaron.ballman

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

22 months ago[Transform] Rewrite LowerSwitch using APInt
Peter Rong [Thu, 29 Dec 2022 00:51:07 +0000 (16:51 -0800)]
[Transform] Rewrite LowerSwitch using APInt

This rewrite fixes https://github.com/llvm/llvm-project/issues/59316.

Previously LowerSwitch uses int64_t, which will crash on case branches using integers with more than 64 bits.
Using APInt fixes this problem. This patch also includes a test

Reviewed By: RKSimon

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

22 months agoAdd isInAnonymousNamespace() to the dynamic AST matchers
Aaron Ballman [Thu, 5 Jan 2023 22:08:57 +0000 (17:08 -0500)]
Add isInAnonymousNamespace() to the dynamic AST matchers

This was added to the static matchers in
125ccd3751472a0c709498f83671577ffed394a6, but the dynamic matcher was
missed. This adds the dynamic matcher to the list.

22 months agoDisable a part of the unit test CommandLineTest/BadResponseFile for z/OS.
Zibi Sarbinowski [Thu, 5 Jan 2023 21:55:21 +0000 (15:55 -0600)]
Disable a part of the unit test CommandLineTest/BadResponseFile for z/OS.

[Support] Do not run test on z/OS

A part of the unit test CommandLineTest/BadResponseFile, added in
the commit fd3d7a9f8cbb need to be disable for z/OS as it was already done for AIX platform.

Reviewed By: fanbo-meng

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

22 months ago[NFC][IR] Avoid string leak with target extension types.
Joshua Cranmer [Thu, 5 Jan 2023 21:53:29 +0000 (16:53 -0500)]
[NFC][IR] Avoid string leak with target extension types.

Reviewed By: nikic, hctim

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

22 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

22 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

22 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)

22 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

22 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

22 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)

22 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

22 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