platform/upstream/llvm.git
18 months ago[LLVM][OHOS] Use emulated TLS for OHOS platform
Pavel Kosov [Mon, 17 Apr 2023 14:01:21 +0000 (17:01 +0300)]
[LLVM][OHOS] Use emulated TLS for OHOS platform

Both Linux and LiteOS for all OpenHarmony targets use emulated TLS

~~~

Huawei RRI, OS Lab

Reviewed By: DavidSpickett, jrtc27, MaskRay

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

18 months ago[BOLT] Fix use-after-free in RewriteInstance::mapCodeSections
Job Noorman [Mon, 17 Apr 2023 12:55:11 +0000 (14:55 +0200)]
[BOLT] Fix use-after-free in RewriteInstance::mapCodeSections

When a cold function is too large, its section gets deregistered.
However, the section is still dereferenced later to get its RuntimeDyld
ID. This patch moves the deregistration to after the last dereference.

Reviewed By: Amir

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

18 months agoSpeculatively fix a failing bot
Aaron Ballman [Mon, 17 Apr 2023 14:08:40 +0000 (10:08 -0400)]
Speculatively fix a failing bot

This attempts to resolve the issue found by:
https://lab.llvm.org/buildbot/#/builders/139/builds/39296

18 months ago[InstSimplify] Precommit a test
Peixin Qiao [Mon, 17 Apr 2023 13:55:51 +0000 (21:55 +0800)]
[InstSimplify] Precommit a test

This patch precommits a test for:

https://reviews.llvm.org/D148420

18 months agoConstexpr evaluator should treat [[gnu::weak]] member pointer comparisons as evaluati...
Takuya Shimizu [Mon, 17 Apr 2023 13:48:58 +0000 (09:48 -0400)]
Constexpr evaluator should treat [[gnu::weak]] member pointer comparisons as evaluation failure

This patch fixes the wrong signal from the constexpr evaluator that
[[gnu::weak]] member pointer comparison is valid, while it is emitting
notes on them.

I found a crashing case fixed by this change and added it as a test
case: https://godbolt.org/z/8391fGjGn

I noticed this while I was working on D146358.

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

18 months ago[LoopDeletion] Don't delete loop exiting to EH pad (PR62160)
Nikita Popov [Mon, 17 Apr 2023 13:47:11 +0000 (15:47 +0200)]
[LoopDeletion] Don't delete loop exiting to EH pad (PR62160)

We can't branch directly to the EH pad, which is what the current
loop deletion code would try to do. We would need a different
approach here, which retains the invoke. This edge case does not
look worth bothering with.

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

18 months ago[Support] Add MVT::getDoubleNumVectorElementsVT helper.
Simon Pilgrim [Mon, 17 Apr 2023 13:42:14 +0000 (14:42 +0100)]
[Support] Add MVT::getDoubleNumVectorElementsVT helper.

Matches the equivalent EVT::getDoubleNumVectorElementsVT helper.

This allows us to consistently MVT instead of EVT in the combinePTESTCC method.

18 months ago[clang] Add __is_trivially_equality_comparable
Nikolas Klauser [Wed, 29 Mar 2023 15:58:25 +0000 (17:58 +0200)]
[clang] Add __is_trivially_equality_comparable

This patch adds a new trait to allow standard libraries to forward `std::equal` calls to `memcmp` in more cases.

Reviewed By: aaron.ballman

Spies: Mordante, shafik, xbolva00, libcxx-commits, cfe-commits, ldionne

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

18 months ago[flang][hlfir] lower hlfir.get_extent to FIR
Tom Eccles [Thu, 13 Apr 2023 10:48:12 +0000 (10:48 +0000)]
[flang][hlfir] lower hlfir.get_extent to FIR

By the ConvertToFIR pass, the hlfir.get_shape operation will have been
lowered into a fir.shape operation (during the HFLIR bufferization pass)
and so, lowering get_extent is as simple as fetching the extent from the
shape operation.

Depends on: D146833

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

18 months ago[flang][hlfir] lower hlfir.shape_of
Tom Eccles [Fri, 17 Mar 2023 15:49:22 +0000 (15:49 +0000)]
[flang][hlfir] lower hlfir.shape_of

If possible the shape is gotten from the bufferization of the expr
argument.

The simple cases should already have been resolved during lowering. This
is mostly intended for cases where shape information is added in between
lowering and the end of bufferization (for example transformational
intrinsics with assumed shape arguments).

Depends on: D146832

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

18 months ago[flang][hlfir] get extents from hlfir.shape_of
Tom Eccles [Thu, 2 Mar 2023 15:52:20 +0000 (15:52 +0000)]
[flang][hlfir] get extents from hlfir.shape_of

If the extents were known, this should have been canonicalised into a
fir.shape operation. Therefore, the extents at this point are not known at
compile time. Use hlfir.get_extents to delay resolving the real extent
until after the expression is bufferized.

Depends On: D146831

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

18 months ago[flang][hlfir] get shape from HLFIR expr using hlfir.shape_of
Tom Eccles [Thu, 2 Mar 2023 15:51:31 +0000 (15:51 +0000)]
[flang][hlfir] get shape from HLFIR expr using hlfir.shape_of

Depends On: D146830

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

18 months ago[flang][hlfir] add hlfir.get_extent
Tom Eccles [Wed, 12 Apr 2023 14:57:45 +0000 (14:57 +0000)]
[flang][hlfir] add hlfir.get_extent

