[llvm-commits] A small cleanup in bugpoint

Rafael Espindola espindola at google.com
Mon Jul 26 20:27:12 PDT 2010


I recently had to debug bugpoint and found the code a bit confusing.
The two main things I found hard to follow were:

* The constant mutation a swapping of the "program being tested"
* The doTest functions that take a prefix and a suffix and are
expected to mutate the program

I think the first case can be avoided by moving the Program field out
of BugDriver. This also opens the possibility of implementing a
functional doTest.  I think we could implement something with the
interface:

  virtual const Module  *doTest(cost Module *M, std::vector<ElTy>
&List, std::string &Error);

The idea is that the test is pure and it should "apply" the List to M
and return the new module *if the bug is not present*. If the bug is
present, it should return NULL. A basic advantaged of this interface
is avoiding any confusion on when the program is updated or not.

Applying the list has different meanings depending on what ElTy is. It
can be running that list of passes or running a fixed list of passes
on that list of functions. A "bug being present" can be a crash or
miscompiled program.

The current Prefix + Suffix behavior of doTest would become something
like the pseudo code:


TempM = DoTest(M, Prefix) // try the prefix on M
if !TempM:
  Continue with the Prefix. It "has" the bug.
else:
  X = doTest(TempM, Suffix) // try the suffix on the result of
applying the prefix on M
  if !X:
    delete M
    M = TempM
    continue with the Suffix. It "has" the bug.
  else: // Splitting the list in these Suffix and Prefix doesn't
reproduce the bug
    delete TempM
    delete X

The attached patch is just a small part of this that is particularly
easy to fix. Instead of abusing swapProgramIn, just add a Module
argument to EmitProgressBitcode.

Is the patch OK. Are the above description and assumptions reasonable?

Cheers,
-- 
Rafael Ávila de Espíndola
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bugpoint.patch
Type: text/x-patch
Size: 9614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100726/8d998a30/attachment.bin>


More information about the llvm-commits mailing list