[all-commits] [llvm/llvm-project] be5d46: [Attributor][FIX] Traverse uses even if a value is...

Johannes Doerfert via All-commits all-commits at lists.llvm.org
Sat Jul 10 10:33:30 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: be5d46e9bbc92ffbff26fa56181f5e21f9e30761
      https://github.com/llvm/llvm-project/commit/be5d46e9bbc92ffbff26fa56181f5e21f9e30761
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/attrs.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/fp80.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/reserve-tbaa.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/2009-09-24-byval-ptr.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/dangling-block-address.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/musttail-call.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
    M llvm/test/Transforms/Attributor/align.ll
    M llvm/test/Transforms/Attributor/depgraph.ll
    M llvm/test/Transforms/Attributor/internal-noalias.ll
    M llvm/test/Transforms/Attributor/internalize.ll
    M llvm/test/Transforms/Attributor/liveness.ll
    M llvm/test/Transforms/Attributor/memory_locations.ll
    M llvm/test/Transforms/Attributor/nodelete.ll
    M llvm/test/Transforms/Attributor/nonnull.ll
    M llvm/test/Transforms/Attributor/norecurse.ll
    M llvm/test/Transforms/Attributor/noundef.ll
    M llvm/test/Transforms/Attributor/potential.ll
    M llvm/test/Transforms/Attributor/range.ll
    M llvm/test/Transforms/Attributor/value-simplify.ll

  Log Message:
  -----------
  [Attributor][FIX] Traverse uses even if a value is assumed constant

Not all attributes are able to handle the interprocedural step and
follow the uses into a call site. Let them be able to combine call site
uses instead. This might result in some unused values/arguments being
leftover but it removes problems where we misused "is dead" even though
it was actually "is simplified/replaced".

We explicitly check for dead values due to constant propagation in
`AAIsDeadValueImpl::areAllUsesAssumedDead` instead.

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


  Commit: 93a279a67dc05c4ce2e3476ee249c1f64634d6e4
      https://github.com/llvm/llvm-project/commit/93a279a67dc05c4ce2e3476ee249c1f64634d6e4
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/nocapture-1.ll

  Log Message:
  -----------
  [Attributor] Introduce an optimistic getUnderlyingObjects helper

As the `llvm::getUnderlyingObjects` helper, the optimistic version
collects objects that might be the base of a given pointer. In contrast
to the llvm variant, the optimistic one will use assumed information,
e.g., about select conditions or dead blocks, to provide a more precise
result.

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


  Commit: 374e573cfc2b85ee2bc661bfb5fdaeb026fb1cc9
      https://github.com/llvm/llvm-project/commit/374e573cfc2b85ee2bc661bfb5fdaeb026fb1cc9
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/ArgumentPromotion/inalloca.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/profile.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/sret.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/PR16052.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/arg-count-mismatch.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/multiple_callbacks.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/musttail-call.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/return-argument.ll
    M llvm/test/Transforms/Attributor/align.ll
    M llvm/test/Transforms/Attributor/cb_liveness_disabled.ll
    M llvm/test/Transforms/Attributor/cb_liveness_enabled.ll
    M llvm/test/Transforms/Attributor/cb_range_enabled.ll
    M llvm/test/Transforms/Attributor/cgscc_bugs.ll
    M llvm/test/Transforms/Attributor/depgraph.ll
    M llvm/test/Transforms/Attributor/dereferenceable-2-inseltpoison.ll
    M llvm/test/Transforms/Attributor/dereferenceable-2.ll
    M llvm/test/Transforms/Attributor/heap_to_stack.ll
    M llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
    M llvm/test/Transforms/Attributor/internalize.ll
    M llvm/test/Transforms/Attributor/memory_locations.ll
    M llvm/test/Transforms/Attributor/noalias.ll
    M llvm/test/Transforms/Attributor/nocapture-1.ll
    M llvm/test/Transforms/Attributor/nocapture-2.ll
    M llvm/test/Transforms/Attributor/nonnull.ll
    M llvm/test/Transforms/Attributor/potential.ll
    M llvm/test/Transforms/Attributor/range.ll
    M llvm/test/Transforms/Attributor/read_write_returned_arguments_scc.ll
    M llvm/test/Transforms/Attributor/readattrs.ll
    M llvm/test/Transforms/Attributor/returned.ll
    M llvm/test/Transforms/Attributor/undefined_behavior.ll
    M llvm/test/Transforms/Attributor/value-simplify.ll
    M llvm/test/Transforms/OpenMP/replace_globalization.ll

  Log Message:
  -----------
  [Attributor] Use AAValueSimplify to simplify returned values

