[llvm-dev] [RFC] Pass return status

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 11 11:15:44 PDT 2020


Hi,

I think this is a very useful addition.

Note that many passes using EXPENSIVE_CHECKS to verify themselves
still allow switching verification on using a command line option
(e.g. -verify-loop-info) where EXPENSIVE_CHECKS just controls the
default value. This is useful so it can be enabled explicitly e.g. in
regression tests for proper pass behavior.

Michael

Am Do., 11. Juni 2020 um 10:42 Uhr schrieb Serge Guelton via llvm-dev
<llvm-dev at lists.llvm.org>:
>
> Hi folks,
>
> Per the documentation[0], whenever an LLVM pass doesn't modify the IR it's run on, it
> should return `false`--it's okay to return `true` if no change happen, just less
> optimal. In the New PM area, this is generally translated into a `PreservedAnalyses::all()`.
>
> https://reviews.llvm.org/D80916 provides an `EXPENSIVE_CHECK` that computes a
> hash of the IR before and after the pass, and checks that any change is
> correctly reported. The hash is currently incomplete (on purpose, let's start
> small), but it turns out a dozen of passes do not satisfy that
> requirement.
>
> This could lead to various category of bugs (dangling references, inconsistent
> state, etc). This affects both New and Legacy PM, as passes tend to wrap functions
> that report their status.
>
> I wrote a bunch of patches for all failure detected by this check, as I cannot land the
> check now, it would break the buildbots :-) Any help to review the remaining
> ones [1] is appreciated.
>
> Once that check lands and we're relatively confident on the quality of the
> return status, some more optimizations could be triggered, like
> https://reviews.llvm.org/D80707.
>
>
> [0] https://llvm.org/docs/WritingAnLLVMPass.html#the-runonmodule-method
> [1] https://reviews.llvm.org/D81230
>     https://reviews.llvm.org/D81236
>     https://reviews.llvm.org/D81256
>     https://reviews.llvm.org/D81238
>     https://reviews.llvm.org/D81225
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list