platform/upstream/llvm.git
13 months ago[CUDA] plumb through new sm_90-specific builtins.
Artem Belevich [Mon, 22 May 2023 22:14:40 +0000 (15:14 -0700)]
[CUDA] plumb through new sm_90-specific builtins.

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

13 months ago[NVPTX] add new sm90-specific intrinsics.
Artem Belevich [Fri, 19 May 2023 20:21:28 +0000 (13:21 -0700)]
[NVPTX] add new sm90-specific intrinsics.

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

13 months ago[CUDA] bump supported CUDA version to 12.1/11.8
Artem Belevich [Wed, 24 May 2023 00:51:09 +0000 (17:51 -0700)]
[CUDA] bump supported CUDA version to 12.1/11.8

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

13 months ago[CUDA] Relax restrictions on variadics in host-side compilation.
Artem Belevich [Wed, 24 May 2023 19:13:41 +0000 (12:13 -0700)]
[CUDA] Relax restrictions on variadics in host-side compilation.

D150718 allows variadics during GPU compilation, but we also need to do it for
the host compilation as well, as it will see the same code.

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

13 months ago[compiler-rt] Use ZLIB_FOUND not LLVM_ENABLE_ZLIB
Alex Brachet [Thu, 25 May 2023 18:55:47 +0000 (18:55 +0000)]
[compiler-rt] Use ZLIB_FOUND not LLVM_ENABLE_ZLIB

LLVM_ENABLE_ZLIB is set to On by default and does not imply that ZLIB
was actually found, only being set to FORCE_ON would imply that it was
found before control reached compiler-rt/test/CMakeLists.txt. Instead,
use ZLIB_FOUND which guarantees that zlib is available.

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

13 months agoRevert "[clang][diagnostics] Add -Wpacked-non-pod to -Wall"
Aaron Ballman [Thu, 25 May 2023 18:50:51 +0000 (14:50 -0400)]
Revert "[clang][diagnostics] Add -Wpacked-non-pod to -Wall"

This reverts commit 9ed3d85e26d8594440bca84fe868a62ac6560ac8.

It broke some bots:
https://lab.llvm.org/buildbot/#/builders/245/builds/8876

13 months ago[InstCombine] Improve bitreverse optimization
Austin Chang [Thu, 25 May 2023 17:10:31 +0000 (12:10 -0500)]
[InstCombine] Improve bitreverse optimization

This patch utilizes the helper function implemented in D149699 and thus folds the following cases:

```
bitreverse(logic_op(x, bitreverse(y))) -> logic_op(bitreverse(x), y)
bitreverse(logic_op(bitreverse(x), y)) -> logic_op(x, bitreverse(y))
bitreverse(logic_op(bitreverse(x), bitreverse(y))) -> logic_op(x, y) in multiuse case
```

Reviewed By: goldstein.w.n, RKSimon

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

13 months ago[InstCombine] Add regression test cases for bitreverse optimization; NFC
Austin Chang [Thu, 25 May 2023 17:10:31 +0000 (12:10 -0500)]
[InstCombine] Add regression test cases for bitreverse optimization; NFC

Fold the following case on IR InstCombine pass. This patch includes the new test cases for this optimization

```
bitreverse(logic_op(x, bitreverse(y))) -> logic_op(bitreverse(x), y)
bitreverse(logic_op(bitreverse(x), y)) -> logic_op(x, bitreverse(y))
bitreverse(logic_op(bitreverse(x), bitreverse(y))) -> logic_op(x, y) with multi-use
```

Reviewed By: goldstein.w.n

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

13 months ago[-Wunsafe-buffer-usage] Group variables associated by pointer assignments
Rashmi Mudduluru [Thu, 25 May 2023 18:28:03 +0000 (11:28 -0700)]
[-Wunsafe-buffer-usage] Group variables associated by pointer assignments

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

13 months ago[clang][diagnostics] Add -Wpacked-non-pod to -Wall
Zenong Zhang [Thu, 25 May 2023 18:17:29 +0000 (14:17 -0400)]
[clang][diagnostics] Add -Wpacked-non-pod to -Wall

Users will be informed when non-POD is not packed using -Wall. This is
also consistent with GCC.

Fixes https://github.com/llvm/llvm-project/issues/60832
Differential Revision: https://reviews.llvm.org/D151162

13 months ago[scudo] releaseToOSMaybe can fail if it can't allocate PageMap
Chia-hung Duan [Thu, 25 May 2023 17:36:10 +0000 (17:36 +0000)]
[scudo] releaseToOSMaybe can fail if it can't allocate PageMap

PageMap is allocated with MAP_ALLOWNOMEM if there's no static buffer
left. So it can be failed and return nullptr without any assertion
triggered. Instead of crashing in the releaseToOSMaybe in the middle,
just return and let the program handles the page failure.

Reviewed By: cferris

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

13 months ago[SelectionDAG][AArch64][ARM] Remove setFlags call from DAGTypeLegalizer::SetPromotedI...
Craig Topper [Thu, 25 May 2023 18:01:19 +0000 (11:01 -0700)]
[SelectionDAG][AArch64][ARM] Remove setFlags call from DAGTypeLegalizer::SetPromotedInteger.

This was originally added to preserve FMF on SETCC. Unfortunately,
it also incorrectly preserves nuw/nsw on ADD/SUB in some cases.

There's also no guarantee the new opcode is even the same opcode
as the original node.

This patch removes the code and adds code to explicitly preserve
FMF flags in the SETCC promotion function.

The other test changes are from nuw/nsw not being preserved. I
believe for all these tests it was correct to preserve the flags,
so we need new code to preserve the flags when possible. I'll post
another patch for that since it's a riskier change.

This should unblock D150769.

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

13 months ago[CodeGen] Make __clang_call_terminate have an unwind table entry
Shoaib Meenai [Thu, 25 May 2023 01:32:38 +0000 (18:32 -0700)]
[CodeGen] Make __clang_call_terminate have an unwind table entry

This enables unwinders to step past that frame on architectures that
don't use DWARF unwinding (such as armv7), e.g. when debugging. The
problem should theoretically be architecture-agnostic, but according to
https://discourse.llvm.org/t/51633/2 it gets masked on architectures
that use DWARF unwind info.

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

Reviewed By: efriedma, rnk

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

13 months agoAdd missing dependency for tests.
Sterling Augustine [Thu, 25 May 2023 17:51:59 +0000 (10:51 -0700)]
Add missing dependency for tests.

13 months ago[libc++][test] Mark throw_format_error as noreturn.
Mark de Wever [Thu, 25 May 2023 17:45:50 +0000 (19:45 +0200)]
[libc++][test] Mark throw_format_error as noreturn.

This fixes and GCC error. This was tested in D135787.

