This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVM] drop `llvm.intr.dbg.value` when promoting in `SROA` or `mem2reg`
ClosedPublic

Authored by zero9178 on Jul 4 2023, 8:08 AM.

Details

Summary

This has previously been done for llvm.intr.dbg.declare, which is a common occurrence when the debug info points to the variable through the pointer, but may also occur when the alloca itself is a local variable in debug info.

Not doing so prevents SROA and mem2reg from promoting e.g. an alloca. We simply drop the value completetly, since there is no meaninful debug info that can be constructed instead as the pointer value is removed.

Diff Detail

Event Timeline

zero9178 created this revision.Jul 4 2023, 8:08 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
zero9178 requested review of this revision.Jul 4 2023, 8:08 AM
gysit accepted this revision.Jul 4 2023, 8:14 AM

LGTM!

This revision is now accepted and ready to land.Jul 4 2023, 8:14 AM
This revision was landed with ongoing or failed builds.Jul 4 2023, 8:16 AM
This revision was automatically updated to reflect the committed changes.
jmorse added a subscriber: jmorse.Jul 4 2023, 8:42 AM

Drive-by comment as my email filters picked this up -- please note that deleting dbg.value intrinsics usually causes important information to be lost. Each dbg.value intrinsic is effectively a variable assignment (sort of). Deleting one is like a variable assignment ceasing to occur in the source program, earlier variable values might appear later in the function than they should do. LLVM replaces dbg.value operands with undef whenever values go away, indicating a variable assignment of a value that has been optimised out.

I've zero familiarity with MLIR, so this might be completely irrelevant, but I figured I'd point this out.