platform/upstream/llvm.git
2 years ago[DebugInfo][InstrRef] Fix error in copy handling in InstrRefLDV
Stephen Tozer [Mon, 20 Jun 2022 09:41:15 +0000 (10:41 +0100)]
[DebugInfo][InstrRef] Fix error in copy handling in InstrRefLDV

Currently, an error exists when InstrRefBasedLDV observes transfers of
variables across copies, which causes it to lose track of variables
under certain circumstances, resulting in shorter lifetimes for those
variables as LDV gives up searching for live locations for them. This
patch fixes this issue by storing the currently tracked values in
the destination first, then updating them manually later without
clobbering or assigning them the wrong value.

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

2 years ago[SystemZ][z/OS] Force alignment to fix build failure on z/OS
Abhina Sreeskantharajan [Mon, 11 Jul 2022 12:28:47 +0000 (08:28 -0400)]
[SystemZ][z/OS] Force alignment to fix build failure on z/OS

The following commit https://reviews.llvm.org/D125998 added a static_assert which was triggered on z/OS because bitfields are always aligned to 1 regardless of type.

```
error: static_assert failed due to requirement 'alignof(llvm::SmallVector<llvm::MDOperand, 0>) <= alignof(llvm::MDNode::Header)' "LargeStorageVector too strongly aligned"
```

The solution was to force the alignment to be size_t.

Reviewed By: wolfgangp

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

2 years ago[ARM] Expand MVE i1 fptoint and inttofp if mve.fp is not present.
David Green [Mon, 11 Jul 2022 12:03:30 +0000 (13:03 +0100)]
[ARM] Expand MVE i1 fptoint and inttofp if mve.fp is not present.

If MVE.fp is not present then we cannot select the vector i1 fp
operations to VCMP instructions, so need to expand.

2 years ago[MLIR][Presburger] introduce MPInt to support fast arbitrary precision in Presburger
Arjun P [Mon, 11 Jul 2022 10:34:10 +0000 (11:34 +0100)]
[MLIR][Presburger] introduce MPInt to support fast arbitrary precision in Presburger

This uses an int64_t-based fastpath for the common case and falls back to
SlowMPInt to handle the rare cases where larger numbers occur.
It uses `__builtin_*` for performance through the support in LLVM MathExtras.

Using this in the Presburger library results in a minor performance
*improvement* over any commit hash before sequence of patches
starting at d5e31cf38adfc2c240fb9717989792537cc9e819.

Reviewed By: Groverkss, ftynse

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

2 years ago[clangd] Include "final" when printing class declaration
Tom Praschan [Mon, 11 Jul 2022 10:20:15 +0000 (12:20 +0200)]
[clangd] Include "final" when printing class declaration

Fixes https://github.com/clangd/clangd/issues/1184

Reviewed By: sammccall

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

2 years agoGo-to-type on smart_ptr<Foo> now also shows Foo
Tom Praschan [Mon, 11 Jul 2022 10:13:35 +0000 (12:13 +0200)]
Go-to-type on smart_ptr<Foo> now also shows Foo

Fixes clangd/clangd#1026

Reviewed By: sammccall

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

2 years ago[LoopVectorize][NFC] Add optional Name parameter to VPInstruction
David Sherwood [Fri, 1 Jul 2022 09:19:45 +0000 (10:19 +0100)]
[LoopVectorize][NFC] Add optional Name parameter to VPInstruction

This patch is a simple piece of refactoring that now permits users
to create VPInstructions and specify the name of the value being
generated. This is useful for creating more readable/meaningful
names in IR.

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

2 years ago[lld-macho] Fix compact unwind output for 32 bit builds
David Spickett [Fri, 8 Jul 2022 11:32:44 +0000 (11:32 +0000)]
[lld-macho] Fix compact unwind output for 32 bit builds

This test was failing on our 32 bit build bot:
https://lab.llvm.org/buildbot/#/builders/178/builds/2463

This happened because in UnwindInfoSectionImpl::finalize
a decision is made whether to write out regular or compressed
unwind info.

One check in this does:
```
if (cuPtr->functionAddress >= functionAddressMax) {
        break;
```

Where cuPtr->functionAddress was uint64_t and functionAddressMax
was uintptr_t, which is 4 bytes on a 32 bit system.

Using uint64_t for functionAddressMax fixes this problem.
Presumably because at only 4 bytes, the max is much lower than
we expect. We're targetting 64 bit though so the size of the max
should match the size of the addresses.

Reviewed By: #lld-macho, int3

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

2 years ago[AArch64] Guard FP16 fptosi_sat patterns with HasFullFP16. NFC
David Green [Mon, 11 Jul 2022 07:35:40 +0000 (08:35 +0100)]
[AArch64] Guard FP16 fptosi_sat patterns with HasFullFP16. NFC

We shouldn't get this far as the operations are already legalized, but
the patterns should be guarded with hasFullFP16.

2 years ago[libc][NFC] Make thread_detach_test an integration test.
Siva Chandra Reddy [Mon, 11 Jul 2022 06:37:36 +0000 (06:37 +0000)]
[libc][NFC] Make thread_detach_test an integration test.

This is simple switch from a unittest to an integration test. It is
being done as a preparatory step to adding TLS support to thread
creation. TLS setup and initialization is tightly coupled with the
loader and hence all thread related tests should be integration tests.

2 years ago[lldb/test] Use SIGINT as the "stopping" signal
Pavel Labath [Mon, 11 Jul 2022 06:37:58 +0000 (08:37 +0200)]
[lldb/test] Use SIGINT as the "stopping" signal

Using SIGSTOP means that if anything goes wrong in the test, the process
can end up in the stopped state, where it is not running, but still
taking up resources. Eventually, these "zombies" can make the machine
completely unusable. Instead, use a signal whose default action is to
kill the processes.

2 years ago[RISCV] Optimize 2x SELECT for floating-point types
LiaoChunyu [Sat, 9 Jul 2022 00:37:05 +0000 (08:37 +0800)]
[RISCV] Optimize 2x SELECT for floating-point types

Including the following opcode:
 Select_FPR16_Using_CC_GPR
 Select_FPR32_Using_CC_GPR
 Select_FPR64_Using_CC_GPR

Reviewed By: craig.topper

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

2 years ago[gn build] Port 96b674f23cd6
LLVM GN Syncbot [Mon, 11 Jul 2022 06:02:59 +0000 (06:02 +0000)]
[gn build] Port 96b674f23cd6

