[PATCH] D149989: [FuzzMutate] Module size heuristics

Zhenkai Weng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 5 13:44:24 PDT 2023


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

IRMutation::mutateModule() currently requires the bitcode size of the module.
To compute the bitcode size, one way is to write the module to a buffer using
BitcodeWriter and calculating the buffer size. This would be fine for a single
mutation, but infeasible for repeated mutations due to the large overhead. It
turns out that the only IR strategy weight calculation method that depends on
the current module size is InstDeleterStrategy, which deletes instructions more
frequently as the module size approaches a given max size. However, there is no
real need for the size to be in bytes of bitcode, so we can use a different
metric. One alternative is to let the size be the number of objects in the
Module, including instructions, basic blocks, globals, and aliases. Although
getting the number of instructions is still O(n), it should have significantly
less overhead than BitcodeWriter. This suggestion would cause a change to the
IRMutator API, since IRMutator::mutateModule() can calculate the Module size
itself.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149989

Files:
  llvm/include/llvm/FuzzMutate/IRMutator.h
  llvm/lib/FuzzMutate/IRMutator.cpp
  llvm/unittests/FuzzMutate/StrategiesTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149989.519962.patch
Type: text/x-patch
Size: 6690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230505/d87db04c/attachment.bin>


More information about the llvm-commits mailing list