platform/upstream/llvm.git
18 months ago[clang-format] Recognize Verilog always blocks
sstwcw [Fri, 10 Mar 2023 15:12:13 +0000 (15:12 +0000)]
[clang-format] Recognize Verilog always blocks

The small `Coverage` test was added because we added the space rule
about 2 at signs along with the rule about only 1 of it. We have not
fully covered covergroup yet.

Reviewed By: MyDeveloperDay, owenpan

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

18 months ago[Docs] Added llvm-mc documentation
aabhinavg [Mon, 13 Mar 2023 06:22:00 +0000 (11:52 +0530)]
[Docs] Added llvm-mc documentation

Fix #61313

Reviewed By: lattner

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

18 months ago[PowerPC] remove side effect for some cases for saturate instructions
Chen Zheng [Tue, 7 Mar 2023 02:31:32 +0000 (21:31 -0500)]
[PowerPC] remove side effect for some cases for saturate instructions

Fixes #60684

Reviewed By: nemanjai

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

18 months agoadd testcases for D145353; NFC
Chen Zheng [Mon, 6 Mar 2023 05:28:39 +0000 (00:28 -0500)]
add testcases for D145353; NFC

18 months ago[libc][NFC] Switch nanosleep_test and getcwd_test to libc_errno.
Siva Chandra Reddy [Tue, 14 Mar 2023 01:25:47 +0000 (01:25 +0000)]
[libc][NFC] Switch nanosleep_test and getcwd_test to libc_errno.

18 months ago[libc] Switch termios implementations to libc_errno.
Siva Chandra Reddy [Tue, 14 Mar 2023 01:00:23 +0000 (01:00 +0000)]
[libc] Switch termios implementations to libc_errno.

18 months agoRevert "[LogicCombine 1/?] Implement a general way to simplify logical operations."
chenglin.bi [Tue, 14 Mar 2023 00:59:53 +0000 (08:59 +0800)]
Revert "[LogicCombine 1/?] Implement a general way to simplify logical operations."

This reverts commit 97dcbea63e11d566cff0cd3a758cf1114cf1f633.

18 months ago[ADT][NFCI] Do not use non-const lvalue-refs with enumerate in llvm/
Jakub Kuderski [Tue, 14 Mar 2023 00:48:38 +0000 (20:48 -0400)]
[ADT][NFCI] Do not use non-const lvalue-refs with enumerate in llvm/

Replace references to `enumerate` results with either const lvalue
rerences or structured bindings. I did not use structured bindings
everywhere as it wasn't clear to me it would improve readability.

This is in preparation to the switch to `zip` semantics which won't
support non-const lvalue reference to elements:
https://reviews.llvm.org/D144503.

Reviewed By: dblaikie

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

18 months ago[flang] Accept non-interoperable LOGICAL scalar dummy arguments
Peter Klausler [Mon, 13 Mar 2023 18:02:32 +0000 (11:02 -0700)]
[flang] Accept non-interoperable LOGICAL scalar dummy arguments

Some Fortran compilers allow kinds of LOGICAL other than C_BOOL
for the types of dummy arguments to interoperable (BIND(C))
procedures.  As any kind of LOGICAL can be converted to any
other without loss of information, this seems to be a useful
unambiguous extension that is attested in real codes; accept it
for scalars with a portability warning.

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

18 months ago[libc][NFC] Switch unistd.h tests to libc_errno.
Siva Chandra Reddy [Mon, 13 Mar 2023 23:44:03 +0000 (23:44 +0000)]
[libc][NFC] Switch unistd.h tests to libc_errno.

18 months agollvm-symbolizer: Don't crash when referencing an invalid CU in a dwp file twice
David Blaikie [Tue, 14 Mar 2023 00:49:32 +0000 (00:49 +0000)]
llvm-symbolizer: Don't crash when referencing an invalid CU in a dwp file twice

Previously we'd stash a null pointer in a sorted vector of CUs - the
next time around, we'd try to do a binary search in that vector (sorting
on a key inside the objects pointed to by the elements of the vector)
which would deref null if we'd stashed a null in there previously.

As a reasonable, but not ideal, workaround - don't stash any result in
the vector - this means every query will produce a new warning
(resulting in duplicate warnings) but better than a crash.

Stashing null in the list could be workable if we also stashed the
offset in a pair - but then all the clients would need to be fixed up
(maybe using a filtering iterator) which seems like overkill for this
uncommon error case.

