Index: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1150,16 +1150,16 @@ return true; } - unsigned Offset = 0; + // Byval arguments with frame indices were already handled after argument + // lowering and before isel. + const auto *Arg = + dyn_cast(Address->stripInBoundsConstantOffsets()); + if (Arg && FuncInfo.getArgumentFrameIndex(Arg) != INT_MAX) + return true; + Optional Op; - if (const auto *Arg = dyn_cast(Address)) - // Some arguments' frame index is recorded during argument lowering. - Offset = FuncInfo.getArgumentFrameIndex(Arg); - if (Offset) - Op = MachineOperand::CreateFI(Offset); - if (!Op) - if (unsigned Reg = lookUpRegForValue(Address)) - Op = MachineOperand::CreateReg(Reg, false); + if (unsigned Reg = lookUpRegForValue(Address)) + Op = MachineOperand::CreateReg(Reg, false); // If we have a VLA that has a "use" in a metadata node that's then used // here but it has no other uses, then we have a problem. E.g., Index: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -85,7 +85,6 @@ MF = &mf; TLI = MF->getSubtarget().getTargetLowering(); RegInfo = &MF->getRegInfo(); - MachineModuleInfo &MMI = MF->getMMI(); const TargetFrameLowering *TFI = MF->getSubtarget().getFrameLowering(); unsigned StackAlign = TFI->getStackAlignment(); @@ -214,33 +213,6 @@ if (!isa(I) || !StaticAllocaMap.count(cast(&I))) InitializeRegForValue(&I); - // Collect llvm.dbg.declare information. This is done now instead of - // during the initial isel pass through the IR so that it is done - // in a predictable order. - if (const DbgDeclareInst *DI = dyn_cast(&I)) { - assert(DI->getVariable() && "Missing variable"); - assert(DI->getDebugLoc() && "Missing location"); - if (MMI.hasDebugInfo()) { - // Don't handle byval struct arguments or VLAs, for example. - // Non-byval arguments are handled here (they refer to the stack - // temporary alloca at this point). - const Value *Address = DI->getAddress(); - if (Address) { - if (const BitCastInst *BCI = dyn_cast(Address)) - Address = BCI->getOperand(0); - if (const AllocaInst *AI = dyn_cast(Address)) { - DenseMap::iterator SI = - StaticAllocaMap.find(AI); - if (SI != StaticAllocaMap.end()) { // Check for VLAs. - int FI = SI->second; - MF->setVariableDbgInfo(DI->getVariable(), DI->getExpression(), - FI, DI->getDebugLoc()); - } - } - } - } - } - // Decide the preferred extend type for a value. PreferredExtendType[&I] = getPreferredExtendForValue(&I); } @@ -510,12 +482,11 @@ /// If the argument does not have any assigned frame index then 0 is /// returned. int FunctionLoweringInfo::getArgumentFrameIndex(const Argument *A) { - DenseMap::iterator I = - ByValArgFrameIndexMap.find(A); + auto I = ByValArgFrameIndexMap.find(A); if (I != ByValArgFrameIndexMap.end()) return I->second; DEBUG(dbgs() << "Argument does not have assigned frame index!\n"); - return 0; + return INT_MAX; } unsigned FunctionLoweringInfo::getCatchPadExceptionPointerVReg( Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4676,7 +4676,8 @@ bool IsIndirect = false; Optional Op; // Some arguments' frame index is recorded during argument lowering. - if (int FI = FuncInfo.getArgumentFrameIndex(Arg)) + int FI = FuncInfo.getArgumentFrameIndex(Arg); + if (FI != INT_MAX) Op = MachineOperand::CreateFI(FI); if (!Op && N.getNode()) { @@ -4927,6 +4928,13 @@ return nullptr; } + // Byval arguments with frame indices were already handled after argument + // lowering and before isel. + const auto *Arg = + dyn_cast(Address->stripInBoundsConstantOffsets()); + if (Arg && FuncInfo.getArgumentFrameIndex(Arg) != INT_MAX) + return nullptr; + SDValue &N = NodeMap[Address]; if (!N.getNode() && isa(Address)) // Check unused arguments map. Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -38,6 +38,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineMemOperand.h" +#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachinePassRegistry.h" #include "llvm/CodeGen/MachineRegisterInfo.h" @@ -1145,6 +1146,51 @@ } } +/// Collect llvm.dbg.declare information. This is done after argument lowering +/// in case the declarations refer to arguments. +static void processDbgDeclares(FunctionLoweringInfo *FuncInfo) { + MachineFunction *MF = FuncInfo->MF; + const DataLayout &DL = MF->getDataLayout(); + for (const BasicBlock &BB : *FuncInfo->Fn) { + for (const Instruction &I : BB) { + const DbgDeclareInst *DI = dyn_cast(&I); + if (!DI) + continue; + + assert(DI->getVariable() && "Missing variable"); + assert(DI->getDebugLoc() && "Missing location"); + const Value *Address = DI->getAddress(); + if (!Address) + continue; + + // Look through casts and constant offset GEPs. These mostly come from + // inalloca. + APInt Offset(DL.getPointerSizeInBits(0), 0); + Address = Address->stripAndAccumulateInBoundsConstantOffsets(DL, Offset); + + // Check if the variable is a static alloca or a byval or inalloca + // argument passed in memory. If it is not, then we will ignore this + // intrinsic and handle this during isel like dbg.value. + int FI = INT_MAX; + if (const auto *AI = dyn_cast(Address)) { + auto SI = FuncInfo->StaticAllocaMap.find(AI); + if (SI != FuncInfo->StaticAllocaMap.end()) + FI = SI->second; + } else if (const auto *Arg = dyn_cast(Address)) + FI = FuncInfo->getArgumentFrameIndex(Arg); + + if (FI == INT_MAX) + continue; + + DIExpression *Expr = DI->getExpression(); + if (Offset.getBoolValue()) + Expr = DIExpression::prepend(Expr, DIExpression::NoDeref, + Offset.getZExtValue()); + MF->setVariableDbgInfo(DI->getVariable(), Expr, FI, DI->getDebugLoc()); + } + } +} + /// Propagate swifterror values through the machine function CFG. static void propagateSwiftErrorVRegs(FunctionLoweringInfo *FuncInfo) { auto *TLI = FuncInfo->TLI; @@ -1317,6 +1363,8 @@ } createSwiftErrorEntriesInEntryBlock(FuncInfo, FastIS, TLI, TII, SDB); + processDbgDeclares(FuncInfo); + // Iterate over all basic blocks in the function. for (const BasicBlock *LLVMBB : RPOT) { if (OptLevel != CodeGenOpt::None) { Index: llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll +++ llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll @@ -1,14 +1,18 @@ -; RUN: llc -march=x86 -O0 < %s | FileCheck %s -; Currently, dbg.declare generates a DEBUG_VALUE comment. Eventually it will -; generate DWARF and this test will need to be modified or removed. +; RUN: llc -march=x86 -O0 < %s -filetype=obj | llvm-dwarfdump - | FileCheck %s +; CHECK-LABEL: .debug_info contents: + +; CHECK-LABEL: DW_TAG_subprogram +; CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}}"foo") +; CHECK: DW_TAG_formal_parameter +; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 08 ) +; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"my_r0") %struct.Pt = type { double, double } %struct.Rect = type { %struct.Pt, %struct.Pt } define double @foo(%struct.Rect* byval %my_r0) nounwind ssp !dbg !1 { entry: -;CHECK: DEBUG_VALUE %retval = alloca double ; [#uses=2] %0 = alloca double ; [#uses=2] %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] Index: llvm/trunk/test/CodeGen/X86/2012-11-30-handlemove-dbg.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/2012-11-30-handlemove-dbg.ll +++ llvm/trunk/test/CodeGen/X86/2012-11-30-handlemove-dbg.ll @@ -1,51 +0,0 @@ -; RUN: llc < %s -mtriple=x86_64-apple-macosx -enable-misched \ -; RUN: -verify-machineinstrs | FileCheck %s -; -; Test LiveInterval update handling of DBG_VALUE. -; rdar://12777252. -; -; CHECK: %entry -; CHECK: DEBUG_VALUE: subdivp:hg -; CHECK: j - -%struct.node.0.27 = type { i16, double, [3 x double], i32, i32 } -%struct.hgstruct.2.29 = type { %struct.bnode.1.28*, [3 x double], double, [3 x double] } -%struct.bnode.1.28 = type { i16, double, [3 x double], i32, i32, [3 x double], [3 x double], [3 x double], double, %struct.bnode.1.28*, %struct.bnode.1.28* } - -declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone - -define signext i16 @subdivp(%struct.node.0.27* nocapture %p, double %dsq, double %tolsq, %struct.hgstruct.2.29* nocapture byval align 8 %hg) nounwind uwtable readonly ssp !dbg !14 { -entry: - call void @llvm.dbg.declare(metadata %struct.hgstruct.2.29* %hg, metadata !4, metadata !DIExpression()), !dbg !DILocation(scope: !14) - %type = getelementptr inbounds %struct.node.0.27, %struct.node.0.27* %p, i64 0, i32 0 - %0 = load i16, i16* %type, align 2 - %cmp = icmp eq i16 %0, 1 - br i1 %cmp, label %return, label %for.cond.preheader - -for.cond.preheader: ; preds = %entry - %arrayidx6.1 = getelementptr inbounds %struct.hgstruct.2.29, %struct.hgstruct.2.29* %hg, i64 0, i32 1, i64 1 - %cmp22 = fcmp olt double 0.000000e+00, %dsq - %conv24 = zext i1 %cmp22 to i16 - br label %return - -return: ; preds = %for.cond.preheader, %entry - %retval.0 = phi i16 [ %conv24, %for.cond.preheader ], [ 0, %entry ] - ret i16 %retval.0 -} - -declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!12} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.3 (trunk 168918) (llvm/trunk 168920)", isOptimized: true, emissionKind: FullDebug, file: !11, enums: !2, retainedTypes: !2, globals: !2) -!2 = !{} -!4 = !DILocalVariable(name: "hg", line: 725, arg: 4, scope: !14, file: !5, type: !6) -!5 = !DIFile(filename: "MultiSource/Benchmarks/Olden/bh/newbh.c", directory: "MultiSource/Benchmarks/Olden/bh") -!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "hgstruct", line: 492, file: !11, baseType: !7) -!7 = !DICompositeType(tag: DW_TAG_structure_type, line: 487, size: 512, align: 64, file: !11) -!11 = !DIFile(filename: "MultiSource/Benchmarks/Olden/bh/newbh.c", directory: "MultiSource/Benchmarks/Olden/bh") -!12 = !{i32 1, !"Debug Info Version", i32 3} -!14 = distinct !DISubprogram(name: "subdivp", isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 1, file: !11, scope: !5, type: !15) -!15 = !DISubroutineType(types: !16) -!16 = !{null} Index: llvm/trunk/test/CodeGen/X86/dbg-baseptr.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-baseptr.ll +++ llvm/trunk/test/CodeGen/X86/dbg-baseptr.ll @@ -1,4 +1,5 @@ ; RUN: llc -o - %s | FileCheck %s +; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF ; This test checks that parameters on the stack pointer are correctly ; referenced by debug info. target triple = "x86_64--" @@ -7,24 +8,54 @@ @ptr = external global i32* %struct.s = type { i32, i32, i32, i32, i32 } +; Simple case: no FP, use offset from RSP. + ; CHECK-LABEL: f0: -; CHECK: DEBUG_VALUE: f:input <- [%RSP+8] +; CHECK-NOT: pushq +; CHECK: movl $42, %eax +; CHECK: retq define i32 @f0(%struct.s* byval align 8 %input) !dbg !8 { call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !4, metadata !17), !dbg !18 - ret i32 42 + ret i32 42, !dbg !18 } +; DWARF-LABEL: .debug_info contents: + +; DWARF-LABEL: DW_TAG_subprogram +; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 57 ) +; 0x57 -> RSP +; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f0") +; DWARF: DW_TAG_formal_parameter +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 08 ) +; DW_OP_fbreg (0x91) 0x08 +; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input") + + +; Dynamic alloca forces the use of RBP as the base pointer + ; CHECK-LABEL: f1: -; CHECK: DEBUG_VALUE: f:input <- [%RBP+16] +; CHECK: pushq %rbp +; CHECK: movl $42, %eax +; CHECK: popq %rbp +; CHECK: retq define i32 @f1(%struct.s* byval align 8 %input) !dbg !19 { %val = load i64, i64* @glob ; this alloca should force FP usage. %stackspace = alloca i32, i64 %val, align 1 store i32* %stackspace, i32** @ptr call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !20, metadata !17), !dbg !21 - ret i32 42 + ret i32 42, !dbg !21 } +; DWARF-LABEL: DW_TAG_subprogram +; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 ) +; 0x56 -> RBP +; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f1") +; DWARF: DW_TAG_formal_parameter +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 10 ) +; DW_OP_fbreg (0x91) 0x10 +; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input") + ; CHECK-LABEL: f2: ; Just check that we are indeed aligning the stack and setting up a base pointer ; in RBX. @@ -34,17 +65,24 @@ ; CHECK: andq $-64, %rsp ; CHECK: subq $64, %rsp ; CHECK: movq %rsp, %rbx -; The parameter should still be referenced through RBP though. -; CHECK-NOT: DEBUG_VALUE: f:input <- [%RBX -; CHECK: DEBUG_VALUE: f:input <- [%RBP+16] define i32 @f2(%struct.s* byval align 8 %input) !dbg !22 { %val = load i64, i64* @glob %stackspace = alloca i32, i64 %val, align 64 store i32* %stackspace, i32** @ptr call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !23, metadata !17), !dbg !24 - ret i32 42 + ret i32 42, !dbg !24 } +; "input" should still be referred to through RBP. +; DWARF-LABEL: DW_TAG_subprogram +; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 ) +; 0x56 -> RBP +; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f2") +; DWARF: DW_TAG_formal_parameter +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 10 ) +; DW_OP_fbreg (0x91) 0x10 +; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input") + declare void @llvm.dbg.declare(metadata, metadata, metadata) !llvm.dbg.cu = !{!2} @@ -52,7 +90,7 @@ !0 = !{i32 2, !"Dwarf Version", i32 4} !1 = !{i32 2, !"Debug Info Version", i32 3} -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3) +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug) !3 = !DIFile(filename: "dbg-baseptr.ll", directory: "/") !4 = !DILocalVariable(name: "input", arg: 1, scope: !8, file: !3, line: 5, type: !9) !5 = !{} @@ -60,7 +98,7 @@ !6 = !DISubroutineType(types: !7) !7 = !{!10, !9} -!8 = distinct !DISubprogram(name: "f", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5) +!8 = distinct !DISubprogram(name: "f0", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, unit: !2, variables: !5) !9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", elements: !11) !10 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) @@ -74,9 +112,9 @@ !17 = !DIExpression() !18 = !DILocation(line: 5, scope: !8) -!19 = distinct !DISubprogram(name: "f", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5) +!19 = distinct !DISubprogram(name: "f1", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5) !20 = !DILocalVariable(name: "input", arg: 1, scope: !19, file: !3, line: 5, type: !9) !21 = !DILocation(line: 5, scope: !19) -!22 = distinct !DISubprogram(name: "f", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5) +!22 = distinct !DISubprogram(name: "f2", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5) !23 = !DILocalVariable(name: "input", arg: 1, scope: !22, file: !3, line: 5, type: !9) !24 = !DILocation(line: 5, scope: !22) Index: llvm/trunk/test/DebugInfo/X86/dbg-declare-inalloca.ll =================================================================== --- llvm/trunk/test/DebugInfo/X86/dbg-declare-inalloca.ll +++ llvm/trunk/test/DebugInfo/X86/dbg-declare-inalloca.ll @@ -0,0 +1,158 @@ +; RUN: llc -O0 < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DEBUG +; RUN: llc < %s | FileCheck %s + +; IR generated by the following source: +; struct NonTrivial { +; NonTrivial();// : x(42) {} +; ~NonTrivial();// {} +; int x; +; }; +; extern "C" void g(int);// {} +; extern "C" void h(int);// {} +; extern "C" void f(NonTrivial a, int b, int unused, int c) { +; if (b) { +; g(c); +; } else { +; h(a.x); +; } +; (void)unused; +; } +; //int main() { +; // NonTrivial x; +; // f(x, 1, 2, 3); +; //} +; +; Remove C++ comments to have a complete, debuggable program. + +; We don't need (or want) DBG_VALUE instructions to describe the location of +; inalloca arguments. We want frame indices in the side table, especially at +; -O0, because they are reliable across the entire function and don't require +; any propagation or analysis. + +; CHECK: _f: # @f +; CHECK: Lfunc_begin0: +; CHECK-NOT: DEBUG_VALUE +; CHECK: [[start:Ltmp[0-9]+]]: +; CHECK-NOT: DEBUG_VALUE +; CHECK: cmpl +; CHECK: calll _g +; CHECK: calll _h +; CHECK: jmp "??1NonTrivial@@QAE@XZ" +; CHECK: [[end:Ltmp[0-9]+]]: +; CHECK: Lfunc_end0: + +; FIXME: Optimized debug info should preserve this. +; DEBUG: .short 4414 # Record kind: S_LOCAL +; DEBUG: .asciz "a" +; DEBUG: .cv_def_range [[start]] [[end]] + +; CHECK: .short 4414 # Record kind: S_LOCAL +; CHECK: .asciz "b" +; CHECK: .cv_def_range [[start]] [[end]] + +; CHECK: .short 4414 # Record kind: S_LOCAL +; CHECK: .asciz "c" +; CHECK: .cv_def_range [[start]] [[end]] + + + +; ModuleID = 't.cpp' +source_filename = "t.cpp" +target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" +target triple = "i386-pc-windows-msvc19.10.24728" + +%struct.NonTrivial = type { i32 } + +; Function Attrs: nounwind +define void @f(<{ %struct.NonTrivial, i32, i32, i32 }>* inalloca) local_unnamed_addr #0 !dbg !7 { +entry: + %a = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 0 + %b = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 1 + tail call void @llvm.dbg.declare(metadata i32* %c, metadata !20, metadata !24), !dbg !25 + tail call void @llvm.dbg.declare(metadata i32* %b, metadata !22, metadata !24), !dbg !26 + tail call void @llvm.dbg.declare(metadata %struct.NonTrivial* %a, metadata !23, metadata !24), !dbg !27 + %1 = load i32, i32* %b, align 4, !dbg !28, !tbaa !30 + %tobool = icmp eq i32 %1, 0, !dbg !28 + br i1 %tobool, label %if.else, label %if.then, !dbg !34 + +if.then: ; preds = %entry + %c = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 3 + %2 = load i32, i32* %c, align 4, !dbg !35, !tbaa !30 + tail call void @g(i32 %2) #4, !dbg !37 + br label %if.end, !dbg !38 + +if.else: ; preds = %entry + %x = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 0, i32 0, !dbg !39 + %3 = load i32, i32* %x, align 4, !dbg !39, !tbaa !41 + tail call void @h(i32 %3) #4, !dbg !43 + br label %if.end + +if.end: ; preds = %if.else, %if.then + tail call x86_thiscallcc void @"\01??1NonTrivial@@QAE@XZ"(%struct.NonTrivial* nonnull %a) #4, !dbg !44 + ret void, !dbg !44 +} + +; Function Attrs: nounwind readnone speculatable +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +declare void @g(i32) local_unnamed_addr + +declare void @h(i32) local_unnamed_addr + +; Function Attrs: nounwind +declare x86_thiscallcc void @"\01??1NonTrivial@@QAE@XZ"(%struct.NonTrivial*) unnamed_addr #3 + +attributes #0 = { nounwind } +attributes #1 = { nounwind readnone speculatable } +attributes #3 = { nounwind } +attributes #4 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) +!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "e41e3fda2a91b52e121ed6c29a209eae") +!2 = !{} +!3 = !{i32 1, !"NumRegisterParameters", i32 0} +!4 = !{i32 2, !"CodeView", i32 1} +!5 = !{i32 2, !"Debug Info Version", i32 3} +!6 = !{!"clang version 5.0.0 "} +!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !19) +!8 = !DISubroutineType(types: !9) +!9 = !{null, !10, !13, !13, !13} +!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "NonTrivial", file: !1, line: 1, size: 32, elements: !11, identifier: ".?AUNonTrivial@@") +!11 = !{!12, !14, !18} +!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !10, file: !1, line: 4, baseType: !13, size: 32) +!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!14 = !DISubprogram(name: "NonTrivial", scope: !10, file: !1, line: 2, type: !15, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true) +!15 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !16) +!16 = !{null, !17} +!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer) +!18 = !DISubprogram(name: "~NonTrivial", scope: !10, file: !1, line: 3, type: !15, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true) +!19 = !{!20, !21, !22, !23} +!20 = !DILocalVariable(name: "c", arg: 4, scope: !7, file: !1, line: 8, type: !13) +!21 = !DILocalVariable(name: "unused", arg: 3, scope: !7, file: !1, line: 8, type: !13) +!22 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 8, type: !13) +!23 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 8, type: !10) +!24 = !DIExpression() +!25 = !DILocation(line: 8, column: 56, scope: !7) +!26 = !DILocation(line: 8, column: 37, scope: !7) +!27 = !DILocation(line: 8, column: 30, scope: !7) +!28 = !DILocation(line: 9, column: 7, scope: !29) +!29 = distinct !DILexicalBlock(scope: !7, file: !1, line: 9, column: 7) +!30 = !{!31, !31, i64 0} +!31 = !{!"int", !32, i64 0} +!32 = !{!"omnipotent char", !33, i64 0} +!33 = !{!"Simple C++ TBAA"} +!34 = !DILocation(line: 9, column: 7, scope: !7) +!35 = !DILocation(line: 10, column: 7, scope: !36) +!36 = distinct !DILexicalBlock(scope: !29, file: !1, line: 9, column: 10) +!37 = !DILocation(line: 10, column: 5, scope: !36) +!38 = !DILocation(line: 11, column: 3, scope: !36) +!39 = !DILocation(line: 12, column: 9, scope: !40) +!40 = distinct !DILexicalBlock(scope: !29, file: !1, line: 11, column: 10) +!41 = !{!42, !31, i64 0} +!42 = !{!"?AUNonTrivial@@", !31, i64 0} +!43 = !DILocation(line: 12, column: 5, scope: !40) +!44 = !DILocation(line: 15, column: 1, scope: !7)