This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] Attempt to strip debug info
ClosedPublic

Authored by aeubanks on Oct 18 2022, 3:44 PM.

Details

Summary

I often run llvm-reduce on IR that contains debug info, this prevents an
extra step of opt -passes=strip I do every time and will result in a
lot less invalid reductions around debug metadata.

Diff Detail

Event Timeline

aeubanks created this revision.Oct 18 2022, 3:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2022, 3:44 PM
aeubanks requested review of this revision.Oct 18 2022, 3:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2022, 3:44 PM
aeubanks added inline comments.Oct 18 2022, 3:44 PM
llvm/tools/llvm-reduce/deltas/StripDebugInfo.cpp
22

not sure if this is the best way to detect presence of debug info

Isn't the first step in the existing debug info reducer to try deleting all of it?

Isn't the first step in the existing debug info reducer to try deleting all of it?

the existing di-metadata pass is very specific, it only tries to remove array entries debug info metadata arrays. it doesn't do anything with !dbg attached to instructions, the corresponding DI metadata nodes, the global named !llvm.dbg.* named metadata, and dbg intrinsics

Isn't the first step in the existing debug info reducer to try deleting all of it?

the existing di-metadata pass is very specific, it only tries to remove array entries debug info metadata arrays. it doesn't do anything with !dbg attached to instructions, the corresponding DI metadata nodes, the global named !llvm.dbg.* named metadata, and dbg intrinsics

But the metadata reduction looks at individual instructions. Doesn't di-metadata + metadata cover this?

Isn't the first step in the existing debug info reducer to try deleting all of it?

the existing di-metadata pass is very specific, it only tries to remove array entries debug info metadata arrays. it doesn't do anything with !dbg attached to instructions, the corresponding DI metadata nodes, the global named !llvm.dbg.* named metadata, and dbg intrinsics

But the metadata reduction looks at individual instructions. Doesn't di-metadata + metadata cover this?

I'm not sure that di-metadata can handle all types of debug info structures (I think I've seen cases where not all debug info is removed even though the striped IR still is interesting, although I'm having a hard time remembering a specific example). But even if it did, we get lots of invalid reductions (due to various verifier constraints) that would be avoided if we just stripped everything to begin with, speeding things up a lot.

I don't really know enough about debug info to dispute this, but I don't find working around invalid reductions in the existing passes a compelling reason to special case eliminating all the debug info

dblaikie added inline comments.Oct 20 2022, 2:10 PM
llvm/tools/llvm-reduce/deltas/StripDebugInfo.cpp
25

Looks like this also strips function/global variable names and register names - any chance we don't want to strip those too? Should we call this llvm-reduce pass "StripSymbols" rather than "stripDebugInfo" to be consistent with the underlying pass and its slightly different/broader semantics?

aeubanks updated this revision to Diff 469366.Oct 20 2022, 3:01 PM

only strip debug info

dblaikie accepted this revision.Oct 20 2022, 3:11 PM

Sounds good to me :)

This revision is now accepted and ready to land.Oct 20 2022, 3:11 PM

I don't really know enough about debug info to dispute this, but I don't find working around invalid reductions in the existing passes a compelling reason to special case eliminating all the debug info

there are random constraints on debug info metadata, e.g. https://reviews.llvm.org/D135492. while it's possible to handle all of these in all the different passes, I don't think it's necessarily worth the effort if most of the time debug info doesn't matter anyway

This revision was automatically updated to reflect the committed changes.