This operation fetches an extent value from a fir.shape. The operation
could just as easily live in the fir namespace, but is only needed for
hlfir lowering so I put it here.

This operation is required to allow one to defer getting the extents of a shape
generated by hlfir.get_shape until after that shape has been resolved
(after bufferization of the hlfir.expr).

This operation will be lowered to FIR as an arith.constant created using
the definition of the fir.shape argument.

Depends on: D146830

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

18 months ago[flang][hlfir] add hlfir.shape_of
Tom Eccles [Wed, 1 Mar 2023 10:20:15 +0000 (10:20 +0000)]
[flang][hlfir] add hlfir.shape_of

This is an operation which returns the fir.shape for a hlfir.expr.

A hlfir.expr can be defined by:
  - A transformational intrinsic (e.g. hlfir.matmul)
  - hlfir.as_expr
  - hlfir.elemental

hlfir.elemental is easy because there is a compulsory shape operand.
hlfir.as_expr is defined as operating on a variable (defined using a
hlfir.declare). hlfir.declare has an optional shape argument. The
transformational intrinsics do not have an associated shape.

If all extents are known at compile time, the extents for the shape can
be fetched from the hlfir.expr's type. For example, the result of a
hlfir.matmul with arguments who's extents are known at compile time will
have constant extents which can be queried from the type. In this case
the hlfir.shape_of will be canonicalised to a fir.shape operation using
those extents.

If not all extents are known at compile time, shapes have to be read
from boxes after bufferization. In the case of the transformational
intrinsics, the shape read from the result box can be queried from the
hlfir.declare operation for the buffer allocated to that hlfir.expr (via
the hlfir.as_expr).

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

18 months ago[libc][NFC] Standardize missing syscalls error messages.
Mikhail R. Gadelha [Mon, 17 Apr 2023 13:16:56 +0000 (10:16 -0300)]
[libc][NFC] Standardize missing syscalls error messages.

This patch standardizes the error messages when a syscall is not
available to be in the format: "ABC and DEF syscalls are not available."

Reviewed By: sivachandra

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

18 months ago[X86] combinePTESTCC - fold TESTZ(OR(LO(X),HI(X)),OR(LO(Y),HI(Y))) -> TESTZ(X,Y)...
Simon Pilgrim [Mon, 17 Apr 2023 13:09:56 +0000 (14:09 +0100)]
[X86] combinePTESTCC - fold TESTZ(OR(LO(X),HI(X)),OR(LO(Y),HI(Y))) -> TESTZ(X,Y) for TESTPS/TESTPD ops

Followup to the fix for #62171, adding support for TESTPS/TESTPD opcodes

18 months ago[RISCV] Fix RUN line in fixed-vectors-abs-vp.ll
Luke Lau [Mon, 17 Apr 2023 10:29:06 +0000 (11:29 +0100)]
[RISCV] Fix RUN line in fixed-vectors-abs-vp.ll

Reviewed By: fakepaper56

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

18 months ago[LV] Regenreate check lines fr pr33706.ll
Florian Hahn [Mon, 17 Apr 2023 12:49:48 +0000 (13:49 +0100)]
[LV] Regenreate check lines fr pr33706.ll

This avoids conflicts when regenerating check lines.

18 months ago[VPlan] Remove uneeded NeedsVectorIV from VPWidenIntOrFpInduction.
Florian Hahn [Mon, 17 Apr 2023 12:38:00 +0000 (13:38 +0100)]
[VPlan] Remove uneeded NeedsVectorIV from VPWidenIntOrFpInduction.

After recent improvements, all instances of
VPWidenIntOrFpInductionRecipe should needs a vector IV and there's no
need for a separate field.

18 months ago[clang] Do not crash after suggesting typo correction to constexpr if condition
Mariya Podchishchaeva [Mon, 17 Apr 2023 11:53:43 +0000 (07:53 -0400)]
[clang] Do not crash after suggesting typo correction to constexpr if condition

In some cases non-null non-constant yet valid expression may reach point where
`ConditionResult` is created. For example, typo correction mechanism can return
such expression, so double check before evaluating it.

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

Reviewed By: tbaeder, aaron.ballman

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

18 months agoRevert "[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer"
Bjorn Pettersson [Mon, 17 Apr 2023 12:23:27 +0000 (14:23 +0200)]
Revert "[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer"

This reverts commit 981ec1faeb508a364cc47c8246b72fc89dd8c1d8.

It broke polly build bots. Polly still uses -instnamer with legacy PM.

18 months agoReapply [SimplifyCFG][LICM] Preserve nonnull, range and align metadata when speculating
Nikita Popov [Wed, 22 Mar 2023 10:53:01 +0000 (11:53 +0100)]
Reapply [SimplifyCFG][LICM] Preserve nonnull, range and align metadata when speculating

This exposed a miscompile in GVN, which was fixed by D148129.

-----

After D141386, violation of nonnull, range and align metadata
results in poison rather than immediate undefined behavior,
which means that these are now safe to retain when speculating.
We only need to remove UB-implying metadata like noundef.

This is done by adding a dropUBImplyingAttrsAndMetadata() helper,
which lists the metadata which is known safe to retain on speculation.

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

18 months ago[LV] Extend recurrence test coverage for sinking memory instructions.
Florian Hahn [Mon, 17 Apr 2023 12:08:14 +0000 (13:08 +0100)]
[LV] Extend recurrence test coverage for sinking memory instructions.

Extra coverage for D143604, D143605.

