platform/upstream/llvm.git
15 months ago[AMDGPU] Place global constructors in .init_array and .fini_array
Joseph Huber [Thu, 27 Apr 2023 13:00:01 +0000 (08:00 -0500)]
[AMDGPU] Place global constructors in .init_array and .fini_array

For the GPU, we emit external kernels that call the initializers and
constructors, however if we had a persistent kernel like in the `_start`
kernel for the `libc` project, we could initialize the standard way of
calling constructors. This patch adds new global variables containing
pointers to the constructors to be called. If these are placed in the
`.init_array` and `.fini_array` sections, then the backend will handle
them specially. The linker will then provide the `__init_array_` and
`__fini_array_` sections to traverse them. An implementation would look
like this.

```
extern uintptr_t __init_array_start[];
extern uintptr_t __init_array_end[];
extern uintptr_t __fini_array_start[];
extern uintptr_t __fini_array_end[];

using InitCallback = void(int, char **, char **);
using FiniCallback = void(void);

extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
_start(int argc, char **argv, char **envp) {
  uint64_t init_array_size = __init_array_end - __init_array_start;
  for (uint64_t i = 0; i < init_array_size; ++i)
    reinterpret_cast<InitCallback *>(__init_array_start[i])(argc, argv, env);
  uint64_t fini_array_size = __fini_array_end - __fini_array_start;
  for (uint64_t i = 0; i < fini_array_size; ++i)
    reinterpret_cast<FiniCallback *>(__fini_array_start[i])();
}
```

Reviewed By: yaxunl

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

15 months agoLangRef: Add "dynamic" option to "denormal-fp-math"
Matt Arsenault [Tue, 6 Dec 2022 14:25:33 +0000 (09:25 -0500)]
LangRef: Add "dynamic" option to "denormal-fp-math"

This is stricter than the default "ieee", and should probably be the
default. This patch leaves the default alone. I can change this in a
future patch.

There are non-reversible transforms I would like to perform which are
legal under IEEE denormal handling, but illegal with flushing zero
behavior. Namely, conversions between llvm.is.fpclass and fcmp with
zeroes.

Under "ieee" handling, it is legal to translate between
llvm.is.fpclass(x, fcZero) and fcmp x, 0.

Under "preserve-sign" handling, it is legal to translate between
llvm.is.fpclass(x, fcSubnormal|fcZero) and fcmp x, 0.

I would like to compile and distribute some math library functions in
a mode where it's callable from code with and without denormals
enabled, which requires not changing the compares with denormals or
zeroes.

If an IEEE function transforms an llvm.is.fpclass call into an fcmp 0,
it is no longer possible to call the function from code with denormals
enabled, or write an optimization to move the function into a denormal
flushing mode. For the original function, if x was a denormal, the
class would evaluate to false. If the function compiled with denormal
handling was converted to or called from a preserve-sign function, the
fcmp now evaluates to true.

This could also be of use for strictfp handling, where code may be
changing the denormal mode.

Alternative name could be "unknown".

Replaces the old AMDGPU custom inlining logic with more conservative
logic which tries to permit inlining for callees with dynamic handling
and avoids inlining other mismatched modes.

15 months ago[mlir][bytecode] Allow client to specify a desired version.
Jacques Pienaar [Sat, 29 Apr 2023 12:35:53 +0000 (05:35 -0700)]
[mlir][bytecode] Allow client to specify a desired version.

Add method to set a desired bytecode file format to generate. Change
write method to be able to return status including the minimum bytecode
version needed by reader. This enables generating an older version of
the bytecode (not dialect ops, attributes or types). But this does not
guarantee that an older version can always be generated, e.g., if a
dialect uses a new encoding only available at later bytecode version.
This clamps setting to at most current version.

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

15 months ago[clangd] Hover: Add CalleeArgInfo for constructor expressions
Tom Praschan [Sat, 8 Apr 2023 12:57:34 +0000 (14:57 +0200)]
[clangd] Hover: Add CalleeArgInfo for constructor expressions

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

15 months ago[CMake] Serialize `build_native_tool`
NAKAMURA Takumi [Mon, 24 Apr 2023 13:59:56 +0000 (22:59 +0900)]
[CMake] Serialize `build_native_tool`

To prevent race in `NATIVE`, let each action depend on preceding action.
At the moment, this is restricted only for "Visual Studio".

For example,

  - `llvm-tblgen-host` depends on the target's `llvm-tblgen`.
  - `clang-tblgen-host` depends on the target's `clang-tblgen` and `llvm-tblgen-host`.

This is rework for D54153.
`build_native_tool` has been introduced since D60024.

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

15 months ago[clang-format] Add BracedInitializerIndentWidth option
Jon Phillips [Sat, 29 Apr 2023 07:22:22 +0000 (00:22 -0700)]
[clang-format] Add BracedInitializerIndentWidth option

The option allows users to specify how many columns to use to indent
the contents of initializer lists.

Closes #51070.

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

15 months ago[X86] Fix the vnni machine combine issue.
Luo, Yuanke [Sat, 29 Apr 2023 05:14:54 +0000 (13:14 +0800)]
[X86] Fix the vnni machine combine issue.

The previous patch (D148980) didn't set the InstrIdxForVirtReg correctly
in genAlternativeDpCodeSequence(). It causes vnni lit test failure when
LLVM_ENABLE_EXPENSIVE_CHECKS is on.

15 months agoRevert "Reland D147337 "[tsan] Add debugging interfaces into interface header.""
Hans Wennborg [Sat, 29 Apr 2023 05:06:16 +0000 (07:06 +0200)]
Revert "Reland D147337 "[tsan] Add debugging interfaces into interface header.""

This broke the lit tests on Mac, see comment on the code review.

> This change the types to match the ones used in:
> Darwin/debug_external.cpp
> debugging.cpp
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D148214

This reverts commit ea7d6e658e37363c61d2f9ce64de0b223a39be50.

15 months ago[RISCV] Disable strict node mutation and use correct lowering action of strict_fsetcc(s).
Yeting Kuo [Thu, 27 Apr 2023 07:37:39 +0000 (15:37 +0800)]
[RISCV] Disable strict node mutation and use correct lowering action of strict_fsetcc(s).

The patch disables strict node mutation by setting IsStrictFPEnabled to true.
It also fixes wrong lowering action of strict_fsetcc(s).

Reviewed By: craig.topper

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

15 months agoGOFFObjectFile.cpp: Suppress a warning in -Asserts (D98437)
NAKAMURA Takumi [Sat, 29 Apr 2023 02:31:27 +0000 (11:31 +0900)]
GOFFObjectFile.cpp: Suppress a warning in -Asserts (D98437)

15 months ago[libc] Fix printing on the GPU when given a `cpp::string_ref`
Joseph Huber [Fri, 28 Apr 2023 22:44:17 +0000 (17:44 -0500)]
[libc] Fix printing on the GPU when given a `cpp::string_ref`

