platform/upstream/llvm.git
2 years ago[AliasAnalysis] Introduce getModRefInfoMask() as a generalization of pointsToConstant...
Patrick Walton [Mon, 24 Oct 2022 22:31:35 +0000 (15:31 -0700)]
[AliasAnalysis] Introduce getModRefInfoMask() as a generalization of pointsToConstantMemory().

The pointsToConstantMemory() method returns true only if the memory pointed to
by the memory location is globally invariant. However, the LLVM memory model
also has the semantic notion of *locally-invariant*: memory that is known to be
invariant for the life of the SSA value representing that pointer. The most
common example of this is a pointer argument that is marked readonly noalias,
which the Rust compiler frequently emits.

It'd be desirable for LLVM to treat locally-invariant memory the same way as
globally-invariant memory when it's safe to do so. This patch implements that,
by introducing the concept of a *ModRefInfo mask*. A ModRefInfo mask is a bound
on the Mod/Ref behavior of an instruction that writes to a memory location,
based on the knowledge that the memory is globally-constant memory (in which
case the mask is NoModRef) or locally-constant memory (in which case the mask
is Ref). ModRefInfo values for an instruction can be combined with the
ModRefInfo mask by simply using the & operator. Where appropriate, this patch
has modified uses of pointsToConstantMemory() to instead examine the mask.

The most notable optimization change I noticed with this patch is that now
redundant loads from readonly noalias pointers can be eliminated across calls,
even when the pointer is captured. Internally, before this patch,
AliasAnalysis was assigning Ref to reads from constant memory; now AA can
assign NoModRef, which is a tighter bound.

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

2 years ago[lit] Remove undefined keyword from a Driver test
Paul Robinson [Mon, 31 Oct 2022 19:58:53 +0000 (12:58 -0700)]
[lit] Remove undefined keyword from a Driver test

`clang-driver` hasn't been a valid keyword for a long time.
The test fails when the keyword is removed, so added XFAIL: *
to reflect the true status of the test (XFAIL not UNSUPPORTED)
and filed issue #58711 to get it fixed.

2 years ago[InstCombine] canonicalize branch with logical-and-not condition
Sanjay Patel [Mon, 31 Oct 2022 19:49:03 +0000 (15:49 -0400)]
[InstCombine] canonicalize branch with logical-and-not condition

https://alive2.llvm.org/ce/z/EfHlWN

In the motivating case from issue #58313,
this allows forming a duplicate 'not' op
which then gets CSE'd and simplifyCFG'd
and combined into the expected 'xor'.

2 years ago[InstCombine] add tests for branch on logical and/or; NFC
Sanjay Patel [Mon, 31 Oct 2022 18:00:05 +0000 (14:00 -0400)]
[InstCombine] add tests for branch on logical and/or; NFC

2 years ago[test] Add coverage for sign bits and known non-zero for scalable vectors
Philip Reames [Mon, 31 Oct 2022 18:54:37 +0000 (11:54 -0700)]
[test] Add coverage for sign bits and known non-zero for scalable vectors

2 years ago[flang] Fix pointer definition semantic checking via refactoring
Peter Klausler [Mon, 17 Oct 2022 19:51:00 +0000 (12:51 -0700)]
[flang] Fix pointer definition semantic checking via refactoring

The infrastructure in semantics that is used to check that the
left-hand sides of normal assignment statements are really definable
variables was not being used to check whether the LHSs of pointer assignments
are modifiable, and so most cases of unmodifiable pointers are left
undiagnosed.  Rework the semantics checking for pointer assignments,
NULLIFY statements, pointer dummy arguments, &c. so that cases of
unmodifiable pointers are properly caught.  This has been done
by extracting all the various definability checking code that has
been implemented for different contexts in Fortran into one new
facility.

The new consolidated definability checking code returns messages
meant to be attached as "because: " explanations to context-dependent
errors like "left-hand side of assignment is not definable".
These new error message texts and their attached explanations
affect many existing tests, which have been updated.  The testing
infrastructure was extended by another patch to properly compare
warnings and explanatory messages, which had been ignored until
recently.

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

2 years ago[mlir][scf] Add scf-to-cf lowering for `scf.index_switch`
Jeff Niu [Thu, 27 Oct 2022 20:43:41 +0000 (13:43 -0700)]
[mlir][scf] Add scf-to-cf lowering for `scf.index_switch`

