[PATCH] D26212: IRMover: Avoid accidentally mapping types from the destination module (PR30799)

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 15:28:43 PDT 2016


hans added a comment.

In https://reviews.llvm.org/D26212#585290, @mehdi_amini wrote:

> >> getIdentifiedStructTypes() isn't even documented in the Module header unfortunately. It is not clear off-hand it the issue should be handled in the IRMover or in `getIdentifiedStructTypes` itself.
> > 
> > I'm not sure how we'd change getIdentifiedStructTypes() though. Once we've ODR'd the metadata, the module now refers to a value with this type, and it makes sense that getIdentifiedStructTypes() finds it.
>
> To begin with: in what situation walking the metadata graph can find a named typed that can't be found by walking only the IR?


I think my test case shows that: when the DI node looks like this:

  !11 = !DITemplateValueParameter(type: !12, value: %Tricky.1* bitcast (i8* @templateValueParam to %Tricky.1*))

The non-MD IR doesn't refer to %Tricky.1, but this node has a constant expression that does.

TypeFinder::incorporateMDNode does:

  if (auto *C = dyn_cast<ConstantAsMetadata>(Op)) {
    incorporateValue(C->getValue());

which hits:

  /// incorporateValue - This method is used to walk operand lists finding types
  /// hiding in constant expressions and other operands that won't be walked in
  /// other ways.  GlobalValues, basic blocks, instructions, and inst operands are
  /// all explicitly enumerated.
  void TypeFinder::incorporateValue(const Value *V) {


https://reviews.llvm.org/D26212





More information about the llvm-commits mailing list