platform/upstream/llvm.git
2 years ago[Test] Mode test for pr56243 from LICM to LoopSimplifyCFG
Max Kazantsev [Mon, 18 Jul 2022 05:37:01 +0000 (12:37 +0700)]
[Test] Mode test for pr56243 from LICM to LoopSimplifyCFG

2 years ago[test] Change -function-import tests to use -passes=
Fangrui Song [Mon, 18 Jul 2022 04:42:59 +0000 (21:42 -0700)]
[test] Change -function-import tests to use -passes=

2 years ago[AMDGPU] Add the uses_dynamic_stack field to the kernel descriptor and the kernel...
Abinav Puthan Purayil [Fri, 17 Jun 2022 09:54:08 +0000 (15:24 +0530)]
[AMDGPU] Add the uses_dynamic_stack field to the kernel descriptor and the kernel metadata map

This change introduces the dynamic stack boolean field to code-object-v3
and above under the code properties of the kernel descriptor and under
the kernel metadata map of NT_AMDGPU_METADATA. This field corresponds to
the is_dynamic_callstack field of amd_kernel_code_t.

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

2 years ago[test] Change -lowertypetests tests to use -passes=
Fangrui Song [Mon, 18 Jul 2022 04:33:02 +0000 (21:33 -0700)]
[test] Change -lowertypetests tests to use -passes=

2 years ago[RISCV][NFC] Use more Arrayref in TargetLowering functions.
jacquesguan [Mon, 16 May 2022 02:57:44 +0000 (02:57 +0000)]
[RISCV][NFC] Use more Arrayref in TargetLowering functions.

This patch replaces some foreach with Arrayref, and abstract some same literal array with a variable.

Reviewed By: craig.topper

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

2 years ago[RISCV] Extend use of SHXADD instructions in RVV spill/reload code.
jacquesguan [Wed, 6 Jul 2022 09:15:59 +0000 (17:15 +0800)]
[RISCV] Extend use of SHXADD instructions in RVV spill/reload code.

This patch extends D124824. It uses SHXADD+SLLI to emit 3, 5, or 9 multiplied by a power 2.

Reviewed By: craig.topper

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

2 years ago[RISCV][test] Precommit test for D129179.
jacquesguan [Mon, 11 Jul 2022 03:35:45 +0000 (11:35 +0800)]
[RISCV][test] Precommit test for D129179.

Reviewed By: craig.topper

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

2 years ago[mlir][Math] Add constant folder for Log10Op.
jacquesguan [Thu, 14 Jul 2022 07:43:16 +0000 (15:43 +0800)]
[mlir][Math] Add constant folder for Log10Op.

This patch adds constant folder for Log10Op which only support single and double precision floating-point.

Reviewed By: Mogball

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

2 years ago[libc++][ranges] Make range algorithms support proxy iterators
Konstantin Varlamov [Mon, 18 Jul 2022 01:11:51 +0000 (18:11 -0700)]
[libc++][ranges] Make range algorithms support proxy iterators

Also test all the range algorithms to verify the support.

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

2 years ago[llvm] Modernize bool literals (NFC)
Kazu Hirata [Mon, 18 Jul 2022 01:08:51 +0000 (18:08 -0700)]
[llvm] Modernize bool literals (NFC)

Identified with modernize-use-bool-literals.

2 years ago[AVR] Remove redundant void (NFC)
Kazu Hirata [Mon, 18 Jul 2022 01:08:50 +0000 (18:08 -0700)]
[AVR] Remove redundant void (NFC)

Identified with modernize-redundant-void-arg.

2 years ago[mlir] Remove unused using (NFC)
Kazu Hirata [Mon, 18 Jul 2022 01:08:48 +0000 (18:08 -0700)]
[mlir] Remove unused using (NFC)

Identified with misc-unused-using-decls.

2 years ago[test] Change test/SampleProfile to use opaque pointers
Fangrui Song [Mon, 18 Jul 2022 00:38:34 +0000 (17:38 -0700)]
[test] Change test/SampleProfile to use opaque pointers

2 years ago[libc++] Enable test for already written ranges algorithms
Nikolas Klauser [Sun, 17 Jul 2022 18:09:52 +0000 (20:09 +0200)]
[libc++] Enable test for already written ranges algorithms

Reviewed By: Mordante, #libc

Spies: libcxx-commits

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

2 years ago[RISCV] Simplify lowerGlobalAddress. NFC
Fangrui Song [Sun, 17 Jul 2022 22:42:45 +0000 (15:42 -0700)]
[RISCV] Simplify lowerGlobalAddress. NFC

2 years agoRemove unused forward declarations (NFC)
Kazu Hirata [Sun, 17 Jul 2022 22:37:48 +0000 (15:37 -0700)]
Remove unused forward declarations (NFC)

2 years agoRemove redundant return statements (NFC)
Kazu Hirata [Sun, 17 Jul 2022 22:37:46 +0000 (15:37 -0700)]
Remove redundant return statements (NFC)

Identified with readability-redundant-control-flow.

2 years agoEnsure newlines at the end of files (NFC)
Kazu Hirata [Sun, 17 Jul 2022 22:37:45 +0000 (15:37 -0700)]
Ensure newlines at the end of files (NFC)