This patch adds lowering from `scf.index_switch` to `cf.switch.

Reviewed By: rriddle

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

2 years ago[test] Refresh an autogened test to pickup naming change
Philip Reames [Mon, 31 Oct 2022 18:36:14 +0000 (11:36 -0700)]
[test] Refresh an autogened test to pickup naming change

2 years agoRevert "[clang] ASTImporter: Fix importing of va_list types and declarations"
Matheus Izvekov [Mon, 31 Oct 2022 18:34:23 +0000 (19:34 +0100)]
Revert "[clang] ASTImporter: Fix importing of va_list types and declarations"

This reverts commit 5f820c0f55cd9d4f4520cc92eae0a1c4afe05a54.

Apparently it breaks aarch64 buildbots.
https://lab.llvm.org/buildbot#builders/188/builds/21591

2 years ago[flang] Be more precise about CHARACTER known length discrepancies
Peter Klausler [Thu, 13 Oct 2022 22:22:55 +0000 (15:22 -0700)]
[flang] Be more precise about CHARACTER known length discrepancies

Many intrinsic functions in Fortran require that two or more of their
arguments have types that agree in the values of all of their type
parameters, while others only require the same type category and kind
type parameters but not lengths, including the important case of
CHARACTER.  The intrinsic procedure tables need to be adjusted in
some cases so that discrepancies in character lengths that are known
at compilation time can be diagnosed as errors where they should be,
as in for example MOVE_ALLOC().

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

2 years agoAddress post commit style comment from 087bb0f
Philip Reames [Mon, 31 Oct 2022 18:15:48 +0000 (11:15 -0700)]
Address post commit style comment from 087bb0f

2 years ago[lit] Remove undefined keyword from an MCJIT test
Paul Robinson [Mon, 31 Oct 2022 17:51:29 +0000 (10:51 -0700)]
[lit] Remove undefined keyword from an MCJIT test

Changed 'XFAIL: mcjit-ia32' to 'XFAIL: i686 && windows' because the
'mcjit-ia32 feature isn't defined anywhere, or used anywhere else.

I found this as part of other work to clean up lit keywords, so
I figured I would go ahead and fix it.  Verified by hacking my
lit.site.cfg.py so host_triple = target_triple = "i686-pc-windows-msvc"
and the test correctly reported XFAIL, while "i686-pc-linux" passes.

2 years agoRevert "[lit] Define keyword used by MCJIT test"
Paul Robinson [Mon, 31 Oct 2022 17:44:49 +0000 (10:44 -0700)]
Revert "[lit] Define keyword used by MCJIT test"

This reverts commit 6d859266803e2a9060c4e8770f92cc2c7bd05a3b.

Causing an XPASS on 32-bit Gentoo, as reported by mgorny.

2 years ago[utils] Remove ancient scripts using llvm-config --src-root
Fangrui Song [Mon, 31 Oct 2022 17:45:00 +0000 (10:45 -0700)]
[utils] Remove ancient scripts using llvm-config --src-root

The last effective changes for the 4 scripts were more than 10 years ago.
They do grep and lines of code counting which have mature modern replacements
(rg, tokei, etc).

Reviewed By: mgorny

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

2 years ago[X86][Driver] Remove stale FIXME. NFC
Craig Topper [Mon, 31 Oct 2022 17:32:22 +0000 (10:32 -0700)]
[X86][Driver] Remove stale FIXME. NFC

We use getHostCPUFeatures in x86::getX86TargetFeatures so I think
this FIXME is taken care of already.

Reviewed By: RKSimon

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

2 years ago[flang] Always diagnose incompatible function results when associating function pointers
Peter Klausler [Wed, 12 Oct 2022 19:59:48 +0000 (12:59 -0700)]
[flang] Always diagnose incompatible function results when associating function pointers

There are some exceptional cases where the compiler permits association of
procedure pointers or dummy arguments with slightly incompatible procedure
targets, but they should not override any incompatibilty of function
result types.

(Includes a second fix to resolve the original motivating test failure, in
which a COMPLEX intrinsic function was getting its result kind divided by
two due to an implicit C++ conversion of the kind to a "*kind" parse tree
node, and those legacy "COMPLEX*size" type designators' values are twice
the type kind value.)

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

2 years ago[OpenMP] [OMPT] [2/8] Implemented a connector for communication of OMPT callbacks...
Dhruva Chakrabarti [Fri, 17 Jun 2022 23:05:39 +0000 (16:05 -0700)]
[OpenMP] [OMPT] [2/8] Implemented a connector for communication of OMPT callbacks between libraries.

This is part of a set of patches implementing OMPT target callback support and has been split out of the originally submitted https://reviews.llvm.org/D113728. The overall design can be found in https://rice.app.box.com/s/pf3gix2hs4d4o1aatwir1set05xmjljc

The purpose of this patch is to provide a way to register tool-provided callbacks into libomp when libomptarget is loaded.

Introduced a cmake variable LIBOMPTARGET_OMPT_SUPPORT that can be used to control OMPT target support. It follows host OMPT support, controlled by LIBOMP_HAVE_OMPT_SUPPORT.

Added a connector that can be used to communicate between OMPT implementations in libomp and libomptarget or libomptarget and a plugin.

Added a global constructor in libomptarget that uses the connector to force registration of tool-provided callbacks in libomp. A pair of init and fini functions are provided to libomp as part of the connect process which will be used to register the tool-provided callbacks in libomptarget.

Depends on D123429

Patch from John Mellor-Crummey <johnmc@rice.edu>
(With contributions from Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>)

Reviewed By: dreachem

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

2 years ago[X86] Enable EVEX GFNI instructions without avx512bw.
Craig Topper [Mon, 31 Oct 2022 17:04:36 +0000 (10:04 -0700)]
[X86] Enable EVEX GFNI instructions without avx512bw.

We only really need avx512bw for masking 256 or 512 bit GFNI
instructions due to the need for v32i1 or v64i1.

I wanted to enable 128-bit intrinsics with avx512vl, but the
__builtin_ia32_selectb_128 used in the header file requires avx512bw.
The codegen test for the same is also not using a masked instruction
because vselect with v16i1 mask and v16i8 is not legal so is expanded
before isel. To fix these issues we need a mask specific builtin and a
mask specific ISD opcode.

Fixes PR58687.

Reviewed By: pengfei

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

2 years ago[flang] Add atomic_and to list of intrinsics
Katherine Rasmussen [Fri, 28 Oct 2022 00:55:18 +0000 (17:55 -0700)]
[flang] Add atomic_and to list of intrinsics

Add the atomic subroutine, atomic_and, to the list of
intrinsic subroutines, add its last dummy argument to a check
for coindexed-object, and update test.

Reviewed By: PeteSteinfeld

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

2 years ago[clang] Instantiate alias templates with sugar
Matheus Izvekov [Sun, 23 Oct 2022 14:57:12 +0000 (16:57 +0200)]
[clang] Instantiate alias templates with sugar

This makes use of the changes introduced in D134604, in order to
instantiate alias templates witn a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be
able to resugar them later anyway.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136565

2 years ago[clang] Instantiate NTTPs and template default arguments with sugar
Matheus Izvekov [Sun, 23 Oct 2022 11:41:57 +0000 (13:41 +0200)]
[clang] Instantiate NTTPs and template default arguments with sugar

This makes use of the changes introduced in D134604, in order to
instantiate non-type template parameters and default template arguments
with a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be
able to resugar them later anyway.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136564

2 years ago[clang] ASTImporter: Fix importing of va_list types and declarations
Matheus Izvekov [Sat, 29 Oct 2022 18:36:31 +0000 (20:36 +0200)]
[clang] ASTImporter: Fix importing of va_list types and declarations

This fixes a problem where __va_list_tag was not correctly imported,
possibly leading to multiple definitions with different types.

This adds __va_list_tag to it's proper scope, so that the ASTImporter
can find it.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136886

2 years ago[clang] Fix handling of unexpanded packs in template argument expressions.
Matheus Izvekov [Fri, 28 Oct 2022 20:22:39 +0000 (22:22 +0200)]
[clang] Fix handling of unexpanded packs in template argument expressions.

Closes #58679.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136977

2 years ago[clang] Improve error recovery for pack expansion of expressions
Matheus Izvekov [Fri, 28 Oct 2022 16:23:02 +0000 (18:23 +0200)]
[clang] Improve error recovery for pack expansion of expressions

Closes #58673.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136962

2 years ago[libc] Implement getopt
Alex Brachet [Mon, 31 Oct 2022 16:55:53 +0000 (16:55 +0000)]
[libc] Implement getopt

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

2 years ago[SLP]Fix a crash in the analysis of the compatible cmp operands.
Alexey Bataev [Mon, 31 Oct 2022 15:54:49 +0000 (08:54 -0700)]
[SLP]Fix a crash in the analysis of the compatible cmp operands.

We can skip the analysis of the operands opcodes, can compare directly
them in some cases.

2 years ago[AAPointerInfo] check for Unknown offsets in callee
Sameer Sahasrabuddhe [Mon, 31 Oct 2022 16:45:56 +0000 (22:15 +0530)]
[AAPointerInfo] check for Unknown offsets in callee

When translating offset info from the callee at a call site, first check if the
offset is Unknown. Any offset in the caller should be added only if the callee
offset is valid.

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

2 years ago[gn build] Port aee2a35ac4ab
LLVM GN Syncbot [Mon, 31 Oct 2022 15:53:48 +0000 (15:53 +0000)]
[gn build] Port aee2a35ac4ab

2 years ago[LoopFuse] Ensure loops are in loop simplified form under new PM
Mengxuan Cai [Mon, 31 Oct 2022 15:45:44 +0000 (11:45 -0400)]
[LoopFuse] Ensure loops are in loop simplified form under new PM

Loop Fusion (Function Pass) requires loops in simplified form. With
legacy-pm, loop-simplify pass is added as a dependency for loop-fusion.
But the new pass manager does not always ensure this format. This patch
tries to invoke simplifyLoop() on loops that are not in simplified form
only for new PM.

Reviewed By: aeubanks

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

2 years ago[X86] Add AVX-NE-CONVERT instructions.
Freddy Ye [Mon, 31 Oct 2022 15:01:31 +0000 (23:01 +0800)]
[X86] Add AVX-NE-CONVERT instructions.

For more details about these instructions, please refer to the latest ISE document: https://www.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html

Reviewed By: pengfei

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

2 years ago[JITLink][AArch46] Update aarch64 pointer jump stub sequence, add utilities.
Lang Hames [Mon, 31 Oct 2022 05:14:30 +0000 (22:14 -0700)]
[JITLink][AArch46] Update aarch64 pointer jump stub sequence, add utilities.

Updates the aarch64 pointer jump stub sequence to:

ADRP x16, <ptr>@page21
LDR  x16, [x16, <ptr>@pageoff12]
BR   x16

from:

LDR  x16, <ptr>@ldrimm19
BR   x16

The old sequence can only reference pointers within +/-1Mb, which may not be
enough for large object files. The new sequence can reach pointers within
+/-4Gb. (A future pre-fixup-pass could apply range-based optimizations to
turn this into an ldr-br-nop sequence.)

Also adds createPointerJumpStubBlock and createAnonymousPointerJumpStub
utilities along the same lines as their x86-64 counterparts.

The PLTTableManager is updated to use the new utility functions.

2 years ago[flang] Fix code generation for polymorphic deallocation
Valentin Clement [Mon, 31 Oct 2022 15:33:45 +0000 (16:33 +0100)]
[flang] Fix code generation for polymorphic deallocation

This patch fix issues found during call to deallocate.
fir.class can be handled the same way as fir.box in fir.store operation
code generation. In MutableBox::createNewFirBox, the fir.class is
also already a boxed entity.

Reviewed By: PeteSteinfeld

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

2 years ago[Support] Do not run test on AIX
Serge Pavlov [Mon, 31 Oct 2022 12:09:32 +0000 (19:09 +0700)]
[Support] Do not run test on AIX

A part of the unit test CommandLineTest/BadResponseFile, added in
the commit fd3d7a9f8cbb (Handle errors in expansion of response files)
fails on AIX. The test checks if an error is issued when `file` in
`@file` is a path to directory. This change excludes that check on
AIX platform.

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

2 years ago[mlir][sparse] Implement the rewrite for sparse_tensor.push_back a value n times.
bixia1 [Fri, 28 Oct 2022 17:26:54 +0000 (10:26 -0700)]
[mlir][sparse] Implement the rewrite for sparse_tensor.push_back a value n times.

Reviewed By: aartbik

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

2 years ago[OpenMP] [OMPIRBuilder] Create a new datatype to hold the unique target region info
Jan Sjodin [Fri, 28 Oct 2022 17:54:59 +0000 (13:54 -0400)]
[OpenMP] [OMPIRBuilder] Create a new datatype to hold the unique target region info

Re-apply of: 3d0e9edd8e53fb72e85084f4170513159212839a
Reverted in: 0cb65b0a585c8b3d4a8a2aefe994a8fc907934f8

A function parameter was using the wrong type 'llvm::TargetRegion' instead of
'const llvm:: TargetRegion&', which caused the error in the address sanitizer.
The correct type is now used.

This patch puts the individual target region information attributes into a
struct so that the nested mappings are not needed and passing the information
around is simplified.

Reviewed By: jdoerfert, mikerice

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

2 years ago[libomptarget] Fix a race condition in checkDeviceAndCtors
Lechen Yu [Mon, 31 Oct 2022 14:36:58 +0000 (15:36 +0100)]
[libomptarget] Fix a race condition in checkDeviceAndCtors

When multiple threads invoke checkDeviceAndCtors, both of them may read true
from the shared variable Device.HasPendingGlobals, and then invoke initLibrary
redundantly. Therefore only protecting the access to Device.HasPendingGlobals
is not sufficient to guarantee that initLibrary is invoked just once.

To fix this race condition, we move the invocation of initLibrary into the
critical section, and remove the same lock inside initLibrary.

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

2 years ago[flang][NFC] move constant lowering into its own unit
Jean Perier [Mon, 31 Oct 2022 14:32:29 +0000 (15:32 +0100)]
[flang][NFC] move constant lowering into its own unit

This patch moves intrinsic evaluate::Constant<T> lowering into its own
unit outside of ScalarExpr and genarr lowering so that it can
be used by the new lowering without any changes.

DerivedType lowering cannot be shared at that stage because it is too
correlated with the current lowering (requires structure constructor
and designator lowering).

The code had to be refactored quite a bit so that it could be carved
out, but the only "functional" change is that the length of character
arrays lowered by genarr is now `index` instead of `i64` (see test change).
One non-functional benefit of the change is that `toEvExpr` is not
needed anymore and some compile time copies of big constant arrays
that it was causing are removed (see old calls in previous genarr code),
although I am not sure any compile time speed-ups are visible here.

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

2 years ago[lldb][Test] Fix TestFrameFormatNameWithArgs.test on Linux
Michael Buch [Mon, 31 Oct 2022 14:11:18 +0000 (14:11 +0000)]
[lldb][Test] Fix TestFrameFormatNameWithArgs.test on Linux

Be less strict about the `std::` namespace string. Depending
on platform it may contain an inline namespace, e.g., `__1`.

2 years ago[mlir][doc] Update op optional-group asm format doc
rkayaith [Fri, 28 Oct 2022 21:17:54 +0000 (17:17 -0400)]
[mlir][doc] Update op optional-group asm format doc

Update docs to describe the behaviour when a default-valued attribute is
used as an optional-group's anchor after D134993.

Reviewed By: Mogball

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

2 years ago[include-cleaner] Add a data-structure to capture IWYU pragmas.
Haojian Wu [Tue, 18 Oct 2022 20:25:46 +0000 (22:25 +0200)]
[include-cleaner] Add a data-structure to capture IWYU pragmas.

PragmaIncludes captures the pragma-based header-mapping information, it is used
in the "Location => Header" step to determine the final spelling header for a
symbol (rather than the header directive).

The structure is by design to be used inside the include-cleaner library
and clangd.

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

2 years agoRevert "[llvm] [cmake] Set EXCLUDE_FROM_ALL on gtest and TestingSupport"
Michał Górny [Mon, 31 Oct 2022 14:20:48 +0000 (15:20 +0100)]
Revert "[llvm] [cmake] Set EXCLUDE_FROM_ALL on gtest and TestingSupport"

This reverts commit 64959325eb470489ca5757b9bd6eef97b402a0da.  It broke
the flang-aarch64-out-of-tree buildbot.

2 years ago[LLDB][AArch64] Add SME2 to disassembler test
David Spickett [Mon, 31 Oct 2022 11:35:54 +0000 (11:35 +0000)]
[LLDB][AArch64] Add SME2 to disassembler test

+all includes it since 5d67b051e29c2bde42a5004634296b88542c096a.

2 years ago[BasicBlockUtils] Add a new way for CreateControlFlowHub()
Brendon Cahoon [Sun, 9 Oct 2022 22:34:57 +0000 (17:34 -0500)]
[BasicBlockUtils] Add a new way for CreateControlFlowHub()

The existing way of creating the predicate in the guard blocks uses
a boolean value per outgoing block. This increases the number of live
booleans as the number of outgoing blocks increases. The new way added
in this change is to store one integer to represent the outgoing block
we want to branch to, then at each guard block, an integer equality
check is performed to decide which a specific outgoing block is taken.

Using an integer reduces the number of live values and decreases
register pressure especially in cases where there are a large number
of outgoing blocks. The integer based approach is used when the
number of outgoing blocks crosses a threshold, which is currently set
to 32.

Patch by Ruiling Song.

Differential review: https://reviews.llvm.org/D127831

2 years ago[llvm] [cmake] Set EXCLUDE_FROM_ALL on gtest and TestingSupport
Michał Górny [Sun, 30 Oct 2022 06:37:15 +0000 (07:37 +0100)]
[llvm] [cmake] Set EXCLUDE_FROM_ALL on gtest and TestingSupport

Exclude building googletest and LLVMTestingSupport libraries from
the `all` target.  If unittests are being built, these libraries will
be built as a dependency anyway.  If they are not being built, building
them makes little sense as they are not installed or used otherwise.

This will also make standalone builds of other projects easier, as it
makes it possible to include these directories without having to cover
them with additional conditions to prevent them from being built
unconditionally.

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

2 years ago[ObjCARC] Regenerate test checks (NFC)
Nikita Popov [Mon, 31 Oct 2022 13:52:05 +0000 (14:52 +0100)]
[ObjCARC] Regenerate test checks (NFC)

2 years ago[flang][NFC] Deallocation of polymorphoc entities are done with the runtime call
Valentin Clement [Mon, 31 Oct 2022 13:51:44 +0000 (14:51 +0100)]
[flang][NFC] Deallocation of polymorphoc entities are done with the runtime call

The runtime function `AllocatableDeallocate/PointerDeallocate` is reponsible to
deallocate and finalize it. This patch just adds tests to make sure the correct
runtime function is called.

Reviewed By: PeteSteinfeld

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

2 years ago[clangd] Run semantic highligting in clangd check.
Haojian Wu [Mon, 31 Oct 2022 09:04:27 +0000 (10:04 +0100)]
[clangd] Run semantic highligting in clangd check.

Allowing us to test this feature (context: a recent crash in
semantic highlighting.)

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

2 years ago[AArch64][SVE2] Add the SVE2.1 shift-and-narrow instructions
David Sherwood [Wed, 19 Oct 2022 15:21:08 +0000 (15:21 +0000)]
[AArch64][SVE2] Add the SVE2.1 shift-and-narrow instructions

This patch adds the assembly/disassembly for the following instructions:

sqrshrn  : Signed saturating rounding shift right narrow by immediate and interleave
sqrshrun : Signed saturating rounding shift right unsigned narrow by immediate and interleave
uqrshrn  : Unsigned saturating rounding shift right narrow by immediate and interleave

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

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

2 years agoNFC: restructure code for CreateControlFlowHub()
Brendon Cahoon [Sun, 9 Oct 2022 22:07:20 +0000 (17:07 -0500)]
NFC: restructure code for CreateControlFlowHub()

Differential review: https://reviews.llvm.org/D127830

2 years ago[NFC] Use isa<...> to replace isa<>||isa<> in clang/Serialization
Chuanqi Xu [Mon, 31 Oct 2022 13:15:04 +0000 (21:15 +0800)]
[NFC] Use isa<...> to replace isa<>||isa<>  in clang/Serialization

Now isa supports the variant args, which could simplify the codes
further. This patch simplify the uses in clang/Serialization

2 years ago[InstCombine] fold mul with decremented "shl -1" factor
Sanjay Patel [Mon, 31 Oct 2022 12:54:18 +0000 (08:54 -0400)]
[InstCombine] fold mul with decremented "shl -1" factor

This is a sibling to:
6064e92b0a84
...but we canonicalize the shl+add to shl+xor,
so the pattern is different than I expected:
https://alive2.llvm.org/ce/z/8CX16e

I have not found any patterns that are safe
to propagate no-wrap, so that is not included
here.

2 years ago[InstCombine] add tests for mul with shl; NFC
Sanjay Patel [Mon, 31 Oct 2022 12:41:25 +0000 (08:41 -0400)]
[InstCombine] add tests for mul with shl; NFC

2 years ago[AArch64] Include SME2 in +all
David Green [Mon, 31 Oct 2022 13:04:32 +0000 (13:04 +0000)]
[AArch64] Include SME2 in +all

The sme2 predicate was as AssemblerPredicate, not
AssemblerPredicateWithAll like all the other features, meaning it wasn't
included in +all. This fixes that inconsistency, allowing the
instructions to be decoded by default.

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

2 years ago[X86] combineConcatVectorOps - fold concat(GF2P8AFFINEQB(x,y,c),GF2P8AFFINEQB(z,w...
Simon Pilgrim [Mon, 31 Oct 2022 12:27:47 +0000 (12:27 +0000)]
[X86] combineConcatVectorOps - fold concat(GF2P8AFFINEQB(x,y,c),GF2P8AFFINEQB(z,w,c)) -> GF2P8AFFINEQB(concat(x,z),concat(y,w),c)

Pulled out of D137026

2 years ago[lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName
Michael Buch [Thu, 27 Oct 2022 10:10:28 +0000 (11:10 +0100)]
[lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

This patch implements the `GetFunctionDisplayName` API which gets
used by the frame-formatting code to decide how to print a
function name.

Currently this API trivially returns `false`, so we try to parse
the demangled function base-name by hand. We try find the closing
parenthesis by doing a forward scan through the demangled name. However,
for arguments that contain parenthesis (e.g., function pointers)
this would leave garbage in the frame function name.

By re-using the `CPlusPlusLanguage` parser for this we offload the
need to parse function names to a component that knows how to do this
already.

We leave the existing parsing code in `FormatEntity` since it's used
in cases where a language-plugin is not available (and is not
necessarily C++ specific).

**Example**

For following function:
```
int foo(std::function<int(void)> const& func) { return 1; }
```

Before patch:
```
frame #0: 0x000000010000151c a.out`foo(func= Function = bar() )> const&) at sample.cpp:11:49
```

After patch:
```
frame #0: 0x000000010000151c a.out`foo(func= Function = bar() ) at sample.cpp:11:49
```

**Testing**

* Added shell test

2 years ago[lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType
Michael Buch [Thu, 27 Oct 2022 10:09:22 +0000 (11:09 +0100)]
[lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType

This patch adds a way to extract the return type out
of the `CPlusPlusNameParser`. This will be useful
for cases where we want a function's basename *and* the
return type but not the function arguments; this is
currently not possible (the parser either gives us the
full name or just the basename). Since the parser knows
how to handle return types already we should just expose
this to users that need it.

**Testing**

* Added unit-tests

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

2 years ago[lldb][FormatEntity][NFC] Move function argument parsing code into separate functions
Michael Buch [Wed, 26 Oct 2022 16:13:00 +0000 (17:13 +0100)]
[lldb][FormatEntity][NFC] Move function argument parsing code into separate functions

Hopefully makes the code more readable and allows
us to re-use argument pretty-printing code from
the `CPlusPlusLanguage` plugin in a follow-up commit.

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

2 years agoAdd explicit cast to fix MSVC error: "'return': cannot convert from 'int (__cdecl...
Simon Pilgrim [Mon, 31 Oct 2022 12:01:06 +0000 (12:01 +0000)]
Add explicit cast to fix MSVC error: "'return': cannot convert from 'int (__cdecl *)(int)' to '`anonymous-namespace'::Plus1FunctionRef::FuncT'"

