platform/upstream/llvm.git
23 months agofix some bad logic that was removing all successor phi nodes, not just
John Regehr [Sun, 14 Aug 2022 01:14:10 +0000 (19:14 -0600)]
fix some bad logic that was removing all successor phi nodes, not just
out of chunk ones. the non-default second argument to
removePredecessor() is necessary to avoid creating invalid IR on
examples like the one in the provided test case

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

23 months ago[llvm-readobj] Remove unused member variable. NFC
Fangrui Song [Sun, 14 Aug 2022 01:14:24 +0000 (18:14 -0700)]
[llvm-readobj] Remove unused member variable. NFC

23 months ago[libc++] Implement `operator<=>` for `thread::id`
Adrian Vogelsgesang [Sun, 31 Jul 2022 23:12:42 +0000 (16:12 -0700)]
[libc++] Implement `operator<=>` for `thread::id`

The new operator<=> is mapped onto the existing functions
__libcpp_thread_id_equal and __libcpp_thread_id_less. Introducing a
new __libcpp_thread_id_compare_three_way might lead to more efficient
code. Given that we can still introduce __libcpp_thread_id_compare_three_way
later, for this commit I opted to not break ABI. If requested, I will
add __libcpp_thread_id_compare_three_way in a follow-up commit.

Implements part of P1614R2 "The Mothership has Landed"

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

23 months ago[libc++] Add a bunch of missing _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser [Sat, 13 Aug 2022 11:23:16 +0000 (13:23 +0200)]
[libc++] Add a bunch of missing _LIBCPP_HIDE_FROM_ABI

Reviewed By: ldionne, Mordante, var-const, huixie90, #libc

Spies: jloser, libcxx-commits, arichardson, miyuki

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

23 months ago[AArch64] Fix signed integer overflow in CSINC case
Vitaly Buka [Fri, 12 Aug 2022 22:43:05 +0000 (15:43 -0700)]
[AArch64] Fix signed integer overflow in CSINC case

https://lab.llvm.org/staging/#/builders/224/builds/2/steps/16/logs/stdio

Reviewed By: dmgreen

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

