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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 07:21:42 PDT 2022


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

The global ctor evaluator currently handles by checking whether the memset memory is already zero, and skips it in that case. However, it only actually check the first byte of the memory being set.

This patch extends the code to check all bytes being set. This is done byte-by-byte to avoid converting undef values to zeros in larger reads. However, the handling is still not completely correct, because there might still be padding bytes (though probably this doesn't matter much in practice, as I'd expect global variable padding to be zero-initialized in practice).

Mostly fixes https://github.com/llvm/llvm-project/issues/55859.


https://reviews.llvm.org/D128532

Files:
  llvm/include/llvm/Transforms/Utils/Evaluator.h
  llvm/lib/Transforms/Utils/Evaluator.cpp
  llvm/test/Transforms/GlobalOpt/ctor-memset.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128532.439746.patch
Type: text/x-patch
Size: 5223 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220624/55113755/attachment.bin>


More information about the llvm-commits mailing list