2 years ago[LegacyPM] Remove LowerTypeTestsPass
Fangrui Song [Sun, 17 Jul 2022 22:06:38 +0000 (15:06 -0700)]
[LegacyPM] Remove LowerTypeTestsPass

Unused after LTO removal from optimization passline.

2 years ago[test] Change -lowertypetests tests to -passes=
Fangrui Song [Sun, 17 Jul 2022 22:03:46 +0000 (15:03 -0700)]
[test] Change -lowertypetests tests to -passes=

2 years ago[LegacyPM] Remove NameAnonGlobalLegacyPass
Fangrui Song [Sun, 17 Jul 2022 21:38:28 +0000 (14:38 -0700)]
[LegacyPM] Remove NameAnonGlobalLegacyPass

Unused after LTO removal from optimization passline.

2 years ago[LegacyPM] Remove CanonicalizeAliasesLegacyPass
Fangrui Song [Sun, 17 Jul 2022 21:30:22 +0000 (14:30 -0700)]
[LegacyPM] Remove CanonicalizeAliasesLegacyPass

Unused after LTO removal from optimization passline.

2 years ago[LegacyPM] Remove LTO passes from optimization pipeline
Fangrui Song [Sun, 17 Jul 2022 21:24:36 +0000 (14:24 -0700)]
[LegacyPM] Remove LTO passes from optimization pipeline

Following recent changes removing non-core features of the legacy
PM/optimization pipeline.

2 years ago[LegacyPM] Remove PGO options from PassManagerBuilder
Fangrui Song [Sun, 17 Jul 2022 21:03:23 +0000 (14:03 -0700)]
[LegacyPM] Remove PGO options from PassManagerBuilder

They have been dead since legacy PGO/SamplePGO passes were removed.

2 years ago[ARM] Guard VMOVH and VINS patterns.
David Green [Sun, 17 Jul 2022 20:26:49 +0000 (21:26 +0100)]
[ARM] Guard VMOVH and VINS patterns.

These instructions are only available when fp is available, so cannot be
used with just +mve. Add predicates to ensure we fall-back under the
right circumstances.

2 years ago[RISCV] Teach targetShrinkDemandedConstant to handle OR and XOR.
Craig Topper [Sun, 17 Jul 2022 19:36:30 +0000 (12:36 -0700)]
[RISCV] Teach targetShrinkDemandedConstant to handle OR and XOR.

We were only handling AND before, but SimplifyDemandedBits can
also call it for OR and XOR.

2 years ago[LegacyPM] Remove SampleProfileLoaderLegacyPass
Fangrui Song [Sun, 17 Jul 2022 19:09:46 +0000 (12:09 -0700)]
[LegacyPM] Remove SampleProfileLoaderLegacyPass

Following recent changes removing non-core features of the legacy
PM/optimization pipeline (e.g. PGO), remove SamplePGO.

2 years ago[test] Change -sample-profile tests to -passes=
Fangrui Song [Sun, 17 Jul 2022 19:00:41 +0000 (12:00 -0700)]
[test] Change -sample-profile tests to -passes=

so that we can remove SampleProfileLoaderLegacyPass.

2 years ago[SystemZ][z/OS] Implement detection and handling for XPLink Leaf procedures.
Neumann Hon [Sun, 17 Jul 2022 18:30:33 +0000 (14:30 -0400)]
[SystemZ][z/OS] Implement detection and handling for XPLink Leaf procedures.

This PR adds support for creating leaf functions when there are no CSRs used, no function calls are made, no stack frame is acquired, and contain no try/catch/throw statements.

Reviewed By: uweigand

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

2 years ago[RISCV] Teach RISCVCodeGenPrepare to optimize (i64 (and (zext/sext (i32 X), C1)))
Craig Topper [Sun, 17 Jul 2022 18:00:54 +0000 (11:00 -0700)]
[RISCV] Teach RISCVCodeGenPrepare to optimize (i64 (and (zext/sext (i32 X), C1)))

If X is known positive by a dominating condition, we can fill in
ones into the upper bits of C1 if that would allow it to become an
simm12 allowing the use of ANDI.

This pattern often occurs in unrolled loops where the induction
variable has been widened.

To get the best benefit from this, I had to move the pass above
ConstantHoisting which is in addIRPasses. Otherwise the AND constant
is often hoisted away from the AND.

Reviewed By: asb

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

2 years ago[RISCV] Remove unnecessary use of IRBuilder from RISCVCodeGenPrepare.
Craig Topper [Sun, 17 Jul 2022 17:59:47 +0000 (10:59 -0700)]
[RISCV] Remove unnecessary use of IRBuilder from RISCVCodeGenPrepare.

We're creating single instruction to replace another instruction.
We can insert using the InsertBefore operand of the constructor.
Then copy the debug location.

2 years ago[RISCV] Remove Gather/Scatter Opt from the O0 pipeline.
Craig Topper [Fri, 15 Jul 2022 17:27:52 +0000 (10:27 -0700)]
[RISCV] Remove Gather/Scatter Opt from the O0 pipeline.

2 years ago[DAG] Fold (or (and X, C1), (and (or X, Y), C2)) -> (or (and X, C1|C2), (and Y, C2))
Simon Pilgrim [Sun, 17 Jul 2022 17:51:41 +0000 (18:51 +0100)]
[DAG] Fold (or (and X, C1), (and (or X, Y), C2)) -> (or (and X, C1|C2), (and Y, C2))

