Commit Graph

430548 Commits

Author SHA1 Message Date
Craig Topper 73f766ca9a [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.
2022-07-17 10:59:54 -07:00
Craig Topper ee6267c443 [RISCV] Remove Gather/Scatter Opt from the O0 pipeline. 2022-07-17 10:58:33 -07:00
Simon Pilgrim 53b90dd372 [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
2022-07-17 18:51:41 +01:00
Simon Pilgrim 0c7380ebbd [DAG] Add or(and(x,c1),and(or(x,y),c2)) tests
Tests for the fold suggested in D77804
2022-07-17 18:22:55 +01:00
Igor Zhukov d2f21f98a9 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
2022-07-17 16:43:41 +02:00
Nico Weber 7b3146dcd3 fix comment typo to cycle bots 2022-07-17 09:10:05 -04:00
Simon Pilgrim 26ce33706f [DAG] computeKnownBits - move UDIV handling to same place as UREM/SREM. NFC. 2022-07-17 11:59:42 +01:00
Simon Pilgrim 5ec47c6dc5 [DAG] Add MERGE_VALUE computeKnownBits/ComputeNumSignBits handling.
Just forward the value tracking to the operand specified by the ResNo
2022-07-17 11:58:08 +01:00
Florian Hahn cc0ee17951
[LV] Move VPPredInstPHIRecipe::execute to VPlanRecipes.cpp (NFC) 2022-07-17 11:34:23 +01:00
Kazu Hirata c13a09a462 [llvm] Fix header guards (NFC)
Identified with llvm-header-guard.
2022-07-17 02:18:55 -07:00
Carl Ritson 547e3cba7d [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
2022-07-17 17:34:05 +09:00
Kazu Hirata 9e6d1f4b5d [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
Fangrui Song 6f32e71b54 [test] Remove duplicate -sample-profile tests
When -passes=sample-profile is tested, -sample-profile is redundant.
2022-07-17 00:52:30 -07:00
Xi Ruoyao 36b52c38aa [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
2022-07-17 00:45:15 -07:00
Kazu Hirata 601b3a13de [Analysis] Qualify auto variables in for loops (NFC) 2022-07-16 23:26:34 -07:00
owenca cd434a202c [llvm] Wrap multi-statement macro definitions with do ... while (0) 2022-07-16 20:58:20 -07:00
zhongyunde 3a6b766b1b [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
2022-07-17 10:48:35 +08:00
Stella Laurenzo beebffa9ab [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.
2022-07-16 18:18:43 -07:00
Stella Laurenzo 5e83a5b475 [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
2022-07-16 17:27:50 -07:00
Fabian Parzefall 8477bc6761 [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
2022-07-16 17:23:24 -07:00
Kazu Hirata b7173553d7 Revert "[Support] Remove redundant declaration setCurrentDebugTypes (NFC)"
This reverts commit 52232abc23.

This patch breaks builds when NDEBUG is defined.
2022-07-16 17:19:27 -07:00
Brad Smith abc8f2b724 [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
2022-07-16 20:13:24 -04:00
Vitaly Buka 0fbafb5a1c [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.
2022-07-16 16:47:50 -07:00
Brad Smith 21ef59a55e [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
2022-07-16 19:08:34 -04:00
Kazu Hirata 52232abc23 [Support] Remove redundant declaration setCurrentDebugTypes (NFC)
The function is declared in llvm/include/llvm/Support/Debug.h.

Identified with readability-redundant-declaration.
2022-07-16 15:50:18 -07:00
Kazu Hirata c0fe37de04 [CodeGen] Remove redundant declaration createGreedyRegisterAllocator (NFC)
The function is declared in llvm/include/llvm/CodeGen/Passes.h.

Identified with readability-redundant-declaration.
2022-07-16 15:43:34 -07:00
Kazu Hirata 4d9d07c5fb [CodeGen] Use RegClassFilterFunc where appropriate (NFC) 2022-07-16 15:43:33 -07:00
Xing Xue d29c947732 [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
2022-07-16 18:11:04 -04:00
Vitaly Buka 45067f8fbf [test] Don't leak DerivedArgList in test 2022-07-16 14:03:38 -07:00
Sanjay Patel 7ca3e23f25 [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
2022-07-16 16:29:15 -04:00
Kazu Hirata 92a1b2afc8 [Analysis] Remove isArithmeticRecurrenceKind
The last use was removed on Jul 30, 2021 in commit
9d35594993.
2022-07-16 13:23:32 -07:00
owenca a0458d92e9 [clang-format] Never remove braces in macro definitions
Fixes #56559.

Differential Revision: https://reviews.llvm.org/D129921
2022-07-16 13:11:10 -07:00
Daniel Bertalan 2b2e858e9c [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
2022-07-16 21:46:47 +02:00
Kazu Hirata deac0ac523 [AMDGPU] Use default member initialization (NFC)
Identified with modernize-use-default-member-init.
2022-07-16 12:44:35 -07:00
Vitaly Buka bbc4a71e41 [test] Fix leak in test 2022-07-16 12:41:12 -07:00
Fangrui Song 9ff36df5a4 [PGO][InstrProf][test] Convert to opaque pointers and fix some stale tests 2022-07-16 11:42:35 -07:00
Kazu Hirata 6cbfffb3a3 [AMDGPU] Declare TableRef in terms of ArrayRef (NFC) 2022-07-16 10:56:20 -07:00
Igor Zhukov 9aea9ab83d 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
2022-07-16 19:47:45 +02:00
Igor Zhukov 844a320ccd 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
2022-07-16 19:46:34 +02:00
Simon Pilgrim d8888e14a0 Revert rG14364200821f7b2d97edf6e78160c514800d3ec6 "[ARM] Regenerate reg_sequence.ll test checks"
Breaks on some apple machines
2022-07-16 17:32:58 +01:00
Simon Pilgrim bba0c0df02 [SystemZ] Add funnel shift test coverage
Based off conversations on Issue #56495
2022-07-16 17:32:58 +01:00
Florian Hahn 6813b41d57
[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.
2022-07-16 17:24:07 +01:00
Krystian Kuzniarek b2465748f2 [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.
2022-07-16 18:19:11 +02:00
Simon Pilgrim 1436420082 [ARM] Regenerate reg_sequence.ll test checks 2022-07-16 17:10:35 +01:00
Simon Pilgrim a44bdf9bc1 [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
2022-07-16 16:37:31 +01:00
Simon Pilgrim 52b6168c16 [DAG] visitINSERT_VECTOR_ELT - remove duplicate VT.getVectorNumElements() call. NFC. 2022-07-16 16:20:49 +01:00
Tim Besard a323dfc015 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).
2022-07-16 10:56:42 -04:00
Simon Pilgrim dc681bc2e0 [AArch64] Regenerate arm64-vector-ldst.ll test checks 2022-07-16 15:27:47 +01:00
Simon Pilgrim 2d4c43d45f [AArch64] Regenerate arm64-neon-simd-ldst-one.ll test checks 2022-07-16 15:27:47 +01:00
Simon Pilgrim f7a9c5c61b [AArch64] Regenerate arm64-vmax.ll test checks 2022-07-16 15:27:47 +01:00