[PATCH] D45975: [DebugInfo] Invalidate debug info in ReassociatePass::RewriteExprTree

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 23 12:09:22 PDT 2018


bjope added inline comments.


================
Comment at: lib/Transforms/Scalar/Reassociate.cpp:791
+      for (auto *DII : DbgUsers)
+        DII->setOperand(0, MetadataAsValue::get(DII->getContext(), nullptr));
+
----------------
aprantl wrote:
> bjope wrote:
> > aprantl wrote:
> > > I think it would be better use use and undef instead of a nullptr here. Otherwise the intrinsic may will be deleted and doesn't serve as an end point of the live range opened by the previous intrinsic describing the same variable any more.
> > Not sure if I understand what you mean by "use use and undef instead of nullptr".
> > 
> > I tried to find some place in the code where a dbg.value is invalidated (and not only erased) like this, to find out how to do it. But could not find any pattern to reuse. Do you know if we do this kind of invalidation somewhere already (maybe there is an existing helper similar to salvageDebugInfo that can be used)?
> > 
> > 
> Sorry this was supposed to say: use an `%undef` instead of a nullptr, i.e.:
> 
> `DII->setOperand(UndefValue::get(...), MetadataAsValue::get(DII->getContext(), nullptr));`
I thought the first was op-number, but maybe it is possible to do something like `DII->setOperand(0, UndefValue::get(...));` ? But I think the operand also has to be metadata.

The resulting IR from my original proposal is basically
  `call void @llvm.dbg.value(metadata !2, ...`
which is what Reassociate produce in other situations where it does rewrites without reusing existing instructions (when the original def is erased). Not sure exactly how the metadata is cleared in such situations (if it is for example is done as part of `replaceAllUsesWith` or `eraseFromParent`). I could not find anything explicit in Reassociate.cpp.


Repository:
  rL LLVM

https://reviews.llvm.org/D45975





More information about the llvm-commits mailing list