Pulled out of D77804

Alive2: https://alive2.llvm.org/ce/z/g61VRe

2 years ago[DAG] Add or(and(x,c1),and(or(x,y),c2)) tests
Simon Pilgrim [Sun, 17 Jul 2022 17:09:27 +0000 (18:09 +0100)]
[DAG] Add or(and(x,c1),and(or(x,y),c2)) tests

Tests for the fold suggested in D77804

2 years agoConversion from '__int64' to 'long', possible loss of data
Igor Zhukov [Sun, 17 Jul 2022 14:37:26 +0000 (16:37 +0200)]
Conversion from '__int64' to 'long', possible loss of data

llvm-project\libcxx\test\std\time\time.hms\time.hms.members\seconds.pass.cpp(38): note: see reference to function template instantiation 'long check_seconds<std::chrono::seconds>(Duration)' being compiled
        with
        [
            Duration=std::chrono::seconds
        ]
llvm-project\libcxx\test\std\time\time.hms\time.hms.members\seconds.pass.cpp(31): warning C4244: 'return': conversion from '_Rep' to 'long', possible loss of data
        with
        [
            _Rep=__int64
        ]

Reviewed By: #libc, Mordante

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

2 years agofix comment typo to cycle bots
Nico Weber [Sun, 17 Jul 2022 13:10:05 +0000 (09:10 -0400)]
fix comment typo to cycle bots

2 years ago[DAG] computeKnownBits - move UDIV handling to same place as UREM/SREM. NFC.
Simon Pilgrim [Sun, 17 Jul 2022 10:59:42 +0000 (11:59 +0100)]
[DAG] computeKnownBits - move UDIV handling to same place as UREM/SREM. NFC.

2 years ago[DAG] Add MERGE_VALUE computeKnownBits/ComputeNumSignBits handling.
Simon Pilgrim [Sun, 17 Jul 2022 10:58:03 +0000 (11:58 +0100)]
[DAG] Add MERGE_VALUE computeKnownBits/ComputeNumSignBits handling.

Just forward the value tracking to the operand specified by the ResNo

2 years ago[LV] Move VPPredInstPHIRecipe::execute to VPlanRecipes.cpp (NFC)
Florian Hahn [Sun, 17 Jul 2022 10:34:23 +0000 (11:34 +0100)]
[LV] Move VPPredInstPHIRecipe::execute to VPlanRecipes.cpp (NFC)

2 years ago[llvm] Fix header guards (NFC)
Kazu Hirata [Sun, 17 Jul 2022 09:18:55 +0000 (02:18 -0700)]
[llvm] Fix header guards (NFC)

Identified with llvm-header-guard.

2 years ago[AMDGPU] Improve liveness copying in si-optimize-exec-masking-pre-ra
Carl Ritson [Sun, 17 Jul 2022 07:19:40 +0000 (16:19 +0900)]
[AMDGPU] Improve liveness copying in si-optimize-exec-masking-pre-ra

Further improve liveness copying for CC register post optimization
by mirroring live internal splits.
The fixes a bug in register allocation when CC register liveness
is extended across a branches instead of split.

Reviewed By: arsenm

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

2 years ago[CodeGen] Qualify auto variables in for loops (NFC)
Kazu Hirata [Sun, 17 Jul 2022 08:33:28 +0000 (01:33 -0700)]
[CodeGen] Qualify auto variables in for loops (NFC)

2 years ago[test] Remove duplicate -sample-profile tests
Fangrui Song [Sun, 17 Jul 2022 07:52:30 +0000 (00:52 -0700)]
[test] Remove duplicate -sample-profile tests

When -passes=sample-profile is tested, -sample-profile is redundant.

2 years ago[sanitizer] Compare against the alignment of the latter range trying to find consecut...
Xi Ruoyao [Sun, 17 Jul 2022 07:45:15 +0000 (00:45 -0700)]
[sanitizer] Compare against the alignment of the latter range trying to find consecutive TLS blocks in GetStaticTlsBoundary

On a mips64el-linux-gnu system, the dynamic linker arranges TLS blocks
like:

    [0] 0xfff7fe9680..0xfff7fe9684, align = 0x4
    [1] 0xfff7fe9688..0xfff7fe96a8, align = 0x8
    [2] 0xfff7fe96c0..0xfff7fe9e60, align = 0x40
    [3] 0xfff7fe9e60..0xfff7fe9ef8, align = 0x8

Note that the dynamic linker can only put [1] at 0xfff7fe9688, not
0xfff7fe9684 or it will be misaligned.  But we were comparing the
distance between two blocks with the alignment of the previous range,
causing GetStaticTlsBoundary fail to merge the consecutive blocks.

Compare against the alignment of the latter range to fix the issue.

Reviewed By: MaskRay

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

2 years ago[Analysis] Qualify auto variables in for loops (NFC)
Kazu Hirata [Sun, 17 Jul 2022 06:26:34 +0000 (23:26 -0700)]
[Analysis] Qualify auto variables in for loops (NFC)

2 years ago[llvm] Wrap multi-statement macro definitions with do ... while (0)
owenca [Sun, 17 Jul 2022 03:57:44 +0000 (20:57 -0700)]
[llvm] Wrap multi-statement macro definitions with do ... while (0)