13 months ago[lldb][nfc] Refactor methods with out parameter
Felipe de Azevedo Piovezan [Thu, 25 May 2023 11:24:30 +0000 (07:24 -0400)]
[lldb][nfc] Refactor methods with out parameter

Currently, the method `GetAttributeAddressRanges` takes a DWARFRangeList as a
parameter, just to immediately clear it. The method also returns the size of
this list. Such an API was obfuscating the intent of the call sites (it's not
clear from the method name what it returns) and it was obfuscating redundant
checks on the size of the list.

This commit refactors the method to return the list and to also make the call
sites use the more explicit `IsEmpty` method.

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

13 months agoFix "[sanitizer_common] Support stripping interceptor prefixes in RenderFrame()"
Marco Elver [Thu, 25 May 2023 17:36:50 +0000 (19:36 +0200)]
Fix "[sanitizer_common] Support stripping interceptor prefixes in RenderFrame()"

RenderFrame() has several implementations, which was missed in
01cea39f8e11012ac96b36ef60bfaf2f3b64320b.

Fix the one in sanitizer_symbolizer_markup.cpp.

Reported-by: gulfem
13 months ago[flang] Don't convert actual argument if IGNORE_TKR is present for the corresponding...
Kelvin Li [Thu, 25 May 2023 16:47:56 +0000 (12:47 -0400)]
[flang] Don't convert actual argument if IGNORE_TKR is present for the corresponding dummy

This patch is to remove the conversion of the actual argument that
is associated with the dummy argument specified with the IGNORE_TKR
directive.

Commit on behalf of @danielcchen

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

13 months ago[mlir][tensor] TrackingListener: Support cast-like InsertSliceOps with dynamic shape
Matthias Springer [Thu, 25 May 2023 17:10:05 +0000 (19:10 +0200)]
[mlir][tensor] TrackingListener: Support cast-like InsertSliceOps with dynamic shape

When looking for payload op replacements, rank-expanding InsertSliceOps of dynamically-typed tensors are now supported.

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

13 months ago[MLIR][sparse][GPU] fixing windows build break caused by D151014
Kun Wu [Thu, 25 May 2023 17:12:03 +0000 (17:12 +0000)]
[MLIR][sparse][GPU] fixing windows build break caused by D151014

Reviewed By: aartbik

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

13 months ago[mlir][Interfaces] ValueBoundsOpInterface: Check if two values are equal
Matthias Springer [Thu, 25 May 2023 17:03:17 +0000 (19:03 +0200)]
[mlir][Interfaces] ValueBoundsOpInterface: Check if two values are equal

Add a helper function that computes if two SSA values have the same value, utilizing the `ValueBoundsOpInterface` infrastructure. Two SSA values have the same value, an equality bound of 0 can be derived for their subtraction.

The helper function can also be used to determine if two tensor dimension sizes are equal.

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

13 months ago[mlir][openacc][NFC] Fix verifier message
Valentin Clement [Thu, 25 May 2023 17:03:50 +0000 (10:03 -0700)]
[mlir][openacc][NFC] Fix verifier message

Reviewed By: vzakhari, jeanPerier

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

13 months ago[mlir][Interfaces][NFC] ValueBoundsConstraintSet: Simplify constructor
Matthias Springer [Thu, 25 May 2023 16:50:27 +0000 (18:50 +0200)]
[mlir][Interfaces][NFC] ValueBoundsConstraintSet: Simplify constructor

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

13 months ago[Inliner] Mark inlinings stopped with inlining history as noinline
Arthur Eubanks [Fri, 19 May 2023 19:35:01 +0000 (12:35 -0700)]
[Inliner] Mark inlinings stopped with inlining history as noinline

The inline history makes sure that we don't keep inlining due to mutual devirtualization. But this gets forgotten between inliner invocations.

So mark the inlined calls as noinline so we respect previous inline history decisions.

This overlaps with D121084, but they're not redundant since we may not inline completely through a child SCC, but we still want a cost multiplier when that happens.

See discussions in D145516.

Reviewed By: jmorse

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

13 months ago[lldb][nfc] Place comment in the right place
Felipe de Azevedo Piovezan [Thu, 25 May 2023 11:23:06 +0000 (07:23 -0400)]
[lldb][nfc] Place comment in the right place

This line has been misplaced since it was introduced in 2011 by
c26e4454035a4160cffc3c865cf83be194ca38c4.

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

13 months ago[AST] Initialized data after TypeSourceInfo
Vitaly Buka [Sat, 13 May 2023 00:06:27 +0000 (17:06 -0700)]
[AST] Initialized data after TypeSourceInfo

There is no initialization of the data between allocation
and first getBeginLoc call.

allocation: llvm-project/clang/lib/AST/ASTContext.cpp:3022
use: llvm-project/clang/lib/AST/TypeLoc.cpp:222

Msan report https://reviews.llvm.org/P8306

Reviewed By: thurston

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

13 months agoFix nested block constructs for SELECT CASE
Carlos Eduardo Seo [Sat, 20 May 2023 05:16:50 +0000 (05:16 +0000)]
Fix nested block constructs for SELECT CASE

In some scenarios, a SELECT CASE could cause an error while lowering to FIR.
This was caused by a spurious extra branch added after the end statement.

Fixes #62726

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

13 months ago[Clang] Switch from TransformExpr to TransformInitializer in places we need to revert...
Shafik Yaghmour [Thu, 25 May 2023 16:44:10 +0000 (09:44 -0700)]
[Clang] Switch from TransformExpr to TransformInitializer in places we need to revert initializer to it syntactic form for Sema

In some cases we are using TransformExpr instead of
TransformInitializer, this results in ExprWithCleanups being dropped and
we are not emitting a destructor as a result.

This fixes: https://github.com/llvm/llvm-project/issues/62818

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

13 months ago[mlir][tensor] TrackingListener: Find replacement ops through cast-like InsertSliceOps
Matthias Springer [Thu, 25 May 2023 16:06:02 +0000 (18:06 +0200)]
[mlir][tensor] TrackingListener: Find replacement ops through cast-like InsertSliceOps

Certain InsertSliceOps, that do not use elements from the destination, are treated like casts when looking for replacement ops. Such InsertSliceOps are typically rank expansions.

Tensors with dynamic shape are not supported at the moment.

Also adds test cases for the TrackingListener.

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

13 months ago[mlir] Return new scf.forall handle in fuse_into_containing_op
Harsh Menon [Thu, 25 May 2023 10:32:59 +0000 (03:32 -0700)]
[mlir] Return new scf.forall handle in fuse_into_containing_op

Since the scf.forall is now consumed by the fuse into
containing op, we need to return a handle to the new scf.forall.
This patch does that and also ensures that the new bbArg
added to the scf.forall is used in its body.

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

