platform/upstream/llvm.git
4 years ago[SyntaxTree] Add const qualifiers, from [llvm-qualified-auto]
Eduardo Caldas [Fri, 11 Sep 2020 16:33:18 +0000 (16:33 +0000)]
[SyntaxTree] Add const qualifiers, from [llvm-qualified-auto]

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

4 years ago[SyntaxTree] Reduce visibility of `Arena::lexBuffer`.
Eduardo Caldas [Fri, 11 Sep 2020 13:13:19 +0000 (13:13 +0000)]
[SyntaxTree] Reduce visibility of `Arena::lexBuffer`.

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

4 years ago[SyntaxTree][Synthesis] Add support for simple Leafs and test based on tree dump
Eduardo Caldas [Thu, 10 Sep 2020 17:54:54 +0000 (17:54 +0000)]
[SyntaxTree][Synthesis] Add support for simple Leafs and test based on tree dump

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

4 years ago[CMake][OpenMP] Simplify getting CUDA library directory
Raul Tambre [Sat, 5 Sep 2020 15:27:04 +0000 (18:27 +0300)]
[CMake][OpenMP] Simplify getting CUDA library directory

LLVM now requires CMake 3.13.4 so we can simplify this.

Reviewed By: phosek

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

4 years ago[WebAssembly] Add assembly syntax for mutable globals
Sam Clegg [Fri, 11 Sep 2020 14:20:40 +0000 (07:20 -0700)]
[WebAssembly] Add assembly syntax for mutable globals

This adds and optional ", immutable" to the end of a `.globaltype`
declaration.  I would have prefered to match the `.wat` syntax
where immutable is the default and `mut` is the signifier for
mutable globals.  Sadly changing the default would break backwards
compat with existing assembly in the wild so I think its best
to stick with this approach.

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

4 years ago[lldb/API] Add Breakpoint::SerializeToStructuredData to SBAPI
Med Ismail Bennani [Fri, 11 Sep 2020 18:09:44 +0000 (20:09 +0200)]
[lldb/API] Add Breakpoint::SerializeToStructuredData to SBAPI

This patch adds a way to fetch breakpoint metadatas as a serialized
`Structured` Data format (JSON). This can be used by IDEs to update
their UI when a breakpoint is set or modified from the console.

rdar://11013798

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
4 years ago[mlir] Fix some edge cases around 0-element TensorFromElementsOp
Sean Silva [Fri, 11 Sep 2020 05:04:58 +0000 (22:04 -0700)]
[mlir] Fix some edge cases around 0-element TensorFromElementsOp

This introduces a builder for the more general case that supports zero
elements (where the element type can't be inferred from the ValueRange,
since it might be empty).

Also, fix up some cases in ShapeToStandard lowering that hit this. It
happens very easily when dealing with shapes of 0-D tensors.

The SameOperandsAndResultElementType is redundant with the new
TypesMatchWith and prevented having zero elements.

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

4 years ago[mlir][spirv] OpConvertSToF support operands with different bitwidth.
Xin Wang [Fri, 11 Sep 2020 17:39:00 +0000 (10:39 -0700)]
[mlir][spirv] OpConvertSToF support operands with different bitwidth.

close SameBitWidth check in verifier.

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

4 years ago[SVE] Regenerate sve vector bits tests. NFC
David Green [Fri, 11 Sep 2020 17:51:57 +0000 (18:51 +0100)]
[SVE] Regenerate sve vector bits tests. NFC

4 years ago[ARM] Extra MLA reductions tests. NFC
David Green [Fri, 11 Sep 2020 16:51:15 +0000 (17:51 +0100)]
[ARM] Extra MLA reductions tests. NFC

4 years ago[FPEnv] [Clang] Enable constrained FP support for PowerPC
Qiu Chaofan [Fri, 11 Sep 2020 16:37:36 +0000 (00:37 +0800)]
[FPEnv] [Clang] Enable constrained FP support for PowerPC

d4ce862f introduced HasStrictFP to disable generating constrained FP
operations for platforms lacking support. Since work for enabling
constrained FP on PowerPC is almost done, we'd like to enable it.

Reviewed By: kpn, steven.zhang

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

4 years agoRevert "[examples] Adjust ThinLtoInstrumentationLayer for emit signature change"
Jonas Devlieghere [Fri, 11 Sep 2020 16:22:42 +0000 (09:22 -0700)]
Revert "[examples] Adjust ThinLtoInstrumentationLayer for emit signature change"

I raced with Florian and he had already reverted the original patch.

4 years ago[ELF][PowerPC] Define NOP as 0x60000000 to tidy up code. NFC
Fangrui Song [Thu, 10 Sep 2020 21:37:11 +0000 (14:37 -0700)]
[ELF][PowerPC] Define NOP as 0x60000000 to tidy up code. NFC

Reviewed By: nemanjai

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

4 years ago[DFSan] Re-enable event_callbacks test.
Matt Morehouse [Fri, 11 Sep 2020 16:13:34 +0000 (09:13 -0700)]
[DFSan] Re-enable event_callbacks test.

Mark the dest pointers for memcpy and memmove as volatile, to avoid dead
store elimination.  Fixes https://bugs.llvm.org/show_bug.cgi?id=47488.

4 years ago[docs] Fix typos
YangZhihui [Fri, 11 Sep 2020 15:51:36 +0000 (17:51 +0200)]
[docs] Fix typos

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

4 years ago[SLP] further limit bailout for load combine candidate (PR47450)
Sanjay Patel [Fri, 11 Sep 2020 15:47:23 +0000 (11:47 -0400)]
[SLP] further limit bailout for load combine candidate (PR47450)

The test example based on PR47450 shows that we can
match non-byte-sized shifts, but those won't ever be
bswap opportunities. This isn't a full fix (we'd still
match if the shifts were by 8-bits for example), but
this should be enough until there's evidence that we
need to do more (this is a borderline case for
vectorization in the first place).

4 years ago[SLP] add test for missed store vectorization; NFC
Sanjay Patel [Fri, 11 Sep 2020 15:33:41 +0000 (11:33 -0400)]
[SLP] add test for missed store vectorization; NFC

4 years ago[libcxx] Remove the 'availability' Lit feature
Louis Dionne [Fri, 11 Sep 2020 15:05:22 +0000 (11:05 -0400)]
[libcxx] Remove the 'availability' Lit feature

Instead, use with_system_cxx_lib with various compile-only tests to ensure
that we're getting compile-time errors, as expected. This follows the
lead of ec46cfefe80d5.