2 years ago[flang] Add -ffp-contract option processing
Tom Eccles [Mon, 31 Oct 2022 11:30:32 +0000 (11:30 +0000)]
[flang] Add -ffp-contract option processing

Only add the option processing and store the result. No attributes are
added to FIR yet.

Only the "off" and "fast" options are supported. "fast-honor-pragmas" is not applicable because we do not implement `#pragma clang fp contract()` in Fortran [1]. "on" is not supported because it is unclear how to fuse only within individual statements. gfortran also does not implement "on": treating it as an "off".

Currently the default value is "off" to preserve existing behavior. gfortran uses "fast" by default and that may be the right thing for flang-new after further discussion in the future, but that can be changed separately. gfortran's documentation is available [[ https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html | here ]].

[1] https://clang.llvm.org/docs/LanguageExtensions.html#extensions-to-specify-floating-point-flags

Reviewed By: vzakhari, awarzynski

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

2 years ago[AArch64][SME] Make all SME intrinsics use 32bit immediates.
Sander de Smalen [Fri, 28 Oct 2022 13:26:39 +0000 (13:26 +0000)]
[AArch64][SME] Make all SME intrinsics use 32bit immediates.

This aligns with what was done for SVE, which consistently uses 32bit
immediates at the LLVM IR level.

