[PATCH] D100718: Explicitly pass type to cast load constant folding result

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 18 01:43:17 PDT 2021


aeubanks created this revision.
Herald added a subscriber: hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100718

Files:
  llvm/include/llvm/Analysis/ConstantFolding.h
  llvm/include/llvm/Transforms/Utils/Evaluator.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/Utils/Evaluator.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100718.338364.patch
Type: text/x-patch
Size: 9694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210418/a0ca6045/attachment.bin>


More information about the llvm-commits mailing list