Skip to content

[DebugInfo][InferAddressSpaces] Missing debug location update for the new addrspacecast instruction #97006

Closed
@Apochens

Description

@Apochens

InferAddressSpaces-L643

In function cloneInstructionWithNewAddressSpace, the new addrspacecast instruction NewI has no debug location and assigning the debug location of I to it is appropriate. Because it is a cast of I.

  if (AS != UninitializedAddressSpace) {
    // For the assumed address space, insert an `addrspacecast` to make that
    // explicit.
    Type *NewPtrTy = getPtrOrVecOfPtrsWithNewAS(I->getType(), AS);
->  auto *NewI = new AddrSpaceCastInst(I, NewPtrTy);
    NewI->insertAfter(I);
    return NewI;
  }

Acctually, there is a debug location update for the return value of this function (cloneInstructionWithNewAddressSpace) in function cloneValueWithNewAddressSpace. However, it happens only when the return value has no parent block, which makes the addrspacecast instruction ignored.

    Value *NewV = cloneInstructionWithNewAddressSpace(
        I, NewAddrSpace, ValueWithNewAddrSpace, PredicatedAS, PoisonUsesToFix);
    if (Instruction *NewI = dyn_cast_or_null<Instruction>(NewV)) {
      if (NewI->getParent() == nullptr) {
        NewI->insertBefore(I);
        NewI->takeName(I);
->      NewI->setDebugLoc(I->getDebugLoc());
      }
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions