From cefca100398ac2f0a1598f3ba83fcdac2e32b0b6 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 28 Mar 2015 02:43:53 +0000 Subject: [PATCH] Verifier: Allow subroutine types to have no type array Loosen one check from r233446: as long as `DIBuilder` requires a non-null type for every subprogram, we should allow a null type array. Also add tests for the rest of `MDSubroutineType`, which were somehow missing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233468 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Verifier.cpp | 11 +++++------ test/Assembler/mdsubroutinetype.ll | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 test/Assembler/mdsubroutinetype.ll diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index b2a86e27b75..af79984f59a 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -758,12 +758,11 @@ void Verifier::visitMDCompositeType(const MDCompositeType &N) { void Verifier::visitMDSubroutineType(const MDSubroutineType &N) { Assert(N.getTag() == dwarf::DW_TAG_subroutine_type, "invalid tag", &N); - Assert(N.getRawElements() && isa(N.getRawElements()), - "invalid composite elements", &N, N.getRawElements()); - - for (Metadata *Ty : N.getTypeArray()->operands()) { - Assert(isTypeRef(Ty), "invalid subroutine type ref", &N, N.getTypeArray(), - Ty); + if (auto *Types = N.getRawTypeArray()) { + Assert(isa(Types), "invalid composite elements", &N, Types); + for (Metadata *Ty : N.getTypeArray()->operands()) { + Assert(isTypeRef(Ty), "invalid subroutine type ref", &N, Types, Ty); + } } } diff --git a/test/Assembler/mdsubroutinetype.ll b/test/Assembler/mdsubroutinetype.ll new file mode 100644 index 00000000000..936cbf4ec7b --- /dev/null +++ b/test/Assembler/mdsubroutinetype.ll @@ -0,0 +1,23 @@ +; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s +; RUN: verify-uselistorder %s + +; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} + +!0 = !MDBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!1 = !{null} +!2 = !{null, !0} +!3 = !{!0, !0, !0} + + +; CHECK: !4 = !MDSubroutineType(types: !1) +; CHECK: !5 = !MDSubroutineType(types: !2) +; CHECK: !6 = !MDSubroutineType(types: !3) +; CHECK: !7 = !MDSubroutineType(flags: DIFlagLValueReference, types: !3) +!4 = !MDSubroutineType(types: !1) +!5 = !MDSubroutineType(types: !2) +!6 = !MDSubroutineType(types: !3) +!7 = !MDSubroutineType(flags: DIFlagLValueReference, types: !3) + +; CHECK: !8 = !MDSubroutineType(types: null) +!8 = !MDSubroutineType(types: null)