platform/upstream/llvm.git
3 years ago[RISCV] When custom iseling masked stores, copy the mask into V0 instead of virtual...
Craig Topper [Tue, 6 Apr 2021 04:25:52 +0000 (21:25 -0700)]
[RISCV] When custom iseling masked stores, copy the mask into V0 instead of virtual register.

I missed a few intrinsics in 3dd4aa7d09599507d1f801ffe4bec4c9eebbb8da
when I did this for masked loads and masked segment loads/stores.

Found while trying to share more code between these custom isel
functions.

3 years agoComment adjustments for a rename
Philip Reames [Tue, 6 Apr 2021 04:05:40 +0000 (21:05 -0700)]
Comment adjustments for a rename

3 years ago[SROA] Allow SROA on pointers with invariant group intrinsic uses
Arthur Eubanks [Tue, 30 Mar 2021 00:02:41 +0000 (17:02 -0700)]
[SROA] Allow SROA on pointers with invariant group intrinsic uses

When we are able to SROA an alloca, we know all uses of it, meaning we
don't have to preserve the invariant group intrinsics and metadata.

It's possible that we could lose information regarding redundant
loads/stores, but that's unlikely to have any real impact since right
now the only user is Clang and vtables.

Reviewed By: rnk

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

3 years agoExact ashr/lshr don't loose any set bits and are thus trivially invertible
Philip Reames [Tue, 6 Apr 2021 02:21:38 +0000 (19:21 -0700)]
Exact ashr/lshr don't loose any set bits and are thus trivially invertible

Use that fact to improve isKnownNonEqual.

3 years ago[Polly] Refactoring isInnermost() from isl to use the C++ wrapper
patacca [Sat, 3 Apr 2021 22:04:52 +0000 (17:04 -0500)]
[Polly] Refactoring isInnermost() from isl to use the C++ wrapper

Polly use algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++.

Changes made:
 - Refactoring isInnermost() to take C++ bindings instead of the plain isl C api.
 - Addition of manage_copy() when needed to get the reference for the isl_ast_node object

Reviewed By: Meinersbur

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

3 years ago[libcxx] moves `std::invoke` into `__functional_base`
Christopher Di Bella [Sun, 21 Mar 2021 18:48:24 +0000 (18:48 +0000)]
[libcxx] moves `std::invoke` into `__functional_base`

Including `<concepts>` in other standard library headers (such as
`<iterator>`) creates circular dependencies due to `<functional>`.
Since `<concepts>` only needs `std::invoke` from `<functional>`, the
easiest, fastest, and cleanest way to eliminate the circular dep is to
move `std::invoke` into `__functional_base`.

This has the added advantage of `<concepts>` not transitively importing
`<functional>`.

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

3 years agoAddress minor post commit feedback on 0e59dd
Philip Reames [Tue, 6 Apr 2021 01:22:01 +0000 (18:22 -0700)]
Address minor post commit feedback on 0e59dd

3 years agoRevert "Revert "Add support for fetching signed values from tagged pointers.""
Jim Ingham [Mon, 5 Apr 2021 17:29:21 +0000 (10:29 -0700)]
Revert "Revert "Add support for fetching signed values from tagged pointers.""

This reverts commit 602ab188a7e18b97d9af95e17271e8fbee129081.

The patch replicated an lldbassert for a certain type of NSNumber for tagged
pointers.  This really shouldn't be an assert since we don't do anything wrong
with these numbers, we just don't print a summary.  So this patch changed the
lldbassert to a log message in reverting the revert.

3 years agoCopy syncscope when expanding atomicrmw into cmpxchg loop
Stanislav Mekhanoshin [Mon, 5 Apr 2021 21:45:33 +0000 (14:45 -0700)]
Copy syncscope when expanding atomicrmw into cmpxchg loop

Fixes: SWDEV-280070

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

3 years ago[RISCV] Add more RV32 vslide1up intrinsic test cases. NFC
Craig Topper [Tue, 6 Apr 2021 00:02:27 +0000 (17:02 -0700)]
[RISCV] Add more RV32 vslide1up intrinsic test cases. NFC

For some reason we only had 1 test case. This synchronizes the
test with vslide1down so we have the same number of tests for both.

3 years ago[mlir][Linalg] Add callbacks to fusion of elementwise operations to control fusion.
MaheshRavishankar [Mon, 5 Apr 2021 22:44:07 +0000 (15:44 -0700)]
[mlir][Linalg] Add callbacks to fusion of elementwise operations to control fusion.

Right now Elementwise operations fusion in Linalg fuses everything it
can. This can run up against resource limits of the target hardware
without some checks. This patch adds a callback function that clients
can use to implement a cost function. When two elementwise operations
are deemed structurally fusable, the callback can be used to control
if the fusion applies.

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

3 years ago[flang] Improve constant folding for type parameter inquiries
Peter Steinfeld [Mon, 5 Apr 2021 18:12:13 +0000 (11:12 -0700)]
[flang] Improve constant folding for type parameter inquiries

We were not folding type parameter inquiries for the form 'var%typeParam'
where 'typeParam' was a KIND or LEN type parameter of a derived type and 'var'
was a designator of the derived type.  I fixed this by adding code to the
function 'FoldOperation()' for 'TypeParamInquiry's to handle this case.  I also
cleaned up the code for the case where there is no designator.

In order to make the error messages correctly refer to both the points of
declaration and instantiation, I needed to add an argument to the function
'InstantiateIntrinsicType()' for the location of the instantiation.

I also changed the formatting of 'TypeParamInquiry' to correctly format this
case.  I also added tests for both KIND and LEN type parameter inquiries in
resolve104.f90.

Making these changes revealed an error in resolve89.f90 and caused one of the
error messages in assign04.f90 to be different.

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

3 years agoRevert "[sanitizer] Simplify GetTls with dl_iterate_phdr on Linux"
Nico Weber [Mon, 5 Apr 2021 23:00:18 +0000 (19:00 -0400)]
Revert "[sanitizer] Simplify GetTls with dl_iterate_phdr on Linux"