Additionally, this change forces the intrinsic operands to be immediates
using ImmArg<>, which subsequently requires the codegenerator to match
TargetConstants instead of Constants.

Reviewed By: paulwalker-arm

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

2 years ago[clang][Interp] Reorder field destruction to avoid use after dtor
Benjamin Kramer [Mon, 31 Oct 2022 11:20:10 +0000 (12:20 +0100)]
[clang][Interp] Reorder field destruction to avoid use after dtor

Found by msan -fsanitize-memory-use-after-dtor.

==8259==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55dbec54d2b8 in dtorRecord(clang::interp::Block*, char*, clang::interp::Descriptor*) clang/lib/AST/Interp/Descriptor.cpp:150:22
    #1 0x55dbec54bfcf in dtorArrayDesc(clang::interp::Block*, char*, clang::interp::Descriptor*) clang/lib/AST/Interp/Descriptor.cpp:97:7
    #2 0x55dbec508578 in invokeDtor clang/lib/AST/Interp/InterpBlock.h:79:7
    #3 0x55dbec508578 in clang::interp::Program::~Program() clang/lib/AST/Interp/Program.h:55:19
    #4 0x55dbec50657a in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #5 0x55dbec50657a in std::__msan::unique_ptr<clang::interp::Program, std::__msan::default_delete<clang::interp::Program>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #6 0x55dbec5035a1 in clang::interp::Context::~Context() clang/lib/AST/Interp/Context.cpp:27:22
    #7 0x55dbebec1daa in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #8 0x55dbebec1daa in std::__msan::unique_ptr<clang::interp::Context, std::__msan::default_delete<clang::interp::Context>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #9 0x55dbebe285f9 in clang::ASTContext::~ASTContext() clang/lib/AST/ASTContext.cpp:1038:40
    #10 0x55dbe941ff13 in llvm::RefCountedBase<clang::ASTContext>::Release() const llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:101:7
    #11 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:159:38
    #12 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:224:7
    #13 0x55dbe94353ef in ~IntrusiveRefCntPtr llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:191:27
    #14 0x55dbe94353ef in clang::CompilerInstance::setASTContext(clang::ASTContext*) clang/lib/Frontend/CompilerInstance.cpp:178:3
    #15 0x55dbe95ad0ad in clang::FrontendAction::EndSourceFile() clang/lib/Frontend/FrontendAction.cpp:1100:8
    #16 0x55dbe9445fcf in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:1047:11
    #17 0x55dbe6b3afef in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:25
    #18 0x55dbe6b13288 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) clang/tools/driver/cc1_main.cpp:250:15
    #19 0x55dbe6b0095f in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) clang/tools/driver/driver.cpp:319:12
    #20 0x55dbe6aff41c in clang_main(int, char**) clang/tools/driver/driver.cpp:395:12
    #21 0x7f9be07fa632 in __libc_start_main
    #22 0x55dbe6a702e9 in _start

  Member fields were destroyed
    #0 0x55dbe6a7da5d in __sanitizer_dtor_callback_fields compiler-rt/lib/msan/msan_interceptors.cpp:949:5
    #1 0x55dbec5094ac in ~SmallVectorImpl llvm/include/llvm/ADT/SmallVector.h:479:7
    #2 0x55dbec5094ac in ~SmallVectorImpl llvm/include/llvm/ADT/SmallVector.h:612:3
    #3 0x55dbec5094ac in llvm::SmallVector<clang::interp::Record::Base, 8u>::~SmallVector() llvm/include/llvm/ADT/SmallVector.h:1207:3
    #4 0x55dbec508e79 in clang::interp::Record::~Record() clang/lib/AST/Interp/Record.h:24:7
    #5 0x55dbec508612 in clang::interp::Program::~Program() clang/lib/AST/Interp/Program.h:49:26
    #6 0x55dbec50657a in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #7 0x55dbec50657a in std::__msan::unique_ptr<clang::interp::Program, std::__msan::default_delete<clang::interp::Program>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #8 0x55dbec5035a1 in clang::interp::Context::~Context() clang/lib/AST/Interp/Context.cpp:27:22
    #9 0x55dbebec1daa in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #10 0x55dbebec1daa in std::__msan::unique_ptr<clang::interp::Context, std::__msan::default_delete<clang::interp::Context>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #11 0x55dbebe285f9 in clang::ASTContext::~ASTContext() clang/lib/AST/ASTContext.cpp:1038:40
    #12 0x55dbe941ff13 in llvm::RefCountedBase<clang::ASTContext>::Release() const llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:101:7
    #13 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:159:38
    #14 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:224:7
    #15 0x55dbe94353ef in ~IntrusiveRefCntPtr llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:191:27
    #16 0x55dbe94353ef in clang::CompilerInstance::setASTContext(clang::ASTContext*) clang/lib/Frontend/CompilerInstance.cpp:178:3
    #17 0x55dbe95ad0ad in clang::FrontendAction::EndSourceFile() clang/lib/Frontend/FrontendAction.cpp:1100:8
    #18 0x55dbe9445fcf in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:1047:11
    #19 0x55dbe6b3afef in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:25
    #20 0x55dbe6b13288 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) clang/tools/driver/cc1_main.cpp:250:15
    #21 0x55dbe6b0095f in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) clang/tools/driver/driver.cpp:319:12
    #22 0x55dbe6aff41c in clang_main(int, char**) clang/tools/driver/driver.cpp:395:12
    #23 0x7f9be07fa632 in __libc_start_main
    #24 0x55dbe6a702e9 in _start

