[PATCH] D70597: [PHIEliminate] skip dbg instruction when LowerPHINode

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 24 15:08:59 PST 2019


bjope added inline comments.


================
Comment at: llvm/test/CodeGen/X86/phi-node-elimination-dbg-invariant.mir:45
+    %1:gr32 = PHI %0:gr32, %bb.0, %2:gr32, %bb.1
+    DBG_VALUE
+    EH_LABEL 0
----------------
bjope wrote:
> What if this DBG_VALUE is using %1. I think that could be an interesting test case to add as well.
> If we PHI is lowered into a copy that comes after the EH_LABEL, then we probably need to move the DBG_VALUE to make sure it is after the label, to make this correct.
> 
> What happens to the DBG_VALUE with the current solution? (it is not shown in the CHECK:s, is it still present before the EH_LABEL?)
Maybe it is better to canonicalize any labels / debug instructions that is present directly after the PHI nodes, by hoisting the labels above the debug instructions, before we lower the PHI nodes.
Assuming that it would be OK to hoist the labels past debug instructions.

For example, if we have:

```
PHI (1)
PHI (2)
DBG_VALUE (1)
EH_LABEL (1)
DBG_VALUE (2)
GC_LABEL (1)
DBG_LABEL (1)
```
it would be canonicalized into
```
PHI (1)
PHI (2)
EH_LABEL (1)
GC_LABEL (1)
DBG_VALUE (1)
DBG_VALUE (2)
DBG_LABEL (1)
```
And then we can insert the COPY instructions between the labels and debug instruction, such as:
```
EH_LABEL (1)
GC_LABEL (1)
COPY (1)
COPY (2)
DBG_VALUE (1)
DBG_VALUE (2)
DBG_LABEL (1)
```

That could solve the potential problem with having DBG_VALUE:s using the value produced by the PHI:s, without introducing use-before-def, as well as dealing with a potential problem with reordering debug instructions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70597/new/

https://reviews.llvm.org/D70597





More information about the llvm-commits mailing list