platform/upstream/llvm.git
2 years ago[clang][scandeps] Update Module Cache Path in Test
Archibald Elliott [Wed, 5 Jan 2022 10:41:48 +0000 (10:41 +0000)]
[clang][scandeps] Update Module Cache Path in Test

This fixes the test introduced in D114206 so it no longer writes to the current working directory.

Reviewed By: simon_tatham

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

2 years ago[ELF] Remove redundant cast. NFC
Fangrui Song [Wed, 5 Jan 2022 10:07:14 +0000 (02:07 -0800)]
[ELF] Remove redundant cast. NFC

2 years ago[ELF] --symbol-ordering-file: use getLocalSymbols. NFC
Fangrui Song [Wed, 5 Jan 2022 10:06:30 +0000 (02:06 -0800)]
[ELF] --symbol-ordering-file: use getLocalSymbols. NFC

2 years ago[ELF] --symbol-ordering-file: remove weird !lazy condition for "no such symbol" diagn...
Fangrui Song [Wed, 5 Jan 2022 10:04:36 +0000 (02:04 -0800)]
[ELF] --symbol-ordering-file: remove weird !lazy condition for "no such symbol" diagnostic

The diagnostic is emitted for an unextracted lazy symbol but suppressed for an
undefined symbol. Suppressing the diagnostic for unextracted lazy symbol
probably makes more sense because (a) an unextracted lazy symbol is quite
similar to an undefined symbol and (b) an unextracted lazy symbol is different
from "no such symbol".

2 years ago[mlir][scf] NFC - refactor the implementation of outlineIfOp
Nicolas Vasilache [Tue, 4 Jan 2022 11:35:52 +0000 (06:35 -0500)]
[mlir][scf] NFC - refactor the implementation of outlineIfOp

This revision refactors the implementation of outlineIfOp to expose
a finer-grain functionality `outlineSingleBlockRegion` that will be
reused in other contexts.

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

2 years ago[LegalizeTypes][VP] Add widening support for vp.select
Victor Perez [Wed, 5 Jan 2022 08:07:46 +0000 (08:07 +0000)]
[LegalizeTypes][VP] Add widening support for vp.select

Widen vp.select the same way as select and vselect.

Reviewed By: craig.topper

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

2 years agoSilence a few unused variable warnings. NFC.
Sjoerd Meijer [Wed, 5 Jan 2022 09:11:43 +0000 (09:11 +0000)]
Silence a few unused variable warnings. NFC.

2 years agoRevert "[InferAttrs] Add writeonly to all the math functions"
Martin Storsjö [Wed, 5 Jan 2022 08:54:07 +0000 (10:54 +0200)]
Revert "[InferAttrs] Add writeonly to all the math functions"

This reverts commit ea75be3d9df448b6abafaf752a8141764d93ca33 and
1eb5b6e85045d22720f177a02aaf7097930e4b4f.

That commit caused crashes with compilation e.g. like this
(not fixed by the follow-up commit):

$ cat sqrt.c
float a;
b() { sqrt(a); }
$ clang -target x86_64-linux-gnu -c -O2 sqrt.c
Attributes 'readnone and writeonly' are incompatible!
  %sqrtf = tail call float @sqrtf(float %0) #1
in function b
fatal error: error in backend: Broken function found, compilation aborted!

2 years ago[M68k][test][NFC] Remove new line at end of file
Jim Lin [Wed, 5 Jan 2022 08:28:14 +0000 (16:28 +0800)]
[M68k][test][NFC] Remove new line at end of file

2 years ago[LoopInfo] Clarify description of `makeLoopInvariant`. NFC.
Sjoerd Meijer [Wed, 5 Jan 2022 08:55:26 +0000 (08:55 +0000)]
[LoopInfo] Clarify description of `makeLoopInvariant`. NFC.

Clarify that `Changed` is set to true if the instruction/value was made
loop-invariant; the function is returning true if it was already invariant.

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

2 years ago[MemCpyOpt] Look through pointer casts when checking capture
Nikita Popov [Wed, 5 Jan 2022 08:48:17 +0000 (09:48 +0100)]
[MemCpyOpt] Look through pointer casts when checking capture

The user scanning loop above looks through pointer casts, so we
also need to strip pointer casts in the capture check. Previously
the source was incorrectly considered not captured if a bitcast
was passed to the call.

2 years ago[ELF] Symbol::getVA: assert not called on a lazy symbol
Fangrui Song [Wed, 5 Jan 2022 08:46:48 +0000 (00:46 -0800)]
[ELF] Symbol::getVA: assert not called on a lazy symbol

The code path is dead after D111365.

2 years ago[MemCpyOpt] Make capture check during call slot optimization more precise
Nikita Popov [Mon, 13 Dec 2021 09:54:53 +0000 (10:54 +0100)]
[MemCpyOpt] Make capture check during call slot optimization more precise

Call slot optimization is currently supposed to be prevented if
the call can capture the source pointer. Due to an implementation
bug, this check currently doesn't trigger if a bitcast of the source
pointer is passed instead. I'm somewhat afraid of the fallout of
fixing this bug (due to heavy reliance on call slot optimization
in rust), so I'd like to strengthen the capture reasoning a bit first.

In particular, I believe that the capture is fine as long as a)
the call itself cannot depend on the pointer identity, because
neither dest has been captured before/at nor src before the
call and b) there is no potential use of the captured pointer
before the lifetime of the source alloca ends, either due to
lifetime.end or a return from a function. At that point the
potentially captured pointer becomes dangling.

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

