[llvm-dev] Pass and Transformation-level debugging in LLVM (original) (raw)

David Greene via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 20 09:56:49 PDT 2018


Zhizhou Yang via llvm-dev <llvm-dev at lists.llvm.org> writes:

To bring it to the next level, DebugCounter provides features for me to have an in-pass (transformation) level limit to tell which transform in the pass exactly caused the error. When we set StopAfter value for a DebugCounter, it will eventually stop there as a limit.

And in D50031 and rL337748, I added a method to print DebugCounter info: the -print-debug-counter flag. With this, writing a transformation level bisection script will be more straightforward. I have already built a bisection tool to help Android toolchain debug on our side. So I will say that the bisecting idea with OptBisect and DebugCounter helps us save time while debugging mis-compilations.

There is already a DebugCounter bisect tool in utils/bisect-skip-count.

It is not documented, unfortunately. I had to figure it out by inspection, but you use it by including "%(skip)d" and "$(count)d" in the command you specify to bisect-skip-count. Then those values get filled in and your command should respond to them appropriately. For example:

bisect-skip-count bisect-command.sh "%(skip)d" "%(count)d" 2>&1 | tee bisect.out

bisect-command.sh presumably looks something like this:

#!/bin/bash

skip=$1 count=$2

opt --debug-counter=my-counter-skip=${skip},my-counter-count=${count} ...

I recently used bisect-skip-count in this way very successfully to track down an aliasing bug deep in the machine scheduler. I'm working on documenting bisect-skip-count so people know about it. I can add comments to the script but I haven't looked at updating web page sources yet. I was thinking of adding something to the existing opt-bisect page. Guidance here would be helpful.

I agree that anyone who adds DebugCounters should propose those changes on Phabricator. We can incrementally improve the debuggability of LLVM with such a process.

                            -David


More information about the llvm-dev mailing list