23 months ago[DAG] canCreateUndefOrPoison - add freeze(add/sub/mul(x,y)) -> add/sub/mul(freeze...
Simon Pilgrim [Sat, 13 Aug 2022 19:57:51 +0000 (20:57 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(add/sub/mul(x,y)) -> add/sub/mul(freeze(x),y,z) support

These are guaranteed not to create undef/poison as long as there are no poison generating flags

23 months ago[X86] Add test coverage for add/sub/mul with freeze
Simon Pilgrim [Sat, 13 Aug 2022 19:42:41 +0000 (20:42 +0100)]
[X86] Add test coverage for add/sub/mul with freeze

23 months agoUse llvm::erase_value (NFC)
Kazu Hirata [Sat, 13 Aug 2022 19:55:50 +0000 (12:55 -0700)]
Use llvm::erase_value (NFC)

23 months agoUse llvm::erase_if (NFC)
Kazu Hirata [Sat, 13 Aug 2022 19:55:48 +0000 (12:55 -0700)]
Use llvm::erase_if (NFC)

23 months agoRemove unused forward declarations (NFC)
Kazu Hirata [Sat, 13 Aug 2022 19:55:47 +0000 (12:55 -0700)]
Remove unused forward declarations (NFC)

23 months agoEnsure newlines at the end of files (NFC)
Kazu Hirata [Sat, 13 Aug 2022 19:55:45 +0000 (12:55 -0700)]
Ensure newlines at the end of files (NFC)

23 months ago[clangd] Drop unnecessary const from return types (NFC)
Kazu Hirata [Sat, 13 Aug 2022 19:55:44 +0000 (12:55 -0700)]
[clangd] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

23 months ago[llvm] Qualify auto in range-based for loops (NFC)
Kazu Hirata [Sat, 13 Aug 2022 19:55:42 +0000 (12:55 -0700)]
[llvm] Qualify auto in range-based for loops (NFC)

Identified with readability-qualified-auto.

23 months ago __has_trivial_copy should map to __is_trivially_copyable
Zachary Henkel [Sat, 13 Aug 2022 19:52:41 +0000 (22:52 +0300)]
 __has_trivial_copy should map to __is_trivially_copyable

Found during clang 15 RC1 testing due to the new diagnostic added by @royjacobson since clang 14.  Uncertain if this fix meets the bar to also be applied to the release branch.

If accepted, I'll need someone with commit access to submit on my behalf.

Reviewed By: royjacobson, aaron.ballman, erichkeane

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

23 months ago[OpenMP] Fix another after scope after D129608
Vitaly Buka [Sat, 13 Aug 2022 19:13:27 +0000 (12:13 -0700)]
[OpenMP] Fix another after scope after D129608

https://lab.llvm.org/buildbot/#/builders/5/builds/26770

23 months ago[MC] Leverage constexpr `std::array` in `SubtargetFeature.h`
Joe Loser [Sat, 13 Aug 2022 04:14:28 +0000 (22:14 -0600)]
[MC] Leverage constexpr `std::array` in `SubtargetFeature.h`

Replace C-style array with `std::array` since `std::array<T, N>::operator[]` is
`constexpr` in C++17. This also allows us to replace `array_lengthof` calls with
member `size()` function.

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

23 months agoUse Optional::transform instead of Optional::map (NFC)
Kazu Hirata [Sat, 13 Aug 2022 18:48:26 +0000 (11:48 -0700)]
Use Optional::transform instead of Optional::map (NFC)

I'm planning to deprecate map in favor of transform for consistency
with std::optional::transform in C++23.

23 months ago[ADT] Implement Optional::transform
Kazu Hirata [Sat, 13 Aug 2022 18:48:25 +0000 (11:48 -0700)]
[ADT] Implement Optional::transform

This patch implements Optional::transform for consistency with
std::optional::transform in C++23.

Note that the new function is identical to Optional::map.  My plan is
to deprecate Optional::map after migrating all of its uses to
Optional::transform.

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

23 months ago[flang][openacc] Handle array section and derived-type components operands
Valentin Clement [Sat, 13 Aug 2022 18:40:03 +0000 (20:40 +0200)]
[flang][openacc] Handle array section and derived-type components operands

This patch lowers correctly operands with array section
and derived-type component.

Depends on D131764

Reviewed By: razvanlupusoru

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

23 months ago[unittest] Update HostTest::isSupportedArchAndOS
Fangrui Song [Sat, 13 Aug 2022 17:27:34 +0000 (10:27 -0700)]
[unittest] Update HostTest::isSupportedArchAndOS

23 months ago[CostModel][X86] Add cost kinds test coverage for select operators
Simon Pilgrim [Sat, 13 Aug 2022 17:08:03 +0000 (18:08 +0100)]
[CostModel][X86] Add cost kinds test coverage for select operators

23 months agoRevert "[AArch64][GlobalISel] Recognise some CCMPri"
Florian Hahn [Sat, 13 Aug 2022 16:44:40 +0000 (17:44 +0100)]
Revert "[AArch64][GlobalISel] Recognise some CCMPri"

This reverts commit 38c2366b3ffcc11da178b8d52814ef609e08d40f.

This patch seems to break boostraping LLVM with `-fglobal-isel -O3`
on AArch64 hardware. Without the revert, there are 500+ test
failures for the `check-llvm-codegen-x86` target.

23 months ago[OpenMP] Fix use after scope after D129608
Vitaly Buka [Sat, 13 Aug 2022 16:39:49 +0000 (09:39 -0700)]
[OpenMP] Fix use after scope after D129608

Broken builder https://lab.llvm.org/buildbot/#/builders/5/builds/26764

23 months ago[mlir][shape] Rename dim.dim to dim.index (NFC)
Jacques Pienaar [Sat, 13 Aug 2022 16:27:22 +0000 (09:27 -0700)]
[mlir][shape] Rename dim.dim to dim.index (NFC)

dim member on dim was confusing, change to be consistent with
tensor::dim.

23 months ago[CostModel] Rename vselect-cost.ll to select.ll
Simon Pilgrim [Sat, 13 Aug 2022 16:30:42 +0000 (17:30 +0100)]
[CostModel] Rename vselect-cost.ll to select.ll

This covers more than just vector select costs

23 months ago[CostModel][X86] Add cost kinds test coverage for fp comparisons
Simon Pilgrim [Sat, 13 Aug 2022 16:20:49 +0000 (17:20 +0100)]
[CostModel][X86] Add cost kinds test coverage for fp comparisons

23 months ago[CostModel][X86] Add cost kinds test coverage for fp arithmetic operators
Simon Pilgrim [Sat, 13 Aug 2022 15:42:36 +0000 (16:42 +0100)]
[CostModel][X86] Add cost kinds test coverage for fp arithmetic operators

23 months ago[InstCombine] fix "X|(X^Y)" pattern-matching for commuted variants
Sanjay Patel [Sat, 13 Aug 2022 15:00:41 +0000 (11:00 -0400)]
[InstCombine] fix "X|(X^Y)" pattern-matching for commuted variants

23 months ago[InstCombine] add tests for or-xor; NFC
Sanjay Patel [Sat, 13 Aug 2022 14:26:16 +0000 (10:26 -0400)]
[InstCombine] add tests for or-xor; NFC

The existing pattern matching fails to handle all commutes.

23 months agoUpdate the implementation status of some C11 features
Aaron Ballman [Sat, 13 Aug 2022 14:16:27 +0000 (10:16 -0400)]
Update the implementation status of some C11 features

This also starts to add some test coverage for specific papers to
validate conformance against.

23 months ago[InstCombine] reduce or-xor-or patterns
Sanjay Patel [Sat, 13 Aug 2022 13:47:28 +0000 (09:47 -0400)]
[InstCombine] reduce or-xor-or patterns

(A | ?) | (A ^ B) --> (A | ?) | B
https://alive2.llvm.org/ce/z/dbNQw4

This extends the existing transform to peek through
another 'or' instruction for the common operand.

This is the underlying missing fold that should allow
issue #56711 and issue #57120 to reduce even more.

23 months ago[Instcombine] Add (simplified) pointless loop unroll / vectorization test for Issue...
Simon Pilgrim [Sat, 13 Aug 2022 13:31:49 +0000 (14:31 +0100)]
[Instcombine] Add (simplified) pointless loop unroll / vectorization test for Issue #37628

23 months ago[InstCombine] move comments closer to relevant code; NFC
Sanjay Patel [Sat, 13 Aug 2022 12:36:58 +0000 (08:36 -0400)]
[InstCombine] move comments closer to relevant code; NFC

23 months ago[InstCombine] add tests for or-xor-or; NFC
Sanjay Patel [Fri, 12 Aug 2022 18:08:11 +0000 (14:08 -0400)]
[InstCombine] add tests for or-xor-or; NFC

23 months ago[AVR] Remove debug location of spill/reload instructions
Liqin.Weng [Sat, 13 Aug 2022 12:57:22 +0000 (20:57 +0800)]
[AVR] Remove debug location of spill/reload instructions

Reviewed By: MatzeB, benshi001

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

23 months ago[Instcombine] known-phi-br.ll - fix test bounds for positive tests
Simon Pilgrim [Sat, 13 Aug 2022 12:48:55 +0000 (13:48 +0100)]
[Instcombine] known-phi-br.ll - fix test bounds for positive tests

I was off by one in a couple of the inverse predicate tests....

23 months ago[gn build] port 7260cdd2e13a3 more
Nico Weber [Sat, 13 Aug 2022 12:41:49 +0000 (08:41 -0400)]
[gn build] port 7260cdd2e13a3 more

23 months ago[Driver] Support linking to compiler-rt for target AVR
Ben Shi [Sat, 13 Aug 2022 12:23:25 +0000 (20:23 +0800)]
[Driver] Support linking to compiler-rt for target AVR

Reviewed By: aykevl

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

23 months ago[RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x...
LiaoChunyu [Sat, 13 Aug 2022 12:27:21 +0000 (20:27 +0800)]
[RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x, y, neq/eq))

(setcc x, y, eq/neq) are seqz, snez that set rd = 0/1.

addi is used to process immediate, which can save instructions for load immediate.

Reviewed By: craig.topper

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

23 months ago[Instcombine] Add some value tracking tests for cases where the conditional branch...
Simon Pilgrim [Sat, 13 Aug 2022 12:00:46 +0000 (13:00 +0100)]
[Instcombine] Add some value tracking tests for cases where the conditional branch feeding a phi gives us known bits of the value based off the branch condition

Part of Issue #37628

23 months ago[libc++] Simplify __config a bit more and add underscores to attributes
Nikolas Klauser [Tue, 9 Aug 2022 11:22:25 +0000 (13:22 +0200)]
[libc++] Simplify __config a bit more and add underscores to attributes

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

23 months ago[Support] computeHostNumPhysicalCores: use sched_getaffinity for all non-Android...
Fangrui Song [Sat, 13 Aug 2022 08:36:12 +0000 (01:36 -0700)]
[Support] computeHostNumPhysicalCores: use sched_getaffinity for all non-Android Linux with no custom implementation

Make the sched_getaffinity based implementation available to all architectures
(except s390x/x86 which have a custom implementation). The `CPU_ALLOC(2048)`
code supports all `CONFIG_NR_CPUS` values in Linux kernel `arch/*/configs/`.

The function is mainly used by in-process ThinLTO to decide the default number
of threads. Returning -1 will use just one thread.

Android is excluded because of the higher API level requirement:
`sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21`

23 months ago[test][sanitizer] Disable netdb tests on Android
Vitaly Buka [Sat, 13 Aug 2022 08:07:05 +0000 (01:07 -0700)]
[test][sanitizer] Disable netdb tests on Android

23 months ago[Driver] Use addOptInFlag. NFC
Fangrui Song [Sat, 13 Aug 2022 07:51:04 +0000 (00:51 -0700)]
[Driver] Use addOptInFlag. NFC

23 months agoReapply [Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManager
Anubhab Ghosh [Fri, 12 Aug 2022 11:35:39 +0000 (17:05 +0530)]
Reapply [Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManager

When memory is deallocated from MapperJITLinkMemoryManager deinitialize
actions are run through mapper and in case of InProcessMapper, memory
protections of the region are reset to read/write as they were previously
changed and can be reused in future.

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

23 months ago[lldb][ARC] Fix -Wtautological-bitwise-compare warning
Fangrui Song [Sat, 13 Aug 2022 07:18:36 +0000 (00:18 -0700)]
[lldb][ARC] Fix -Wtautological-bitwise-compare warning

23 months ago[test][sanitizer] Fix REQUIRES in the test
Vitaly Buka [Sat, 13 Aug 2022 05:41:46 +0000 (22:41 -0700)]
[test][sanitizer] Fix REQUIRES in the test

23 months ago[test][asan] Remove -fsanitize-address-use-after-scope
Vitaly Buka [Sat, 13 Aug 2022 05:36:26 +0000 (22:36 -0700)]
[test][asan] Remove -fsanitize-address-use-after-scope

It's enabled by default in D31479.

23 months ago[libcxx][hwasan] Add basic HWAddress support
Vitaly Buka [Sat, 13 Aug 2022 05:12:28 +0000 (22:12 -0700)]
[libcxx][hwasan] Add basic HWAddress support

23 months ago(Reland) [fastalloc] Support allocating specific register class in fastalloc
Luo, Yuanke [Thu, 23 Jun 2022 01:18:47 +0000 (09:18 +0800)]
(Reland) [fastalloc] Support allocating specific register class in fastalloc

Reland commit 719658d078c4

The base RA support infrastructure that only allow a specific register
class be allocated in RA pss. Since greedy RA, basic RA derived from
base RA, they all allow allocating specific register class. Fast RA
doesn't support allocating register for specific register class. This
patch is to enable ShouldAllocateClass in fast RA, so that it can
support allocating register for specific register class.

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

23 months ago[RISCV] isImpliedByDomCondition returns an Optional<bool> not a bool.
Craig Topper [Sat, 13 Aug 2022 05:15:22 +0000 (22:15 -0700)]
[RISCV] isImpliedByDomCondition returns an Optional<bool> not a bool.

We were incorrectly checking that it returned an implicaton result,
not that the implication result itself was true.

23 months ago[ORC] Silence copy elision warning.
Sunho Kim [Sat, 13 Aug 2022 05:17:18 +0000 (14:17 +0900)]
[ORC] Silence copy elision warning.

23 months ago[openmp] Remove __ANDROID_API__ < 19 workaround
Fangrui Song [Sat, 13 Aug 2022 05:15:38 +0000 (22:15 -0700)]
[openmp] Remove __ANDROID_API__ < 19 workaround

https://github.com/android/ndk/wiki/Changelog-r24 shows that the NDK has
moved forward to at least a minimum target API of 19. Remove old workaround.

23 months ago[ORC] Specify the typename.
Sunho Kim [Sat, 13 Aug 2022 04:58:50 +0000 (13:58 +0900)]
[ORC] Specify the typename.

23 months agoRevert "[Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManager"
Anubhab Ghosh [Sat, 13 Aug 2022 04:50:57 +0000 (10:20 +0530)]
Revert "[Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManager"

This reverts commit 143555b2ed30746fbcc8ff84e9cef4267688f110.

23 months ago[ORC_RT][COFF] Initial platform support for COFF/x86_64.
Sunho Kim [Sat, 13 Aug 2022 04:47:31 +0000 (13:47 +0900)]
[ORC_RT][COFF] Initial platform support for COFF/x86_64.

Initial platform support for COFF/x86_64.

Completed features:
* Statically linked orc runtime.
* Full linking/initialization of static/dynamic vc runtimes and microsoft stl libraries.
* SEH exception handling.
* Full static initializers support
* dlfns
* JIT side symbol lookup/dispatch

Things to note:
* It uses vc runtime libraries found in vc toolchain installations.
* Bootstrapping state is separated because when statically linking orc runtime it needs microsoft stl functions to initialize the orc runtime, but static initializers need to be ran in order to fully initialize stl libraries.
* Process symbols can't be used blidnly on msvc platform; otherwise duplicate definition error gets generated. If process symbols are used, it's destined to get out-of-reach error at some point.
* Atexit currently not handled -- will be handled in the follow-up patches.

Reviewed By: lhames

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

23 months ago[Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManager
Anubhab Ghosh [Fri, 12 Aug 2022 11:35:39 +0000 (17:05 +0530)]
[Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManager

When memory is deallocated from MapperJITLinkMemoryManager deinitialize
actions are run through mapper and in case of InProcessMapper, memory
protections of the region are reset to read/write as they were previously
changed and can be reused in future.

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

23 months ago[clang-format] Distinguish logical and after bracket from reference
jackh [Sat, 13 Aug 2022 03:12:10 +0000 (11:12 +0800)]
[clang-format] Distinguish logical and after bracket from reference

Fix commit `b646f0955574` and remove redundant code.

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

23 months ago[DAGCombine] Replace std::monostate equivalent in DAGCombiner.cpp
Joe Loser [Fri, 12 Aug 2022 14:22:59 +0000 (08:22 -0600)]
[DAGCombine] Replace std::monostate equivalent in DAGCombiner.cpp

Remove the `UnitT` type and operators in favor of using `std::monostate`
directly.

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

23 months ago[mlir][python] add a todo to replace throw in dense array iterator
Jeff Niu [Sat, 13 Aug 2022 03:35:38 +0000 (23:35 -0400)]
[mlir][python] add a todo to replace throw in dense array iterator

23 months ago[mlir] Remove colon from empty dense array syntax
Jeff Niu [Sat, 13 Aug 2022 01:32:15 +0000 (21:32 -0400)]
[mlir] Remove colon from empty dense array syntax

E.g. `array<i32:>` -> `array<i32>`

Reviewed By: rriddle, jpienaar

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

23 months ago[mlir][ods] Rename Confined and AllAttrConstraintsOf
Jeff Niu [Sat, 13 Aug 2022 01:22:26 +0000 (21:22 -0400)]
[mlir][ods] Rename Confined and AllAttrConstraintsOf

Confined -> ConfinedAttr
AllAttrConstraintsOf -> AllOfAttr

To be in line with ConfinedType and AllOfType.

Reviewed By: rriddle

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

23 months ago[mlir] Deprecate OptionalParseResult::{hasValue,getValue}
Kazu Hirata [Sat, 13 Aug 2022 02:19:24 +0000 (19:19 -0700)]
[mlir] Deprecate OptionalParseResult::{hasValue,getValue}

This patch deprecates hasValue and getValue for consistency with
std::optional and llvm::Optional.  Note that I've migrated all known
uses of them to has_value and value, respectively.

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

23 months ago[mlir] Use has_value instead of hasValue (NFC)
Kazu Hirata [Sat, 13 Aug 2022 02:19:23 +0000 (19:19 -0700)]
[mlir] Use has_value instead of hasValue (NFC)

23 months ago[RISCV][NFC] Use nested namespace definations.
jacquesguan [Fri, 12 Aug 2022 06:44:26 +0000 (14:44 +0800)]
[RISCV][NFC] Use nested namespace definations.

Since we use C++17 now, we could use nested namespace definations to simplify code.

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

23 months ago[mlir][ods] OpFormat: ensure that regions don't follow `attr-dict`
Jeff Niu [Thu, 11 Aug 2022 00:18:01 +0000 (20:18 -0400)]
[mlir][ods] OpFormat: ensure that regions don't follow `attr-dict`

An optional attribute dictionary before a region in an assembly format
is a potential format ambiguity because they both start with `{`.

Fixes #53077

Reviewed By: rriddle

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

23 months ago[mlir][ods] Support string literals in `custom` directives
Jeff Niu [Wed, 10 Aug 2022 17:37:11 +0000 (13:37 -0400)]
[mlir][ods] Support string literals in `custom` directives

This patch adds support for string literals as `custom` directive
arguments. This can be useful for re-using custom parsers and printers
when arguments have a known value. For example:

```
ParseResult parseTypedAttr(AsmParser &parser, Attribute &attr, Type type) {
  return parser.parseAttribute(attr, type);
}

void printTypedAttr(AsmPrinter &printer, Attribute attr, Type type) {
  return parser.printAttributeWithoutType(attr);
}
```

And in TableGen:

```
def FooOp : ... {
  let arguments = (ins AnyAttr:$a);
  let assemblyFormat = [{ custom<TypedAttr>($a, "$_builder.getI1Type()")
                          attr-dict }];
}

def BarOp : ... {
  let arguments = (ins AnyAttr:$a);
  let assemblyFormat = [{ custom<TypedAttr>($a, "$_builder.getIndexType()")
                          attr-dict }];
}
```

Instead of writing two separate sets of custom parsers and printers.

Reviewed By: rriddle

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

23 months ago[OpenMP] Fix segmentation fault when data field is used in is_device_pt
Jennifer Yu [Thu, 11 Aug 2022 18:23:57 +0000 (11:23 -0700)]
[OpenMP] Fix segmentation fault when data field is used in is_device_pt

Currently, the field just emit map info for this pointer variable. It is
failed at run time. For the fields, the PartialStruct is created and it
needs call to emitCombinedEntry which create the base that covers all
the pieces.

The change is to generate map info as regular fields.

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

23 months ago[sanitizer] Add dn_comp interceptor
Vitaly Buka [Thu, 7 Jul 2022 04:17:23 +0000 (21:17 -0700)]
[sanitizer] Add dn_comp interceptor

Reviewed By: kda

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

23 months ago(Reland) [mlir] Switch segment size attributes to DenseI32ArrayAttr
Jeff Niu [Fri, 12 Aug 2022 19:43:03 +0000 (15:43 -0400)]
(Reland) [mlir] Switch segment size attributes to DenseI32ArrayAttr

This reland includes changes to the Python bindings.

Switch variadic operand and result segment size attributes to use the
dense i32 array. Dense integer arrays were introduced primarily to
represent index lists. They are a better fit for segment sizes than
dense elements attrs.

Depends on D131801

Reviewed By: rriddle

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

23 months ago[mlir][python] Add python bindings for DenseArrayAttr
Jeff Niu [Fri, 12 Aug 2022 19:41:42 +0000 (15:41 -0400)]
[mlir][python] Add python bindings for DenseArrayAttr

This patch adds python bindings for the dense array variants.

Fixes #56975

Reviewed By: ftynse

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

23 months agoUpdate hwasan test to fix failure on older Android API versions.
Usman Nadeem [Fri, 12 Aug 2022 23:28:04 +0000 (16:28 -0700)]
Update hwasan test to fix failure on older Android API versions.

In Android API < 30 there is no HWAsan instrumentation support for globals
so the test fails if API < 30 or if the target triple does not specify the API version.

Add -triple=aarch64-linux-android31 to enable global instrumentation. This is the
same triple as is used in the RUN line for -fsanitize=memtag-globals.

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

Change-Id: I300703bd126b10e3c52505e23c78c5a48acb0309

23 months ago[MLIR][TOSA] Remove ReluN operator from TOSA dialect
Eric Kunze [Fri, 12 Aug 2022 23:00:11 +0000 (16:00 -0700)]
[MLIR][TOSA] Remove ReluN operator from TOSA dialect

ReluN has been removed from the TOSA specification. It can be replaced
in all instances with Clamp(0,N)

Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Reviewed By: jpienaar

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

23 months ago[analyzer] Fix a crash on copy elided initialized lambda captures
isuckatcs [Fri, 12 Aug 2022 15:12:50 +0000 (17:12 +0200)]
[analyzer] Fix a crash on copy elided initialized lambda captures

Inside `ExprEngine::VisitLambdaExpr()` we wasn't prepared for a
copy elided initialized capture's `InitExpr`. This patch teaches
the analyzer how to handle such situation.

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

23 months ago[trace][intel pt] Fix per-psb packet decoding
Walter Erquinigo [Mon, 8 Aug 2022 23:24:22 +0000 (16:24 -0700)]
[trace][intel pt] Fix per-psb packet decoding

The per-PSB packet decoding logic was wrong because it was assuming that pt_insn_get_sync_offset was being udpated after every PSB. Silly me, that is not true. It returns the offset of the PSB packet after invoking pt_insn_sync_forward regardless of how many PSBs are visited later. Instead, I'm now following the approach described in https://github.com/intel/libipt/blob/master/doc/howto_libipt.md#parallel-decode for parallel decoding, which is basically what we need.

A nasty error that happened because of this is that when we had two PSBs (A and B), the following was happening

1. PSB A was processed all the way up to the end of the trace, which includes PSB B.
2. PSB B was then processed until the end of the trace.

The instructions emitted by step 2. were also emitted as part of step 1. so our trace had duplicated chunks. This problem becomes worse when you many PSBs.

As part of making sure this diff is correct, I added some other features that are very useful.

- Added a "synchronization point" event to the TraceCursor, so we can inspect when PSBs are emitted.
- Removed the single-thread decoder. Now the per-cpu decoder and single-thread decoder use the same code paths.
- Use the query decoder to fetch PSBs and timestamps. It turns out that the pt_insn_sync_forward of the instruction decoder can move past several PSBs (this means that we could skip some TSCs). On the other hand, the pt_query_sync_forward method doesn't skip PSBs, so we can get more accurate sync events and timing information.
- Turned LibiptDecoder into PSBBlockDecoder, which decodes single PSB blocks. It is the fundamental processing unit for decoding.
- Added many comments, asserts and improved error handling for clarity.
- Improved DecodeSystemWideTraceForThread so that a TSC is emitted always before a cpu change event. This was a bug that was annoying me before.
- SplitTraceInContinuousExecutions and FindLowestTSCInTrace are now using the query decoder, which can identify precisely each PSB along with their TSCs.
- Added an "only-events" option to the trace dumper to inspect only events.

I did extensive testing and I think we should have an in-house testing CI. The LLVM buildbots are not capable of supporting testing post-mortem traces of hundreds of megabytes. I'll leave that for later, but at least for now the current tests were able to catch most of the issues I encountered when doing this task.

A sample output of a program that I was single stepping is the following. You can see that only one PSB is emitted even though stepping happened!

```
thread #1: tid = 3578223
    0: (event) trace synchronization point [offset = 0x0xef0]
  a.out`main + 20 at main.cpp:29:20
    1: 0x0000000000402479    leaq   -0x1210(%rbp), %rax
    2: (event) software disabled tracing
    3: 0x0000000000402480    movq   %rax, %rdi
    4: (event) software disabled tracing
    5: (event) software disabled tracing
    6: 0x0000000000402483    callq  0x403bd4                  ; std::vector<int, std::allocator<int>>::vector at stl_vector.h:391:7
    7: (event) software disabled tracing
  a.out`std::vector<int, std::allocator<int>>::vector() at stl_vector.h:391:7
    8: 0x0000000000403bd4    pushq  %rbp
    9: (event) software disabled tracing
    10: 0x0000000000403bd5    movq   %rsp, %rbp
    11: (event) software disabled tracing
```

This is another trace of a long program with a few PSBs.
```
(lldb) thread trace dump instructions -E -f                                                                                                         thread #1: tid = 3603082
    0: (event) trace synchronization point [offset = 0x0x80]
    47417: (event) software disabled tracing
    129231: (event) trace synchronization point [offset = 0x0x800]
    146747: (event) software disabled tracing
    246076: (event) software disabled tracing
    259068: (event) trace synchronization point [offset = 0x0xf78]
    259276: (event) software disabled tracing
    259278: (event) software disabled tracing
    no more data
```

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

23 months ago[libunwind][AIX] Implement _Unwind_FindEnclosingFunction() using traceback table...
Xing Xue [Fri, 12 Aug 2022 22:07:56 +0000 (18:07 -0400)]
[libunwind][AIX] Implement _Unwind_FindEnclosingFunction() using traceback table on AIX

Summary:
The implementation of  _Unwind_FindEnclosingFunction(void *ip) takes the context of itself and then uses the context to get the info of the function enclosing ip. This approach does not work for AIX because on AIX, the TOC base in GPR2 is used as the base for calculating relative addresses. Since  _Unwind_FindEnclosingFunction() may be in a different shared lib than the function containing ip, their TOC bases can be different. Therefore, using the value of GPR2 in the context from  _Unwind_FindEnclosingFunction() as the base results in incorrect addresses. On the other hand, the start address of a function is available in the traceback table following the instructions of each function on AIX. To get to the traceback table, search a word of 0 starting from ip and the traceback table is located after the word 0. This patch implements _Unwind_FindEnclosingFunction() for AIX by obtaining the function start address from its traceback table.

Reviewed by: compnerd, MaskRay, libunwind

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

23 months ago[DebugInfo] Don't join DW_AT_comp_dir and directories[0] for DWARF v5 line tables
Fangrui Song [Fri, 12 Aug 2022 21:01:52 +0000 (14:01 -0700)]
[DebugInfo] Don't join DW_AT_comp_dir and directories[0] for DWARF v5 line tables

DWARF v5 6.2.4 The Line Number Program Header says:

> The first entry is the current directory of the compilation. Each additional
> path entry is either a full path name or is relative to the current directory of
> the compilation.

When forming a path, relative DW_AT_comp_dir and directories[0] are not supposed
to be joined together. Fix getFileNameByIndex to special case DWARF v5 DirIdx == 0.

Reviewed By: #debug-info, dblaikie

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

23 months agoX86: Don't fold TEST into ADD ...@GOTTPOFF/GOTNTPOFF/INDNTPOFF
James Y Knight [Thu, 11 Aug 2022 16:20:49 +0000 (16:20 +0000)]
X86: Don't fold TEST into ADD ...@GOTTPOFF/GOTNTPOFF/INDNTPOFF

The linker may convert such an ADD into a LEA, so we must not
use the EFLAGS output.

This causes miscompiles with -fsanitize=null after
bacdf80f42b46044262e97e98398d1bd0b75900d added
llvm.threadlocal.address -- previously, global variables were known to
be non-null, but the intrinsic is not currently known to return
nonnull. (That should be corrected, but it shouldn't've caused
miscompiles!)

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

23 months ago[mlir] Add AllOfType and ConfinedType constraints
Jeff Niu [Fri, 12 Aug 2022 16:07:13 +0000 (12:07 -0400)]
[mlir] Add AllOfType and ConfinedType constraints

`AllOfType` is a type constraint that satisfies all given type
constraints and `ConfinedType` is a type that satisfies additional
predicates. These shorthands simplify type constraint definition mostly
by removing the need to deal with `myType.predicate` manipulation.

Reviewed By: jpienaar

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

23 months ago[MCDwarf] Respect -fdebug-prefix-map= for generated assembly debug info (DWARF v5)
Fangrui Song [Fri, 12 Aug 2022 19:52:36 +0000 (12:52 -0700)]
[MCDwarf] Respect -fdebug-prefix-map= for generated assembly debug info (DWARF v5)

For generated assembly debug info, MCDwarfLineTableHeader::CompilationDir is an
unmapped path set in MCContext::setGenDwarfRootFile. Remap it.

A relative destination path of -fdebug-prefix-map= exposes a llvm-dwarfdump bug
which joins relative DW_AT_comp_dir and directories[0].

Fix https://github.com/llvm/llvm-project/issues/56609

Reviewed By: dblaikie

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

23 months ago[BOLT] Use Optional::emplace to avoid move assignment. NFC
Fangrui Song [Fri, 12 Aug 2022 19:51:50 +0000 (12:51 -0700)]
[BOLT] Use Optional::emplace to avoid move assignment. NFC

23 months ago[SPIRV] support capabilities and extensions
Ilia Diachkov [Wed, 10 Aug 2022 21:37:46 +0000 (00:37 +0300)]
[SPIRV] support capabilities and extensions

This patch supports SPIR-V capabilities and extensions. In addition,
it inserts decorations related to MIFlags and improves support of switches.
Five tests are included to demonstrate the improvement.

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
23 months ago[mlir] Flip Tensor dialect and ViewLike (NFC)
Jacques Pienaar [Fri, 12 Aug 2022 19:41:32 +0000 (12:41 -0700)]
[mlir] Flip Tensor dialect and ViewLike (NFC)

Also requires updating view like interface to use prefixed form.

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

23 months ago[lld/mac] Stop accepting arbitrary suffixes on --(no-)warn-dylib-install-name
Nico Weber [Fri, 12 Aug 2022 15:01:07 +0000 (11:01 -0400)]
[lld/mac] Stop accepting arbitrary suffixes on --(no-)warn-dylib-install-name

The flag accidentally used Joined<> instead of Flag<>.

Previously, `--warn-dylib-install-namefoobarbaz` would be accepted and
had the same effect as `-warn-dylib-install-name`. Now the flag only
works if no suffix is attached to it, as originally intended.

Also fix a typo in the flag's help text.

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

23 months ago[flang] Pass SemanticsContext to the LoweringBridge
Valentin Clement [Fri, 12 Aug 2022 19:22:30 +0000 (21:22 +0200)]
[flang] Pass SemanticsContext to the LoweringBridge

The SemanticsContext is needed to analyze expression later in the
lowering for directive languages. This patch allows to keep a reference of
the SemanticsContext in the LoweringBridge.

Building block for D131765

Reviewed By: razvanlupusoru

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

23 months ago[MSAN] add flag to suppress storage of stack variable names with -sanitize-memory...
Kevin Athey [Thu, 11 Aug 2022 21:53:38 +0000 (14:53 -0700)]
[MSAN] add flag to suppress storage of stack variable names with -sanitize-memory-track-origins

Allows for even more savings in the binary image while simultaneously removing the name of the offending stack variable.

Depends on D131631

Reviewed By: vitalybuka

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

23 months ago[ADT] Mark variable inline to avoid ODR violations in Sequence.h
Joe Loser [Fri, 12 Aug 2022 14:13:16 +0000 (08:13 -0600)]
[ADT] Mark variable inline to avoid ODR violations in Sequence.h

Mark `force_iteration_on_noniterable_enum` as an `inline` variable
to avoid ODR violations.

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

23 months ago[ADT] Remove STLForwardCompat.h's C++17 equivalents
Joe Loser [Fri, 12 Aug 2022 12:59:38 +0000 (06:59 -0600)]
[ADT] Remove STLForwardCompat.h's C++17 equivalents

As a follow-up of e8578968f684997840f680ed62bff5cad0accc13 which replaced the
callers to use the C++17 equivalents, remove the equivalents from
`STLForwardCompat.h` entirely and their corresponding tests.

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

23 months ago[libc] add sprintf size comparison
Michael Jones [Thu, 11 Aug 2022 22:48:32 +0000 (15:48 -0700)]
[libc] add sprintf size comparison

To accurately measure the size of sprintf in a finished binary, the
easiest method is to simply build a binary with and without sprintf.
This patch adds an integration test that can be built with and without
sprintf, as well as targets to build it.

Reviewed By: sivachandra

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

23 months ago[bazel] Use lld in --config=generic_clang
Arthur Eubanks [Thu, 11 Aug 2022 21:15:47 +0000 (14:15 -0700)]
[bazel] Use lld in --config=generic_clang

This should give us faster links.

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

23 months ago[bazel] Remove --config=rbe
Arthur Eubanks [Thu, 11 Aug 2022 21:12:34 +0000 (14:12 -0700)]
[bazel] Remove --config=rbe

RBE is currently broken due to the RBE container being too old and not supporting C++17.
The bots have already stopped using --config=rbe.

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

23 months ago[MLIR] Add utility function to create values for all dimensions of a tensor value
Frederik Gossen [Fri, 12 Aug 2022 18:40:48 +0000 (14:40 -0400)]
[MLIR] Add utility function to create values for all dimensions of a tensor value

This is a variant of the already provided `createDynamicDimValues` helper.

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

23 months ago[clang-doc] Always emit the TagType for RecordInfo
Brett Wilson [Fri, 12 Aug 2022 18:38:21 +0000 (18:38 +0000)]
[clang-doc] Always emit the TagType for RecordInfo

Always emit the TagType for RecordInfo in YAML output. Previously this omitted the type for "struct", considering it the default. But records in C++ don't really have a default type so always emitting this is more clear.

Emit IsTypeDef in YAML. Previously this existed only in the Representation but was never written. Additionally, adds IsTypeDef to the record merge operation which was clearing it (all RecordInfo structures are merged with am empty RecordInfo during the reduce phase).

Reviewed By: paulkirth

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

23 months ago[clang-doc] Fix assert on startup
Brett Wilson [Fri, 12 Aug 2022 18:35:42 +0000 (18:35 +0000)]
[clang-doc] Fix assert on startup

When using `clang-doc --format=html` it will crash on startup because of an assertion doing a self-assignment of a `SmallString`. This patch removes the self-assignment by creating an intermediate copy.

Reviewed By: paulkirth

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

23 months ago[mlir][sparse] enable integral abs recognition
Aart Bik [Thu, 11 Aug 2022 19:22:21 +0000 (12:22 -0700)]
[mlir][sparse] enable integral abs recognition

The end-to-end test for this new feature also exposed a bug
in LLVM IR lowering (since then, fixed), where we need to account
for the min-poison bit as extra argument.

    declare i32 @llvm.abs.i32(i32 <src>, i1 <is_int_min_poison>)

Reviewed By: bixia

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

23 months ago[llvm] Fix assertion when stat fails in remove_directories
Ben Langmuir [Fri, 12 Aug 2022 17:16:56 +0000 (10:16 -0700)]
[llvm] Fix assertion when stat fails in remove_directories

We were dereferencing an empty Optional if IgnoreErrors was true and the
stat failed.

rdar://60887887

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

23 months ago[Inlining] Introduce the function attribute "inline-max-stacksize"
Wolfgang Pieb [Fri, 15 Jul 2022 20:19:21 +0000 (13:19 -0700)]
[Inlining] Introduce the function attribute "inline-max-stacksize"

The value of the attribute is a size in bytes. It has the effect of
suppressing inlining of functions whose stacksizes exceed the given value.

Reviewed By: mtrofin

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

23 months ago[mlir][shape] Add dim op
Jacques Pienaar [Fri, 12 Aug 2022 18:02:07 +0000 (11:02 -0700)]
[mlir][shape] Add dim op

Convenience op that allows for simple expression of common crossing of
value/shape divide.

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

23 months ago[clangd][unittests][IncludeCleaner] Don't call findReferencedFiles() if the result...
Aleksandr Platonov [Fri, 12 Aug 2022 17:59:49 +0000 (20:59 +0300)]
[clangd][unittests][IncludeCleaner] Don't call findReferencedFiles() if the result is not used

IncludeCleaner.RecursiveInclusion and IncludeCleaner.IWYUPragmaExport tests don't check referenced files list, so we don't need to call findReferencedFiles() there.

Reviewed By: kbobyrev

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

23 months ago[libunwind] Remove __ANDROID_API__ < 18 workaround
Fangrui Song [Fri, 12 Aug 2022 17:46:46 +0000 (10:46 -0700)]
[libunwind] Remove __ANDROID_API__ < 18 workaround

https://github.com/android/ndk/wiki/Changelog-r24 shows that the NDK has
moved forward to at least a minimum target API of 19. Remove old workaround.

Reviewed By: #libunwind, danalbert

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