2 years ago[MemCpyOpt] Add additional call slot capture tests (NFC)
Nikita Popov [Wed, 5 Jan 2022 08:33:04 +0000 (09:33 +0100)]
[MemCpyOpt] Add additional call slot capture tests (NFC)

2 years ago[GlobalOpt][Evaluator] Don't create bitcast for same type (PR52994)
Nikita Popov [Wed, 5 Jan 2022 08:14:50 +0000 (09:14 +0100)]
[GlobalOpt][Evaluator] Don't create bitcast for same type (PR52994)

isBitOrNoopPointerCastable() returns true if the types are the
same, but it's not actually possible to create a bitcast for all
such types. The assumption seems to be that the user will omit
creating the cast in that case, as it is unnecessary.

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

2 years ago[libc++] Use _LIBCPP_DEBUG_ASSERT in __iterator/wrap_iter.h
Nikolas Klauser [Tue, 4 Jan 2022 14:56:49 +0000 (15:56 +0100)]
[libc++] Use _LIBCPP_DEBUG_ASSERT in __iterator/wrap_iter.h

Use `_LIBCPP_DEBUG_ASSERT` in `__iterator/wrap_iter.h`

Reviewed By: #libc, Quuxplusone, Mordante, ldionne

Spies: libcxx-commits

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

2 years agoSIGSEGV in Sanitizer INTERCEPTOR of strstr function.
Bharadwaj, Ritanya B [Wed, 22 Dec 2021 23:30:35 +0000 (15:30 -0800)]
SIGSEGV in Sanitizer INTERCEPTOR of strstr function.

This is a segmentation fault in INTERCEPTOR function on a special edge
case of strstr libc call. When 'Haystack'(main string to be examined) is
NULL and 'needle'(sub-string to be searched in 'Haystack') is an empty
string then it hits a SEGV while using sanitizers and as a 'string not
found' case otherwise.

Reviewed By: vitalybuka

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

2 years agoDocument __builtin_trap and __builtin_debugtrap
serge-sans-paille [Tue, 4 Jan 2022 13:35:09 +0000 (08:35 -0500)]
Document __builtin_trap and __builtin_debugtrap

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

2 years ago[libc++][NFC] Remove duplicate header includes from <algorithm> and reorder them
Nikolas Klauser [Mon, 3 Jan 2022 00:24:09 +0000 (01:24 +0100)]
[libc++][NFC] Remove duplicate header includes from <algorithm> and reorder them

Remove duplicate header includes from `<algorithm>` and reorder the includes

Reviewed By: Quuxplusone, ldionne, Mordante, #libc, jloser

Spies: jloser, libcxx-commits

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

2 years ago[CSKY] Add python script of CSKY asm update test check
Zi Xuan Wu [Wed, 5 Jan 2022 07:55:11 +0000 (15:55 +0800)]
[CSKY] Add python script of CSKY asm update test check

2 years ago[CSKY] Add codegen of select/br/cmp instruction and some frame lowering infra
Zi Xuan Wu [Thu, 30 Dec 2021 08:10:22 +0000 (16:10 +0800)]
[CSKY] Add codegen of select/br/cmp instruction and some frame lowering infra

Add basic integer codegen of select/br/cmp instruction. It also includes frame lowering code
such as prologue/epilogue.

2 years ago[M68k][test][NFC] Remove unecessary labels and assembly directives
Jim Lin [Wed, 5 Jan 2022 06:29:38 +0000 (14:29 +0800)]
[M68k][test][NFC] Remove unecessary labels and assembly directives

2 years ago[Hexagon] Fix warning about unused variable when compiling without asserts
Mikael Holmen [Wed, 5 Jan 2022 07:35:16 +0000 (08:35 +0100)]
[Hexagon] Fix warning about unused variable when compiling without asserts

2 years ago[NFC][clang] Fix comments.
Shao-Ce SUN [Wed, 5 Jan 2022 06:49:03 +0000 (14:49 +0800)]
[NFC][clang] Fix comments.

2 years ago[sanitizers] Fix integer underflow when parsing ELF.
Florian Mayer [Wed, 5 Jan 2022 02:22:46 +0000 (18:22 -0800)]
[sanitizers] Fix integer underflow when parsing ELF.

Reviewed By: vitalybuka

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

2 years agoAlign adaptor's generator accessors for attribute on the Op class
Mehdi Amini [Wed, 5 Jan 2022 05:36:34 +0000 (05:36 +0000)]
Align adaptor's generator accessors for attribute on the Op class

Each attribute has two accessor: one suffixed with `Attr` which returns the attribute itself
and one without the suffix which unwrap the attribute.
For example for a StringAttr attribute with a field named `kind`, we'll generate:

StringAttr getKindAttr();
StringRef getKind();

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

2 years ago[LTO] Fix assertion failed when flushing bitcode incrementally for LTO output.
Xu Mingjie [Wed, 5 Jan 2022 05:40:23 +0000 (21:40 -0800)]
[LTO] Fix assertion failed when flushing bitcode incrementally for LTO output.

In https://reviews.llvm.org/D86905, we introduce an optimization, when lld emits LLVM bitcode,
we allow bitcode writer flush data to disk early when buffered data size is above some threshold.

But when `--plugin-opt=emit-llvm` and `-o /dev/null` are used,
lld will trigger assertion `BytesRead >= 0 && static_cast<size_t>(BytesRead) == BytesFromDisk`.
When we write output to /dev/null, BytesRead is zero, but at this program point BytesFromDisk is always non-zero.