2 years ago[AArch64-SVE]: Force generating code compatible to streaming mode.
Hassnaa Hamdi [Mon, 24 Oct 2022 09:45:00 +0000 (09:45 +0000)]
[AArch64-SVE]: Force generating code compatible to streaming mode.

When streaming mode is enabled, lower some operations and disable some code paths;
to force generateing code compatible to streaming mode.
Add streaming-mode flag for new sve-fixed-length testing files:
build_vector.ll
concat.ll
extract-subvector.ll
extract-vector-elt.ll
int-shifts.ll
loads.ll
shuffle.ll
stores.ll

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

2 years ago[AArch64] Adjust operand sequence for Add+Sub to combine more inline shift
chenglin.bi [Mon, 31 Oct 2022 02:37:40 +0000 (10:37 +0800)]
[AArch64] Adjust operand sequence for Add+Sub to combine more inline shift

((X >> C) - Y) + Z --> (Z - Y) + (X >> C)

Fix AArch part: #55714

Reviewed By: dmgreen

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

2 years ago[MLIR][OpenMP] Allow the single operation to have a region
Kiran Chandramohan [Mon, 31 Oct 2022 10:34:39 +0000 (10:34 +0000)]
[MLIR][OpenMP] Allow the single operation to have a region

The OpenMP standard specifies the region inside to be a structured
block. This means that branches into or out of the region is not
permitted but branches are permitted inside the OpenMP single region.
This is currently modeled by having a region of kind `AnyRegion` for
all the OpenMP ops. In future we can have a more strictly defined
region.

