platform/upstream/llvm.git
16 months agorun-clang-tidy.py should only search for the clang-apply-replacements if really needed
Anonymous [Tue, 7 Mar 2023 08:56:00 +0000 (14:26 +0530)]
run-clang-tidy.py should only search for the clang-apply-replacements if really needed

run-clang-tidy.py should only search for the clang-apply-replacements if really needed.

Reviewed By: carlosgalvezp

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

16 months ago[SCEV] Use fallthoughs in predicate switch when collecting rewrites for loop guard...
Dmitry Makogon [Mon, 6 Mar 2023 11:58:31 +0000 (18:58 +0700)]
[SCEV] Use fallthoughs in predicate switch when collecting rewrites for loop guard (NFC)

16 months ago[CodeGen][AArch64] Precommit additional tests for integer MLA/MAD/MLS/MSB (NFC)
sgokhale [Tue, 7 Mar 2023 08:28:34 +0000 (13:58 +0530)]
[CodeGen][AArch64] Precommit additional tests for integer MLA/MAD/MLS/MSB (NFC)

This forms the base for upcoming patch to generate pseudo instructions for MLA/MAD/MLS/MSB.

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

16 months ago[flang][hlfir] Map scalar character symbols in internal procedures
Jean Perier [Tue, 7 Mar 2023 07:59:57 +0000 (08:59 +0100)]
[flang][hlfir] Map scalar character symbols in internal procedures

