[all-commits] [llvm/llvm-project] bf789b: [Attributor] Replace AAValueSimplify with AAPotent...

Johannes Doerfert via All-commits all-commits at lists.llvm.org
Tue Jul 19 14:25:04 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bf789b1957efd2482e1dbd164d91a6612a450fe3
      https://github.com/llvm/llvm-project/commit/bf789b1957efd2482e1dbd164d91a6612a450fe3
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2022-07-19 (Tue, 19 Jul 2022)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
    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/ArgumentPromotion/2008-02-01-ReturnAttrs.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/X86/min-legal-vector-width.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/X86/thiscall.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/aggregate-promote.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/alloca-as.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/array.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/attrs.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/basictest.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/byval-2.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/byval.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/chained.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/crash.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/musttail.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/profile.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/sret.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/2009-09-24-byval-ptr.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/PR16052.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/PR26044.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/return-argument.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/thread_local_acs.ll
    M llvm/test/Transforms/Attributor/align.ll
    M llvm/test/Transforms/Attributor/allow_list.ll
    M llvm/test/Transforms/Attributor/callbacks.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_disabled.ll
    M llvm/test/Transforms/Attributor/cb_range_enabled.ll
    M llvm/test/Transforms/Attributor/depgraph.ll
    M llvm/test/Transforms/Attributor/dereferenceable-1.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/internal-noalias.ll
    M llvm/test/Transforms/Attributor/liveness.ll
    M llvm/test/Transforms/Attributor/lvi-after-jumpthreading.ll
    M llvm/test/Transforms/Attributor/lvi-for-ashr.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/norecurse.ll
    M llvm/test/Transforms/Attributor/openmp_parallel.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-dbg.ll
    M llvm/test/Transforms/Attributor/value-simplify-gpu.ll
    M llvm/test/Transforms/Attributor/value-simplify-instances.ll
    A llvm/test/Transforms/Attributor/value-simplify-local-remote.ll
    M llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
    M llvm/test/Transforms/Attributor/value-simplify.ll
    M llvm/test/Transforms/Attributor/willreturn.ll
    M llvm/test/Transforms/Attributor/wrapper.ll
    M llvm/test/Transforms/OpenMP/is_spmd_exec_mode_fold.ll
    M llvm/test/Transforms/OpenMP/parallel_deletion.ll
    M llvm/test/Transforms/OpenMP/remove_globalization.ll
    M llvm/test/Transforms/OpenMP/replace_globalization.ll
    M llvm/test/Transforms/OpenMP/spmdization.ll

  Log Message:
  -----------
  [Attributor] Replace AAValueSimplify with AAPotentialValues

For the longest time we used `AAValueSimplify` and
`genericValueTraversal` to determine "potential values". This was
problematic for many reasons:
- We recomputed the result a lot as there was no caching for the 9
  locations calling `genericValueTraversal`.
- We added the idea of "intra" vs. "inter" procedural simplification
  only as an afterthought. `genericValueTraversal` did offer an option
  but `AAValueSimplify` did not. Thus, we might end up with "too much"
  simplification in certain situations and then gave up on it.
- Because `genericValueTraversal` was not a real `AA` we ended up with
  problems like the infinite recursion bug (#54981) as well as code
  duplication.

This patch introduces `AAPotentialValues` and replaces the
`AAValueSimplify` uses with it. `genericValueTraversal` is folded into
`AAPotentialValues` as are the instruction simplifications performed in
`AAValueSimplify` before. We further distinguish "intra" and "inter"
procedural simplification now.

`AAValueSimplify` was not deleted as we haven't ported the
re-materialization of instructions yet. There are other differences over
the former handling, e.g., we may not fold trivially foldable
instructions right now, e.g., `add i32 1, 1` is not folded to `i32 2`
but if an operand would be simplified to `i32 1` we would fold it still.

We are also even more aware of function/SCC boundaries in CGSCC passes,
which is good even if some tests look like they regress.

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

Note: A previous version was flawed and consequently reverted in
      6555558a80589d1c5a1154b92cc3af9495f8f86c.




More information about the All-commits mailing list