The implementation of the test printing currently expects a null
terminated C-string. However, the `write_to_stderr` interface uses a
string view, which doesn't need to be null terminated. This patch
changes the printing interface to directly use `fwrite` instead rather
than relying on a null terminator.

Reviewed By: sivachandra

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

15 months ago[NFC][clang] Fix static analyzer concerns about AUTO_CAUSES_COPY
Manna, Soumi [Sat, 29 Apr 2023 01:38:07 +0000 (18:38 -0700)]
[NFC][clang] Fix static analyzer concerns about AUTO_CAUSES_COPY

Reported by Coverity:

AUTO_CAUSES_COPY
Unnecessary object copies can affect performance

1. Inside "ODRHash.cpp" file, in clang::ODRHash::AddCXXRecordDecl(clang::CXXRecordDecl const *): Using the auto keyword without an & causes the copy of an object of type CXXBaseSpecifier.

2. Inside "Tokens.cpp" file, in clang::syntax::TokenBuffer::dumpForTests[abi:cxx11](): Using the auto keyword without an & causes the copy of an object of type DenseMapPair.

3. Inside "TargetID.cpp" file, in clang::getCanonicalTargetID[abi:cxx11](llvm::StringRef, llvm::StringMap<bool, llvm::MallocAllocator> const &): Using the auto keyword without an & causes the copy of an object of type pair.

Reviewed By: tahonermann, aaron.ballman

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

15 months agoSimplify affine bound min or max with operands
Uday Bondhugula [Sat, 29 Apr 2023 01:35:56 +0000 (07:05 +0530)]
Simplify affine bound min or max with operands

Add canonicalization for affine.for bounds to use operand info (when
operands are outer loop affine.for IVs) to simplify bounds: redundant
bound expressions are eliminated in specific cases that are easy to
check and well-suited for op canonicaliation. If the lowest or the
highest value the affine expression can take is already covered by other
constant bounds, the expression can be removed.

Eg:
`min (d0) -> (32 * d0 + 32, 32)(%i) where 0 <= %i < 2`

The first expression can't be less than 32 and can be simplified away
with a lightweight local rewrite.

This simplification being part of canonicalization only handles simple
expressions, specifically, a sum of products of operands with constants.
This is a very common and a dominant case where such simplification is
desired. These can be flattened without any local variables.

Reviewed By: dcaballe, springerm

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

15 months ago[HWASAN] Support short granules in __hwasan_test_shadow
Vitaly Buka [Sat, 29 Apr 2023 01:18:31 +0000 (18:18 -0700)]
[HWASAN] Support short granules in __hwasan_test_shadow

Reviewed By: thurston

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

15 months agoRevert "[HWASAN] Support short granules in __hwasan_test_shadow"
Vitaly Buka [Sat, 29 Apr 2023 01:31:03 +0000 (18:31 -0700)]
Revert "[HWASAN] Support short granules in __hwasan_test_shadow"

Acidentally relanded without the fix.

This reverts commit 008c3934ab6b3a6dfcbb81f6258b9e03e9b61c1c.

15 months ago[HWASAN] Support short granules in __hwasan_test_shadow
Vitaly Buka [Sat, 29 Apr 2023 01:18:31 +0000 (18:18 -0700)]
[HWASAN] Support short granules in __hwasan_test_shadow

Reviewed By: thurston

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

15 months agoRefactor and generalize AArch64 watchpoint support in debugserver
Jason Molenda [Sat, 29 Apr 2023 01:20:40 +0000 (18:20 -0700)]
Refactor and generalize AArch64 watchpoint support in debugserver

Refactor the debugserver watchpiont support in anticipating of
adding support for AArch64 MASK hardware watchpoints to watch
larger regions of memory.  debugserver already had support for
handling a request to watch an unaligned region of memory up
to 8 bytes using Byte Address Select watchpoints - it would split
an unaligned watch request into two aligned doublewords that
could be watched with two hardware watchpoints using the BAS
specification.

This patch generalizes that code for properly aligning, and
possibly splitting, a watchpoint request into two hardware watchpoints
to handle any size request.  And separates out the specifics
about BAS watchpoints into its own method, so a sibling method
for MASK watchpoints can be dropped in next.

Differential Revision: https://reviews.llvm.org/D149040
rdar://108233371

15 months agoRemove i386 and armv7 native support in debugserver
Jason Molenda [Sat, 29 Apr 2023 01:18:43 +0000 (18:18 -0700)]
Remove i386 and armv7 native support in debugserver

i386 and armv7 macOS/iOS cannot be built with current Xcode
any longer; we cannot build or test the support code for running
debugserver on these targets.  Remove the code.

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

15 months ago[lldb] Refactor host::OpenFileInExternalEditor
Jonas Devlieghere [Fri, 28 Apr 2023 20:36:00 +0000 (13:36 -0700)]
[lldb] Refactor host::OpenFileInExternalEditor