Reviewed By: stephan.yichao.zhao, MaskRay

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

2 years ago[AMDGPU] Test commit. NFC.
Pravin Jagtap [Wed, 5 Jan 2022 03:54:13 +0000 (22:54 -0500)]
[AMDGPU] Test commit. NFC.

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

2 years ago[NFC][MLGO]Add RTTI support for MLModelRunner and simplify runner setup
Mircea Trofin [Tue, 4 Jan 2022 17:22:29 +0000 (09:22 -0800)]
[NFC][MLGO]Add RTTI support for MLModelRunner and simplify runner setup

2 years ago[NFC] [Coroutines] Rename ReuseFrameSlot to OptimizeFrame
Chuanqi Xu [Wed, 5 Jan 2022 03:36:49 +0000 (11:36 +0800)]
[NFC] [Coroutines] Rename ReuseFrameSlot to OptimizeFrame

We could use the variable as a flag to indicate if the optimization
is on.

2 years ago[lld-link] Remove unneeded lto::InputFile::create after D116434
Fangrui Song [Wed, 5 Jan 2022 03:38:32 +0000 (19:38 -0800)]
[lld-link] Remove unneeded lto::InputFile::create after D116434

2 years ago[lld] Add support for other demanglers other than Itanium
Luís Ferreira [Wed, 5 Jan 2022 03:05:10 +0000 (03:05 +0000)]
[lld] Add support for other demanglers other than Itanium

LLVM core library supports demangling other mangled symbols other than itanium,
such as D and Rust. LLD should use those demanglers in order to output pretty
demangled symbols on error messages.

Reviewed By: MaskRay, #lld-macho

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

2 years ago[InferAttrs] If readonly is already set, set readnone instead of writeonly
Fangrui Song [Wed, 5 Jan 2022 02:59:35 +0000 (18:59 -0800)]
[InferAttrs] If readonly is already set, set readnone instead of writeonly

D116426 may lead to an assertion failure `Attributes 'readonly and writeonly' are incompatible!` if the builtin function already has `readonly`.

2 years ago[Coroutines] Set presplit attribute in Clang and mlir
Chuanqi Xu [Wed, 5 Jan 2022 02:19:44 +0000 (10:19 +0800)]
[Coroutines] Set presplit attribute in Clang and mlir

This fixes bug49264.

Simply, coroutine shouldn't be inlined before CoroSplit. And the marker
for pre-splited coroutine is created in CoroEarly pass, which ran after
AlwaysInliner Pass in O0 pipeline. So that the AlwaysInliner couldn't
detect it shouldn't inline a coroutine. So here is the error.

This patch set the presplit attribute in clang and mlir. So the inliner
would always detect the attribute before splitting.

Reviewed By: rjmccall, ezhulenev

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

2 years ago[WebAssembly] Use llvm utility functions in EH/SjLj
Heejin Ahn [Mon, 3 Jan 2022 07:42:38 +0000 (23:42 -0800)]
[WebAssembly] Use llvm utility functions in EH/SjLj

This uses `changeToCall` and `changeToInvokeAndSplitBasicBlock` from
`lib/Transforms/Utils`, replacing the custom logic. One difference of
those functions from our previous logic is they delete the original
`CallInst`/`InvokeInst`, which makes them tricky to use while iterating
through instructions/BBs. So this CL gathers the candidate calls first
and run them through `changeToInvokeAndSplitBasicBlock` later.

Also this renames some variables.

Reviewed By: dschuff

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

2 years ago[WebAssembly] Nullify unnecessary setjmp calls
Heejin Ahn [Sun, 2 Jan 2022 02:03:00 +0000 (18:03 -0800)]
[WebAssembly] Nullify unnecessary setjmp calls

D107530 did a small optimization that, if a function contains `setjmp`
calls but not other calls that can `longjmp`, we don't do SjLj
transformation on those `setjmp` calls, because they don't have
possibilities of returning from `longjmp`.

But we should remove those `setjmp` calls even in that case, because
Emscripten doesn't provide that function, assuming it is lowered away by
SjLj transformation. `setjmp` always returns 0 when called directly, so
this CL replaces them with `i32 0`.

Fixes https://github.com/emscripten-core/emscripten/issues/15679.

Reviewed By: dschuff

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

2 years ago[docs] Re-generate ClangCommandLineReference.rst
Fangrui Song [Wed, 5 Jan 2022 00:52:24 +0000 (16:52 -0800)]
[docs] Re-generate ClangCommandLineReference.rst

2 years agoRevert "[clang][ObjC] Add fix it for missing methods in impl"
Rumeet Dhindsa [Wed, 5 Jan 2022 00:23:20 +0000 (16:23 -0800)]
Revert "[clang][ObjC] Add fix it for missing methods in impl"

This reverts commit dd72ae3dcc6895f95e1203b40aabcb069c76a0ab.

Notified the author of the internal failure and author suggested to revert it for
now.

2 years ago[mlir][sparse] Factoring out type-based function-name suffixes
wren romano [Tue, 4 Jan 2022 23:15:36 +0000 (15:15 -0800)]
[mlir][sparse] Factoring out type-based function-name suffixes

Depends On D115010

This changes a couple of places that used to `return failure();` to now use `llvm_unreachable()` instead. However, `Transforms/Sparsification.cpp` should be doing the necessary type checks to ensure that those cases are in fact unreachable.

