This is an archive of the discontinued LLVM Phabricator instance.

Port the strip-invalid-debuginfo logic to the legacy verifier pass, too.
ClosedPublic

Authored by aprantl on May 25 2016, 9:07 AM.

Details

Reviewers
mehdi_amini
Summary
Since r268966 the modern Verifier pass defaults to stripping invalid debug info
in nonasserts builds.  This patch ports this behavior back to the legacy
Verifier pass as well.  The primary motivation is that the clang frontend
accepts bitcode files as input but is still using the legacy pass pipeline.

Background: 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/26448800>

Diff Detail

Event Timeline

aprantl updated this revision to Diff 58437.May 25 2016, 9:07 AM
aprantl retitled this revision from to Port the strip-invalid-debuginfo logic to the legacy verifier pass, too..
aprantl updated this object.
aprantl added a reviewer: mehdi_amini.
aprantl set the repository for this revision to rL LLVM.
aprantl added subscribers: llvm-commits, friss.
aprantl updated this revision to Diff 58439.May 25 2016, 9:19 AM
aprantl removed rL LLVM as the repository for this revision.

Fixed a logic error that would have prevented the assertion from firing at all.

mehdi_amini edited edge metadata.May 25 2016, 1:37 PM

I didn't know there was a modern and a "legacy" one. Is it suppose to go away? Could we just nuke it and move clang to the new one?

Since r268966 the modern Verifier pass defaults to stripping invalid debug info in nonasserts builds. This patch ports this behavior back to the legacy Verifier pass as well.

This sentence makes me expect a difference between release and assert builds, and I don't spot it in this patch.

mehdi_amini added inline comments.May 25 2016, 1:41 PM
lib/IR/Verifier.cpp
4475

It is not clear to me why new VerifierLegacyPass() has a different behavior with respect to debug info compared to new VerifierLegacyPass(true) or new VerifierLegacyPass(false) (these last two will have the same behavior in face of debug info.

In D20629#439834, @joker.eph wrote:

I didn't know there was a modern and a "legacy" one. Is it suppose to go away? Could we just nuke it and move clang to the new one?

This is certainly the intended long-term prospect, but that would mean rewriting the majority of clang's BackendUtil, which I don't feel qualified for at the moment. It may not even be possible because not all passes have been ported to the new pass manager.

In D20629#439835, @joker.eph wrote:

Since r268966 the modern Verifier pass defaults to stripping invalid debug info in nonasserts builds. This patch ports this behavior back to the legacy Verifier pass as well.

This sentence makes me expect a difference between release and assert builds, and I don't spot it in this patch.

The difference is this assert:

assert(!V.hasBrokenDebugInfo() && "Module contains invalid debug info");
lib/IR/Verifier.cpp
4475

Good catch, they probably shouldn't.

In D20629#439834, @joker.eph wrote:

I didn't know there was a modern and a "legacy" one. Is it suppose to go away? Could we just nuke it and move clang to the new one?

This is certainly the intended long-term prospect, but that would mean rewriting the majority of clang's BackendUtil, which I don't feel qualified for at the moment. It may not even be possible because not all passes have been ported to the new pass manager.

Oh I missed the fact that it was involving the new pass manager, makes sense.

aprantl updated this revision to Diff 58517.May 25 2016, 2:34 PM
aprantl edited edge metadata.

Made the default constructor match the explicit one.

mehdi_amini accepted this revision.May 25 2016, 2:35 PM
mehdi_amini edited edge metadata.

LGTM

This revision is now accepted and ready to land.May 25 2016, 2:35 PM
aprantl closed this revision.May 25 2016, 2:40 PM

Thanks! Committed as r270768.