https://bugs.llvm.org/show_bug.cgi?id=47712

            Bug ID: 47712
           Summary: verifyFunction spends too much time validating module
                    metadata in +asserts builds
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Core LLVM classes
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected], [email protected]

I was profiling LLVM for other reasons and accidentally used a build with
assertions enabled. What I discovered is that, if you compile PassBuilder.cpp
with assertions, most of the time is spent in the verifier, mostly due to
asserts in SLPVectorizer and LoopVectorizer. There are 187,486 samples overall,
and 131,698 of them (70.2%) are inside calls to verifyFunction.

If you drill into what verifyFunction is doing, all the time is spent in
recursive calls to visitMDNode. These calls are rooted in visitInstruction
calls to visitMDNode:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/IR/Verifier.cpp#L4431

visitMDNode in turn validates each of its operands. This is undesirable when
validating a function: location metadata points upwards, so validating one
location will ultimately validate the entire metadata graph rooted in the
compile unit. See the tree of calls in this screenshot:
https://reviews.llvm.org/file/data/u5ms43qqwl3aahxopjql/PHID-FILE-ysoomivlg3fixz52f4ny/visitmdnode-profile.png

The code I linked was added in
http://github.com/llvm/llvm-project/commit/8dfe819bcd23, but I'm not sure when
this regressed. We used to ship clang with assertions enabled, so we saw these
non-linear assert compile time issues in the field as they arose. Now that we
are no longer watching carefully, it seems like these issues can slip in.

Should we try to establish the invariant that llvm::verifyFunction runs in
O(#instructions), or should we move all calls to verifyFunction to
EXPENSIVE_CHECKS?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to