Fixes #58396.

Reviewed By: peixin

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

2 years ago[clangd] Populate ranges and symbol origin for paramname completions
Kadir Cetinkaya [Fri, 28 Oct 2022 14:30:22 +0000 (16:30 +0200)]
[clangd] Populate ranges and symbol origin for paramname completions

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

2 years ago[clangd] Fix a semantic-highlighting crash.
Haojian Wu [Mon, 31 Oct 2022 08:58:58 +0000 (09:58 +0100)]
[clangd] Fix a semantic-highlighting crash.

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

2 years ago[mlir][bufferize][NFC] Better debug output for One-Shot Analysis
Matthias Springer [Mon, 31 Oct 2022 09:46:33 +0000 (10:46 +0100)]
[mlir][bufferize][NFC] Better debug output for One-Shot Analysis

Run mlir-opt with `-debug-only="one-shot-analysis"` for detailed debug output.

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

2 years ago[flang] Set declared type when NULLIFY a polymorphic pointer
Valentin Clement [Mon, 31 Oct 2022 10:02:50 +0000 (11:02 +0100)]
[flang] Set declared type when NULLIFY a polymorphic pointer

Fortran standard 7.3.2.3 point 7 mentions that a diassociated
pointer dynamic type is its declared type.
in 9.7.2 note 1, when a NULLIFY statement is applied to a polymorphic pointer,
its dynamic type becomes the same as its declared type.
This patch enforce these standard points by calling the runtime function
`PointerNullifyDerived` with the declared type descriptor.

Reviewed By: jeanPerier

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

2 years ago[Attributes] Add additional MemoryEffects APIs (NFC)
Nikita Popov [Mon, 31 Oct 2022 09:34:51 +0000 (10:34 +0100)]
[Attributes] Add additional MemoryEffects APIs (NFC)

This adds the usual complement of APIs for creating and fetching
a non-trivial attribute.

Split out from D135780.

2 years ago[mlir][bufferize][NFC] Debug output during bufferization
Matthias Springer [Mon, 31 Oct 2022 09:24:02 +0000 (10:24 +0100)]
[mlir][bufferize][NFC] Debug output during bufferization

When running with `-debug`, print the IR after bufferizing each op.

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

2 years ago[llvm][ocaml] Replace deprecated C functions in OCaml bindings
Alan Hu [Mon, 31 Oct 2022 09:23:35 +0000 (10:23 +0100)]
[llvm][ocaml] Replace deprecated C functions in OCaml bindings

Follow-up to D135524, to replace two more deprecated C functions
in the OCaml bindings. const_in_bounds_gep now accepts the source
element type as argument, and const_element has been changed into
aggregate_element, which works on a wider range of constants and
returns an option.

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

2 years ago[ValueTracking] Improve performance of programUndefinedIfUndefOrPoison (NFC)
Geza Lore [Mon, 31 Oct 2022 09:20:11 +0000 (10:20 +0100)]
[ValueTracking] Improve performance of programUndefinedIfUndefOrPoison (NFC)

programUndefinedIfUndefOrPoison used to eagerly propagate the fact that
a value is poison to the users of the value. The problem is that if the
value has a lot of uses (orders of magnitude more than the scanning
limit we use in this function), then we spend the bulk of our time in
eagerly propagating the poison property, which we will mostly never use
later anyway due to the scanning limit.

I have a test case (of ~50k lines of machine generated C++), where this
results in ~60% of 35s compilation time being spent doing just this
eager propagation.

This patch changes programUndefinedIfUndefOrPoison to only propagate to
instructions actually visited, looking back to see if their operands are
poison. This should be equivalent and no functional change is intended,
but we regain virtually all of the 60% compilation time spent in this
function in my test case (i.e.: a 2.5x total compilation speedup).

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