We should use AAValueSimplify for all value simplification, however
there was some leftover logic that predates AAValueSimplify in
AAReturnedValues. This remove the AAReturnedValues part and provides a
replacement by making AAValueSimplifyReturned strong enough to handle
all previously covered cases. Further, this improve
AAValueSimplifyCallSiteReturned to handle returned arguments.

AAReturnedValues is now much easier and the collected returned
values/instructions are now from the associated function only, making it
much more sane. We also do not have the brittle logic anymore that looks
for unresolved calls. Instead, we use AAValueSimplify to handle
recursion.

Useful code has been split into helper functions, e.g., an Attributor
interface to get a simplified value.

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


  Commit: 1eb31d6de36bc274fa8fb692615515223148ac5e
      https://github.com/llvm/llvm-project/commit/1eb31d6de36bc274fa8fb692615515223148ac5e
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    M llvm/test/Transforms/Attributor/depgraph.ll
    M llvm/test/Transforms/Attributor/heap_to_stack.ll
    M llvm/test/Transforms/OpenMP/remove_globalization.ll

  Log Message:
  -----------
  [Attributor] Reorganize AAHeapToStack

In order to simplify future extensions, e.g., the merge of
AAHeapToShared in to AAHeapToStack, we reorganize AAHeapToStack and the
state we keep for each malloc-like call. The result is also less
confusing as we only track malloc-like calls, not all calls. Further, we
only perform the updates necessary for a malloc-like to argue it can go
to the stack, e.g., we won't check all uses if we moved on to the
"must-be-freed" argument.

This patch also uses Attributor helps to simplify the allocated size,
alignment, and the potentially freed objects.

Overall, this is mostly a reorganization and only the use of the
optimistic helpers should change (=improve) the capabilities a bit.

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


  Commit: 5003ba2542c14ab203ff6875af496d816144a5f4
      https://github.com/llvm/llvm-project/commit/5003ba2542c14ab203ff6875af496d816144a5f4
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/lvi-for-ashr.ll
    M llvm/test/Transforms/Attributor/value-simplify.ll

  Log Message:
  -----------
  [Attributor] Look through selects in genericValueTraversal

