This is an archive of the discontinued LLVM Phabricator instance.

[DeadArgElim] Fixes for dbg.values using dead arg/return values
ClosedPublic

Authored by dstenb on Dec 10 2018, 7:56 AM.

Details

Summary

When eliminating a dead argument or return value in a function with
local linkage, all uses, including in dbg.value intrinsics, would be
replaced with null constants. This would mean that, for example for an
integer argument, the debug info would incorrectly express that the
value is 0. Instead, replace all uses with undef to indicate that the
argument/return value is optimized out.

Also, make sure that metadata uses of return values are rewritten even
if there are no non-metadata uses of the value.

As a bit of historical curiosity, the code that emitted null constants
was introduced in the initial check-in of the pass in 2003, before
'undef' values even existed in LLVM.

This fixes PR23260.

Diff Detail

Repository
rL LLVM

Event Timeline

dstenb created this revision.Dec 10 2018, 7:56 AM
aprantl accepted this revision.Dec 10 2018, 9:45 AM

Thanks!

This revision is now accepted and ready to land.Dec 10 2018, 9:45 AM

LGTM as well! Thanks!

Thanks for the reviews! I'm planning on submitting this shortly then.

This revision was automatically updated to reflect the committed changes.