2 years ago[BasicAA] Include MayBeCrossIteration in cache key
Nikita Popov [Tue, 18 Oct 2022 10:05:12 +0000 (12:05 +0200)]
[BasicAA] Include MayBeCrossIteration in cache key

Rather than switching to a new AAQI instance with empty cache when
MayBeCrossIteration is toggled, include the value in the cache key.

The implementation redundantly include the information in both sides
of the pair, but that seems simpler than trying to store it only on
one side.

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

2 years ago[flang][NFC] Update document with current status
Valentin Clement [Mon, 31 Oct 2022 08:45:38 +0000 (09:45 +0100)]
[flang][NFC] Update document with current status

fir.dispatch codegen was done in D136189.

2 years ago[Coroutines] Use default attributes for some coro intrinsics
Nikita Popov [Fri, 28 Oct 2022 09:42:10 +0000 (11:42 +0200)]
[Coroutines] Use default attributes for some coro intrinsics

This adds the default attributes (nosync, nofree, nocallback,
willreturn) to the coro.id and coro.subfn.addr intrinsics. This
is needed to avoid optimization regressions in the future.

It's probably possible to use default attributes for most other
coro intrinsics as well, but I only hit these as problematic in
practice.

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

2 years agoHandle errors in expansion of response files
Serge Pavlov [Mon, 31 Oct 2022 05:59:15 +0000 (12:59 +0700)]
Handle errors in expansion of response files

Previously an error raised during an expansion of response files (including
configuration files) was ignored and only the fact of its presence was
reported to the user with generic error messages. This made it difficult to
analyze problems. For example, if a configuration file tried to read an
inexistent file, the error message said that 'configuration file cannot
be found', which is wrong and misleading.

This change enhances handling errors in the expansion so that users
could get more informative error messages.

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

2 years ago[libarcher] Place classes in anonymous namespace
Nikita Popov [Thu, 27 Oct 2022 13:58:57 +0000 (15:58 +0200)]
[libarcher] Place classes in anonymous namespace

Place various classes/structs into anonymous namespaces and mark
variables as static. As far as I understand, these are all
implementation details and not intended to be exported -- only a
small number of tsan hooks are supposed to be.

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

2 years ago[X86] Use default attributes for intrinsics
Nikita Popov [Fri, 28 Oct 2022 10:30:28 +0000 (12:30 +0200)]
[X86] Use default attributes for intrinsics

This adds the default attributes (nocallback, nosync, nofree,
willreturn) to some X86 intrinsics. This will be needed to avoid
optimization regressions in the future (once we remove the
readonly -> willreturn implication for intrinsics).

Due to the number of intrinsics, this patch focuses just on the
IntrNoMem intrinsics up to the AVX2 section.

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

2 years ago[mlir] Do not expose MLIRContext::isDialectLoading
Matthias Springer [Mon, 31 Oct 2022 07:59:12 +0000 (08:59 +0100)]
[mlir] Do not expose MLIRContext::isDialectLoading

This addresses post-commit comments and should have been part of D136685.

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

2 years ago[docs] Add the description about mixing use of clang modules and c++
Chuanqi Xu [Mon, 24 Oct 2022 03:00:03 +0000 (11:00 +0800)]
[docs] Add the description about mixing use of clang modules and c++
modules

From the discussion in
https://discourse.llvm.org/t/how-should-we-support-dependency-scanner-for-c-20-modules/66027,
we get a consensus that we want to support clang modules and c++ modules
at the same time. This patch documents this intention.

Reviewed By: bruno

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

2 years agoFix unused-variable warning in release build, NFC
Haojian Wu [Mon, 31 Oct 2022 07:53:04 +0000 (08:53 +0100)]
Fix unused-variable warning in release build, NFC

2 years ago[libc++] newlib/xlocale.h: remove redundant includes
Michael Platings [Fri, 28 Oct 2022 13:19:05 +0000 (14:19 +0100)]
[libc++] newlib/xlocale.h: remove redundant includes

This permits using the <locale> header with newlib or picolibc when
LIBCXX_ENABLE_WIDE_CHARACTERS=FALSE.

Since D136682 the __support/xlocale headers themselves include the
headers they require, respecting the LIBCXX_ENABLE_WIDE_CHARACTERS
option.

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

2 years ago[lit][NFC] not check stdout in googletest-timeout.py
Yuanfang Chen [Mon, 31 Oct 2022 06:17:50 +0000 (23:17 -0700)]
[lit][NFC] not check stdout in googletest-timeout.py