This reverts commit ec575e3b0a462ff7a3d23d0f39a22147606050de.
Still doesn't work, see https://crbug.com/1196037

3 years agoRework the way statement attributes are processed; NFC
Aaron Ballman [Mon, 5 Apr 2021 21:51:05 +0000 (17:51 -0400)]
Rework the way statement attributes are processed; NFC

This changes our approach to processing statement attributes to be more
similar to how we process declaration attributes. Namely,
ActOnAttributedStmt() now calls ProcessStmtAttributes() instead of
vice-versa, and there is now an interface split between building an
attributed statement where you already have a list of semantic
attributes and building an attributed statement with attributes from
the parser.

This should make it easier to support statement attributes that are
dependent on a template. In that case, you would add a
TransformFooAttr() function in TreeTransform.h to perform the semantic
checking (morally similar to how Sema::InstantiateAttrs() already works
for declaration attributes) when transforming the semantic attribute at
instantiation time.

3 years ago[mlir][sparse] move new test to right directory structure
Aart Bik [Mon, 5 Apr 2021 20:43:22 +0000 (13:43 -0700)]
[mlir][sparse] move new test to right directory structure

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

3 years ago[libcxx] [ci] Add a Windows CI buildkite configuration
Martin Storsjö [Wed, 17 Mar 2021 10:10:42 +0000 (12:10 +0200)]
[libcxx] [ci] Add a Windows CI buildkite configuration

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

3 years ago[InstSimplify] fix potential miscompile in select value equivalence
Sanjay Patel [Mon, 5 Apr 2021 20:47:29 +0000 (16:47 -0400)]
[InstSimplify] fix potential miscompile in select value equivalence

This is the sibling fix to c590a9880d7a -
as there, we can't subsitute a vector value the equality
compare replacement that we are trying requires that the
comparison is true for the entire value. Vector select
can be partly true/false.

3 years ago[InstSimplify] add test for vector select with operand replacement; NFC
Sanjay Patel [Mon, 5 Apr 2021 20:11:39 +0000 (16:11 -0400)]
[InstSimplify] add test for vector select with operand replacement; NFC

