[all-commits] [llvm/llvm-project] 5e71b9: Explicitly pass type to cast load constant folding...

aeubanks via All-commits all-commits at lists.llvm.org
Tue Apr 20 00:59:46 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5e71b9fa933a279458f31adffb2a092493a9e1eb
      https://github.com/llvm/llvm-project/commit/5e71b9fa933a279458f31adffb2a092493a9e1eb
  Author: Arthur Eubanks <aeubanks at google.com>
  Date:   2021-04-20 (Tue, 20 Apr 2021)

  Changed paths:
    M llvm/include/llvm/Analysis/ConstantFolding.h
    M llvm/include/llvm/Transforms/Utils/Evaluator.h
    M llvm/lib/Analysis/ConstantFolding.cpp
    M llvm/lib/Transforms/IPO/GlobalOpt.cpp
    M llvm/lib/Transforms/Utils/Evaluator.cpp

  Log Message:
  -----------
  Explicitly pass type to cast load constant folding result

Previously we would use the type of the pointee to determine what to
cast the result of constant folding a load. To aid with opaque pointer
types, we should explicitly pass the type of the load rather than
looking at pointee types.

ConstantFoldLoadThroughBitcast() converts the const prop'd value to the
proper load type (e.g. [1 x i32] -> i32). Instead of calling this in
every intermediate step like bitcasts, we only call this when we
actually see the global initializer value.

In some existing uses of this API, we don't know the exact type we're
loading from immediately (e.g. first we visit a bitcast, then we visit
the load using the bitcast). In those cases we have to manually call
ConstantFoldLoadThroughBitcast() when simplifying the load to make sure
that we cast to the proper type.

Reviewed By: dblaikie

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




More information about the All-commits mailing list