Reviewed By: aartbik

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

2 years ago[mlir][sparse] adding OverheadType::kIndex
wren romano [Tue, 4 Jan 2022 23:10:54 +0000 (15:10 -0800)]
[mlir][sparse] adding OverheadType::kIndex

Depends On D115008

This change opens the way for D115012, and removes some corner cases in `CodegenUtils.cpp`. The `SparseTensorAttrDefs.td` already specifies that we allow `0` bitwidth for the two overhead types and that it is interpreted to mean the architecture's native width.

Reviewed By: aartbik

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

2 years ago[mlir][sparse] Factoring out Transforms/CodegenUtils.{cpp,h}
wren romano [Tue, 4 Jan 2022 23:06:28 +0000 (15:06 -0800)]
[mlir][sparse] Factoring out Transforms/CodegenUtils.{cpp,h}

This moves a bunch of helper functions from `Transforms/SparseTensorConversion.cpp` into `Transforms/CodegenUtils.{cpp,h}` so that they can be reused by `Transforms/Sparsification.cpp`, etc.

See also the dependent D115010 which cleans up some corner cases in this change.

Reviewed By: aartbik, rriddle

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

2 years agoCUDA/HIP: Allow __int128 on the host side
Henry Linjamäki [Wed, 5 Jan 2022 00:00:36 +0000 (16:00 -0800)]
CUDA/HIP: Allow __int128 on the host side

Consider case where `__int128` type is supported by the host target but
not by a device target (e.g. spirv*). Clang emits an error message for
unsupported type even if the device code does not use it. This patch
fixes this issue by emitting the error message when the device code
attempts to use the unsupported type.

Reviewed By: tra

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

2 years ago[Hexagon] Fix MachineSink not to hoist FP instructions that update USR.
Sumanth Gundapaneni [Wed, 1 Sep 2021 03:46:21 +0000 (22:46 -0500)]
[Hexagon] Fix MachineSink not to hoist FP instructions that update USR.

Ideally we should make USR as Def for these floating point instructions.
However, it violates some assembler MCChecker rules. This patch fixes
the issue by marking these FP instructions as non-sinkable.

2 years ago[Hexagon] Make A2_tfrsi not cheap for operands exceeding 16 bits
SANTANU DAS [Mon, 2 Nov 2020 19:15:40 +0000 (00:45 +0530)]
[Hexagon] Make A2_tfrsi not cheap for operands exceeding 16 bits

This patch aids to reduce code size since it removes generation
of back-to-back A2_tfrsi instructions. It is enabled only at -Os/-Oz.

2 years ago[Hexagon] Convert codegen testcase from .ll to .mir
Krzysztof Parzyszek [Tue, 4 Jan 2022 23:37:05 +0000 (15:37 -0800)]
[Hexagon] Convert codegen testcase from .ll to .mir

2 years ago[mlir] Retain metadata for single loc fusedloc
Jacques Pienaar [Tue, 4 Jan 2022 23:37:33 +0000 (15:37 -0800)]
[mlir] Retain metadata for single loc fusedloc

If a fusedloc is created with a single location then no fusedloc
was previously created and single location returned instead. In the case
where there is a metadata associated with the location this results in
discarding the metadata. Instead only canonicalize where there is no
loss of information.

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

2 years ago[lld-link] Replace LazyObjFile with lazy ObjFile/BitcodeFile
Fangrui Song [Tue, 4 Jan 2022 23:11:44 +0000 (15:11 -0800)]
[lld-link] Replace LazyObjFile with lazy ObjFile/BitcodeFile

Similar to ELF 3a5fb57393c3bc77be9e7afc2ec9d4ec3c9bbf70.

* previously when a LazyObjFile was extracted, a new ObjFile/BitcodeFile was created; now the file is reused, just with `lazy` cleared
* avoid the confusing transfer of `symbols` from LazyObjFile to the new file
* simpler code, smaller executable (5200+ bytes smaller on x86-64)
* make eager parsing feasible (for parallel section/symbol table initialization)

Reviewed By: aganea, rnk

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

2 years ago[libc++][test] Allow multiple tries in some thread tests
Nikolas Klauser [Tue, 4 Jan 2022 22:28:21 +0000 (23:28 +0100)]
[libc++][test] Allow multiple tries in some thread tests

2 years ago[gn build] Port 6d722801d1a2
LLVM GN Syncbot [Tue, 4 Jan 2022 22:44:20 +0000 (22:44 +0000)]
[gn build] Port 6d722801d1a2

2 years ago[libc++][ranges] Add indirectly_comparable concept
Nikolas Klauser [Tue, 4 Jan 2022 18:55:37 +0000 (19:55 +0100)]
[libc++][ranges] Add indirectly_comparable concept

Add `indirectly_comparable` concept

Reviewed By: Quuxplusone, Mordante, #libc

Spies: mgorny, libcxx-commits

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

2 years ago[Hexagon] Fix some issues with packetizing slot0-only instructions
Brendon Cahoon [Tue, 4 Jan 2022 22:34:15 +0000 (14:34 -0800)]
[Hexagon] Fix some issues with packetizing slot0-only instructions

2 years ago[flang] Modify an IO format error message
V Donaldson [Tue, 4 Jan 2022 20:54:45 +0000 (12:54 -0800)]
[flang] Modify an IO format error message

F18 constraint C1308 is:

  For the G edit descriptor, e shall not be specified if w is zero.