We need a sibling fix to c590a9880d7a
( https://llvm.org/PR49832 ) to avoid miscompiling.

3 years ago[OpenCL, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sun, 4 Apr 2021 07:31:41 +0000 (08:31 +0100)]
[OpenCL, test] Fix use of undef FileCheck var

Clang test CodeGenOpenCL/fpmath.cl uses a variable defined in an earlier
CHECK-NOT directive. However, by definition the pattern in that
directive is not supposed to occur so no variable will be defined. This
commit solves the issue by using a regex match with the same regex as in
the definition. It also changes the definition into a regex match since
no variable is going to be defined.

Reviewed By: yaxunl

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

3 years ago[RISCV] Add SDTCisInt to the SDTRVVSlide1 since it is only used for vslide1up.vx...
Craig Topper [Mon, 5 Apr 2021 20:03:36 +0000 (13:03 -0700)]
[RISCV] Add SDTCisInt to the SDTRVVSlide1 since it is only used for vslide1up.vx/vslide1down.vx.

The scalar type is already marked as XLenVT. The floating point
version would need a different rule.

3 years ago[RISCV] Split RISCVISD::VMV_S_XF_VL into separate integer and FP.
Craig Topper [Mon, 5 Apr 2021 19:54:49 +0000 (12:54 -0700)]
[RISCV] Split RISCVISD::VMV_S_XF_VL into separate integer and FP.

It's a bit silly, but it allows us to write stricter type
constraints for isel. There's still some extra type checks in
the generated table due to some type interference limitations
around HWMode.

3 years agoFix copy paste errors in tests from be11bd1e
Philip Reames [Mon, 5 Apr 2021 19:38:36 +0000 (12:38 -0700)]
Fix copy paste errors in tests from be11bd1e

Several of these weren't testing what was intented.

3 years agoExtract a helper for figuring out if an operator is invertible [nfc]
Philip Reames [Mon, 5 Apr 2021 19:12:16 +0000 (12:12 -0700)]
Extract a helper for figuring out if an operator is invertible [nfc]

For use in an uncoming patch.  Left out the phi case (which could otherwise fit in this framework) as it would cause infinite recursion in said patch.  We can probably also leverage this in instcombine to ensure we keep the two sets of related analysis and transforms in sync.

3 years ago[tests] Precommmit tests for reasoning about equality of recurrences
Philip Reames [Mon, 5 Apr 2021 17:24:35 +0000 (10:24 -0700)]
[tests] Precommmit tests for reasoning about equality of recurrences

3 years ago[RISCV] Move VSLIDE1UP_VX pattern out of a loop that includes FP types.
Craig Topper [Mon, 5 Apr 2021 18:52:41 +0000 (11:52 -0700)]
[RISCV] Move VSLIDE1UP_VX pattern out of a loop that includes FP types.

FP would need VFSLIDE1UP_VF which uses an FP register.

3 years ago[M68k] Add support for Motorola literal syntax to AsmParser
Ricky Taylor [Tue, 26 Jan 2021 14:51:50 +0000 (14:51 +0000)]
[M68k] Add support for Motorola literal syntax to AsmParser

These look like $00A0cf for hex and  %001010101 for binary. They are used in Motorola assembly syntax.

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

3 years ago[OPENMP51]Initial support for nocontext clause.
Jennifer Yu [Sat, 3 Apr 2021 18:09:25 +0000 (11:09 -0700)]
[OPENMP51]Initial support for nocontext clause.

Added basic parsing/sema/serialization support for the 'nocontext' clause.

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

3 years ago[mlir][Linalg] NFC: Move populatePatterns* method into linalg namespace.
MaheshRavishankar [Mon, 5 Apr 2021 17:54:59 +0000 (10:54 -0700)]
[mlir][Linalg] NFC: Move populatePatterns* method into linalg namespace.

The moved `populate` methods are only relevant to Linalg
operations. So they are better of in `linalg` namespace.  Also rename
`populateLinalgTensorOpsFusionPatterns` to
`populateElementwiseOpsFusionPatterns`. This makes the scope of these
patterns explicit and disambiguates it with fusion on tensors using
tile + fuse.

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

3 years ago[lld][WebAssembly] Rewrite exports test in assembly. NFC
Sam Clegg [Mon, 5 Apr 2021 15:11:37 +0000 (08:11 -0700)]
[lld][WebAssembly] Rewrite exports test in assembly. NFC

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

3 years ago[gn build] (manually) port 0116d04d04f2
Nico Weber [Mon, 5 Apr 2021 18:12:58 +0000 (14:12 -0400)]
[gn build] (manually) port 0116d04d04f2

3 years agoRevert "llvm-shlib: Create object libraries for each component and link against them"
Tom Stellard [Mon, 5 Apr 2021 15:31:09 +0000 (08:31 -0700)]
Revert "llvm-shlib: Create object libraries for each component and link against them"

This reverts commit 43ceb74eb1a5801662419fb66a6bf0d5414f1ec5.

This caused some build failures: https://bugs.llvm.org/show_bug.cgi?id=49818

3 years agoRevert "Fix build rules for LLVM_WITH_Z3 after D95727"
Tom Stellard [Mon, 5 Apr 2021 15:30:37 +0000 (08:30 -0700)]
Revert "Fix build rules for LLVM_WITH_Z3 after D95727"

This reverts commit d66f9c4f1e83e69abf75f97cb5f8fd1dc9422357.

This was a follow up fix for 43ceb74eb1a5801662419fb66a6bf0d5414f1ec5, which
will be reverted.

3 years ago[TextAPI] move source code files out of subdirectory, NFC
Cyndy Ishida [Mon, 5 Apr 2021 16:59:50 +0000 (09:59 -0700)]
[TextAPI] move source code files out of subdirectory, NFC

TextAPI/ELF has moved out into InterfaceStubs, so theres no longer a
need to seperate out TextAPI between formats.

Reviewed By: ributzka, int3, #lld-macho

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

3 years ago[gn build] Port 9b3df78b4c2a
LLVM GN Syncbot [Mon, 5 Apr 2021 17:21:14 +0000 (17:21 +0000)]
[gn build] Port 9b3df78b4c2a

3 years ago[analyzer] DynamicSize: Rename 'size' to 'extent'
Charusso [Mon, 5 Apr 2021 17:20:43 +0000 (19:20 +0200)]
[analyzer] DynamicSize: Rename 'size' to 'extent'

3 years ago[analyzer] DynamicSize: Debug facility
Charusso [Mon, 5 Apr 2021 17:17:48 +0000 (19:17 +0200)]
[analyzer] DynamicSize: Debug facility

This patch adds two debug functions to ExprInspectionChecker to dump out
the dynamic extent and element count of symbolic values:
dumpExtent(), dumpElementCount().

3 years ago[flang][driver] Modify the existing test cases that use -Mstandard in f18, to use...
Arnamoy Bhattacharyya [Mon, 5 Apr 2021 16:58:00 +0000 (12:58 -0400)]
[flang][driver] Modify the existing test cases that use -Mstandard in f18, to use -pedantic and %flang_fc1 to share with the new driver

Reviewed By: awarzynski

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

3 years ago[LoopFusion] Bails out if only the second candidate is guarded (PR48060)
Ta-Wei Tu [Mon, 5 Apr 2021 17:08:35 +0000 (01:08 +0800)]
[LoopFusion] Bails out if only the second candidate is guarded (PR48060)

If only the second candidate loop is guarded while the first one is not, fusioning
two loops might not be valid but this check is currently missing.

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

Reviewed By: sidbav

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

3 years ago[analyzer] DynamicSize: Store the dynamic size
Charusso [Mon, 5 Apr 2021 17:04:30 +0000 (19:04 +0200)]
[analyzer] DynamicSize: Store the dynamic size

This patch introduces a way to store the size.

Reviewed By: NoQ

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

3 years ago[flang][driver] Add options for -Werror
Arnamoy Bhattacharyya [Mon, 5 Apr 2021 16:41:46 +0000 (12:41 -0400)]
[flang][driver] Add options for -Werror

With the option given, warnings are treated as error.

Reviewed By: awarzynski

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

3 years ago[RISCV] Add support for bitcasts between scalars and fixed-length vectors
Fraser Cormack [Wed, 31 Mar 2021 16:01:16 +0000 (17:01 +0100)]
[RISCV] Add support for bitcasts between scalars and fixed-length vectors

This patch supports bitcasts from scalar types to fixed-length vectors
and vice versa. It custom-lowers and custom-legalizes them to
EXTRACT_VECTOR_ELT/INSERT_VECTOR_ELT operations, using a single-element
vectors to hold the scalar where appropriate.

Previously, some of these would fail to select, others would be expanded
through stack loads and stores. Effort was made to ensure the codegen
avoids the stack for both legal and illegal scalar types.

Some of the codegen could be improved, but on first glance it looks like
a general optimization of EXTRACT_VECTOR_ELT when extracting an i64
element on RV32.

Reviewed By: craig.topper

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

3 years ago[InstCombine] fix potential miscompile in select value equivalence
Sanjay Patel [Mon, 5 Apr 2021 16:14:49 +0000 (12:14 -0400)]
[InstCombine] fix potential miscompile in select value equivalence

As shown in the example based on:
https://llvm.org/PR49832
...and the existing test, we can't substitute
a vector value because the equality compare
replacement that we are attempting requires
that the comparison is true for the entire
value. Vector select can be partly true/false.

3 years ago[InstCombine] add test for miscompile from select value equivalence; NFC
Sanjay Patel [Mon, 5 Apr 2021 16:03:50 +0000 (12:03 -0400)]
[InstCombine] add test for miscompile from select value equivalence; NFC

The new test is reduced from:
https://llvm.org/PR49832
...but we already show a potential miscompile in the existing test too.

3 years ago[M68k] Mark public functions with the LLVM_EXTERNAL_VISIBILITY macro
John Paul Adrian Glaubitz [Mon, 5 Apr 2021 16:22:59 +0000 (09:22 -0700)]
[M68k] Mark public functions with the LLVM_EXTERNAL_VISIBILITY macro

In 0dbcb3639451, most most target symbols were made hidden by default
with the public ones marked with LLVM_EXTERNAL_VISIBILITY. When the
M68k target was added, this particular change was forgotten so that
external tools cannot make use of the public M68k target functions
in libLLVM.so. Thus, add the missing LLVM_EXTERNAL_VISIBILITY macro
to all public target functions in the M68k backend.

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

3 years ago[RISCV] Expand scalable-vector truncstores and extloads
Fraser Cormack [Wed, 31 Mar 2021 11:51:03 +0000 (12:51 +0100)]
[RISCV] Expand scalable-vector truncstores and extloads

Caught in internal testing, these operations are assumed legal by
default, even for scalable vector types. Expand them back into separate
truncations and stores, or loads and extensions.

Also add explicit fixed-length vector tests for these operations, even
though they should have been correct already.

Reviewed By: craig.topper

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

3 years ago[SemaObjC] Fix a -Wbridge-cast false-positive
Erik Pilkington [Mon, 5 Apr 2021 13:05:56 +0000 (09:05 -0400)]
[SemaObjC] Fix a -Wbridge-cast false-positive

Clang used to emit a bad -Wbridge-cast diagnostic on the cast in the attached
test. This was because, after 09abecef7, struct __CFString was not added to
lookup, so the objc_bridge attribute wasn't getting duplicated onto the most
recent declaration, causing us to fail to find it in getObjCBridgeAttr. This
patch fixes this by instead walking through the redeclarations to find an
appropriate bridge attribute. rdar://72823399

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

3 years ago[PowerPC] Fix issue where binary uses a .got but is missing a .TOC.
Stefan Pintilie [Mon, 5 Apr 2021 13:07:16 +0000 (08:07 -0500)]
[PowerPC] Fix issue where binary uses a .got but is missing a .TOC.

From the PowerPC ELFv2 ABI section 4.2.3. Global Offset Table.
```
The GOT consists of an 8-byte header that contains the TOC base (the first TOC
base when multiple TOCs are present), followed by an array of 8-byte addresses.
```

Due to the introduction of PC Relative code it is now possible to require a GOT
without having a .TOC. symbol in the object that is being linked. Since LLD uses
the .TOC. symbol to determine whether or not a GOT is required the GOT header is
not setup correctly and the 8-byte header is missing.

This patch allows the Power PC GOT setup to happen when an element is added to
the GOT instead of at the very begining. When this header is added a .TOC.
symbol is also added.

Reviewed By: MaskRay

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

3 years ago[OpenMP] Fix incorrect KMP_STRLEN() macro
Peyton, Jonathan L [Thu, 25 Feb 2021 18:49:12 +0000 (12:49 -0600)]
[OpenMP] Fix incorrect KMP_STRLEN() macro

The second argument to the strnlen_s(str, size) function should be
sizeof(str) when str is a true array of characters with known size
(instead of just a char*). Use type traits to determine if first
parameter is a character array and use the correct size based on that
trait.

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

3 years ago[SLP]Improve vectorization of the CmpInst instructions.
Alexey Bataev [Thu, 1 Apr 2021 16:16:31 +0000 (09:16 -0700)]
[SLP]Improve vectorization of the CmpInst instructions.

During vectorization better to postpone the vectorization of the CmpInst
instructions till the end of the basic block. Otherwise we may vectorize
it too early and may miss some vectorization patterns, like reductions.

Reworked part of D57059

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

3 years ago[TableGen] [docs] Correct a couple of mistakes; use 'true' and 'false' in examples
Paul C. Anagnostopoulos [Fri, 2 Apr 2021 16:35:24 +0000 (12:35 -0400)]
[TableGen] [docs] Correct a couple of mistakes; use 'true' and 'false' in examples

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

3 years ago* NFC. Refactored DIPrinter for better support of new print styles.
Alex Orlov [Mon, 5 Apr 2021 11:40:41 +0000 (15:40 +0400)]
* NFC. Refactored DIPrinter for better support of new print styles.

This patch introduces a DIPrinter interface to implement by different output style printer implementations. DIPrinterGNU and DIPrinterLLVM implement the GNU and LLVM output style printing respectively. No functional changes.

This refactoring clarifies and simplifies the code, and makes a new output style addition easier.

Reviewed By: jhenderson, dblaikie

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

3 years ago[RISCV] Add a test showing incorrect codegen
Fraser Cormack [Wed, 20 Jan 2021 07:49:53 +0000 (07:49 +0000)]
[RISCV] Add a test showing incorrect codegen

This patch adds a test which shows how the compiler incorrectly sets the
size and alignment of a stack object used to indirectly pass vector
types to functions.

In the particular example, the test passes a <4 x i8> vector type to a
function and creates a stack object of size and alignment equal to 4
bytes. However, the code generated to set up that parameter has been
scalarized and stores each element as individual XLEN-sized values. Thus
on RV32 this stores 16 bytes and on RV64 32 bytes, both of which clobber
the stack. Similarly, the alignment is set up as the alignment
of the vector type, which is not necessarily the natural alignment of XLEN.

Reviewed By: luismarques

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

3 years ago[X86] Fold xor(zext(xor(x,c1)),c2) -> xor(zext(x),xor(zext(c1),c2))
Simon Pilgrim [Mon, 5 Apr 2021 10:40:29 +0000 (11:40 +0100)]
[X86] Fold xor(zext(xor(x,c1)),c2) -> xor(zext(x),xor(zext(c1),c2))

Fixes PR47603 (second case) by extending rG89afec348dbd3e5078f176e978971ee2d3b5dec8

3 years ago[X86] Add second PR47603 test case
Simon Pilgrim [Mon, 5 Apr 2021 10:16:03 +0000 (11:16 +0100)]
[X86] Add second PR47603 test case

We had coverage for the xor(trunc(xor(x,31)),31) case but not xor(zext(xor(x,31)),31)

3 years ago[DebugInfo, CallSites, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sat, 3 Apr 2021 07:52:39 +0000 (08:52 +0100)]
[DebugInfo, CallSites, test] Fix use of undef FileCheck var

Clang test CodeGen/debug-info-extern-call.c tries to check for the
absence of a sequence of instructions with several CHECK-NOT with one of
those directives using a variable defined in another. However CHECK-NOT
are checked independently so that is using a variable defined in a
pattern that should not occur in the input.

This commit removes the CHECK-NOT for the retained line attribute
definition since the CHECK-NOT on the compile unit will already check
that there is no retained lines.

Reviewed By: djtodoro

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

3 years ago[NFC][OCaml] Reformat to clean up following CAMLprim removal
Josh Berdine [Sun, 28 Mar 2021 22:18:01 +0000 (23:18 +0100)]
[NFC][OCaml] Reformat to clean up following CAMLprim removal

The removal of CAMLprim left the code in need of an application of
clang-format. There are various other changes made by clang-format
which it seems ought to be rolled together into this diff.

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

3 years ago[NFC][OCaml] Remove vestigial CAMLprim declarations
Josh Berdine [Sun, 28 Mar 2021 21:52:55 +0000 (22:52 +0100)]
[NFC][OCaml] Remove vestigial CAMLprim declarations

The CAMLprim macro has not been needed since OCaml 3.11, and is
defined to the empty string. This diff removes all instances of it.

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

3 years ago[OCaml] Omit unnecessary GC root registrations
Josh Berdine [Sun, 28 Mar 2021 20:54:25 +0000 (21:54 +0100)]
[OCaml] Omit unnecessary GC root registrations

The current code does not follow the simple interface to the OCaml GC,
where GC roots are registered conservatively, only initializing
allocations are performed, etc. This is intentional, as stated in the
opening file comments. On the other hand, the current code does
register GC roots in many situations where it is not strictly
necessary. This diff omits many of them.

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

3 years ago[OCaml] Code simplification using string allocation functions
Josh Berdine [Sat, 27 Mar 2021 23:00:47 +0000 (23:00 +0000)]
[OCaml] Code simplification using string allocation functions

Using the `cstr_to_string` function that allocates and initializes an
OCaml `string` value enables simplifications in several cases. This
change also has the effect of avoiding calling `memcpy` on NULL
pointers even if only 0 bytes are to be copied.

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

3 years ago[OCaml] Code simplification using option allocation functions
Josh Berdine [Sat, 27 Mar 2021 22:53:35 +0000 (22:53 +0000)]
[OCaml] Code simplification using option allocation functions

Using the `caml_alloc_some` and `ptr_to_option` functions that
allocate OCaml `option` values enables simplifications in many
cases. These simplifications also result in avoiding unnecessary
double initialization in many cases, so yield a minor optimization as
well.

Also, change to avoid using the old unprefixed functions such as
`alloc_small` and instead use the current `caml_alloc_small`.

A few of the changed functions were slightly rewritten in the
early-return style.

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

3 years ago[OCaml] Minor optimizations by avoiding double initialization
Josh Berdine [Sat, 27 Mar 2021 16:54:16 +0000 (16:54 +0000)]
[OCaml] Minor optimizations by avoiding double initialization

In several functions an OCaml block is allocated and no further OCaml
allocation functions (or other functions that might trigger allocation
or collection) are performed before the block is fully initialized. In
these cases, it is safe and slightly more efficient to allocate an
uninitialized block.

Also, the code does not become more complex after the non-initializing
allocation, since in the case that a non-small allocation is made, the
initial values stored are definitely not pointers to OCaml young
blocks, and so initializing via direct assignment is still safe. That
is, in general if `caml_alloc_small` is called, initializing it with
direct assignments is safe, but if `caml_alloc_shr` is
called (e.g. for a block larger than `Max_young_wosize`), then
`caml_initialize` should be called to inform the GC of a potential
major to minor pointer. But if the initial value is definitely not a
young OCaml block, direct assignment is safe.

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

3 years ago[OCaml] Fix unsafe uses of Store_field
Josh Berdine [Sat, 27 Mar 2021 15:16:25 +0000 (15:16 +0000)]
[OCaml] Fix unsafe uses of Store_field

Using `Store_field` to initialize fields of blocks allocated with
`caml_alloc_small` is unsafe. The fields of blocks allocated by
`caml_alloc_small` are not initialized, and `Store_field` calls the
OCaml GC write barrier. If the uninitialized value of a field happens
to point into the OCaml heap, then it will e.g. be added to a conflict
set or followed and have what the GC thinks are color bits
changed. This leads to crashes or memory corruption.

This diff fixes a few (I think all) instances of this problem. Some of
these are creating option values. OCaml 4.12 has a dedicated
`caml_alloc_some` function for this, so this diff adds a compatible
function with a version check to avoid conflict. With that, macros for
accessing option values are also added.

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

3 years agoignore -flto= options recognized by GCC
Sylvestre Ledru [Mon, 5 Apr 2021 09:54:17 +0000 (11:54 +0200)]
ignore -flto= options recognized by GCC

as requested in https://bugs.llvm.org/show_bug.cgi?id=49553, submitting the proposed changes to just ignore the -flto= options which are recognized by GCC ("auto" and "jobserver").

GCC supports -flto=<auto|jobserver|<N> to select the parallelity for LTO builds. LLVM also has -flto-jobs=<N>, which only seems to have a meaning when used with -flto=thin?

The attached patch just ignores the values "auto" and "jobserver". that doesn't change anything in functionality.  Another option would be to map these values to either "thin" or "full", maybe in presence of the -ffat-lto-objects option?

-flto=<n> could also be translated to -flto-jobs=<N>.

Reviewed By: tejohnson

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

3 years ago[Test] Auto-update checks in a test
Max Kazantsev [Mon, 5 Apr 2021 09:24:00 +0000 (16:24 +0700)]
[Test] Auto-update checks in a test

3 years ago[Test] Split out new and old PM tests
Max Kazantsev [Mon, 5 Apr 2021 07:51:29 +0000 (14:51 +0700)]
[Test] Split out new and old PM tests

This is to avoid sophistication of checks as the old and new PM behave
differently with fix patches.

3 years ago[Test] Add tests for various scenarios of PRE of a loop load
Max Kazantsev [Mon, 5 Apr 2021 05:00:10 +0000 (12:00 +0700)]
[Test] Add tests for various scenarios of PRE of a loop load

3 years ago[CUDA][HIP] rename -fcuda-flush-denormals-to-zero
Yaxun (Sam) Liu [Wed, 31 Mar 2021 21:23:11 +0000 (17:23 -0400)]
[CUDA][HIP] rename -fcuda-flush-denormals-to-zero

Rename it to -fgpu-flush-denormals-to-zero.

Reviewed by: Artem Belevich

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

3 years ago[lldb] Replace unneeded use of Foundation with ObjectiveC in tests (NFC)
Dave Lee [Sun, 4 Apr 2021 21:52:26 +0000 (14:52 -0700)]
[lldb] Replace unneeded use of Foundation with ObjectiveC in tests (NFC)

When referencing `NSObject`, it's enough to import `objc/NSObject.h`. Importing `Foundation` is unnecessary in these cases.

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

3 years ago[lldb] Import ObjectiveC module instead of Foundation in test
Dave Lee [Sun, 4 Apr 2021 15:28:10 +0000 (08:28 -0700)]
[lldb] Import ObjectiveC module instead of Foundation in test

Use `@import ObjectiveC` instead of `@import Foundation`, as the former is all
that's needed, and results in fewer clang modules being built.

This results in the following clang modules *not* being built for this test.

ApplicationServices
CFNetwork
ColorSync
CoreFoundation
CoreGraphics
CoreServices
CoreText
DiskArbitration
Dispatch
Foundation
IOKit
ImageIO
Security
XPC
_Builtin_intrinsics
launch
libkern
os_object
os_workgroup

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

3 years ago[RISCV] Use gorciw for i32 orc.b intrinsic when Zbp is enabled.
Craig Topper [Sun, 4 Apr 2021 22:40:41 +0000 (15:40 -0700)]
[RISCV] Use gorciw for i32 orc.b intrinsic when Zbp is enabled.

The W version of orc.b does not exist in Zbp so we need to use
gorci encoding. If we have Zbp, we can use gorciw which can avoid a
sext.w in some cases.

3 years ago[sanitizer] Simplify GetTls with dl_iterate_phdr on Linux
Fangrui Song [Sun, 4 Apr 2021 22:35:53 +0000 (15:35 -0700)]
[sanitizer] Simplify GetTls with dl_iterate_phdr on Linux

This was reverted by f176803ef1f4050a350e01868d64fe09a674d3bf due to
Ubuntu 16.04 x86-64 glibc 2.23 problems.
This commit additionally calls `__tls_get_addr({modid,0})` to work around the
dlpi_tls_data==NULL issues for glibc<2.25
(https://sourceware.org/bugzilla/show_bug.cgi?id=19826)

GetTls is the range of

* thread control block and optional TLS_PRE_TCB_SIZE
* static TLS blocks plus static TLS surplus

On glibc, lsan requires the range to include
`pthread::{specific_1stblock,specific}` so that allocations only referenced by
`pthread_setspecific` can be scanned.

This patch uses `dl_iterate_phdr` to collect TLS blocks. Find the one
with `dlpi_tls_modid==1` as one of the initially loaded module, then find
consecutive ranges. The boundaries give us addr and size.

This allows us to drop the glibc internal `_dl_get_tls_static_info` and
`InitTlsSize` entirely. Use the simplified method with non-Android Linux for
now, but in theory this can be used with *BSD and potentially other ELF OSes.

This simplification enables D99566 for TLS Variant I architectures.

See https://reviews.llvm.org/D93972#2480556 for analysis on GetTls usage
across various sanitizers.

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

3 years ago[libc++] Fix test_macros.h in the same way as commit 49e5a896 fixed __config.
Arthur O'Dwyer [Sun, 4 Apr 2021 22:05:12 +0000 (18:05 -0400)]
[libc++] Fix test_macros.h in the same way as commit 49e5a896 fixed __config.

Since D99515, this header triggers -Wundef on Mac OSX older than 10.15.
This is now fixed.

3 years ago[libc++] Fix the header guard from _LIBCPP_STEAMBUF to _LIBCPP_STREAMBUF.
Arthur O'Dwyer [Sun, 4 Apr 2021 21:39:50 +0000 (17:39 -0400)]
[libc++] Fix the header guard from _LIBCPP_STEAMBUF to _LIBCPP_STREAMBUF.

3 years ago[InstCombine] dropRedundantMaskingOfLeftShiftInput(): check that adding shift amounts...
Roman Lebedev [Sun, 4 Apr 2021 20:25:29 +0000 (23:25 +0300)]
[InstCombine] dropRedundantMaskingOfLeftShiftInput(): check that adding shift amounts doesn't overflow (PR49778)

This is identical to 781d077afb0ed9771c513d064c40170c1ccd21c9,
but for the other function.

For certain shift amount bit widths, we must first ensure that adding
shift amounts is safe, that the sum won't have an unsigned overflow.

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

3 years ago[NFC][InstCombine] Extract canTryToConstantAddTwoShiftAmounts() as helper
Roman Lebedev [Sun, 4 Apr 2021 20:23:10 +0000 (23:23 +0300)]
[NFC][InstCombine] Extract canTryToConstantAddTwoShiftAmounts() as helper

3 years ago[NFC][InstCombine] Add test for PR49778
Roman Lebedev [Sun, 4 Apr 2021 20:15:29 +0000 (23:15 +0300)]
[NFC][InstCombine] Add test for PR49778

3 years ago[RISCV] Lower orc.b intrinsic to RISCVISD::GORCI.
Craig Topper [Sun, 4 Apr 2021 19:30:25 +0000 (12:30 -0700)]
[RISCV] Lower orc.b intrinsic to RISCVISD::GORCI.

This will allow us to share any future known bits, demaned bits,
or sign bits improvements.

3 years ago[HIP, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sat, 3 Apr 2021 08:29:38 +0000 (09:29 +0100)]
[HIP, test] Fix use of undef FileCheck var

Clang test CodeGenCUDA/kernel-stub-name.cu uses never defined DKERN
variable in a CHECK-NOT directive. This commit replace the variable by a
regex, thereby avoiding the issue.

Reviewed By: yaxunl

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

3 years ago[HIP-Clang, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sat, 3 Apr 2021 08:13:11 +0000 (09:13 +0100)]
[HIP-Clang, test] Fix use of undef FileCheck var

Commit 8129521318accc44c2a009647572f6ebd3fc56dd changed a line defining
PREFIX in clang test CodeGenCUDA/device-stub.cu into a CHECK-NOT
directive. All following lines using PREFIX are therefore using an
undefined variable since the pattern defining PREFIX is not supposed to
occur and CHECK-NOT are checked independently.

This commit replaces all uses of PREFIX by the regex used to define it,
thereby avoiding the problem.

Reviewed By: yaxunl

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

3 years ago[libc++] Improve generate_feature_test_macro_components.py.
Mark de Wever [Tue, 30 Mar 2021 18:19:12 +0000 (20:19 +0200)]
[libc++] Improve generate_feature_test_macro_components.py.

This improves the naming of the fields `depends`/`internal_depends`. It
also adds the documentation for this script. The changes are based on
D99290 and its review comments.

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

3 years ago[Driver] Detect libstdc++ include paths for native gcc (-m32 and -m64) on Debian...
Fangrui Song [Sun, 4 Apr 2021 17:15:12 +0000 (10:15 -0700)]
[Driver] Detect libstdc++ include paths for native gcc (-m32 and -m64) on Debian i386

Take gcc-8 on Debian i386 as an example. The target-specific libstdc++ search
path (`GPLUSPLUS_TOOL_INCLUDE_DIR`) uses the multiarch name `i386-linux-gnu`,
instead of the triple of the GCC installation `i686-linux-gnu` (the directory
under `usr/lib/gcc/`):

```
/usr/include/c++/8
/usr/include/i386-linux-gnu/c++/8
/usr/include/c++/8/backward
```

Clang currently detects `/usr/lib/gcc/i686-linux-gnu/8/../../../include/i686-linux-gnu/c++/8`.
This patch changes the second i686-linux-gnu to i386-linux-gnu so that
`/usr/include/i386-linux-gnu/c++/8` can be found.

Fix PR49827 - this was somehow regressed by my previous libstdc++ include path
cleanups and fixes for gcc-cross, but it seems that the paths were never properly tested before.

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

3 years ago[libcxx] [test] Link against msvcprt as C++ ABI library in tests
Martin Storsjö [Wed, 24 Mar 2021 08:46:17 +0000 (10:46 +0200)]
[libcxx] [test] Link against msvcprt as C++ ABI library in tests

This matches what we link the library itself against (set in
CMakeLists.txt). When testing a static library version of libc++,
this is needed for essentially every test due to libc++ object files
requiring it.

Also with libc++ built as a DLL, some tests directly call functions that
are provided by msvcprt (such as std::set_new_handler), thus this fixes
a number of tests in that configuration too.

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

3 years ago[InstCombine] fold popcount of exactly one bit to shift
Sanjay Patel [Sun, 4 Apr 2021 15:38:09 +0000 (11:38 -0400)]
[InstCombine] fold popcount of exactly one bit to shift

This is discussed in https://llvm.org/PR48999 ,
but it does not solve that request.

The difference in the vector test shows that some
other logic transform is limited to scalar types.

3 years ago[InstCombine] add tests for ctpop of power-of-2; NFC
Sanjay Patel [Sun, 4 Apr 2021 13:39:24 +0000 (09:39 -0400)]
[InstCombine] add tests for ctpop of power-of-2; NFC

PR48999

3 years ago[SimplifyCFG] Handle two equal cases in switch to select
Nikita Popov [Sun, 4 Apr 2021 08:49:59 +0000 (10:49 +0200)]
[SimplifyCFG] Handle two equal cases in switch to select

When converting a switch with two cases and a default into a
select, also handle the denegerate case where two cases have the
same value.

Generate this case directly as

  %or = or i1 %cmp1, %cmp2
  %res = select i1 %or, i32 %val, i32 %default

rather than

  %sel1 = select i1 %cmp1, i32 %val, i32 %default
  %res = select i1 %cmp2, i32 %val, i32 %sel1

as InstCombine is going to canonicalize to the former anyway.

3 years ago[SimplifyCFG] Add switch-to-select test with two equal cases (NFC)
Nikita Popov [Sun, 4 Apr 2021 15:10:11 +0000 (17:10 +0200)]
[SimplifyCFG] Add switch-to-select test with two equal cases (NFC)

We handle the case where we have two cases and a default all having
different values, but not the case where two cases happen to have
the same one.

The PhaseOrdering test is a particularly bad example where this
showed up.

3 years ago[SimplifyCFG] Make test more robust (NFC)
Nikita Popov [Sun, 4 Apr 2021 14:47:54 +0000 (16:47 +0200)]
[SimplifyCFG] Make test more robust (NFC)

These are supposed to test creation of a switch, so make sure
there is some actual code in the branches. Otherwise this could
be turned into a select instead.

3 years agoSpeculative fix for failing build bot.
Aaron Ballman [Sun, 4 Apr 2021 14:58:56 +0000 (10:58 -0400)]
Speculative fix for failing build bot.

This attempts to resolve an issue found by http://45.33.8.238/macm1/6821/step_6.txt

3 years ago[llvm-exegesis] SnippetFile: do create source manager in MCContext
Roman Lebedev [Sun, 4 Apr 2021 12:56:43 +0000 (15:56 +0300)]
[llvm-exegesis] SnippetFile: do create source manager in MCContext

This way, once there's an error in the snippet file (like in the test),
llvm-exegesis won't crash with an assertion failure,
but print a nice diagnostic about the problem.

3 years ago[CVP] Add more tests for select with overdefined operand (NFC)
Nikita Popov [Sun, 4 Apr 2021 11:45:03 +0000 (13:45 +0200)]
[CVP] Add more tests for select with overdefined operand (NFC)

Also check the case where one operand isn't constant, which isn't
handled right now, because the SPF code requires both operands
to be ranges.

Move the tests to directly check ranges rather than go through an
and, to make it more obvious that this has no relation to bitmasks.

3 years ago[llvm-exegesis] Don't erroneously refuse to measure POPCNT instruction
Roman Lebedev [Sun, 4 Apr 2021 11:36:56 +0000 (14:36 +0300)]
[llvm-exegesis] Don't erroneously refuse to measure POPCNT instruction

3 years agoDon't check that std::pair is trivially copyable on FreeBSD
Dimitry Andric [Sat, 3 Apr 2021 10:20:13 +0000 (12:20 +0200)]
Don't check that std::pair is trivially copyable on FreeBSD

As FreeBSD already used libc++ before it changed its ABI, we still use
the non-trivially copyable version of std::pair, which used to be
exposed via `_LIBCPP_TRIVIAL_PAIR_COPY_CTOR`, but more recently via
`_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR`.

Reviewed By: serge-sans-paille

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

3 years ago[mlir][NFC] Fully spell mlir types names in LoopLikeOpInterface, so it can be used...
Butygin [Sat, 3 Apr 2021 19:06:47 +0000 (22:06 +0300)]
[mlir][NFC] Fully spell mlir types names in LoopLikeOpInterface, so it can be used in ops defined outside mlir namespace

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

3 years ago[LVI] Don't bail on overdefined value in select
Nikita Popov [Sun, 4 Apr 2021 08:52:22 +0000 (10:52 +0200)]
[LVI] Don't bail on overdefined value in select

Even if one of the operands is overdefined, we may still produce
a non-overdefined result, e.g. due to a min/max operation. This
matches our handling elsewhere, e.g. for binary operators.

The slot poisoning comment refers to a much older LVI cache
implementation.

3 years ago[CVP] Add test for and of min (NFC)
Nikita Popov [Sun, 4 Apr 2021 09:05:59 +0000 (11:05 +0200)]
[CVP] Add test for and of min (NFC)

The and currently doesn't get optimized away because %a is
overdefined.

3 years agoRevert "Add support for fetching signed values from tagged pointers."
Jason Molenda [Sun, 4 Apr 2021 08:47:35 +0000 (01:47 -0700)]
Revert "Add support for fetching signed values from tagged pointers."

This reverts commit 4d9039c8dc2d1f0be1b5ee486d5a83b1614b038a.

This is causing the greendragon bots to fail most of the time when
running TestNSDictionarySynthetic.py.  Reverting until Jim has a chance
to look at this on Monday.  Running the commands from that test from
the command line, it fails 10-13% of the time on my desktop.

This is a revert of Jim's changes in https://reviews.llvm.org/D99694

3 years ago[NFC][scudo] Restore !UseQuarantine check in tests
Vitaly Buka [Sun, 4 Apr 2021 06:52:06 +0000 (23:52 -0700)]
[NFC][scudo] Restore !UseQuarantine check in tests

The check was removed in D99786 as it seems that quarantine is
irrelevant for the just created allocator. However there is internal
issues with tagged memory access.

We should be able to fix iterateOverChunks for taggin later.

3 years ago[RISCV] Don't convert fshr/fshl to target specific FSL/FSR node if shift amount is...
Craig Topper [Sun, 4 Apr 2021 06:05:34 +0000 (23:05 -0700)]
[RISCV] Don't convert fshr/fshl to target specific FSL/FSR node if shift amount is a constant.

As long as it's a constant we can directly pattern match it
without any problems. It's only when it isn't a constant that
we need to add an AND.

In theory this should allow more target independent optimizations
to remain active.

3 years ago[clang][parser] Set source ranges for GNU-style attributes
Timm Bäder [Thu, 25 Mar 2021 12:32:42 +0000 (13:32 +0100)]
[clang][parser] Set source ranges for GNU-style attributes

Set the source ranges for parsed GNU-style attributes in
ParseGNUAttributes(), the same way that ParseCXX11Attributes() does it.

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

3 years ago[InstCombine] Conditionally fold select i1 into and/or
Juneyoung Lee [Sun, 4 Apr 2021 04:35:33 +0000 (13:35 +0900)]
[InstCombine] Conditionally fold select i1 into and/or

This patch fixes llvm.org/pr49688 by conditionally folding select i1 into and/or:

```
select cond, cond2, false
->
and cond, cond2
```

This is not safe if cond2 is poison whereas cond isn’t.

Unconditionally disabling this transformation affects later pipelines that depend on and/or i1s.
To minimize its impact, this patch conservatively checks whether cond2 is an instruction that
creates a poison or its operand creates a poison.
This approach is similar to what InstSimplify's SimplifyWithOpReplaced is doing.

Reviewed By: nikic

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