2 years ago[IndVars] Directly use unsigned integer induction for FPToUI/FPToSI of float induction
zhongyunde [Sun, 17 Jul 2022 02:47:23 +0000 (10:47 +0800)]
[IndVars] Directly use unsigned integer induction for FPToUI/FPToSI of float induction

Depend on D129358

Reviewed By: nikic

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

2 years ago[NFC] Remove obsolete all_passes_registration from integration tests.
Stella Laurenzo [Sun, 17 Jul 2022 01:18:43 +0000 (18:18 -0700)]
[NFC] Remove obsolete all_passes_registration from integration tests.

After https://reviews.llvm.org/D128593 this is not needed (and not available). Was missed in original landing because integration tests do not run on pre-merge.

2 years ago[mlir] Overhaul C/Python registration APIs to properly scope registration/loading...
Stella Laurenzo [Sat, 16 Jul 2022 23:09:03 +0000 (16:09 -0700)]
[mlir] Overhaul C/Python registration APIs to properly scope registration/loading activities.

Since the very first commits, the Python and C MLIR APIs have had mis-placed registration/load functionality for dialects, extensions, etc. This was done pragmatically in order to get bootstrapped and then just grew in. Downstreams largely bypass and do their own thing by providing various APIs to register things they need. Meanwhile, the C++ APIs have stabilized around this and it would make sense to follow suit.

The thing we have observed in canonical usage by downstreams is that each downstream tends to have native entry points that configure its installation to its preferences with one-stop APIs. This patch leans in to this approach with `RegisterEverything.h` and `mlir._mlir_libs._mlirRegisterEverything` being the one-stop entry points for the "upstream packages". The `_mlir_libs.__init__.py` now allows customization of the environment and Context by adding "initialization modules" to the `_mlir_libs` package. If present, `_mlirRegisterEverything` is treated as such a module. Others can be added by downstreams by adding a `_site_initialize_{i}.py` module, where '{i}' is a number starting with zero. The number will be incremented and corresponding module loaded until one is not found. Initialization modules can:

* Perform load time customization to the global environment (i.e. registering passes, hooks, etc).
* Define a `register_dialects(registry: DialectRegistry)` function that can extend the `DialectRegistry` that will be used to bootstrap the `Context`.
* Define a `context_init_hook(context: Context)` function that will be added to a list of callbacks which will be invoked after dialect registration during `Context` initialization.

Note that the `MLIRPythonExtension.RegisterEverything` is not included by default when building a downstream (its corresponding behavior was prior). For downstreams which need the default MLIR initialization to take place, they must add this back in to their Python CMake build just like they add their own components (i.e. to `add_mlir_python_common_capi_library` and `add_mlir_python_modules`). It is perfectly valid to not do this, in which case, only the things explicitly depended on and initialized by downstreams will be built/packaged. If the downstream has not been set up for this, it is recommended to simply add this back for the time being and pay the build time/package size cost.

CMake changes:
* `MLIRCAPIRegistration` -> `MLIRCAPIRegisterEverything` (renamed to signify what it does and force an evaluation: a number of places were incidentally linking this very expensive target)
* `MLIRPythonSoure.Passes` removed (without replacement: just drop)
* `MLIRPythonExtension.AllPassesRegistration` removed (without replacement: just drop)
* `MLIRPythonExtension.Conversions` removed (without replacement: just drop)
* `MLIRPythonExtension.Transforms` removed (without replacement: just drop)

Header changes:
* `mlir-c/Registration.h` is deleted. Dialect registration functionality is now in `IR.h`. Registration of upstream features are in `mlir-c/RegisterEverything.h`. When updating MLIR and a couple of downstreams, I found that proper usage was commingled so required making a choice vs just blind S&R.

Python APIs removed:
  * mlir.transforms and mlir.conversions (previously only had an __init__.py which indirectly triggered `mlirRegisterTransformsPasses()` and `mlirRegisterConversionPasses()` respectively). Downstream impact: Remove these imports if present (they now happen as part of default initialization).
  * mlir._mlir_libs._all_passes_registration, mlir._mlir_libs._mlirTransforms, mlir._mlir_libs._mlirConversions. Downstream impact: None expected (these were internally used).

C-APIs changed:
  * mlirRegisterAllDialects(MlirContext) now takes an MlirDialectRegistry instead. It also used to trigger loading of all dialects, which was already marked with a TODO to remove -- it no longer does, and for direct use, dialects must be explicitly loaded. Downstream impact: Direct C-API users must ensure that needed dialects are loaded or call `mlirContextLoadAllAvailableDialects(MlirContext)` to emulate the prior behavior. Also see the `ir.c` test case (e.g. `  mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("func"));`).
  * mlirDialectHandle* APIs were moved from Registration.h (which now is restricted to just global/upstream registration) to IR.h, arguably where it should have been. Downstream impact: include correct header (likely already doing so).

C-APIs added:
  * mlirContextLoadAllAvailableDialects(MlirContext): Corresponds to C++ API with the same purpose.

Python APIs added:
  * mlir.ir.DialectRegistry: Mapping for an MlirDialectRegistry.
  * mlir.ir.Context.append_dialect_registry(MlirDialectRegistry)
  * mlir.ir.Context.load_all_available_dialects()
  * mlir._mlir_libs._mlirAllRegistration: New native extension that exposes a `register_dialects(MlirDialectRegistry)` entry point and performs all upstream pass/conversion/transforms registration on init. In this first step, we eagerly load this as part of the __init__.py and use it to monkey patch the Context to emulate prior behavior.
  * Type caster and capsule support for MlirDialectRegistry