4 years ago[examples] Adjust ThinLtoInstrumentationLayer for emit signature change
Jonas Devlieghere [Fri, 11 Sep 2020 15:32:55 +0000 (08:32 -0700)]
[examples] Adjust ThinLtoInstrumentationLayer for emit signature change

Emit now takes a std::unique_ptr<MaterializationResponsibility> instead
of a MaterializationResponsibility directly.

This should fix:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/

4 years ago[gn build] slightly improve libcxx_needs_site_config
Nico Weber [Fri, 11 Sep 2020 15:32:17 +0000 (11:32 -0400)]
[gn build] slightly improve libcxx_needs_site_config

The write_cmake_config() here still looks busted, but at least
the value that's explicitly set is now set correctly.

4 years ago[flang] Fix build issue with BUILD_SHARED_LIBS=ON
Richard Barton [Fri, 11 Sep 2020 14:46:39 +0000 (15:46 +0100)]
[flang] Fix build issue with BUILD_SHARED_LIBS=ON

Define Fortran::Semantics::Scope::GetName in the header so it is available
to Fortran::Evaluate::Tool::AttachDeclaration without a circular dependency
introduced in 82edd42.

Reviewed By: tskeith

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

4 years ago[NFC] Follow up on D87111 - Add an option for unrolling loops up to a factor - CR...
Lubomir Litchev [Tue, 8 Sep 2020 18:50:08 +0000 (11:50 -0700)]
[NFC] Follow up on D87111 - Add an option for unrolling loops up to a factor - CR issues addressed.

Addressed some CR issues pointed out in D87111. Formatting and other nits.
The original Diff D87111 - Add an option for unrolling loops up to a factor.

Reviewed By: bondhugula

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

4 years ago[DSE] Make sure that DSE+MSSA can handle masked stores
Krzysztof Parzyszek [Wed, 9 Sep 2020 20:23:34 +0000 (15:23 -0500)]
[DSE] Make sure that DSE+MSSA can handle masked stores

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

4 years agoRevert "[InstCombine] propagate 'nsw' on pointer difference of 'inbounds' geps (PR47430)"
Sanjay Patel [Fri, 11 Sep 2020 14:51:14 +0000 (10:51 -0400)]
Revert "[InstCombine] propagate 'nsw' on pointer difference of 'inbounds' geps (PR47430)"

This reverts commit 324a53205a3af979e3de109fdd52f91781816cba.

On closer examination of at least one of the test diffs,
this does not appear to be correct in all cases. Even the
existing 'nsw' creation may be wrong based on this example:
https://alive2.llvm.org/ce/z/uL4Hw9
https://alive2.llvm.org/ce/z/fJMKQS

4 years ago[SyntaxTree] Rename functions to start with verb
Eduardo Caldas [Fri, 11 Sep 2020 08:56:10 +0000 (08:56 +0000)]
[SyntaxTree] Rename functions to start with verb

According to LLVM coding standards:
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly

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

4 years ago[InstCombine] propagate 'nsw' on pointer difference of 'inbounds' geps (PR47430)
Sanjay Patel [Thu, 10 Sep 2020 21:09:36 +0000 (17:09 -0400)]
[InstCombine] propagate 'nsw' on pointer difference of 'inbounds' geps (PR47430)

There's no signed wrap if both geps have 'inbounds':
https://alive2.llvm.org/ce/z/nZkQTg
https://alive2.llvm.org/ce/z/7qFauh

4 years ago[InstCombine] add/move tests for ptr diff; NFC
Sanjay Patel [Thu, 10 Sep 2020 20:38:12 +0000 (16:38 -0400)]
[InstCombine] add/move tests for ptr diff; NFC

4 years ago[LiveDebugValues][NFC] Add additional tests
Jeremy Morse [Fri, 11 Sep 2020 14:30:52 +0000 (15:30 +0100)]
[LiveDebugValues][NFC] Add additional tests

These were supposed to be in 0caeaff1237 and D83054, but a fat-fingered
error when git-adding missed them. Ooops.

4 years ago[NFC] Fix compiler warnings due to integer comparison of different signedness
Simon Pilgrim [Fri, 11 Sep 2020 14:32:03 +0000 (15:32 +0100)]
[NFC] Fix compiler warnings due to integer comparison of different signedness

Fix by directly using INT_MAX and INT32_MAX.

Patch by: @nullptr.cpp (Yang Fan)

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

4 years ago[libc++] NFC: Add missing license to test
Louis Dionne [Wed, 26 Aug 2020 14:43:05 +0000 (10:43 -0400)]
[libc++] NFC: Add missing license to test

4 years ago[analyzer][NFC] Don't bind values to ObjCForCollectionStmt, replace it with a GDM...
Kristóf Umann [Fri, 11 Sep 2020 13:51:25 +0000 (15:51 +0200)]
[analyzer][NFC] Don't bind values to ObjCForCollectionStmt, replace it with a GDM trait

Based on the discussion in D82598#2171312. Thanks @NoQ!

D82598 is titled "Get rid of statement liveness, because such a thing doesn't
exist", and indeed, expressions express a value, non-expression statements
don't.

if (a && get() || []{ return true; }())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ has a value
    ~ has a value
    ~~~~~~~~~~ has a value
                  ~~~~~~~~~~~~~~~~~~~~ has a value
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ doesn't have a value

That is simple enough, so it would only make sense if we only assigned symbolic
values to expressions in the static analyzer. Yet the interface checkers can
access presents, among other strange things, the following two methods:

ProgramState::BindExpr(const Stmt *S, const LocationContext *LCtx, SVal V,
                       bool Invalidate=true)
ProgramState::getSVal(const Stmt *S, const LocationContext *LCtx)

So, what gives? Turns out, we make an exception for ReturnStmt (which we'll
leave for another time) and ObjCForCollectionStmt. For any other loops, in order
to know whether we should analyze another iteration, among other things, we
evaluate it's condition. Which is a problem for ObjCForCollectionStmt, because
it simply doesn't have one (CXXForRangeStmt has an implicit one!). In its
absence, we assigned the actual statement with a concrete 1 or 0 to indicate
whether there are any more iterations left. However, this is wildly incorrect,
its just simply not true that the for statement has a value of 1 or 0, we can't
calculate its liveness because that doesn't make any sense either, so this patch
turns it into a GDM trait.

Fixing this allows us to reinstate the assert removed in
https://reviews.llvm.org/rG032b78a0762bee129f33e4255ada6d374aa70c71.

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

4 years ago[gn build] Port 8da6ae4ce1b
LLVM GN Syncbot [Fri, 11 Sep 2020 13:49:35 +0000 (13:49 +0000)]
[gn build] Port 8da6ae4ce1b