18 months ago[-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream
ziqingluo-90 [Tue, 14 Mar 2023 00:17:30 +0000 (17:17 -0700)]
[-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream

The -Wunsafe-buffer-usage analysis outputs diagnostics in the order of
pointer values to associated `VarDecl`s. This creates non-determinism
in the order of diagnostics in output since the order cannot be
guaranteed in pointer values. However, our fix-it tests were written
under the assumption that diagnostics are output in source location
order.  This results in non-deterministic failures in our tests.  This
patch fixes the problem by keeping analysis results sorted by source
locations.

Reviewed by: jkorous, NoQ

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

18 months ago[lldb] Remove MIPS Linux UnixSignals
Alex Langford [Tue, 14 Mar 2023 00:17:02 +0000 (17:17 -0700)]
[lldb] Remove MIPS Linux UnixSignals

MIPS Linux support was removed in ce03a862372a6f36d2fcf80dc80052aa155fcae8

18 months ago[libc][NFC] Switch sys/*.h tests over to libc_errno.
Siva Chandra Reddy [Mon, 13 Mar 2023 23:43:31 +0000 (23:43 +0000)]
[libc][NFC] Switch sys/*.h tests over to libc_errno.

18 months ago[IRLinker] Fix mapping of declaration metadata
Carl Ritson [Mon, 13 Mar 2023 23:42:22 +0000 (08:42 +0900)]
[IRLinker] Fix mapping of declaration metadata

Ensure metadata for declarations copied during materialization
is properly mapped if declarations do not become definitions.

Reviewed By: tejohnson

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

18 months agoSwitch ABI references to env/environment
Jacob Lambert [Sat, 11 Mar 2023 01:27:43 +0000 (17:27 -0800)]
Switch ABI references to env/environment

To be consistent with Triple.h, we update references to the
optional fourth triple field from ABI to env or enviornment

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

18 months ago[clang][deps] Handle response files in dep scanner
Ben Langmuir [Sat, 11 Mar 2023 05:21:09 +0000 (21:21 -0800)]
[clang][deps] Handle response files in dep scanner

Extract the code the driver uses to expand response files and reuse it
in the dependency scanner.

rdar://106155880

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

18 months ago[libc][NFC] Switch mman.h tests to libc_errno and update Bazel build.
Siva Chandra Reddy [Mon, 13 Mar 2023 22:46:19 +0000 (22:46 +0000)]
[libc][NFC] Switch mman.h tests to libc_errno and update Bazel build.

18 months ago[libc][NFC] Switch startup tests to libc_errno.
Siva Chandra Reddy [Mon, 13 Mar 2023 22:11:32 +0000 (22:11 +0000)]
[libc][NFC] Switch startup tests to libc_errno.

18 months ago[libc][NFC] Switch string and errno tests to libc_errno.
Siva Chandra Reddy [Mon, 13 Mar 2023 22:11:07 +0000 (22:11 +0000)]
[libc][NFC] Switch string and errno tests to libc_errno.

18 months ago[libc][NFC] Switch all uses of errno in math and math tests to libc_errno.
Siva Chandra Reddy [Mon, 13 Mar 2023 22:07:34 +0000 (22:07 +0000)]
[libc][NFC] Switch all uses of errno in math and math tests to libc_errno.

18 months ago[RISCV] Improve SK_Reverse shuffle costs for fixed length vectors
Philip Reames [Mon, 13 Mar 2023 22:10:13 +0000 (15:10 -0700)]
[RISCV] Improve SK_Reverse shuffle costs for fixed length vectors

As noted by @luke (https://reviews.llvm.org/D145953#inline-1409312), we were accounting for the cost of vector element size using vlenb whereas the expression can be constant folded for fixed length vectors.

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

18 months ago[Propeller][ELF] Add Doxygen comment for decodeBBAddrMap
Aiden Grossman [Mon, 13 Mar 2023 21:43:05 +0000 (21:43 +0000)]
[Propeller][ELF] Add Doxygen comment for decodeBBAddrMap

Adds a doxygen comment on decodeBBAddrMap specifying what it does as well
as some requirements that need to be met when calling it (especially
the condition of passing in a relocation section when the ELFFile is
relocatable).

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

18 months ago[ASAN] Extract out a helper routine for foreach lane on vectors [nfc]
Philip Reames [Mon, 13 Mar 2023 21:40:15 +0000 (14:40 -0700)]
[ASAN] Extract out a helper routine for foreach lane on vectors [nfc]

The new API matches a case we also need in MSAN.  For the moment, I'm staging this as a local-to-ASAN commit, but I expect to move this to a shared location and reuse in the next day or two.

18 months ago[lldb] Explicitly import json in TestSymbolFileJSON.py
Jonas Devlieghere [Mon, 13 Mar 2023 21:39:10 +0000 (14:39 -0700)]
[lldb] Explicitly import json in TestSymbolFileJSON.py

The test was relying on the json module getting imported transitively by
one of its imported modules. Make this less brittle by importing it
explicitly.

18 months ago[SPIR-V] Promote arbitrary width ints to regular width
Michal Paszkowski [Mon, 13 Mar 2023 21:26:04 +0000 (22:26 +0100)]
[SPIR-V] Promote arbitrary width ints to regular width

After this patch all arbitrary size integers (smaller than 64 bits) in
LLVM IR will be promoted to regular size type in SPIR-V (OpTypeInt
8/16/32/64).

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

18 months ago[Propeller] Make decoding BBAddrMaps trace through relocations
Aiden Grossman [Sat, 25 Feb 2023 10:18:57 +0000 (10:18 +0000)]
[Propeller] Make decoding BBAddrMaps trace through relocations

Currently when using the LLVM tools (eg llvm-readobj, llvm-objdump) to
find information about basic block locations using the propeller tooling
in relocatable object files function addresses are not mapped properly
which causes problems. In llvm-readobj this means that incorrect
function names will be pulled. In llvm-objdum this means that most BBs
won't show up in the output if --symbolize-operands is used. This patch
changes the behavior of decodeBBAddrMap to trace through relocations
to get correct function addresses if it is going through a relocatable
object file. This fixes the behavior in both tools and also other
consumers of decodeBBAddrMap. Some helper functions have been added
in/refactoring done to aid in grabbing BB address map sections now that
in some cases both relocation and BB address map sections need to be
obtained at the same time.

Regression tests moved around/added.

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

18 months ago[libc] Fix policy CMP0116 warnings for cmake 3.20 or above.
Tue Ly [Mon, 13 Mar 2023 20:14:53 +0000 (16:14 -0400)]
[libc] Fix policy CMP0116 warnings for cmake 3.20 or above.

Warnings due to changes in behavior of cmake 3.20 or above.  See
https://cmake.org/cmake/latest/policy/CMP0116.html

Reviewed By: sivachandra

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

18 months ago[MSAN] Use TypeSize and related utilities [nfc-ish]
Philip Reames [Mon, 13 Mar 2023 20:55:24 +0000 (13:55 -0700)]
[MSAN] Use TypeSize and related utilities [nfc-ish]

This is part of prework for supporting scalable vector types.  This isn't NFC because it shifts the point of failure (i.e. which assert triggers first), but should be NFC for all non-scalable vector inputs.

18 months ago[clang][driver] accept maix32/maix64 gcc compat options
David Tenty [Wed, 8 Mar 2023 20:48:44 +0000 (15:48 -0500)]
[clang][driver] accept maix32/maix64 gcc compat options

GCC on AIX primarily uses the -maix32 and -maix64 to select the bitmode
to target. In order to be compatible with existing build configurations,
clang should accept these options as well. In this patch we implement
these options for AIX targets.

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

18 months ago[MSAN] Remove usage of FixedVectorType where trivial [nfc]
Philip Reames [Mon, 13 Mar 2023 20:05:53 +0000 (13:05 -0700)]
[MSAN] Remove usage of FixedVectorType where trivial [nfc]

This is a prepass on generalizing for scalable vectors; I'm just picking off the easy bits.

18 months agoRevert "[memprof] Record BuildIDs in the raw profile."
Snehasish Kumar [Mon, 13 Mar 2023 20:08:41 +0000 (20:08 +0000)]
Revert "[memprof] Record BuildIDs in the raw profile."

This reverts commit 287177a47a396ca6cc0bef7696108cdaa0c68e5f.

18 months ago[BOLT][NFC] Return instruction list from createInstrIncMemory
Amir Ayupov [Mon, 6 Feb 2023 22:03:40 +0000 (14:03 -0800)]
[BOLT][NFC] Return instruction list from createInstrIncMemory

Leverage move semantics for `std::vector`.

This also makes it consistent with `createInstrumentationSnippet`.

Reviewed By: Elvina

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

18 months ago[flang] Handle parent component in user function argument for special cases
Valentin Clement [Mon, 13 Mar 2023 13:08:20 +0000 (06:08 -0700)]
[flang] Handle parent component in user function argument for special cases

In some cases the argument is already handled by a fir.rebox operation. Just
adapat the type to match the parent component in that case.

Depends on D145928

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

18 months ago[LV][VPlan] Fix printing TripCount liveins. NFC
David Green [Mon, 13 Mar 2023 19:44:12 +0000 (19:44 +0000)]
[LV][VPlan] Fix printing TripCount liveins. NFC

The TripCount liveins would currently be printed as badref in the vplan as they
are not allocated slots in the VPSlotTracker. This patch allocates them a slot
and adds them to the printed Live-Ins. It also makes a minor adjustment to
printing of Live-ins to reduce the empty lines when multiple Live-ins are
present.

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

18 months ago[flang] Handle parent component in user function argument
Valentin Clement [Mon, 13 Mar 2023 19:29:43 +0000 (20:29 +0100)]
[flang] Handle parent component in user function argument

When the argument is a parent component the box needs to
be updated to reflect the correct type. Use `updateBoxForParentComponent`
to update the argument accordingly.

Depends on D145907

Reviewed By: PeteSteinfeld

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

18 months ago[AArchExpandPseudo] Preserve instruction debug number in expansions
Felipe de Azevedo Piovezan [Mon, 13 Mar 2023 14:44:13 +0000 (10:44 -0400)]
[AArchExpandPseudo] Preserve instruction debug number in expansions

This is an initial attempt at preserving debug information in the pseudo
instruction expansion of the AArch backend. In particular, we preserve
the instruction number required by the InstrRef implementation of live
debug values.

There are many other expansions that need to be considered, but the ones
addressed in this commit should be extremely common, as they handle most
arithmetic and logical instructions.

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

18 months ago[memprof] Record BuildIDs in the raw profile.
Snehasish Kumar [Tue, 28 Feb 2023 21:33:30 +0000 (21:33 +0000)]
[memprof] Record BuildIDs in the raw profile.

This patch adds support for recording BuildIds usng the sanitizer
ListOfModules API. We add another entry to the SegmentEntry struct and
change the memprof raw version.

Reviewed By: tejohnson

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

18 months agoRevert "[Libomptarget] Use freestanding stdint.h header for DeviceRTL"
Joseph Huber [Mon, 13 Mar 2023 19:16:13 +0000 (14:16 -0500)]
Revert "[Libomptarget] Use freestanding stdint.h header for DeviceRTL"

This patch breaks the handling of `printf` in the OpenMP library. Usiing
`-ffreestanding` prevents clang from emitting LLVM builtins, which we
use for OpenMP printing support. Shelve this until we have functioning
`printf` in the GPU `libc` and we can remove that code.

This reverts commit a92eaa3ebee6ff85549e8f1c50da4958dbbdcb30.

18 months ago[AArch64][SVE]: custom lower AVGFloor/AVGCeil.
Hassnaa Hamdi [Thu, 23 Feb 2023 16:13:16 +0000 (16:13 +0000)]
[AArch64][SVE]: custom lower AVGFloor/AVGCeil.

-Lower AVGFloor(A, B) to:
 SRL(A) + SRL(B) + (A&B)&1.
-Lower AVGCeil(A, B) to:
 SRL(A) + SRL(B) + (A|B)&1.

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

18 months ago[lldb] Fix lldb code for renaming of OpenCL AVC types.
Joshua Cranmer [Mon, 13 Mar 2023 18:53:55 +0000 (14:53 -0400)]
[lldb] Fix lldb code for renaming of OpenCL AVC types.

18 months ago[IRBuilder] Add utilities for materializing scalable values [nfc]
Philip Reames [Mon, 13 Mar 2023 18:39:00 +0000 (11:39 -0700)]
[IRBuilder] Add utilities for materializing scalable values [nfc]

These idioms already appear a number of places in code, and upcoming changes to the various sanitizers continue to need more instances of the same patterns.

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

18 months ago[BOLT][NFC] Improve performance of MCPlusBuilder::initAliases
Job Noorman [Fri, 10 Mar 2023 20:12:57 +0000 (12:12 -0800)]
[BOLT][NFC] Improve performance of MCPlusBuilder::initAliases

It was using a redundant iteration over super regs to build
SmallerAliasMap. Removing this results in exactly the same alias maps
and a noticeable performance gain on targets with a large number of
registers.

Just anecdotally: on my machine, processing a small AArch64 binary went
from 2.7s down to 80ms.

Reviewed By: Amir

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

18 months ago[docs] Add more complete documentation for -f[no]split-lto-unit
Teresa Johnson [Mon, 13 Mar 2023 16:21:01 +0000 (09:21 -0700)]
[docs] Add more complete documentation for -f[no]split-lto-unit

Option was added in D53891, and only has basic documentation added
later in 5168ddfac44206e94f7ddd484d1cf03dee320fa7. Add more extensive
documentation with links to related docs.

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

18 months ago[GVNHoist] add cast to unbreak windows build
Nick Desaulniers [Mon, 13 Mar 2023 18:22:25 +0000 (11:22 -0700)]
[GVNHoist] add cast to unbreak windows build

Follow up to
commit 831e99fee90e ("[GVNHoist] don't hoist callbr users into the callbr's block")

Looks like MSVC has trouble with llvm::is_contained. Unbreak the build.

Link: https://lab.llvm.org/buildbot/#/builders/127/builds/45021/steps/7/logs/stdio
Reviewed By: hans, kuhar

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

18 months ago[Clang][SPIR-V] Emit target extension types for OpenCL types on SPIR-V.
Joshua Cranmer [Mon, 13 Mar 2023 18:14:12 +0000 (14:14 -0400)]
[Clang][SPIR-V] Emit target extension types for OpenCL types on SPIR-V.

Reviewed By: Anastasia

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

18 months agoRefactor ObjectFilePlaceholder for sharing
Jeffrey Tan [Mon, 13 Mar 2023 16:42:11 +0000 (09:42 -0700)]
Refactor ObjectFilePlaceholder for sharing

This patch refactors PlaceholderObjectFile into ObjectFile plugin directory
so that we can reuse it for other cases like coredump debugging with NT_FILE
notes.

PlaceholderObjectFile is also renamed to ObjectFilePlaceholder to be consistent
with ObjectFile plugin naming convention.

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

18 months ago[RISCV] Extend SK_Broadcast costing to scalable vectors
Philip Reames [Mon, 13 Mar 2023 18:01:19 +0000 (11:01 -0700)]
[RISCV] Extend SK_Broadcast costing to scalable vectors

The existing scalable costing was just bad.  No LMUL cost, no i1 specific costing, etc..  We had updated the fixed cost model, but none of the code is actually fixed length specific.  Moving it down handles the scalable cases too.

18 months ago[mlir] Don't use -z,defs on sanitizer builds
Rahul Kayaith [Mon, 13 Mar 2023 16:42:25 +0000 (12:42 -0400)]
[mlir] Don't use -z,defs on sanitizer builds

This works around link errors when building the python bindings with
ASAN, since the ASAN run-time doesn't get linked into shared libraries.
The ASAN docs specficially call out -z,defs as a potential issue:
https://clang.llvm.org/docs/AddressSanitizer.html#usage

closes https://github.com/llvm/llvm-project/issues/60565

Reviewed By: stellaraccident, mehdi_amini

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

18 months ago[clang-tidy] Support readability-redundant-string-cstr.StringParameterFunctions option
Mike Crowe [Mon, 13 Mar 2023 17:38:34 +0000 (17:38 +0000)]
[clang-tidy] Support readability-redundant-string-cstr.StringParameterFunctions option

Add StringParameterFunctions option to allow the
readability-redundant-string-cstr check to work with library functions
such as fmt::format and spdlog::logger:info that are able to support
std::string arguments in addition to const char * ones.

Depends on D143342

Reviewed By: PiotrZSL

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

18 months ago[mlir][vector] Clarify OOB semantics for `gather` and `scatter`
Jakub Kuderski [Mon, 13 Mar 2023 17:58:11 +0000 (13:58 -0400)]
[mlir][vector] Clarify OOB semantics for `gather` and `scatter`

Reword the vector gather and scatter op description to make it
well-defined to have out-of-bounds indices when the corresponding mask
bits are false.

Update the code sample to avoid relying on C UB semantics to provide
informal semantics for vector.gather.

This change should be consistent with the existing interpretation of the
semantics in the codebase.

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

Reviewed By: dcaballe

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

18 months ago[lld] Use installed llvm_gtest in standalone builds
Michał Górny [Mon, 13 Mar 2023 17:22:31 +0000 (18:22 +0100)]
[lld] Use installed llvm_gtest in standalone builds

Use the installed llvm_gtest library instead of rebuilding it locally
when standalone builds are used.  This change is now required
as otherwise the build fails due to duplicate llvm_gtest target.
This is based on 82169103958583d3320b3a9a1e6542e8d32ef8da in clang.

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

18 months ago[SystemZ] NFC minor cleanup
Jonas Paulsson [Mon, 13 Mar 2023 17:52:09 +0000 (18:52 +0100)]
[SystemZ] NFC minor cleanup

Don't create local pointers to Subtarget in places in SystemZTargetLowering
as the class already has a Subtarget member.

Review: Ulrich Weigand

18 months ago[LinkerWrapper] Switch to add_clang_tool() macro
Evangelos Foutras [Mon, 13 Mar 2023 17:40:26 +0000 (12:40 -0500)]
[LinkerWrapper] Switch to add_clang_tool() macro

Summary:
This creates install-clang-linker-wrapper{,-stripped} targets which are
useful for Linux distro builds when using LLVM_DISTRIBUTION_COMPONENTS.

Fixes: https://bugs.archlinux.org/task/77814

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

18 months ago[Clang] Fix not including clangBasic in the dynamic build
Joseph Huber [Mon, 13 Mar 2023 17:38:04 +0000 (12:38 -0500)]
[Clang] Fix not including clangBasic in the dynamic build

Summary:
The previous patch only included the needed library if you had HSA and
CUDA installed. Fix that.

18 months ago[OpenMP] remove obsolete symbol defintions
Vadim Paretsky [Mon, 13 Mar 2023 17:11:12 +0000 (10:11 -0700)]
[OpenMP] remove obsolete symbol defintions

Some globals were used for enforcing certain linking rules in the Intel
OpenMP implementation's MSVC compatibility layer and are not applicable
to the LLVM implementation (kmp_import.cpp has already been removed from
the build).

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

18 months ago[Libomptarget] Use freestanding stdint.h header for DeviceRTL
Joseph Huber [Mon, 13 Mar 2023 17:18:58 +0000 (12:18 -0500)]
[Libomptarget] Use freestanding stdint.h header for DeviceRTL

The `stdint.h` header provides the standard types. Previously we used
`-nostdinc` and defined these ourselves. This patch switches to a
freestanding version which should work properly. Without
`-ffreestanding` the `stdint.h` header will include other libraries. But
in a freestanding environment it should work given the primitives.

Reviewed By: jdoerfert

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

18 months ago[Clang] Add --version and --help messages to amdgpu/nvptx-arch
Joseph Huber [Mon, 13 Mar 2023 15:07:36 +0000 (10:07 -0500)]
[Clang] Add --version and --help messages to amdgpu/nvptx-arch

Summray:
These clang tools should print some basic help and version messages so
they are less opaque.

Reviewed By: ye-luo

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

18 months ago[GVNHoist] don't hoist callbr users into the callbr's block
Nick Desaulniers [Mon, 13 Mar 2023 17:14:02 +0000 (10:14 -0700)]
[GVNHoist] don't hoist callbr users into the callbr's block

This isn't safe to do.

Link: https://github.com/llvm/llvm-project/issues/53562
Fixes: https://github.com/llvm/llvm-project/issues/61023

Reviewed By: efriedma, nikic

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

18 months ago[flang] Avoid ICE in case of subprogram name clash with runtime namespace.
Slava Zakharin [Thu, 9 Mar 2023 04:51:19 +0000 (20:51 -0800)]
[flang] Avoid ICE in case of subprogram name clash with runtime namespace.

This is related to llvm-project#61074.
In general, it is undefined behavior if user subprogram is declared
with a name that matches a name of function from any runtime library
that Flang is using (e.g. FortranRuntime, libm, etc.). With this change-set
we avoid ICE for invalid calls generated during math lowering by
type casing the function before the call. This happens when a user function
call is lowered before the math function call with the same name.
To detect the name clash in cases when the math function call is lowered
before the user function call we set fir.runtime attribute for the math
functions and check it when we lower the user function call.

The warnings are currently emitted only in debug compiler and
under llvm debug options. I think they should be reported
in the same way as regular Flang warnings.

Note that this change-set does not resolve issues with the conversion
passes that might introduce libm calls after the lowering.

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

18 months agoFix a small typo in a comment in MlitOptMain.cpp (NFC)
Mehdi Amini [Mon, 13 Mar 2023 17:15:07 +0000 (18:15 +0100)]
Fix a small typo in a comment in MlitOptMain.cpp (NFC)

18 months ago[mlir] Use splitBlock instread of createBlock in GenericAtomicRMWLowering.
Alexander Belyaev [Mon, 13 Mar 2023 07:35:21 +0000 (08:35 +0100)]
[mlir] Use splitBlock instread of createBlock in GenericAtomicRMWLowering.

When generic_atomic_rmw is inside of memref.alloca_scope, then the pattern would fail.

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

18 months ago[scudo] Reduce the times of holding MapAllocatorCache::Mutex (NFC)
Chia-hung Duan [Fri, 10 Mar 2023 17:01:21 +0000 (17:01 +0000)]
[scudo] Reduce the times of holding MapAllocatorCache::Mutex (NFC)

Also fix few lints

Reviewed By: cryptoad

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

18 months ago[RISCV] Fallback to scalable lowering costs for fixed length vectors
Philip Reames [Mon, 13 Mar 2023 17:01:25 +0000 (10:01 -0700)]
[RISCV] Fallback to scalable lowering costs for fixed length vectors

Fixed vector costs may be more precise, but the actual lowering will use scalable vectors if nothing better is available.  During review, we noticed a case where fixed vector reverse can be improved cost model wise, that will follow seperately.

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

18 months ago[SCEV] Apply loop guards against min/max for its arguments
Dmitry Makogon [Tue, 7 Mar 2023 08:22:31 +0000 (15:22 +0700)]
[SCEV] Apply loop guards against min/max for its arguments

This replaces several rewriting rules in ScalarEvolution::applyLoopGuards
that are applied to min/max expressions with the equivalent ones but
applied to its arguments.
So previously given we had a loop guard min(a, b) >= c,
the min expression would get rewritten as max(c, min(a, b)).
With such approach, we were unable to apply the rewrite if min operands
were zext for example (min(zext(a), zext(b))), however it's equivalent
to the expression zext(min(a, b)) for which we could apply the rewrite.

Now we'd rewrite the min operands also with these expressions:
a -> max(c, a) and
b -> max(c, b).
and this would allow us to apply the loop guard in this and similar cases:
min(zext(a), zext(b)) would get rewritten as min(zext(max(c, a)), zext(max(c, b)))
instead of just being skipped.

The list of added rules (omitting predicates signedness for simplicity):
1. Guard:     min(a, b) >= c
   Old rule:  min(a, b) -> max(c, min(a, b))
   New rules: a -> max(a, c) and b -> max(b, c)
2. Guard:     min(a, b) > c
   Old rule:  min(a, b) -> max(c + 1, min(a, b))
   New rules: a -> max(a, c + 1) and b -> max(b, c + 1)
3. Guard:     max(a, b) <= c
   Old rule:  max(a, b) -> min(c, max(a, b))
   New rules: a -> min(a, c) and b -> min(b, c)
4. Guard:     max(a, b) < c
   Old rule:  max(a, b) -> min(c - 1, max(a, b))
   New rules: a -> min(a, c - 1) and b -> min(b, c - 1)
The old rewrites still hold.

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

18 months ago[SCEV] Rename variables in applyLoopGuards (NFC)
Dmitry Makogon [Mon, 13 Mar 2023 15:55:32 +0000 (22:55 +0700)]
[SCEV] Rename variables in applyLoopGuards (NFC)

18 months ago[Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0
Ayal Zaks [Tue, 14 Feb 2023 09:56:21 +0000 (11:56 +0200)]
[Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0

Structs that contain global or local pointers can be passed as kernel
arguments starting OpenCL v2.0 with the introduction of shared virtual memory.

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

18 months ago[clang][AST] Improve diagnostic for `nullptr` constexpr function pointer call
Takuya Shimizu [Mon, 13 Mar 2023 16:53:12 +0000 (12:53 -0400)]
[clang][AST] Improve diagnostic for `nullptr` constexpr function pointer call

This patch improves diagnostic for clang constexpr evaluator by adding
a check for nullptr in function pointer call evaluations.

ex.
```
constexpr int foo(int (*bla)(void)) {
  return bla();
}

static_assert(foo(nullptr) == 1);
```

BEFORE this patch, clang generates the following diagnostic for the
code above:

```
<source>:5:15: error: static assertion expression is not an integral constant expression
static_assert(foo(nullptr) == 1);
              ^~~~~~~~~~~~~~~~~
<source>:2:10: note: subexpression not valid in a constant expression
  return bla();
         ^
<source>:5:15: note: in call to 'foo(nullptr)'
static_assert(foo(nullptr) == 1);
              ^
1 error generated.
```

AFTER this patch, subexpression not valid in a constant expression note
is replaced with 'bla' evaluates to a null function pointer.

Fixes https://github.com/llvm/llvm-project/issues/59872
Differential Revision: https://reviews.llvm.org/D145793

18 months agoRevert "Add a `skipRegion()` feature to the OpPrintingFlags for MLIR ASM printer"
Mehdi Amini [Mon, 13 Mar 2023 16:49:23 +0000 (17:49 +0100)]
Revert "Add a `skipRegion()` feature to the OpPrintingFlags for MLIR ASM printer"

This reverts commit 0fe16607a523af3d8978ad636134e4d3034e365c which wasn't ready
to land.

18 months agoRevert "[LowerTypeTests] Avoid creation of select constant expression"
Zequan Wu [Mon, 13 Mar 2023 16:45:42 +0000 (12:45 -0400)]
Revert "[LowerTypeTests] Avoid creation of select constant expression"

This reverts commit 0317147a2848547ec97d8e76782f7dc38267a21f.

It causes broken module error when building chromium media_unittests
PHI nodes not grouped at top of basic block!
%19 = phi ptr [ %16, %15 ], [ %18, %12 ], !dbg !16
label %17
LLVM ERROR: Broken module found, compilation aborted!

18 months ago[AArch64] Don't #define __ARM_FP when there's no FPU.
Simon Tatham [Mon, 13 Mar 2023 16:28:38 +0000 (16:28 +0000)]
[AArch64] Don't #define __ARM_FP when there's no FPU.

On some R-profile CPUs, leaving out the FPU is an option. Clang will
accept `-march=armv8-r+nofp`, but it's currently not possible to find
out via the preprocessor whether it's in that mode (e.g. to change or
disable inline asm statements in your code).

The __ARM_FP macro, which has a bit set for each size of floating
point number supported by the hardware, is the natural thing to test.
But Clang was defining it unconditionally on AArch64. Now it checks
for FP support before defining it at all.

Reviewed By: tmatheson, DavidSpickett

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

18 months ago[BPF] Improve pruning to avoid generate more types in BTF
Yonghong Song [Fri, 10 Mar 2023 07:55:16 +0000 (23:55 -0800)]
[BPF] Improve pruning to avoid generate more types in BTF

Commit 3671bdbcd214("[BPF] Fix a BTF type pruning bug") fixed a
pruning bug to allow generate more types. But the commit has a bug
which permits to generate more types than necessary. The following
is an example to illustrate the problem.

   struct t1 {
     int a;
   };
   struct t2 {
     struct t1 *p1;
     struct t1 *p2;
     int b;
   };
   int foo(struct t2 *arg) {
     return arg->b;
   }

The following is the part of BTF generation sequence:
  (1). 'struct t2 *arg' -> 'struct t1 *p1'
       In this step, the type 'struct t1' will be generated as
       a forward decl and the ptr type (to 'struct t1') will
       be stored in the internal type table.
  (2). now the second field 'struct t1 *p2' will be processed.
       Since the ptr type (to 'struct t1') already in the type
       table, the existing logic strips out ptr modifier and
       is able to generate BTF type for 'struct t1'.

In the above step (2), if CheckPointer is true (the type traversal
chain including a struct member), 'ptr' modifier should be checked
and the subsequent type generation should be skipped since
the same case has been processed in visitDerivedType().

The issue is exposed when I am trying to use llvm15 to compile
some internal bpf programs. The bpf skeleton put the whole
ELF section (after striping some sections like dwarf) as a string.
The large BTF section triggered the following error:

  bpf_object_with_struct_ops_test_prog_bpf/BpfObjectWithStructOpsTestProg.skel.h:222:23:
  error: string literal of length 140144 exceeds maximum length 65536 that C++ compilers
  are required to support [-Werror,-Woverlength-strings]
        return (const void *)"\
                             ^~
  1 error generated.

Although adding -Wno-overlength-strings could workaround the issue,
improving llvm BTF generation sounds better esp. for users using vmlinux.h.

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

18 months ago[PassManagerBuilder] Remove PassManagerBuilder
Arthur Eubanks [Sat, 11 Mar 2023 01:24:19 +0000 (17:24 -0800)]
[PassManagerBuilder] Remove PassManagerBuilder

PassManagerBuilder is dead, long live PassBuilder!

bugpoint's -O# are now useless (and probably have been for a while given the number of passes we've removed from PassManagerBuilder). Perhaps they'll be revived if bugpoint ever works with the new PM.

Reviewed By: nikic, MaskRay

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

18 months agoMSVC: support version preference with search
Saleem Abdulrasool [Tue, 7 Mar 2023 18:10:31 +0000 (10:10 -0800)]
MSVC: support version preference with search

Extend the logic for the WinSDK and UCRT handling to prefer a user
specified version of the VisualC++ tools and Windows SDK.  This allows
us to now perform the regular search for the installation but select the
exact version of the SDK or VC++ tools to override the latest version.
Similar to the other flags controlling this behaviour, if the user
specifies a value, we will not perform validation on the input and will
attempt to prefer that, particularly in the case of VisualC++ tools
where no fallback occurs.

Reviewed by: hans
Differential Revision: https://reviews.llvm.org/D145517

18 months ago[ADT] Implement {DenseMap,MapVector,StringMap}::contains
Kazu Hirata [Mon, 13 Mar 2023 16:13:28 +0000 (09:13 -0700)]
[ADT] Implement {DenseMap,MapVector,StringMap}::contains

This patch implements the C++20-style contains() for DenseMap,
MapVector, and StringMap.

With this patch, every set and map container type that has count()
also has contains().

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

18 months ago[third-party] Respect LLVM_INSTALL_GTEST for llvm_gtest_main
Michał Górny [Mon, 13 Mar 2023 15:37:10 +0000 (16:37 +0100)]
[third-party] Respect LLVM_INSTALL_GTEST for llvm_gtest_main

Pass BUILDTREE_ONLY to llvm_gtest_main only if LLVM_INSTALL_GTEST
is not set.  This fixes 0807986303f5d498cee32d42c242940d00617ad9.
Otherwise, llvm_gtest_main cannot be used
in LLVM_DISTRIBUTION_COMPONENTS, effectively making it impossible
to install llvm_gtest correctly.

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

18 months ago[flang][nfc] Avoid generating external-hello-world by default
Shao-Ce SUN [Mon, 13 Mar 2023 15:44:36 +0000 (23:44 +0800)]
[flang][nfc] Avoid generating external-hello-world by default

The current setting is not working.
When compiling `flang`, the `external-hello-world` is still compiled by default.

Reviewed By: luporl

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

18 months ago[X86] Use llvm::Align for passing the alignment
Phoebe Wang [Mon, 13 Mar 2023 15:32:46 +0000 (23:32 +0800)]
[X86] Use llvm::Align for passing the alignment

This should be a typo in `emitConstantSizeRepmov`. Both its caller and
callee store the alignment in a 64-bit variables, no reason to truncate
it to 32-bit. It results in alignment turns into 0 when larger than
0x100000000.

Fixes #61348

Reviewed By: RKSimon

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

18 months ago[gn build] Port 383cfeee09d1
LLVM GN Syncbot [Mon, 13 Mar 2023 15:57:29 +0000 (15:57 +0000)]
[gn build] Port 383cfeee09d1

18 months ago[RISCV] Inline and delete RISCVTTIImpl::getSpliceCost [nfc]
Philip Reames [Mon, 13 Mar 2023 15:54:44 +0000 (08:54 -0700)]
[RISCV] Inline and delete RISCVTTIImpl::getSpliceCost [nfc]

The code structure was copied from AArch64 which has a much more complicated splice cost model.

18 months agoFix typo: statment to statement; NFC
HerrCai0907 [Mon, 13 Mar 2023 15:50:43 +0000 (11:50 -0400)]
Fix typo: statment to statement; NFC

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

18 months agoFix test dialect to avoid using an unregistered dialect
Mehdi Amini [Mon, 13 Mar 2023 15:37:21 +0000 (16:37 +0100)]
Fix test dialect to avoid using an unregistered dialect

Fixes #61374

18 months agoAdd a `skipRegion()` feature to the OpPrintingFlags for MLIR ASM printer
Mehdi Amini [Sun, 12 Mar 2023 22:44:21 +0000 (23:44 +0100)]
Add a `skipRegion()` feature to the OpPrintingFlags for MLIR ASM printer

This is a convenient flag for context where we intend to summarize a top-level
operation without the full-blown regions it may hold.

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

18 months ago[clang][pp] Handle attributes defined by plugin in __has_attribute
Anders Waldenborg [Sun, 12 Feb 2023 21:12:08 +0000 (22:12 +0100)]
[clang][pp] Handle attributes defined by plugin in __has_attribute

When using attributes by plugins (both in clang and clang-tidy) the
preprocessor functions `__has_attribute`, `__has_c_attribute`,
`__has_cpp_attribute` still returned 0.

That problem is fixed by having the "hasAttribute" function also check
if any of the plugins provide that attribute.

This also adds C2x spelling to the example plugin for attributes so that
`__has_c_attribute` can be tested.

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

18 months ago[clang] Extract function for generated part of clang::hasAttribute (NFC)
Anders Waldenborg [Thu, 2 Feb 2023 21:10:20 +0000 (22:10 +0100)]
[clang] Extract function for generated part of clang::hasAttribute (NFC)

This makes it easier to add additional handling when the
tablegen-generated code does not find a match.

No functional change intended.

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

18 months ago[clang] Extract ParsedAttrInfo::hasSpelling method (NFC)
Anders Waldenborg [Thu, 9 Mar 2023 21:55:38 +0000 (22:55 +0100)]
[clang] Extract ParsedAttrInfo::hasSpelling method (NFC)

This intends to simplify this checking when it is done in more places.

No functional change intended.

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

18 months ago[clang] Extract attribute plugin instantiation to function (NFC)
Anders Waldenborg [Sun, 12 Feb 2023 19:44:30 +0000 (20:44 +0100)]
[clang] Extract attribute plugin instantiation to function (NFC)

This moves the code to instantiate the attribute plugins to the same
place where the plugin registry is defined so they live together and the
user of the plugins doesn't have the burden of instantiating the
plugins.

No functional change intended.

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

18 months ago[clang] Move ParsedAttrInfo from Sema to Basic (NFC)
Anders Waldenborg [Sun, 12 Feb 2023 18:33:22 +0000 (19:33 +0100)]
[clang] Move ParsedAttrInfo from Sema to Basic (NFC)

This moves the ParsedAttrInfo class and the registry for attribute
plugin to be part of Basic module instead of Sema module.

This will allow it to be accessed from preprocessor later on.

No functional change intended.

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

18 months ago[RISCV] Use switch in RISCVTargetTransformInfo::getShuffleCost [nfc]
Philip Reames [Mon, 13 Mar 2023 15:32:16 +0000 (08:32 -0700)]
[RISCV] Use switch in RISCVTargetTransformInfo::getShuffleCost [nfc]

Refactoring in advance of a semantic change.

18 months ago[libc][NFC] Add string.h header to various platform headers.txt.
Siva Chandra Reddy [Mon, 13 Mar 2023 15:34:58 +0000 (15:34 +0000)]
[libc][NFC] Add string.h header to various platform headers.txt.

18 months agoReland [RISCV] Fix gaps in IgnoreUnknown=true for RISCVISAInfo::parseArchString
Alex Bradbury [Mon, 13 Mar 2023 15:14:43 +0000 (15:14 +0000)]
Reland [RISCV] Fix gaps in IgnoreUnknown=true for RISCVISAInfo::parseArchString

Prior to this patch, unrecognised z/s/sx/x prefixed extensions were not
ignored when IgnoreUnknown=true.

The first version of this patch, a7313f83b9ca9, incorrectly used
`!isSupportedExtension(Ext)` rather than `!isSupportedExtension(Name)`.
i.e. checked the full substring rather than the split out name, causing
incorrect behaviour when a version is specified. This was fixed and a
new test case addded.

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

18 months ago[AArch64] Cost-model vector splat LD1Rs to avoid unprofitable SLP vectorisation
Sjoerd Meijer [Mon, 13 Mar 2023 13:05:34 +0000 (13:05 +0000)]
[AArch64] Cost-model vector splat LD1Rs to avoid unprofitable SLP vectorisation

This slightly increases the costs of InsertElement instructions that are part
of a vector splat sequence, i.e. a load, InsertElement and a shuffle (load +
dup). The resulting LD1R is a high latency instruction, and this slight
increase in costs avoids SLP vectorisation for a couple of cases where this
isn't profitable.

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

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

18 months ago[flang] Handle parent component in intrinsic function arguments
Valentin Clement [Mon, 13 Mar 2023 14:27:02 +0000 (15:27 +0100)]
[flang] Handle parent component in intrinsic function arguments

When the argument is a parent component the box needs to
be updated to reflect the correct type. Use `updateBoxForParentComponent`
to update the argument accordingly.

Reviewed By: PeteSteinfeld

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

18 months ago[flang] Only check for embox/rebox if defining op is present
Valentin Clement [Mon, 13 Mar 2023 14:25:30 +0000 (15:25 +0100)]
[flang] Only check for embox/rebox if defining op is present

When the base box is a block argument, the defining op is null.
Only try to recover embox/rebox if there is a defining op.

Reviewed By: PeteSteinfeld

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

18 months ago[libc++] Add missing include in exception_ptr.h
Hans Wennborg [Mon, 13 Mar 2023 10:24:29 +0000 (11:24 +0100)]
[libc++] Add missing include in exception_ptr.h

Windows builds were failing due to missing include for std::addressof
after D145095.

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

18 months ago[clang] Replace Member Expressions During Instantiation If Necessary
Liming Liu [Tue, 7 Mar 2023 13:08:57 +0000 (21:08 +0800)]
[clang] Replace Member Expressions During Instantiation If Necessary

This patch replaces member accesses to declaration references during template
instantiation if the context is the unevaluated context and the class does not
contain the declaration.

The replacement fixes the issue #58674. Unlike previous fixes such as D143840,
it checks the membership during instantiation rather than right after parsing,
so the check is more accurate and efficient.

This patch also includes cases that previous fixes had once failed on.

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

18 months agoFix include order in CXType.cpp
Collin Baker [Mon, 13 Mar 2023 14:11:05 +0000 (10:11 -0400)]
Fix include order in CXType.cpp

Handle template parameter-dependent bit field widths in libclang

In a class template, a bit field's width may depend on a template
parameter. In this case the width expression cannot be evaluated.

Previously clang_getFieldDeclBitWidth() would assert, or cause memory
unsafety and return an invalid result if assertions are disabled.

This adds a check for this case which returns an error code. An
additional function clang_isBitFieldDecl() is added to disambiguate
between error code meanings.

Fixes: https://github.com/llvm/llvm-project/issues/56644
Differential Revision: https://reviews.llvm.org/D130303

18 months agoRevert "[clangd] Move standard options adaptor to CommandMangler"
Dmitry Polukhin [Mon, 13 Mar 2023 14:00:56 +0000 (07:00 -0700)]
Revert "[clangd] Move standard options adaptor to CommandMangler"

This reverts commit 34de7da6246cdfa6ff6f3d3c514583cddc0a10ec.

18 months ago[DAG] Use ISD::isBitwiseLogicOp in AND/OR/XOR checks. NFCI.
Simon Pilgrim [Mon, 13 Mar 2023 13:38:55 +0000 (13:38 +0000)]
[DAG] Use ISD::isBitwiseLogicOp in AND/OR/XOR checks. NFCI.

There's additional cases we can cleanup (mainly in target code), but this tries to cleanup generic code and PPC which had an equivalent helper.

18 months ago[MachineCombiner] Preserve debug instruction number
Felipe de Azevedo Piovezan [Fri, 10 Mar 2023 03:22:50 +0000 (22:22 -0500)]
[MachineCombiner] Preserve debug instruction number

Each target's `TargetInstrInfo` is responsible for announcing which code
patterns it is able to transform during the MachineCombiner pass.
Currently, these patterns are applied without preserving the debug
instruction number required by the InstrRef implementation of
LiveDebugValues. As such, we've seen a number of examples where debug
information is dropped for variables in InstrRef mode that were
otherwise available in VarLoc mode. This has been observed both in X86
and AArch examples.

This commit is an initial attempt at preserving said numbers by changing
the general (target agnostic) implementation of TargetInstrInfo: the
reassociation pattern must keep the debug number of the "top level"
instruction, i.e., the instruction whose value represents the final
value of the arithmetic expression. Intermediate values must have their
debug number dropped, as they have no equivalent value in the
unoptimized code.

Future work is required to update each target's
`TargetInstrInfo::genAlternativeCodeSequence` method.

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