2 years ago[libc++][ranges] implement `std::ranges::set_intersection`
Hui Xie [Fri, 8 Jul 2022 14:21:40 +0000 (15:21 +0100)]
[libc++][ranges] implement `std::ranges::set_intersection`

implement `std::ranges::set_intersection` by reusing the classic `std::set_intersenction`
added unit tests

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

2 years ago[DWARFLinker] Remove unused declaration copyAbbrev (NFC)
Kazu Hirata [Mon, 11 Jul 2022 05:10:23 +0000 (22:10 -0700)]
[DWARFLinker] Remove unused declaration copyAbbrev (NFC)

The corresponding definition was removed on Apr 26, 2021 in commit
233c24330b8e253c4a22053fb405cffb6da769d9.

2 years ago[libc] Linux threads - Set CLEAR_TID addr to 0 when exiting a detached thread.
Siva Chandra Reddy [Sun, 10 Jul 2022 09:48:23 +0000 (09:48 +0000)]
[libc] Linux threads - Set CLEAR_TID addr to 0 when exiting a detached thread.

A detached thread cleans itself up at completion. So, the CLEAR_TID memory is
also gone by the time the kernel tries to signal potential waiters. By nulling
the CLEAR_TID address, we prevent the kernel from signalling at a non-existent
futex location.

2 years ago[mlir] Flip accessors to prefixed form (NFC)
Jacques Pienaar [Mon, 11 Jul 2022 04:19:11 +0000 (21:19 -0700)]
[mlir] Flip accessors to prefixed form (NFC)

Another mechanical sweep to keep diff small for flip to _Prefixed.

2 years ago[GlobalISel] Remove unused declaration fewerElementsVectorSextInReg (NFC)
Kazu Hirata [Mon, 11 Jul 2022 03:41:02 +0000 (20:41 -0700)]
[GlobalISel] Remove unused declaration fewerElementsVectorSextInReg (NFC)

The corresponding definition was removed on Dec 23, 2021 in commit
29f88b93fdbe3e20c35842ca3a6c2a3f1a81cfce.

2 years ago[RISCV] Increase complexity of RVV element extraction patterns
Pengcheng Wang [Mon, 11 Jul 2022 02:51:34 +0000 (10:51 +0800)]
[RISCV] Increase complexity of RVV element extraction patterns

Somehow some tests failed in our downstream because it matched
VFMV+FSD pattern first. Both FSD and VSE patterns have the same
complexity, while FSD is matched before VSE in the generated
matcher table.

This problem only occurs in our downstream (so sorry that I can't
provide a test here) and increasing the value of `AddedComplexity`
can fix it.

Reviewed By: StephenFan, craig.topper

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

2 years ago[AIX][compiler-rt] Fix missing dependency of parent target
Kai Luo [Mon, 11 Jul 2022 02:47:56 +0000 (10:47 +0800)]
[AIX][compiler-rt] Fix missing dependency of parent target

`add_dependencies(${LIB_PARENT_TARGET} aix-${libname})` should only happen when `aix-${libname}` is added.

Reviewed By: hubert.reinterpretcast

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

2 years ago[mlir][Math] Support fold Log2Op with constant dense.
jacquesguan [Thu, 7 Jul 2022 06:17:50 +0000 (14:17 +0800)]
[mlir][Math] Support fold Log2Op with constant dense.

This patch is similar to D129108, it adds a conditional unary constant folder which allow to exit when the constants not meet the fold condition. And use it for Log2Op to make it able to fold the constant dense.

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

2 years ago[CodeGen] Remove unused member variable NextCascade (NFC)
Kazu Hirata [Mon, 11 Jul 2022 01:57:40 +0000 (18:57 -0700)]
[CodeGen] Remove unused member variable NextCascade (NFC)

2 years ago[lldb] Delete more mydir references (NFC)
Dave Lee [Sat, 25 Jun 2022 15:45:48 +0000 (08:45 -0700)]
[lldb] Delete more mydir references (NFC)

2 years ago[LV] Move VPWidenGEPRecipe::execute to VPlanRecipes.cpp (NFC).
Florian Hahn [Mon, 11 Jul 2022 00:10:17 +0000 (17:10 -0700)]
[LV] Move VPWidenGEPRecipe::execute to VPlanRecipes.cpp (NFC).

2 years ago[flang] Don't use Optional::hasValue (NFC)
Kazu Hirata [Sun, 10 Jul 2022 22:01:06 +0000 (15:01 -0700)]
[flang] Don't use Optional::hasValue (NFC)

Flang C++ Style Guide tells us to avoid .has_value() in the predicate
expressions of control flow statements.  I am treating ternary
expressions as control flow statements for the purpose of this patch.

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

2 years ago[SelectionDAG] Restore calls to has_value (NFC)
Kazu Hirata [Sun, 10 Jul 2022 21:37:23 +0000 (14:37 -0700)]
[SelectionDAG] Restore calls to has_value (NFC)

This patch restores calls to has_value to make it clear that we are
checking the presence of an optional value, not the underlying value.

This patch partially reverts d08f34b592ff06ccb1f36da88ec09aa926427a4d.

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

2 years ago[RISCV] Teach shouldConvertConstantLoadToIntImm that constant materialization can...
Craig Topper [Sun, 10 Jul 2022 21:09:14 +0000 (14:09 -0700)]
[RISCV] Teach shouldConvertConstantLoadToIntImm that constant materialization can use constant pools.

I think it only makes sense to return true here if we aren't going
to turn around and create a constant pool for the immmediate.

I left out the check for useConstantPoolForLargeInts() thinking
that even if you don't want the commpiler to create a constant pool
you might still want to avoid materializing an integer that is
already available in a global variable.

Test file was copied from AArch64/ARM and has not been commited yet.
Will post separate review for that.

Reviewed By: luismarques

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

2 years ago[RISCV] Add test cases for inline memcpy expansion
Craig Topper [Sun, 10 Jul 2022 21:09:00 +0000 (14:09 -0700)]
[RISCV] Add test cases for inline memcpy expansion

Test file was taken directly from AArch64/ARM. I've added RUN
lines for aligned and unaligned since many of the test cases
are strings that aren't aligned and have an odd size.

Some of these test cases are modified by D129402.

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

2 years ago[InterleaveAccessPass] Handle multi-use binop shuffles
David Green [Sun, 10 Jul 2022 16:24:37 +0000 (17:24 +0100)]
[InterleaveAccessPass] Handle multi-use binop shuffles