18 months ago[Clang][X86] Change X86 cast intrinsics to use __builtin_nondeterministic_value
ManuelJBrito [Mon, 17 Apr 2023 10:31:22 +0000 (11:31 +0100)]
[Clang][X86] Change X86 cast intrinsics to use __builtin_nondeterministic_value

The following intrinsics are currently implemented using a shufflevector with
an undefined mask, this is however incorrect according to intel's semantics for
undefined value which expect an unknown but consistent value.

With __builtin_nondeterministic_value we can now match intel's undefined value.

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

18 months ago[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer
Bjorn Pettersson [Sun, 16 Apr 2023 21:17:58 +0000 (23:17 +0200)]
[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer

18 months ago[Vectorize] Clean up Transforms/Vectorize.h
Bjorn Pettersson [Sat, 15 Apr 2023 08:58:22 +0000 (10:58 +0200)]
[Vectorize] Clean up Transforms/Vectorize.h

Removed definitions of vectorizeBasicBlock and VectorizeConfig
(possibly a remnant from the BBVectorize pass that was removed
way back in 2017).

Also reduced amount of include dependencies to Transforms/Vectorize.h.

18 months agoRemove several no longer needed includes. NFCI
Bjorn Pettersson [Sat, 15 Apr 2023 08:16:09 +0000 (10:16 +0200)]
Remove several no longer needed includes. NFCI

Mostly removing includes of InitializePasses.h and Pass.h in
passes that no longer has support for the legacy PM.

18 months ago[mlir] Apply ClangTidy fix.
Adrian Kuegel [Mon, 17 Apr 2023 11:50:29 +0000 (13:50 +0200)]
[mlir] Apply ClangTidy fix.

The argument name 'useBarePtrCallConv' does not match the actual
parameter name 'useBarePointerCallConv'.

18 months ago[VPlan] Mark recurrence recipes as not having side-effects.
Florian Hahn [Mon, 17 Apr 2023 11:30:52 +0000 (12:30 +0100)]
[VPlan] Mark recurrence recipes as not having side-effects.

Add support for FirstOrderRecurrenceSplice and VPFirstOrderRecurrencePHI
recipes to mayHaveSideEffects. They both don't have side-effects.

18 months ago[mlir] Remove unused using llvm::Twine declaration (NFC).
Adrian Kuegel [Mon, 17 Apr 2023 11:15:45 +0000 (13:15 +0200)]
[mlir] Remove unused using llvm::Twine declaration (NFC).

18 months ago[Pipelines] Add LoopSink and DivRemPairs to LTO post-link pipeline
Nikita Popov [Fri, 14 Apr 2023 13:30:27 +0000 (15:30 +0200)]
[Pipelines] Add LoopSink and DivRemPairs to LTO post-link pipeline

As pointed out in D148010, these passes are missing from the LTO
post-link pipeline. They are present in the pre-link pipeline,
but LoopSink is completely useless there (it will always be fully
undone by LICM post-link) and DivRemPairs is mostly useless
(I believe most of what it does will be undone by InstCombine).

I've not added RelLookupTableConverterPass, because it's also
disabled in the LTO pre-link pipeline, with a comment that there
is an unresolved issue with full LTO.

Compile-time impact of the extra passes is minimal. Of course,
LoopSink will have a larger impact in PGO builds.

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

18 months agoRevert "ValueTracking: Handle freeze in computeKnownFPClass"
Nikita Popov [Mon, 17 Apr 2023 10:52:58 +0000 (12:52 +0200)]
Revert "ValueTracking: Handle freeze in computeKnownFPClass"

This reverts commit 2c8d0048f03d054f13909a26f959ef95b2a0a4de.

This is incorrect: computeKnownFPClass() is only known up to
poison, and freeze poison may have any FP class.

18 months ago[LV] Add users to recurrence tests to make sure they are not removable.
Florian Hahn [Mon, 17 Apr 2023 10:56:56 +0000 (11:56 +0100)]
[LV] Add users to recurrence tests to make sure they are not removable.

This ensures VPlan-based DCE won't be able to remove the unused
recurrences.

It also adds a dedicated new test (@unused_recurrence) where an unused
recurrence can be removed.

18 months ago[GVN] Adjust metadata for coerced load CSE
Nikita Popov [Fri, 14 Apr 2023 09:48:54 +0000 (11:48 +0200)]
[GVN] Adjust metadata for coerced load CSE

When reusing a load in a way that requires coercion (i.e. casts or
bit extraction) we currently fail to adjust metadata. Unfortunately,
none of our existing tooling for this is really suitable, because
combineMetadataForCSE() expects both loads to have the same type.
In this case we may work on loads of different types and possibly
offset memory location.

As such, what this patch does is to simply drop all metadata, with
the following exceptions:

* Metadata for which violation is known to always cause UB.
* If the load is !noundef, keep all metadata, as this will turn
  poison-generating metadata into UB as well.

This fixes the miscompile that was exposed by D146629.

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

18 months ago[LoopVectorize] Take vscale into account when deciding to create epilogues
David Sherwood [Mon, 3 Apr 2023 16:14:09 +0000 (16:14 +0000)]
[LoopVectorize] Take vscale into account when deciding to create epilogues

In LoopVectorizationCostModel::isEpilogueVectorizationProfitable we
check to see if the chosen main vector loop VF >= 16. If so, we
decide to create a vector epilogue loop. However, this doesn't
take VScaleForTuning into account because we could be targeting a
CPU where vscale > 1, and hence the runtime VF would be a multiple
of the known minimum value.

This patch multiplies scalable VFs by VScaleForTuning and several
tests have been updated that now produce vector epilogues.

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

18 months ago[X86] combinePTESTCC - only fold TESTZ(OR(LO(X),HI(X)),OR(LO(Y),HI(Y))) -> TESTZ...
Simon Pilgrim [Mon, 17 Apr 2023 10:40:39 +0000 (11:40 +0100)]
[X86] combinePTESTCC - only fold TESTZ(OR(LO(X),HI(X)),OR(LO(Y),HI(Y))) -> TESTZ(X,Y) for TESTP ops

Stop value type mismatch assertions, we can add TESTPS/TESTPD support to this in the future.

Fixes #62171

18 months ago[libc++] Add annotation for arm64e in the strong_order test for long double
Louis Dionne [Mon, 17 Apr 2023 10:40:51 +0000 (11:40 +0100)]
[libc++] Add annotation for arm64e in the strong_order test for long double

As a fly-by, improve readability by giving a bit more space to some
comments.

18 months ago[DAGCombiner] Fold add (mul x, C), x to mul x, C+1
Nikita Popov [Fri, 14 Apr 2023 13:46:45 +0000 (15:46 +0200)]
[DAGCombiner] Fold add (mul x, C), x to mul x, C+1

While this is normally non-canonical IR, this pattern can appear
during SDAG lowering if the add is actually a getelementptr, as
illustrated in `@test_ptr`. This pattern comes up when doing
provenance-aware high-bit pointer tagging.

Proof: https://alive2.llvm.org/ce/z/DLoEcs

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

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

18 months ago[OpenMP][MLIR] Prevent constant hoisting out of target regions
Sergio Afonso [Fri, 14 Apr 2023 13:07:02 +0000 (14:07 +0100)]
[OpenMP][MLIR] Prevent constant hoisting out of target regions

This patch prevents constant operations defined inside `omp.target` from being
hoisted out and into their parent functions by canonicalization passes.

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

18 months ago[AArch64] Add tests for vacgt/vacge. NFC
David Green [Mon, 17 Apr 2023 09:21:46 +0000 (10:21 +0100)]
[AArch64] Add tests for vacgt/vacge. NFC

See D147945.

18 months agoFix uninitialized pointer members in CodeGen
Akshay Khadse [Mon, 17 Apr 2023 08:16:23 +0000 (16:16 +0800)]
Fix uninitialized pointer members in CodeGen

This change initializes the members TSI, LI, DT, PSI, and ORE pointer feilds of the SelectOptimize class to nullptr.

Reviewed By: LuoYuanke

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

18 months ago[LV] Don't sink scalar instructions that may read from memory.
Florian Hahn [Mon, 17 Apr 2023 08:30:25 +0000 (09:30 +0100)]
[LV] Don't sink scalar instructions that may read from memory.

The current sinking code doesn't prevent us from sinking a load past an
aliasing store. Skip sinking instructions that may read from memory to
avoid a mis-compile.

See @minimal_bit_widths_with_aliasing_store for an example where 2 loads
are sunk past aliasing stores before this fix.

Reviewed By: Ayal

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

18 months ago[ConstraintElimination] Transfer info from sgt %a, %b to ugt %a, %b if %b > 0
Zain Jaffal [Fri, 14 Apr 2023 15:19:31 +0000 (16:19 +0100)]
[ConstraintElimination] Transfer info from sgt %a, %b to ugt %a, %b if %b > 0

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

18 months agoremove useless call in MIRSampleProfile.cpp
Wang, Xin10 [Mon, 17 Apr 2023 08:09:00 +0000 (04:09 -0400)]
remove useless call in MIRSampleProfile.cpp

This call getSummary returns a value but nobody take
it.

Reviewed By: skan

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

18 months ago[clang][NFC] Use range-for loop in SemaLookup.cpp
Timm Bäder [Sat, 15 Apr 2023 08:16:51 +0000 (10:16 +0200)]
[clang][NFC] Use range-for loop in SemaLookup.cpp

18 months ago[lldb] Change some pointers to refs in register printing code
David Spickett [Mon, 13 Mar 2023 13:22:01 +0000 (13:22 +0000)]
[lldb] Change some pointers to refs in register printing code

No one was passing nullptr for these.

Reviewed By: JDevlieghere

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

18 months ago[AVR] Fix an issue of writing 16-bit ports
Ben Shi [Sat, 14 Jan 2023 08:40:43 +0000 (16:40 +0800)]
[AVR] Fix an issue of writing 16-bit ports

For 16-bit ports, the normal devices reqiure writing high byte first
and then low byte. But the XMEGA devices require the reverse order.

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

Reviewed By: aykevl, jacquesguan

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

18 months ago[clang][NFC] Make parameters to NoteOverloadCandidate const
Timm Bäder [Sat, 15 Apr 2023 08:14:59 +0000 (10:14 +0200)]
[clang][NFC] Make parameters to NoteOverloadCandidate const

18 months ago[Analysis] Remove DA & LegacyDA
pvanhout [Wed, 12 Apr 2023 11:28:45 +0000 (13:28 +0200)]
[Analysis] Remove DA & LegacyDA

UniformityAnalysis offers all of the same features and much more, there is no reason left to use the legacy DAs.
See RFC: https://discourse.llvm.org/t/rfc-deprecate-divergenceanalysis-legacydivergenceanalysis/69538

- Remove LegacyDivergenceAnalysis.h/.cpp
- Remove DivergenceAnalysis.h/.cpp + Unit tests
- Remove SyncDependenceAnalysis - it was not a real registered analysis and was only used by DAs
- Remove/adjust references to the passes in the docs where applicable
- Remove TTI hook associated with those passes.
- Move tests to UniformityAnalysis folder.
  - Remove RUN lines for the DA, leave only the UA ones.
- Some tests had to be adjusted/removed depending on how they used the legacy DAs.

Reviewed By: foad, sameerds

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

18 months ago[builtins] Fix -Wshift-count-overflow warnings for targets with 16-bit int
Mikael Holmen [Tue, 4 Apr 2023 06:45:53 +0000 (08:45 +0200)]
[builtins] Fix -Wshift-count-overflow warnings for targets with 16-bit int

Without this fix we got warnings like
 /repo/llvm/compiler-rt/lib/builtins/floattidf.c:67:29: warning: shift count >= width of type [-Wshift-count-overflow]
                 ((e + 1023) << 20) |              // exponent
                             ^  ~~
 1 warning generated.
when compiling for a target with 16-bit int.

In floatundisf.c the type of "e" was already changed to "si_int" in
4d41df6482, now we do the same in a couple of other files where "e" is
also left shifted 20/23 steps.

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

18 months ago[clang-tidy] Add alias cppcoreguidelines-use-default-member-init
Carlos Galvez [Sun, 16 Apr 2023 10:23:37 +0000 (10:23 +0000)]
[clang-tidy] Add alias cppcoreguidelines-use-default-member-init

And deprecate identical functionality from
cppcoreguidelines-prefer-member-initializer, which had too many
responsibilities and a tight coupling to the
modernize-use-default-member-init check.

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

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

18 months ago[flang][hlfir] Preserve hlfir.assign in the bufferize-hlfir pass
Jean Perier [Mon, 17 Apr 2023 05:47:35 +0000 (07:47 +0200)]
[flang][hlfir] Preserve hlfir.assign in the bufferize-hlfir pass

hlfir.assign must be rewritten in the bufferize pass since its operands,
that can be expressions, may have been updated. This is just
an operand update rewrite. The previous code was replacing the
operation, but it was dropping all hlfir.assign on the floor doing
so. This broke allocatable assignment semantics that use attributes.

Update the operands in place instead to preserve the attributes, if any.

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

18 months ago[flang][hlfir] Fix hlfir.set_length codegen
Jean Perier [Mon, 17 Apr 2023 05:46:13 +0000 (07:46 +0200)]
[flang][hlfir] Fix hlfir.set_length codegen

The bufferization pass was propagating the raw alloca storage
(which may not allow to later retrieve the length) instead of
the hlfir variable value (which is guaranteed to hold the
character length).

Fix this and makes packageBufferizedExpr "storage" argument and
getBufferizedExprStorage return an hlfir::Entity to avoid similar
error in the future (the caller of packageBufferizedExpr will have
to think a bit when adding the explicit hlfir::Entity{} cast).

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

18 months ago[libc][NFC] Remove use of StreamWrapper from math differential tests.
Siva Chandra Reddy [Sun, 16 Apr 2023 05:40:07 +0000 (05:40 +0000)]
[libc][NFC] Remove use of StreamWrapper from math differential tests.

Along the way, the utility Timer has been moved to the math differential
test directory.

Reviewed By: lntue

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

18 months agoRevert "[clang-rename] Exit gracefully when no input provided"
Shivam Gupta [Mon, 17 Apr 2023 05:01:40 +0000 (10:31 +0530)]
Revert "[clang-rename] Exit gracefully when no input provided"

This reverts commit 726199146a0bb53315ade042e759c65e6d96d556.

This broke the buildbot -
https://lab.llvm.org/buildbot#builders/139/builds/39267

18 months ago[clang-rename] Exit gracefully when no input provided
Shivam Gupta [Sat, 15 Apr 2023 18:23:56 +0000 (23:53 +0530)]
[clang-rename] Exit gracefully when no input provided

clang-rename on a non existing file segfaults

Command to run -
$ clang-rename -offset=0 -new-name=plop asdasd

Error while processing llvm-project/asdasd.
clang-rename: llvm-project/llvm/include/llvm/Support/ErrorOr.h:237:
llvm::ErrorOr<T>::storage_type* llvm::ErrorOr<T>::getStorage()
[with T = const clang::FileEntry*; llvm::ErrorOr<T>::storage_type = const clang::FileEntry*]:
Assertion `!HasError && "Cannot get value when an error exists!"' failed.

[1]    827497 IOT instruction  clang-rename -offset=0 -new-name=plop asdasd

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

18 months ago[LLDB] Fix broken Windows unittests build
Muhammad Omair Javaid [Mon, 17 Apr 2023 03:28:13 +0000 (08:28 +0500)]
[LLDB] Fix broken Windows unittests build

LLDB Windows tests were broken because SymbolFilePDBTests.cpp failed
to compile after 6cdfa295743729178ff6f15a8dcd36f8f7d27c2c.

This patch fixes the SymbolFilePDBTests.cpp. (Tested on Surface X Pro)

https://lab.llvm.org/buildbot/#/builders/219

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

18 months ago[TableGen] Use PointerUnion for Operator and Val in TreePatternNode.
Craig Topper [Mon, 17 Apr 2023 03:10:51 +0000 (20:10 -0700)]
[TableGen] Use PointerUnion for Operator and Val in TreePatternNode.

These fields are never set at the same time so we can store them
using a single PointerUnion.

18 months ago[m68k] Add basic support for floating point arithmetic instruction
Sheng [Mon, 17 Apr 2023 03:08:48 +0000 (11:08 +0800)]
[m68k] Add basic support for floating point arithmetic instruction

This patch adds support for fneg, fabs, fadd, fsub, fdiv, fmul.

Note that this only adds freg->freg addressing mode. memory->reg addressing mode will be introduced once the infrastructure is ready.

Reviewed By: myhsu

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

18 months ago[Support] Apply fixes from modernize-type-trait (NFC)
Kazu Hirata [Mon, 17 Apr 2023 02:20:21 +0000 (19:20 -0700)]
[Support] Apply fixes from modernize-type-trait (NFC)

18 months ago[TableGen] Avoid extra IntrusiveRefCntPtr when calling SimplifyTree. NFC
Craig Topper [Mon, 17 Apr 2023 01:07:10 +0000 (18:07 -0700)]
[TableGen] Avoid extra IntrusiveRefCntPtr when calling SimplifyTree. NFC

Add a helper to get modifiable access to the IntrusiveRefCntPtr
stored in the Children array. This avoids copying and overwriting the child.

18 months ago[clang-format] Fix regression with AlignTrailingComments set to true
Owen Pan [Sun, 16 Apr 2023 02:53:24 +0000 (19:53 -0700)]
[clang-format] Fix regression with AlignTrailingComments set to true

Fixes #62161.

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

18 months ago[JITLink][ELF][x86-64] Add support for R_X86_64_GOTPC32 relocation.
Lang Hames [Mon, 17 Apr 2023 01:22:52 +0000 (01:22 +0000)]
[JITLink][ELF][x86-64] Add support for R_X86_64_GOTPC32 relocation.

Adds support for the R_X86_64_GOTPC32 relocation, which is a 32-bit delta to
the global offset table.

Since the delta to the GOT doesn't actually require any GOT entries to exist
this commit adds an extra fallback path to the getOrCreateGOTSymbol function:
If the symbol is in the extenal symbols list but no entry exists then the
symbol is turned into an absolute symbol pointing to an arbitrary address in
the current graph's allocation (accessing this address via the symbol would be
illegal, but any access should have triggered creation of a GOT entry which
would prevent this fallback path from being taken in the first place).

This commit also updates the llvm-jitlink tool to scrape the addresses of the
absolute symbols in the graph so that the testcase can see the now-absolute
_GLOBAL_OFFSET_TABLE_ symbol.

18 months ago[Coverity] Add assert for assumption.
Luo, Yuanke [Mon, 17 Apr 2023 00:50:53 +0000 (08:50 +0800)]
[Coverity] Add assert for assumption.

18 months ago[clang-format][NFC] Output tokens on test assert
sstwcw [Sun, 16 Apr 2023 23:47:55 +0000 (23:47 +0000)]
[clang-format][NFC] Output tokens on test assert

Reviewed By: rymiel

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

18 months ago[ADT] Apply fixes from modernize-type-traits (NFC)
Kazu Hirata [Sun, 16 Apr 2023 23:24:34 +0000 (16:24 -0700)]
[ADT] Apply fixes from modernize-type-traits (NFC)

18 months ago[mlir][math] Properly disable ctlz conversion in MathToFuncs.
Slava Zakharin [Sun, 16 Apr 2023 20:07:55 +0000 (13:07 -0700)]
[mlir][math] Properly disable ctlz conversion in MathToFuncs.

This fixes issues caused by D146261.
Differential Revision: https://reviews.llvm.org/D148477

18 months ago[M68k] Fix printing of immediate in `M68kOperand::print`
Ian Douglas Scott [Sun, 16 Apr 2023 22:43:27 +0000 (15:43 -0700)]
[M68k] Fix printing of immediate in `M68kOperand::print`

The `Imm` union variant wasn't initialized anywhere. This fixes what is
printed by `llvm-mc -arch m68k --show-inst-operands`.

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

18 months ago[clang-format] Handle Verilog assertions and loops
sstwcw [Sun, 16 Apr 2023 21:55:50 +0000 (21:55 +0000)]
[clang-format] Handle Verilog assertions and loops

Assert statements in Verilog can optionally have an else part.  We
handle them like for `if` statements, except that an `if` statement in
the else part of an `assert` statement doesn't get merged with the
`else` keyword.  Like this:

    assert (x)
      $info();
    else
      if (y)
        $info();
      else if (z)
        $info();
      else
        $info();

`foreach` and `repeat` are now handled like for or while loops.

We used the type `TT_ConditionLParen` to mark the condition part so
they are handled in the same way as the condition part of an `if`
statement.  When the code being formatted is not in Verilog, it is
only set for `if` statements, not loops.  It's because loop conditions
are currently handled slightly differently, and existing behavior is
not supposed to change.  We formatted all files ending in `.cpp` and
`.h` in the repository with and without this change.  It showed that
setting the type for `if` statements doesn't change existing behavior.

And we noticed that we forgot to make the program print the list of
tokens when the number is not correct in `TokenAnnotatorTest`.  It's
fixed now.

Reviewed By: HazardyKnusperkeks

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

18 months ago[clang] Modernize ModuleDeclSeq (NFC)
Kazu Hirata [Sun, 16 Apr 2023 21:48:18 +0000 (14:48 -0700)]
[clang] Modernize ModuleDeclSeq (NFC)

Identified with modernize-use-default-member-init.

18 months ago[clang] Modernize ReturnAdjustment and ThisAdjustment (NFC)
Kazu Hirata [Sun, 16 Apr 2023 21:48:16 +0000 (14:48 -0700)]
[clang] Modernize ReturnAdjustment and ThisAdjustment (NFC)

Identified with modernize-use-default-member-init.

18 months ago[clang] Modernize OptRemark (NFC)
Kazu Hirata [Sun, 16 Apr 2023 21:24:22 +0000 (14:24 -0700)]
[clang] Modernize OptRemark (NFC)

Identified with modernize-use-default-member-init.

18 months ago[clang] Modernize EvalStatus (NFC)
Kazu Hirata [Sun, 16 Apr 2023 21:02:34 +0000 (14:02 -0700)]
[clang] Modernize EvalStatus (NFC)

Identified with modernize-use-default-member-init.

18 months ago[clang] Modernize ASTConsumer (NFC)
Kazu Hirata [Sun, 16 Apr 2023 20:46:11 +0000 (13:46 -0700)]
[clang] Modernize ASTConsumer (NFC)

Identified with modernize-use-default-member-init.

18 months ago[clang] Modernize Vec (NFC)
Kazu Hirata [Sun, 16 Apr 2023 20:46:09 +0000 (13:46 -0700)]
[clang] Modernize Vec (NFC)

Identified with modernize-use-default-member-init.

18 months ago[AMDGPU] Modernize Status and BlockData (NFC)
Kazu Hirata [Sun, 16 Apr 2023 20:03:02 +0000 (13:03 -0700)]
[AMDGPU] Modernize Status and BlockData (NFC)

Identified with modernize-use-default-member-init.

18 months ago[IPO] Modernize OpenMPOptPass and OpenMPOptCGSCCPass (NFC)
Kazu Hirata [Sun, 16 Apr 2023 19:48:14 +0000 (12:48 -0700)]
[IPO] Modernize OpenMPOptPass and OpenMPOptCGSCCPass (NFC)

Identified with readability-redundant-member-init.

18 months ago[InstCombine] Modernize InstCombineOptions (NFC)
Kazu Hirata [Sun, 16 Apr 2023 19:43:02 +0000 (12:43 -0700)]
[InstCombine] Modernize InstCombineOptions (NFC)

Identified with modernize-use-default-member-init.

18 months ago[ORC][LLJIT] Add LLJITBuilder convenience function to enable debugger support.
Lang Hames [Sun, 16 Apr 2023 19:14:15 +0000 (12:14 -0700)]
[ORC][LLJIT] Add LLJITBuilder convenience function to enable debugger support.

Clients can now call LLJITBuilder::setEnableDebuggerSupport to enable
registration of debug info via the GDB-JIT registration protocol for JIT'd
code.

Calling LLJITBuilder::setEnableDebuggerSupport(true) will cause LLJITBuilder to
add either a DebugObjectManagerPlugin (if the object format on the triple is
ELF), or a GDBJITDebugInfoRegistrationPlugin (if the object format on the
triple is MachO). At present there is no support for debugging when using COFF.

This debugger registration support will only work when JITLink is used as the
underlying JIT linker.

This patch only addresses registration of JIT'd code by the JIT. To debug JIT'd
code you may also need to enable JIT'd code debugging in your debugger. E.g.
when debugging MachO JIT'd code under LLDB you will currently need to run
(lldb) set set plugin.jit-loader.gdb.enable on
to tell LLDB to listen for JIT'd code registration.

18 months ago[Analysis] Modernize CallStackTrie (NFC)
Kazu Hirata [Sun, 16 Apr 2023 19:12:07 +0000 (12:12 -0700)]
[Analysis] Modernize CallStackTrie (NFC)

Identified with modernize-use-default-member-init.

18 months ago[AMDGPU] Don't assert that image intrinsics are supported
Jay Foad [Wed, 12 Apr 2023 17:33:01 +0000 (18:33 +0100)]
[AMDGPU] Don't assert that image intrinsics are supported

Unsupported intrinsics should give a regular "cannot select" error.

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

18 months ago[Support] Modernize TimeRecord (NFC)
Kazu Hirata [Sun, 16 Apr 2023 18:40:32 +0000 (11:40 -0700)]
[Support] Modernize TimeRecord (NFC)

Identified with modernize-use-default-member-init.

18 months ago[TargetParser] Expose Triple::getObjectFormatTypeName.
Lang Hames [Sun, 16 Apr 2023 18:10:09 +0000 (11:10 -0700)]
[TargetParser] Expose Triple::getObjectFormatTypeName.

This is useful for printing the object format of a triple in debug logs.

18 months ago[flang] Refine how Clang dependencies are expressed #58663
Ezike Ebuka [Sun, 16 Apr 2023 14:19:46 +0000 (14:19 +0000)]
[flang] Refine how Clang dependencies are expressed #58663

Fixes #58663

Reviewed By: awarzynski

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

18 months ago[MCParser] Modernize IntelExpr (NFC)
Kazu Hirata [Sun, 16 Apr 2023 17:18:57 +0000 (10:18 -0700)]
[MCParser] Modernize IntelExpr (NFC)

Identified with readability-redundant-member-init.

18 months ago[llvm] Remove redundant string initialization (NFC)
Kazu Hirata [Sun, 16 Apr 2023 16:42:34 +0000 (09:42 -0700)]
[llvm] Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

18 months agollvm/module.modulemap: Exclude `CodeGenPassBuilder.h` out of `LLVM_Backend`
NAKAMURA Takumi [Sun, 16 Apr 2023 16:12:40 +0000 (01:12 +0900)]
llvm/module.modulemap: Exclude `CodeGenPassBuilder.h` out of `LLVM_Backend`

18 months agollvm/module.modulemap: Add `Demangle` in `LLVM_Utils`
NAKAMURA Takumi [Sun, 16 Apr 2023 16:12:40 +0000 (01:12 +0900)]
llvm/module.modulemap: Add `Demangle` in `LLVM_Utils`

18 months agollvm/module.modulemap: Exclude `Support/Host.h`
NAKAMURA Takumi [Sun, 16 Apr 2023 16:12:40 +0000 (01:12 +0900)]
llvm/module.modulemap: Exclude `Support/Host.h`

It is declared as `deprecated`.

18 months agoRevert "[FuzzMutate] RandomIRBuilder has more source and sink type now."
Peter Rong [Sun, 16 Apr 2023 16:07:19 +0000 (09:07 -0700)]
Revert "[FuzzMutate] RandomIRBuilder has more source and sink type now."

This reverts commit e0117a3efacf9620408393f162a7795b5e0965d2.

18 months ago[Scalar] Use range-based for loops (NFC)
Kazu Hirata [Sun, 16 Apr 2023 16:05:20 +0000 (09:05 -0700)]
[Scalar] Use range-based for loops (NFC)

18 months ago[clang-tidy] Prevent `llvmlibc-inline-function-decl` triggering on lambdas
Joseph Huber [Mon, 17 Apr 2023 20:08:59 +0000 (15:08 -0500)]
[clang-tidy] Prevent `llvmlibc-inline-function-decl` triggering on lambdas

The `llvmlibc-inline-function-decl` check is intended to be used to
allow declarations in the `libc` project's header to be changed per-TU.
However, it is impossible to place this macro in front of a lambda so
this is not helpful. Additionally, lambdas are always going to have
internal linkage so they will not differ accross TUs.

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

Reviewed By: lntue, PiotrZSL

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

18 months ago[CMake] Cleanup deps
NAKAMURA Takumi [Sun, 16 Apr 2023 15:38:49 +0000 (00:38 +0900)]
[CMake] Cleanup deps

18 months ago[CMake] Reorder and reformat deps
NAKAMURA Takumi [Sun, 16 Apr 2023 15:17:45 +0000 (00:17 +0900)]
[CMake] Reorder and reformat deps

18 months ago[flang] Apply fixes from readability-string-compare (NFC)
Kazu Hirata [Sun, 16 Apr 2023 15:31:23 +0000 (08:31 -0700)]
[flang] Apply fixes from readability-string-compare (NFC)

18 months ago[Transforms] Apply fixes from performance-for-range-copy (NFC)
Kazu Hirata [Sun, 16 Apr 2023 15:25:28 +0000 (08:25 -0700)]
[Transforms] Apply fixes from performance-for-range-copy (NFC)

18 months ago[VPlan] Unify Value2VPValue and VPExternalDefs maps (NFCI).
Florian Hahn [Sun, 16 Apr 2023 14:38:31 +0000 (15:38 +0100)]
[VPlan] Unify Value2VPValue and VPExternalDefs maps (NFCI).

Before this patch, a VPlan contained 2 mappings for Values -> VPValue:
1) Value2VPValue and 2) VPExternalDefs.

This duplication is unnecessary and there are already cases where
external defs are added to Value2VPValue. This patch replaces all uses
of VPExternalDefs with Value2VPValue.

It clarifies the naming of getOrAddVPValue (to getOrAddExternalVPValue)
and addVPValue (to addExternalVPValue).

At the moment, this is NFC, but will enable additional simplifications
in D147783.

Depends on D147891.

Reviewed By: Ayal

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

18 months ago[SROA] Remove UB-implying metadata when promoting speculative instruction.
DianQK [Sun, 16 Apr 2023 14:35:27 +0000 (22:35 +0800)]
[SROA] Remove UB-implying metadata when promoting speculative instruction.

After D138238 introduced the then/else blocks, we should remove UB-implying metadata for the promoted speculative instruction.

Reviewed By: nikic

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

18 months ago[VPlan] Check VPValue step in isCanonical (NFCI).
Florian Hahn [Sun, 16 Apr 2023 13:48:02 +0000 (14:48 +0100)]
[VPlan] Check VPValue step in isCanonical (NFCI).

Update the isCanonical() implementations to check the VPValue step
operand instead of the step in the induction descriptor.

At the moment this is NFC, but it enables further optimizations if the
step is replaced by a constant in D147783.

Reviewed By: Ayal

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

18 months ago[libc++] Add hide_from_abi check for classes
Nikolas Klauser [Mon, 23 Jan 2023 09:27:14 +0000 (10:27 +0100)]
[libc++] Add hide_from_abi check for classes

We already have a clang-tidy check for making sure that `_LIBCPP_HIDE_FROM_ABI` is on free functions. This patch extends this to class members. The places where we don't check for `_LIBCPP_HIDE_FROM_ABI` are classes for which we have an instantiation in the library.

Reviewed By: ldionne, Mordante, #libc

Spies: jplehr, mikhail.ramalho, sstefan1, libcxx-commits, krytarowski, miyuki, smeenai

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