This should make it possible to build downstream Python dialects that only depend on a subset of MLIR. See: https://github.com/llvm/llvm-project/issues/56037

Here is an example PR, minimally adapting IREE to these changes: https://github.com/iree-org/iree/pull/9638/files In this situation, IREE is opting to not link everything, since it is already configuring the Context to its liking. For projects that would just like to not think about it and pull in everything, add `MLIRPythonExtension.RegisterEverything` to the list of Python sources getting built, and the old behavior will continue.

Reviewed By: mehdi_amini, ftynse

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

2 years ago[BOLT] Add function layout class
Fabian Parzefall [Sun, 17 Jul 2022 00:23:21 +0000 (17:23 -0700)]
[BOLT] Add function layout class

This patch adds a dedicated class to keep track of each function's
layout. It also lays the groundwork for splitting functions into
multiple fragments (as opposed to a strict hot/cold split).

Reviewed By: maksfb

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

2 years agoRevert "[Support] Remove redundant declaration setCurrentDebugTypes (NFC)"
Kazu Hirata [Sun, 17 Jul 2022 00:19:27 +0000 (17:19 -0700)]
Revert "[Support] Remove redundant declaration setCurrentDebugTypes (NFC)"

This reverts commit 52232abc230435d4c1e1273d4b857a11f2c7b45b.

This patch breaks builds when NDEBUG is defined.

2 years ago[Driver] Don't passs --dynamic-linker in -r mode
Brad Smith [Sat, 16 Jul 2022 23:36:52 +0000 (19:36 -0400)]
[Driver] Don't passs --dynamic-linker in -r mode

No behavior change as GNU ld/gold/ld.lld ignore --dynamic-linker in -r mode.
This change makes the intention clearer as we already suppress --dynamic-linker
for -shared, -static, and -static-pie.

Reviewed by: MaskRay, phosek

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

2 years ago[test] Fix memory leak in validateTargetProfile
Vitaly Buka [Sat, 16 Jul 2022 23:37:28 +0000 (16:37 -0700)]
[test] Fix memory leak in validateTargetProfile

Unfortunatly fixing leak expose use-after-free if delete more then one
Compilation for the same Driver, so I am changing validateTargetProfile
to create own Driver each time.

The test was added by D122865.

2 years ago[libcxx] Replace remaining _LIBCPP_INLINE_VISIBILITY in __support
Brad Smith [Sat, 16 Jul 2022 23:06:50 +0000 (19:06 -0400)]
[libcxx] Replace remaining _LIBCPP_INLINE_VISIBILITY in __support

Replace remaining _LIBCPP_INLINE_VISIBILITY in __support with _LIBCPP_HIDE_FROM_ABI.

Reviewed by: Mordante

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

2 years ago[Support] Remove redundant declaration setCurrentDebugTypes (NFC)
Kazu Hirata [Sat, 16 Jul 2022 22:50:18 +0000 (15:50 -0700)]
[Support] Remove redundant declaration setCurrentDebugTypes (NFC)

The function is declared in llvm/include/llvm/Support/Debug.h.

Identified with readability-redundant-declaration.

2 years ago[CodeGen] Remove redundant declaration createGreedyRegisterAllocator (NFC)
Kazu Hirata [Sat, 16 Jul 2022 22:43:34 +0000 (15:43 -0700)]
[CodeGen] Remove redundant declaration createGreedyRegisterAllocator (NFC)

The function is declared in llvm/include/llvm/CodeGen/Passes.h.

Identified with readability-redundant-declaration.

2 years ago[CodeGen] Use RegClassFilterFunc where appropriate (NFC)
Kazu Hirata [Sat, 16 Jul 2022 22:43:33 +0000 (15:43 -0700)]
[CodeGen] Use RegClassFilterFunc where appropriate (NFC)

2 years ago[libc++][AIX] Correct the definition of __regex_word for AIX
Xing Xue [Sat, 16 Jul 2022 22:11:04 +0000 (18:11 -0400)]
[libc++][AIX] Correct the definition of __regex_word for AIX

Summary:
The patch changes the definition of __regex_word to 0x8000 for AIX because the current definition 0x80 clashes with ctype_base::print (_ISPRINT is defined as 0x80 in AIX ctype.h).

Reviewed by: Mordante, hubert.reinterpretcast, libc++

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

2 years ago[test] Don't leak DerivedArgList in test
Vitaly Buka [Sat, 16 Jul 2022 21:03:22 +0000 (14:03 -0700)]
[test] Don't leak DerivedArgList in test

2 years ago[SDAG] narrow truncated sign_extend_inreg
Sanjay Patel [Sat, 16 Jul 2022 19:59:49 +0000 (15:59 -0400)]
[SDAG] narrow truncated sign_extend_inreg

trunc (sign_ext_inreg X, iM) to iN --> sign_ext_inreg (trunc X to iN), iM

There are improvements on existing tests from this, and there are a pair
of large regressions in D127115 for Thumb2 caused by not folding this
pattern.

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