I missed `addCharSymbol` in the patch adding the hlfir.declare in
internal procedures for "captured" entities (https://reviews.llvm.org/D143481).

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

16 months ago[libc] Add a headers.txt for linux/arm config.
Siva Chandra Reddy [Tue, 7 Mar 2023 07:46:16 +0000 (07:46 +0000)]
[libc] Add a headers.txt for linux/arm config.

16 months ago[analyzer] Explicit cast on customized offsetof should not be ignored when evaluating...
danix800 [Tue, 7 Mar 2023 07:41:30 +0000 (08:41 +0100)]
[analyzer] Explicit cast on customized offsetof should not be ignored when evaluating as const

If ignored, the subexpr is a UnaryOperator (&) which cannot be evaluated
(assertion failed).

  #define offsetof(type,memb) ((unsigned long)&((type*)0)->memb)

Patch By danix800!

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

16 months ago[C++20] [Modules] Handle the linkage of defaulted friend function
Chuanqi Xu [Tue, 7 Mar 2023 07:16:23 +0000 (15:16 +0800)]
[C++20] [Modules] Handle the linkage of defaulted friend function
definition correctly

Close https://github.com/llvm/llvm-project/issues/61067

Previously we will only handle the defaulted member functions as
discardable ODR. But we need to handle defaulted friend function in this
way too. Otherwise we may run into the problems the above issue report
mentions.

16 months agoDelete ActionManager and replace it with a simple callback on the Context
Mehdi Amini [Sat, 4 Feb 2023 22:16:35 +0000 (14:16 -0800)]
Delete ActionManager and replace it with a simple callback on the Context

The concept of the ActionManager acts as a sort of "Hub" that can receive
various types of action and dispatch them to a set of registered handlers.
One handler will handle the action or it'll cascade to other handlers.

This model does not really fit the current evolution of the Action tracing
and debugging: we can't foresee a good case where this behavior compose with
the use-case behind the handlers. Instead we simplify it with a single
callback installed on the Context.

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

16 months ago[mlir][Bazel] Add missing dependency.
Adrian Kuegel [Tue, 7 Mar 2023 06:41:47 +0000 (07:41 +0100)]
[mlir][Bazel] Add missing dependency.

16 months ago[test] Improve MC/RISCV/riscv64-64b-pcrel.s to demonstrate regression due to D132262
Fangrui Song [Tue, 7 Mar 2023 06:33:42 +0000 (22:33 -0800)]
[test] Improve MC/RISCV/riscv64-64b-pcrel.s to demonstrate regression due to D132262

16 months ago[RISCV][CodeGen] Add codegen pattern for FLI instruction in experimental zfa extension
Jun Sha (Joshua) [Tue, 7 Mar 2023 06:27:48 +0000 (14:27 +0800)]
[RISCV][CodeGen] Add codegen pattern for FLI instruction in experimental zfa extension

This patch implements experimental support for the RISCV Zfa extension as specified here: https://github.com/riscv/riscv-isa-manual/releases/download/draft-20221119-5234c63/riscv-spec.pdf, Ch. 25. This extension has not been ratified. Once ratified, it'll move out of experimental status.

This change adds codegen support for load-immediate instructions (fli.s/fli.d/fli.h).

Reviewed By: craig.topper

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

16 months agoAdd missing roundtointegral builtin functions for some FP instructions to be generate...
Jun Sha (Joshua) [Tue, 7 Mar 2023 06:17:35 +0000 (14:17 +0800)]
Add missing roundtointegral builtin functions for some FP instructions to be generated from C-written codes

To generate FROUND instructions in https://reviews.llvm.org/D143982, we need to use llvm intrinsics in IR files. Now I add some corresponding builtin functions to make sure these roundtointegral instructions can be generated from C codes.

Reviewed By: efriedma

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

16 months ago[RISCV][MC] Add FLI instruction support for the experimental zfa extension
Jun Sha (Joshua) [Tue, 7 Mar 2023 06:06:01 +0000 (14:06 +0800)]
[RISCV][MC] Add FLI instruction support for the experimental zfa extension

This implements experimental support for the RISCV Zfa extension as specified here: https://github.com/riscv/riscv-isa-manual/releases/download/draft-20221119-5234c63/riscv-spec.pdf, Ch. 25. This extension has not been ratified. Once ratified, it'll move out of experimental status.

This change adds assembly support for load-immediate instructions (fli.s/fli.d/fli.h). The assembly prefers decimal constants in C-like syntax. In my implementation, an integer encoding ranging from 0 to 31 can also be accepted, but for the MCInst printer, the constant is specified in decimal notation by default.

Reviewed By: craig.topper

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

16 months ago[test] Improve MC/RISCV/riscv64-64b-pcrel.s
Fangrui Song [Tue, 7 Mar 2023 05:59:56 +0000 (21:59 -0800)]
[test] Improve MC/RISCV/riscv64-64b-pcrel.s

16 months ago[libc][math] Switch math functions to use libc_errno and fix some errno and floating...
Tue Ly [Mon, 6 Mar 2023 03:57:51 +0000 (22:57 -0500)]
[libc][math] Switch math functions to use libc_errno and fix some errno and floating point exceptions.

Switch math functions to use libc_errno and fix some errno and
floating point exceptions

Reviewed By: sivachandra

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

16 months agoRISCVELFObjectWriter: de-capitalize some error messages
Fangrui Song [Tue, 7 Mar 2023 05:50:19 +0000 (21:50 -0800)]
RISCVELFObjectWriter: de-capitalize some error messages

These are unfortunately untested.
I'll add some tests in a subsequent change.

16 months ago[RISCV] Make D extension imply F extension.
Craig Topper [Tue, 7 Mar 2023 03:59:45 +0000 (19:59 -0800)]
[RISCV] Make D extension imply F extension.

I believe this implies relationship is documented in the current
spec but may have been less clear in an older spec.

We used to report an error so I think it should be ok to change this.
Only someone expecting the error should be impacted.

Reviewed By: asb, luismarques

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

16 months ago[TableGen] Fix error message that called Record::getName on a possibly anonymous...
Craig Topper [Tue, 7 Mar 2023 03:56:43 +0000 (19:56 -0800)]
[TableGen] Fix error message that called Record::getName on a possibly anonymous record.

Record::getName only works for named records. Use getNameInitAsString
to handle anonymous records without crashing.

16 months ago[hwasan] Add non-exception variant of operator delete[] for hwasan
Leonard Chan [Tue, 7 Mar 2023 03:44:57 +0000 (03:44 +0000)]
[hwasan] Add non-exception variant of operator delete[] for hwasan

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

16 months ago[X86] Precommit a test
Kazu Hirata [Tue, 7 Mar 2023 03:45:34 +0000 (19:45 -0800)]
[X86] Precommit a test

This patch precommits a test for:

https://github.com/llvm/llvm-project/issues/61073

16 months ago[sanitizer] Disabled test for DLLs
Vitaly Buka [Tue, 7 Mar 2023 03:31:07 +0000 (19:31 -0800)]
[sanitizer] Disabled test for DLLs

Similar to compiler-rt/test/asan/TestCases/default_options.cpp

16 months ago[DebugInfo] Fix a warning
Kazu Hirata [Tue, 7 Mar 2023 03:28:35 +0000 (19:28 -0800)]
[DebugInfo] Fix a warning

This patch fixes:

  llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:117:18: error: unused
  variable 'MaxAddressOffset' [-Werror,-Wunused-variable]

16 months agoRevert "[X86] Revise Alderlake P-Core schedule model"
Haohai Wen [Tue, 7 Mar 2023 00:20:35 +0000 (08:20 +0800)]
Revert "[X86] Revise Alderlake P-Core schedule model"

This reverts commit 3083b65c3494b912e622a006a1b563a7e9f1d508.
Since latency from intel doc doesn't reflect worst case.

16 months ago[DAGCombiner] Add fold for `~x + x` -> `-1`
Noah Goldstein [Tue, 7 Mar 2023 00:14:46 +0000 (18:14 -0600)]
[DAGCombiner] Add fold for `~x + x` -> `-1`

This is generally done by the InstCombine, but can be emitted as an
intermediate step and is cheap to handle.

Reviewed By: RKSimon

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

16 months ago[DAGCombiner] Add fold for `~x & x` -> `0`
Noah Goldstein [Thu, 2 Mar 2023 17:40:00 +0000 (11:40 -0600)]
[DAGCombiner] Add fold for `~x & x` -> `0`

This is generally done by the InstCombine, but can be emitted as an
intermediate step and is cheap to handle.

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

16 months ago[X86] Add test for `~x & x` -> `0` and `~x + x` -> `-1` in DAG Lowering; NFC
Noah Goldstein [Thu, 2 Mar 2023 07:30:44 +0000 (01:30 -0600)]
[X86] Add test for `~x & x` -> `0` and `~x + x` -> `-1` in DAG Lowering; NFC

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

16 months ago[InstCombine] Transform `(shift X,Or(Y,BitWidth-1))` -> `(shift X,BitWidth-1)`
Noah Goldstein [Tue, 7 Mar 2023 00:13:21 +0000 (18:13 -0600)]
[InstCombine] Transform `(shift X,Or(Y,BitWidth-1))` -> `(shift X,BitWidth-1)`

shl : https://alive2.llvm.org/ce/z/_B7Qca
lshr: https://alive2.llvm.org/ce/z/6eXz_W
ashr: https://alive2.llvm.org/ce/z/oGEx-q

Reviewed By: nikic

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

16 months ago[InstCombine] Add tests for transform `(shift X,(Or Y, BitWidth-1))`; NFC
Noah Goldstein [Sun, 5 Mar 2023 22:37:17 +0000 (16:37 -0600)]
[InstCombine] Add tests for transform `(shift X,(Or Y, BitWidth-1))`; NFC

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

16 months ago[InstSimplify] Simplify `(shl nsw nuw X, BitWidth - 1)` -> `0`
Noah Goldstein [Tue, 7 Mar 2023 00:12:49 +0000 (18:12 -0600)]
[InstSimplify] Simplify `(shl nsw nuw X, BitWidth - 1)` -> `0`

https://alive2.llvm.org/ce/z/uFy5zT

Reviewed By: nikic, spatel

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

16 months ago[InstSimplify] Add tests for `(shl nuw nsw X, BitWidth - 1)` -> `0`; NFC
Noah Goldstein [Sun, 5 Mar 2023 22:43:28 +0000 (16:43 -0600)]
[InstSimplify] Add tests for `(shl nuw nsw X, BitWidth - 1)` -> `0`; NFC

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

16 months ago[InstCombine] Add transform `(icmp eq/ne bitreverse(x), C)` -> `(icmp eq/ne x, bitrev...
Noah Goldstein [Tue, 7 Mar 2023 00:12:09 +0000 (18:12 -0600)]
[InstCombine] Add transform `(icmp eq/ne bitreverse(x), C)` -> `(icmp eq/ne x, bitreverse(C))`

EQ: https://alive2.llvm.org/ce/z/TESofr
NE: https://alive2.llvm.org/ce/z/mwloaT

Reviewed By: nikic

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

16 months ago[InstCombine] Add tests for `(icmp eq/ne bitreverse(x), C)`; NFC
Noah Goldstein [Sun, 5 Mar 2023 23:22:57 +0000 (17:22 -0600)]
[InstCombine] Add tests for `(icmp eq/ne bitreverse(x), C)`; NFC

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

16 months ago[lld][WebAssembly] Implement --why-extract flag from the ELF backend
Sam Clegg [Mon, 6 Mar 2023 17:18:03 +0000 (09:18 -0800)]
[lld][WebAssembly] Implement --why-extract flag from the ELF backend

See https://reviews.llvm.org/D109572 for the original ELF version.

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

16 months agoFix LLDB windows build
Muhammad Omair Javaid [Tue, 7 Mar 2023 01:36:27 +0000 (05:36 +0400)]
Fix LLDB windows build

LLDB WoA buildbot is failing due to pid_t redefinition after recent changes in
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp.
Process.h includes PosixApi.h which defines pid_t. Python.h on windows also typedefs
pid_t. To make sure that we include Python.h before PosixApi this patch renforces
the workaround previously set up to guard this issue.

https://lab.llvm.org/buildbot/#/builders/219

Reviewed By: mib

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

16 months ago[CMake] Allow custom `CMAKE_BUILD_TYPE`s
Igor Zhukov [Tue, 7 Mar 2023 00:44:47 +0000 (07:44 +0700)]
[CMake] Allow custom `CMAKE_BUILD_TYPE`s

Fixes #60975

Reviewed By: bogner

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

16 months ago[lldb] Stop opening Console.app and TextEdit.app when running the testsuite on macOS
Alex Langford [Tue, 7 Mar 2023 00:43:31 +0000 (16:43 -0800)]
[lldb] Stop opening Console.app and TextEdit.app when running the testsuite on macOS

16 months ago[asan darwin] Allow clients to implement `__sanitizer_report_error_summary`
Dave MacLachlan [Mon, 6 Mar 2023 23:47:13 +0000 (15:47 -0800)]
[asan darwin] Allow clients to implement `__sanitizer_report_error_summary`

`__sanitizer_report_error_summary` is declared `llvm/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h` as being able to be overridden by the client. On darwin the sanitizer runtime uses this symbol to find references to the sanitizer libraries, so if you override it you end up with the error `=ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:` at launch time.

Replace uses of `__sanitizer_report_error_summary` for finding the sanitizer libraries with using the address of a local function.

Reviewed By: yln, vitalybuka

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

16 months ago[lldb] Fix stack-use-after-scope issue in ScriptedInterface.h
Med Ismail Bennani [Tue, 7 Mar 2023 00:35:03 +0000 (16:35 -0800)]
[lldb] Fix stack-use-after-scope issue in ScriptedInterface.h

This patch should fix a `stack-use-after-scope` in the helper function
`ScriptedInterface::ErrorWithMessage`.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
16 months ago[mlir][arith] Canonicalize `addi(x, muli(y, -1))` -> `subi(x, y)`
Jakub Kuderski [Tue, 7 Mar 2023 00:28:39 +0000 (19:28 -0500)]
[mlir][arith] Canonicalize `addi(x, muli(y, -1))` -> `subi(x, y)`

These propagate all the way down to SPIR-V and result in some fishy code
with large constants.

Reviewed By: antiagainst

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

16 months ago[ADT][NFC] Use declval to suppress warning for nullptr use.
Yeting Kuo [Mon, 6 Mar 2023 15:52:09 +0000 (23:52 +0800)]
[ADT][NFC] Use declval to suppress warning for nullptr use.

The patch uses declval instead of nullptr to suppress warning for calling member
function by nullptr. Also the patch replace is_same<*>::value with is_same_v<*>.

Reviewed By: dexonsmith, kuhar

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

16 months agoAdd the ability to segment GSYM files.
Greg Clayton [Mon, 6 Mar 2023 23:57:17 +0000 (15:57 -0800)]
Add the ability to segment GSYM files.

Some workflows can generate large GSYM files and sharding GSYM files into segments can help some performant workflows that can take advantage of smaller GSYM files. This patch add a new --segment-size option to llvm-gsymutil. This option can specify a rough size in bytes of how large each segment should be.

Segmented GSYM files contain only the strings and files that are needed for the FunctionInfo objects that are added to each shard. The output file path gets the first address of the first contained function info appended as a suffix to the filename. If a base address of an image is set in the GsymCreator, then all segments will use this same base address which allows lookups for symbolication to happen correctly when the image has been slid in memory.

Code has been addeed to refactor and re-use methods within the GsymCreator to allow for segments to be created easily and tested.

Example of segmenting GSYM files:

$ llvm-gsymutil --convert llvm-gsymutil.dSYM -o llvm-gsymutil.gsym --segment-size 10485760
$ ls -l llvm-gsymutil.gsym-*
-rw-r--r--  1 gclayton  staff  10485839 Feb  9 10:45 llvm-gsymutil.gsym-0x1000030c0
-rw-r--r--  1 gclayton  staff  10485765 Feb  9 10:45 llvm-gsymutil.gsym-0x100668888
-rw-r--r--  1 gclayton  staff  10485881 Feb  9 10:45 llvm-gsymutil.gsym-0x100c948b8
-rw-r--r--  1 gclayton  staff  10485954 Feb  9 10:45 llvm-gsymutil.gsym-0x101659e70
-rw-r--r--  1 gclayton  staff  10485792 Feb  9 10:45 llvm-gsymutil.gsym-0x1022b1dc0
-rw-r--r--  1 gclayton  staff  10485889 Feb  9 10:45 llvm-gsymutil.gsym-0x102a18b10
-rw-r--r--  1 gclayton  staff  10485893 Feb  9 10:45 llvm-gsymutil.gsym-0x1030b05d0
-rw-r--r--  1 gclayton  staff  10485802 Feb  9 10:45 llvm-gsymutil.gsym-0x1037caaac
-rw-r--r--  1 gclayton  staff  10485781 Feb  9 10:45 llvm-gsymutil.gsym-0x103e767a0
-rw-r--r--  1 gclayton  staff  10485832 Feb  9 10:45 llvm-gsymutil.gsym-0x10452d0d4
-rw-r--r--  1 gclayton  staff  10485782 Feb  9 10:45 llvm-gsymutil.gsym-0x104b93310
-rw-r--r--  1 gclayton  staff   6255785 Feb  9 10:45 llvm-gsymutil.gsym-0x10526bf34

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

16 months ago[lld][ELF] Remove unused enum value. NFC
Sam Clegg [Mon, 6 Mar 2023 22:44:08 +0000 (14:44 -0800)]
[lld][ELF] Remove unused enum value. NFC

The usage was removed in https://reviews.llvm.org/D119074

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

16 months agoRevert "[memprof] Refactor tests to generate binaries and profiles on the fly."
Snehasish Kumar [Mon, 6 Mar 2023 23:48:52 +0000 (23:48 +0000)]
Revert "[memprof] Refactor tests to generate binaries and profiles on the fly."

This reverts commit 599b7690fa917ea4e9cd67275e34d0b5a0f51aa9. Since
adding a cross project dependency is a concern.

16 months ago[LLParser] Error out if a name is too long and gets renamed
Arthur Eubanks [Fri, 3 Mar 2023 23:50:10 +0000 (15:50 -0800)]
[LLParser] Error out if a name is too long and gets renamed

Typically names longer than -non-global-value-max-name-size will just get renamed if there is a collision after truncating. This is fine since we typically don't reference Values by name.

However LLParser does reference Values by name, so report an error when that happens, otherwise weird issues can crop up if there are name collisions (e.g. verifier issues with the changed test case because we end up reusing the same block for `testz` and `testa`).

Reviewed By: nikic

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

16 months ago[LoopVectorize][NFC] Fix incorrect comment in LoopVectorize.h
Ben Shi [Mon, 6 Mar 2023 06:53:58 +0000 (14:53 +0800)]
[LoopVectorize][NFC] Fix incorrect comment in LoopVectorize.h

Reviewed By: david-arm, fhahn

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

16 months agoRevert "[scudo] Mitigate page releasing thrashing"
Chia-hung Duan [Mon, 6 Mar 2023 23:26:20 +0000 (23:26 +0000)]
Revert "[scudo] Mitigate page releasing thrashing"

This reverts commit 436ea5485d02c529e26a7a1007b82d581be016c4.

16 months ago[AArch64] Extend load insert into zero patterns to SVE.
David Green [Mon, 6 Mar 2023 23:26:08 +0000 (23:26 +0000)]
[AArch64] Extend load insert into zero patterns to SVE.

This extends the patterns for loading into the zeroth lane of a zero vector
from D144086 to SVE, which work in the same way as the existing patterns. Only
full length vectors are added here, not the narrower floating point vector
types.

16 months agoRevert "[lldb] Redefine p alias to dwim-print command"
Dave Lee [Mon, 6 Mar 2023 23:04:32 +0000 (15:04 -0800)]
Revert "[lldb] Redefine p alias to dwim-print command"

This reverts commit a00801d94b02eaebd1385b03fb9e549c07cc8585.

Broke TestVSCode_completions.py

16 months ago[libc] Add riscv64 config.
Siva Chandra [Mon, 6 Mar 2023 22:19:37 +0000 (22:19 +0000)]
[libc] Add riscv64 config.

Memory functions get the basic implementation. They can be tuned
as a follow up.

Reviewed By: michaelrj, lntue

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

16 months ago[libc][NFC] Switch dirent, fcntl, inttypes and sched to use libc_errno.
Siva Chandra Reddy [Fri, 3 Mar 2023 07:09:58 +0000 (07:09 +0000)]
[libc][NFC] Switch dirent, fcntl, inttypes and sched to use libc_errno.

Reviewed By: michaelrj

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

16 months ago[mlir][sparse] Fixing -Wsign-compare error in D144773
wren romano [Mon, 6 Mar 2023 21:46:12 +0000 (13:46 -0800)]
[mlir][sparse] Fixing -Wsign-compare error in D144773

Reviewed By: aartbik, Peiming

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

16 months ago[libc] Add ALIAS option to add_object_library rule.
Siva Chandra Reddy [Mon, 6 Mar 2023 19:15:50 +0000 (19:15 +0000)]
[libc] Add ALIAS option to add_object_library rule.

This ALIAS option is now used with threads/callonce target.

Reviewed By: lntue

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

16 months ago[lldb] Fix cyclic dependency issue in ScriptedMetadata
Med Ismail Bennani [Mon, 6 Mar 2023 21:59:47 +0000 (13:59 -0800)]
[lldb] Fix cyclic dependency issue in ScriptedMetadata

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
16 months ago[mlir] Fix a warning
Kazu Hirata [Mon, 6 Mar 2023 21:57:16 +0000 (13:57 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp:675:56:
  error: comparison of integers of different signs: 'long const' and
  'const mlir::sparse_tensor::Level' (aka 'const unsigned long')
  [-Werror,-Wsign-compare]

16 months ago[SLP]Fix PR61224: Compiler hits infinite loop.
Alexey Bataev [Mon, 6 Mar 2023 20:09:45 +0000 (12:09 -0800)]
[SLP]Fix PR61224: Compiler hits infinite loop.

IRBuilder in many cases is able to fold constant code automatically,
but in some cases (for some intrinsics) it cannot do it. Need to perform
manual calculation, if constant provided in these corner cases, to avoid
infinite loop.

16 months ago[mlir][math] Add math.cbrt polynomial approximation
Robert Suderman [Mon, 6 Mar 2023 19:09:11 +0000 (11:09 -0800)]
[mlir][math] Add math.cbrt polynomial approximation

Cbrt can be approximated with some relatively simple polynomial
operators. This includes a lit test validating the implementation
and some run tests that validate numerical correct.

Reviewed By: jpienaar

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

16 months ago[memprof] Refactor tests to generate binaries and profiles on the fly.
Snehasish Kumar [Wed, 1 Mar 2023 01:33:19 +0000 (01:33 +0000)]
[memprof] Refactor tests to generate binaries and profiles on the fly.

This change replaces the binary profiles and executables used for
testing the memprof profile reader with tests where the profiles are
generated on the fly. This reduces toil when the profile version
changes. The tests are moved from tools/llvm-profdata to
compiler-rt/test/memprof due to the following reasons:
1. Adding dependency on memprof lit.cfg.py for llvm-profdata is
   preferable to adding a dependency on compiler-rt for llvm/test.
2. All the tests can now be run with `ninja check-memprof`.

Reviewed By: tejohnson

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

16 months agoRevert "[lldb] Add an example of interactive scripted process debugging (NFC)"
Med Ismail Bennani [Mon, 6 Mar 2023 21:17:46 +0000 (13:17 -0800)]
Revert "[lldb] Add an example of interactive scripted process debugging (NFC)"

This reverts commit 70b9822ef3b0774609c72d380504c9abfa717f81.

16 months agoRevert "[lldb/Plugin] Add breakpoint setting support to ScriptedProcesses."
Med Ismail Bennani [Mon, 6 Mar 2023 21:17:45 +0000 (13:17 -0800)]
Revert "[lldb/Plugin] Add breakpoint setting support to ScriptedProcesses."

This reverts commit cfe06f495beb520ab366957d1108bb80c7c92832.

16 months agoRevert "[lldb] Move ScriptedProcess private state update to implementation"
Med Ismail Bennani [Mon, 6 Mar 2023 21:17:43 +0000 (13:17 -0800)]
Revert "[lldb] Move ScriptedProcess private state update to implementation"

This reverts commit 3c33d72e7fa83beb8a9b39fb3b8ecf4ee00c697d.

16 months agoRevert "[lldb/API] Introduce SBProcess::ForceScriptedState method"
Med Ismail Bennani [Mon, 6 Mar 2023 21:17:40 +0000 (13:17 -0800)]
Revert "[lldb/API] Introduce SBProcess::ForceScriptedState method"

This reverts commit 3675e0bb67fa86b8476a67bb1a7623a6b1a373b3.

16 months ago[lldb/Utility] Fix layering violation caused by ScriptedMetadata
Med Ismail Bennani [Mon, 6 Mar 2023 19:53:09 +0000 (11:53 -0800)]
[lldb/Utility] Fix layering violation caused by ScriptedMetadata

This patch moves `ScriptedMetadata.h` from the `Interpreter` directory to
the `Utility` sub-directory since `ProcessInfo.h` depends on it.

It also gets rid of the unused `OptionGroupPythonClassWithDict`
constructor for `ScriptedMetadata` which would address the layering
violation.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
16 months ago[lldb] Add an example of interactive scripted process debugging (NFC)
Med Ismail Bennani [Sat, 4 Mar 2023 05:44:51 +0000 (21:44 -0800)]
[lldb] Add an example of interactive scripted process debugging (NFC)

This patch is a proof of concept that shows how a scripted process could
be used with real process to perform interactive debugging.

In this example, we run a process that spawns 10 threads. Then, we
create a intermediary scripted process who's job will be to wrap the
real process while intercepting it's process events and dispatching them
back either to the real process or to other child scripted processes.

In this example, we have 2 child scripted processes, with even and odd
thread indices. The goal is to be able to do thread filtering and
explore the various interactive debugging approaches, by letting a child
process running when stopping the other process and inspecting it.
Another approach would be to have the child processes execution in-sync
to force running every child process when one of them starts running.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
16 months ago[lldb/Plugin] Add breakpoint setting support to ScriptedProcesses.
Med Ismail Bennani [Sat, 4 Mar 2023 05:40:51 +0000 (21:40 -0800)]
[lldb/Plugin] Add breakpoint setting support to ScriptedProcesses.

This patch adds support for breakpoint setting to Scripted Processes.

For now, Scripted Processes only support setting software breakpoints.

When doing interactive scripted process debugging, it makes use of the
memory writing capability to write the trap opcodes in the memory of the
driving process. However the real process' target doesn't keep track of
the breakpoints that got added by the scripted process. This is a design
that we might need to change in the future, since we'll probably need to
do some book keeping to handle breakpoints that were set by different
scripted processes.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
16 months ago[lldb] Move ScriptedProcess private state update to implementation
Med Ismail Bennani [Sat, 4 Mar 2023 05:39:36 +0000 (21:39 -0800)]
[lldb] Move ScriptedProcess private state update to implementation

While debugging a Scripted Process, in order to update its state and
work nicely with lldb's execution model, it needs to toggle its private
state from running to stopped, which will result in broadcasting a
process state changed event to the debugger listener.

Originally, this state update was done systematically in the Scripted
Process C++ plugin, however in order to make scripted process
interactive, we need to be able to update their state dynamically.

This patch makes use of the recent addition of the
`SBProcess::ForceScriptedState` to programatically, and moves the
process private state update to the python implementation of the `resume`
method instead of doing it in `ScriptedProcess::DoResume`.

This patch also removes the unused `ShouldStop` & `Stop` scripted
process APIs, and adds new ScriptedInterface transform methods for
boolean arguments. This allow the user to programmatically decide if
after running the process, we should stop it (which is the default setting).

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
16 months ago[lldb/API] Introduce SBProcess::ForceScriptedState method
Med Ismail Bennani [Sat, 4 Mar 2023 05:37:45 +0000 (21:37 -0800)]
[lldb/API] Introduce SBProcess::ForceScriptedState method

This patch introduces a new method to the SBProcess API called
ForceScriptedState. As the name suggests, this affordance will allow the
user to alter the private state of the scripted process programatically.

This is necessary to update the scripted process state when perform
interactive debugging.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
16 months ago[clang-format] Don't annotate left brace of class as FunctionLBrace
Owen Pan [Mon, 6 Mar 2023 01:52:42 +0000 (17:52 -0800)]
[clang-format] Don't annotate left brace of class as FunctionLBrace

The l_brace of class/struct/union was incorrectly annotated as
TT_FunctionLBrace in the presence of attributes. This in turn
would cause the RemoveSemicolon option to remove the semicolon
at the end of the declaration, resulting in invalid code being
generated.

Fixes #61188.

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

16 months ago[lldb] Redefine p alias to dwim-print command
Dave Lee [Sat, 18 Feb 2023 03:53:16 +0000 (19:53 -0800)]
[lldb] Redefine p alias to dwim-print command

Redefine the `p` alias to the `dwim-print` command instead of `expression`.

See https://reviews.llvm.org/D138315 for the introduction of `dwim-print`.

To summarize, `dwim-print` is, as the name suggests, a command for printing. How a value
gets printed, is decided by `dwim-print`. In some cases, `dwim-print` will print values
using the same means as `frame variable` (because it's generally more reliable and
faster that `expression` evaluation), and in other cases `dwim-print` uses the same code
path as `expression`.

This change has been tested in two different ways:

1. Re-aliasing `p` to `dwim-print`, as in this patch
2. Redefinining the `expression` command to `CommandObjectDWIMPrint`

Previously, many of the lldb's tests used `p`, and which meant a test run with `p`
aliases to `dwim-print` was a good way to test `dwim-print`. However most of those tests
were updated to use `expression` explicitly (in anticipation of this change). Now, the
best way to test `dwim-print` is the second approach:

```
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 373c894f34f5..9c943cd30c7c 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -539,7 +539,7 @@ void CommandInterpreter::LoadCommandDictionary() {
   REGISTER_COMMAND_OBJECT("diagnostics", CommandObjectDiagnostics);
   REGISTER_COMMAND_OBJECT("disassemble", CommandObjectDisassemble);
   REGISTER_COMMAND_OBJECT("dwim-print", CommandObjectDWIMPrint);
-  REGISTER_COMMAND_OBJECT("expression", CommandObjectExpression);
+  REGISTER_COMMAND_OBJECT("expression", CommandObjectDWIMPrint);
   REGISTER_COMMAND_OBJECT("frame", CommandObjectMultiwordFrame);
   REGISTER_COMMAND_OBJECT("gui", CommandObjectGUI);
   REGISTER_COMMAND_OBJECT("help", CommandObjectHelp);
```

When the test suite is run with this change, there are two main categories of test
failures for specific to features that `dwim-print` intentionally doesn't support:

1. Top level expressions (`--top-level`/`-p`)
2. Multiline expressions

In cases where the behavior of `expression` is needed, users can use `expression` at
those times.

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

16 months ago[mlir][sparse] Renaming "pointer/index" to "position/coordinate"
wren romano [Mon, 6 Mar 2023 20:19:41 +0000 (12:19 -0800)]
[mlir][sparse] Renaming "pointer/index" to "position/coordinate"

The old "pointer/index" names often cause confusion since these names clash with names of unrelated things in MLIR; so this change rectifies this by changing everything to use "position/coordinate" terminology instead.

In addition to the basic terminology, there have also been various conventions for making certain distinctions like: (1) the overall storage for coordinates in the sparse-tensor, vs the particular collection of coordinates of a given element; and (2) particular coordinates given as a `Value` or `TypedValue<MemRefType>`, vs particular coordinates given as `ValueRange` or similar.  I have striven to maintain these distinctions
as follows:

  * "p/c" are used for individual position/coordinate values, when there is no risk of confusion.  (Just like we use "d/l" to abbreviate "dim/lvl".)

  * "pos/crd" are used for individual position/coordinate values, when a longer name is helpful to avoid ambiguity or to form compound names (e.g., "parentPos").  (Just like we use "dim/lvl" when we need a longer form of "d/l".)

    I have also used these forms for a handful of compound names where the old name had been using a three-letter form previously, even though a longer form would be more appropriate.  I've avoided renaming these to use a longer form purely for expediency sake, since changing them would require a cascade of other renamings.  They should be updated to follow the new naming scheme, but that can be done in future patches.

  * "coords" is used for the complete collection of crd values associated with a single element.  In the runtime library this includes both `std::vector` and raw pointer representations.  In the compiler, this is used specifically for buffer variables with C++ type `Value`, `TypedValue<MemRefType>`, etc.

    The bare form "coords" is discouraged, since it fails to make the dim/lvl distinction; so the compound names "dimCoords/lvlCoords" should be used instead.  (Though there may exist a rare few cases where is is appropriate to be intentionally ambiguous about what coordinate-space the coords live in; in which case the bare "coords" is appropriate.)

    There is seldom the need for the pos variant of this notion.  In most circumstances we use the term "cursor", since the same buffer is reused for a 'moving' pos-collection.

  * "dcvs/lcvs" is used in the compiler as the `ValueRange` analogue of "dimCoords/lvlCoords".  (The "vs" stands for "`Value`s".)  I haven't found the need for it, but "pvs" would be the obvious name for a pos-`ValueRange`.

    The old "ind"-vs-"ivs" naming scheme does not seem to have been sustained in more recent code, which instead prefers other mnemonics (e.g., adding "Buf" to the end of the names for `TypeValue<MemRefType>`).  I have cleaned up a lot of these to follow the "coords"-vs-"cvs" naming scheme, though haven't done an exhaustive cleanup.

  * "positions/coordinates" are used for larger collections of pos/crd values; in particular, these are used when referring to the complete sparse-tensor storage components.

    I also prefer to use these unabbreviated names in the documentation, unless there is some specific reason why using the abbreviated forms helps resolve ambiguity.

In addition to making this terminology change, this change also does some cleanup along the way:
  * correcting the dim/lvl terminology in certain places.
  * adding `const` when it requires no other code changes.
  * miscellaneous cleanup that was entailed in order to make the proper distinctions.  Most of these are in CodegenUtils.{h,cpp}

Reviewed By: aartbik

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

16 months ago[NFC][Clang] add test comments for GitHub issue 58896
Yuanfang Chen [Mon, 6 Mar 2023 19:54:18 +0000 (11:54 -0800)]
[NFC][Clang] add test comments for GitHub issue 58896

Per discussions with @erichkeane.

16 months agoRecommit [lldb] Test 'v' support for direct ivar access (NFC)
Dave Lee [Mon, 6 Mar 2023 03:26:29 +0000 (19:26 -0800)]
Recommit [lldb] Test 'v' support for direct ivar access (NFC)

Add basic tests for `frame variable`'s ability to direct access fields of `this` and
ivars of `self`.

This splits the tests, preventing ObjC tests from running on Linux.

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

16 months ago[ADT] Avoid needless iterator copies in `zippy`
Jakub Kuderski [Mon, 6 Mar 2023 19:39:39 +0000 (14:39 -0500)]
[ADT] Avoid needless iterator copies in `zippy`

Make `zip_common` increment and decrement iterators in place.

This improves performance with iterator types that have non-triviall
copy constructors.

Reviewed By: zero9178

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

16 months ago[scudo] Make the boundary of memory group aligned with region begin
Chia-hung Duan [Mon, 6 Mar 2023 19:22:30 +0000 (19:22 +0000)]
[scudo] Make the boundary of memory group aligned with region begin

This alignment guarantee enables simpler group range check while page
releasing and a potential optimization which is, now all the pointers
from the same group are also inth same region, that means the complexity
in markFreeBlocks() can be reduced as well.

Reviewed By: cferris

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

16 months agoRevert "[lldb] Test 'v' support for direct ivar access (NFC)"
Dave Lee [Mon, 6 Mar 2023 19:12:07 +0000 (11:12 -0800)]
Revert "[lldb] Test 'v' support for direct ivar access (NFC)"

This reverts commit 03e5c46e15b4a196cdca0c646e61f0c92a6dc7e1.

16 months ago[clang][deps] Un-XFAIL test on AIX
Jan Svoboda [Mon, 6 Mar 2023 18:57:09 +0000 (10:57 -0800)]
[clang][deps] Un-XFAIL test on AIX

16 months ago[InstCombine] fold signed absolute diff patterns
Sanjay Patel [Mon, 6 Mar 2023 15:22:58 +0000 (10:22 -0500)]
[InstCombine] fold signed absolute diff patterns

This overlaps partially with the codegen patch D144789. This needs no-wrap
for correctness, and I'm not sure if there's an unsigned equivalent:
https://alive2.llvm.org/ce/z/ErmQ-9
https://alive2.llvm.org/ce/z/mr-c_A

This is obviously an improvement in IR, and it looks like a codegen win
for all targets and data types that I sampled.

The 'nabs' case is left as a potential follow-up (and seems less likely
to occur in real code).

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

16 months ago[InstCombine] use dyn_cast instead of isa+cast; NFC
Sanjay Patel [Fri, 3 Mar 2023 17:48:59 +0000 (12:48 -0500)]
[InstCombine] use dyn_cast instead of isa+cast; NFC

16 months ago[lldb] Add variable completion to dwim-print
Dave Lee [Wed, 1 Mar 2023 22:59:31 +0000 (14:59 -0800)]
[lldb] Add variable completion to dwim-print

Enable completion of variables for `dwim-print` command.

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

16 months ago[lldb] Test 'v' support for direct ivar access (NFC)
Dave Lee [Mon, 6 Mar 2023 03:26:29 +0000 (19:26 -0800)]
[lldb] Test 'v' support for direct ivar access (NFC)

Add basic tests for `frame variable`'s ability to direct access fields of `this` and
ivars of `self`.

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

16 months ago[Bitcode] Add test for constant scalable vector gep.
Paul Walker [Mon, 6 Mar 2023 16:13:25 +0000 (16:13 +0000)]
[Bitcode] Add test for constant scalable vector gep.

16 months ago[mlir-opt] Fix dialect preload after fb1bb6a
Goran Flegar [Mon, 6 Mar 2023 18:11:03 +0000 (19:11 +0100)]
[mlir-opt] Fix dialect preload after fb1bb6a

Also pipe empty string to the commandline test to make sure it does
not hang on some configurations.

16 months ago[X86] combineBitcastvxi1/checkBitcastSrcVectorSize - sign-extend select(i1,vXi1,vXi1...
Simon Pilgrim [Mon, 6 Mar 2023 18:22:30 +0000 (18:22 +0000)]
[X86] combineBitcastvxi1/checkBitcastSrcVectorSize - sign-extend select(i1,vXi1,vXi1) patterns

Fixes #61104

16 months ago[AMDGPU] Add GFX9,GFX10,GFX11 checks for llvm.amdgcn.s.buffer.load
Jay Foad [Mon, 6 Mar 2023 18:09:35 +0000 (18:09 +0000)]
[AMDGPU] Add GFX9,GFX10,GFX11 checks for llvm.amdgcn.s.buffer.load

16 months ago[AMDGPU] Generate checks for llvm.amdgcn.s.buffer.load
Jay Foad [Mon, 6 Mar 2023 18:05:48 +0000 (18:05 +0000)]
[AMDGPU] Generate checks for llvm.amdgcn.s.buffer.load

16 months ago[X86] Optimize umax(X,1) (NFC)
Kazu Hirata [Mon, 6 Mar 2023 18:18:57 +0000 (10:18 -0800)]
[X86] Optimize umax(X,1) (NFC)

Without this patch:

  %cond = call i32 @llvm.umax.i32(i32 %X, i32 1)

is compiled as:

  83 ff 02                   cmp    $0x2,%edi
  b8 01 00 00 00             mov    $0x1,%eax
  0f 43 c7                   cmovae %edi,%eax

With this patch, the compiler generates:

  89 f8                      mov    %edi,%eax
  83 ff 01                   cmp    $0x1,%edi
  83 d0 00                   adc    $0x0,%eax

saving 3 bytes.  We should be able to save 5 bytes in larger functions
where the mov is unnecessary.

This patch converts the specific cmov pattern to cmp $1 followed by
adc $0.

This patch partially fixes:

https://github.com/llvm/llvm-project/issues/60374

The LLVM IR optimizer is yet to canonicalize max expressions to
actual @llvm.umax.

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

16 months ago[X86] Add Issue #61104 test case
Simon Pilgrim [Mon, 6 Mar 2023 18:00:13 +0000 (18:00 +0000)]
[X86] Add Issue #61104 test case

Shows the failure of combineBitcastvxi1 to sign-extend a select(i1,vXi1,vXi1) pattern

16 months ago[docs][NewPM] fix typos in new pass manager docs
Alex MacLean [Mon, 6 Mar 2023 17:16:48 +0000 (09:16 -0800)]
[docs][NewPM] fix typos in new pass manager docs

Fix some minor errors in the code-block sections of the new pass manager documentation

Reviewed By: aeubanks

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

16 months ago[Driver] Reject -march= for ppc
Fangrui Song [Mon, 6 Mar 2023 17:16:57 +0000 (09:16 -0800)]
[Driver] Reject -march= for ppc

Clang -march= for ppc triples currently leads to an
-Wunused-command-line-argument warning but GCC rejects -march=.

    error: unrecognized command-line option ‘-march=xxx’

Let's reject -march= as well similar to the Sparc change D130273.

Close https://github.com/llvm/llvm-project/issues/57587

Reviewed By: #powerpc, nemanjai

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

16 months ago[Pipeline] Adjust PostOrderFunctionAttrs placement in simplification pipeline
Arthur Eubanks [Fri, 3 Mar 2023 00:19:23 +0000 (16:19 -0800)]
[Pipeline] Adjust PostOrderFunctionAttrs placement in simplification pipeline

We can infer more attribute information once functions are fully
simplified, so move the PostOrderFunctionAttrs pass after the function
simplification pipeline. However, just doing this can impact
simplification of recursive functions since function simplification
takes advantage of function attributes of callees (some LLVM tests are
actually impacted by this), so keep a copy of PostOrderFunctionAttrs
before the function simplification pipeline that only runs on recursive
functions.

For example, this fixes the small regression noticed in https://reviews.llvm.org/D128830.

This requires some restructuring of the CGSCC NoRerun feature. We need
to cache the ShouldNotRunFunctionPassesAnalysis analysis after the
simplification is done, which now is after the second
PostOrderFunctionAttrs run, rather than after the function
simplification pipeline.

Compile time impact:
https://llvm-compile-time-tracker.com/compare.php?from=33cf40122279342b50f92a3a53f5c185390b6018&to=1bb2a07875634e508a6bdf2ca1b130f55510f060&stat=instructions:u

Compile time increase from unconditionally running the first PostOrderFunctionAttrs:
https://llvm-compile-time-tracker.com/compare.php?from=1bb2a07875634e508a6bdf2ca1b130f55510f060&to=f4f87e89cc7a35c64e3a103a8036192a84ae002b&stat=instructions:u

Reviewed By: nikic

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

16 months ago[SROA] Make order of analysis fetching more predictable
Arthur Eubanks [Mon, 6 Mar 2023 17:00:33 +0000 (09:00 -0800)]
[SROA] Make order of analysis fetching more predictable

For pipeline tests.

16 months ago[clang][alias|ifunc]: Add a diagnostic for mangled names
Dhruv Chawla [Mon, 6 Mar 2023 16:16:16 +0000 (08:16 -0800)]
[clang][alias|ifunc]: Add a diagnostic for mangled names

When an alias or ifunc attribute refers to a function name that is
mangled, a diagnostic is emitted to suggest the mangled name as a
replacement for the given function name for every matching name in the
current TU.

Fixes #59164

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

16 months ago[flang] Do not query type_desc for unlimited polymoprhic entities in move_alloc
Valentin Clement [Mon, 6 Mar 2023 16:54:29 +0000 (17:54 +0100)]
[flang] Do not query type_desc for unlimited polymoprhic entities in move_alloc

In D144997, the dynamic type of polymorphic entities is reset to the declared
type when the FROM is deallocated. To do this, the declared type was passed as
a fir.type_desc op. For unlimited polymorphic entities, this should just be a
null pointer.

Reviewed By: PeteSteinfeld

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

16 months ago[flang] Avoid double cleanup when the result is cleaned up by the Destroy function
Valentin Clement [Mon, 6 Mar 2023 16:45:50 +0000 (17:45 +0100)]
[flang] Avoid double cleanup when the result is cleaned up by the Destroy function

The Destroy runtime function does free the memory so do not do it
inlined when we use Destroy. This avoid a double free execution error.

Reviewed By: PeteSteinfeld

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

16 months agoChecked that complexity of std::sort_heap is 2N log(N) comparisons
Nilay Vaish [Tue, 14 Feb 2023 08:01:59 +0000 (00:01 -0800)]
Checked that complexity of std::sort_heap is 2N log(N) comparisons

https://wg21.link/LWG2444 updated the comparison complexity of
std:sort_heap to be at most 2N log (N) where N == last - first.  In the
current implementation, we invoke __pop_heap exactly N-1 times.  In each
call to __pop_heap, we first go down the heap from first to possibly
last in the function __floyd_sift_down.  Then, we possibly go back up in
the function __sift_up.

In the function __floyd_sift_down, there is loop in which one comparison
is made in each iteration.  The loop runs till __child becomes greater
than (__len - 2) / 2.  __child starts at 0 and it is at least set to 2 *
__child + 1 on each iteration.  Thus, after k iterations, __child will
be at least 2^k - 1.  After log(N) iterations,  __child >= 2^(log(N)) -
1 = N - 1 > (__len - 2) / 2.  This means that the while loop in the
function __floyd_sift_down would perform at most log(N) comparisons on
each invocation.

In the function __sift_up, there is one comparison made that will almost
always occur.  After that there is a do-while loop.  The comparison
function is invoked once in each iteration.  In the worst case, the loop
will run till __len goes down to zero.  It can start from (N-3)/2.  In
each iteration, __len goes down to (__len-1) / 2.  After k iterations,
__len will be at most (N - 2^(k+1) -1) / 2^(k+1).  Thus, __len will
become  when (N-2^(k+1)-1) < 2^(k+1)  i.e. N  < 2^(k+2) + 1.  This means
at most log(N) - 1 iterations for the loop.  So in total at most log(N)
  comparison will be performed in __sift_up.

So overall for each iteration of the loop in __pop_heap, there will at
most 2 log(N) comparisons.  So, the total number of comparisons is
at most 2 N log(N).

We also updated the test sort.heap/complexity.pass.cpp to test for the
number of operations.

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

16 months ago[bazel] Fix build after 28d04c5
Goran Flegar [Mon, 6 Mar 2023 16:24:26 +0000 (17:24 +0100)]
[bazel] Fix build after 28d04c5

16 months ago[scudo] Temporarily disable GetRssFromBuffer test
Chia-hung Duan [Fri, 3 Mar 2023 21:43:29 +0000 (21:43 +0000)]
[scudo] Temporarily disable GetRssFromBuffer test

This is a flaky test and may not test the thing it expected to verify.
E.g., it doesn't dirty the pages so the memory usage may not be reflected
on the RSS.

Reviewed By: cferris

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

16 months ago[scudo] Mitigate page releasing thrashing
Chia-hung Duan [Fri, 3 Mar 2023 19:21:11 +0000 (19:21 +0000)]
[scudo] Mitigate page releasing thrashing

We have the heuristic to determine the threshold of doing page
releasing for smaller size classes. However, in a case that the
memory usage is bouncing between that threshold may result in
frequent try of page releasing but not returning much memory.

This CL add another heuristic to mitigate this problem by increasing
the minimum pages that potentially can be released. Note that this
heuristic is only applied on SizeClassAllocator64. SizeClassAllocator32
has a smaller group size so the overhead is smaller than 64-bit
platform.

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

16 months agoReland D144920 "[scudo] Only prepare PageMap entry for partial region
Chia-hung Duan [Fri, 3 Mar 2023 01:45:34 +0000 (01:45 +0000)]
Reland D144920 "[scudo] Only prepare PageMap entry for partial region

This reverts commit daaef4c49954cb04ea1831615e0876865a29a08a.

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

16 months ago[SelectionDAG] Optimize copyExtraInfo deep copy
Marco Elver [Mon, 6 Mar 2023 16:15:53 +0000 (17:15 +0100)]
[SelectionDAG] Optimize copyExtraInfo deep copy

It turns out that there are relatively trivial, albeit rare, cases that
require a MaxDepth of more than 16 (see added test). However, we want to
avoid having to rely on a large fixed MaxDepth.

Since these cases are relatively rare, apply the following strategy:

  1. Start with a low MaxDepth of 16 - if the entry node was not
     reached, we can return (the common case).

  2. If the entry node was reached, exponentially increase MaxDepth up
     to some large limit that should cover all cases and guard against
     stack exhaustion.

This retains the better performance with a low MaxDepth in the common
case, and in complex cases backs off and retries. On a whole, this is
preferable vs. starting with a large MaxDepth which would unnecessarily
penalize the common case where a low MaxDepth is sufficient.

Reviewed By: dvyukov

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

16 months ago[ADT] Clean up zip iterators. NFC.
Jakub Kuderski [Mon, 6 Mar 2023 16:10:59 +0000 (11:10 -0500)]
[ADT] Clean up zip iterators. NFC.

*  Use inheriting constructors declarations to avoid introducing the
   `Base` typedef and duplicate constructor definitions. This should make
   things cleaner, especially since `zip_common` also exposes a `Base`
   typedef.
*  Drop unnecessary template parameters.
*  Avoid double negation in `zip_shortest`'s `operator==` and rename the
   comparison function for better readability.

Reviewed By: zero9178

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