4 years agoRevert "[ConstraintSystem] Add helpers to deal with linear constraints."
Florian Hahn [Fri, 11 Sep 2020 13:48:26 +0000 (14:48 +0100)]
Revert "[ConstraintSystem] Add helpers to deal with linear constraints."

This reverts commit 3eb141e5078a0ce9d92eadc721bc49d214d23056.

This uses __builtin_mul_overflow which is not available everywhere.

4 years ago[gn build] Port 3eb141e5078
LLVM GN Syncbot [Fri, 11 Sep 2020 13:43:45 +0000 (13:43 +0000)]
[gn build] Port 3eb141e5078

4 years ago[ConstraintSystem] Add helpers to deal with linear constraints.
Florian Hahn [Fri, 11 Sep 2020 13:33:06 +0000 (14:33 +0100)]
[ConstraintSystem] Add helpers to deal with linear constraints.

This patch introduces a new ConstraintSystem class, that maintains a set
of linear constraints and uses Fourier–Motzkin elimination to eliminate
constraints to check if there are solutions for the system.

It also adds a convert-constraint-log-to-z3.py script, which can parse
the debug output of the constraint system and convert it to a python
script that feeds the constraints into Z3 and checks if it produces the
same result as the LLVM implementation. This is for verification
purposes.

Reviewed By: spatel

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

4 years ago[libcxx] Handle target triples with dashes in platform name
Mikhail Maltsev [Fri, 11 Sep 2020 13:41:36 +0000 (14:41 +0100)]
[libcxx] Handle target triples with dashes in platform name

Target triples may contain a dash in the platform name (e.g.
"aarch64-arm-none-eabi"). Account for it when splitting the triple
into components.

Reviewed By: ldionne, #libc

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

4 years ago[flang] Add new documentation main page
Richard Barton [Fri, 11 Sep 2020 13:17:19 +0000 (14:17 +0100)]
[flang] Add new documentation main page

Add a new index page to be the Flang documentation mainpage instead of
Overview.md, which jumps straight into the compiler Design. The index file
needs to be in .rst format to use the toctree directive to create table of
contents.

Also use the sphinx_markdown_tables extension to generate html tables form
markdown.

A number of additional style changes to the existing docs were needed to make
this work well:
 * Convert all headings to the # style, which works better with toctree's
   titlesonly option. Ensure that there is only one top-level heading per
   document.
 * Add a title to documents that don't have one for rendering on the index.
 * Convert the grammar docs from .txt to .md. for better rendering
 * Fixed broken link to a section in another document - sphinx does not seem to
   support anchor links in markdown files.

Depends on D87226

Reviewed By: sameeranjoshi

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

4 years ago[ARM] Update arm-storebytesmerge.ll test. NFC
David Green [Fri, 11 Sep 2020 12:56:57 +0000 (13:56 +0100)]
[ARM] Update arm-storebytesmerge.ll test. NFC

This test was using a very odd combination of cortex-m7 and Neon. I have
changed it to thumbv7em only.

4 years ago[libTooling] Fix use of `char` in comparison.
Yitzhak Mandelbaum [Wed, 9 Sep 2020 19:11:47 +0000 (19:11 +0000)]
[libTooling] Fix use of `char` in comparison.

Fixes Transformer's `Range` parser to handle `char` in a platform-independent way.

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

4 years ago[MLIR][Linalg] Undo spurious parameter name change
Nicolas Vasilache [Fri, 11 Sep 2020 12:19:00 +0000 (08:19 -0400)]
[MLIR][Linalg] Undo spurious parameter name change