2 years ago[Analysis] Remove isArithmeticRecurrenceKind
Kazu Hirata [Sat, 16 Jul 2022 20:23:32 +0000 (13:23 -0700)]
[Analysis] Remove isArithmeticRecurrenceKind

The last use was removed on Jul 30, 2021 in commit
9d355949937038c32c7608ebb558bbc3984f6340.

2 years ago[clang-format] Never remove braces in macro definitions
owenca [Sat, 16 Jul 2022 06:17:42 +0000 (23:17 -0700)]
[clang-format] Never remove braces in macro definitions

Fixes #56559.

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

2 years ago[lld-macho] Handle filename being passed in -lto_object_path
Daniel Bertalan [Wed, 13 Jul 2022 23:17:48 +0000 (01:17 +0200)]
[lld-macho] Handle filename being passed in -lto_object_path

Clang passes a filename rather than a directory in -lto_object_path when
using FullLTO. Previously, it was always treated it as a directory, so
lld would crash when it attempted to create temporary files inside it.

Fixes #54805

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

2 years ago[AMDGPU] Use default member initialization (NFC)
Kazu Hirata [Sat, 16 Jul 2022 19:44:35 +0000 (12:44 -0700)]
[AMDGPU] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

2 years ago[test] Fix leak in test
Vitaly Buka [Sat, 16 Jul 2022 19:40:41 +0000 (12:40 -0700)]
[test] Fix leak in test

2 years ago[PGO][InstrProf][test] Convert to opaque pointers and fix some stale tests
Fangrui Song [Sat, 16 Jul 2022 18:42:35 +0000 (11:42 -0700)]
[PGO][InstrProf][test] Convert to opaque pointers and fix some stale tests

2 years ago[AMDGPU] Declare TableRef in terms of ArrayRef (NFC)
Kazu Hirata [Sat, 16 Jul 2022 17:56:20 +0000 (10:56 -0700)]
[AMDGPU] Declare TableRef in terms of ArrayRef (NFC)

2 years agoVisual C++ doesn't support C99 compound literal
Igor Zhukov [Sat, 16 Jul 2022 17:47:20 +0000 (19:47 +0200)]
Visual C++ doesn't support C99 compound literal

Fix test libcxx/test/std/containers/sequences/array/array.creation/to_array.pass.cpp

Reviewed By: #libc, Mordante

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

2 years agoTests ignore the return value of sto{meow}, triggering nodiscard warnings in MS STL
Igor Zhukov [Sat, 16 Jul 2022 17:40:53 +0000 (19:40 +0200)]
Tests ignore the return value of sto{meow}, triggering nodiscard warnings in MS STL

Reviewed By: #libc, Mordante

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

2 years agoRevert rG14364200821f7b2d97edf6e78160c514800d3ec6 "[ARM] Regenerate reg_sequence...
Simon Pilgrim [Sat, 16 Jul 2022 16:32:53 +0000 (17:32 +0100)]
Revert rG14364200821f7b2d97edf6e78160c514800d3ec6 "[ARM] Regenerate reg_sequence.ll test checks"

Breaks on some apple machines

2 years ago[SystemZ] Add funnel shift test coverage
Simon Pilgrim [Sat, 16 Jul 2022 16:31:50 +0000 (17:31 +0100)]
[SystemZ] Add funnel shift test coverage

Based off conversations on Issue #56495

2 years ago[LV] Avoid creating new run-time VF expression for each runtime checks.
Florian Hahn [Sat, 16 Jul 2022 16:24:07 +0000 (17:24 +0100)]
[LV] Avoid creating new run-time VF expression for each runtime checks.

At the moment, the cost of runtime checks for scalable vectors is
overestimated due to creating separate vscale * VF expressions for each
check. Instead re-use the first expression.

2 years ago[clang-format][docs] Fix incorrect 'clang-format 7' option markers
Krystian Kuzniarek [Thu, 28 Apr 2022 13:40:09 +0000 (15:40 +0200)]
[clang-format][docs] Fix incorrect 'clang-format 7' option markers

Introduced by 23a5090c6, some style option markers indicated
'clang-format 7', though their respective options were available in
different releases.

2 years ago[ARM] Regenerate reg_sequence.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 16:10:35 +0000 (17:10 +0100)]
[ARM] Regenerate reg_sequence.ll test checks

2 years ago[DAG] visitINSERT_VECTOR_ELT - refactor BUILD_VECTOR creation from INSERT_VECTOR_ELT...
Simon Pilgrim [Sat, 16 Jul 2022 15:37:31 +0000 (16:37 +0100)]
[DAG] visitINSERT_VECTOR_ELT - refactor BUILD_VECTOR creation from INSERT_VECTOR_ELT chain.

D127595 added the ability to recurse up a (one-use) INSERT_VECTOR_ELT chain to create a BUILD_VECTOR before other combines manage to break the chain, something that is particularly bad in D127115.

The patch generalises this so it doesn't have to build the chain starting from the last element insertion, instead it can now start from any insertion and will recurse up the chain until it finds all elements or finds a UNDEF/BUILD_VECTOR/SCALAR_TO_VECTOR which represents that start of the chain.

Fixes several regressions in D127115