D89489 added some logic to the interleaved access pass to attempt to
undo the folding of shuffles into binops, that instcombine performs. If
early-cse is run too, the binops may be commoned into a single operation
with multiple shuffle uses. It is still profitable reverse the transform
though, so long as all the uses are shuffles.

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

2 years ago[libc++][format] Use forwarding references.
Mark de Wever [Tue, 5 Oct 2021 17:25:37 +0000 (19:25 +0200)]
[libc++][format] Use forwarding references.

This implements a not accepted LWG issue. Not doing so would require
integral types to use the handle class instead of being directly stored
in the basic_format_arg.

The previous code used `std::forward` in places where it wasn't required
by the Standard. These are now removed.

Implements:
- P2418R2 Add support for std::generator-like types to std::format
- LWG 3631 basic_format_arg(T&&) should use remove_cvref_t<T> throughout

Reviewed By: ldionne, #libc

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

2 years agoManagedStatic: remove from GDBRegistrationListener
Nicolai Hähnle [Sun, 10 Jul 2022 08:25:20 +0000 (10:25 +0200)]
ManagedStatic: remove from GDBRegistrationListener

An earlier version of this change originally landed as part of
e6f1f062457c928c18a88c612f39d9e168f65a85 (D129120), which caused a
Fuchsia buildbot regression in ExecutionEngine tests.

Careful review suggests that the issue was that in the earlier version,
the destructor of the JITDebugLock was run before the destructor of
GDBJITRegistrationListener. The new version of the change moves the lock
to a member variable of the (singleton!) GDBJITRegistartionListener so
that destructors are run in the right order.

2 years ago[libc++][NFC] Update #ifdef comments.
Mark de Wever [Sun, 10 Jul 2022 12:08:35 +0000 (14:08 +0200)]
[libc++][NFC] Update #ifdef comments.

These review comments weren't addressed in D129056.

2 years ago[C++20][Modules] Implement include translation.
Iain Sandoe [Fri, 1 Jul 2022 10:36:19 +0000 (11:36 +0100)]
[C++20][Modules] Implement include translation.

This addresses [cpp.include]/7

