[PATCH] D125114: [SimplifyLibCalls] handle subobjects of constant aggregates
Martin Sebor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 18 13:14:21 PDT 2022
msebor added inline comments.
================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:660
+
+ SmallVector<Constant*, 256> Ar;
+ Type *Int8Ty = Type::getInt8Ty(GV->getContext());
----------------
nikic wrote:
> There is no need to convert the values to ConstantInt, you should be able to use the `ConstantDataArray::get()` constructor with the SmallVector directly.
Nice, thanks!
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4109
// Look through bitcast instructions and geps.
V = V->stripPointerCasts();
----------------
nikic wrote:
> You can replace this with stripAndAccumulateOffsets(), in which case you don't need explicit handling for GEPs.
You mean replace the line above and the whole `if` statement below with a call to `stripAndAccumulateOffsets()` plus the handling of the resulting offset? To do that I need to get a `DataLayout` reference from the `GlobalVariable` that `V` refers to, and I don't see how to do that without first stripping the intervening pointer casts.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125114/new/
https://reviews.llvm.org/D125114
More information about the llvm-commits
mailing list