This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][instr-ref] Accept register-reads after isel in any block
ClosedPublic

Authored by jmorse on Mar 4 2022, 8:25 AM.

Details

Summary

When lowering LLVM-IR to instruction referencing stuff, I'd assumed that if a value was defined by a COPY, we could follow the register definitions back to where the value was defined, and build an instruction reference to that instruction. The only scenario I envisioned where that might not happen is function arguments: they're not defined by any instruction. Thus, I baked in some assertions that we could always find the defining instruction for a value, unless it was an argument.

Since the I've discovered:

  • Exception handling landing pads,
  • Constant physical registers,
  • Various IR intrinsics,

all can read arbitrary registers that are never defined. It seems the original assertions were just a bad idea: thus, this patch deletes them.

In all circumstances it's fine to issue a DBG_PHI at a position, that reads the desired register, and this will be handled just fine by the rest of the instruction referencing code. The assertions were only put there to encode my assumptions.

Repro from https://github.com/llvm/llvm-project/issues/54190

Diff Detail

Event Timeline

jmorse created this revision.Mar 4 2022, 8:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 8:25 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
jmorse requested review of this revision.Mar 4 2022, 8:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 8:25 AM
Orlando accepted this revision.Mar 4 2022, 8:30 AM

LGTM

This revision is now accepted and ready to land.Mar 4 2022, 8:30 AM
This revision was landed with ongoing or failed builds.Mar 4 2022, 9:01 AM
This revision was automatically updated to reflect the committed changes.