If we can simplify the select condition we can avoid one value in the
traversal.

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


  Commit: 1d5711c3eeb62098b46d4d383f2e849b9756105d
      https://github.com/llvm/llvm-project/commit/1d5711c3eeb62098b46d4d383f2e849b9756105d
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
    M clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
    M llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
    M llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    M llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    M llvm/test/Transforms/OpenMP/replace_globalization.ll
    M llvm/test/Transforms/OpenMP/single_threaded_execution.ll
    A openmp/libomptarget/deviceRTLs/common/include/target.h
    M openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
    M openmp/libomptarget/deviceRTLs/common/src/parallel.cu
    M openmp/libomptarget/deviceRTLs/interface.h
    M openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

  Log Message:
  -----------
  [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

In the spirit of TRegions [0], this patch provides a simpler and uniform
interface for a kernel to set up the device runtime. The OMPIRBuilder is
used for reuse in Flang. A custom state machine will be generated in the
follow up patch.

The "surplus" threads of the "master warp" will not exit early anymore
so we need to use non-aligned barriers. The new runtime will not have an
extra warp but also require these non-aligned barriers.

[0] https://link.springer.com/chapter/10.1007/978-3-030-28596-8_11

This was in parts extracted from D59319.

Reviewed By: ABataev, JonChesterfield

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


  Commit: f0628c6ff7ba2f3ceeb99791e5e34028de0c82c4
      https://github.com/llvm/llvm-project/commit/f0628c6ff7ba2f3ceeb99791e5e34028de0c82c4
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    A llvm/test/Transforms/OpenMP/custom_state_machines.ll
    A llvm/test/Transforms/OpenMP/custom_state_machines_remarks.ll
    M llvm/test/Transforms/OpenMP/globalization_remarks.ll
    M llvm/test/Transforms/OpenMP/remove_globalization.ll
    M llvm/test/Transforms/OpenMP/replace_globalization.ll
    M llvm/test/Transforms/OpenMP/single_threaded_execution.ll

  Log Message:
  -----------
  [OpenMP] Create custom state machines for generic target regions

In the spirit of TRegions [0], this patch creates a custom state
machine for a generic target region based on the potentially called
parallel regions.

The code analysis is done interprocedurally via an abstract attribute
(AAKernelInfo). All outermost parallel regions are collected and we
check if there might be unknown outermost parallel regions for which
we need an indirect call. Other AAKernelInfo extensions are expected.

[0] https://link.springer.com/chapter/10.1007/978-3-030-28596-8_11

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


  Commit: ae08df87dfbae62542d2a37ecebbbc5fa04b82f4
      https://github.com/llvm/llvm-project/commit/ae08df87dfbae62542d2a37ecebbbc5fa04b82f4
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/IPConstantProp/PR16052.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/return-argument.ll
    M llvm/test/Transforms/Attributor/heap_to_stack.ll
    M llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
    M llvm/test/Transforms/Attributor/memory_locations.ll
    M llvm/test/Transforms/Attributor/noalias.ll
    M llvm/test/Transforms/Attributor/nonnull.ll
    M llvm/test/Transforms/Attributor/value-simplify.ll

  Log Message:
  -----------
  [Attributor][FIX] Do not replace a value with a non-dominating instruction

We have to be careful when we replace values to not use a non-dominating
instruction. It makes sense that simplification offers those as
"simplified values" but we can't manifest them in the IR without PHI
nodes. In the future we should consider potentially adding those PHI
nodes.


  Commit: 966342790e8d4a64295845b50f49117d4ec9e7cf
      https://github.com/llvm/llvm-project/commit/966342790e8d4a64295845b50f49117d4ec9e7cf
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/value-simplify.ll

  Log Message:
  -----------
  [Attributor][FIX] Sanitize queries to LVI and ScalarEvolution

When we talk to outside analyse, e.g., LVI and ScalarEvolution, we need
to be careful with the query. The particular error occurred because we
folded a PHI node before the LVI query but the context location was now
not dominated by the value anymore. This is not supported by LVI so we
have to filter these situations before we query the outside analyses.


  Commit: e603ca0306d7f41d407b013c8cb27ca49e571de2
      https://github.com/llvm/llvm-project/commit/e603ca0306d7f41d407b013c8cb27ca49e571de2
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M openmp/libomptarget/deviceRTLs/common/src/loop.cu
    M openmp/libomptarget/deviceRTLs/common/src/parallel.cu
    M openmp/libomptarget/deviceRTLs/common/src/reduction.cu
    M openmp/libomptarget/deviceRTLs/common/src/support.cu
    M openmp/libomptarget/deviceRTLs/common/src/sync.cu
    M openmp/libomptarget/deviceRTLs/common/src/task.cu
    M openmp/libomptarget/deviceRTLs/common/support.h

  Log Message:
  -----------
  [OpenMP] Remove checkXXXX device runtime functions

We had multiple functions to determine the execution mode (SPMD/Generic)
and runtime status (initialized/uninitialized) but that just increased
complexity without a real benefit. Especially with D102307 in mind it
is helpful to reduce the dependence on the `ident_t` flags.

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


  Commit: d39179d7fa17a20e214cffeaad61a12e9b0d337a
      https://github.com/llvm/llvm-project/commit/d39179d7fa17a20e214cffeaad61a12e9b0d337a
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
    M llvm/lib/IR/Assumptions.cpp
    M llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    M llvm/test/Transforms/OpenMP/custom_state_machines.ll
    M llvm/test/Transforms/OpenMP/custom_state_machines_remarks.ll
    A llvm/test/Transforms/OpenMP/spmdization.ll
    A llvm/test/Transforms/OpenMP/spmdization_remarks.ll

  Log Message:
  -----------
  [OpenMP] Detect SPMD compatible kernels and execute them as such

In the spirit of TRegions [0], this patch analyzes a kernel and tracks
if it can be executed in SPMD-mode. If so, we flip the arguments of
the __kmpc_target_init and deinit call to enable the mode. We also
update the `<kernel>_exec_mode` flag to indicate to the runtime we
changed the mode to SPMD.

The code analysis is done interprocedurally by extending the
AAKernelInfo abstract attribute to track SPMD compatibility as well.

[0] https://link.springer.com/chapter/10.1007/978-3-030-28596-8_11

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


  Commit: 269416d41908bb670f67af689155d5ab8eea689a
      https://github.com/llvm/llvm-project/commit/269416d41908bb670f67af689155d5ab8eea689a
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/lib/Transforms/IPO/OpenMPOpt.cpp

  Log Message:
  -----------
  [Attributor][NFCI] Add UsedAssumedInformation to more interfaces

As with other Attributor interfaces we often want to know if assumed
information was used to answer a query. This is important if only
known information is allowed or if known information can lead to an
early fixpoint. The users have been adjusted but none of them utilizes
the new information yet.


Compare: https://github.com/llvm/llvm-project/compare/ebbe149a6f08...269416d41908


More information about the All-commits mailing list