This patch refactors the macOS implementation of
OpenFileInExternalEditor. It fixes an AppleEvent memory leak, the
caching of LLDB_EXTERNAL_EDITOR and speculatively fixes a crash when
CFURL is NULL (rdar://108633464). The new code also improves error
handling, readability and documents calls to the CoreFoundation Launch
Services APIs.

A bunch of the Launch Services APIs have been deprecated
(LSFindApplicationForInfo, LSOpenURLsWithRole). The preferred API is
LSOpenCFURLRef but it doesn't specifying the "location" Apple Event
which is used to highlight the current line and switching over would
regress the existing behavior.

rdar://108633464

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

15 months agoRevert "[HWASAN] Support short granules in __hwasan_test_shadow"
Vitaly Buka [Sat, 29 Apr 2023 00:38:11 +0000 (17:38 -0700)]
Revert "[HWASAN] Support short granules in __hwasan_test_shadow"

Break internal tests, but it supposed to be almost NFC.

This reverts commit bf12b746372a25c5a15fa9bd452bd469cc047b47.

15 months ago[RISCV] Add a DAG combine to fold (add (xor (setcc X, Y), 1) -1)->(neg (setcc X,...
Craig Topper [Fri, 28 Apr 2023 23:52:55 +0000 (16:52 -0700)]
[RISCV] Add a DAG combine to fold (add (xor (setcc X, Y), 1) -1)->(neg (setcc X, Y)).

15 months ago[mlir][Tensor] Dont drop attributes during tiling.
Mahesh Ravishankar [Fri, 28 Apr 2023 23:45:02 +0000 (23:45 +0000)]
[mlir][Tensor] Dont drop attributes during tiling.

Reviewed By: hanchung

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

15 months ago[gn build] Port 2fa6bcf02f15
LLVM GN Syncbot [Fri, 28 Apr 2023 23:32:00 +0000 (23:32 +0000)]
[gn build] Port 2fa6bcf02f15

15 months agoFix use of undeclared identifier 'EC' (NFC)
Jie Fu [Fri, 28 Apr 2023 23:30:35 +0000 (07:30 +0800)]
Fix use of undeclared identifier 'EC' (NFC)

/Users/jiefu/llvm-project/llvm/lib/Object/GOFFObjectFile.cpp:199:3: error: use of undeclared identifier 'EC'
  EC = ConverterEBCDIC::convertToUTF8(SymbolName, SymbolNameConverted);
  ^
1 error generated.

15 months ago[msan] Improve handling of Intrinsic::is_fpclass after c55fffe
Vitaly Buka [Fri, 28 Apr 2023 22:13:52 +0000 (15:13 -0700)]
[msan] Improve handling of Intrinsic::is_fpclass after c55fffe

c55fffe replaced fcmp with fpclass.

```
declare i1 @llvm.is.fpclass(<fptype> <op>, i32 <test>)
declare <N x i1> @llvm.is.fpclass(<vector-fptype> <op>, i32 <test>)
```

Perfect fix will require checking bits of <op> corresponding to <test>
argument. For now just propagate shadow without reporting before
intrinsic. Still existing handling of fcmp is also simple OR, so it's
not making it worse.

Reviewed By: eugenis

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

15 months ago[msan] Precommit test for regression from c55fffe
Vitaly Buka [Fri, 28 Apr 2023 21:52:27 +0000 (14:52 -0700)]
[msan] Precommit test for regression from c55fffe

Msan uses strict approach for unknown intrinsics like fpclass. So any
uninitialized bits in the value trigger msan report.

15 months ago[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records
Yusra Syeda [Fri, 28 Apr 2023 23:08:00 +0000 (19:08 -0400)]
[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records

This patch details the GOFF file format and implements the GOFFObjectfile class
with support for only the HDR, ESD and END GOFF records.

Reviewed By: jhenderson, kpn

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

15 months agoRevert "[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records"
Neumann Hon [Fri, 28 Apr 2023 23:06:17 +0000 (19:06 -0400)]
Revert "[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records"

This reverts commit 5b2423183cb35703723ec91ce5b93b99cec36fb2.

15 months ago[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records
Neumann Hon [Fri, 28 Apr 2023 23:00:45 +0000 (19:00 -0400)]
[SystemZ][z/OS] Add GOFFObjectFile class support for HDR, ESD and END records

This patch details the GOFF file format and implements the GOFFObjectfile class
with support for only the HDR, ESD and END GOFF records.

Reviewed By: jhenderson, kpn

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

15 months agofix a use-after-free failure
wlei [Fri, 28 Apr 2023 22:53:47 +0000 (15:53 -0700)]
fix a use-after-free failure

15 months ago[flang] Fixed branch-to-default generation for select_type.
Slava Zakharin [Fri, 28 Apr 2023 22:44:59 +0000 (15:44 -0700)]
[flang] Fixed branch-to-default generation for select_type.

When the default case requires block arguments, they have to be passed
through the cf.br - this piece was missing.

Reviewed By: clementval

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

15 months ago[libc][NFC] Start cleanup of time functions
Michael Jones [Fri, 28 Apr 2023 21:43:04 +0000 (14:43 -0700)]
[libc][NFC] Start cleanup of time functions

The time functions have not yet been updated to match our new coding
patterns. This patch removes some unnecessary includes, adjusts the
names of the test targets, and adds several TODO comments. It is my
intention to follow this patch up with additional cleanup.

Reviewed By: sivachandra, rtenneti

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

15 months ago[RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.
Craig Topper [Fri, 28 Apr 2023 22:41:17 +0000 (15:41 -0700)]
[RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

This allows the user to set the size of the scalable vector so they
can be used in structs and as the type of global variables. This works
by representing the type as a fixed vector instead of a scalable vector
in IR. Conversions to and from scalable vectors are made where necessary
like function arguments/returns and intrinsics.

This features has been requested here
https://github.com/riscv-non-isa/rvv-intrinsic-doc/issues/176
I know arm_sve_vector_bits is used by the Eigen library so this
could be used to port Eigen to RVV.

This patch adds a new preprocessor define `__riscv_v_fixed_vlen` that
is set when -mrvv_vector_bits is passed on the command line.

The code is largely based on the AArch64 code. A lot of code was
copy/pasted and then modiied to RVV. There may be some opportunities
for sharing.

This first patch only supports the LMUL=1 types. Additional changes
will be needed to support other LMULs. I have also not supported
mask vectors.

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

15 months ago[NFC] check for UnreachableInst first as it is cheaper compared to getTerminatingDeop...
AdityaK [Fri, 28 Apr 2023 22:29:41 +0000 (15:29 -0700)]
[NFC] check for UnreachableInst first as it is cheaper compared to getTerminatingDeoptimizeCall

Reviewers: craig.topper, aeubanks, Peter
Differential Revision: https://reviews.llvm.org/D134490

15 months ago[RISCV] Fix spelling consition -> condition. NFC
Craig Topper [Fri, 28 Apr 2023 22:08:19 +0000 (15:08 -0700)]
[RISCV] Fix spelling consition -> condition. NFC

15 months ago[gn build] Add gn flag to force enable stats
Arthur Eubanks [Fri, 28 Apr 2023 21:32:45 +0000 (14:32 -0700)]
[gn build] Add gn flag to force enable stats

15 months ago[LV] Rename Preheader -> VecPreheader (NFC).
Florian Hahn [Fri, 28 Apr 2023 21:15:23 +0000 (22:15 +0100)]
[LV] Rename Preheader -> VecPreheader (NFC).

Clarify variable name as suggested in D147964 to reduce diff.

15 months ago[gn build] Remove scudo sources that no longer exist
Arthur Eubanks [Fri, 28 Apr 2023 20:57:23 +0000 (13:57 -0700)]
[gn build] Remove scudo sources that no longer exist

15 months ago[libc] add exception to atof differential fuzz
Michael Jones [Thu, 27 Apr 2023 17:43:10 +0000 (10:43 -0700)]
[libc] add exception to atof differential fuzz

The differential fuzzer for atof found a bug in glibc's handling of
hexadecimal rounding. Since we can't easily update glibc and we want to
avoid false positives when running the fuzzer, I've added an exception
to skip all hexadecimal subnormal cases.

Reviewed By: sivachandra

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

15 months ago[HWASAN] Support short granules in __hwasan_test_shadow
Vitaly Buka [Fri, 28 Apr 2023 07:31:29 +0000 (00:31 -0700)]
[HWASAN] Support short granules in __hwasan_test_shadow

Reviewed By: thurston

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

15 months ago[MemProf] Use updated version of hot/cold operator new
Teresa Johnson [Fri, 28 Apr 2023 16:37:32 +0000 (09:37 -0700)]
[MemProf] Use updated version of hot/cold operator new

Switch to the just updated versions of the API in tcmalloc that change
the name of the hot cold paramter to a reserved identifier __hot_cold_t.
This was based on feedback from Richard Smith, as I also need to add
some follow-on handling to clang so they are annotated properly.

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

15 months ago[mlir][arith] Add narrowing pattern to commute extension over insertion
Jakub Kuderski [Fri, 28 Apr 2023 20:17:43 +0000 (16:17 -0400)]
[mlir][arith] Add narrowing pattern to commute extension over insertion

This enabled more optimization opportunities by moving
zero/sign-extension closer to the use.

Reviewed By: antiagainst

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

15 months ago[SamplePGO] Stale profile matching(part 2)
wlei [Thu, 6 Apr 2023 04:21:59 +0000 (21:21 -0700)]
[SamplePGO] Stale profile matching(part 2)

Part 2 of https://reviews.llvm.org/D147456
Use callee name on IR as an anchor to match the call target/inlinee name in the profile. The advantages of this in particular:
- Different from the traditional way of encoding hash signatures to every block that would affect binary/profile size and build speed, it doesn't require any additional information for this, all the data is already in the IR and profiles.
- Effective for current nested profile layout in which once a callsite is mismatched all the inlinee's profiles are dropped.
**The input of the algorithm:**
- IR locations: the anchor is the callee name of direct callsite.
- Profile locations: the anchor is the call target name for `BodySample`s or inlinee's profile name for `CallsiteSamples`.
The two lists are populated by parsing the IR and profile and both can be generalized as a sequence of locations with an optional anchor.
For example: say location `1.2(foo)` refers to a callsite at `1.2` with callee name `foo` and `1.3` refers to a non-directcall location `1.3`.
```
// The current build source code:
   int main() {
1.     ...
2.     foo();
3.     ...
4      ...
5.     ...
6.     bar();
7.     ...
   }
```
IR locations are populated and simplified as: `[1, 2(foo), 3, 5, 6(bar), 7]`.
```
; The "stale" profile:
main:350:1
 1: 1
 2: 3
 3: 100 foo:100
 4: 2
 7: 2
 8: 200 bar:200
 9: 30
```
Profile locations are populated and simplified as `[1, 2, 3(foo), 4, 7, 8(bar), 9]`
**Matching heuristic:**
- Match all the anchors in lexical order first.
- Match non-anchors evenly between two anchors: Split the non-anchor range, the first half is matched based on the start anchor, the second half is matched based on the end anchor.
So the example above is matched like:
```
   [1,    2(foo), 3,  5,  6(bar), 7]
    |     |       |   |     |     |
   [1, 2, 3(foo), 4,  7,  8(bar), 9]
```
3 -> 4 matching is based on anchor `foo`, 5 -> 7 matching is based on anchor `bar`.
The output mapping of matching is [2->3, 3->4, 5->7, 6->8, 7->9].

For the implementation, the anchors are saved in a map for fast look-up. The result mapping is saved into `IRToProfileLocationMap`(see https://reviews.llvm.org/D147456) and distributed to all FunctionSamples(`distributeIRToProfileLocationMap`)

**Clang-self build benchmark: **
Current build version: clang-10
The profiled version:  clang-9
Results compared to a refresh profile(collected profile on clang-10) and to be fair, we invalidated new functions' profiles(both refresh and stale profile use the same profile list).
1) Regression to using refresh profile with this off : -3.93%
2) Regression to using refresh profile with this on  : -1.1%
So this algorithm can recover ~72% of the regression.
**Internal(Meta) large-scale services.**
we saw one real instance of a 3 week stale profile., it delivered a ~1.8% win.

**Notes or future work:**
- Classic AutoFDO support: the current version only supports pseudo-probe, but I believe it's not hard to extend to classic line-number based AutoFDO since pseudo-probe and line-number are shared the LineLocation structure.
- The fuzzy matching is an open-ended area and there could be more heuristics to try out, but since the current version already recovers a reasonable percentage of regression(with some pseudo probe order change, it can recover close to 90%), I'm submitting the patch for review and we will try more heuristics in future.
- Profile call target name are only available when the call is hit by samples, the missing anchor might mislead the matching, this can be mitigated in llvm-profgen to generate the call target for the zero samples.
- This doesn't handle function name mismatch, we plan to solve it in future.

Reviewed By: hoy, wenlei

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

15 months ago[SamplePGO] Stale profile matching(part 1)
wlei [Mon, 27 Mar 2023 18:21:24 +0000 (11:21 -0700)]
[SamplePGO] Stale profile matching(part 1)

AutoFDO/CSSPGO often has to deal with stale profiles collected on binaries built from several revisions behind release. It’s likely to get incorrect profile annotations using the stale profile, which results in unstable or low performing binaries. Currently for source location based profile, once a code change causes a profile mismatch, all the locations afterward are mismatched, the affected samples or inlining info are lost. If we can provide a matching framework to reuse parts of the mismatched profile - aka incremental PGO, it will make PGO more stable, also increase the optimization coverage and boost the performance of binary.

This patch is the part 1 of stale profile matching, summary of the implementation:
 - Added a structure for the matching result:`LocToLocMap`, which is a location to location map meaning the location of current build is matched to the location of the previous build(to be used to query the “stale” profile).
 - In order to use the matching results for sample query, we need to pass them to all the location queries. For code cleanliness, we added a new pointer field(`IRToProfileLocationMap`) to `FunctionSamples`.
 - Added a wrapper(`mapIRLocToProfileLoc`) for the query to the location, the location from input IR will be remapped to the matched profile location.
 - Added a new switch `--salvage-stale-profile`.
 - Some refactoring for the staleness detection.

Test case is in part 2 with the matching algorithm.

Reviewed By: wenlei

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

15 months ago[lldb/crashlog] Fix JSON ObjectFile module loading issue
Med Ismail Bennani [Fri, 28 Apr 2023 19:50:02 +0000 (12:50 -0700)]
[lldb/crashlog] Fix JSON ObjectFile module loading issue

In 27f27d15f6c9, we added a new way to use textual (JSON) object files
and symbol files with the interactive crashlog command, using the
inlined symbols from the crash report.

However, there was a missing piece after successfully adding the textual
module to the target, we didn't mark it as available causing the module
loading to exit early.

This patch addresses that issue by marking the module as available when
added successfully to the target.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
15 months ago[IndVars] Add test for simplifying a induction cmp against global.
Florian Hahn [Fri, 28 Apr 2023 19:41:09 +0000 (20:41 +0100)]
[IndVars] Add test for simplifying a induction cmp against global.

15 months ago[NFC][SLP] Cleanup: Replace Value* operand with Instruction* in `vectorizeRootInstruc...
Vasileios Porpodas [Thu, 27 Apr 2023 21:54:34 +0000 (14:54 -0700)]
[NFC][SLP] Cleanup: Replace Value* operand with Instruction* in `vectorizeRootInstruction()` and `vectorizeHorReduction()`

This makes it explicit that these functions work with instructions, and avoids
calling them if the operand is not an instruction.

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

15 months ago[libc++] Fix __verbose_abort in C++11
Louis Dionne [Thu, 27 Apr 2023 17:54:09 +0000 (13:54 -0400)]
[libc++] Fix __verbose_abort in C++11

__use() can't be marked as constexpr in C++11 because it returns void,
which is not a literal type. But it turns out that we just don't need
to define it at all, since it's never called outside of decltype.

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

15 months ago[NFC][CLANG] Fix coverity remarks about large copy by values
Manna, Soumi [Fri, 28 Apr 2023 18:53:43 +0000 (11:53 -0700)]
[NFC][CLANG] Fix coverity remarks about large copy by values

Reported By Static Analyzer Tool, Coverity:

Big parameter passed by value
Copying large values is inefficient, consider passing by reference; Low, medium, and high size thresholds for detection can be adjusted.

1. Inside "CodeGenModule.cpp" file, in clang::CodeGen::CodeGenModule::EmitBackendOptionsMetadata(clang::CodeGenOptions): A very large function call parameter exceeding the high threshold is passed by value.

pass_by_value: Passing parameter CodeGenOpts of type clang::CodeGenOptions const (size 2168 bytes) by value, which exceeds the high threshold of 512 bytes.

2. Inside "SemaType.cpp" file, in IsNoDerefableChunk(clang::DeclaratorChunk): A large function call parameter exceeding the low threshold is passed by value.

pass_by_value: Passing parameter Chunk of type clang::DeclaratorChunk (size 176 bytes) by value, which exceeds the low threshold of 128 bytes.

3. Inside "CGNonTrivialStruct.cpp" file, in <unnamed>::getParamAddrs<1ull, <0ull...>>(std::integer_sequence<unsigned long long, T2...>, std::array<clang::CharUnits, T1>, clang::CodeGen::FunctionArgList, clang::CodeGen::CodeGenFunction *): A large function call parameter exceeding the low threshold is passed by value.

.i. pass_by_value: Passing parameter Args of type clang::CodeGen::FunctionArgList (size 144 bytes) by value, which exceeds the low threshold of 128 bytes.

4. Inside "CGGPUBuiltin.cpp" file, in <unnamed>::containsNonScalarVarargs(clang::CodeGen::CodeGenFunction *, clang::CodeGen::CallArgList): A very large function call parameter exceeding the high threshold is passed by value.

i. pass_by_value: Passing parameter Args of type clang::CodeGen::CallArgList (size 1176 bytes) by value, which exceeds the high threshold of 512 bytes.

Reviewed By: tahonermann

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

15 months ago[libc++] Clean up pair's constructors and assignment operators
Louis Dionne [Tue, 7 Feb 2023 23:21:08 +0000 (15:21 -0800)]
[libc++] Clean up pair's constructors and assignment operators

This patch makes std::pair's constructors and assignment operators
closer to conforming in C++23. The only missing bit I am aware of
now is `reference_constructs_from_temporary_v` checks, which we
don't have the tools for yet.

This patch also refactors a long-standing non-standard extension where
we'd provide constructors for tuple-like types in all standard modes. The
criteria for being a tuple-like type are different from pair-like types
as introduced recently in the standard, leading to a lot of complexity
when trying to implement recent papers that touch the pair constructors.

After this patch, the pre-C++23 extension is provided in a self-contained
block so that we can easily deprecate and eventually remove the extension
in future releases.

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

15 months ago[flang][openacc][NFC] Cleanup enter data lowering
Valentin Clement [Fri, 28 Apr 2023 18:50:47 +0000 (11:50 -0700)]
[flang][openacc][NFC] Cleanup enter data lowering

Remove copyinOperands, createOperands, createZeroOperands, attachOperands
SmallVectors as they are not used anymore.
The op itself cannot be cleanup yet because
`mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp`
still depends on it. The final clean up on the op will be down once
the translation uses the new data operand operations.

Reviewed By: vzakhari

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

15 months ago[Flang] Add a missing case for bfloat
Kiran Chandramohan [Fri, 28 Apr 2023 18:37:52 +0000 (18:37 +0000)]
[Flang] Add a missing case for bfloat

A case was missed for the bfloat type in the getRealType function
in FIRBuilder. This can cause a crash in some situations like in
the provided test. The patch adds the missing case.

Reviewed By: vzakhari

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

15 months ago[Clang][Doc] Added an open project for improving command line docs
Shivam Gupta [Fri, 28 Apr 2023 17:59:52 +0000 (23:29 +0530)]
[Clang][Doc] Added an open project for improving command line docs

There seems to be a lot of documentation is missing
for different command line flags uses.
This create confusion with same looking options, better to
document clearly their uses.

Reviewed By: aaron.ballman

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

15 months ago[mlir][arith] Add patterns to commute extension over vector extraction
Jakub Kuderski [Fri, 28 Apr 2023 17:48:48 +0000 (13:48 -0400)]
[mlir][arith] Add patterns to commute extension over vector extraction

This moves zero/sign-extension ops closer to their use and exposes more
narrowing optimization opportunities.

Reviewed By: antiagainst

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

15 months ago[clangd] Hover: resolve forwarding parameters for CalleeArgInfo
Tom Praschan [Sat, 8 Apr 2023 12:04:47 +0000 (14:04 +0200)]
[clangd] Hover: resolve forwarding parameters for CalleeArgInfo

This uses the logic added in D124690

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

15 months ago[Driver] Pass --target2= to linker from baremetal toolchain
Mikhail Maltsev [Fri, 28 Apr 2023 17:30:49 +0000 (18:30 +0100)]
[Driver] Pass --target2= to linker from baremetal toolchain

According to the GNU ld manual
https://sourceware.org/binutils/docs/ld/ARM.html#ARM the R_ARM_TARGET2
relocation (used in exception handling tables) is treated differently
depending on the target. By default, LLD treats R_ARM_TARGET2 as
R_ARM_GOT_PREL (--target2=got-rel), which is correct for Linux but not
for embedded targets.

This patch adds --target2=rel to linker options in the baremetal
toolchain driver so that on baremetal targets, R_ARM_TARGET2 is
treated as R_ARM_REL32. Such behavior is compatible with GNU ld and
unwinding libraries (e.g., libuwind).

Reviewed By: peter.smith, phosek

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

15 months ago[NFC] Fix a mem-sanitizer found issue in AutoType
Erich Keane [Fri, 28 Apr 2023 16:54:28 +0000 (09:54 -0700)]
[NFC] Fix a mem-sanitizer found issue in AutoType

We only need the list of constriant template arguments when we have a
valid constraint.  We give up on merging the auto-type constraints if
the template arguments don't match, but neglected to clear the
collection of template arguments.  The result was we had an AutoType
where we initialized the number of template arguments, but never
initialized the template arguments themselves.

This patch adds an assert to catch this in the future, plus ensures we
clear out the vector so we don't try to create the AutoType incorrectly.

15 months ago[NFC][SLP] Cleanup: Moves code that changes the reduction root into a separate function.
Vasileios Porpodas [Thu, 27 Apr 2023 18:22:12 +0000 (11:22 -0700)]
[NFC][SLP] Cleanup: Moves code that changes the reduction root into a separate function.

This makes `matchAssociativeReduction()` a bit simpler.

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

15 months ago[sanitizer] Remove crypt and crypt_r interceptors
Fangrui Song [Fri, 28 Apr 2023 16:59:17 +0000 (09:59 -0700)]
[sanitizer] Remove crypt and crypt_r interceptors

From Florian Weimer's D144073

> On GNU/Linux (glibc), the crypt and crypt_r functions are not part of the main shared object (libc.so.6), but libcrypt (with multiple possible sonames). The sanitizer libraries do not depend on libcrypt, so it can happen that during sanitizer library initialization, no real implementation will be found because the crypt, crypt_r functions are not present in the process image (yet). If its interceptors are called nevertheless, this results in a call through a null pointer when the sanitizer library attempts to forward the call to the real implementation.
>
> Many distributions have already switched to libxcrypt, a library that is separate from glibc and that can be build with sanitizers directly (avoiding the need for interceptors). This patch disables building the interceptor for glibc targets.

Let's remove crypt and crypt_r interceptors (D68431) to fix issues with
newer glibc.

For older glibc, msan will not know that an uninstrumented crypt_r call
initializes `data`, so there is a risk for false positives. However, with some
codebase survey, I think crypt_r uses are very few and the call sites typically
have a `memset(&data, 0, sizeof(data));` anyway.

Fix https://github.com/google/sanitizers/issues/1365
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2169432

Reviewed By: #sanitizers, fweimer, thesamesam, vitalybuka

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

15 months agoHost: generalise `GetXcodeSDKPath`
Saleem Abdulrasool [Fri, 28 Apr 2023 16:29:19 +0000 (09:29 -0700)]
Host: generalise `GetXcodeSDKPath`

This generalises the GetXcodeSDKPath hook to a GetSDKRoot path which
will be re-used for the Windows support to compute a language specific
SDK path on the platform. Because there may be other options that we
wish to use to compute the SDK path, sink the XcodeSDK parameter into
a structure which can pass a disaggregated set of options. Furthermore,
optionalise the parameter as Xcode is not available for all platforms.

Differential Revision: https://reviews.llvm.org/D149397
Reviewed By: JDevlieghere

15 months ago[flang][hlfir] Fixed hlfir.assign codegen for polymorphic LHS.
Slava Zakharin [Fri, 28 Apr 2023 16:07:23 +0000 (09:07 -0700)]
[flang][hlfir] Fixed hlfir.assign codegen for polymorphic LHS.

The RHS cannot be casted to the LHS type, when LHS is polymorphic.
With this change we will use the RHS type for emboxing with special
hadling for i1 type.

I created https://github.com/llvm/llvm-project/issues/62419 for the
AllocaOp generated during HLFIRtoFir conversion.

Reviewed By: jeanPerier

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

15 months agoHandle `select` in programUndefinedIfPoison.
Justin Lebar [Fri, 28 Apr 2023 06:31:26 +0000 (23:31 -0700)]
Handle `select` in programUndefinedIfPoison.

If both the true and false operands of a `select` are poison, then the `select`
is poison.

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

15 months ago[flang][hlfir] Fixed length-one assignment.
Slava Zakharin [Fri, 28 Apr 2023 15:50:55 +0000 (08:50 -0700)]
[flang][hlfir] Fixed length-one assignment.

Assignment from a character dummy argument to a length-one character
variable resulted in illegal fir.convert:
  %0 = fir.load %unboxed_dummy : !fir.ref<!fir.char<1,?>>
  %1 = fir.convert %0 : (!fir.char<1,?>) -> !fir.char<1>
  fir.store %1 to %local : !fir.ref<!fir.char<1>>

This change fixes the length-one assignment code to use proper casts.

For character dummy arguments with constant length we will now also
type cast the unboxed reference to the character type with constant length
during the lowering:
  fir.convert %x : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,8>>

I also adjusted the length-one assignment recognition so that in case
of same-length assignment we recognize length-one from either LHS or RHS
data types.

Reviewed By: jeanPerier

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

15 months ago[flang][hlfir] Fixed actual argument type for passing to poly dummy.
Slava Zakharin [Fri, 28 Apr 2023 00:45:06 +0000 (17:45 -0700)]
[flang][hlfir] Fixed actual argument type for passing to poly dummy.

The `none` type cannot be used for creating AssociateOp for the actual
argument. I think it should be always okay to compute the storage
data type based on the actual argument expression.

15 months ago[mlir][spirv] Fix nullptr dereference in UnifyAliasedResource
Jakub Kuderski [Fri, 28 Apr 2023 15:39:22 +0000 (11:39 -0400)]
[mlir][spirv] Fix nullptr dereference in UnifyAliasedResource

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

Reviewed By: antiagainst

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

15 months ago[RISCV] Introduce unaligned-vector-mem feature
Philip Reames [Fri, 28 Apr 2023 15:16:48 +0000 (08:16 -0700)]
[RISCV] Introduce unaligned-vector-mem feature

This allows us to model and thus test transforms which are legal only when a vector load with less than element alignment are supported. This was originally part of D126085, but was split out as we didn't have a good example of such a transform. As can be seen in the test diffs, we have the recently added concat_vector(loads) -> strided_load transform (from D147713) which now benefits from the unaligned support.

While making this change, I realized that we actually *do* support unaligned vector loads and stores of all types via conversion to i8 element type. For contiguous loads and stores without masking, we actually already implement this in the backend - though we don't tell the optimizer that. For indexed, lowering to i8 requires complicated addressing. For indexed and segmented, we'd have to use indexed. All around, doesn't seem worthwhile pursuing, but makes for an interesting observation.

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

15 months ago[llvm-gsymutil] Add gsymutil to llvm driver build
Alex Brachet [Fri, 28 Apr 2023 15:15:16 +0000 (15:15 +0000)]
[llvm-gsymutil] Add gsymutil to llvm driver build

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

15 months ago[RISCV] Consolidate legality checking for strided load/store [nfc]
Philip Reames [Fri, 28 Apr 2023 15:07:28 +0000 (08:07 -0700)]
[RISCV] Consolidate legality checking for strided load/store [nfc]

Note that the strided load from concat_vector combine was using the wrong legality test. It happened to work out as the alignment requirement is based on the scalar type either way, but unless I'm missing something allowsMisalignedAccess is expecting a contiguous memory access.

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

15 months ago[SCEV] Skip instrs with non-scevable types in visitAndClearUsers.
Florian Hahn [Fri, 28 Apr 2023 14:37:32 +0000 (15:37 +0100)]
[SCEV] Skip instrs with non-scevable types in visitAndClearUsers.

No SCEVs are formed for instructions with non-scevable types, so no
other SCEV expressions can depend on them. Skip those instructions and
their users when invalidating SCEV expressions.

Depends on D144847.

Reviewed By: mkazantsev

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

15 months ago[SCEV] Add tests for ptrtoint with different globals.
Florian Hahn [Fri, 28 Apr 2023 14:29:07 +0000 (15:29 +0100)]
[SCEV] Add tests for ptrtoint with different globals.

15 months ago[ARM] Enable shouldFoldSelectWithIdentityConstant for MVE
David Green [Fri, 28 Apr 2023 13:57:51 +0000 (14:57 +0100)]
[ARM] Enable shouldFoldSelectWithIdentityConstant for MVE

We already have tablegen patterns for a lot of these, but performing the
combine earlier in DAG can help in a few extra cases.

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

15 months ago[EarlyCSE] Do not CSE convergent calls in different basic blocks
Jay Foad [Thu, 27 Apr 2023 12:43:11 +0000 (13:43 +0100)]
[EarlyCSE] Do not CSE convergent calls in different basic blocks

"convergent" is documented as meaning that the call cannot be made
control-dependent on more values, but in practice we also require that
it cannot be made control-dependent on fewer values, e.g. it cannot be
hoisted out of the body of an "if" statement.

In code like this, if we allow CSE to combine the two calls:

  x = convergent_call();
  if (cond) {
    y = convergent_call();
    use y;
  }

then we get this:

  x = convergent_call();
  if (cond) {
    use x;
  }

This is conceptually equivalent to moving the second call out of the
body of the "if", up to the location of the first call, so it should be
disallowed.

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

15 months ago[CSE] Precommit an AMDGPU test case for D149348
Jay Foad [Thu, 27 Apr 2023 13:45:32 +0000 (14:45 +0100)]
[CSE] Precommit an AMDGPU test case for D149348

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

15 months ago[OpenMP] Add missing -L to libomptarget tests
Joel E. Denny [Fri, 28 Apr 2023 13:47:39 +0000 (09:47 -0400)]
[OpenMP] Add missing -L to libomptarget tests

Without this patch, if an incompatible libomptarget.so is present in a
system directory, such as /usr/lib64, check-openmp fails many
libomptarget tests with linking errors.  The problem appears to have
started at D129875, which landed as dc52712a0632.  This patch extends
the libomptarget test suite config with a -L for the current build
directory of libomptarget.so.

Reviewed By: jhuber6, JonChesterfield

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

15 months ago[SCEV] Use SmallDenseMap in SCEVRewriteVisitor (NFC)
Nikita Popov [Fri, 28 Apr 2023 12:37:29 +0000 (14:37 +0200)]
[SCEV] Use SmallDenseMap in SCEVRewriteVisitor (NFC)

15 months ago[AIX][llvm-ar] Use the Correct Kind for Bitcode File Inputs
Qiongsi Wu [Fri, 28 Apr 2023 12:42:51 +0000 (08:42 -0400)]
[AIX][llvm-ar] Use the Correct Kind for Bitcode File Inputs

On AIX, when the input files are LLVM bitcode files, `llvm-ar` should set the archive kind to `K_AIXBIG` as well, instead of leaving it to the default `K_GNU`.

Reviewed By: daltenty

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

15 months ago[AArch64] Add preserve_all calling convention.
Daniel Kiss [Fri, 28 Apr 2023 12:01:51 +0000 (14:01 +0200)]
[AArch64] Add preserve_all calling convention.

Clang accepts preserve_all for AArch64 while it is missing form the backed.

Fixes #58145

Reviewed By: efriedma

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

15 months ago[ARM] Update and regenerate pred-selectop test. NFC
David Green [Fri, 28 Apr 2023 12:47:14 +0000 (13:47 +0100)]
[ARM] Update and regenerate pred-selectop test. NFC

Shift and fdiv tests have been added to show the reverse transform.

15 months ago[SCEV] Don't invalidate past dependency-breaking instructions
Nikita Popov [Thu, 27 Apr 2023 07:36:35 +0000 (09:36 +0200)]
[SCEV] Don't invalidate past dependency-breaking instructions

When invalidating a value, we walk all users of that value and
invalidate them as well. This can be very expensive for large use
graphs.

However, we only need to invalidate a user U of instruction I if
SCEV(U) can depend on SCEV(I). This is not the case if U is an
instruction that always produces a SCEVUnknown, such as a load.
If the load pointer operand is invalidated, there is no need to
invalidate the load result, which is completely unrelated from a
SCEV perspective.

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

15 months ago[LICM] Don't duplicate instructions just because they're free
Nikita Popov [Wed, 26 Apr 2023 08:00:42 +0000 (10:00 +0200)]
[LICM] Don't duplicate instructions just because they're free

D37076 makes LICM duplicate instructions into exit blocks if the
instruction is free. For GEPs, the motivation appears to be that
this allows the GEP to be folded into addressing modes, while
non-foldable users outside the loop might prevent this. TBH I don't
think LICM is the place to do this (why doesn't CGP apply this
heuristic itself?) but at least I understand the motivation.

However, the transform is also applied to all other "free"
instructions, which are just that (removed during lowering and not
"folded" in some way). For such instructions, this transform seems
somewhere between useless, counter-productive (undoing CSE/GVN) and
actively incorrect. For example, this transform can duplicate freeze
instructions, which is illegal.

This patch limits the transform to just foldable GEPs, though we
might want to drop it from LICM entirely as a followup.

This is a small compile-time improvement, because querying TTI cost
model for every single instruction is expensive.

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

15 months agoRevert "[BOLT] Parallelize legacy profile merging"
Yi Kong [Fri, 28 Apr 2023 12:24:52 +0000 (21:24 +0900)]
Revert "[BOLT] Parallelize legacy profile merging"

This reverts commit 35af20d9e036deeed250b73fd3ae86d6455173c5.

The patch caused a test failure.

15 months ago[PGO] Fix expensive test compilation error
Christian Ulmann [Fri, 28 Apr 2023 12:10:47 +0000 (12:10 +0000)]
[PGO] Fix expensive test compilation error

This commit fixes a compilation error introduced in
https://reviews.llvm.org/D149361

Reviewed By: gysit

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

15 months ago[LV] Add tests for integer min max with index reduction pattern. (NFC)
Mel Chen [Thu, 23 Mar 2023 09:01:29 +0000 (02:01 -0700)]
[LV] Add tests for integer min max with index reduction pattern. (NFC)

The test case for signed max with index, include strict and non-strict
max.

Reviewed By: fhahn

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

15 months ago[VPlan] Turn Plan entry node into VPBasicBlock (NFCI).
Florian Hahn [Fri, 28 Apr 2023 11:29:05 +0000 (12:29 +0100)]
[VPlan] Turn Plan entry node into VPBasicBlock (NFCI).

The entry to the plan is the preheader of the vector loop and
guaranteed to be a VPBasicBlock. Make sure this is the case by
adjusting the type.

Reviewed By: Ayal

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

15 months ago[clang] Diagnose shadowing of lambda's template parameter by a capture
Mariya Podchishchaeva [Fri, 28 Apr 2023 10:26:35 +0000 (06:26 -0400)]
[clang] Diagnose shadowing of lambda's template parameter by a capture

expr.prim.lambda.capture p5 says:
If an identifier in a capture appears as the declarator-id of a parameter of
the lambda-declarator's parameter-declaration-clause or as the name of a
template parameter of the lambda-expression's template-parameter-list,
the program is ill-formed.
and also has the following example:
```
auto h = [y = 0]<typename y>(y) { return 0; };
```
which now results in
```
error: declaration of 'y' shadows template parameter
  auto l1 = [y = 0]<typename y>(y) { return 0; };
             ^
note: template parameter is declared here
  auto l1 = [y = 0]<typename y>(y) { return 0; };
                             ^
```

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

Reviewed By: shafik, cor3ntin

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

15 months agoRe-apply "[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer"
Bjorn Pettersson [Sun, 16 Apr 2023 21:17:58 +0000 (23:17 +0200)]
Re-apply "[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer"

A new attempt after removing uses of -instnamer in polly lit tests
in D148530.

15 months ago[polly] Drop redundant use of -instnamer in polly MemAccess lit tests
Bjorn Pettersson [Mon, 17 Apr 2023 14:07:15 +0000 (16:07 +0200)]
[polly] Drop redundant use of -instnamer in polly MemAccess lit tests

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

15 months ago[RISCV] Fix labels in fixed-vectors-fp test
Luke Lau [Fri, 28 Apr 2023 11:00:47 +0000 (12:00 +0100)]
[RISCV] Fix labels in fixed-vectors-fp test

15 months agoReland D147337 "[tsan] Add debugging interfaces into interface header."
Pierre Gousseau [Mon, 17 Apr 2023 14:32:57 +0000 (14:32 +0000)]
Reland D147337 "[tsan] Add debugging interfaces into interface header."

This change the types to match the ones used in:
Darwin/debug_external.cpp
debugging.cpp

Reviewed By: vitalybuka

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

15 months ago[TEST][LICM] Add test cases on widenable condition hoisting opportunity
Max Kazantsev [Fri, 28 Apr 2023 10:52:54 +0000 (17:52 +0700)]
[TEST][LICM] Add test cases on widenable condition hoisting opportunity

Patch by Aleksandr Popov!

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

15 months agoReapply D146987 "[Assignment Tracking] Enable by default"
OCHyams [Fri, 28 Apr 2023 08:43:50 +0000 (09:43 +0100)]
Reapply D146987 "[Assignment Tracking] Enable by default"

See https://discourse.llvm.org/t/rfc-enable-assignment-tracking/69399

This sets the -Xclang -fexperimental-assignment-tracking flag to the value
enabled which means it will be enabled so long as none of the following are
true: it's an LTO build, LLDB debugger tuning has been specified, or it's an O0
build (no work is done in any case if -g is not specified or -gmlt is used).

This reverts commit 0ba922f600469df273c753f873668e41025487c0 which reverts
https://reviews.llvm.org/D146987

15 months ago[OpenMP] Add LIT test on task depend clause
Animesh Kumar [Thu, 23 Mar 2023 09:28:01 +0000 (14:58 +0530)]
[OpenMP] Add LIT test on task depend clause

The working of depend clause with iterator modifier
can be correctly tested by means of execution tests
and not at the LLVM IR level. These tests
are imported/inspired from the SOLLVE tests.

SOLLVE repo: https://github.com/SOLLVE/sollve_vv

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

15 months ago[AArch64] Add support for efficient bitcast in vector truncate store.
Lawrence Benson [Fri, 28 Apr 2023 10:19:45 +0000 (11:19 +0100)]
[AArch64] Add support for efficient bitcast in vector truncate store.

Following the changes in D145301, we now also support the efficient bitcast
when storing the bool vector. Previously, this was expanded.

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

15 months agoRevert "[LLD][ELF] Fix compressed-debug-level test on SystemZ"
Ulrich Weigand [Fri, 28 Apr 2023 10:17:44 +0000 (12:17 +0200)]
Revert "[LLD][ELF] Fix compressed-debug-level test on SystemZ"

This reverts commit f2404d589ece81b029c607af011c372d52bff8d2,
which causes failures on Windows.

15 months ago[LCSSA] Don't invalidate entire loop in SCEV
Nikita Popov [Thu, 27 Apr 2023 09:36:21 +0000 (11:36 +0200)]
[LCSSA] Don't invalidate entire loop in SCEV

We already invalidate each individual instruction for which LCSSA
is formed in formLCSSAForInstructions(), so I don't see a reason
why we would need to invalidate the entire loop on top of that.

I believe we also no longer need the instruction-level invalidation
now that SCEV looks through LCSSA phis, but I'll leave that for a
separate patch, as it's less obvious.

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

15 months ago[LangRef] Update shufflevector's semantics to return poison if the mask is undef
ManuelJBrito [Thu, 27 Apr 2023 17:11:14 +0000 (18:11 +0100)]
[LangRef] Update shufflevector's semantics to return poison if the mask is undef

This patch changes the shufflevector's semantics to yield poison if the mask is undefined.
This allows the extraction of shufflevectors while also opening the door for more
optimization opportunities due to the fact that poison is more undefined than undef.

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

15 months ago[LV] Add tests for #60831.
Florian Hahn [Fri, 28 Apr 2023 09:42:01 +0000 (10:42 +0100)]
[LV] Add tests for #60831.

Also contains an extra test mentioned in D144434.

15 months ago[AArch64][FastISel] Handle CRC32 intrinsics
Alexis Engelke [Fri, 21 Apr 2023 12:15:04 +0000 (14:15 +0200)]
[AArch64][FastISel] Handle CRC32 intrinsics

With a similar reason as D148023; some applications make heavy use of
the CRC32 intrinsic (e.g., as part of a hash function) and therefore
benefit from avoiding frequent SelectionDAG fallbacks. In our
application, we get a 2% compile-time improvement.

Reviewed By: efriedma

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

15 months ago[VP] Add more functional SD opcodes to definitions
Luke Lau [Mon, 17 Apr 2023 09:56:56 +0000 (10:56 +0100)]
[VP] Add more functional SD opcodes to definitions

This defines more equivalent base SD opcodes for various VP nodes, so
that getVPForBaseOpcode can do more lookups of VP-equivalent operations.

Reviewed By: frasercrmck

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

15 months ago[RISCV] Add tests for illegal fixed length vectors that need widened
Luke Lau [Fri, 14 Apr 2023 18:49:41 +0000 (19:49 +0100)]
[RISCV] Add tests for illegal fixed length vectors that need widened

Reviewed By: craig.topper

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