[PATCH] D56297: [DWARFUnit] Don't assume basic types.

Andrew Kelley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 4 12:56:41 PST 2019


andrewrk added a comment.

In D56297#1345884 <https://reviews.llvm.org/D56297#1345884>, @aprantl wrote:

> Is the problem that it is a SubroutineType, but not a function *pointer*?
>  Generally, if the Verifier accepts it we ought to not crash, so this seems to be okay, but it might be worth asking whether this is really what you want your frontend to be creating since subroutinetypes don't have a size, etc.


I'm the author of the frontend that is generating this code. Thanks for the explanation of the problem. Based on this I tried similar code with clang:

  static void another(void) {}
  
  int main() {
      void (*x)(void) = another;
      return 0;
  }

To find out how it represented the debug info:

    call void @llvm.dbg.declare(metadata void ()** %2, metadata !11, metadata !DIExpression()), !dbg !15
  !11 = !DILocalVariable(name: "x", scope: !7, file: !1, line: 4, type: !12)
  !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
  !13 = !DISubroutineType(types: !14)

So it looks like I should modify the frontend to represent this as a DerivedType with a baseType=SubroutineType. Is that right?

For what it's worth, I would consider this issue resolved if the verifier would reject the code. Although I will note that this assertion is not tripped in 7.0.0 for the same code.


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

https://reviews.llvm.org/D56297





More information about the llvm-commits mailing list