platform/upstream/llvm.git
2 years ago[SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both.
Florian Hahn [Fri, 6 May 2022 08:50:03 +0000 (09:50 +0100)]
[SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both.

After D97756, collectHomogenousInstGraphLoopInvariants may collect
conditions for both logical ANDs and logical ORs in case the root is a
select that matches both logical AND & OR.

This means the function won't return invariant values of either AND/OR
chains, but both. This can result in incorrect transformations.

See llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch-logical-and-or.ll.
Without the patch, Alive2 rejects the modified tests with:
    Source and target don't have the same return domain.

Note that this also applies to the test case added in D97756
(@test_partial_condition_unswitch_or_select). We can't unswitch on
%cond6, because the graph leading to it contains and AND and an OR.

This only fixes trivial unswitching for now, but a similar problem
likely exists with non-trivial unswitching.

Reviewed By: nikic

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

2 years ago[flang][driver] Add support for -save-temps
Andrzej Warzynski [Fri, 29 Apr 2022 11:48:36 +0000 (11:48 +0000)]
[flang][driver] Add support for -save-temps

This patch adds support for `-save-temps` in `flang-new`, Flang's
compiler driver. The semantics of this option are inherited from Clang.

The file extension for temporary Fortran preprocessed files is set to
`i`. This is identical to what Clang uses for C (or C++) preprocessed
files. I have tried researching what other compilers do here, but I
couldn't find any definitive answers. One GFortran thread [1] suggests
that indeed it is not clear what the right approach should be.

Normally, various phases in Clang/Flang are combined. The `-save-temps`
option works by forcing the compiler to run every phase separately. As
there is no integrated assembler driver in Flang, user will have to use
`-save-temps` together with `-fno-integrated-as`. Otherwise, an
invocation to the integrated assembler would be generated generated,
which is going to fail (i.e. something equivalent to `clang -cc1as` from
Clang).

There are no specific plans for implementing an integrated assembler for
Flang for now. One possible solution would be to share it entirely with
Clang.

Note that on Windows you will get the following error when using
`-fno-integrated-as`:
```bash
  flang-new: error: there is no external assembler that can be used on this platform
```
Unfortunately, I don't have access to a Windows machine to investigate
this. Instead, I marked the tests in this patch as unsupported on
Windows.

[1] https://gcc.gnu.org/bugzilla//show_bug.cgi?id=81615

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

2 years ago[mlir][bufferize] Do not copy buffers with undefined contents
Matthias Springer [Fri, 6 May 2022 08:30:02 +0000 (17:30 +0900)]
[mlir][bufferize] Do not copy buffers with undefined contents

Buffers with undefined contents (e.g., the result of an init_tensor) are no longer copied.

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

2 years ago[mlir][scf] Implement BufferizableOpInterface for scf::WhileOp
Matthias Springer [Fri, 6 May 2022 08:22:44 +0000 (17:22 +0900)]
[mlir][scf] Implement BufferizableOpInterface for scf::WhileOp

This follows the same implementation strategy as scf::ForOp and common functionality is extracted into helper functions.

This implementation works well in cases where each yielded value (from either body/condition region) is equivalent to the corresponding bbArg of the parent block. In that case, each OpResult of the loop may be aliasing with the corresponding OpOperand of the loop (and with no other OpOperand).

In the absence of said equivalence relationship, new buffer copies must be inserted, so that the aliasing OpOperand/OpResult contract of scf::WhileOp is honored. In essence, by yielding a newly allocated buffer, we can enforce the specified may-alias relationship. (Newly allocated buffers cannot alias with any OpOperands of the loop.)

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

2 years ago[fastregalloc] Add test case for self loop (D125079).
Luo, Yuanke [Fri, 6 May 2022 07:38:42 +0000 (15:38 +0800)]
[fastregalloc] Add test case for self loop (D125079).

2 years ago[flang] Add ExternalNameConversionPass to pass pipeline
Diana Picus [Wed, 2 Mar 2022 11:02:59 +0000 (11:02 +0000)]
[flang] Add ExternalNameConversionPass to pass pipeline

This seems to be the consensus in
https://github.com/flang-compiler/f18-llvm-project/issues/1316

The patch adds ExternalNameConversion to the default FIR CodeGen pass
pipeline, right before the FIRtoLLVM pass. It also adds a flag to
optionally disable it, and sets it in `tco`. In other words, `flang-new`
and `flang-new -fc1` will both run the pass by default, whereas `tco`
will not, so none of the tests need to be updated.

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

2 years ago[pseudo] Add fuzzer for the pseudoparser.
Sam McCall [Thu, 5 May 2022 19:20:32 +0000 (21:20 +0200)]
[pseudo] Add fuzzer for the pseudoparser.

As confirmation, running this locally found 2 crashes:
 - trivial: crashes on file with no tokens
 - lexer: hits an assertion failure on bytes: 0x5c,0xa,0x5c,0x1,0x65,0x5c,0xa

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

2 years ago[Instrumentation] Share InstrumentationIRBuilder between TSan and SanCov
Marco Elver [Fri, 6 May 2022 06:53:31 +0000 (08:53 +0200)]
[Instrumentation] Share InstrumentationIRBuilder between TSan and SanCov

Factor our InstrumentationIRBuilder and share it between ThreadSanitizer
and SanitizerCoverage. Simplify its usage at the same time (use function
of passed Instruction or BasicBlock).

This class may be used in other instrumentation passes in future.

NFCI.

Reviewed By: nickdesaulniers

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

2 years ago[VectorCombine] Fold shuffle select pattern
David Green [Fri, 6 May 2022 07:13:18 +0000 (08:13 +0100)]
[VectorCombine] Fold shuffle select pattern

This patch adds a combine to attempt to reduce the costs of certain
select-shuffle patterns. The form of code it attempts to detect is:
  %x = shuffle ...
  %y = shuffle ...
  %a = binop %x, %y
  %b = binop %x, %y
  shuffle %a, %b, selectmask

A classic select-mask will pick items from each lane of a or b. These
do not always have a great lowering on many architectures. This patch
attempts to pack a and b into the lower elements, creating a differently
ordered shuffle for reconstructing the orignal which may be better than
the select mask. This can be better for performance, especially if less
elements of a and b need to be computed and the input shuffles are
cheaper.

Because select-masks are just one form of shuffle, we generalize to any
mask. So long as the backend has decent costmodel for the shuffles, this
can generally improve things when they come up. For more basic cost
models the folds do not appear to be profitable, not getting past the
cost checks.

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

2 years ago[libcxx] [ci] Add a i386 Windows configuration to CI
Martin Storsjö [Wed, 4 May 2022 08:05:44 +0000 (11:05 +0300)]
[libcxx] [ci] Add a i386 Windows configuration to CI

Adding a mingw based config is easy in the current CI environment
(where we can just choose the different target by calling
`i686-w64-mingw32-clang`), while adding a clang-cl based config would
require setting up different environment variables pointing to the
i386 library directory.

Just adding one config (DLL) instead of exhaustively testing both
(DLL and static) as very few tests would differ in practice, to keep
the CI load reasonable.

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

2 years ago[Support] Fix UB in BumpPtrAllocator when first allocation is zero.
Sam McCall [Thu, 5 May 2022 20:54:22 +0000 (22:54 +0200)]
[Support] Fix UB in BumpPtrAllocator when first allocation is zero.

BumpPtrAllocator::Allocate() is marked __attribute__((returns_nonnull)) when the
compiler supports it, which makes it UB to return null.

When there have been no allocations yet, the current slab is [nullptr, nullptr).
A zero-sized allocation fits in this range, and so Allocate(0, 1) returns null.

There's no explicit docs whether Allocate(0) is valid. I think we have to assume
that it is:
 - the implementation tries to support it (e.g. >= tests instead of >)
 - malloc(0) is allowed
 - requiring each callsite to do a check is bug-prone
 - I found real LLVM code that makes zero-sized allocations

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

2 years ago[pseudo] Only expand UCNs for raw_identifiers
Sam McCall [Thu, 5 May 2022 22:15:07 +0000 (00:15 +0200)]
[pseudo] Only expand UCNs for raw_identifiers

It turns out clang::expandUCNs only works on tokens that contain valid UCNs
and no other random escapes, and clang only uses it on raw_identifiers.

Currently we can hit an assertion by creating tokens with stray non-valid-UCN
backslashes in them.

Fortunately, expanding UCNs in raw_identifiers is actually all we need.
Most tokens (keywords, punctuation) can't have them. UCNs in literals can be
treated as escape sequences like \n even this isn't the standard's
interpretation. This more or less matches how clang works.
(See https://isocpp.org/files/papers/P2194R0.pdf which points out that the
standard's description of how UCNs work is misaligned with real implementations)

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

2 years ago[Lex] Don't assert when decoding invalid UCNs.
Sam McCall [Thu, 5 May 2022 23:44:41 +0000 (01:44 +0200)]
[Lex] Don't assert when decoding invalid UCNs.

Currently if a lexically-valid UCN encodes an invalid codepoint, then we
diagnose that, and then hit an assertion while trying to decode it.

Since there isn't anything preventing us reaching this state, remove the
assertion. expandUCNs("X\UAAAAAAAAY") will produce "XY".

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

2 years ago[AVR][NFC] Eliminate warning 'unused variable'
Ben Shi [Fri, 6 May 2022 06:10:37 +0000 (06:10 +0000)]
[AVR][NFC] Eliminate warning 'unused variable'

Reviewed By: Patryk27, aykevl

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

2 years ago[Coroutines] Don't re-materialize for debug instructions
Chuanqi Xu [Fri, 6 May 2022 05:50:08 +0000 (13:50 +0800)]
[Coroutines] Don't re-materialize for debug instructions

Re-materialize for debug instructions would cause a different code
generated if we enabled `-g`. This is bad. So we disable to
re-materialize for debug instructions.

2 years agoApply clang-tidy fixes for llvm-else-after-return in OpenMPDialect.cpp (NFC)
Mehdi Amini [Thu, 5 May 2022 23:01:50 +0000 (23:01 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in OpenMPDialect.cpp (NFC)

2 years agoApply clang-tidy fixes for bugprone-argument-comment in AffineOps.cpp (NFC)
Mehdi Amini [Thu, 5 May 2022 22:37:00 +0000 (22:37 +0000)]
Apply clang-tidy fixes for bugprone-argument-comment in AffineOps.cpp (NFC)

2 years ago[InstCombine] precommit tests for D124590
Chenbing Zheng [Fri, 6 May 2022 02:53:12 +0000 (10:53 +0800)]
[InstCombine] precommit tests for D124590

2 years ago[InstCombine] try to narrow more shifted bswap-of-zext
Chenbing Zheng [Fri, 6 May 2022 02:45:10 +0000 (10:45 +0800)]
[InstCombine] try to narrow more shifted bswap-of-zext

Try to narrow more bswap, if the shift amount is less than the zext
(bswap (zext X)) >> C --> (zext (bswap X)) << C'

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

Reviewed By: RKSimon

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

2 years ago[clang][NFC] In parts of Objective-C Sema use Obj-C-specific types instead of `Decl`.
Volodymyr Sapsai [Thu, 31 Mar 2022 18:06:42 +0000 (11:06 -0700)]
[clang][NFC] In parts of Objective-C Sema use Obj-C-specific types instead of `Decl`.

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

2 years ago[RISCV][SelectionDAG] Support VP_REDUCE_ADD mask operation.
Lian Wang [Thu, 5 May 2022 06:30:12 +0000 (06:30 +0000)]
[RISCV][SelectionDAG] Support VP_REDUCE_ADD mask operation.

Reviewed By: craig.topper

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

2 years agoXFAIL some PGO tests on AIX until the new linker becomes publicly available.
Wael Yehia [Fri, 6 May 2022 00:08:34 +0000 (20:08 -0400)]
XFAIL some PGO tests on AIX until the new linker becomes publicly available.

2 years agoInsert crashing stack frame when call to null func ptr
Jason Molenda [Fri, 6 May 2022 00:53:43 +0000 (17:53 -0700)]
Insert crashing stack frame when call to null func ptr

On arm64 targets, when the crashing pc is 0, the caller
frame can be found by looking at $lr, but the crash
reports don't use that trick to show the actual crashing
frame.  This patch adds that stack frame that lldb shows.

Also fix an issue where some register names were printed
as having a prefix of 'None'.

Differential Revision: https://reviews.llvm.org/D125042
rdar://92631787

2 years ago[gn build] (semi-manually) port 70a66c08fc65
Nico Weber [Fri, 6 May 2022 00:34:49 +0000 (20:34 -0400)]
[gn build] (semi-manually) port 70a66c08fc65

2 years ago[NFC][test] Replace hardcoded number with numeric substitution blocks
Sheng [Fri, 6 May 2022 00:04:52 +0000 (08:04 +0800)]
[NFC][test] Replace hardcoded number with numeric substitution blocks

In VarLenDecoder.td, the opcode in CHECK line is hardcoded, which
causes chaos in several downstream projects. This patch is trying
to fix that.

2 years ago[mlir] Fix printer when it is a DenseElementsAttr of i1
Chengji Yao [Thu, 5 May 2022 23:29:33 +0000 (16:29 -0700)]
[mlir] Fix printer when it is a DenseElementsAttr of i1

A large DenseElementsAttr of i1could trigger a bug in printer/parser roundtrip.

Ex. A DenseElementsAttr of i1 with 200 elements will print as Hex format of length 400 before the fix. However, when parsing the printed text, an error will be triggered. After fix, the printed length will be 50.

Reviewed By: rriddle

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

2 years ago[HWASan] Clean up hwasan_symbolize.
Florian Mayer [Thu, 5 May 2022 18:51:53 +0000 (11:51 -0700)]
[HWASan] Clean up hwasan_symbolize.

The globals are better expressed as members of the Symbolizer, and all
functions operating on it should be methods instead.

Also using the standard idiom of wrapping the main code in
`if __name__ == '__main__'`.

Reviewed By: eugenis

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

2 years ago[HWASan] Allow to linkify symbolizer output.
Florian Mayer [Tue, 3 May 2022 22:12:30 +0000 (15:12 -0700)]
[HWASan] Allow to linkify symbolizer output.

Reviewed By: eugenis

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

2 years ago[compiler-rt][builtins] Add helper functions for uint16/sint16/uint8/sint8 div and mod
Ben Shi [Thu, 5 May 2022 07:35:09 +0000 (07:35 +0000)]
[compiler-rt][builtins] Add helper functions for uint16/sint16/uint8/sint8 div and mod

__udivmodhi4 : uint16 div and mod
__udivmodqi4 : uint8 div and mod
__divmodhi4  : sint16 div and mod
__divmodqi4  : sint8 div and mod

The above helper functions in libgcc have special ABI as described at
https://gcc.gnu.org/wiki/avr-gcc#Exceptions_to_the_Calling_Convention .

Reviewed By: aykevl

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

2 years ago[SPIRV] Add SPIR-V specific intrinsics, two passes and tests
Ilia Diachkov [Thu, 5 May 2022 20:29:26 +0000 (23:29 +0300)]
[SPIRV] Add SPIR-V specific intrinsics, two passes and tests

The patch adds SPIR-V specific intrinsics required to keep information
critical to SPIR-V consistency (types, constants, etc.) during translation
from IR to MIR.

Two related passes (SPIRVEmitIntrinsics and SPIRVPreLegalizer) and several
LIT tests (passed with this change) have also been added.

It also fixes the issue with opaque pointers in SPIRVGlobalRegistry.cpp
and the mismatch of the data layout between the SPIR-V backend and clang
(Issue #55122).

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[docs] Fix uses of `foo` that should be ``foo`` throughout release notes.
Richard Smith [Thu, 5 May 2022 23:04:19 +0000 (16:04 -0700)]
[docs] Fix uses of `foo` that should be ``foo`` throughout release notes.

2 years ago[docs] Add blank lines to help Sphinx parse nested bullets.
Richard Smith [Thu, 5 May 2022 22:57:17 +0000 (15:57 -0700)]
[docs] Add blank lines to help Sphinx parse nested bullets.

2 years agoRevert "Pedantically warn about // comments in gnu89 mode"
Aaron Ballman [Thu, 5 May 2022 22:39:13 +0000 (18:39 -0400)]
Revert "Pedantically warn about // comments in gnu89 mode"

This reverts commit f6dff93641b2259623e686eb13a1884b8b9f4a00.

This diagnostic is also in the -Wcomment group, which is in the -Wall
group, so the diagnostic is enabled in a wider context than GCC does.
That turns out to be disruptive for the Linux kernel builds still using
-std=gnu89 because the kernel requires C source files to start with //
comments: https://kernel.org/doc/html/v5.18-rc5/process/license-rules.html#license-identifier-syntax

2 years ago[mlir][sparse] add more zero-preserving unary ops to sparse compiler
Aart Bik [Thu, 5 May 2022 21:02:03 +0000 (14:02 -0700)]
[mlir][sparse] add more zero-preserving unary ops to sparse compiler

Although we now have semi-rings to deal with arbitrary ops,
it is still good to convey zero-preserving semantics of
ops to the sparse compiler.

Reviewed By: bixia

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

2 years ago[flang] Change "unsupported" messages in the runtime to "not yet implemented"
Peter Steinfeld [Thu, 5 May 2022 21:54:57 +0000 (14:54 -0700)]
[flang] Change "unsupported" messages in the runtime to "not yet implemented"

If a programmer is able to compile and link a program that contains types that
are not yet supported by the runtime, it must be because they're not yet
implemented.

This change will make it easier to find unimplemented code in tests.

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

2 years ago[clang-format][NFC] Add a few regression tests
owenca [Thu, 5 May 2022 22:02:34 +0000 (15:02 -0700)]
[clang-format][NFC] Add a few regression tests

2 years ago[mlir] Add a better error message when failing to parse an attribute
River Riddle [Tue, 3 May 2022 19:54:31 +0000 (12:54 -0700)]
[mlir] Add a better error message when failing to parse an attribute

The fallback attribute parse path is parsing a Type attribute, but this results
in a really unintuitive error message: `expected non-function type`, which
doesn't really hint at tall that we were trying to parse an attribute. This
commit fixes this by trying to optionally parse a type, and on failure
emitting an error that we were expecting an attribute.

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

2 years ago[BOLT][DWARF] Add version 5 split dwarf support
Alexander Yermolovich [Thu, 5 May 2022 21:57:14 +0000 (14:57 -0700)]
[BOLT][DWARF] Add version 5 split dwarf support

Added support for DWARF5 Split Dwarf.

Reviewed By: maksfb

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

2 years agoReimplement `__builtin_dump_struct` in Sema.
Richard Smith [Thu, 5 May 2022 21:52:57 +0000 (14:52 -0700)]
Reimplement `__builtin_dump_struct` in Sema.

Compared to the old implementation:

* In C++, we only recurse into aggregate classes.
* Unnamed bit-fields are not printed.
* Constant evaluation is supported.
* Proper conversion is done when passing arguments through `...`.
* Additional arguments are supported and are injected prior to the
  format string; this directly supports use with `fprintf`, for example.
* An arbitrary callable can be passed rather than only a function
  pointer. In particular, in C++, a function template or overload set is
  acceptable.
* All text generated by Clang is printed via `%s` rather than directly;
  this avoids issues where Clang's pretty-printing output might itself
  contain a `%` character.
* Fields of types that we don't know how to print are printed with a
  `"*%p"` format and passed by address to the print function.
* No return value is produced.

Reviewed By: aaron.ballman, erichkeane, yihanaa

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

2 years ago[clang-format] Fix another bug in AlignConsecutiveAssignments
owenca [Wed, 4 May 2022 19:25:22 +0000 (12:25 -0700)]
[clang-format] Fix another bug in AlignConsecutiveAssignments

The ShouldShiftBeAdded lambda checks if extra space should be
added before the wrapped part of a braced list. If the first
element of the list is wrapped, no extra space should be added.

Fixes #55161.

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

2 years ago[mlir:ExecutionEngine] Update use of getAddress now that lookup returns ExecutorAddr
River Riddle [Thu, 5 May 2022 21:21:03 +0000 (14:21 -0700)]
[mlir:ExecutionEngine] Update use of getAddress now that lookup returns ExecutorAddr

This was changed in 16dcbb53dc7968a3752661aac731172ebe0faf64

2 years agoDecr return pc mid-stack when picking UnwindPlan row
Jason Molenda [Thu, 5 May 2022 21:13:23 +0000 (14:13 -0700)]
Decr return pc mid-stack when picking UnwindPlan row

When picking the UnwindPlan row to use to backtrace,
off of the zeroth frame, decrement the return pc so
we're in the address range of the call instruction.
If this is a noretrun function call, the instruction
at the "return address" is likely an entirely different
basic block with possibly very different unwind rules,
and this can cause the backtrace to be incorrect.

Differential Revision: https://reviews.llvm.org/D124957
rdar://84651805

2 years ago[GlobalISel] Re-generate some tests.
Amara Emerson [Thu, 5 May 2022 21:05:15 +0000 (14:05 -0700)]
[GlobalISel] Re-generate some tests.

2 years ago[ORC] Return ExecutorAddrs rather than JITEvaluatedSymbols from LLJIT::lookup.
Lang Hames [Thu, 5 May 2022 20:24:39 +0000 (13:24 -0700)]
[ORC] Return ExecutorAddrs rather than JITEvaluatedSymbols from LLJIT::lookup.

Clients don't care about linkage, and ExecutorAddr is much more ergonomic.

2 years ago[sanitizer] Correct GetTls for x32
H.J. Lu [Thu, 5 May 2022 16:49:05 +0000 (09:49 -0700)]
[sanitizer] Correct GetTls for x32

Since x32 pointer size is 4 bytes, the self pointer offset in TCB:

struct
{
  void *tcb;
  dtv_t *dtv;
  void *self;
  ...

should be 8, not 16.

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

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

2 years ago[mlir] Fix the names of exported functions
Stella Stamenova [Thu, 5 May 2022 20:46:15 +0000 (13:46 -0700)]
[mlir] Fix the names of exported functions

The names of the functions that are supposed to be exported do not match the implementations. This is due in part to https://github.com/llvm/llvm-project/commit/cac7aabbd8236bef2909bfc0dbba17644f7aaade.

This change makes the implementations and declarations match and adds a couple missing declarations.

The new names follow the pattern of the existing `verify` functions where the prefix is maintained as `_mlir_ciface_` but the suffix follows the new naming convention.

Reviewed By: rriddle

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

2 years ago[clang][dataflow] Centralize expression skipping logic
Eric Li [Wed, 4 May 2022 21:08:43 +0000 (21:08 +0000)]
[clang][dataflow] Centralize expression skipping logic

A follow-up to 62b2a47 to centralize the logic that skips expressions
that the CFG does not emit. This allows client code to avoid
sprinkling this logic everywhere.

Add redirects in the transfer function to similarly skip such
expressions by forwarding the visit to the sub-expression.

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

2 years ago[libcxx] [test] Narrow down an XFAIL for clang-cl configurations
Martin Storsjö [Thu, 5 May 2022 07:04:54 +0000 (07:04 +0000)]
[libcxx] [test] Narrow down an XFAIL for clang-cl configurations

This test only fails on x86_64 clang-cl, not for i386.

(The root cause is still not explored, thus the FIXME is still
relevant.)

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

2 years ago[libcxx] [test] Extend the UNSUPPORTED lines in strong_order_long_double.verify.cpp...
Martin Storsjö [Wed, 4 May 2022 19:05:50 +0000 (22:05 +0300)]
[libcxx] [test] Extend the UNSUPPORTED lines in strong_order_long_double.verify.cpp for non-x86_64 Windows

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

2 years ago[libcxxabi] Use the right calling convention for exception destructors on i386 Windows
Martin Storsjö [Wed, 4 May 2022 12:50:24 +0000 (15:50 +0300)]
[libcxxabi] Use the right calling convention for exception destructors on i386 Windows

On Windows on i386, C++ member functions use a different calling
convention (`__thiscall`) than the default one for regular functions
(`__cdecl`). (On Windows on architectures other than i386, both calling
convention attributes are no-ops.)

This matches how libstdc++ declares these types.

This fixes the std/thread/futures/futures.{shared,unique}_future/dtor.pass.cpp
tests on i386 mingw.

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

2 years ago[libcxx] [test] Fix max_size.pass.cpp for other Windows architectures
Martin Storsjö [Wed, 4 May 2022 11:39:21 +0000 (14:39 +0300)]
[libcxx] [test] Fix max_size.pass.cpp for other Windows architectures

All current Windows architectures (i386, x86_64, arm, arm64) get
the full_size() behaviour here. x86_64 (the only one tested in CI
currently) is handled by the first ifdef at the top, but handle
Windows in general on all other architectures later.

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

2 years ago[SelectionDAGISel] Add back a comment to MergeInputChains handling. NFC
Craig Topper [Thu, 5 May 2022 19:57:17 +0000 (12:57 -0700)]
[SelectionDAGISel] Add back a comment to MergeInputChains handling. NFC

This comment used to exist, but was lost in a refactor over 10 years
ago, but still seems relevant and improves readability.

2 years ago[ORC] Add an ExecutorAddr::toPtr overload for function types.
Lang Hames [Thu, 5 May 2022 16:20:52 +0000 (09:20 -0700)]
[ORC] Add an ExecutorAddr::toPtr overload for function types.

In the common case of converting an ExecutorAddr to a function pointer type,
this eliminates the need for the '(*)' boilerplate to explicitly specify a
function pointer. E.g.:

auto *F = A.toPtr<int(*)()>();

can now be written as

auto *F = A.toPtr<int()>();

2 years ago[X86] Add some test coverage for Issue #55271
Simon Pilgrim [Thu, 5 May 2022 19:06:09 +0000 (20:06 +0100)]
[X86] Add some test coverage for Issue #55271

We needed something that would delay the creation of the undef until after the rem-by-constant expansion, so I used a SSE shift of undef by zero which will expand to undef.

2 years ago[clang][ASTImporter][NFC]: Move clang::ImportError into own header.
phyBrackets [Mon, 2 May 2022 15:52:32 +0000 (21:22 +0530)]
[clang][ASTImporter][NFC]: Move clang::ImportError into own header.

Reviewed By: martong

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

2 years ago[BOLT] Report per-section hotness in bolt-heatmap.
Rahman Lavaee [Thu, 5 May 2022 18:37:15 +0000 (11:37 -0700)]
[BOLT] Report per-section hotness in bolt-heatmap.

This patch adds a new feature to bolt heatmap to print the hotness of each section in terms of the percentage of samples within that section.

Sample output generated for the clang binary:

Section Name, Begin Address, End Address, Percentage Hotness
.text, 0x1a7b9b0, 0x20a2cc0, 1.4709
.init, 0x20a2cc0, 0x20a2ce1, 0.0001
.fini, 0x20a2ce4, 0x20a2cf2, 0.0000
.text.unlikely, 0x20a2d00, 0x431990c, 0.3061
.text.hot, 0x4319910, 0x4bc6927, 97.2197
.text.startup, 0x4bc6930, 0x4c10c89, 0.0058
.plt, 0x4c10c90, 0x4c12010, 0.9974

Reviewed By: rafauler

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

2 years agoPedantically warn about // comments in gnu89 mode
Aaron Ballman [Thu, 5 May 2022 18:33:55 +0000 (14:33 -0400)]
Pedantically warn about // comments in gnu89 mode

GCC warns with a pedantic warning when -std=gnu89, but Clang would only
diagnose in -std=c89 mode. Clang now matches the GCC behavior in both
modes.

Fixes #18427

2 years agoFix debugserver translation check
Alexandre Perez [Mon, 2 May 2022 21:16:45 +0000 (14:16 -0700)]
Fix debugserver translation check

Currently, debugserver has a test to check if it was launched in
translation. The intent was to cover the case where an x86_64
debugserver attempts to control an arm64/arm64e process, returning
an error. However, this check also covers the case where users
are attaching to an x86_64 process, exiting out before attempting
to hand off control to the translated debugserver at
`/Library/Apple/usr/libexec/oah/debugserver`.

This diff delays the debugserver translation check until after
determining whether to hand off control to
`/Library/Apple/usr/libexec/oah/debugserver`. Only when the
process is not translated and thus has not been handed off do we
check if the debugserver is translated, erroring out in that case.

Reviewed By: jasonmolenda

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

2 years ago[VPlan] Remove dead code to create VPWidenPHIRecipes (NFCI).
Florian Hahn [Thu, 5 May 2022 18:29:02 +0000 (19:29 +0100)]
[VPlan] Remove dead code to create VPWidenPHIRecipes (NFCI).

After introducing VPWidenPointerInductionRecipe, VPWidenPHIRecipes
should not be created at this point. Turn check into an assert.

2 years agoDWARFVerifier: Verify CU/TU index overlap issues
David Blaikie [Thu, 5 May 2022 18:09:34 +0000 (18:09 +0000)]
DWARFVerifier: Verify CU/TU index overlap issues

Discovered in a large object that would need a 64 bit index (but the
cu/tu index format doesn't include a 64 bit offset/length mode in
DWARF64 - a spec bug) but instead binutils dwp overflowed the offsets
causing overlapping regions.

2 years ago[X86SchedSandyBridge] update cost of COPY to 1 cycle from 0
Nick Desaulniers [Thu, 5 May 2022 18:06:09 +0000 (11:06 -0700)]
[X86SchedSandyBridge] update cost of COPY to 1 cycle from 0

To match the cost of other scheduling models. This is expected to
schedule mov instructions around INLINEASM less frequently for the
default machineschedule (pre-RA scheduling).

Suggested by Craig Topper.

Link: https://github.com/llvm/llvm-project/issues/41914
Reviewed By: RKSimon

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

2 years agoRevert "[InstCombine] Remove side effect of replaced constrained intrinsics"
Serge Pavlov [Thu, 5 May 2022 18:05:05 +0000 (01:05 +0700)]
Revert "[InstCombine] Remove side effect of replaced constrained intrinsics"

This reverts commit 83914ee96fc2d828e1cfb8913f5d156d39150e2c.
The change caused discussion: https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20220502/1034841.html

2 years ago[libc++] Avoid a Microsoft SAL macro.
Peter Kasting [Thu, 5 May 2022 17:52:12 +0000 (19:52 +0200)]
[libc++] Avoid a Microsoft SAL macro.

Bug: https://github.com/llvm/llvm-project/issues/55195

Reviewed By: #libc, Mordante

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

2 years ago[x86][scheduler] Add MIR test for 41914
Nick Desaulniers [Thu, 5 May 2022 17:59:49 +0000 (10:59 -0700)]
[x86][scheduler] Add MIR test for 41914

Generated via:
    $ clang -fno-omit-frame-pointer -m32 -mregparm=3 -O2 crash.c -emit-llvm -S
    $ llc -print-before=machine-scheduler -mcpu=sandybridge crash.mir

Reviewed By: pengfei

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

2 years ago[flang][driver] Add missing parentheses in an assert
Andrzej Warzynski [Thu, 5 May 2022 17:58:08 +0000 (17:58 +0000)]
[flang][driver] Add missing parentheses in an assert

The assert in https://reviews.llvm.org/D124665 was missing parentheses,
which triggered a warning in GCC (verified with GCC 11). As `-Werror` is
on by default in FLang, that triggered build errors, see e.g. [1].

The fix is rather straightforward, so I am sending this without a
review.

[1] https://lab.llvm.org/buildbot/#/builders/160/builds/7016

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

2 years agoNo longer accept scoped enumerations in C
Aaron Ballman [Thu, 5 May 2022 17:53:03 +0000 (13:53 -0400)]
No longer accept scoped enumerations in C

We had a think-o that would allow a user to declare a scoped
enumeration in C language modes "as a C++11 extension". This is a
think-o because there's no way for the user to spell the name of the
enumerators; C does not have '::' for a fully-qualified name. See
commit d0d87b597259a2b74ae5c2825a081c7e336cb1d0 for details on why this
is unintentional for C.

Fixes #42372

2 years ago[AMDGPU] Split FeatureAtomicFaddInsts
Joe Nash [Thu, 14 Apr 2022 13:29:25 +0000 (09:29 -0400)]
[AMDGPU] Split FeatureAtomicFaddInsts

FeatureAtomicFaddInsts is replaced with three more granular features.
Contributors:
Petar Avramovic <Petar.Avramovic@amd.com>

Patch 3/N for upstreaming of AMDGPU gfx11 architecture

Depends on D124537

Reviewed By: foad, #amdgpu, arsenm

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

2 years ago[BOLT][CMAKE] Check build target architecture for runtime libs
Amir Ayupov [Thu, 5 May 2022 17:38:31 +0000 (10:38 -0700)]
[BOLT][CMAKE] Check build target architecture for runtime libs

Account for cross-compilation build scenarios (X86 to ARM, Linux
to Windows, etc).

Reviewed By: rafauler

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

2 years ago[mlir][nvvm] Fix support for tf32 data type in mma.sync
Christopher Bate [Wed, 4 May 2022 20:12:07 +0000 (14:12 -0600)]
[mlir][nvvm] Fix support for tf32 data type in mma.sync

The NVVM dialect test coverage for all possible type/shape combinations
in the `nvvm.mma.sync` op is mostly complete. However, there were tests
missing for TF32 datatype support. This change adds tests for the one
relevant shape/type combination. This uncovered a small bug in the op
verifier, which this change also fixes.

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

2 years ago[clangd] Fix inlayhints crash, don't assume functions have FunctionTypeLocs
Sam McCall [Thu, 5 May 2022 16:50:44 +0000 (18:50 +0200)]
[clangd] Fix inlayhints crash, don't assume functions have FunctionTypeLocs

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

2 years ago[InstCombine] fix typo in test name; NFC
Sanjay Patel [Thu, 5 May 2022 16:47:11 +0000 (12:47 -0400)]
[InstCombine] fix typo in test name; NFC

2 years ago[InstCombine] add scalable vector test for logical select; NFC
Sanjay Patel [Thu, 5 May 2022 16:41:32 +0000 (12:41 -0400)]
[InstCombine] add scalable vector test for logical select; NFC

D124997 shows that the code is not ready to handle scalable vectors,
so add some more coverage for a potential crashing case.

2 years ago[SelectionDAG] Constant fold (sext_inreg undef, VT) to 0 instead of undef.
Craig Topper [Thu, 5 May 2022 16:40:10 +0000 (09:40 -0700)]
[SelectionDAG] Constant fold (sext_inreg undef, VT) to 0 instead of undef.

The result of sign_extend_inreg needs to have as many sign bits
as requested by the VT argument. The easiest way to guarantee this
is to fold it to 0.

SystemZ test was modified to avoid using undef.

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

Reviewed By: RKSimon

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

2 years ago[flang] Fix triple in a couple of driver tests
Andrzej Warzynski [Thu, 5 May 2022 16:35:59 +0000 (16:35 +0000)]
[flang] Fix triple in a couple of driver tests

In https://reviews.llvm.org/D124667, I added tests that check the
generated assembly. I verified the assembly on AArch64 and X86_64, but
the PPC Flang buildbot [1] started failing (i.e. the assembly was not
generic enough).

In order to fix this, I'm changing these tests to be only run on
AAarch64 - that's the architecture that most of public Flang buildbots
use.

I'm hoping that this is straightforward enough and am merging it without
a review.

[1] https://lab.llvm.org/buildbot/#/builders/21/builds/40256

2 years ago[DAGCombiner] Fold (sext/zext undef) -> 0 and aext(undef) -> undef.
Craig Topper [Thu, 5 May 2022 07:19:10 +0000 (00:19 -0700)]
[DAGCombiner] Fold (sext/zext undef) -> 0 and aext(undef) -> undef.

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

2 years ago[DAGCombiner] Fold (max/min X, X) -> X.
Craig Topper [Thu, 5 May 2022 06:38:24 +0000 (23:38 -0700)]
[DAGCombiner] Fold (max/min X, X) -> X.

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

2 years ago[RISCV] Add integer min/max intrinsic tests. NFC
Craig Topper [Thu, 5 May 2022 06:37:00 +0000 (23:37 -0700)]
[RISCV] Add integer min/max intrinsic tests. NFC

Add basic tests and some tests for same operands and all undef
operands inspired by PR55271.

i32 is umin/umax is using signext to match RISC-V ABI. i8/i16 are
using signext/zeroext to match the operation.

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

2 years ago[OpenMP] libomp: Add itt notifications to sync dependent tasks.
AndreyChurbanov [Thu, 5 May 2022 16:27:48 +0000 (11:27 -0500)]
[OpenMP] libomp: Add itt notifications to sync dependent tasks.

Intel Inspector uses itt notifications to analyze code execution, and it
reports race conditions in dependent tasks.
This patch fixes the issue notifying Inspector on tasks dependency
synchronizations.

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

2 years ago[AArch64][GlobalISel] Add undef combines to postlegalizer combiner.
Amara Emerson [Thu, 5 May 2022 16:09:51 +0000 (09:09 -0700)]
[AArch64][GlobalISel] Add undef combines to postlegalizer combiner.

2 years agoSilence a false positive about an unevaluated expr w/side effects
Aaron Ballman [Thu, 5 May 2022 16:10:06 +0000 (12:10 -0400)]
Silence a false positive about an unevaluated expr w/side effects

If the operand to `sizeof` is an expression of VLA type, the operand is
still evaluated, so we should not issue a diagnostic about ignoring the
side effects in this case, as they're not actually ignored.

Fixes #48010

2 years ago[clang] Fix Clang release notes
Ilya Biryukov [Thu, 5 May 2022 16:09:23 +0000 (16:09 +0000)]
[clang] Fix Clang release notes

I have forgotten a space by mistake in the previous commit.

2 years ago[OpenMP] libomp: cleanup - remove duplicate check
AndreyChurbanov [Thu, 5 May 2022 16:00:12 +0000 (11:00 -0500)]
[OpenMP] libomp: cleanup - remove duplicate check

The identical check remains 20 lines above in the code.

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

2 years ago[OpenMP] libomp: cleanup dead code
AndreyChurbanov [Thu, 5 May 2022 15:55:52 +0000 (10:55 -0500)]
[OpenMP] libomp: cleanup dead code

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

2 years ago[Driver] Remove -fno-concept-satisfaction-caching
Ilya Biryukov [Thu, 5 May 2022 15:52:04 +0000 (15:52 +0000)]
[Driver] Remove -fno-concept-satisfaction-caching

The flag was added when the C++20 draft did not allow for concept
caching. The final C++20 standard permits the caching, so flag is
redundant. See http://wg21.link/p2104r0.

Reviewed By: sammccall

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

2 years agoFix "the the" typo in documentation and user facing strings
Brian Tracy [Thu, 5 May 2022 15:49:23 +0000 (17:49 +0200)]
Fix "the the" typo in documentation and user facing strings

There are many more instances of this pattern, but I chose to limit this change to .rst files (docs), anything in libcxx/include, and string literals. These have the highest chance of being seen by end users.

Reviewed By: #libc, Mordante, martong, ldionne

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

2 years ago[analyzer] Canonicalize SymIntExpr so the RHS is positive when possible
Tomasz Kamiński [Thu, 5 May 2022 15:48:49 +0000 (17:48 +0200)]
[analyzer] Canonicalize SymIntExpr so the RHS is positive when possible

This PR changes the `SymIntExpr` so the expression that uses a
negative value as `RHS`, for example: `x +/- (-N)`, is modeled as
`x -/+ N` instead.

This avoids producing a very large `RHS` when the symbol is cased to
an unsigned number, and as consequence makes the value more robust in
presence of casts.

Note that this change is not applied if `N` is the lowest negative
value for which negation would not be representable.

Reviewed By: steakhal

Patch By: tomasz-kaminski-sonarsource!

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

2 years ago[clang-tidy] Make header-guard check a little looser on comment whitespace
Sam McCall [Wed, 4 May 2022 19:37:24 +0000 (21:37 +0200)]
[clang-tidy] Make header-guard check a little looser on comment whitespace

Currently it rejects "//  FOO_BAR_H" as an endif comment due to the extra space.
A user complained that this is too picky, which seems fair enough.

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

2 years ago[libc++] Add a few _LIBCPP_ASSERTs in __tree
Louis Dionne [Tue, 26 Apr 2022 21:02:40 +0000 (15:02 -0600)]
[libc++] Add a few _LIBCPP_ASSERTs in __tree

Several helper functions specify preconditions as comments, but we never
check them. I ran across a bug report (without a reproducer) in this code,
and I thought that having these assertions in place would make it easier
to troubleshoot.

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

2 years ago[flang][driver] Add support for consuming LLVM IR/BC files
Andrzej Warzynski [Fri, 22 Apr 2022 09:07:31 +0000 (09:07 +0000)]
[flang][driver] Add support for consuming LLVM IR/BC files

This change makes sure that Flang's driver recognises LLVM IR and BC as
supported file formats. To this end, `isFortran` is extended and renamed
as `isSupportedByFlang` (the latter better reflects the new
functionality).

New tests are added to verify that the target triple is correctly
overridden by the frontend driver's default value or the value specified
with `-triple`. Strictly speaking, this is not a functionality that's
new in this patch (it was added in D124664). This patch simply enables
us to write such tests and hence I'm including them here.

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

2 years ago[Sema] Replace invalid FIXME about memory leak. NFC
Ilya Biryukov [Thu, 5 May 2022 15:02:36 +0000 (15:02 +0000)]
[Sema] Replace invalid FIXME about memory leak. NFC

Added in my previous patch by mistake.

2 years ago[MachinePipeliner] Fix unscheduled instruction
Thomas Preud'homme [Tue, 5 Apr 2022 21:34:40 +0000 (22:34 +0100)]
[MachinePipeliner] Fix unscheduled instruction

Prior to ordering instructions to be scheduled, the machine pipeliner
update recurrence node sets in groupRemainingNodes() by adding in a
given node set any node on the dependency path from a node set with
higher priority to the given node set. The function computePath() that
determine what constitutes a path follows artificial dependencies.

However, when ordering the nodes in the resulting node sets,
computeNodeOrder() calls ignoreDependence when looking at dependencies
which ignores artificial dependencies. This can cause a node not to be
scheduled which then causes wrong code generation and in the case of a
debug build will lead to an assert failure in generatePhis() in
ModuloScheduler.cpp.

This commit adds calls to ignoreDependence() in computePath() to not add
any node in groupRemainingNodes() that would not be ordered by
computeNodeOrder().

Reviewed By: sgundapa

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

2 years ago[PowerPC] Add extra v2i64 splat load tests. NFC
David Green [Thu, 5 May 2022 14:56:55 +0000 (15:56 +0100)]
[PowerPC] Add extra v2i64 splat load tests. NFC

In service of D123801, this add some tests targetting a v2i64 splat of a
load, and regenerates vsx_shuffle_le.ll for easier updating.

2 years ago[Driver] Make "upgrade" of -include to include-pch optional; disable in clangd
Sam McCall [Wed, 4 May 2022 23:15:28 +0000 (01:15 +0200)]
[Driver] Make "upgrade" of -include to include-pch optional; disable in clangd

If clang is passed "-include foo.h", it will rewrite to "-include-pch foo.h.pch"
before passing it to cc1, if foo.h.pch exists.

Existence is checked, but validity is not. This is probably a reasonable
assumption for the compiler itself, but not for clang-based tools where the
actual compiler may be a different version of clang, or even GCC.
In the end, we lose our -include, we gain a -include-pch that can't be used,
and the file often fails to parse.

I would like to turn this off for all non-clang invocations (i.e.
createInvocationFromCommandLine), but we have explicit tests of this behavior
for libclang and I can't work out the implications of changing it.

Instead this patch:
 - makes it optional in the driver, default on (no change)
 - makes it optional in createInvocationFromCommandLine, default on (no change)
 - changes driver to do IO through the VFS so it can be tested
 - tests the option
 - turns the option off in clangd where the problem was reported

Subsequent patches should make libclang opt in explicitly and flip the default
for all other tools. It's probably also time to extract an options struct
for createInvocationFromCommandLine.

Fixes https://github.com/clangd/clangd/issues/856
Fixes https://github.com/clangd/vscode-clangd/issues/324

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

2 years ago[riscv] Use X0 for destination of VSETVLI instruction if result unused
Philip Reames [Thu, 5 May 2022 14:35:09 +0000 (07:35 -0700)]
[riscv] Use X0 for destination of VSETVLI instruction if result unused

If the GPR destination register of a VSETVLI instruction is unused, we can replace it with X0. This discards the result, and thus reduces register pressure.

Since after the core insertion/lowering algorithm has run, many user written VSETVLIs will have their GPR result unused (as VTYPE/VLEN is now explicitly read instead), this kicks in for most tests which involve a vsetvli intrinsic for fixed length vectorization. (vscale vectorization generally uses the GPR result to know how far to e.g. advance pointers in a loop and these uses are not removed.)  When inserting VSETVLIs to lower psuedos, we prefer the X0 form anyways.

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

2 years ago[ARM][AArch64] Add some extra shuffle conversion test coverage. NFC
David Green [Thu, 5 May 2022 14:27:44 +0000 (15:27 +0100)]
[ARM][AArch64] Add some extra shuffle conversion test coverage. NFC

This adds a big endian run line for the AArch64 TRN tests and
regenerated the check lines, along with adding an extra MVE VMOVN case
and regenerating vector-DAGCombine.ll for easier updating.

2 years ago[flang][nfc] Use a message class for "not yet implemented" messages
Peter Steinfeld [Thu, 5 May 2022 01:30:22 +0000 (18:30 -0700)]
[flang][nfc] Use a message class for "not yet implemented" messages

Following a previous suggestion from Peter Klausler.

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

2 years ago[IR] Simplify code. NFCI.
Benjamin Kramer [Thu, 5 May 2022 14:05:11 +0000 (16:05 +0200)]
[IR] Simplify code. NFCI.

2 years ago[flang][driver] Re-organise the code-gen actions (nfc)
Andrzej Warzynski [Fri, 22 Apr 2022 09:07:31 +0000 (09:07 +0000)]
[flang][driver] Re-organise the code-gen actions (nfc)

All frontend actions that generate code  (MLIR, LLVM IR/BC,
Assembly/Object Code) are re-factored as essentially one action,
`CodeGenAction`, with minor specialisations. To facilate all this,
`CodeGenAction` is extended to hold `TargetMachine` and backend action
type (MLIR vs LLVM IR vs LLVM BC vs Assembly vs Object Code).

`CodeGenAction` is no longer a pure abstract class and the
corresponding `ExecuteAction` is implemented so that it covers all use
cases. All this allows a much better code re-use.

Key functionality is extracted into some helpful hooks:
  * `SetUpTargetMachine`
  * `GetOutputStream`
  * `EmitObjectCodeHelper`
  * `EmitBCHelper`
I hope that this clarifies the overall structure. I suspect that we may
need to revisit this again as the functionality grows in complexity.

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

2 years agoIn MSVC compatibility mode, handle unqualified templated base class initialization
Fred Tingaud [Thu, 5 May 2022 13:03:12 +0000 (15:03 +0200)]
In MSVC compatibility mode, handle unqualified templated base class initialization

Before C++20, MSVC was supporting not mentioning the template argument of the base class when initializing a class inheriting a templated base class.
So the following code compiled correctly:
```
template <class T>
class Base {
};

template <class T>
class Derived : public Base<T> {
public:
  Derived() : Base() {}
};

void test() {
    Derived<int> d;
}
```
See https://godbolt.org/z/Pxxe7nccx for a conformance view.

This patch adds support for such construct when in MSVC compatibility mode.

Reviewed By: rnk

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

2 years ago[ConstantFold] Use getFltSemantics instead of manually checking the type
Benjamin Kramer [Thu, 5 May 2022 13:50:33 +0000 (15:50 +0200)]
[ConstantFold] Use getFltSemantics instead of manually checking the type

Simplifies the code and makes fpext/fptrunc constant folding not crash
when the result is bf16.