For an edit descriptor such as 'G0.2E4', change the error message from:

  error: Unexpected 'e' in 'G0' edit descriptor

To:

  error: A 'G0' edit descriptor must not have an 'e' value

2 years ago[libc++] [P0887] Add newest feature-test macros; mark `type_identity` as implemented.
Arthur O'Dwyer [Fri, 31 Dec 2021 04:28:12 +0000 (23:28 -0500)]
[libc++] [P0887] Add newest feature-test macros; mark `type_identity` as implemented.

`__cpp_lib_type_identity` was implemented way back in cf49ccd0 (Clang 8),
probably before the feature-test macro had been settled on.

`__cpp_lib_string_resize_and_overwrite` will be added by D113013 so I didn't add it here.

Fixes #46605.

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

2 years ago[libc++] [ranges] ADL-proof the [range.access] CPOs.
Arthur O'Dwyer [Thu, 23 Dec 2021 21:53:48 +0000 (16:53 -0500)]
[libc++] [ranges] ADL-proof the [range.access] CPOs.

For example, `std::ranges::range<Holder<Incomplete>*>` should be
well-formed false, not a hard error at compile time.

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

2 years ago[libc++] [test] More test coverage for ranges::{data,size}.
Arthur O'Dwyer [Thu, 23 Dec 2021 21:39:22 +0000 (16:39 -0500)]
[libc++] [test] More test coverage for ranges::{data,size}.

Reviewed as part of D116239.

2 years ago[Hexagon] Performance regression with b2b
Harsha Jagasia [Fri, 2 Oct 2020 16:26:45 +0000 (11:26 -0500)]
[Hexagon] Performance regression with b2b

