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

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

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

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

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

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

Reviewed By: StephenTozer

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

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

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

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

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

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

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

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

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

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

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

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

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

Reviewed By: arsenm

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

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

This reverts commit ee9ccb11036ac46ff9b9f3fa2d459d9d2bce5509.

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

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

This reverts commit 2679e8bba3e166e3174971d040b9457ec7b7d768.

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

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

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

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

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

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

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

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

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

Reviewed By: ahatanak

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

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

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

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

Reviewed By: craig.topper

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

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

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

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

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

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

Reviewed By: pengfei

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

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

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

This reverts commit ef47a0a711f12add401394f7af07a0b4d1635b56.

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

This reverts commit b2ac5fd724c44cf662caed84bd8f84af574b981d.

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

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

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

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

Reviewed By: StephenTozer

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

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

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

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

Make sure the destructor is called if needed.

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

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

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

Depends on D140872

Reviewed By: SixWeining

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

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

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

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

Reviewed By: MaskRay

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

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

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

This patch disallows decltype to be a part of these clauses

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

Depends on D140339

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

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

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

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

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

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

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

Depends on D140330

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

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

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

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

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

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

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

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

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

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

Reviewed By: nemanjai

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

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

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

Reviewed By: phosek

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

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

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

Reviewed By: nemanjai

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

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

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

Reviewed By: SixWeining

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

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

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Reviewed By: SixWeining, MaskRay

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

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

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

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

Reviewed By: antiagainst

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

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

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

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

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

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

It is only used in the LSAN specific part.

Reviewed By: vitalybuka

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

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

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

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

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

Add codegen pattern for sparse_tensor.indices_buffer.

Reviewed By: aartbik

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

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

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

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

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

Reviewed By: antiagainst

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

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

Closes #38042.

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

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

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

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

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

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

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

Reviewed By: nikic

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

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

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

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

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

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

Reviewed By: aaron.ballman

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

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

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

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

Reviewed By: RKSimon

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

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

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

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

[Support] Do not run test on z/OS

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

Reviewed By: fanbo-meng

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

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

Reviewed By: nikic, hctim

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

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

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

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

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

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

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

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

rdar://103415402

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

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

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

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

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

Change clang::annotate into clang::annotate_type.

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

Reviewed By: aaron.ballman

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

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

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

Reviewed By: kzhuravl, arsenm

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

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

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

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

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

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

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

Fixes #59778.

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

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

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

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

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

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

             Profit = NewOccupancy/OldOccupancy * OldMetric/NewMetric

Reviewed By: rampitec

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

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

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

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

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

This reverts commit f58b025354ee2d3bcd7ab2399a11429ec940c1e0.

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

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

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

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

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

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

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

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

Reviewed By: reames

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

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

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

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

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

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

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

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

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

Update the condition used to prevent it from getting removed.

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

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

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

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

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

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

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

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

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

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

Reviewed By: #lld-macho, thakis

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

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

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

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

Reviewed By: cor3ntin

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

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

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

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

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

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

Reviewed By: jeffbailey

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

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

Reviewed By: jeffbailey

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

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

Reviewed By: aartbik

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

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

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

Reviewed By: sivachandra

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

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

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

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

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

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

Fixing a crash during vsetvli insertion pass.

We have a testcase with 3 vsetvli:

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

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

Reviewed By: reames

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

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

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

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

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

Reviewed By: lebedev.ri

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

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

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

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

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

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

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

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

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

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

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

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

Reviewed By: jryans

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

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

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

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

Reviewed By: carlosgalvezp

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

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

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

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

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

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

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

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

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

Reviewed By: springerm, ThomasRaoux

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

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

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

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

Reviewed By: gchatelet

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reviewed By: carlosgalvezp

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

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

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

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

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

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

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

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