[all-commits] [llvm/llvm-project] 0d966a: [Loads] Add canReplacePointersIfEqual helper.

Florian Hahn via All-commits all-commits at lists.llvm.org
Tue Sep 1 12:58:15 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d966ae4b2ac0344e15888d0f0a81c322e3d6dd2
      https://github.com/llvm/llvm-project/commit/0d966ae4b2ac0344e15888d0f0a81c322e3d6dd2
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2020-09-01 (Tue, 01 Sep 2020)

  Changed paths:
    M llvm/include/llvm/Analysis/Loads.h
    M llvm/lib/Analysis/Loads.cpp
    M llvm/unittests/Analysis/LoadsTest.cpp

  Log Message:
  -----------
  [Loads] Add canReplacePointersIfEqual helper.

This patch adds an initial, incomeplete and unsound implementation of
canReplacePointersIfEqual to check if a pointer value A can be replaced
by another pointer value B, that are deemed to be equivalent through
some means (e.g. information from conditions).

Note that is in general not sound to blindly replace pointers based on
equality, for example if they are based on different underlying objects.

LLVM's memory model is not completely settled as of now; see
https://bugs.llvm.org/show_bug.cgi?id=34548 for a more detailed
discussion.

The initial version of canReplacePointersIfEqual only rejects a very
specific case: replacing a pointer with a constant expression that is
not dereferenceable. Such a replacement is problematic and can be
restricted relatively easily without impacting most code. Using it to
limit replacements in GVN/SCCP/CVP only results in small differences in
7 programs out of MultiSource/SPEC2000/SPEC2006 on X86 with -O3 -flto.

This patch is supposed to be an initial step to improve the current
situation and the helper should be made stricter in the future. But this
will require careful analysis of the impact on performance.

Reviewed By: aqjune

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




More information about the All-commits mailing list