For code below:
        {
                r7 = addasl(r3,r0,#2)
                r8 = addasl(r3,r2,#2)
                r5 = memw(r3+r0<<#2)
                r6 = memw(r3+r2<<#2)
        }
        {
                p1 = cmp.gtu(r6,r5)
                if (p1.new) memw(r8+#0) = r5
                if (p1.new) memw(r7+#0) = r6
        }
        {
                r0 = mux(p1,r2,r4)

        }

In packetizer, a new packet is created for the cmp instruction since
there arent enough resources in previous packet. Also it is determined
that the cmp stalls by 2 cycles since it depends on the prior load of r5.
In current packetizer implementation, the predicated store is evaluated
for whether it can go in the same packet as compare, and since the compare
stalls, the stall of the predicated store does not matter and it can go in
the same packet as the cmp. However the predicated store will stall for
more cycles because of its dependence on the addasl instruction and to
avoid that stall we can put it in a new packet.

Improve the packetizer to check if an instruction being added to packet
will stall longer than instruction already in packet and if so create a
new packet.

2 years ago[LLDB][Clang] add AccessSpecDecl for methods and fields in RecordType
Zequan Wu [Thu, 2 Dec 2021 22:58:23 +0000 (14:58 -0800)]
[LLDB][Clang] add AccessSpecDecl for methods and fields in RecordType

This allows access type be printed when running `lldb-test -dump-ast` and
`lldb-test -dump-clang-ast`.

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

2 years ago[Hexagon] HVX .new store uses different resources
SANTANU DAS [Tue, 3 Aug 2021 15:57:56 +0000 (21:27 +0530)]
[Hexagon] HVX .new store uses different resources

When checking resources in the post RA scheduler, see if a .new
vector store should be used instead of a regular vector store.

It may not be possible to schedule a regular vector store, but
it may be possible to schedule a .new version. If the correct one
isn't used, then the post RA scheduler may not generate the best
schedule.

2 years ago[libc++] Implement `ranges::{cbegin,cend}` per the spec.
Arthur O'Dwyer [Thu, 23 Dec 2021 03:36:42 +0000 (22:36 -0500)]
[libc++] Implement `ranges::{cbegin,cend}` per the spec.

The big change here is that they now work as intended for rvalues,
e.g. `ranges::cbegin(std::string_view("hello"))`.
Also, add tests verifying their return types.

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

2 years ago[Hexagon] Refactor updateLatency() function
Ikhlas Ajbar [Tue, 4 Jan 2022 20:58:04 +0000 (12:58 -0800)]
[Hexagon] Refactor updateLatency() function

Co-authored-by: Sumanth Gundapaneni <sgundapa@quicinc.com>
2 years ago[libc++] Fix whitespace in __partial_sort. NFC.
Arthur O'Dwyer [Tue, 4 Jan 2022 21:15:02 +0000 (16:15 -0500)]
[libc++] Fix whitespace in __partial_sort. NFC.

2 years ago[libc++] Add an early return for __partial_sort of an empty range.
Arthur O'Dwyer [Mon, 27 Dec 2021 03:57:46 +0000 (22:57 -0500)]
[libc++] Add an early return for __partial_sort of an empty range.

If `__first == __middle`, then `partial_sort` is a no-op; don't
bother to iterate all the way from `__middle` to `__end`.

Fixes #49431.

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

2 years ago[Sema] Fix the assertion in Sema::ActOnDependentMemberExpr
Yuanfang Chen [Tue, 4 Jan 2022 20:11:33 +0000 (12:11 -0800)]
[Sema] Fix the assertion in Sema::ActOnDependentMemberExpr

617007240cbfb97c introduced the use of ActOnDependentMemberExpr with
variable template specialization. The assertion inside
ActOnDependentMemberExpr should be adjusted accordingly.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47211

Reviewed By: aaron.ballman

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

2 years ago[clang][ObjC] Add fix it for missing methods in impl
David Goldman [Thu, 30 Dec 2021 17:31:59 +0000 (12:31 -0500)]
[clang][ObjC] Add fix it for missing methods in impl

We suggest inserting the method with an empty body at the end
of the implementation decl.

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

2 years ago[flang][openacc] Remove unused variable. NFC.
Benjamin Kramer [Tue, 4 Jan 2022 20:47:28 +0000 (21:47 +0100)]
[flang][openacc] Remove unused variable. NFC.

2 years ago[LegalizeIntegerTypes][RISCV] Teach PromoteSetCCOperands to check sign bits of unsign...
Craig Topper [Tue, 4 Jan 2022 20:23:17 +0000 (12:23 -0800)]
[LegalizeIntegerTypes][RISCV] Teach PromoteSetCCOperands to check sign bits of unsigned compares.

Unsigned compares work with either zero extended or sign extended
inputs just like equality comparisons. I didn't allow this when
I refactored the code in D116421 due to lack of tests. But I've
since found a simple C test case that demonstrates when this can be
useful.

Reviewed By: efriedma

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

2 years ago[Hexagon] Update latencies on REG_SEQUENCE/COPY based on successors.
Sumanth Gundapaneni [Tue, 4 Jan 2022 20:26:34 +0000 (12:26 -0800)]
[Hexagon] Update latencies on REG_SEQUENCE/COPY based on successors.

If there are multiple uses of the def of COPY/REG_SEQUENCE, set the
latency only if the latencies on all the uses are equal, otherwise set
it to default.

2 years ago[DebugInfo] Avoid triggering global location assert for 2-byte pointer sizes.
Jack Andersen [Tue, 4 Jan 2022 20:16:36 +0000 (15:16 -0500)]
[DebugInfo] Avoid triggering global location assert for 2-byte pointer sizes.

D111404 moved a 4/8 byte check assert into a block taken by 2-byte platforms.
Since these platforms do not take the branches where the pointer size is used,
sink the assert accordingly.

Reviewed By: dblaikie

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

2 years ago[mlir] Make Value's constructor constexpr. NFCI.
Benjamin Kramer [Mon, 3 Jan 2022 15:45:08 +0000 (16:45 +0100)]
[mlir] Make Value's constructor constexpr. NFCI.

This allows clang to flag unused Values in more cases, so remove them.

2 years agoprecommit tests for a planned followon to D116200
Philip Reames [Tue, 4 Jan 2022 20:02:07 +0000 (12:02 -0800)]
precommit tests for a planned followon to D116200

2 years ago[PS4] Verify the default DWARF version is 4.
Paul Robinson [Tue, 4 Jan 2022 19:56:42 +0000 (11:56 -0800)]
[PS4] Verify the default DWARF version is 4.

Follow-up to b8e03be. Even if Clang's generic default DWARF version
bumps up, PS4 will stay on v4.

2 years agoprecommit additional tests for D116200
Philip Reames [Tue, 4 Jan 2022 19:44:56 +0000 (11:44 -0800)]
precommit additional tests for D116200

2 years ago[Hexagon] Fix an instruction move in HexagonVectorCombine
Brendon Cahoon [Tue, 4 Jan 2022 19:40:30 +0000 (11:40 -0800)]
[Hexagon] Fix an instruction move in HexagonVectorCombine

The HexagonVectorCombine pass was moving an instruction
incorrectly, which caused a use in a GEP that was not yet
defined.

HexagonVectorCombine removes a load from a group due to its
dependences, but in realignGroup, the load is processed anyways.
In realignGroup, when determining the maximum alignment, only
those instructions still in the group should be considered.

2 years ago[libc++] Remove incorrect default constructor in cpp17_input_iterator
Louis Dionne [Wed, 15 Dec 2021 16:26:47 +0000 (11:26 -0500)]
[libc++] Remove incorrect default constructor in cpp17_input_iterator

AFAICT, Cpp17InputIterators are not required to be default constructible,
since that requirement is added in Cpp17ForwardIterator. Hence, our
archetype for Cpp17InputIterator should not be default constructible.
Removing that constructor has a ripple effect on a couple of tests that
were making incorrect assumptions. Notably:

- Some tests were using cpp17_input_iterator as a sentinel for itself.
  That is not valid, because a cpp17_input_iterator is not semiregular
  anymore after the change (and hence it doesn't satisfy sentinel_for).

- Some tests were using a stride-counted cpp17_input_iterator as the
  sentinel for a range. This doesn't work anymore because of the problem
  above, so these tests were changed not to check stride counts for
  input iterators.

- Some tests were default constructing cpp17_input_iterator when a simple
  alternative was available -- those have been changed to use that alternative.

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

2 years ago[libc++] [test] Add tests for std::span construction from initializer lists.
Arthur O'Dwyer [Sun, 3 Oct 2021 04:54:18 +0000 (00:54 -0400)]
[libc++] [test] Add tests for std::span construction from initializer lists.

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

2 years ago[Hexagon] Fix buildVector32 for v4i8 constants
Tasmia Rahman [Tue, 4 Jan 2022 19:18:13 +0000 (11:18 -0800)]
[Hexagon] Fix buildVector32 for v4i8 constants

The code for constructing a 32-bit constant from 4 8-bit constants has
a typo and uses one of the constants twice

2 years ago[libc++] [test] Remove IFNDR uses of std::invocable.
Arthur O'Dwyer [Mon, 27 Dec 2021 02:36:33 +0000 (21:36 -0500)]
[libc++] [test] Remove IFNDR uses of std::invocable.

libstdc++'s implementation diagnoses these with hard errors.

Fixes #50059.

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

2 years ago[mlir][python] Add bindings for diagnostic handler.
Stella Laurenzo [Tue, 4 Jan 2022 00:39:58 +0000 (16:39 -0800)]
[mlir][python] Add bindings for diagnostic handler.

I considered multiple approaches for this but settled on this one because I could make the lifetime management work in a reasonably easy way (others had issues with not being able to cast to a Python reference from a C++ constructor). We could stand to have more formatting helpers, but best to get the core mechanism in first.

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

2 years ago[Hexagon] Conversions to/from FP types, HVX and scalar
Krzysztof Parzyszek [Tue, 4 Jan 2022 18:15:48 +0000 (10:15 -0800)]
[Hexagon] Conversions to/from FP types, HVX and scalar

Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
Co-authored-by: Sumanth Gundapaneni <sgundapa@quicinc.com>
2 years ago[libc++] Add the version header to all headers.
Mark de Wever [Wed, 22 Dec 2021 17:14:14 +0000 (18:14 +0100)]
[libc++] Add the version header to all headers.

Some headers which require the version header depend on other headers to
provide it. Include the version header in all top-level headers to make
sure a header cleanup can't remove the version header.

Note this doesn't add the version header to the c headers.

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years ago[libcxx] Use Fuchsia-native CPRNG for std::random_device
Roland McGrath [Sun, 2 Jan 2022 19:53:53 +0000 (11:53 -0800)]
[libcxx] Use Fuchsia-native CPRNG for std::random_device

Use the zx_cprng_draw system call directly rather than going
through the libc getentropy function.  The libc function is a
trivial wrapper around the system call, and is not a standard C
function.  Avoiding it reduces the Fuchsia libc ABI surface that
libc++ depends on.

Reviewed By: #libc, ldionne

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

2 years ago[Analysis] fix swapped operands to computeConstantRange
Sanjay Patel [Tue, 4 Jan 2022 18:11:24 +0000 (13:11 -0500)]
[Analysis] fix swapped operands to computeConstantRange

This was noted in post-commit review for D116322 / 0edf99950e6 .

I am not seeing how to expose the bug in a test though because
we don't pass an assumption cache into this analysis from there.

2 years ago[RISCV] Teach RISCVGatherScatterLowering to handle more complex recurrence start...
Craig Topper [Tue, 4 Jan 2022 18:08:03 +0000 (10:08 -0800)]
[RISCV] Teach RISCVGatherScatterLowering to handle more complex recurrence start values.

Previously we only recognized strided loads/store when the initial
value for the phi was a strided constant vector.

This patch extends the support to a strided_constant added to a
splatted value. The rewritten loop will add the splat value to the
first element of the strided constant vector to use as the scalar
start value. The stride is unaffected.

Reviewed By: frasercrmck

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

2 years ago-Wmissing-prototypes: Don't warn in named namespaces nested in anonymous namespaces
David Blaikie [Tue, 4 Jan 2022 18:07:50 +0000 (10:07 -0800)]
-Wmissing-prototypes: Don't warn in named namespaces nested in anonymous namespaces

2 years agoFix altivec regression caused by D115670 in Vec Const Eval
Erich Keane [Tue, 4 Jan 2022 17:28:22 +0000 (09:28 -0800)]
Fix altivec regression caused by D115670 in Vec Const Eval

The Vector Constant Evaluator assumes that all the types of its
sub-expressions are going to be Vector APValues, which holds for most
situations.  However, in the 1 examples of Altivec C compilation of
operator ++ (not allowed for other vector types), the result is an
LValue.

Since the operator isn't supported for constant evaluation anyway, this
patch just fails-out of constant eval if we are in a situation where the
operand to the unary operator causes an LValue.

2 years ago[SCEV] Compute exit count from overflow check expressed w/ x.with.overflow intrinsics
Philip Reames [Tue, 4 Jan 2022 17:43:29 +0000 (09:43 -0800)]
[SCEV] Compute exit count from overflow check expressed w/ x.with.overflow intrinsics

This ports the logic we generate in instcombine for a single use x.with.overflow check for use in SCEV's analysis. The result is that we can prove trip counts for many checks, and (through existing logic) often discharge them.

Motivation comes from compiling a simple example with -ftrapv.

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

2 years agoAdd extra test for D116499 requested in review
Philip Reames [Tue, 4 Jan 2022 17:10:02 +0000 (09:10 -0800)]
Add extra test for D116499 requested in review

2 years ago[mlir] Fix incorrect top-level comment in DialectSparseTensor.cpp
Alex Zinenko [Tue, 4 Jan 2022 17:38:30 +0000 (18:38 +0100)]
[mlir] Fix incorrect top-level comment in DialectSparseTensor.cpp

2 years ago[llvm][cmake] never link llvm-config against llvm dylib
sternenseemann [Tue, 4 Jan 2022 17:33:29 +0000 (17:33 +0000)]
[llvm][cmake] never link llvm-config against llvm dylib

When cross-compiling, in order to make the output of the native and
cross-compiled llvm-config match, one needs to re-pass all cmake flags
relevant to BuildVariables.inc via `CROSS_TOOLCHAIN_FLAGS_NATIVE`. If
`LLVM_LINK_LLVM_DYLIB=ON` is among those, building a full `libLLVM` shared
object is required for the native llvm-config, otherwise `--shared-mode`
will be incorrect and `--link-shared` broken.

To avoid this, we can make llvm-config link statically against the
needed components for simplicity's sake in both the native and cross
case.

Reviewed By: beanz

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

2 years ago[libc++] Use std::addressof in std::function::target
Louis Dionne [Wed, 29 Dec 2021 17:24:45 +0000 (12:24 -0500)]
[libc++] Use std::addressof in std::function::target

This guards against hostile overloads of operator&. Thanks to Peter Dimov
for the report in https://github.com/boostorg/lambda/issues/24.

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

2 years ago[funcattrs] Infer writeonly argument attribute [part 2]
Philip Reames [Tue, 4 Jan 2022 16:39:51 +0000 (08:39 -0800)]
[funcattrs] Infer writeonly argument attribute [part 2]

This builds on the code from D114963, and extends it to handle calls both direct and indirect. With the revised code structure (from series of previously landed NFCs), this is pretty straight forward.

One thing to note is that we can not infer writeonly for arguments which might be captured. If the pointer can be read back by the caller, and then read through, we have no way to track that. This is the same restriction we have for readonly, except that we get no mileage out of the "callee can be readonly" exception since a writeonly param on a readonly function is either a) readnone or b) UB. This means we can't actually infer much unless nocapture has already been inferred.

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

2 years ago[regalloc] Fix GCC warning `-Wattributes`. NFC.
Michael Liao [Tue, 4 Jan 2022 17:01:21 +0000 (12:01 -0500)]
[regalloc] Fix GCC warning `-Wattributes`. NFC.

- Mark it with LLVM_LIBRARY_VISIBILITY to preserve the legacy
  visibility.

2 years ago[X86] combineSetCCMOVMSK - use APInt::getLowBitsSet to create bitmask. NFC.
Simon Pilgrim [Tue, 4 Jan 2022 16:56:33 +0000 (16:56 +0000)]
[X86] combineSetCCMOVMSK - use APInt::getLowBitsSet to create bitmask. NFC.

SelectionDAG::getConstant creates an APInt internally anyway, and getLowBitsSet helps assert for legal bitwidths. Plus it silences static analyzer out-of-bounds shift warnings.

2 years ago[mlir][ods] Handle DeclareOpInterfaceMethods in formatgen
Jacques Pienaar [Tue, 4 Jan 2022 16:28:59 +0000 (08:28 -0800)]
[mlir][ods] Handle DeclareOpInterfaceMethods in formatgen

Previously it would not consider ops with
DeclareOpInterfaceMethods<InferTypeOpInterface> as having the
InferTypeOpInterface interfaces added. The OpInterface nested inside
DeclareOpInterfaceMethods is not retained so that one could query it, so
check for the the C++ class directly (a bit raw/low level - will be
addressed in follow up).

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

2 years ago[clang-format] Add an option to add a space between operator overloading and opening...
Rajat Bajpai [Tue, 4 Jan 2022 16:19:24 +0000 (17:19 +0100)]
[clang-format] Add an option to add a space between operator overloading and opening parentheses

This change adds an option AfterOverloadedOperator in SpaceBeforeParensOptions to add a space between overloaded operator and opening parentheses in clang-format.

Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks

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

2 years ago[NFC] Expose isRematerializable and copyHint from CalcSpillWeights
Mircea Trofin [Tue, 21 Dec 2021 03:42:38 +0000 (19:42 -0800)]
[NFC] Expose isRematerializable and copyHint from CalcSpillWeights

We need to reuse them for the ML regalloc eviction advisor, as we
'explode' the weight calculation into sub-features.

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

2 years ago[AST] Produce ReturnStmt containing RecoveryExpr when type is wrong
Sam McCall [Thu, 30 Dec 2021 15:30:55 +0000 (16:30 +0100)]
[AST] Produce ReturnStmt containing RecoveryExpr when type is wrong

Previously we just drop the ReturnStmt and its argument from the AST,
which blocks analysis of broken code.

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

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

2 years ago[NFC][regalloc] Introduce RegAllocGreedy.h
Mircea Trofin [Tue, 21 Dec 2021 16:44:01 +0000 (08:44 -0800)]
[NFC][regalloc] Introduce RegAllocGreedy.h

This was suggested in D114831. It should simplify the relation between
eviction advisor and the allocator, and simplify ingesting more features
tied to the internals of the allocator, in the future.

This change simply pulls out RAGreedy, places it in the llvm namespace,
and cleans up a bit the includes in the new header file.

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

2 years agoRevert "[JITLink] Add fixup value range check"
luxufan [Tue, 4 Jan 2022 16:04:09 +0000 (00:04 +0800)]
Revert "[JITLink] Add fixup value range check"

This reverts commit 17af06ba8005d6d14b0ac79ece01ecb028de9f90.

2 years ago[InferAttrs] Add writeonly to all the math functions
Benjamin Kramer [Thu, 30 Dec 2021 22:57:21 +0000 (23:57 +0100)]
[InferAttrs] Add writeonly to all the math functions

All of these functions would be `readnone`, but can't be on platforms
where they can set `errno`. A `writeonly` function with no pointer
arguments can only write (but never read) global state.

Writeonly theoretically allows these calls to be CSE'd (a writeonly call
with the same arguments will always result in the same global stores) or
hoisted out of loops, but that's not implemented currently.

There are a few functions in this list that could be `readnone` instead
of `writeonly`, if someone is interested.

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