4 years ago[analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__
Kristóf Umann [Fri, 11 Sep 2020 11:51:54 +0000 (13:51 +0200)]
[analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__

In short, macro expansions handled the case where a variadic parameter mapped to
multiple arguments, but not the other way around. An internal ticket was
submitted that demonstrated that we fail an assertion. Macro expansion so far
worked by lexing the source code token-by-token and using the Preprocessor to
turn these tokens into identifiers or just get their proper spelling, but what
this counter intuitively doesn't do, is actually expand these macros, so we have
to do the heavy lifting -- in this case, figure out what __VA_ARGS__ expands
into. Since this case can only occur in a nested macro, the information we
gathered from the containing macro does contain this information. If a parameter
resolves to __VA_ARGS__, we need to temporarily stop getting our tokens from the
lexer, and get the tokens from what __VA_ARGS__ maps to.

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

4 years ago[mlir][Linalg] Refactor StructuredOpInterface - NFC
Nicolas Vasilache [Fri, 11 Sep 2020 10:19:07 +0000 (06:19 -0400)]
[mlir][Linalg] Refactor StructuredOpInterface - NFC

This revision refactors and cleans up a bunch of things to simplify StructuredOpInterface
before work can proceed on Linalg on tensors:
- break out pieces of the StructuredOps trait that are part of the StructuredOpInterface,
- drop referenceIterators and referenceIndexingMaps that end up being more confusing than useful,
- drop NamedStructuredOpTrait

4 years ago[analyzer][MacroExpansion][NFC] Fix a missing test output check
Kirstóf Umann [Wed, 12 Aug 2020 17:00:24 +0000 (19:00 +0200)]
[analyzer][MacroExpansion][NFC] Fix a missing test output check

4 years ago[NFC] Fix the signature and definition of findByPrefix
Andrzej Warzynski [Fri, 11 Sep 2020 11:17:51 +0000 (12:17 +0100)]
[NFC] Fix the signature and definition of findByPrefix

In https://reviews.llvm.org/rG257b29715bb27b7d9f6c3c40c481b6a4af0b37e5,
the definition of OptTable::Info::Flags was changed from `unsigned
short` to `unsigned int`, but the definition/declaration of
OptTable::findByPrefix wasn't updated to reflect that.

This patch updates findByPrefix accordingly.

4 years ago[analyzer][MacroExpansion][NFC] Fix incorrectly calling parameters arguments
Kirstóf Umann [Wed, 12 Aug 2020 15:54:49 +0000 (17:54 +0200)]
[analyzer][MacroExpansion][NFC] Fix incorrectly calling parameters arguments

4 years ago[analyzer][MacroExpansion] Add a few dumps functions
Kirstóf Umann [Wed, 12 Aug 2020 14:33:22 +0000 (16:33 +0200)]
[analyzer][MacroExpansion] Add a few dumps functions

4 years ago[LiveDebugValues][NFC] Re-land 60db26a66d, add instr-ref tests
Jeremy Morse [Fri, 11 Sep 2020 11:10:55 +0000 (12:10 +0100)]
[LiveDebugValues][NFC] Re-land 60db26a66d, add instr-ref tests

This was landed but reverted in 5b9c2b1bea7 due to asan picking up a memory
leak. This is fixed in the change to InstrRefBasedImpl.cpp. Original
commit message follows:

[LiveDebugValues][NFC] Add instr-ref tests, adapt old tests

This patch adds a few tests in DebugInfo/MIR/InstrRef/ of interesting
behaviour that the instruction referencing implementation of
LiveDebugValues has. Mostly, these tests exist to ensure that if you
give the "-experimental-debug-variable-locations" command line switch,
the right implementation runs; and to ensure it behaves the same way as
the VarLoc LiveDebugValues implementation.

I've also touched roughly 30 other tests, purely to make the tests less
rigid about what output to accept. DBG_VALUE instructions are usually
printed with a trailing !debug-location indicating its scope:

  !debug-location !1234

However InstrRefBasedLDV produces new DebugLoc instances on the fly,
meaning there sometimes isn't a numbered node when they're printed,
making the output:

  !debug-location !DILocation(line: 0, blah blah)

Which causes a ton of these tests to fail. This patch removes checks for
that final part of each DBG_VALUE instruction. None of them appear to
be actually checking the scope is correct, just that it's present, so
I don't believe there's any loss in coverage here.

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

4 years ago[IPO] Remove unnecessary Module.h includes. NFCI.
Simon Pilgrim [Fri, 11 Sep 2020 11:12:18 +0000 (12:12 +0100)]
[IPO] Remove unnecessary Module.h includes. NFCI.

Uses of Module are all implicit to PassInfoMixin<> so we can guarantee PassManager.h to handle it for us.

4 years agoAttributor.h - remove unused includes. NFCI.
Simon Pilgrim [Fri, 11 Sep 2020 10:44:03 +0000 (11:44 +0100)]
Attributor.h - remove unused includes. NFCI.

4 years agoPluginLoader.h - only include CommandLine.h if required. NFCI.
Simon Pilgrim [Fri, 11 Sep 2020 10:24:59 +0000 (11:24 +0100)]
PluginLoader.h - only include CommandLine.h if required. NFCI.

We only need this if DONT_GET_PLUGIN_LOADER_OPTION isn't defined.

4 years ago[DFSan] XFail a test that's suffering too much optimization
Jeremy Morse [Fri, 11 Sep 2020 10:22:27 +0000 (11:22 +0100)]
[DFSan] XFail a test that's suffering too much optimization

See https://bugs.llvm.org/show_bug.cgi?id=47488 , rGfb109c42d9 is
optimizing out part of this test.

4 years ago[clang][aarch64] Fix mangling of bfloat16 neon vectors
Cullen Rhodes [Thu, 10 Sep 2020 15:41:36 +0000 (15:41 +0000)]
[clang][aarch64] Fix mangling of bfloat16 neon vectors

The AAPCS64 specifies the internal type is used for c++ mangling. For
bfloat16 it was defined as `BFloat16` when it should be `Bfloat16`, i.e.
lowercase 'f'.

For more information, see:

https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-support-for-advanced-simd-extensions

Reviewed By: stuij

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

4 years ago[flang][driver] Add the new flang compiler and frontend drivers
Caroline Concatto [Fri, 11 Sep 2020 09:17:31 +0000 (10:17 +0100)]
[flang][driver] Add the new flang compiler and frontend drivers

Summary:

This is the first patch implementing the new Flang driver as outlined in [1],
[2] & [3]. It creates Flang driver (`flang-new`) and Flang frontend driver
(`flang-new -fc1`). These will be renamed as `flang` and `flang -fc1` once the
current Flang throwaway driver, `flang`, can be replaced with `flang-new`.

Currently only 2 options are supported: `-help` and `--version`.

`flang-new` is implemented in terms of libclangDriver, defaulting the driver
mode to `FlangMode` (added to libclangDriver in [4]). This ensures that the
driver runs in Flang mode regardless of the name of the binary inferred from
argv[0].

The design of the new Flang compiler and frontend drivers is inspired by it
counterparts in Clang [3]. Currently, the new Flang compiler and frontend
drivers re-use Clang libraries: clangBasic, clangDriver and clangFrontend.

To identify Flang options, this patch adds FlangOption/FC1Option enums.
Driver::printHelp is updated so that `flang-new` prints only Flang options.
The new Flang driver is disabled by default. To enable it, set
`-DBUILD_FLANG_NEW_DRIVER=ON` when configuring CMake and add clang to
`LLVM_ENABLE_PROJECTS` (e.g. -DLLVM_ENABLE_PROJECTS=“clang;flang;mlir”).

[1] “RFC: new Flang driver - next steps”
http://lists.llvm.org/pipermail/flang-dev/2020-July/000470.html
[2] “RFC: Adding a fortran mode to the clang driver for flang”
http://lists.llvm.org/pipermail/cfe-dev/2019-June/062669.html
[3] “RFC: refactoring libclangDriver/libclangFrontend to share with Flang”
http://lists.llvm.org/pipermail/cfe-dev/2020-July/066393.html
[4] https://reviews.llvm.org/rG6bf55804924d5a1d902925ad080b1a2b57c5c75c

co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com>

Reviewed By: richard.barton.arm, sameeranjoshi

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

4 years ago[clang][aarch64] Fix ILP32 ABI for arm_sve_vector_bits
Cullen Rhodes [Tue, 8 Sep 2020 17:14:17 +0000 (17:14 +0000)]
[clang][aarch64] Fix ILP32 ABI for arm_sve_vector_bits

The element types of scalable vectors are defined in terms of stdint
types in the ACLE. This patch fixes the mapping to builtin types for the
ILP32 ABI when creating VLS types with the arm_sve_vector_bits, where
the mapping is as follows:

  int32_t -> LongTy
  int64_t -> LongLongTy
  uint32_t -> UnsignedLongTy
  uint64_t -> UnsignedLongLongTy

This is implemented by leveraging getBuiltinVectorTypeInfo which is
target agnostic since it calls ASTContext::getIntTypeForBitwidth for
integer types. The element type for svfloat16_t is changed from
Float16Ty to HalfTy when creating VLS types since this is what is used
elsewhere.

For more information, see:

https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#types-varying-by-data-model
https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-support-for-scalable-vectors

Reviewed By: efriedma

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

4 years ago[X86] Keep variables from getDataLayout/getDebugLoc calls as const reference. NFCI.
Simon Pilgrim [Fri, 11 Sep 2020 09:09:10 +0000 (10:09 +0100)]
[X86] Keep variables from getDataLayout/getDebugLoc calls as const reference. NFCI.

These are only ever used as references in the called functions, so just pass the original reference instead of copying it.

4 years agoBasicTTIImpl.h - remove unused MCSchedule.h include. NFCI.
Simon Pilgrim [Thu, 10 Sep 2020 17:03:41 +0000 (18:03 +0100)]
BasicTTIImpl.h - remove unused MCSchedule.h include. NFCI.

4 years ago[clangd][NFC] Get rid of an `else after return`
Kadir Cetinkaya [Fri, 11 Sep 2020 09:30:06 +0000 (11:30 +0200)]
[clangd][NFC] Get rid of an `else after return`

4 years ago[AMDGPU] Make movreld-bug test case more robust
Jay Foad [Fri, 11 Sep 2020 09:23:04 +0000 (10:23 +0100)]
[AMDGPU] Make movreld-bug test case more robust

Without this, future optimizer improvements can optimize the entire
function to "return 0".

4 years ago[CodeGenPrepare] Simplify code. NFCI.
Benjamin Kramer [Fri, 11 Sep 2020 09:24:08 +0000 (11:24 +0200)]
[CodeGenPrepare] Simplify code. NFCI.

4 years ago[mlir][Linalg] Print both types for linalg.transpose
Benjamin Kramer [Thu, 10 Sep 2020 15:56:15 +0000 (17:56 +0200)]
[mlir][Linalg] Print both types for linalg.transpose

Previously only the input type was printed, and the parser applied it to
both input and output, creating an invalid transpose. Print and parse
both types, and verify that they match.

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

4 years agoRevert "[ORC] Make MaterializationResponsibility immovable, pass by unique_ptr."
Florian Hahn [Fri, 11 Sep 2020 08:35:20 +0000 (09:35 +0100)]
Revert "[ORC] Make MaterializationResponsibility immovable, pass by unique_ptr."

This reverts commit c74900ca67241bf963b7a4cfa1fae8eadf6bb8cd.

This appears to be breaking some builds on macOS and has been causing
build failures on Green Dragon (see below). I am reverting this for now,
to unblock testing on Green Dragon.

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/18144/console

[65/187] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iexamples/ThinLtoJIT -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/examples/ThinLtoJIT -Iinclude -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -O3  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.9    -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT examples/ThinLtoJIT/CMakeFiles/ThinLtoJIT.dir/ThinLtoDiscoveryThread.cpp.o -MF examples/ThinLtoJIT/CMakeFiles/ThinLtoJIT.dir/ThinLtoDiscoveryThread.cpp.o.d -o examples/ThinLtoJIT/CMakeFiles/ThinLtoJIT.dir/ThinLtoDiscoveryThread.cpp.o -c /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/examples/ThinLtoJIT/ThinLtoDiscoveryThread.cpp
FAILED: examples/ThinLtoJIT/CMakeFiles/ThinLtoJIT.dir/ThinLtoDiscoveryThread.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iexamples/ThinLtoJIT -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/examples/ThinLtoJIT -Iinclude -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -O3  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.9    -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT examples/ThinLtoJIT/CMakeFiles/ThinLtoJIT.dir/ThinLtoDiscoveryThread.cpp.o -MF examples/ThinLtoJIT/CMakeFiles/ThinLtoJIT.dir/ThinLtoDiscoveryThread.cpp.o.d -o examples/ThinLtoJIT/CMakeFiles/ThinLtoJIT.dir/ThinLtoDiscoveryThread.cpp.o -c /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/examples/ThinLtoJIT/ThinLtoDiscoveryThread.cpp
In file included from /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/examples/ThinLtoJIT/ThinLtoDiscoveryThread.cpp:7:
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/examples/ThinLtoJIT/ThinLtoInstrumentationLayer.h:37:68: error: non-virtual member function marked 'override' hides virtual member function
  void emit(MaterializationResponsibility R, ThreadSafeModule TSM) override;
                                                                   ^
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Layer.h:103:16: note: hidden overloaded virtual function 'llvm::orc::IRLayer::emit' declared here: type mismatch at 1st parameter ('std::unique_ptr<MaterializationResponsibility>' vs 'llvm::orc::MaterializationResponsibility')
  virtual void emit(std::unique_ptr<MaterializationResponsibility> R,
               ^
1 error generated.

4 years ago[MC] [Win64EH] Fix builds with expensive checks enabled
Martin Storsjö [Fri, 11 Sep 2020 08:14:45 +0000 (11:14 +0300)]
[MC] [Win64EH] Fix builds with expensive checks enabled

This fixes a failed assert if expensive checks are enabled,
since 1308bb99e06752ab0b5175c92da31083f91af921.

4 years ago[mlir] Fix generation of AVX512 dialect documentation
Marius Brehler [Thu, 10 Sep 2020 15:37:56 +0000 (17:37 +0200)]
[mlir] Fix generation of AVX512 dialect documentation

This changes adjusts the documentation generation for the AVX512 dialect. The machanism to generate documentation was changed with https://github.com/llvm/llvm-project/commit/1a083f027f33f4014247df4c0e757e23d5cdab64.

Reviewed By: nicolasvasilache

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

4 years agoUncapitalize word in LanguageExtensions.rst
Guillaume Chatelet [Fri, 11 Sep 2020 08:08:02 +0000 (10:08 +0200)]
Uncapitalize word in LanguageExtensions.rst

4 years ago[clang][Sparc] Default to -mcpu=v9 for Sparc V8 on Solaris
Rainer Orth [Fri, 11 Sep 2020 07:53:19 +0000 (09:53 +0200)]
[clang][Sparc] Default to -mcpu=v9 for Sparc V8 on Solaris

As reported in Bug 42535, `clang` doesn't inline atomic ops on 32-bit
Sparc, unlike `gcc` on Solaris.  In a 1-stage build with `gcc`, only two
testcases are affected (currently `XFAIL`ed), while in a 2-stage build more
than 100 tests `FAIL` due to this issue.

The reason for this `gcc`/`clang` difference is that `gcc` on 32-bit
Solaris/SPARC defaults to `-mpcu=v9` where atomic ops are supported, unlike
with `clang`'s default of `-mcpu=v8`.  This patch changes `clang` to use
`-mcpu=v9` on 32-bit Solaris/SPARC, too.

Doing so uncovered two bugs:

`clang -m32 -mcpu=v9` chokes with any Solaris system headers included:

  /usr/include/sys/isa_defs.h:461:2: error: "Both _ILP32 and _LP64 are defined"
  #error "Both _ILP32 and _LP64 are defined"

While `clang` currently defines `__sparcv9` in a 32-bit `-mcpu=v9`
compilation, neither `gcc` nor Studio `cc` do.  In fact, the Studio 12.6
`cc(1)` man page clearly states:

            These predefinitions are valid in all modes:
  [...]
               __sparcv8 (SPARC)
               __sparcv9 (SPARC -m64)

At the same time, the patch defines `__GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248]`
for a 32-bit Sparc compilation with any V9 cpu.  I've also changed
`MaxAtomicInlineWidth` for V9, matching what `gcc` does and the Oracle
Developer Studio 12.6: C User's Guide documents (Ch. 3, Support for Atomic
Types, 3.1 Size and Alignment of Atomic C Types).

The two testcases that had been `XFAIL`ed for Bug 42535 are un-`XFAIL`ed
again.

Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

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

4 years ago[mlir][Linalg] Make LinalgBaseTilingPattern not delete the original operation.
MaheshRavishankar [Fri, 11 Sep 2020 06:56:34 +0000 (23:56 -0700)]
[mlir][Linalg] Make LinalgBaseTilingPattern not delete the original operation.

The LinalgTilingPattern class dervied from the base deletes the
original operation. This allows for the use case where the more
transformations are necessary on the original operation after
tiling. In such cases the pattern can derive from
LinalgBaseTilingPattern instead of LinalgTilingPattern.

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

4 years ago[SVE][CodeGen] Fix InlineFunction for scalable vectors
David Sherwood [Thu, 3 Sep 2020 10:57:55 +0000 (11:57 +0100)]
[SVE][CodeGen] Fix InlineFunction for scalable vectors

When inlining functions containing allocas of scalable vectors we
cannot specify the size in the lifetime markers, since we don't
know this at compile time.

Added new test here:

  test/Transforms/Inline/AArch64/sve-alloca-merge.ll

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

4 years ago[NewPM] Introduce PreserveCFG check
Yevgeny Rouban [Fri, 11 Sep 2020 05:55:24 +0000 (12:55 +0700)]
[NewPM] Introduce PreserveCFG check

Check that all passes, which report they preserve CFG,
are really preserving CFG.
A new standard instrumentation is introduced. It can be
switched on/off by the flag verify-cfg-preserved, which
is on by default for debug builds.

Reviewers: kuhar, fedor.sergeev

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

4 years ago[MC] [Win64EH] Write packed ARM64 epilogues if possible
Martin Storsjö [Mon, 7 Sep 2020 21:00:07 +0000 (00:00 +0300)]
[MC] [Win64EH] Write packed ARM64 epilogues if possible

This gives a pretty substantial size reduction; for a 6.5 MB
DLL with 300 KB .xdata, the .xdata shrinks by 66 KB.

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

4 years ago[MC] [Win64EH] Canonicalize ARM64 unwind opcodes
Martin Storsjö [Mon, 7 Sep 2020 11:45:37 +0000 (14:45 +0300)]
[MC] [Win64EH] Canonicalize ARM64 unwind opcodes

Convert 2-byte opcodes to equivalent 1-byte ones.

Adjust the existing exhaustive testcase to avoid being altered by
the simplification rules (to keep that test exercising all individual
opcodes).

Fix the assembler parser limits for register pairs; for .seh_save_regp
and .seh_save_regp_x, we can allow up to x29, for a x29+x30 pair
(which gets remapped to the UOP_SaveFPLR(X) opcodes), for .seh_save_fregp
and .seh_save_fregpx, allow up to d14+d15.

Not creating .seh_save_next for float register pairs, as the
actual unwinder implementation in current versions of Windows is buggy
for that case.

This gives a minimal but measurable size reduction. (For a 6.5 MB
DLL with 300 KB .xdata, the .xdata shrinks by 48 bytes. The opcode
sequences are padded to a 4 byte boundary, so very small improvements
might not end up mattering directly.)

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

4 years ago[CodeGen] [WinException] Remove a redundant explicit section switch for aarch64
Martin Storsjö [Thu, 10 Sep 2020 09:37:34 +0000 (12:37 +0300)]
[CodeGen] [WinException] Remove a redundant explicit section switch for aarch64

The following EmitWinEHHandlerData() implicitly switches to .xdata, just
like on x86_64.

This became orphaned from the original code requiring it in
0b61d220c9b1f0 / https://reviews.llvm.org/D61095.

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

4 years ago[Clang] Clarify __builtin_memcpy_inline documentation
Guillaume Chatelet [Thu, 10 Sep 2020 14:27:27 +0000 (14:27 +0000)]
[Clang] Clarify __builtin_memcpy_inline documentation

This patch updates the documentation about `__builtin_memcpy_inline` and reorders the sections so it is more consitent and understandable.

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

4 years ago[NFC][PowerPC] Add tests of constants-i64.
Esme-Yi [Fri, 11 Sep 2020 07:16:58 +0000 (07:16 +0000)]
[NFC][PowerPC] Add tests of constants-i64.

4 years ago[EarlyCSE] Remove unnecessary operand swap.
Michael Liao [Fri, 11 Sep 2020 05:58:11 +0000 (01:58 -0400)]
[EarlyCSE] Remove unnecessary operand swap.

- As min/max are commutative operators, there is no need to swap
  operands. That breaks the convention calculating the hash value.

4 years ago[DebugInfo] Fixing CodeView assert related to lowerBound field of DISubrange.
Alok Kumar Sharma [Fri, 11 Sep 2020 05:41:39 +0000 (11:11 +0530)]
[DebugInfo] Fixing CodeView assert related to lowerBound field of DISubrange.

    This is to fix CodeView build failure https://bugs.llvm.org/show_bug.cgi?id=47287
    after DIsSubrange upgrade D80197

    Assert condition is now removed and Count is calculated in case LowerBound
    is absent or zero and Count or UpperBound is constant. If Count is unknown
    it is later handled as VLA (currently Count is set to zero).

Reviewed By: rnk

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

4 years ago[NFC][MLInliner] Presort instruction successions.
Mircea Trofin [Fri, 11 Sep 2020 03:25:42 +0000 (20:25 -0700)]
[NFC][MLInliner] Presort instruction successions.

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

4 years agolibclc/spirv: Add missing files from D85911
Jan Vesely [Thu, 10 Sep 2020 19:43:28 +0000 (15:43 -0400)]
libclc/spirv: Add missing files from D85911

Fixes: 060c8e083dd637866854acb6a0823c45b2ef68ef
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
4 years ago[EarlyCSE] Fix and recommit the revised c9826829d74e637163fdb0351870b8204e62d6e6
Michael Liao [Fri, 11 Sep 2020 03:11:22 +0000 (23:11 -0400)]
[EarlyCSE] Fix and recommit the revised c9826829d74e637163fdb0351870b8204e62d6e6

In addition to calculate hash consistently by swapping SELECT's
operands, we also need to inverse the select pattern favor to match the
original logic.

[EarlyCSE] Equivalent SELECTs should hash equally

DenseMap<SimpleValue> assumes that, if its isEqual method returns true
for two elements, then its getHashValue method must return the same value
for them. This invariant is broken when one SELECT node is a min/max
operation, and the other can be transformed into an equivalent min/max by
inverting its predicate and swapping its operands. This patch fixes an
assertion failure that would occur intermittently while compiling the
following IR:

    define i32 @t(i32 %i) {
      %cmp = icmp sle i32 0, %i
      %twin1 = select i1 %cmp, i32 %i, i32 0
      %cmpinv = icmp sgt i32 0, %i
      %twin2 = select i1 %cmpinv,  i32 0, i32 %i
      %sink = add i32 %twin1, %twin2
      ret i32 %sink
    }

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

4 years ago[Asan] Fix __asan_update_allocation_context
Vitaly Buka [Fri, 11 Sep 2020 02:59:31 +0000 (19:59 -0700)]
[Asan] Fix __asan_update_allocation_context

Update both thread and stack.
Update thread and stack as atomic operation.
Keep all 32bit of TID as now we have enough bits.

Depends on D87135.

Reviewed By: morehouse

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

4 years agoRevert "[EarlyCSE] Equivalent SELECTs should hash equally"
Michael Liao [Fri, 11 Sep 2020 02:37:35 +0000 (22:37 -0400)]
Revert "[EarlyCSE] Equivalent SELECTs should hash equally"

This reverts commit c9826829d74e637163fdb0351870b8204e62d6e6 as it
breaks regression tests.

4 years agoRemove dependency on clangASTMatchers.
Michael Liao [Fri, 11 Sep 2020 02:16:42 +0000 (22:16 -0400)]
Remove dependency on clangASTMatchers.

- It seems no long required for shared library builds.

4 years agoscudo: Remove the THREADLOCAL macro.
Peter Collingbourne [Thu, 10 Sep 2020 19:38:42 +0000 (12:38 -0700)]
scudo: Remove the THREADLOCAL macro.

Replace all remaining uses with thread_local, which is a C++11
standard feature.

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

4 years agoscudo: Introduce a new mechanism to let Scudo access a platform-specific TLS slot
Peter Collingbourne [Wed, 9 Sep 2020 22:15:46 +0000 (15:15 -0700)]
scudo: Introduce a new mechanism to let Scudo access a platform-specific TLS slot

An upcoming change to Scudo will change how we use the TLS slot
in tsd_shared.h, which will be a little easier to deal with if
we can remove the code path that calls pthread_getspecific and
pthread_setspecific. The only known user of this code path is Fuchsia.

We can't eliminate this code path by making Fuchsia use ELF TLS
because although Fuchsia supports ELF TLS, it is not supported within
libc itself. To address this, Roland McGrath on the Fuchsia team has
proposed that Scudo will optionally call a platform-provided function
to access a TLS slot reserved for Scudo. Android also has a reserved
TLS slot, but the code that accesses the TLS slot lives in Scudo.

We can eliminate some complexity and duplicated code by having Android
use the same mechanism that was proposed for Fuchsia, which is what
this change does. A separate change to Android implements it.

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

4 years ago[mlir][Analysis] Allow Slice Analysis to work with linalg::LinalgOp
MaheshRavishankar [Thu, 10 Sep 2020 23:47:29 +0000 (16:47 -0700)]
[mlir][Analysis] Allow Slice Analysis to work with linalg::LinalgOp

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

4 years ago[lldb] Add missing LLDB_REGISTER_CONSTRUCTOR in SBPlatform
Jonas Devlieghere [Fri, 11 Sep 2020 01:48:24 +0000 (18:48 -0700)]
[lldb] Add missing LLDB_REGISTER_CONSTRUCTOR in SBPlatform

This fixes the following assertion in TestPlatformPython.py.

  Assertion failed: (id != 0 && "Forgot to add function to
  registry?")

4 years ago[obj2yaml] Add support for dumping the .debug_ranges section.
Xing GUO [Fri, 11 Sep 2020 00:42:16 +0000 (08:42 +0800)]
[obj2yaml] Add support for dumping the .debug_ranges section.

This patch adds support for dumping the .debug_ranges section to
elf2yaml.

Reviewed By: jhenderson

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

4 years agoRemove unused variable introduce in 0448d11a06b451a causing build
Zarko Todorovski [Fri, 11 Sep 2020 00:07:11 +0000 (20:07 -0400)]
Remove unused variable introduce in 0448d11a06b451a causing build
failures with -Werror on.

4 years agoFix wrong comment about enabling optimizations to work around a bug
Reid Kleckner [Thu, 10 Sep 2020 23:45:20 +0000 (16:45 -0700)]
Fix wrong comment about enabling optimizations to work around a bug

4 years ago[AArch64][GlobalISel] Don't emit a branch for a fallthrough G_BR at -O0.
Amara Emerson [Thu, 10 Sep 2020 21:57:16 +0000 (14:57 -0700)]
[AArch64][GlobalISel] Don't emit a branch for a fallthrough G_BR at -O0.

With optimizations we leave the decision to eliminate fallthrough branches to
bock placement, but at -O0 we should do it in the selector to save code size.

This regressed -O0 with a recent change to a combiner.

4 years agoUse pragmas to work around MSVC x86_32 debug miscompile bug
Reid Kleckner [Thu, 10 Sep 2020 18:23:42 +0000 (11:23 -0700)]
Use pragmas to work around MSVC x86_32 debug miscompile bug

Halide users reported this here: https://llvm.org/pr46176
I reported the issue to MSVC here:
https://developercommunity.visualstudio.com/content/problem/1179643/msvc-copies-overaligned-non-trivially-copyable-par.html

This codepath is apparently not covered by LLVM's unit tests, so I added
coverage in a unit test.

If we want to support this configuration going forward, it means that is
in general not safe to pass a SmallVector<T, N> by value if alignof(T)
is greater than 4. This doesn't appear to come up often because passing
a SmallVector by value is inefficient and not idiomatic: it copies the
inline storage. In this case, the SmallVector<LLT,4> is captured by
value by a lambda, and the lambda is passed by value into std::function,
and that's how we hit the bug.

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

4 years ago[flang] Fix assert on constant folding of extended types
Peter Steinfeld [Fri, 4 Sep 2020 15:44:52 +0000 (08:44 -0700)]
[flang] Fix assert on constant folding of extended types

When we define a derived type that extends another derived type, we can then
create a structure constructor that contains values for the fields of both the
child type and its parent.  The compiler's internal representation of that
value contains the name of the parent type where a component name would
normally appear.  This caused an assert during contant folding.

There are three cases for components that appear in structure constructors.
The first is the normal case of a component appearing in a structure
constructor for its type.

  The second is a component of the parent (or grandparent) type appearing in a
  structure constructor for the child type.

  The third is the parent type component, which can appear in the structure
  constructor of its child.

There are also cases where the component can be arrays.

I created the test case folding12.f90 that covers all of these cases and
modified the code to handle them.

Most of my changes were to the "Find()" method of the type
"StructureConstructor" where I added code to cover the second and third cases
described above.  To handle these cases, I needed to create a
"StructureConstructor" for the parent type component and return it.  To handle
returning a newly created "StructureConstructor", I changed the return type of
"Find()" to be "std::optional" rather than an ordinary pointer.

This change supersedes D86172.

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

4 years ago[ELF] Make two PPC64.cpp variables constexpr. NFC
Fangrui Song [Thu, 10 Sep 2020 21:30:00 +0000 (14:30 -0700)]
[ELF] Make two PPC64.cpp variables constexpr. NFC

Why are they mutable? :)

4 years ago[DSE] Switch to MemorySSA-backed DSE by default.
Florian Hahn [Thu, 10 Sep 2020 21:00:10 +0000 (22:00 +0100)]
[DSE] Switch to MemorySSA-backed DSE by default.

The tests have been updated and I plan to move them from the MSSA
directory up.

Some end-to-end tests needed small adjustments. One difference to the
legacy DSE is that legacy DSE also deletes trivially dead instructions
that are unrelated to memory operations. Because MemorySSA-backed DSE
just walks the MemorySSA, we only visit/check memory instructions. But
removing unrelated dead instructions is not really DSE's job and other
passes will clean up.

One noteworthy change is in llvm/test/Transforms/Coroutines/ArgAddr.ll,
but I think this comes down to legacy DSE not handling instructions that
may throw correctly in that case. To cover this with MemorySSA-backed
DSE, we need an update to llvm.coro.begin to treat it's return value to
belong to the same underlying object as the passed pointer.

There are some minor cases MemorySSA-backed DSE currently misses, e.g. related
to atomic operations, but I think those can be implemented after the switch.

This has been discussed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2020-August/144417.html

For the MultiSource/SPEC2000/SPEC2006 the number of eliminated stores
goes from ~17500 (legayc DSE) to ~26300 (MemorySSA-backed). More numbers
and details in the thread on llvm-dev.

Impact on CTMark:
```
                                     Legacy Pass Manager
                        exec instrs    size-text
O3                       + 0.60%        - 0.27%
ReleaseThinLTO           + 1.00%        - 0.42%
ReleaseLTO-g.            + 0.77%        - 0.33%
RelThinLTO (link only)   + 0.87%        - 0.42%
RelLO-g (link only)      + 0.78%        - 0.33%
```
http://llvm-compile-time-tracker.com/compare.php?from=3f22e96d95c71ded906c67067d75278efb0a2525&to=ae8be4642533ff03803967ee9d7017c0d73b0ee0&stat=instructions
```
                                     New Pass Manager
                       exec instrs.   size-text
O3                       + 0.95%       - 0.25%
ReleaseThinLTO           + 1.34%       - 0.41%
ReleaseLTO-g.            + 1.71%       - 0.35%
RelThinLTO (link only)   + 0.96%       - 0.41%
RelLO-g (link only)      + 2.21%       - 0.35%
```
http://195.201.131.214:8000/compare.php?from=3f22e96d95c71ded906c67067d75278efb0a2525&to=ae8be4642533ff03803967ee9d7017c0d73b0ee0&stat=instructions

Reviewed By: asbirlea, xbolva00, nikic

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

4 years ago[EarlyCSE] Equivalent SELECTs should hash equally
Bryan Chan [Sat, 29 Aug 2020 21:25:16 +0000 (17:25 -0400)]
[EarlyCSE] Equivalent SELECTs should hash equally

DenseMap<SimpleValue> assumes that, if its isEqual method returns true
for two elements, then its getHashValue method must return the same value
for them. This invariant is broken when one SELECT node is a min/max
operation, and the other can be transformed into an equivalent min/max by
inverting its predicate and swapping its operands. This patch fixes an
assertion failure that would occur intermittently while compiling the
following IR:

    define i32 @t(i32 %i) {
      %cmp = icmp sle i32 0, %i
      %twin1 = select i1 %cmp, i32 %i, i32 0
      %cmpinv = icmp sgt i32 0, %i
      %twin2 = select i1 %cmpinv,  i32 0, i32 %i
      %sink = add i32 %twin1, %twin2
      ret i32 %sink
    }

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

4 years ago[libc][obvious] Include Sqrt.h in SqrtLongDoubleX86.h.
Siva Chandra Reddy [Thu, 10 Sep 2020 19:39:50 +0000 (12:39 -0700)]
[libc][obvious] Include Sqrt.h in SqrtLongDoubleX86.h.

This makes SqrtLongDoubleX86.h includable by itself.

4 years ago[ORC] Make MaterializationResponsibility immovable, pass by unique_ptr.
Lang Hames [Thu, 10 Sep 2020 20:10:27 +0000 (13:10 -0700)]
[ORC] Make MaterializationResponsibility immovable, pass by unique_ptr.

Making MaterializationResponsibility instances immovable allows their
associated VModuleKeys to be updated by the ExecutionSession while the
responsibility is still in-flight. This will be used in the upcoming
removable code feature to enable safe merging of resource keys even if
there are active compiles using the keys being merged.

4 years ago[DemandedBits][BDCE] Add support for min/max intrinsics
Nikita Popov [Fri, 4 Sep 2020 20:40:46 +0000 (22:40 +0200)]
[DemandedBits][BDCE] Add support for min/max intrinsics

Add DemandedBits / BDCE support for min/max intrinsics: If the low
bits are not demanded in the result, they also aren't demanded in
the operands.

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

4 years ago[DemandedBits] Add braces to large if (NFC)
Nikita Popov [Thu, 10 Sep 2020 20:11:04 +0000 (22:11 +0200)]
[DemandedBits] Add braces to large if (NFC)

While the if only contains a single statement, it happens to be
a huge switch. Add braces to make this code easier to read.

4 years ago[InstCombine] Add more tests for select op replacement (NFC)
Nikita Popov [Thu, 10 Sep 2020 16:53:08 +0000 (18:53 +0200)]
[InstCombine] Add more tests for select op replacement (NFC)

4 years ago[InstCombine] Regenerate test checks (NFC)
Nikita Popov [Thu, 10 Sep 2020 16:51:34 +0000 (18:51 +0200)]
[InstCombine] Regenerate test checks (NFC)