diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h index 228752957df..68ffd8e091c 100644 --- a/include/llvm/IR/DIBuilder.h +++ b/include/llvm/IR/DIBuilder.h @@ -434,8 +434,9 @@ namespace llvm { /// includes return type at 0th index. /// @param Flags E.g.: LValueReference. /// These flags are used to emit dwarf attributes. - DICompositeType createSubroutineType(DIFile File, DIArray ParameterTypes, - unsigned Flags = 0); + DISubroutineType createSubroutineType(DIFile File, + DITypeArray ParameterTypes, + unsigned Flags = 0); /// createArtificialType - Create a new DIType with "artificial" flag set. DIType createArtificialType(DIType Ty); diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index d9cd7c2e374..fb70efc7125 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -127,6 +127,7 @@ public: bool isDerivedType() const; bool isCompositeType() const; + bool isSubroutineType() const; bool isBasicType() const; bool isTrivialType() const; bool isVariable() const; @@ -430,7 +431,10 @@ class DICompositeType : public DIDerivedType { public: explicit DICompositeType(const MDNode *N = nullptr) : DIDerivedType(N) {} - DIArray getElements() const { return getFieldAs(10); } + DIArray getElements() const { + assert(!isSubroutineType() && "no elements for DISubroutineType"); + return getFieldAs(10); + } template void setArrays(DITypedArray Elements, DIArray TParams = DIArray()) { assert((!TParams || DbgNode->getNumOperands() == 15) && @@ -448,6 +452,14 @@ public: bool Verify() const; }; +class DISubroutineType : public DICompositeType { +public: + explicit DISubroutineType(const MDNode *N = nullptr) : DICompositeType(N) {} + DITypedArray getTypeArray() const { + return getFieldAs>(10); + } +}; + /// DIFile - This is a wrapper for a file. class DIFile : public DIScope { friend class DIDescriptor; @@ -501,7 +513,7 @@ public: StringRef getDisplayName() const { return getStringField(4); } StringRef getLinkageName() const { return getStringField(5); } unsigned getLineNumber() const { return getUnsignedField(6); } - DICompositeType getType() const { return getFieldAs(7); } + DISubroutineType getType() const { return getFieldAs(7); } /// isLocalToUnit - Return true if this subprogram is local to the current /// compile unit, like 'static' in C. diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 89e9547bdb7..3ac4899f544 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -468,8 +468,8 @@ DIE *DwarfDebug::createScopeChildrenDIE( // If this is a variadic function, add an unspecified parameter. DISubprogram SP(Scope->getScopeNode()); - DIArray FnArgs = SP.getType().getElements(); - if (FnArgs.getElement(FnArgs.getNumElements() - 1) + DITypeArray FnArgs = SP.getType().getTypeArray(); + if (resolve(FnArgs.getElement(FnArgs.getNumElements() - 1)) .isUnspecifiedParameter()) { Children.push_back( make_unique(dwarf::DW_TAG_unspecified_parameters)); diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index e20a3fbfc32..43c6de5b0c3 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1129,9 +1129,9 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) { } /// constructSubprogramArguments - Construct function argument DIEs. -void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) { +void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) { for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { - DIDescriptor Ty = Args.getElement(i); + DIType Ty = resolve(Args.getElement(i)); if (Ty.isUnspecifiedParameter()) { assert(i == N-1 && "Unspecified parameter must be the last argument"); createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer); @@ -1161,14 +1161,14 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) { break; case dwarf::DW_TAG_subroutine_type: { // Add return type. A void return won't have a type. - DIArray Elements = CTy.getElements(); - DIType RTy(Elements.getElement(0)); + DITypeArray Elements = DISubroutineType(CTy).getTypeArray(); + DIType RTy(resolve(Elements.getElement(0))); if (RTy) addType(Buffer, RTy); bool isPrototyped = true; if (Elements.getNumElements() == 2 && - Elements.getElement(1).isUnspecifiedParameter()) + resolve(Elements.getElement(1)).isUnspecifiedParameter()) isPrototyped = false; constructSubprogramArguments(Buffer, Elements); @@ -1452,15 +1452,15 @@ void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie) { Language == dwarf::DW_LANG_ObjC)) addFlag(SPDie, dwarf::DW_AT_prototyped); - DICompositeType SPTy = SP.getType(); + DISubroutineType SPTy = SP.getType(); assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type && "the type of a subprogram should be a subroutine"); - DIArray Args = SPTy.getElements(); + DITypeArray Args = SPTy.getTypeArray(); // Add a return type. If this is a type like a C/C++ void type we don't add a // return type. - if (Args.getElement(0)) - addType(SPDie, DIType(Args.getElement(0))); + if (resolve(Args.getElement(0))) + addType(SPDie, DIType(resolve(Args.getElement(0)))); unsigned VK = SP.getVirtuality(); if (VK) { diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h index a224c173369..5580412ba7d 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -422,7 +422,7 @@ public: bool Abstract = false); /// constructSubprogramArguments - Construct function argument DIEs. - void constructSubprogramArguments(DIE &Buffer, DIArray Args); + void constructSubprogramArguments(DIE &Buffer, DITypeArray Args); /// Create a DIE with the given Tag, add the DIE to its parent, and /// call insertDIE if MD is not null. diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 5eb195e3904..16ff8a07570 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -720,9 +720,9 @@ DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name, } /// createSubroutineType - Create subroutine type. -DICompositeType DIBuilder::createSubroutineType(DIFile File, - DIArray ParameterTypes, - unsigned Flags) { +DISubroutineType DIBuilder::createSubroutineType(DIFile File, + DITypeArray ParameterTypes, + unsigned Flags) { // TAG_subroutine_type is encoded in DICompositeType format. Value *Elts[] = { GetTagConstant(VMContext, dwarf::DW_TAG_subroutine_type), @@ -741,7 +741,7 @@ DICompositeType DIBuilder::createSubroutineType(DIFile File, nullptr, nullptr // Type Identifer }; - return DICompositeType(MDNode::get(VMContext, Elts)); + return DISubroutineType(MDNode::get(VMContext, Elts)); } /// createEnumerationType - Create debugging information entry for an diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 543e8e5b0bd..b97358545a5 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -159,6 +159,10 @@ bool DIDescriptor::isTrivialType() const { return DbgNode && getTag() == dwarf::DW_TAG_unspecified_parameters; } +bool DIDescriptor::isSubroutineType() const { + return isCompositeType() && getTag() == dwarf::DW_TAG_subroutine_type; +} + /// isBasicType - Return true if the specified tag is legal for /// DIBasicType. bool DIDescriptor::isBasicType() const { @@ -1055,6 +1059,12 @@ void DebugInfoFinder::processType(DIType DT) { if (DT.isCompositeType()) { DICompositeType DCT(DT); processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap)); + if (DT.isSubroutineType()) { + DITypeArray DTA = DISubroutineType(DT).getTypeArray(); + for (unsigned i = 0, e = DTA.getNumElements(); i != e; ++i) + processType(DTA.getElement(i).resolve(TypeIdentifierMap)); + return; + } DIArray DA = DCT.getElements(); for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) { DIDescriptor D = DA.getElement(i); diff --git a/lib/Transforms/Instrumentation/DebugIR.cpp b/lib/Transforms/Instrumentation/DebugIR.cpp index 2c78c9e0bba..f416339c6ad 100644 --- a/lib/Transforms/Instrumentation/DebugIR.cpp +++ b/lib/Transforms/Instrumentation/DebugIR.cpp @@ -440,7 +440,7 @@ private: Params.push_back(getOrCreateType(T)); } - DIArray ParamArray = Builder.getOrCreateArray(Params); + DITypeArray ParamArray = Builder.getOrCreateTypeArray(Params); return Builder.createSubroutineType(DIFile(FileNode), ParamArray); } diff --git a/test/CodeGen/X86/2012-11-30-regpres-dbg.ll b/test/CodeGen/X86/2012-11-30-regpres-dbg.ll index 81438961087..678d39917f1 100644 --- a/test/CodeGen/X86/2012-11-30-regpres-dbg.ll +++ b/test/CodeGen/X86/2012-11-30-regpres-dbg.ll @@ -43,6 +43,6 @@ invoke.cont44: ; preds = %if.end !4 = metadata !{i32 786451, metadata !6, null, metadata !"btCompoundLeafCallback", i32 90, i64 512, i64 64, i32 0, i32 0, null, null, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [btCompoundLeafCallback] [line 90, size 512, align 64, offset 0] [def] [from ] !5 = metadata !{i32 786473, metadata !6} ; [ DW_TAG_file_type ] !6 = metadata !{metadata !"MultiSource/Benchmarks/Bullet/btCompoundCollisionAlgorithm.cpp", metadata !"MultiSource/Benchmarks/Bullet"} -!7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !9, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !8 = metadata !{i32 1, metadata !"Debug Info Version", i32 1} !9 = metadata !{null} diff --git a/test/Linker/type-unique-type-array-a.ll b/test/Linker/type-unique-type-array-a.ll new file mode 100644 index 00000000000..f51bb0e49a5 --- /dev/null +++ b/test/Linker/type-unique-type-array-a.ll @@ -0,0 +1,129 @@ +; REQUIRES: object-emission +; +; RUN: llvm-link %s %p/type-unique-type-array-b.ll -S -o - | %llc_dwarf -filetype=obj -O0 | llvm-dwarfdump -debug-dump=info - | FileCheck %s +; +; rdar://problem/17628609 +; +; cat -n a.cpp +; 1 struct SA { +; 2 int a; +; 3 }; +; 4 +; 5 class A { +; 6 public: +; 7 void testA(SA a) { +; 8 } +; 9 }; +; 10 +; 11 void topA(A *a, SA sa) { +; 12 a->testA(sa); +; 13 } +; +; CHECK: DW_TAG_compile_unit +; ; CHECK: DW_TAG_class_type +; CHECK-NEXT: DW_AT_name {{.*}} "A" +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_MIPS_linkage_name {{.*}} "_ZN1A5testAE2SA" +; CHECK: DW_TAG_formal_parameter +; CHECK: DW_TAG_formal_parameter +; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x{{.*}} => {0x[[STRUCT:.*]]}) +; CHECK: 0x[[STRUCT]]: DW_TAG_structure_type +; CHECK-NEXT: DW_AT_name {{.*}} "SA" + +; CHECK: DW_TAG_compile_unit +; CHECK: DW_TAG_class_type +; CHECK-NEXT: DW_AT_name {{.*}} "B" +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_MIPS_linkage_name {{.*}} "_ZN1B5testBE2SA" +; CHECK: DW_TAG_formal_parameter +; CHECK: DW_TAG_formal_parameter +; CHECK-NEXT: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[STRUCT]] + +%class.A = type { i8 } +%struct.SA = type { i32 } + +; Function Attrs: ssp uwtable +define void @_Z4topAP1A2SA(%class.A* %a, i32 %sa.coerce) #0 { +entry: + %sa = alloca %struct.SA, align 4 + %a.addr = alloca %class.A*, align 8 + %agg.tmp = alloca %struct.SA, align 4 + %coerce.dive = getelementptr %struct.SA* %sa, i32 0, i32 0 + store i32 %sa.coerce, i32* %coerce.dive + store %class.A* %a, %class.A** %a.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.A** %a.addr}, metadata !24), !dbg !25 + call void @llvm.dbg.declare(metadata !{%struct.SA* %sa}, metadata !26), !dbg !27 + %0 = load %class.A** %a.addr, align 8, !dbg !28 + %1 = bitcast %struct.SA* %agg.tmp to i8*, !dbg !28 + %2 = bitcast %struct.SA* %sa to i8*, !dbg !28 + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %2, i64 4, i32 4, i1 false), !dbg !28 + %coerce.dive1 = getelementptr %struct.SA* %agg.tmp, i32 0, i32 0, !dbg !28 + %3 = load i32* %coerce.dive1, !dbg !28 + call void @_ZN1A5testAE2SA(%class.A* %0, i32 %3), !dbg !28 + ret void, !dbg !29 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +; Function Attrs: nounwind ssp uwtable +define linkonce_odr void @_ZN1A5testAE2SA(%class.A* %this, i32 %a.coerce) #2 align 2 { +entry: + %a = alloca %struct.SA, align 4 + %this.addr = alloca %class.A*, align 8 + %coerce.dive = getelementptr %struct.SA* %a, i32 0, i32 0 + store i32 %a.coerce, i32* %coerce.dive + store %class.A* %this, %class.A** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.A** %this.addr}, metadata !30), !dbg !31 + call void @llvm.dbg.declare(metadata !{%struct.SA* %a}, metadata !32), !dbg !33 + %this1 = load %class.A** %this.addr + ret void, !dbg !34 +} + +; Function Attrs: nounwind +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #3 + +attributes #0 = { ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #3 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!21, !22} +!llvm.ident = !{!23} + +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5.0 (trunk 214102:214113M) (llvm/trunk 214102:214115M)", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !14, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/Users/manmanren/test-Nov/type_unique/rdar_di_array/a.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"a.cpp", metadata !"/Users/manmanren/test-Nov/type_unique/rdar_di_array"} +!2 = metadata !{} +!3 = metadata !{metadata !4, metadata !10} +!4 = metadata !{i32 786434, metadata !1, null, metadata !"A", i32 5, i64 8, i64 8, i32 0, i32 0, null, metadata !5, i32 0, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_class_type ] [A] [line 5, size 8, align 8, offset 0] [def] [from ] +!5 = metadata !{metadata !6} +!6 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"testA", metadata !"testA", metadata !"_ZN1A5testAE2SA", i32 7, metadata !7, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, null, i32 7} ; [ DW_TAG_subprogram ] [line 7] [testA] +!7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!8 = metadata !{null, metadata !9, metadata !"_ZTS2SA"} +!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A] +!10 = metadata !{i32 786451, metadata !1, null, metadata !"SA", i32 1, i64 32, i64 32, i32 0, i32 0, null, metadata !11, i32 0, null, null, metadata !"_ZTS2SA"} ; [ DW_TAG_structure_type ] [SA] [line 1, size 32, align 32, offset 0] [def] [from ] +!11 = metadata !{metadata !12} +!12 = metadata !{i32 786445, metadata !1, metadata !"_ZTS2SA", metadata !"a", i32 2, i64 32, i64 32, i64 0, i32 0, metadata !13} ; [ DW_TAG_member ] [a] [line 2, size 32, align 32, offset 0] [from int] +!13 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!14 = metadata !{metadata !15, metadata !20} +!15 = metadata !{i32 786478, metadata !1, metadata !16, metadata !"topA", metadata !"topA", metadata !"_Z4topAP1A2SA", i32 11, metadata !17, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.A*, i32)* @_Z4topAP1A2SA, null, null, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 11] [def] [topA] +!16 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/Users/manmanren/test-Nov/type_unique/rdar_di_array/a.cpp] +!17 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !18, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!18 = metadata !{null, metadata !19, metadata !"_ZTS2SA"} +!19 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS1A] +!20 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"testA", metadata !"testA", metadata !"_ZN1A5testAE2SA", i32 7, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.A*, i32)* @_ZN1A5testAE2SA, null, metadata !6, metadata !2, i32 7} ; [ DW_TAG_subprogram ] [line 7] [def] [testA] +!21 = metadata !{i32 2, metadata !"Dwarf Version", i32 2} +!22 = metadata !{i32 2, metadata !"Debug Info Version", i32 1} +!23 = metadata !{metadata !"clang version 3.5.0 (trunk 214102:214113M) (llvm/trunk 214102:214115M)"} +!24 = metadata !{i32 786689, metadata !15, metadata !"a", metadata !16, i32 16777227, metadata !19, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [a] [line 11] +!25 = metadata !{i32 11, i32 14, metadata !15, null} +!26 = metadata !{i32 786689, metadata !15, metadata !"sa", metadata !16, i32 33554443, metadata !"_ZTS2SA", i32 0, i32 0} ; [ DW_TAG_arg_variable ] [sa] [line 11] +!27 = metadata !{i32 11, i32 20, metadata !15, null} +!28 = metadata !{i32 12, i32 3, metadata !15, null} +!29 = metadata !{i32 13, i32 1, metadata !15, null} +!30 = metadata !{i32 786689, metadata !20, metadata !"this", null, i32 16777216, metadata !19, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 0] +!31 = metadata !{i32 0, i32 0, metadata !20, null} +!32 = metadata !{i32 786689, metadata !20, metadata !"a", metadata !16, i32 33554439, metadata !"_ZTS2SA", i32 0, i32 0} ; [ DW_TAG_arg_variable ] [a] [line 7] +!33 = metadata !{i32 7, i32 17, metadata !20, null} +!34 = metadata !{i32 8, i32 3, metadata !20, null} ; [ DW_TAG_imported_declaration ] diff --git a/test/Linker/type-unique-type-array-b.ll b/test/Linker/type-unique-type-array-b.ll new file mode 100644 index 00000000000..1f56998e7f0 --- /dev/null +++ b/test/Linker/type-unique-type-array-b.ll @@ -0,0 +1,108 @@ +; RUN: true +; This file belongs to type-unique-type-array-a.ll. +; +; rdar://problem/17628609 +; +; cat -n b.cpp +; 1 struct SA { +; 2 int a; +; 3 }; +; 4 +; 5 class B { +; 6 public: +; 7 void testB(SA sa) { +; 8 } +; 9 }; +; 10 +; 11 void topB(B* b, SA sa) { +; 12 b->testB(sa); +; 13 } + +%class.B = type { i8 } +%struct.SA = type { i32 } + +; Function Attrs: ssp uwtable +define void @_Z4topBP1B2SA(%class.B* %b, i32 %sa.coerce) #0 { +entry: + %sa = alloca %struct.SA, align 4 + %b.addr = alloca %class.B*, align 8 + %agg.tmp = alloca %struct.SA, align 4 + %coerce.dive = getelementptr %struct.SA* %sa, i32 0, i32 0 + store i32 %sa.coerce, i32* %coerce.dive + store %class.B* %b, %class.B** %b.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.B** %b.addr}, metadata !24), !dbg !25 + call void @llvm.dbg.declare(metadata !{%struct.SA* %sa}, metadata !26), !dbg !27 + %0 = load %class.B** %b.addr, align 8, !dbg !28 + %1 = bitcast %struct.SA* %agg.tmp to i8*, !dbg !28 + %2 = bitcast %struct.SA* %sa to i8*, !dbg !28 + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %2, i64 4, i32 4, i1 false), !dbg !28 + %coerce.dive1 = getelementptr %struct.SA* %agg.tmp, i32 0, i32 0, !dbg !28 + %3 = load i32* %coerce.dive1, !dbg !28 + call void @_ZN1B5testBE2SA(%class.B* %0, i32 %3), !dbg !28 + ret void, !dbg !29 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +; Function Attrs: nounwind ssp uwtable +define linkonce_odr void @_ZN1B5testBE2SA(%class.B* %this, i32 %sa.coerce) #2 align 2 { +entry: + %sa = alloca %struct.SA, align 4 + %this.addr = alloca %class.B*, align 8 + %coerce.dive = getelementptr %struct.SA* %sa, i32 0, i32 0 + store i32 %sa.coerce, i32* %coerce.dive + store %class.B* %this, %class.B** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.B** %this.addr}, metadata !30), !dbg !31 + call void @llvm.dbg.declare(metadata !{%struct.SA* %sa}, metadata !32), !dbg !33 + %this1 = load %class.B** %this.addr + ret void, !dbg !34 +} + +; Function Attrs: nounwind +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #3 + +attributes #0 = { ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #3 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!21, !22} +!llvm.ident = !{!23} + +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5.0 (trunk 214102:214113M) (llvm/trunk 214102:214115M)", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !14, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/Users/manmanren/test-Nov/type_unique/rdar_di_array/b.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"b.cpp", metadata !"/Users/manmanren/test-Nov/type_unique/rdar_di_array"} +!2 = metadata !{} +!3 = metadata !{metadata !4, metadata !10} +!4 = metadata !{i32 786434, metadata !1, null, metadata !"B", i32 5, i64 8, i64 8, i32 0, i32 0, null, metadata !5, i32 0, null, null, metadata !"_ZTS1B"} ; [ DW_TAG_class_type ] [B] [line 5, size 8, align 8, offset 0] [def] [from ] +!5 = metadata !{metadata !6} +!6 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1B", metadata !"testB", metadata !"testB", metadata !"_ZN1B5testBE2SA", i32 7, metadata !7, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, null, i32 7} ; [ DW_TAG_subprogram ] [line 7] [testB] +!7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!8 = metadata !{null, metadata !9, metadata !"_ZTS2SA"} +!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1B"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1B] +!10 = metadata !{i32 786451, metadata !1, null, metadata !"SA", i32 1, i64 32, i64 32, i32 0, i32 0, null, metadata !11, i32 0, null, null, metadata !"_ZTS2SA"} ; [ DW_TAG_structure_type ] [SA] [line 1, size 32, align 32, offset 0] [def] [from ] +!11 = metadata !{metadata !12} +!12 = metadata !{i32 786445, metadata !1, metadata !"_ZTS2SA", metadata !"a", i32 2, i64 32, i64 32, i64 0, i32 0, metadata !13} ; [ DW_TAG_member ] [a] [line 2, size 32, align 32, offset 0] [from int] +!13 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!14 = metadata !{metadata !15, metadata !20} +!15 = metadata !{i32 786478, metadata !1, metadata !16, metadata !"topB", metadata !"topB", metadata !"_Z4topBP1B2SA", i32 11, metadata !17, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.B*, i32)* @_Z4topBP1B2SA, null, null, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 11] [def] [topB] +!16 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/Users/manmanren/test-Nov/type_unique/rdar_di_array/b.cpp] +!17 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !18, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!18 = metadata !{null, metadata !19, metadata !"_ZTS2SA"} +!19 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTS1B"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS1B] +!20 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1B", metadata !"testB", metadata !"testB", metadata !"_ZN1B5testBE2SA", i32 7, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.B*, i32)* @_ZN1B5testBE2SA, null, metadata !6, metadata !2, i32 7} ; [ DW_TAG_subprogram ] [line 7] [def] [testB] +!21 = metadata !{i32 2, metadata !"Dwarf Version", i32 2} +!22 = metadata !{i32 2, metadata !"Debug Info Version", i32 1} +!23 = metadata !{metadata !"clang version 3.5.0 (trunk 214102:214113M) (llvm/trunk 214102:214115M)"} +!24 = metadata !{i32 786689, metadata !15, metadata !"b", metadata !16, i32 16777227, metadata !19, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [b] [line 11] +!25 = metadata !{i32 11, i32 14, metadata !15, null} +!26 = metadata !{i32 786689, metadata !15, metadata !"sa", metadata !16, i32 33554443, metadata !"_ZTS2SA", i32 0, i32 0} ; [ DW_TAG_arg_variable ] [sa] [line 11] +!27 = metadata !{i32 11, i32 20, metadata !15, null} +!28 = metadata !{i32 12, i32 3, metadata !15, null} +!29 = metadata !{i32 13, i32 1, metadata !15, null} +!30 = metadata !{i32 786689, metadata !20, metadata !"this", null, i32 16777216, metadata !19, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 0] +!31 = metadata !{i32 0, i32 0, metadata !20, null} +!32 = metadata !{i32 786689, metadata !20, metadata !"sa", metadata !16, i32 33554439, metadata !"_ZTS2SA", i32 0, i32 0} ; [ DW_TAG_arg_variable ] [sa] [line 7] +!33 = metadata !{i32 7, i32 17, metadata !20, null} +!34 = metadata !{i32 8, i32 3, metadata !20, null} ; [ DW_TAG_imported_declaration ] diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp index b3a1f5b1052..571008e07f7 100644 --- a/unittests/Transforms/Utils/Cloning.cpp +++ b/unittests/Transforms/Utils/Cloning.cpp @@ -232,7 +232,7 @@ protected: // Function DI DIFile File = DBuilder.createFile("filename.c", "/file/dir/"); - DIArray ParamTypes = DBuilder.getOrCreateArray(ArrayRef()); + DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray(None); DICompositeType FuncType = DBuilder.createSubroutineType(File, ParamTypes); DICompileUnit CU = DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c", "/file/dir", "CloneFunc", false, "", 0);