This is an archive of the discontinued LLVM Phabricator instance.

Refactor the Verifier so it can diagnose IR validation errors and debug info metadata errors separately. (NFC)
ClosedPublic

Authored by aprantl on May 5 2016, 11:11 AM.

Details

Summary

This patch refactors the Verifier so it can diagnose IR validation errors and debug info metadata errors separately.
The motivation behind this change is that broken (or outdated) debug info can be "recovered" from by stripping the debug info.

The problem I'm trying to solve with this sequence of patches is that historically we've done a really bad job at verifying debug info. We want to be able to make the verifier stricter without having to worry about breaking bitcode compatibility with existing producers. For example, we don't necessarily want IR produced by an older version of clang to be rejected by an LTO link just because of malformed debug info, and rather provide an option to strip it. Note that merely outdated (but well-formed) debug info would continue to be auto-upgraded in this scenario.

rdar://problem/25818489

Diff Detail

Event Timeline

aprantl updated this revision to Diff 56313.May 5 2016, 11:11 AM
aprantl retitled this revision from to Refactor the Verifier so it can diagnose IR validation errors and debug info metadata errors separately. (NFC).
aprantl updated this object.
aprantl added reviewers: mehdi_amini, dexonsmith.
aprantl added a subscriber: llvm-commits.

seems like it'd be a bit of a performance hit to do this - compared to just
rolling the debug info version number & throwing out everything older. Is
it really worth it to take that performance hit for some uncertain amount
of debug info from old bitcode?

mehdi_amini accepted this revision.May 5 2016, 11:25 AM
mehdi_amini edited edge metadata.

LGTM (see inline nits)

lib/IR/Verifier.cpp
262

First letter should be capital.

265

Any reason not to put it in the initializer list?

This revision is now accepted and ready to land.May 5 2016, 11:25 AM
  1. The problem is that we'd have to bump the version number for every improvement we make to the Verifier. In the past month (thanks to Davide's effort) this would have been several times per week.
  2. It gets really messy when a vendor is stabilizing an LLVM branch separately from trunk and cherry-picking improvements that bump the version number.
  3. Frontends can easily create broken debug info (such as the bug caught by LLVM r267370) that no amount of version number bumping can guard against.

Also, this is not any more expensive since we are already running the Verifier (debug+IR) on all input anyway.

mehdi_amini added inline comments.May 5 2016, 1:20 PM
lib/IR/Verifier.cpp
262

You can either:

  • name it slightly differently than the member
  • keep the same name if you can use the initializer list (see the other comment below)
  • use this->TreatBrokenDebugInfoAsError = TreatBrokenDebugInfoAsError if you want to keep the same name but can't use the initializer list.

(I don't really mind, but I don't think I've seen the last option frequently used in LLVM)

probinson added inline comments.
lib/IR/Verifier.cpp
93

Need a space before '='.

aprantl closed this revision.May 6 2016, 12:33 PM

Thanks, commited with fixed as r268778.