[llvm] [SROA] Use tree-structure merge to remove alloca (PR #152793)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 15:41:47 PDT 2025


Chengjunp wrote:

I have a question in the function `bool SROA::deleteDeadInstructions`. I see that 
1. We only remove the debug info attached to Allocas
2. We only remove DbgDeclare, but not DbgValues

```cpp
    // If the instruction is an alloca, find the possible dbg.declare connected
    // to it, and remove it too. We must do this before calling RAUW or we will
    // not be able to find it.
    if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
      DeletedAllocas.insert(AI);
      for (DbgVariableRecord *OldDII : findDVRDeclares(AI))
        OldDII->eraseFromParent();
    }
```
As a result, the tests run with `-passes=debugify,sroa` will keep many `#dbg_value`s for the deleted `undef` values.
Is this expected? Or we should make some changes here.

https://github.com/llvm/llvm-project/pull/152793


More information about the llvm-commits mailing list