13 months ago[Pipeline] Don't run EarlyFPM in LTO post link
Arthur Eubanks [Mon, 22 May 2023 18:07:51 +0000 (11:07 -0700)]
[Pipeline] Don't run EarlyFPM in LTO post link

EarlyFPM cleans up the output of the frontend. This isn't necessary in post link pipelines as the pre link pipeline already ran this.

~0.4% savings in ThinLTO builds:
https://llvm-compile-time-tracker.com/compare.php?from=8a5d4eb775c644d8683f24817d44c510d2b853b7&to=3580252a2162eadca0da99f1eeaa112f74a0353d&stat=instructions:u

Reviewed By: tejohnson

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

13 months ago[unittest][codegen] Avoid memory leak in recently added FindDebugLocTest unittest
Bjorn Pettersson [Thu, 25 May 2023 16:15:11 +0000 (18:15 +0200)]
[unittest][codegen] Avoid memory leak in recently added FindDebugLocTest unittest

Need to finalize the DIBuilder to avoid leak sanitizer errors
like this:

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x55c99ea1761d in operator new(unsigned long)
    #1 0x55c9a518ae49 in operator new
    #2 0x55c9a518ae49 in llvm::MDTuple::getImpl(...)
    #3 0x55c9a4f1b1ec in getTemporary
    #4 0x55c9a4f1b1ec in llvm::DIBuilder::createFunction(...)

13 months ago[mlir][bytecode] Avoid recording null arglocs & realloc opnames.
Jacques Pienaar [Thu, 25 May 2023 16:24:50 +0000 (09:24 -0700)]
[mlir][bytecode] Avoid recording null arglocs & realloc opnames.

For block arg locs a common case is no/uknown location (where the producer
signifies they don't care about blockarg location). Also avoid needing to
dynamically resize opnames during parsing.

Assumed to be post lazy loading change, so chose version 3.

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

13 months ago[mlir] Change the order of members in MLIRContext to ensure dialects are destroyed...
Laszlo Kindrat [Thu, 25 May 2023 13:23:49 +0000 (09:23 -0400)]
[mlir] Change the order of members in MLIRContext to ensure dialects are destroyed first

Currently, the dialects precede the registered operations in the context object, which means that the latter is destroyed first. At the same time, Operation::~Operation dereferences the registered operation when destroying properties, which can cause use-after-free (e.g. if a dialect owns an op). This patch fixes that by changing the order of the members so that dialects come after registered operations.

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

13 months ago[StandardInstrumentations] Add option to dump IR to a file on crash
Arthur Eubanks [Mon, 22 May 2023 23:00:18 +0000 (16:00 -0700)]
[StandardInstrumentations] Add option to dump IR to a file on crash

We already have -print-on-crash which dumps the IR to stderr on a crash, but it's more useful to dump to a file.

Introduce -print-on-crash-path to dump the IR to a file.

Making -print-on-crash a string option is confusing if you only pass -print-on-crash and it swallows up the next command line arg, which is why this is a new option.

Perhaps we could retire the dump to stderr version if people don't use it, but not sure how much people find that useful.

Reviewed By: jamieschmeiser

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

13 months agoDiscussion: Darwin Sanitizers Stable ABI
Roy Sundahl [Thu, 9 Feb 2023 20:43:54 +0000 (12:43 -0800)]
Discussion: Darwin Sanitizers Stable ABI

# Darwin Sanitizers Stable ABI

We wish to make it possible to include the AddressSanitizer (ASan) runtime implementation in OSes and for this we need a stable ASan ABI. Based on previous discussions about this topic, our understanding is that freezing the present ABI would impose an excessive burden on other sanitizer developers and for unrelated platforms. Therefore, we propose adding a secondary stable ABI for our use and anyone else in the community seeking the same. We believe that we can define a stable ABI with minimal burden on the community, expecting only to keep existing tests running and implementing stubs when new features are added. We are okay with trading performance for stability with no impact for existing users of ASan while minimizing the maintenance burden for ASan maintainers. We wish to commit this functionality to the LLVM project to maintain it there. This new and stable ABI will abstract away the implementation details allowing new and novel approaches to ASan for developers, researchers and others.

## Details

Rather than adding a lot of conditional code to the LLVM instrumentation phase, which would incur excessive complexity and maintenance cost of adding conditional code into all places that emit a runtime call, we propose a “shim” layer which will map the unstable ABI to the stable ABI:

* A static library (.a library) shim that maps the existing ASan ABI to a generalized, smaller and stable ABI. The library would implement the __asan functions and call into the new ABI. For example:
    * `void __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); }`
    * `void __asan_load2(uptr p) { __asan_abi_loadn(p, 2, true); }`
    * `void __asan_noabort_load16(uptr p) { __asan_abi_loadn(p, 16, false); }`
    * `void __asan_poison_cxx_array_cookie(uptr p) { __asan_abi_pac(p); }`
* This “shim” library would only be used by people who opt in: A compilation flag in the Clang driver will be used to gate the use of the stable ABI workflow.
* Utilize the existing ability for the ASan instrumentation to prefer runtime calls instead of inlined direct shadow memory accesses.
* Pursue (under the new driver flag) a better separation of abstraction and implementation with:
    * LLVM instrumentation: Calling out for all poisoning, checking and unpoisoning.
    * Runtime: Implementing the stable ABI and being responsible of implementation details of the shadow memory.

## Maintenance

Our aim is that the maintenance burden on the sanitizer developer community be negligible. Stable ABI tests will always pass for non-Darwin platforms. Changes to the existing ABI which would require a change to the shim have been infrequent as the ASan ABI is already relatively stable. Rarely, a change that impacts the contract between LLVM and the shim will occur. Among such foreseeable changes are: 1) changes to a function signature, 2) additions of new functions, or 3) deprecation of an existing function. Following are some examples of reasonable responses to those changes:

* Example: An existing ABI function is changed to return the input parameter on success or NULL on failure. In this scenario, a reasonable change to the shim would be to modify the function signature appropriately and to simply guess at a common-sense implementation.
    * `uptr __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); return p; }`
* Example: An additional function is added for performance reasons. It has a very similar function signature to other similarly named functions and logically is an extension of that same pattern. In this case it would make sense to apply the same logic as the existing entry points:
    * `void __asan_load128(uptr p) { __asan_abi_loadn(p, 128, true); }`
* Example: An entry point is added to the existing ABI for which there is no obvious stable ABI implementation: In this case, doing nothing in a no-op stub would be acceptable, assuming existing features of ASan can still work without an actual implementation of this new function.
    * `void __asan_prefetch(uptr p) { }`
* Example: An entrypoint in the existing ABI is deprecated and/or deleted:
    * (Delete the entrypoint from the shim.)

We’re looking for buy-in for this level of support.

(Note: Upon acceptance of the general concepts herein, we will add a controlling clang flag, cmake integration, contract for the stable ABI, and the appropriate test infrastructure.)

Reviewed By: eugenis, vitalybuka, MaskRay

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

13 months ago[asan] Fix Windows tests after StripFunctionName() improvements
Marco Elver [Thu, 25 May 2023 15:52:33 +0000 (17:52 +0200)]
[asan] Fix Windows tests after StripFunctionName() improvements

Stacktraces should no longer show __asan_wrap_, but the "normal"
function name.

Reflect that in tests.

13 months ago[flang][hlfir] Use actual type when copying an actual argument variable
Jean Perier [Thu, 25 May 2023 15:42:04 +0000 (17:42 +0200)]
[flang][hlfir] Use actual type when copying an actual argument variable

The copy must made according to the actual type, not the dummy type. In
case the dummy is polymorphic, these types will be different and the
dynamic type of the copy passed in the call should be the one of the
actual.

There is no support for "class(t), value" yet (it is hitting a TODO in
CallInterface that is moot for HLFIR but has not been lifted for lack of
proper testing) so the bug was dormant, but D151271 created a situation
where a copy is needed with polymorphic dummies and exposed the bug.
This led to a compile time assert
"value.isScalar() && fir::isa_trivial(value.getType())" in "hlfir::genAssociateExpr".

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

13 months ago[InlineCost] Consider branches with !make.implicit metadata as free.
Denis Antrushin [Tue, 2 May 2023 17:16:42 +0000 (00:16 +0700)]
[InlineCost] Consider branches with !make.implicit metadata as free.

!make.implicit metadata attached to branch means it will very likely
be eliminated (together with associated cmp instruction).

Reviewed By: apilipenko

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

13 months agosanitizer-common: temporarily disable release_to_os test for powerpc64
Thurston Dang [Thu, 25 May 2023 15:36:37 +0000 (15:36 +0000)]
sanitizer-common: temporarily disable release_to_os test for powerpc64

release_to_os has been failing on powerpc64 since yesterday. Temporarily disabling the test to prevent this error from
hiding other potential problems.

13 months ago[ADT] Allow specifying the size of resulting `SmallVector` in `map_to_vector`
Laszlo Kindrat [Mon, 15 May 2023 19:04:19 +0000 (15:04 -0400)]
[ADT] Allow specifying the size of resulting `SmallVector` in `map_to_vector`

This patch adds an overload for the `map_to_vector` helper template, exposing a parameter to control the size of the resulting `SmallVector`. A few call sites in mlir are updated to illustrate and test the change.

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

13 months ago[ThinLTO] Disable partial sample profile scaling by default
Teresa Johnson [Tue, 23 May 2023 20:02:48 +0000 (13:02 -0700)]
[ThinLTO] Disable partial sample profile scaling by default

As pointed out in
https://discourse.llvm.org/t/undeterministic-thin-index-file/69985, the
block count added to distributed ThinLTO index files breaks incremental
builds on ThinLTO - if any linked file has a different number of BBs,
then the accumulated sum placed in the index files will change, causing
all ThinLTO backend compiles to be redone.

This was only used for partial sample profiles, and was therefore
removed for other cases (3adc6e03080c6d38a51f5c5b6744b7c0d9c7541b).

Subsequent testing did not show a performance effect of disabling this
feature even for partial sample profiles. Therefore, switch the default
to false. If this does not cause a noticeable performance degradation
after the default flip, we can remove this support completely.

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

13 months agoAvoid pointless canonicalize when using Dwarf names
Mark Santaniello [Thu, 25 May 2023 15:11:40 +0000 (08:11 -0700)]
Avoid pointless canonicalize when using Dwarf names

CPU profile indicated memcmp was hot due to the two rfind calls in
getCanonicalFnName. If UseSymbolTable is false, we can avoid the cost entirely.

For CSSPGO profiles I've measured ~5% speedup with this change.

Profile similarity before/after matches 100%.

Reviewed By: wenlei

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

13 months ago[mlir] Enable folding memref alias for`vector.load`
Guray Ozen [Thu, 25 May 2023 14:10:38 +0000 (16:10 +0200)]
[mlir] Enable folding memref alias for`vector.load`

This work enables  folding memref alias pass for`vector.load`

Reviewed By: qcolombet

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

13 months ago[KnownBits] Simplify shl. NFCI.
Jay Foad [Thu, 25 May 2023 10:02:50 +0000 (11:02 +0100)]
[KnownBits] Simplify shl. NFCI.

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

13 months ago[APInt] Add unsigned overloads of shift functions
Jay Foad [Thu, 25 May 2023 10:56:06 +0000 (11:56 +0100)]
[APInt] Add unsigned overloads of shift functions

Add overloads of sshl_ov, ushl_ov, sshl_sat and ushl_sat that take the
shift amount as unsigned instead of APInt. This matches what we do for
the normal shift operators and can help to avoid creating temporary
APInts in some cases.

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

13 months ago[libc][test] Drastically reduce mem test runtime
Guillaume Chatelet [Thu, 25 May 2023 14:29:26 +0000 (14:29 +0000)]
[libc][test] Drastically reduce mem test runtime

Reviewed By: lntue

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

13 months ago[KnownBits] Check functions that return zero for poison results
Jay Foad [Thu, 25 May 2023 14:51:00 +0000 (15:51 +0100)]
[KnownBits] Check functions that return zero for poison results

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

13 months ago[libc++][PSTL] Make sure that -fexperimental-library enables the PSTL
Nikolas Klauser [Tue, 23 May 2023 19:06:53 +0000 (12:06 -0700)]
[libc++][PSTL] Make sure that -fexperimental-library enables the PSTL

@Mordante noticed that this was missing while making `<format>` non-experimental.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits, Mordante

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

13 months ago[libc++] Forward to std::{,w}memchr in std::find
Nikolas Klauser [Wed, 24 May 2023 21:37:22 +0000 (14:37 -0700)]
[libc++] Forward to std::{,w}memchr in std::find

Reviewed By: #libc, ldionne

Spies: Mordante, libcxx-commits, ldionne, mikhail.ramalho

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

13 months ago[RISCV] Add test coverage for shuffle/insert idioms which can become v(f)slide1ups
Philip Reames [Thu, 25 May 2023 14:51:14 +0000 (07:51 -0700)]
[RISCV] Add test coverage for shuffle/insert idioms which can become v(f)slide1ups

13 months ago[clang][dataflow] Fix a crash in `getLogicOperatorSubExprValue()`.
Martin Braenne [Thu, 25 May 2023 09:22:37 +0000 (09:22 +0000)]
[clang][dataflow] Fix a crash in `getLogicOperatorSubExprValue()`.

This patch adds a test that crashes without the fix.

Reviewed By: ymandel

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

13 months ago[GlobalIsel][X86] fix legalization of G_CTLZ and G_CTPOP
Thorsten Schütt [Wed, 17 May 2023 15:36:55 +0000 (17:36 +0200)]
[GlobalIsel][X86] fix legalization of G_CTLZ and G_CTPOP

Note that the builders are protected by is64Bit().

More fine-grained availibility checks.

Reviewed By: RKSimon

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

13 months ago[ELF] x86-64: place .lrodata, .lbss, and .ldata away from code sections
Fangrui Song [Thu, 25 May 2023 14:35:38 +0000 (07:35 -0700)]
[ELF] x86-64: place .lrodata, .lbss, and .ldata away from code sections

The x86-64 medium code model utilizes large data sections, namely .lrodata,
.lbss, and .ldata (along with some variants of .ldata). There is a proposal to
extend the use of large data sections to the large code model as well[1].

This patch aims to place large data sections away from code sections in order to
alleviate relocation overflow pressure caused by code sections referencing
regular data sections.

```
.lrodata
.rodata
.text     # if --ro-segment, MAXPAGESIZE alignment
RELRO     # MAXPAGESIZE alignment
.data     # MAXPAGESIZE alignment
.bss
.ldata    # MAXPAGESIZE alignment
.lbss
```

In comparison to GNU ld, which places .lbss, .lrodata, and .ldata after .bss, we
place .lrodata above .rodata to minimize the number of permission transitions in
the memory image.

While GNU ld places .lbss after .bss, the subsequent sections don't reuse the
file offset bytes of BSS.

Our approach is to place .ldata and .lbss after .bss and create a PT_LOAD
segment for .bss to large data section transition in the absence of SECTIONS
commands. assignFileOffsets ensures we insert an alignment instead of allocating
space for BSS, and therefore we don't waste more than MAXPAGESIZE bytes. We have
a missing optimization to prevent all waste, but implementing it would introduce
complexity and likely be error-prone.

GNU ld's layout introduces 2 more MAXPAGESIZE alignments while ours
introduces just one.

[1]: https://groups.google.com/g/x86-64-abi/c/jnQdJeabxiU "Large data sections for the large code model"

With help from Arthur Eubanks.

Co-authored-by: James Y Knight <jyknight@google.com>
Reviewed By: aeubanks, tkoeppe

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

13 months ago[flang][hlfir] address post-commit comments from D151247 and D151251
Jean Perier [Thu, 25 May 2023 11:11:15 +0000 (04:11 -0700)]
[flang][hlfir] address post-commit comments from D151247 and D151251

Addresses comments not addressed in https://reviews.llvm.org/D151251
and https://reviews.llvm.org/D151247

- Fix typo in comments.
- Update an expected test output to include the fir.allocmem argument.
- Make a more generic type comparisons and cast when fetching value
  back from the AnyValueStack temporary storage.

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

13 months ago[NFC][DAGCombiner]: Only consider nodes with no uses for pruning when forming initial...
Dhruv Chawla [Wed, 24 May 2023 07:25:22 +0000 (12:55 +0530)]
[NFC][DAGCombiner]: Only consider nodes with no uses for pruning when forming initial worklist

When the worklist is initially being formed, there is no need to
consider all nodes for pruning. This is because the first time calling
getNextWorklistEntry will only clear those nodes which have no uses,
with their operands being added to the worklist. However, when the worklist is
created for the first time all nodes are added anyways, so this operation
actually ends up adding no nodes.

This patch adds a parameter IsCandidateForPruning to AddToWorklist with a
default value of true to avoid having to update every call site.

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

13 months agoFix build file for https://github.com/llvm/llvm-project/commit/12648492998bd22d268eb1...
Aliia Khasanova [Thu, 25 May 2023 11:36:55 +0000 (13:36 +0200)]
Fix build file for https://github.com/llvm/llvm-project/commit/12648492998bd22d268eb1d4d476c6c3acc6c43d

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

13 months ago[RISCV] Fix -Wunused-variable in release builds. NFCI
Alexander Kornienko [Thu, 25 May 2023 12:45:28 +0000 (14:45 +0200)]
[RISCV] Fix -Wunused-variable in release builds. NFCI

Fix -Wunused-variable in release builds

Reviewed By: krasimir

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

13 months ago[X86] Regenerate x86-32-intrcc.ll test checks
Simon Pilgrim [Thu, 25 May 2023 13:13:59 +0000 (14:13 +0100)]
[X86] Regenerate x86-32-intrcc.ll test checks

This will allow us to improve the diffs for D151400

13 months ago[CodeGen] Fix for MachineBasicBlock::rfindDebugLoc(instr_rend())
Bjorn Pettersson [Thu, 25 May 2023 10:57:33 +0000 (12:57 +0200)]
[CodeGen] Fix for MachineBasicBlock::rfindDebugLoc(instr_rend())

Make sure we do not crash in rfindDebugLoc when starting at
instr_rend(). Solution is to see it as we start one MI before the
first MI, so we can start searching forward at instr_begin()
instead.

This behavior is similar to how findPrevDebugLoc(instr_end()) works.

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

13 months ago[CodeGen] Add unittest for findDebugLoc, rfindDebugLoc, findPrevDebugLoc and rfindPre...
Bjorn Pettersson [Mon, 15 May 2023 12:40:00 +0000 (14:40 +0200)]
[CodeGen] Add unittest for findDebugLoc, rfindDebugLoc, findPrevDebugLoc and rfindPrevDebugLoc. NFC

- Add some unittests for the findDebugLoc, rfindDebugLoc,
  findPrevDebugLoc and rfindPrevDebugLoc helpers in MachineBasicBlock.

- Clean up code comments and code formatting related to the functions
  mentioned above.

This was extracted as a pre-commit to D150577, adn some of the tests
are commented out since they would crash/assert in a rather
uncontrolled way.

13 months ago[DWARFLinker] Set size of location expression of DW_FORM_block1 properly.
Alexey Lapshin [Wed, 24 May 2023 13:38:44 +0000 (15:38 +0200)]
[DWARFLinker] Set size of location expression of DW_FORM_block1 properly.

This patch fixes the problem introduced by D147066. As D147066 may change
the contents of location expression, it started to calculate final attribute
size. This patch uses more correct way to calculate size: DIEValue::sizeOf().

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

13 months ago[clang][dataflow][NFC] Remove unused variable.
Martin Braenne [Thu, 25 May 2023 12:02:39 +0000 (12:02 +0000)]
[clang][dataflow][NFC] Remove unused variable.

Thanks to chapuni to pointing this out on
https://reviews.llvm.org/D151183.

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

13 months ago[sanitizer_common] Fix StripFunctionName() on Windows
Marco Elver [Thu, 25 May 2023 11:04:43 +0000 (13:04 +0200)]
[sanitizer_common] Fix StripFunctionName() on Windows

Also implement StripFunctionName() on Windows to properly strip
interceptor prefixes.

Reported-by: https://lab.llvm.org/buildbot#builders/127/builds/48810
13 months ago[mlir] Enable folding memref alias for `ldmatrix`
Guray Ozen [Thu, 25 May 2023 09:16:46 +0000 (11:16 +0200)]
[mlir] Enable folding memref alias for `ldmatrix`

Folding mechanism does not recognize `ldmatrix` op. This work helps pass to recognize the op and fold the memref aliases.

Reviewed By: nicolasvasilache

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

13 months ago[flang][hlfir] fix regression in inline elementals
Tom Eccles [Tue, 23 May 2023 11:38:17 +0000 (11:38 +0000)]
[flang][hlfir] fix regression in inline elementals

InlineElementals created a regression when inlining elemental
expressions where the type of the result of the hlfir.apply does not
match the hlfir.yield.

This patch ensures the pass doesn't match in these cases, fixing the
regression.

It isn't clear to me what the /right/ solution is:
 - Is it actually valid for the hlfir.apply to have a different type
   (even just different array bounds?). Should this be enforced in the
   verifier?
 - Inserting a convert if these types don't match doesn't work because
   fir.convert doesn't know how to convert a hlfir.expr. Should this be
   added?

Test case is from @vzakhari

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

13 months ago[Lex] Warn when defining or undefining any builtin macro
John Brawn [Mon, 23 Jan 2023 17:40:59 +0000 (17:40 +0000)]
[Lex] Warn when defining or undefining any builtin macro

Currently we warn when MI->isBuiltinMacro, but this is only true for
builtin macros that require processing when expanding. Checking
SourceMgr.isWrittenInBuiltinFile in addition to this will mean that
we catch all builtin macros, though we shouldn't warn on feature test
macros.

As part of doing this I've also moved the handling of undefining from
CheckMacroName to HandleUndefDirective, as it doesn't really make
sense to handle undefining in CheckMacroName but defining in
HandleDefineDirective. It would be nice to instead handle both in
CheckMacroName, but that isn't possible as the handling of defines
requires looking at what the name is being defined to.

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

13 months ago[IRTranslator][NFC] Refactor if/else chain into early returns
Felipe de Azevedo Piovezan [Tue, 23 May 2023 14:27:34 +0000 (10:27 -0400)]
[IRTranslator][NFC] Refactor if/else chain into early returns

This will make it easier to add more cases in a subsequent commit and also
better conforms to the coding guidelines.

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

13 months ago[gn build] Port e837f4b7dbc3
LLVM GN Syncbot [Thu, 25 May 2023 10:16:02 +0000 (10:16 +0000)]
[gn build] Port e837f4b7dbc3

13 months ago[gn] port e837f4b7dbc3 (_LIBCPP_PSTL_CPU_BACKEND_SERIAL)
Nico Weber [Thu, 25 May 2023 10:15:35 +0000 (06:15 -0400)]
[gn] port e837f4b7dbc3 (_LIBCPP_PSTL_CPU_BACKEND_SERIAL)

13 months ago[AArch64] add missing prfm-slc disassembly test
Tomas Matheson [Mon, 22 May 2023 15:33:41 +0000 (16:33 +0100)]
[AArch64] add missing prfm-slc disassembly test

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

13 months ago[sanitizer_common] Check 'demangle' flag in StripFunctionName and DemangleFunctionName
Marco Elver [Thu, 25 May 2023 09:10:48 +0000 (11:10 +0200)]
[sanitizer_common] Check 'demangle' flag in StripFunctionName and DemangleFunctionName

To allow getting the original stack trace.

Reviewed By: dvyukov

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

13 months ago[msan] Strip __interceptor_ from reports
Marco Elver [Thu, 25 May 2023 09:08:06 +0000 (11:08 +0200)]
[msan] Strip __interceptor_ from reports

Showing __interceptor_ as part of the function name in reports does not
make sense and is distracting.

Strip the interceptor function name before printing.

Reviewed By: dvyukov, vitalybuka

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

13 months ago[sanitizer_common] Support stripping interceptor prefixes in RenderFrame()
Marco Elver [Thu, 25 May 2023 09:08:00 +0000 (11:08 +0200)]
[sanitizer_common] Support stripping interceptor prefixes in RenderFrame()

Rather than having every tool pass the right interceptor prefix, just
move this logic into RenderFrame().

Note that currently there are a few cases where due to aliasing the
intercepted function -> interceptor, the unwinder sees the intercepted
function - however this is never guaranteed. In a later change this
becomes more apparent, and other non-tsan sanitizer tests would fail as
well. By making the default RenderFrame() strip interceptor prefixes, we
don't rely on the linker aliasing preferences.

Reviewed By: dvyukov, vitalybuka, MaskRay

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

13 months ago[compiler-rt] Unify Linux and *BSD interceptors more
Marco Elver [Thu, 25 May 2023 09:07:55 +0000 (11:07 +0200)]
[compiler-rt] Unify Linux and *BSD interceptors more

The Linux and *BSD interceptors are almost identical, except for *BSD,
where the overridden intercepted function is not defined weak due to
some incompliant linker behaviour.

Since most of the interception machinery is shared between Linux and
*BSD (see INTERCEPT_FUNCTION macro), it makes sense to unify interceptor
definition and declarations as much as possible to ease future changes.

NFC.

Reviewed By: dvyukov, vitalybuka

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

13 months ago[compiler-rt] Introduce asm macros for interceptor trampolines
Marco Elver [Thu, 25 May 2023 09:07:50 +0000 (11:07 +0200)]
[compiler-rt] Introduce asm macros for interceptor trampolines

This introduces macros for asm sources to define trampolines, and
aliases to trampolines.

Because we currently do not yet have any real trampolines, this change
is a NFC.

Reviewed By: dvyukov, vitalybuka

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

13 months ago[compiler-rt] Introduce the notion of an interceptor trampoline
Marco Elver [Thu, 25 May 2023 09:07:36 +0000 (11:07 +0200)]
[compiler-rt] Introduce the notion of an interceptor trampoline

To make the interceptor implementation more flexible, allowing for 2
levels of indirection instead of just 1 in the current scheme (where the
intercepted function aliases the interceptor implementation), introduce
the notion of an interceptor "trampoline".

A trampoline may be a real function (and not just an alias, where
aliases of aliases do not work), which will simply forward to the
interceptor implementation; the intercepted function will then alias the
trampoline:

func -[alias]-> trampoline -[call]-> interceptor

Make the necessary changes to prepare for introducing real trampolines.

This change does not yet introduce any real trampolines, and so
trampoline == interceptor, and we currently still just have:

func -[alias]-> interceptor

NFC.

Reviewed By: dvyukov, vitalybuka, MaskRay

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

13 months ago[flang][hlfir] Generate temporary storage in Forall/Where [2/2]
Jean Perier [Thu, 25 May 2023 09:55:55 +0000 (11:55 +0200)]
[flang][hlfir] Generate temporary storage in Forall/Where [2/2]

Generate temporary storage inside WHERE and FORALL using the temporary
stack runtime. This covers all cases outside of LHS temporary, where the
descriptor stack will have to be used.

Reviewed By: vzakhari

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

13 months ago[flang][hlfir] Generate temporary storage in Forall/Where [1/2]
Jean Perier [Thu, 25 May 2023 09:17:16 +0000 (11:17 +0200)]
[flang][hlfir] Generate temporary storage in Forall/Where [1/2]

Generate temporary storage inline inside WHERE and FORALL when possible.
A following patch will use the runtime to cover the generic cases.

Reviewed By: vzakhari

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

13 months ago[GuardUtils] Allow intermmediate blocks between widenable branch and deopt block
Serguei Katkov [Wed, 24 May 2023 04:22:54 +0000 (11:22 +0700)]
[GuardUtils] Allow intermmediate blocks between widenable branch and deopt block

Reviewed By: anna
Differential Revision: https://reviews.llvm.org/D151082

13 months ago[mlir] Add pass to enable Armv9 Streaming SVE mode
Cullen Rhodes [Thu, 25 May 2023 09:13:15 +0000 (09:13 +0000)]
[mlir] Add pass to enable Armv9 Streaming SVE mode

This patch adds a pass 'enable-arm-streaming' that enables the Armv9
Scalable Matrix Extension (SME) Streaming SVE (SSVE) mode [1] by adding
either of the following attributes to 'func.func' ops:

  * arm_streaming (default)
  * arm_locally_streaming

PATCH [2 / 2] in series for RFC: https://discourse.llvm.org/t/rfc-supporting-armv9-scalable-matrix-extension-sme-streaming-sve-ssve-mode-in-mlir/70678

[1] https://developer.arm.com/documentation/ddi0616/aa

Reviewed By: awarzynski, dcaballe

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

13 months ago[mlir][llvm] Add arm_streaming LLVM function attributes
Cullen Rhodes [Thu, 25 May 2023 08:57:19 +0000 (08:57 +0000)]
[mlir][llvm] Add arm_streaming LLVM function attributes

This patch adds two optional attributes to 'llvm.func' op for the Armv9
Streaming SVE (SSVE) mode [1] that map 1-1 with LLVM function attributes [2]:

  * arm_streaming -> aarch64_pstate_sm_enabled
  * arm_locally_streaming -> aarch64_pstate_sm_body

Streaming-mode is part of the interface (ABI) for functions with the
first attribute and it's the responsibility of the caller to manage
PSTATE.SM on entry/exit to functions with this attribute [3]. The LLVM
backend will emit 'smstart sm' / 'smstop sm' [4] around calls to
streaming functions.

In locally streaming functions PSTATE.SM is kept internal and managed by
the callee on entry/exit. The LLVM backend will emit 'smstart sm' /
'smstop sm' in the prologue / epilogue for functions with this
attribute.

The integration test for SSVE has been updated to no longer use the
passthrough mechanism that's intended for prototyping.

PATCH [1 / 2] in series for RFC: https://discourse.llvm.org/t/rfc-supporting-armv9-scalable-matrix-extension-sme-streaming-sve-ssve-mode-in-mlir/70678

[1] https://developer.arm.com/documentation/ddi0616/aa
[2] https://llvm.org/docs/AArch64SME.html#introduction
[3] https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#671pstatesm-interfaces
[4] https://developer.arm.com/documentation/ddi0602/2023-03/Base-Instructions/SMSTART--Enables-access-to-Streaming-SVE-mode-and-SME-architectural-state--an-alias-of-MSR--immediate--

Reviewed By: awarzynski, dcaballe, WanderAway

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

13 months ago[NFC] Add more python reformat SHA to .git-blame-ignore-revs
Tobias Hieta [Thu, 25 May 2023 09:17:29 +0000 (11:17 +0200)]
[NFC] Add more python reformat SHA to .git-blame-ignore-revs

13 months ago[NFC][Py Reformat] Reformat python files in the rest of the dirs
Tobias Hieta [Wed, 17 May 2023 14:59:41 +0000 (16:59 +0200)]
[NFC][Py Reformat] Reformat python files in the rest of the dirs

This is an ongoing series of commits that are reformatting our
Python code. This catches the last of the python files to
reformat. Since they where so few I bunched them together.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: jhenderson, #libc, Mordante, sivachandra

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

13 months ago[NFC] Add libcxx python reformat SHA to .git-blame-ignore-revs
Tobias Hieta [Thu, 25 May 2023 09:16:01 +0000 (11:16 +0200)]
[NFC] Add libcxx python reformat SHA to .git-blame-ignore-revs

13 months ago[NFC][Py Reformat] Reformat python files in libcxx/libcxxabi
Tobias Hieta [Wed, 17 May 2023 09:09:29 +0000 (11:09 +0200)]
[NFC][Py Reformat] Reformat python files in libcxx/libcxxabi

This is an ongoing series of commits that are reformatting our
Python code.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: #libc, kwk, Mordante

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

13 months agoRevert "[SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits()"
Nikita Popov [Thu, 25 May 2023 09:11:42 +0000 (11:11 +0200)]
Revert "[SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits()"

This reverts commit b66551370fdfc6f357ae0d77237119d2b1077b62.

This has exposed a pre-existing miscompile, reported in
https://reviews.llvm.org/D150769#4370467.

13 months agoRevert "[-Wunsafe-buffer-usage] Group variables associated by pointer assignments"
Douglas Yung [Thu, 25 May 2023 09:01:50 +0000 (02:01 -0700)]
Revert "[-Wunsafe-buffer-usage] Group variables associated by pointer assignments"

This reverts commit ee6b08e99375fc48d1e5848704a66c2e8e57eb3b.

One of the added tests warn-unsafe-buffer-usage-multi-decl-warnings.cpp does
not seem to be deterministic, and seems to be especially problematic on Windows.

Failures of this one test on llvm-clang-x86_64-sie-win:
- https://lab.llvm.org/buildbot/#/builders/216/builds/21758
- https://lab.llvm.org/buildbot/#/builders/216/builds/21761
- https://lab.llvm.org/buildbot/#/builders/216/builds/21762
- https://lab.llvm.org/buildbot/#/builders/216/builds/21765
- https://lab.llvm.org/buildbot/#/builders/216/builds/21770
- https://lab.llvm.org/buildbot/#/builders/216/builds/21771
- https://lab.llvm.org/buildbot/#/builders/216/builds/21773
- https://lab.llvm.org/buildbot/#/builders/216/builds/21776
- https://lab.llvm.org/buildbot/#/builders/216/builds/21777
- https://lab.llvm.org/buildbot/#/builders/216/builds/21778
- https://lab.llvm.org/buildbot/#/builders/216/builds/21779

