This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo@O2] Prevent Instcombine from dropping debug info when removing zexts (fixes PR41475)
ClosedPublic

Authored by wolfgangp on Apr 12 2019, 3:41 PM.

Details

Summary

See PR41475 for a short description of the problem.

salvageDebugInfo() in Transforms/Utils/Local.cpp decides how an instruction's actions are affecting a value that is used in a dbg.value() call and attempts to return a DIExpr that would make it possible to reconstruct the original value from the instruction's source operand in case the instruction is removed by someone (e.g. by instcombine). Noop casts don't change the value and we can safely say that the cast's source operand can be used by the debug user, thus we simply return the DIExpr found there.

This patch extends this to zext instructions, which are not a noop cast, but arguably don't change the value. Thus the source value of a zext can replace the result value in debug users and survive a removal of the zext instruction.

Diff Detail

Repository
rL LLVM

Event Timeline

wolfgangp created this revision.Apr 12 2019, 3:41 PM
aprantl accepted this revision.Apr 12 2019, 3:45 PM
This revision is now accepted and ready to land.Apr 12 2019, 3:45 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2019, 10:40 AM