This is an archive of the discontinued LLVM Phabricator instance.

(Expensive) Check for Loop, SCC and Region pass return status
ClosedPublic

Authored by serge-sans-paille on Aug 25 2020, 10:44 PM.

Details

Summary

This generalizes the logic introduced in https://reviews.llvm.org/D80916 to other passes.
It's needed by https://reviews.llvm.org/D86442 to assert passes correctly report their status.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 10:44 PM
serge-sans-paille requested review of this revision.Aug 25 2020, 10:44 PM

Thanks. I don't see anything wrong with this, but I think it needs some more eyes on it.

jdoerfert accepted this revision.Aug 27 2020, 6:24 AM

LGTM

llvm/include/llvm/IR/StructuralHash.h
3

Nit: ^

llvm/lib/IR/StructuralHash.cpp
3

Nit ^

This revision is now accepted and ready to land.Aug 27 2020, 6:24 AM
nikic added inline comments.Aug 27 2020, 6:35 AM
llvm/lib/Analysis/CallGraphSCCPass.cpp
470

This will probably cause an unused variable warning in NDEBUG builds.

Take review into account

nikic added inline comments.Aug 27 2020, 9:50 AM
llvm/include/llvm/IR/StructuralHash.h
29–30

Style nit: I believe LLVM uses leading const where possible.

llvm/lib/Analysis/CallGraphSCCPass.cpp
480

There is a mismatch between #if checks here. Above only EXPENSIVE_CHECKS is checked, here !NDEBUG is checked as well.

Aren't we guaranteed that !NDEBUG if EXPENSIVE_CHECKS is set? In any case, both should be consistent.

484

Style nit: Typically llvm_unreachable() is used instead of assert(false).

Take into account @nikic review.

nikic accepted this revision.Aug 27 2020, 1:47 PM

LGTM

MaskRay added inline comments.
llvm/lib/IR/StructuralHash.cpp
72

Probably not worth changing now.... many older functions are capitalized but they are in conflict with the lowerCase style for new functions

uabelho added a subscriber: uabelho.Sep 3 2020, 3:03 AM
uabelho added inline comments.
llvm/lib/IR/StructuralHash.cpp
51

Hi!
What if the BB doesn't have a terminator at all? Then Term will be nullptr which I don't think is good..

(This happens for us in the unit test PassManager.CallGraphUpdater0 with expensive checks when we run in our downstream clone)

fhahn added inline comments.Sep 3 2020, 3:08 AM
llvm/lib/IR/StructuralHash.cpp
51

I'd assume this should only be called for valid IR, which means there must be terminator?

Unrelated, but could this just be something like for (auto &Succ : successors(BB)) {?

jdoerfert added inline comments.Sep 3 2020, 8:32 AM
llvm/lib/IR/StructuralHash.cpp
51

I'd assume this should only be called for valid IR, which means there must be terminator?

Yes. We cannot harden this for broken IR (without good reason). @uabelho What pass breaks the IR?

uabelho added inline comments.Sep 3 2020, 9:37 AM
llvm/lib/IR/StructuralHash.cpp
51

I see. Thanks!

(The testcase was originally not behaving well (it inserted a non-terminator after the terminator in a bb), but that was fixed in 3667d87. Unfortunately we have lost that fix downstream during some EXPENSIVE_CHECKS fiddling we've done and then ran into this problem.)

No need to change the successor iteration then.

Thanks again!