Other random bot failures:
- https://lab.llvm.org/buildbot/#/builders/65/builds/9821
- https://lab.llvm.org/buildbot/#/builders/65/builds/9822
- https://lab.llvm.org/buildbot/#/builders/65/builds/9824
- https://lab.llvm.org/buildbot/#/builders/119/builds/13440
- https://lab.llvm.org/buildbot/#/builders/119/builds/13442
- https://lab.llvm.org/buildbot/#/builders/119/builds/13444
- https://lab.llvm.org/buildbot/#/builders/119/builds/13445
- https://lab.llvm.org/buildbot/#/builders/60/builds/12156
- https://lab.llvm.org/buildbot/#/builders/60/builds/12157
- https://lab.llvm.org/buildbot/#/builders/60/builds/12160

13 months ago[FuncSpec] Enable specialization of literal constants.
Alexandros Lamprineas [Wed, 24 May 2023 11:31:05 +0000 (12:31 +0100)]
[FuncSpec] Enable specialization of literal constants.

To do so we have to tweak the cost model such that specialization
does not trigger excessively.

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

13 months ago[clang][dataflow] Add support for return values of reference type.
Martin Braenne [Tue, 23 May 2023 09:35:52 +0000 (09:35 +0000)]
[clang][dataflow] Add support for return values of reference type.

This patch changes the way `Environment::ReturnLoc` is set: Whereas previously it was set by the caller, it is now set by the callee (obviously, as we otherwise would not be able to return references).

The patch also introduces `Environment::ReturnVal`, which is used for non-reference-type return values. This allows these to be handled with the correct value category semantics; see also https://discourse.llvm.org/t/70086, which describes the ongoing migration to strict value category semantics.

Depends On D150776

Reviewed By: ymandel, xazax.hun

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

13 months ago[RISCV] Don't reduce vslidedown's VL in rotations
Luke Lau [Wed, 24 May 2023 23:48:56 +0000 (00:48 +0100)]
[RISCV] Don't reduce vslidedown's VL in rotations

Even though we only need to write to the bottom NumElts - Rotation
elements for the vslidedown.vi, we can save an extra vsetivli toggle if
we just keep the wide VL.

(I may be missing something here: is there a reason why we want to explicitly keep the vslidedown narrow?)

Reviewed By: craig.topper

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

13 months ago[CodeGen][ShrinkWrap] Enable PostShrinkWrap by default
sgokhale [Thu, 25 May 2023 08:24:47 +0000 (13:54 +0530)]
[CodeGen][ShrinkWrap] Enable PostShrinkWrap by default

This is an attempt to reland D42600 and enabling this optimisation by default.

This also resolves the issue pointed out in the context of PGO build.

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

13 months ago-fsanitize=function: fix alignment fault on Arm targets.
Simon Tatham [Wed, 24 May 2023 08:28:33 +0000 (09:28 +0100)]
-fsanitize=function: fix alignment fault on Arm targets.

Function pointers are checked by loading a prefix structure from just
before the function's entry point. However, on Arm, the function
pointer is not always exactly equal to the address of the entry point,
because Thumb function pointers have the low bit set to tell the BX
instruction to enter them in Thumb state. So the generated code loads
from an odd address and suffers an alignment fault.

Fixed by clearing the low bit of the function pointer before
subtracting 8.

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

13 months ago[KnownBits] Add support for nuw/nsw on shifts
Nikita Popov [Mon, 22 May 2023 12:21:56 +0000 (14:21 +0200)]
[KnownBits] Add support for nuw/nsw on shifts

Implement precise nuw/nsw support in the KnownBits implementation,
replacing the rather crude handling in ValueTracking.

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

13 months ago[mlir] Removing unnecessary includes from Memref dialect
John Demme [Thu, 25 May 2023 08:01:51 +0000 (08:01 +0000)]
[mlir] Removing unnecessary includes from Memref dialect

`MemRefMemorySlot.cpp` had two unused includes without a cmake
dependency on the dialects they were in. Led to build failures.

13 months agoReapply [SCEV] Replace IsAvailableOnEntry with block disposition
Nikita Popov [Thu, 27 Apr 2023 13:11:02 +0000 (15:11 +0200)]
Reapply [SCEV] Replace IsAvailableOnEntry with block disposition

This exposed an issue in SCEVExpander/LCSSA, which has been fixed
in D150681.

-----

As far as I understand, the IsAvailableOnEntry() function basically
implements the same functionality as the properlyDominates() block
disposition. The primary difference (apart from a weaker
implementation) seems to be in this comment at the top:

    // Checks if the SCEV S is available at BB.  S is considered available at BB
    // if S can be materialized at BB without introducing a fault.

However, I don't really understand why there would be such a
requirement. It's my understanding that SCEV explicitly does not
care about trapping udiv instructions itself, and it's the job of
SCEVExpander's isSafeToExpand() to make sure these don't get
expanded if they may trap.

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

13 months ago[clangd] Dont run raw-lexer for OOB source locations
Kadir Cetinkaya [Wed, 24 May 2023 12:22:43 +0000 (14:22 +0200)]
[clangd] Dont run raw-lexer for OOB source locations

We can get stale source locations from preamble, make sure we don't
access those locations without checking first.

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

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

13 months ago[SCEVExpander] Remember phi nodes inserted by LCSSA construction
Nikita Popov [Tue, 16 May 2023 15:05:58 +0000 (17:05 +0200)]
[SCEVExpander] Remember phi nodes inserted by LCSSA construction

SCEVExpander keeps track of all instructions it inserted. However,
it currently misses some phi nodes created during LCSSA construction.
Fix this by collecting these into another argument.

This also removes the IRBuilder argument, which was added for
essentially the same purpose, but only handles the root LCSSA nodes,
not those inserted by SSAUpdater.

This was reported as a regression on D149344, but the reduced test
case also reproduces without it.

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

13 months agoFix MLIR bytecode loading of resources
Mehdi Amini [Thu, 25 May 2023 04:52:05 +0000 (21:52 -0700)]
Fix MLIR bytecode loading of resources

The bytecode reader didn't handle properly the case where resource names
conflicted and were renamed, leading to orphan handles in the IR as well
as overwriting the exiting resources.

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

13 months agoSpecialize OwningOpRef::operator-> to work with pointers like Operation*
Mehdi Amini [Thu, 25 May 2023 05:01:48 +0000 (22:01 -0700)]
Specialize OwningOpRef::operator-> to work with pointers like Operation*

This just simplifies user code.

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