[PATCH] D128532: [GlobalOpt] Fix memset handling in global ctor evaluation (PR55859)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 07:47:47 PDT 2022


nikic marked an inline comment as done.
nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/Evaluator.cpp:453-454
+              DL, Offset, /* AllowNonInbounds */ true));
+          Offset = Offset.sextOrTrunc(
+              DL.getIndexTypeSizeInBits(Ptr->getType()));
+          auto *GV = dyn_cast<GlobalVariable>(Ptr);
----------------
aeubanks wrote:
> why is this necessary?
This is to handle address space casts that change the index size. However, it doesn't look like this needed here (because the called API doesn't require a specific width for the offset). I'll drop this for now.


================
Comment at: llvm/lib/Transforms/Utils/Evaluator.cpp:465
+            Constant *DestVal = ComputeLoadResult(GV, Val->getType(), Offset);
+            if (DestVal != Val) {
+              LLVM_DEBUG(dbgs() << "Memset is not a no-op at offset "
----------------
aeubanks wrote:
> are there any tests to test non-zero values?
Nope, I've added some in https://github.com/llvm/llvm-project/commit/771c46ad291ce4c2265782c8a89a6771055c65d8.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128532/new/

https://reviews.llvm.org/D128532



More information about the llvm-commits mailing list