2 years ago[DAG] visitINSERT_VECTOR_ELT - remove duplicate VT.getVectorNumElements() call. NFC.
Simon Pilgrim [Sat, 16 Jul 2022 15:20:49 +0000 (16:20 +0100)]
[DAG] visitINSERT_VECTOR_ELT - remove duplicate VT.getVectorNumElements() call. NFC.

2 years agoDon't sink ptrtoint/inttoptr sequences into non-noop addrspacecasts.
Tim Besard [Sat, 16 Jul 2022 14:34:42 +0000 (10:34 -0400)]
Don't sink ptrtoint/inttoptr sequences into non-noop addrspacecasts.

In https://reviews.llvm.org/D30114, support for mismatching address
spaces was introduced to CodeGenPrepare's optimizeMemoryInst, using
addrspacecast as it was argued that only no-op addrspacecasts would be
considered when constructing the address mode. However, by doing
inttoptr/ptrtoint, it's possible to get CGP to emit an addrspace
that's not actually no-op, introducing a miscompilation:

define void @kernel(i8* %julia_ptr) {
  %intptr = ptrtoint i8* %julia_ptr to i64
  %ptr = inttoptr i64 %intptr to i32 addrspace(3)*

  br label %end
end:

  store atomic i32 1, i32 addrspace(3)* %ptr unordered, align 4
  ret void
}

Gets compiled to:

define void @kernel(i8* %julia_ptr) {
end:
  %0 = addrspacecast i8* %julia_ptr to i32 addrspace(3)*
  store atomic i32 1, i32 addrspace(3)* %0 unordered, align 4
  ret void
}

In the case of NVPTX, this introduces a cvta.to.shared, whereas
leaving out the %end block and branch doesn't trigger this
optimization. This results in illegal memory accesses as seen in
https://github.com/JuliaGPU/CUDA.jl/issues/558

In this change, I introduced a check before doing the pointer cast
that verifies address spaces are the same. If not, it emits a
ptrtoint/inttoptr combination to get a no-op cast between address
spaces. I decided against disallowing ptrtoint/inttoptr with
non-default AS in matchOperationAddr, because now its still possible
to look through multiple sequences of them that ultimately do not
result in a address space mismatch (i.e. the second lit test).

2 years ago[AArch64] Regenerate arm64-vector-ldst.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:27:41 +0000 (15:27 +0100)]
[AArch64] Regenerate arm64-vector-ldst.ll test checks

2 years ago[AArch64] Regenerate arm64-neon-simd-ldst-one.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:26:51 +0000 (15:26 +0100)]
[AArch64] Regenerate arm64-neon-simd-ldst-one.ll test checks

2 years ago[AArch64] Regenerate arm64-vmax.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:25:43 +0000 (15:25 +0100)]
[AArch64] Regenerate arm64-vmax.ll test checks

2 years ago[AArch64] Regenerate arm64-mul.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:24:53 +0000 (15:24 +0100)]
[AArch64] Regenerate arm64-mul.ll test checks

2 years ago[mlir][NFC] Fully qualify typenames in SymbolInterfaces.td
Markus Böck [Sat, 16 Jul 2022 12:38:53 +0000 (14:38 +0200)]
[mlir][NFC] Fully qualify typenames in SymbolInterfaces.td

2 years ago[VectorCombine] Only consider shuffle uses with the same type.
David Green [Sat, 16 Jul 2022 12:23:39 +0000 (13:23 +0100)]
[VectorCombine] Only consider shuffle uses with the same type.

The backend getShuffleCosts do not currently handle shuffles that change
size very well. Limit the shuffles we collect to the same type to make
sure they do not cause issues as reported in D128732.

2 years agoFix signed/unsigned mismatch
Simon Pilgrim [Sat, 16 Jul 2022 10:48:41 +0000 (11:48 +0100)]
Fix signed/unsigned mismatch

2 years ago[DAG] Canonicalize non-inlane shuffle -> AND if all non-inlane referenced elements...
Simon Pilgrim [Sat, 16 Jul 2022 10:38:19 +0000 (11:38 +0100)]
[DAG] Canonicalize non-inlane shuffle -> AND if all non-inlane referenced elements are known zero

As mentioned on D127115, this patch that attempts to recognise shuffle masks that could be simplified to a AND mask - we already have a similar transform that will fold AND -> 'clear mask' shuffle, but this patch handles cases where the referenced elements are not from the same lane indices but are known to be zero.

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

2 years ago[MC] Avoid UAF in WinCOFFObjectWriter with weak symbols.
Tim Besard [Sat, 16 Jul 2022 07:48:30 +0000 (10:48 +0300)]
[MC] Avoid UAF in WinCOFFObjectWriter with weak symbols.

When using weak symbols, the WinCOFFObjectWriter keeps a list (`WeakDefaults`)
that's used to make names unique. This list should be reset when the object
writer is reset, because otherwise reuse of the object writer can result in
freed symbols being accessed. With some added output, this becomes clear when
using `llc` in `--run-twice` mode:

```
$ ./llc --compile-twice -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj

DefineSymbol::WeakDefaults
 - .weak.foo.default
 - .weak.bar.default

DefineSymbol::WeakDefaults
 - .weak.foo.default
 - áÑJij⌂  p§┼Ø┐☺
 - .debug_macinfo.dw
 - .weak.bar.default
```

This does not seem to leak into the output object file though, so I couldn't
come up with a test. I added one that just does `--run-twice` (and verified
that it does access freed memory), which should result in detecting the
invalid memory accesses when running under ASAN.