This is flicky for buildbots (for example, https://lab.llvm.org/buildbot/#/builders/188/builds/21560)
because of the short timeout. The test coverage is not reduced because
the stdout check is performed in other googtest-* unit tests.

2 years ago[Clang] use non-instantiated function declaration for constraints partial ordering
Yuanfang Chen [Mon, 31 Oct 2022 04:33:22 +0000 (21:33 -0700)]
[Clang] use non-instantiated function declaration for constraints partial ordering

Per wordings in
- https://eel.is/c++draft/over.match#best.general-2.6
- https://eel.is/c++draft/temp.constr.order
- https://eel.is/c++draft/temp.constr#atomic-1

constraints partial ordering should use the unsubstituted template
parameters of the constrained entity, not the instantiated entity.

Fix #56154

Reviewed By: erichkeane, royjacobson, mizvekov

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

2 years ago[Clang] perform "maximum TLS alignment" check for template instantiation
Yuanfang Chen [Mon, 31 Oct 2022 04:33:10 +0000 (21:33 -0700)]
[Clang] perform "maximum TLS alignment" check for template instantiation

follow up https://github.com/llvm/llvm-project/commit/d30e2eefc3cf8dfd2210aefd62f13a6e7c011b43

Reviewed By: mizvekov

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

2 years ago[PowerPC] Optimize compare by using record form in post-RA.
esmeyi [Mon, 31 Oct 2022 05:33:50 +0000 (01:33 -0400)]
[PowerPC] Optimize compare by using record form in post-RA.

Summary: We currently optimize the comparison only in SSA, therefore we will miss some optimization opportunities where the input of comparison is lowered from COPY in post-RA.
Ie. ExpandPostRA::LowerCopy is called after PPCInstrInfo::optimizeCompareInstr.
This patch optimizes the comparison in post-RA and only the cases that compare against zero can be handled.
D131374 converts the comparison and its user to a compare against zero with the appropriate predicate on the branch, which creates additional opportunities for this patch.

Reviewed By: shchenz, lkail

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

2 years ago[JITLink][AArch64] Update edge names to be more descriptive, add comments.
Lang Hames [Mon, 31 Oct 2022 01:41:28 +0000 (18:41 -0700)]
[JITLink][AArch64] Update edge names to be more descriptive, add comments.

This brings the aarch64 edges into alignment with the naming scheme for the
x86-64 edges.

Edge behavior is mostly unchanged, but some irrelevant assertions and errors
have been removed.

2 years ago[LoongArch] Support inline asm operand modifier 'z'
Weining Lu [Mon, 31 Oct 2022 01:15:29 +0000 (09:15 +0800)]
[LoongArch] Support inline asm operand modifier 'z'

Print $zero register if operand is zero, otherwise print it normally.

Clang is highly compatible [1] with GCC inline assembly extensions,
allowing the same set of constraints, modifiers and operands as GCC
inline assembly. This patch tries to make it compatible regarding
LoongArch specific operand modifiers.

GCC supports many modifiers [2], but it seems that only x86 and msp430
are documented [3][4]. I don't know if any other modifiers are being
used except the 'z' in Linux [5].

[1]: https://clang.llvm.org/compatibility.html#inline-asm
[2]: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/loongarch.cc#L4884-L4911
[3]: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers
[4]: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#msp430Operandmodifiers
[5]: https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cmpxchg.h#L17

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

2 years ago[LoongArch] Replace assertion by error message while lowering RETURNADDR and FRAMEADDR
gonglingqin [Mon, 31 Oct 2022 01:18:20 +0000 (09:18 +0800)]
[LoongArch] Replace assertion by error message while lowering RETURNADDR and FRAMEADDR

If `__builtin_frame_address` or `__builtin_return_address` is invoked with
non-zero argument, show an error message instead of a crash.

Reference: https://reviews.llvm.org/rG83b88441ad951fe99c30402930ef3cd661f2fd2b

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

2 years ago[Clang][LoongArch] Support inline asm constraint 'J'
Weining Lu [Mon, 31 Oct 2022 00:46:58 +0000 (08:46 +0800)]
[Clang][LoongArch] Support inline asm constraint 'J'

'J' is defined in GCC [1] but not documented [2] while Linux [3] has
already used it in LoongArch port.

[1]: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/constraints.md#L61
[2]: https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html
[3]: https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cmpxchg.h#L19

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

2 years ago[flang] Catch attempts to do anything with statement functions other than call them
Peter Klausler [Mon, 24 Oct 2022 23:59:55 +0000 (16:59 -0700)]
[flang] Catch attempts to do anything with statement functions other than call them

A statement function in Fortran may be called, but it may not be the target
of a procedure pointer or passed as an actual argument.

2 years ago[NFC][m68k] Add pipeline.ll
Sheng [Mon, 31 Oct 2022 00:50:54 +0000 (08:50 +0800)]
[NFC][m68k] Add pipeline.ll

2 years ago[JITLink][i386] Adds absolute and pc relative relocation support for ELF/i386.
Kshitij Jain [Mon, 31 Oct 2022 00:24:57 +0000 (17:24 -0700)]
[JITLink][i386] Adds absolute and pc relative relocation support for ELF/i386.

This commit adds support for 32 bit absolute and pc relative relocations in
ELF/i386 objects, along with simple regression tests.

Reviewed By: sgraenitz, lhames

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

2 years ago[flang] Require explicit interface for some dummy procedures
Peter Klausler [Mon, 24 Oct 2022 22:47:56 +0000 (15:47 -0700)]
[flang] Require explicit interface for some dummy procedures

Some of the circumstances that require that a procedure have an
explicit interface at a point of call due to a characteristic of
a dummy argument apply to dummy procedures, too.

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

2 years agoMake scf.for and affine.for conditionally speculatable
Sanjoy Das [Thu, 20 Oct 2022 06:03:14 +0000 (23:03 -0700)]
Make scf.for and affine.for conditionally speculatable

for (I = Start; I < End; I += 1) always terminates so mark
{scf|affine}.for as RecursivelySpeculatable when step is known to be
1.

Reviewed By: chelini

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

2 years ago[JITLink][aarch64] Remove the unused PairedAddend aarch64 edge kind.
Lang Hames [Sun, 30 Oct 2022 22:53:38 +0000 (15:53 -0700)]
[JITLink][aarch64] Remove the unused PairedAddend aarch64 edge kind.

This is a vestige of the original MachO-specific edge set and was never used
as a generic aarch64 edge kind.

2 years ago[flang][MSVC] Disable test
Peter Klausler [Sun, 30 Oct 2022 21:53:05 +0000 (14:53 -0700)]
[flang][MSVC] Disable test

Disable the test that corresponds to a semantic check that was
disabled to work around an MSVC build problem.

2 years ago[flang] Enforce C815
Peter Klausler [Mon, 24 Oct 2022 20:03:50 +0000 (13:03 -0700)]
[flang] Enforce C815

A Fortran program may not specify a particular attribute multiple
times for the same entity in a scope.

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

2 years ago[InstCombine] Allow memcpys from constant memory to readonly nocapture parameters...
Patrick Walton [Thu, 27 Oct 2022 02:54:26 +0000 (19:54 -0700)]
[InstCombine] Allow memcpys from constant memory to readonly nocapture parameters to be elided.

Currently, InstCombine can elide a memcpy from a constant to a local alloca if
that alloca is passed as a nocapture parameter to a *function* that's readnone
or readonly, but it can't forward the memcpy if the *argument* is marked
readonly nocapture, even though readonly guarantees that the callee won't
mutate the pointee through that pointer. This patch adds support for detecting
and handling such situations, which arise relatively frequently in Rust, a
frontend that liberally emits readonly.

A more general version of this optimization would use alias analysis to check
the call's ModRef info for the pointee, but I was concerned about blowing up
compile time, so for now I'm just checking for one of readnone on the function,
readonly on the function, or readonly on the parameter.

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

2 years ago[ADT] Make mapped_iterator copy assignable
James Player [Sun, 30 Oct 2022 21:37:07 +0000 (14:37 -0700)]
[ADT] Make mapped_iterator copy assignable

As mentioned in https://discourse.llvm.org/t/rfc-extend-ranges-infrastructure-to-better-match-c-20/65377

Lambda objects are not copy assignable, and therefore neither are
iterator types which hold a lambda.  STL code require iterators be
copy assignable.  Users may not use mapped_iterator with a std::deque
for example: https://godbolt.org/z/4Px7odEEd

This blog post [1] explains the problem and solution.  We define a
wrapper class to store callable objects with two specialization.

1. Specialization for non-function types
    - Use a std::optional as storage for non-function callable.
    - Define operator=() implementation(s) which use
      std::optional::emplace() instead of the assignment operator.
2. Specialization for function types
    - Store as a pointer (even if template argument is a function reference).
    - Default construct pointer to nullptr.

This Callable wrapper class is now default constructible (with invalid
state) and copy/move assignable.

With these new properties available on the callable object,
mapped_iterator can define a default constructor as well.

[1] https://www.fluentcpp.com/2019/04/16/an-alternative-design-to-iterators-and-ranges-using-stdoptional/

Reviewed By: kazu

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