(when encountering #include header-name)

If the header identified by the header-name denotes an importable header, it
is implementation-defined whether the #include preprocessing directive is
instead replaced by an import directive.

In this implementation, include translation is performed _only_ for headers
in the Global Module fragment, so:
```
module;
 #include "will-be-translated.h" // IFF the header unit is available.

export module M;
 #include "will-not-be-translated.h" // even if the header unit is available
```
The reasoning is that, in general, includes in the module purview would not
be validly translatable (they would have to immediately follow the module
decl and without any other intervening decls).  Otherwise that would violate
the rules on contiguous import directives.

This would be quite complex to track in the preprocessor, and for relatively
little gain (the user can 'import "will-not-be-translated.h";' instead.)

TODO: This is one area where it becomes increasingly difficult to disambiguate
clang modules in C++ from C++ standard modules.  That needs to be addressed in
both the driver and the FE.

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

2 years ago[libc++] Don't call key_eq in unordered_map/set rehashing routine
Ivan Trofimov [Sun, 10 Jul 2022 09:41:02 +0000 (11:41 +0200)]
[libc++] Don't call key_eq in unordered_map/set rehashing routine

As of now containers key_eq might get called when rehashing happens, which is redundant for unique keys containers.

Reviewed By: #libc, philnik, Mordante

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

2 years agoR600ISelLowering.h: Silence a warning. [-Warray-parameter]
NAKAMURA Takumi [Sun, 10 Jul 2022 09:23:02 +0000 (18:23 +0900)]
R600ISelLowering.h: Silence a warning. [-Warray-parameter]

FIXME: Could it be rewritten with llvm::ArrayRef ?

2 years agoManagedStatic: remove from PerfJITEventListener
Nicolai Hähnle [Sun, 10 Jul 2022 08:19:27 +0000 (10:19 +0200)]
ManagedStatic: remove from PerfJITEventListener

This change originally landed as part of
e6f1f062457c928c18a88c612f39d9e168f65a85 (D129120), which caused a
Fuchsia buildbot regression in ExecutionEngine tests.

I am resubmitting the backed out parts in smaller pieces after a careful
review.

2 years agoManagedStatic: Remove from JITLoaderGDB
Nicolai Hähnle [Sun, 10 Jul 2022 08:15:52 +0000 (10:15 +0200)]
ManagedStatic: Remove from JITLoaderGDB

This change originally landed as part of
e6f1f062457c928c18a88c612f39d9e168f65a85 (D129120), which caused a
Fuchsia buildbot regression in ExecutionEngine tests.

I am resubmitting the backed out parts in smaller pieces after a careful
review.

2 years agoManagedStatic: remove many straightforward uses in llvm
Nicolai Hähnle [Wed, 29 Jun 2022 12:29:33 +0000 (14:29 +0200)]
ManagedStatic: remove many straightforward uses in llvm

(Reapply after revert in e9ce1a588030d8d4004f5d7e443afe46245e9a92 due to
Fuchsia test failures. Removed changes in lib/ExecutionEngine/ other
than error categories, to be checked in more detail and reapplied
separately.)

Bulk remove many of the more trivial uses of ManagedStatic in the llvm
directory, either by defining a new getter function or, in many cases,
moving the static variable directly into the only function that uses it.

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

2 years agoRevert "ManagedStatic: remove many straightforward uses in llvm"
Nicolai Hähnle [Sun, 10 Jul 2022 07:54:30 +0000 (09:54 +0200)]
Revert "ManagedStatic: remove many straightforward uses in llvm"

This reverts commit e6f1f062457c928c18a88c612f39d9e168f65a85.

Reverting due to a failure on the fuchsia-x86_64-linux buildbot.

2 years agoManagedStatic: remove many straightforward uses in llvm
Nicolai Hähnle [Wed, 29 Jun 2022 12:29:33 +0000 (14:29 +0200)]
ManagedStatic: remove many straightforward uses in llvm

Bulk remove many of the more trivial uses of ManagedStatic in the llvm
directory, either by defining a new getter function or, in many cases,
moving the static variable directly into the only function that uses it.

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

2 years ago[clang] Enforce instantiation of constexpr template functions during non-constexpr...
serge-sans-paille [Sat, 18 Jun 2022 11:48:41 +0000 (13:48 +0200)]
[clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

Otherwise these functions are not instantiated and we end up with an undefined
symbol.

Fix #55560

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

2 years ago[Support] Delete redundant 'static' from namespace scope 'static constexpr'. NFC
Fangrui Song [Sun, 10 Jul 2022 06:36:01 +0000 (23:36 -0700)]
[Support] Delete redundant 'static' from namespace scope 'static constexpr'. NFC

2 years ago[RISCV] Modify the custom isel for (add X, imm) used by load/stores.
Craig Topper [Sun, 10 Jul 2022 02:37:13 +0000 (19:37 -0700)]
[RISCV] Modify the custom isel for (add X, imm) used by load/stores.

We have custom isel that tries to select the Lo12 bits using a
separate ADDI that can later folded into the load/store address
by the post-isel peephole.

This patch disables this if the load/store already had a non-zero
offset. A non-zero offset implies that CodeGenPrepare split several
large offsets used by different loads and stores into a common large
offset and multiple small offsets that could be folded. Folding more
of the lo12 bits changes this common offset by increasing the small
offsets. While this can save an instruction to materialize the common
offset, it can also prevent the small offsets from fitting in a
compressed load/store instruction.

Removing this also simplifies the last piece needed to fold the custom
isel for add into SelectAddrRegImm and remove the post-isel peephole.

2 years ago[libc] Linux threads - store a ptr to the thread attribs in the start args.
Siva Chandra Reddy [Sat, 9 Jul 2022 21:44:37 +0000 (21:44 +0000)]
[libc] Linux threads - store a ptr to the thread attribs in the start args.

Previosly, a pointer to the thread data structure was stored in the
start args. However, the thread data structure need not have the
lifetime of the thread. On the the other hand, thread attributes are
stored on the thread stack so they live as long as the thread lives.

2 years agoRestore Python install behavior from before D128230.
Stella Laurenzo [Sun, 10 Jul 2022 01:35:44 +0000 (18:35 -0700)]
Restore Python install behavior from before D128230.

In D128230, we accidentally moved the install for Python sources outside of the loop, having one install() per group of files. While it would be nice if we could do this, it means that we flatten the relative directory tree and every source ends up in the root. The right way to do this is to use FILE_SETS, which preserve the relative directory tree, but they are not available until CMake 3.23.

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

2 years ago[LV] Move VPWidenRecipe::execute to VPlanRecipes.cpp (NFC).
Florian Hahn [Sun, 10 Jul 2022 01:46:56 +0000 (18:46 -0700)]
[LV] Move VPWidenRecipe::execute to VPlanRecipes.cpp (NFC).

2 years ago[LinkerWrapper] Forward `-mllvm` options to the linker wrapper
Joseph Huber [Wed, 6 Jul 2022 15:28:32 +0000 (11:28 -0400)]
[LinkerWrapper] Forward `-mllvm` options to the linker wrapper

This patch adds the ability to use `-mllvm` options in the linker
wrapper when performing bitcode linking or the module compilation.
This is done by passing in the LLVM argument to the clang-linker-wrapper
tool. Inside the linker-wrapper tool we invoke the `CommandLine` parser
solely for forwarding command line options to the `clang-linker-wrapper`
to the LLVM tools that also use the `CommandLine` parser. The actual
arguments to the linker wrapper are parsed using the `Opt` library
instead.

For example, in the following command the `CommandLine` parser will attempt to
parse `abc`, while the `opt` parser takes `-mllvm <arg>` and ignores it so it is
not passed to the linker arguments.
```
clang-linker-wrapper -mllvm -abc -- <linker-args>
```

As far as I can tell this is the easiest way to forward arguments to
LLVM tool invocations. If there is a better way to pass these arguments
(such as through the LTO config) let me know.

Reviewed By: MaskRay

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

2 years ago[libcxx] Uglify __support/musl
Brad Smith [Sat, 9 Jul 2022 21:59:34 +0000 (17:59 -0400)]
[libcxx] Uglify __support/musl

Uglify __support/musl

Reviewed By: philnik

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

2 years ago[ARM][AArch64] Add additional test for multiuse vldn binop shuffles. NFC
David Green [Sat, 9 Jul 2022 21:48:12 +0000 (22:48 +0100)]
[ARM][AArch64] Add additional test for multiuse vldn binop shuffles. NFC

For D129419, these are the same as the existing test, but run through
-early-cse.

2 years agofix comment typo to cycle bots
Nico Weber [Sat, 9 Jul 2022 20:41:58 +0000 (22:41 +0200)]
fix comment typo to cycle bots

2 years ago[RISCV] Support folding constant addresses in SelectAddrRegImm.
Craig Topper [Sat, 9 Jul 2022 18:54:52 +0000 (11:54 -0700)]
[RISCV] Support folding constant addresses in SelectAddrRegImm.

We already handled this by folding an ADDI in the post-isel peephole.
My goal is to remove that peephole so this adds the functionality
to isel.

2 years ago[DAGCombiner][X86] Fold sra (sub AddC, (shl X, N1C)), N1C --> sext (sub AddC1',(trunc...
Craig Topper [Sat, 9 Jul 2022 18:40:53 +0000 (11:40 -0700)]
[DAGCombiner][X86] Fold sra (sub AddC, (shl X, N1C)), N1C --> sext (sub AddC1',(trunc X to (width - N1C)))

We already handled this case for add with a constant RHS. A
similar pattern can occur for sub with a constant left hand side.

Test cases use add and a mul representing (neg (shl X, C)) because
that's what I saw in the wild. The mul will be decomposed and then
the new transform can kick in.

Tests have not been committed, but this patch shows the changes.

Reviewed By: RKSimon

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

2 years ago[mlir][vector] Relax reduction distribution pattern
Thomas Raoux [Sat, 9 Jul 2022 18:36:39 +0000 (18:36 +0000)]
[mlir][vector] Relax reduction distribution pattern

Support distributing reductions with vector size multiple of the warp
size.

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

2 years ago[libc][NFC] Remove the now used thread_attrib target.
Siva Chandra Reddy [Sat, 9 Jul 2022 18:25:27 +0000 (18:25 +0000)]
[libc][NFC] Remove the now used thread_attrib target.

2 years ago[CMake][Fuchsia] Use libunwind as the default unwinder
Petr Hosek [Sat, 28 May 2022 05:55:38 +0000 (05:55 +0000)]
[CMake][Fuchsia] Use libunwind as the default unwinder

Fuchsia already uses libunwind, but it does so implicitly via libc++.
This change makes the unwinder choice explicit.

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

2 years ago[Fuchsia] Remove the test cflags to explicitly set the unwinder
Petr Hosek [Sat, 9 Jul 2022 17:00:01 +0000 (17:00 +0000)]
[Fuchsia] Remove the test cflags to explicitly set the unwinder

These are no longer needed and cause issue when cross-compiling.

2 years agoFix -Warray-parameter warning
David Blaikie [Sat, 9 Jul 2022 17:04:01 +0000 (17:04 +0000)]
Fix -Warray-parameter warning

Remove the bound in the definition, since it's not guaranteed/could
provide a false sense of security (I'd be inclined to go further and
change this to a pointer parameter, since that's what it really is - but
figured I'd preserve some of the author's intent here)

2 years agoReapply 51c705fbe5d, "[JITLink] Include LinkGraph name in...", with fixes.
Lang Hames [Sat, 9 Jul 2022 16:12:19 +0000 (09:12 -0700)]
Reapply 51c705fbe5d, "[JITLink] Include LinkGraph name in...", with fixes.

Original commit reverted in 976de7130b338aa0d0e63255826a79347635c107 due to test
failures. This commit includes fixes for the tests.

2 years ago[SimplifyLibCalls] refactor pow(x, n) expansion where n is a constant integer value
Paul Osmialowski [Sat, 9 Jul 2022 15:58:18 +0000 (11:58 -0400)]
[SimplifyLibCalls] refactor pow(x, n) expansion where n is a constant integer value

Since the backend's codegen is capable to expand powi into fmul's, it
is not needed anymore to do so in the ::optimizePow() function of
SimplifyLibCalls.cpp. What is sufficient is to always turn pow(x, n)
into powi(x, n) for the cases where n is a constant integer value.

Dropping the current expansion code allowed relaxation of the folding
conditions and now this can also happen at optimization levels below
Ofast.

The added CodeGen/AArch64/powi.ll test case ensures that powi is
actually expanded into fmul's, confirming that this refactor did not
cause any performance degradation.

Following an idea proposed by David Sherwood <david.sherwood@arm.com>.

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

2 years agoRevert "[JITLink] Include LinkGraph name in debugging output."
Lang Hames [Sat, 9 Jul 2022 15:30:04 +0000 (08:30 -0700)]
Revert "[JITLink] Include LinkGraph name in debugging output."

Revert 51c705fbe5d8cc85868fc0f35e9b86d7ec301ee5 while I investigate some
builder failures.

2 years ago[LinkerWrapper] Fix errors not exiting inside of the LTO pipeline
Joseph Huber [Thu, 7 Jul 2022 15:28:32 +0000 (11:28 -0400)]
[LinkerWrapper] Fix errors not exiting inside of the LTO pipeline

The LTO pipeline handles its errors using the diagnostics handler
callback function. We were not checking the results of these errors and
not properly returning an error code in the linker wrapper when errors
occured inside of the LTO pipeline. This patch adds a simple boolean
flag to indicate if the LTO backend failed to any reason and quit.

Reviewed By: ye-luo

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

2 years agoRevert "[Clang] Add a warning on invalid UTF-8 in comments."
Corentin Jabot [Sat, 9 Jul 2022 15:18:35 +0000 (17:18 +0200)]
Revert "[Clang] Add a warning on invalid UTF-8 in comments."

It is probable thart this change crashes on the powerpc bots.

This reverts commit 355532a1499aa9b13a89fb5b5caaba2344d57cd7.

2 years ago[JITLink][AArch64] Rename PointerToGOT and fix typo.
Lang Hames [Sat, 9 Jul 2022 01:55:43 +0000 (18:55 -0700)]
[JITLink][AArch64] Rename PointerToGOT and fix typo.

PointerToGOT lowering was accidentally changed from Delta32 to Delta64 in
db3722580335c. This patch moves it back to Delta32 and renames the generic
aarch64 edge to Delta32ToGOT to avoid the ambiguity.

No test case yet -- I haven't figured out how to write a succinct test case
(this typically appears in CIEs in eh-frames).

2 years ago[JITLink] Include LinkGraph name in debugging output.
Lang Hames [Sat, 9 Jul 2022 01:36:29 +0000 (18:36 -0700)]
[JITLink] Include LinkGraph name in debugging output.

Makes it easier to identify the graph being fixed up at a glance.

2 years ago[C++20][Modules] Update handling of implicit inlines [P1779R3]
Iain Sandoe [Sun, 3 Jul 2022 13:27:10 +0000 (14:27 +0100)]
[C++20][Modules] Update handling of implicit inlines [P1779R3]

This provides updates to
[class.mfct]:
Pre C++20 [class.mfct]p2:
  A member function may be defined (8.4) in its class definition, in
  which case it is an inline member function (7.1.2)
Post C++20 [class.mfct]p1:
  If a member function is attached to the global module and is defined
  in its class definition, it is inline.

and
[class.friend]:
Pre-C++20 [class.friend]p5
  A function can be defined in a friend declaration of a
  class . . . . Such a function is implicitly inline.
Post C++20 [class.friend]p7
  Such a function is implicitly an inline function if it is attached
  to the global module.

We add the output of implicit-inline to the TextNodeDumper, and amend
a couple of existing tests to account for this, plus add tests for the
cases covered above.

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

2 years ago[clang-tidy] Sort release notes entries alphabetically by check name
Danny Mösch [Sat, 9 Jul 2022 13:45:19 +0000 (15:45 +0200)]
[clang-tidy] Sort release notes entries alphabetically by check name

2 years ago[clang-tidy] Initialize boolean variables with `false` in cppcoreguidelines-init...
Danny Mösch [Sat, 9 Jul 2022 12:38:41 +0000 (14:38 +0200)]
[clang-tidy] Initialize boolean variables with `false` in cppcoreguidelines-init-variables' fix-it

In case of a variable with a built-in boolean type, `false` is a better fit to default-initialize it.

Reviewed By: njames93

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

2 years ago[C++20][Modules] Fix two tests for CTORs that return pointers [NFC].
Iain Sandoe [Sat, 9 Jul 2022 10:18:49 +0000 (11:18 +0100)]
[C++20][Modules] Fix two tests for CTORs that return pointers [NFC].

The test are to check that we call the correctly mangled CTORs, so that
the return values from them are irrelevant.  I forgot that some targets
return a pointer, apologies for the breakage.

2 years ago[Clang] Add a warning on invalid UTF-8 in comments.
Corentin Jabot [Fri, 17 Jun 2022 14:23:41 +0000 (16:23 +0200)]
[Clang] Add a warning on invalid UTF-8 in comments.

Introduce an off-by default `-Winvalid-utf8` warning
that detects invalid UTF-8 code units sequences in comments.

Invalid UTF-8 in other places is already diagnosed,
as that cannot appear in identifiers and other grammar constructs.

The warning is off by default as its likely to be somewhat disruptive
otherwise.

This warning allows clang to conform to the yet-to be approved WG21
"P2295R5 Support for UTF-8 as a portable source file encoding"
paper.

Reviewed By: aaron.ballman, #clang-language-wg

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

2 years ago[CMake] Set the common link flags for memprof tests
Petr Hosek [Sat, 9 Jul 2022 08:59:58 +0000 (08:59 +0000)]
[CMake] Set the common link flags for memprof tests

This was missed in ba007f20bb4acf95262f49ab527ce35c4a1f5a19 by mistake.

2 years ago[C++20][Modules] Build module static initializers per P1874R1.
Iain Sandoe [Sun, 15 May 2022 13:47:54 +0000 (14:47 +0100)]
[C++20][Modules] Build module static initializers per P1874R1.

Currently we only implement this for the Itanium ABI since the correct
mangling for the initializers in other ABIs is not yet known.

Intended result:

For a module interface [which includes partition interface and implementation
units] (instead of the generic CXX initializer) we emit a module init that:

 - wraps the contained initializations in a control variable to ensure that
   the inits only happen once, even if a module is imported many times by
   imports of the main unit.

 - calls module initializers for imported modules first.  Note that the
   order of module import is not significant, and therefore neither is the
   order of imported module initializers.

 - We then call initializers for the Global Module Fragment (if present)
 - We then call initializers for the current module.
 - We then call initializers for the Private Module Fragment (if present)

For a module implementation unit, or a non-module TU that imports at least one
module we emit a regular CXX init that:

 - Calls the initializers for any imported modules first.
 - Then proceeds as normal with remaining inits.

For all module unit kinds we include a global constructor entry, this allows
for the (in most cases unusual) possibility that a module object could be
included in a final binary without a specific call to its initializer.

Implementation:

 - We provide the module pointer in the AST Context so that CodeGen can act
   on it and its sub-modules.

 - We need to account for module build lines like this:
  ` clang -cc1 -std=c++20 Foo.pcm -emit-obj -o Foo.o` or
  ` clang -cc1 -std=c++20 -xc++-module Foo.cpp -emit-obj -o Foo.o`

 - in order to do this, we add to ParseAST to set the module pointer in
   the ASTContext, once we establish that this is a module build and we
   know the module pointer. To be able to do this, we make the query for
   current module public in Sema.

 - In CodeGen, we determine if the current build requires a CXX20-style module
   init and, if so, we defer any module initializers during the "Eagerly
   Emitted" phase.

 - We then walk the module initializers at the end of the TU but before
   emitting deferred inits (which adds any hidden and static ones, fixing
   https://github.com/llvm/llvm-project/issues/51873 ).

 - We then proceed to emit the deferred inits and continue to emit the CXX
   init function.

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

2 years ago[clang] Add a fixit for warn-self-assign if LHS is a field with the same name as...
Nathan James [Sat, 9 Jul 2022 07:28:07 +0000 (08:28 +0100)]
[clang] Add a fixit for warn-self-assign if LHS is a field with the same name as parameter on RHS

Add a fix-it for the common case of setters/constructors using parameters with the same name as fields
```lang=c++
struct A{
  int X;
  A(int X) { /*this->*/X = X; }
  void setX(int X) { /*this->*/X = X;
};
```

Reviewed By: aaron.ballman

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

2 years ago[mlir][bufferization] Do not canonicalize to_tensor(to_memref(x))
Matthias Springer [Sat, 9 Jul 2022 07:15:36 +0000 (09:15 +0200)]
[mlir][bufferization] Do not canonicalize to_tensor(to_memref(x))

This is a partial revert of D128615.

to_memref(to_tensor(x)) always be folded to x. But to_tensor(to_memref(x)) cannot be folded in the general case because writes to the intermediary memref may go unnoticed.

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

2 years ago[AMDGPU][NFC] Harmonize decl&def of R600TargetLowering::OptimizeSwizzle
serge-sans-paille [Sat, 9 Jul 2022 07:05:22 +0000 (09:05 +0200)]
[AMDGPU][NFC] Harmonize decl&def of R600TargetLowering::OptimizeSwizzle

The freshly baked -Warray-parameter warning discovered an inconsistency in
argument declaration, use the stricter one.

This fixes build issues like https://lab.llvm.org/buildbot#builders/18/builds/5305

2 years ago[clang-format] Fix an assertion failure on -lines=0:n
owenca [Fri, 8 Jul 2022 06:34:44 +0000 (23:34 -0700)]
[clang-format] Fix an assertion failure on -lines=0:n

Also fixed the error message for start line > end line and added test cases.

Fixes #56438.

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

2 years ago[CMake] Use explicit header path when using in-tree libc++ for tests
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests

This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.

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

2 years ago[Inliner] Make recusive inlinee stack size limit tunable
Wenlei He [Sat, 9 Jul 2022 00:17:11 +0000 (17:17 -0700)]
[Inliner] Make recusive inlinee stack size limit tunable

For recursive callers, we want to be conservative when inlining callees with large stack size. We currently have a limit `InlineConstants::TotalAllocaSizeRecursiveCaller`, but that is hard coded.

We found the current limit insufficient to suppress problematic inlining that bloats stack size for deep recursion. This change adds a switch to make the limit tunable as a mitigation.

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

2 years agoRevert "[CMake] Use explicit header path when using in-tree libc++ for tests"
Petr Hosek [Sat, 9 Jul 2022 04:27:16 +0000 (04:27 +0000)]
Revert "[CMake] Use explicit header path when using in-tree libc++ for tests"

This reverts commit 61b410cb8b9af0aa265e730a3070b3154d869803 as this
appears to have broken some sanitizer tests.

2 years ago[CMake] Use explicit header path when using in-tree libc++ for tests
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests

This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.

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

2 years ago[clangd] Support "usedAsMutableReference" in member initializations
Christian Kandeler [Fri, 8 Jul 2022 08:12:31 +0000 (04:12 -0400)]
[clangd] Support "usedAsMutableReference" in member initializations

That is, mark constructor parameters being used to initialize
non-const reference members.

Reviewed By: nridge

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

2 years ago[libcxx] Uglify __support/openbsd
Brad Smith [Sat, 9 Jul 2022 01:33:57 +0000 (21:33 -0400)]
[libcxx] Uglify __support/openbsd

Uglify __support/openbsd

Reviewed By: philnik

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

2 years ago[NFC][OpenMP][Offloading] Fix compilation warning caused by misuse of `static_cast`
Shilei Tian [Sat, 9 Jul 2022 00:59:37 +0000 (20:59 -0400)]
[NFC][OpenMP][Offloading] Fix compilation warning caused by misuse of `static_cast`

2 years ago[mlir:LSP] Drop potentialy annoying completion commit characters
River Riddle [Sat, 9 Jul 2022 00:56:48 +0000 (17:56 -0700)]
[mlir:LSP] Drop potentialy annoying completion commit characters

These can result in accidentally accepting a completion when it isn't intended.

2 years ago[mlir:LSP] Add code completions for builtin signed/unsigned integers
River Riddle [Sat, 9 Jul 2022 00:55:30 +0000 (17:55 -0700)]
[mlir:LSP] Add code completions for builtin signed/unsigned integers

2 years ago[mlir:LSP] Add support for code completing attributes and types
River Riddle [Thu, 7 Jul 2022 05:54:36 +0000 (22:54 -0700)]
[mlir:LSP] Add support for code completing attributes and types

This required changing a bit of how attributes/types are parsed. A new
`KeywordSwitch` class was added to AsmParser that provides a StringSwitch
like API for parsing keywords with a set of potential matches. It intends to
both provide a cleaner API, and enable injection for code completion. This
required changing the API of `generated(Attr|Type)Parser` to handle the
parsing of the keyword, instead of having the user do it. Most upstream
dialects use the autogenerated handling and didn't require a direct update.

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

2 years ago[mlir:LSP] Add support for keyword code completions
River Riddle [Wed, 6 Jul 2022 09:49:58 +0000 (02:49 -0700)]
[mlir:LSP] Add support for keyword code completions

This commit adds code completion results to the MLIR LSP when
parsing keywords. Keyword support is currently limited to the
case where the expected keyword is provided, but a followup will
work on expanding the set of keyword cases we handle (e.g. to
allow capturing attribute/type mnemonics).

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

2 years ago[libc] add printf hexadecimal float conversion
Michael Jones [Wed, 6 Jul 2022 23:53:34 +0000 (16:53 -0700)]
[libc] add printf hexadecimal float conversion

This patch adds the %a/A conversions to printf, as well as the compiler
flag to disable floating point handling entirely. This will allow our
printf implementation to display every type of argument allowed by
printf, although some formats are still incomplete.

Reviewed By: sivachandra

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

2 years agoReplace hard coded number with regex so the test passes on downstream projects that...
Douglas Yung [Fri, 8 Jul 2022 22:47:03 +0000 (15:47 -0700)]
Replace hard coded number with regex so the test passes on downstream projects that may define additional opcodes.

2 years ago[libc] add dependencies to generic sqrt tests
Michael Jones [Fri, 8 Jul 2022 18:35:29 +0000 (11:35 -0700)]
[libc] add dependencies to generic sqrt tests

This adds dependencies on the corresponding sqrt function to each
generic sqrt test. This is so that on platforms that don't support the
math functions, the tests are not run.

Reviewed By: lntue

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

2 years ago[AIX][clang/test] Set/propagate AIXTHREAD_STK for AIX
Hubert Tong [Fri, 8 Jul 2022 22:30:48 +0000 (18:30 -0400)]
[AIX][clang/test] Set/propagate AIXTHREAD_STK for AIX

Some tests perform deep recursion, which requires a larger pthread stack
size than the relatively low default of 192 KiB for 64-bit processes on
AIX. The `AIXTHREAD_STK` environment variable provides a non-intrusive
way to request a larger pthread stack size for the tests. The required
pthread stack size depends on the build configuration.

A 4 MiB default is generous compared to the 512 KiB of macOS; however,
it is known that some compilers on AIX produce code that uses
comparatively more stack space.

This patch expands the solution from D65688 to apply to all Clang LIT
tests.

This also reverts commit c3c75d805c2174388417080f762230961b3433d6,
"[clang][test] Mark test arm-float-abi-lto.c unsupported on AIX".

The problem was caused by the test running up against the per-thread
stack limit on AIX. This is resolved by having the tests run with
`AIXTHREAD_STK` set for 4 MiB.

Reviewed By: xingxue

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

2 years ago[BOLT][Runtime] Fix memset definition
Vladislav Khmelevsky [Thu, 7 Jul 2022 11:48:47 +0000 (14:48 +0300)]
[BOLT][Runtime] Fix memset definition

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

2 years agojGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded
Jason Molenda [Fri, 8 Jul 2022 21:01:15 +0000 (14:01 -0700)]
jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded

jGetLoadedDynamicLibrariesInfos normally checks with dyld to find
the list of binaries loaded in the inferior, and getting the filepath,
before trying to parse the Mach-O binary in inferior memory.
This allows for debugserver to parse a Mach-O binary present in memory,
but not yet registered with dyld.  This patch also adds some simple
sanity checks that we're reading a Mach-O header before we begin
stepping through load commands, because we won't have the sanity check
of consulting dyld for the list of loaded binaries before parsing.
Also adds a testcase.

Differential Revision: https://reviews.llvm.org/D128956
rdar://95737734

2 years ago[CMake] Option to select C++ library for runtimes that use it
Petr Hosek [Thu, 2 Jun 2022 21:52:56 +0000 (21:52 +0000)]
[CMake] Option to select C++ library for runtimes that use it

We currently have an option to select C++ ABI and C++ library for tests
but there are runtimes that use C++ library, specifically ORC and XRay,
which aren't covered by existing options. This change introduces a new
option to control the use of C++ libray for these runtimes.

Ideally, this option should become the default way to select C++ library
for all of compiler-rt replacing the existing options (the C++ ABI
option could remain as a hidden internal option).

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

2 years agoRemove unnecessary braces
David Blaikie [Fri, 8 Jul 2022 21:37:24 +0000 (21:37 +0000)]
Remove unnecessary braces

2 years agollvm-dwarfdump: Don't crash if DW_AT_{decl,call}_{file,line} uses signed form
Pedro Alves [Fri, 8 Jul 2022 21:15:52 +0000 (21:15 +0000)]
llvm-dwarfdump: Don't crash if DW_AT_{decl,call}_{file,line} uses signed form

The DWARF spec says:

 Any debugging information entry representing the declaration of an object,
 module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and
 DW_AT_decl_column attributes, each of whose value is an unsigned integer
 ^^^^^^^^
 constant.

If however, a producer happens to emit DW_AT_decl_file /
DW_AT_decl_line using a signed integer form, llvm-dwarfdump crashes,
like so:

     (... snip ...)
     0x000000b4:   DW_TAG_structure_type
                     DW_AT_name      ("test_struct")
                     DW_AT_byte_size (136)
                     DW_AT_decl_file (llvm-dwarfdump: (... snip ...)/llvm/include/llvm/ADT/Optional.h:197: T& llvm::optional_detail::OptionalStorage<T, true>::getValue() &
 [with T = long unsigned int]: Assertion `hasVal' failed.
     PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
     Stack dump:
     0.      Program arguments: /opt/rocm/llvm/bin/llvm-dwarfdump ./testsuite/outputs/gdb.rocm/lane-pc-vega20/lane-pc-vega20-kernel.so
      #0 0x000055cc8e78315f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
      #1 0x000055cc8e780d3d SignalHandler(int) Signals.cpp:0:0
      #2 0x00007f8f2cae8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
      #3 0x00007f8f2c58d00b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
      #4 0x00007f8f2c56c859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
      #5 0x00007f8f2c56c729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
      #6 0x00007f8f2c56c729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
      #7 0x00007f8f2c57dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
      #8 0x000055cc8e58ceb9 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2e0eb9)
      #9 0x000055cc8e58bec3 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2dfec3)
     #10 0x000055cc8e5b28a3 llvm::DWARFCompileUnit::dump(llvm::raw_ostream&, llvm::DIDumpOptions) (.part.21) DWARFCompileUnit.cpp:0:0

Likewise with DW_AT_call_file / DW_AT_call_line.

The problem is that the code in llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
dumping these attributes assumes that
FormValue.getAsUnsignedConstant() returns an armed optional.  If in
debug mode, we get an assertion line the above.  If in release mode,
and asserts are compiled out, then we proceed as if the optional had a
value, running into undefined behavior, printing whatever random
value.

Fix this by checking whether the optional returned by
FormValue.getAsUnsignedConstant() has a value, like done in other
places.

In addition, DWARFVerifier.cpp is validating DW_AT_call_file /
DW_AT_decl_file, but not AT_call_line / DW_AT_decl_line.  This commit
fixes that too.

The llvm-dwarfdump/X86/verify_file_encoding.yaml testcase is extended
to cover these cases.  Current llvm-dwarfdump crashes running the
newly-extended test.

"make check-llvm-tools-llvm-dwarfdump" shows no regressions, on x86-64
GNU/Linux.

Reviewed By: dblaikie

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

2 years ago[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage
Julian Lettner [Fri, 1 Jul 2022 18:05:40 +0000 (11:05 -0700)]
[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage

While investigating another issue, I noticed that `MaybeReexec()` never
actually "re-executes via `execv()`" anymore.  `DyldNeedsEnvVariable()`
only returned true on macOS 10.10 and below.

Usually, I try to avoid "unnecessary" cleanups (it's hard to be certain
that there truly is no fallout), but I decided to do this one because:

* I initially tricked myself into thinking that `MaybeReexec()` was
  relevant to my original investigation (instead of being dead code).
* The deleted code itself is quite complicated.
* Over time a few other things were mushed into `MaybeReexec()`:
  initializing `MonotonicNanoTime()`, verifying interceptors are
  working, and stripping the `DYLD_INSERT_LIBRARIES` env var to avoid
  problems when forking.
* This platform-specific thing leaked into `sanitizer_common.h`.
* The `ReexecDisabled()` config nob relies on the "strong overrides weak
  pattern", which is now problematic and can be completely removed.
* `ReexecDisabled()` actually hid another issue with interceptors not
  working in unit tests.  I added an explicit `verify_interceptors`
  (defaults to `true`) option instead.

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

2 years ago[Clang] Fix the wrong features being derivec in the offload packager
Joseph Huber [Fri, 8 Jul 2022 19:59:10 +0000 (15:59 -0400)]
[Clang] Fix the wrong features being derivec in the offload packager

The offload packager embeds the features in the offloading binary when
performing LTO. This had an incorrect interaction with the
`--cuda-feature` option because we weren't deriving the features from
the CUDA toolchain arguments when it was being specified. This patch
fixes this so the features are correctly overrideen when using this
argument.

However, this brings up a question of how best to handle conflicting
target features. The user could compile many libraries with different
features, in this case we do not know which one to pick. This was not
previously a problem when we simply passed the features in from the CUDA
installation at link-link because we just defaulted to whatever was
current on the system.

Reviewed By: ye-luo

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

2 years ago[LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries
Joseph Huber [Fri, 8 Jul 2022 17:33:46 +0000 (13:33 -0400)]
[LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries

This patch removes some uses of string savers that are no-longer needed.
We also create a new string saver when linking bitcode files. It seems
that occasionally the symbol string references can go out of scope when
they are added to the LTO input so we need to save these names that are
used for symbol resolution. Additionally, a previous patch added new
logic for handling bitcode libraries, but failed to actually add them to
the input. This bug has been fixed.

Fixes #56445

Reviewed By: ye-luo

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

2 years ago[clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.
Martin Storsjö [Wed, 25 May 2022 12:07:18 +0000 (15:07 +0300)]
[clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.

The two first parameters of checkPreprocessorOptions are "PPOpts, ExistingPPOpts".
All other callers of the function pass them consistently.

This avoids confusion when working on the code.

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

2 years ago[ELF] Refactor ELFCOMPRESS_ZLIB handling and improve diagnostics
Fangrui Song [Fri, 8 Jul 2022 21:04:19 +0000 (14:04 -0700)]
[ELF] Refactor ELFCOMPRESS_ZLIB handling and improve diagnostics

And add some tests.