This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][InferAddressSpaces] Propagate DebugLoc when cloning an instruction in InferAddressSpaces
ClosedPublic

Authored by jmmartinez on Sep 22 2022, 4:54 AM.

Diff Detail

Event Timeline

jmmartinez created this revision.Sep 22 2022, 4:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2022, 4:54 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
jmmartinez requested review of this revision.Sep 22 2022, 4:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2022, 4:54 AM
probinson added a subscriber: probinson.

Needs a test. Could be an update to an existing test, if there's an appropriate one that's easy to modify.

Please specify at least one reviewer. There are some hints for choosing one here: https://llvm.org/docs/Contributing.html#format-patches

Please add a test.

& also, I assume/but would like confirmed that this new instruction will for sure be going into the same BB as the old instruciton?(so there are no hoisting/profile problem concerns)

& also, I assume/but would like confirmed that this new instruction will for sure be going into the same BB as the old instruciton?(so there are no hoisting/profile problem concerns)

Good question!

Yes it's going exactly in the same place. The code surrounding the setDebugLoc is the following:

if (Instruction *I = dyn_cast<Instruction>(V)) {
  Value *NewV = cloneInstructionWithNewAddressSpace(
      I, NewAddrSpace, ValueWithNewAddrSpace, PredicatedAS, UndefUsesToFix);
  if (Instruction *NewI = dyn_cast_or_null<Instruction>(NewV)) {
    if (NewI->getParent() == nullptr) {
      NewI->insertBefore(I);
      NewI->takeName(I);
      NewI->setDebugLoc(I->getDebugLoc());
    }
  }
}
  • Add test for InferAddressSpaces DILocation propagation
  • Fix NVPTX test: the debug_loc is maintained for instructions issued from the gep inst
arsenm added a subscriber: arsenm.Sep 27 2022, 7:29 AM
arsenm added inline comments.
llvm/test/Transforms/InferAddressSpaces/AMDGPU/debug-info.ll
43

Can you add another test for cases handled by rewriteIntrinsicWithAddressSpace? In particular ptrmask and is_shared could be interesting

  • Added test cases and a fix:
    • Test: with ptrmsk
    • Test: with is.shared and assume
    • Fix: Use the debug_loc from the insert-point when creating a new addrspacecast
arsenm accepted this revision.Sep 28 2022, 8:08 AM

LGTM

This revision is now accepted and ready to land.Sep 28 2022, 8:08 AM