Observed in a Julia PR where we started using weak symbols:
https://github.com/JuliaLang/julia/pull/45649

Reviewed By: mstorsjo

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

2 years ago[DAG] combineShiftAnd1ToBitTest - match "and (srl (not X), C)), 1 --> (and X, 1<...
Simon Pilgrim [Sat, 16 Jul 2022 10:00:02 +0000 (11:00 +0100)]
[DAG] combineShiftAnd1ToBitTest - match "and (srl (not X), C)), 1 --> (and X, 1<<C) == 0" patterns

combineShiftAnd1ToBitTest already matches "and (not (srl X, C)), 1 --> (and X, 1<<C) == 0" patterns, but we can end up with situations where the not is before the shift.

Part of some yak shaving for D127115 to generalise the "xor (X >> ShiftC), XorC --> (not X) >> ShiftC" fold.

2 years ago[mlir][LLVM] Add OpBuilder for opaque pointer GEPs without struct indices
Markus Böck [Sat, 16 Jul 2022 08:55:49 +0000 (10:55 +0200)]
[mlir][LLVM] Add OpBuilder for opaque pointer GEPs without struct indices

An OpBuilder already exists for GEPs that does not have any struct indices for existing typed pointers, but no such builder exists for GEPs utilizing opaque pointers that has an explicit `basePtrType`.

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

2 years ago[LegacyPM] Remove ControlHeightReductionLegacyPass
Fangrui Song [Sat, 16 Jul 2022 08:35:56 +0000 (01:35 -0700)]
[LegacyPM] Remove ControlHeightReductionLegacyPass

This pass tries to reduce the number of conditional branches in the hot path
based on profile. It's mostly a no-op after legacy PGO passes are moved.

2 years ago[LegacyPM] Remove createInstrProfilingLegacyPass
Fangrui Song [Sat, 16 Jul 2022 08:26:40 +0000 (01:26 -0700)]
[LegacyPM] Remove createInstrProfilingLegacyPass

Follow the steps of removing non-core instrumentation passes like PGO.

2 years ago[test] Migrate PGO related -instrprof tests to new PM
Fangrui Song [Sat, 16 Jul 2022 08:21:11 +0000 (01:21 -0700)]
[test] Migrate PGO related -instrprof tests to new PM

2 years ago[test] Migrate FunctionImport/cg_profile.ll to new PM
Fangrui Song [Sat, 16 Jul 2022 08:10:39 +0000 (01:10 -0700)]
[test] Migrate FunctionImport/cg_profile.ll to new PM

2 years ago[test] Migrate legacy InstrProfiling tests to new PM
Fangrui Song [Sat, 16 Jul 2022 08:10:08 +0000 (01:10 -0700)]
[test] Migrate legacy InstrProfiling tests to new PM

2 years ago[flang] Use value_or (NFC)
Kazu Hirata [Sat, 16 Jul 2022 07:51:54 +0000 (00:51 -0700)]
[flang] Use value_or (NFC)

2 years ago[LegacyPM] Remove CGProfileLegacyPass
Fangrui Song [Sat, 16 Jul 2022 07:39:55 +0000 (00:39 -0700)]
[LegacyPM] Remove CGProfileLegacyPass

It's mostly a no-op after I removed legacy PGO passes in D123834.

2 years ago[SDAG] Add test for DAGCombiner multiple result commutative CSE
Itay Bookstein [Fri, 15 Jul 2022 20:30:57 +0000 (23:30 +0300)]
[SDAG] Add test for DAGCombiner multiple result commutative CSE

This commit adds a test for DAGCombiner commutative CSE on
nodes with multiple results (UMUL_LOHI). In this commit it
asserts the lack of CSE, a later commit will demonstrate
the CSE in the changed assertions.

Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Reviewed By: barannikov88

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

2 years ago[mli][sparse] Remove manual dense dealloc from test case
Matthias Springer [Fri, 15 Jul 2022 06:17:50 +0000 (08:17 +0200)]
[mli][sparse] Remove manual dense dealloc from test case

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

2 years ago[MLIR] Clean up checks for alloc-like ops in analysis
Uday Bondhugula [Sat, 16 Jul 2022 07:21:55 +0000 (12:51 +0530)]
[MLIR] Clean up checks for alloc-like ops in analysis

Clean up checks for alloc-like ops in analysis. Use the analysis
utility to properly check for the desired kind of effects. The previous
locality utility worked for all practical purposes but wasn't sound and
was locally duplicate code. Instead, use mlir::hasSingleEffect.

Reviewed By: rriddle

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

2 years ago[flang] Use *X instead of X.getValue() (NFC)
Kazu Hirata [Sat, 16 Jul 2022 07:24:02 +0000 (00:24 -0700)]
[flang] Use *X instead of X.getValue() (NFC)

Per Flang C++ Style Guide, this patch replaces X.getValue() with *X
where *X is protected by a presence test.

2 years ago[MLIR] NFC. Clean up logic of hasSingleEffect
Uday Bondhugula [Sat, 16 Jul 2022 07:09:24 +0000 (12:39 +0530)]
[MLIR] NFC. Clean up logic of hasSingleEffect

Clean up conditional logic of hasSingleEffect. NFC.

Reviewed By: rriddle

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