From 800e3ba1d7377b9a5d415211dca5bb52ab07f205 Mon Sep 17 00:00:00 2001 From: Amy Huang Date: Wed, 31 Jul 2019 23:59:31 +0000 Subject: [PATCH] Revert "[MS] Emit S_HEAPALLOCSITE debug info in Selection DAG" and and partial fix. Causes windows buildbot errors. This reverts commit 6e65c34523963094acd0d6c94a5f5c64b32fe6aa and 53da7ca94343166ac68aef81db0398932fc258bb. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367496 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 28 +-- .../SelectionDAG/ScheduleDAGSDNodes.cpp | 10 - lib/Target/X86/X86ISelLowering.cpp | 11 -- test/CodeGen/X86/label-heapallocsite.ll | 185 +++++++----------- 4 files changed, 81 insertions(+), 153 deletions(-) diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 426f3efcd5b..cbeebbc51da 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -269,13 +269,7 @@ class SelectionDAG { using CallSiteInfo = MachineFunction::CallSiteInfo; using CallSiteInfoImpl = MachineFunction::CallSiteInfoImpl; - - struct CallSiteDbgInfo { - CallSiteInfo CSInfo; - MDNode *HeapAllocSite = nullptr; - }; - - DenseMap SDCallSiteDbgInfo; + DenseMap SDCallSiteInfo; uint16_t NextPersistentId = 0; @@ -1669,28 +1663,16 @@ public: } void addCallSiteInfo(const SDNode *CallNode, CallSiteInfoImpl &&CallInfo) { - SDCallSiteDbgInfo[CallNode].CSInfo = std::move(CallInfo); + SDCallSiteInfo[CallNode] = std::move(CallInfo); } CallSiteInfo getSDCallSiteInfo(const SDNode *CallNode) { - auto I = SDCallSiteDbgInfo.find(CallNode); - if (I != SDCallSiteDbgInfo.end()) - return std::move(I->second).CSInfo; + auto I = SDCallSiteInfo.find(CallNode); + if (I != SDCallSiteInfo.end()) + return std::move(I->second); return CallSiteInfo(); } - void addHeapAllocSite(const SDNode *Node, MDNode *MD) { - SDCallSiteDbgInfo[Node].HeapAllocSite = MD; - } - - /// Return the HeapAllocSite type associated with the SDNode, if it exists. - MDNode *getHeapAllocSite(const SDNode* Node) { - auto It = SDCallSiteDbgInfo.find(Node); - if (It == SDCallSiteDbgInfo.end()) - return nullptr; - return It->second.HeapAllocSite; - } - private: void InsertNode(SDNode *N); bool RemoveNodeFromCSEMaps(SDNode *N); diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp index e09f2e760f5..568c6191e51 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -909,12 +909,6 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) { // Remember the source order of the inserted instruction. if (HasDbg) ProcessSourceNode(N, DAG, Emitter, VRBaseMap, Orders, Seen, NewInsn); - - if (MDNode *MD = DAG->getHeapAllocSite(N)) { - if (NewInsn && NewInsn->isCall()) - MF.addCodeViewHeapAllocSite(NewInsn, MD); - } - GluedNodes.pop_back(); } auto NewInsn = @@ -923,10 +917,6 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) { if (HasDbg) ProcessSourceNode(SU->getNode(), DAG, Emitter, VRBaseMap, Orders, Seen, NewInsn); - if (MDNode *MD = DAG->getHeapAllocSite(SU->getNode())) { - if (NewInsn && NewInsn->isCall()) - MF.addCodeViewHeapAllocSite(NewInsn, MD); - } } // Insert all the dbg_values which have not already been inserted in source diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 4331cb9c231..294ec69e867 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4058,11 +4058,6 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, MF.getFrameInfo().setHasTailCall(); SDValue Ret = DAG.getNode(X86ISD::TC_RETURN, dl, NodeTys, Ops); DAG.addCallSiteInfo(Ret.getNode(), std::move(CSInfo)); - if (CLI.CS && CLI.CS->getMetadata("heapallocsite")) { - DAG.addHeapAllocSite(Chain.getNode(), - CLI.CS->getMetadata("heapallocsite")); - } - return Ret; } @@ -4074,12 +4069,6 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, InFlag = Chain.getValue(1); DAG.addCallSiteInfo(Chain.getNode(), std::move(CSInfo)); - // Save heapallocsite metadata. - if (CLI.CS && CLI.CS->getMetadata("heapallocsite")) { - DAG.addHeapAllocSite(Chain.getNode(), - CLI.CS->getMetadata("heapallocsite")); - } - // Create the CALLSEQ_END node. unsigned NumBytesForCalleeToPop; if (X86::isCalleePop(CallConv, Is64Bit, isVarArg, diff --git a/test/CodeGen/X86/label-heapallocsite.ll b/test/CodeGen/X86/label-heapallocsite.ll index 31813d416b2..f693695580e 100644 --- a/test/CodeGen/X86/label-heapallocsite.ll +++ b/test/CodeGen/X86/label-heapallocsite.ll @@ -1,162 +1,129 @@ -; RUN: llc < %s | FileCheck --check-prefixes=DAG,CHECK %s -; RUN: llc -O0 < %s | FileCheck --check-prefixes=FAST,CHECK %s +; RUN: llc -O0 < %s | FileCheck %s +; FIXME: Add test for llc with optimizations once it is implemented. ; Source to regenerate: -; $ clang -cc1 -triple x86_64-windows-msvc t.cpp -debug-info-kind=limited \ -; -gcodeview -O2 -fms-extensions -emit-llvm -o t.ll +; $ clang --target=x86_64-windows-msvc -S heapallocsite.cpp -g -gcodeview -o t.ll \ +; -emit-llvm -O0 -Xclang -disable-llvm-passes -fms-extensions ; -; extern "C" struct Foo { +; struct Foo { ; __declspec(allocator) virtual void *alloc(); ; }; +; ; extern "C" __declspec(allocator) Foo *alloc_foo(); -; extern "C" void use_result(void *); ; -; extern "C" int call_tail() { -; use_result(alloc_foo()); -; } -; extern "C" int call_virtual(Foo *p) { -; use_result(p->alloc()); -; return 0; +; extern "C" void use_alloc(void*); +; extern "C" void call_virtual(Foo *p) { +; use_alloc(p->alloc()); ; } -; extern "C" int call_multiple() { -; use_result(alloc_foo()); -; use_result(alloc_foo()); -; return 0; +; +; extern "C" void call_multiple() { +; use_alloc(alloc_foo()); +; use_alloc(alloc_foo()); ; } -; ModuleID = 'label.cpp' -source_filename = "label.cpp" target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-windows-msvc" %struct.Foo = type { i32 (...)** } -; Function Attrs: nounwind -define dso_local void @call_tail() local_unnamed_addr #0 !dbg !7 { +; Function Attrs: noinline optnone uwtable +define dso_local void @call_virtual(%struct.Foo* %p) #0 !dbg !8 { entry: - %call = tail call %struct.Foo* @alloc_foo() #3, !dbg !11, !heapallocsite !12 - %0 = bitcast %struct.Foo* %call to i8*, !dbg !11 - tail call void @use_result(i8* %0) #3, !dbg !11 - ret void, !dbg !13 + %p.addr = alloca %struct.Foo*, align 8 + store %struct.Foo* %p, %struct.Foo** %p.addr, align 8 + call void @llvm.dbg.declare(metadata %struct.Foo** %p.addr, metadata !13, metadata !DIExpression()), !dbg !14 + %0 = load %struct.Foo*, %struct.Foo** %p.addr, align 8, !dbg !15 + %1 = bitcast %struct.Foo* %0 to i8* (%struct.Foo*)***, !dbg !15 + %vtable = load i8* (%struct.Foo*)**, i8* (%struct.Foo*)*** %1, align 8, !dbg !15 + %vfn = getelementptr inbounds i8* (%struct.Foo*)*, i8* (%struct.Foo*)** %vtable, i64 0, !dbg !15 + %2 = load i8* (%struct.Foo*)*, i8* (%struct.Foo*)** %vfn, align 8, !dbg !15 + %call = call i8* %2(%struct.Foo* %0), !dbg !15, !heapallocsite !2 + call void @use_alloc(i8* %call), !dbg !15 + ret void, !dbg !16 } -declare dso_local void @use_result(i8*) local_unnamed_addr #1 - -declare dso_local %struct.Foo* @alloc_foo() local_unnamed_addr #1 +; Function Attrs: nounwind readnone speculatable +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 -; Function Attrs: nounwind -define dso_local i32 @call_virtual(%struct.Foo* %p) local_unnamed_addr #0 !dbg !14 { -entry: - call void @llvm.dbg.value(metadata %struct.Foo* %p, metadata !20, metadata !DIExpression()), !dbg !21 - %0 = bitcast %struct.Foo* %p to i8* (%struct.Foo*)***, !dbg !22 - %vtable = load i8* (%struct.Foo*)**, i8* (%struct.Foo*)*** %0, align 8, !dbg !22, !tbaa !23 - %1 = load i8* (%struct.Foo*)*, i8* (%struct.Foo*)** %vtable, align 8, !dbg !22 - %call = tail call i8* %1(%struct.Foo* %p) #3, !dbg !22, !heapallocsite !2 - tail call void @use_result(i8* %call) #3, !dbg !22 - ret i32 0, !dbg !26 -} +declare dso_local void @use_alloc(i8*) #2 -; Function Attrs: nounwind -define dso_local i32 @call_multiple() local_unnamed_addr #0 !dbg !27 { +; Function Attrs: noinline optnone uwtable +define dso_local void @call_multiple() #0 !dbg !17 { entry: - %call = tail call %struct.Foo* @alloc_foo() #3, !dbg !30, !heapallocsite !12 - %0 = bitcast %struct.Foo* %call to i8*, !dbg !30 - tail call void @use_result(i8* %0) #3, !dbg !30 - %call1 = tail call %struct.Foo* @alloc_foo() #3, !dbg !31, !heapallocsite !12 - %1 = bitcast %struct.Foo* %call1 to i8*, !dbg !31 - tail call void @use_result(i8* %1) #3, !dbg !31 - ret i32 0, !dbg !32 + %call = call %struct.Foo* @alloc_foo(), !dbg !20, !heapallocsite !12 + %0 = bitcast %struct.Foo* %call to i8*, !dbg !20 + call void @use_alloc(i8* %0), !dbg !20 + %call1 = call %struct.Foo* @alloc_foo(), !dbg !21, !heapallocsite !12 + %1 = bitcast %struct.Foo* %call1 to i8*, !dbg !21 + call void @use_alloc(i8* %1), !dbg !21 + ret void, !dbg !22 } -; Function Attrs: nounwind readnone speculatable -declare void @llvm.dbg.value(metadata, metadata, metadata) #2 +declare dso_local %struct.Foo* @alloc_foo() #2 -; CHECK-LABEL: call_tail: # @call_tail +; CHECK-LABEL: call_virtual: # @call_virtual ; CHECK: .Lheapallocsite0: -; CHECK: callq alloc_foo +; CHECK: callq *(%rax) ; CHECK: .Lheapallocsite1: +; CHECK: retq -; CHECK-LABEL: call_virtual: # @call_virtual -; CHECK: .Lheapallocsite2: -; CHECK: callq *{{.*}}%rax{{.*}} -; CHECK: .Lheapallocsite3: - -; CHECK-LABEL: call_multiple: # @call_multiple -; FastISel emits instructions in a different order. -; DAG: .Lheapallocsite4: -; FAST: .Lheapallocsite6: +; CHECK-LABEL: call_multiple: # @call_multiple +; CHECK: .Lheapallocsite4: ; CHECK: callq alloc_foo -; DAG: .Lheapallocsite5: -; FAST: .Lheapallocsite7: -; DAG: .Lheapallocsite6: -; FAST: .Lheapallocsite4: +; CHECK: .Lheapallocsite5: +; CHECK: .Lheapallocsite2: ; CHECK: callq alloc_foo -; DAG: .Lheapallocsite7: -; FAST: .Lheapallocsite5: +; CHECK: .Lheapallocsite3: +; CHECK: retq ; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE ; CHECK-NEXT: .secrel32 .Lheapallocsite0 ; CHECK-NEXT: .secidx .Lheapallocsite0 ; CHECK-NEXT: .short .Lheapallocsite1-.Lheapallocsite0 -; CHECK-NEXT: .long 4099 +; CHECK-NEXT: .long 3 +; CHECK-NEXT: .p2align 2 +; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END ; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE ; CHECK-NEXT: .secrel32 .Lheapallocsite2 ; CHECK-NEXT: .secidx .Lheapallocsite2 ; CHECK-NEXT: .short .Lheapallocsite3-.Lheapallocsite2 -; CHECK-NEXT: .long 3 +; CHECK-NEXT: .long 4096 +; CHECK-NEXT: .p2align 2 + ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE ; CHECK-NEXT: .secrel32 .Lheapallocsite4 ; CHECK-NEXT: .secidx .Lheapallocsite4 ; CHECK-NEXT: .short .Lheapallocsite5-.Lheapallocsite4 -; CHECK-NEXT: .long 4099 -; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE -; CHECK-NEXT: .secrel32 .Lheapallocsite6 -; CHECK-NEXT: .secidx .Lheapallocsite6 -; CHECK-NEXT: .short .Lheapallocsite7-.Lheapallocsite6 -; CHECK-NEXT: .long 4099 - -attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #2 = { nounwind readnone speculatable } -attributes #3 = { nounwind } +; CHECK-NEXT: .long 4096 +; CHECK-NEXT: .p2align 2 +; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END !llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5} -!llvm.ident = !{!6} +!llvm.module.flags = !{!3, !4, !5, !6} +!llvm.ident = !{!7} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git ebca9d67ffca71c9a996bd89844425ee13141f47)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) -!1 = !DIFile(filename: "", directory: "/usr/local/google/home/akhuang/testing/heapallocsite", checksumkind: CSK_MD5, checksum: "68a8ba93f37944165cfe76612a7073fd") +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 9c8073f44f786fbf47335e53f20abe64429e8e47)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)!1 = !DIFile(filename: "filename", directory: "directory", checksumkind: CSK_MD5, checksum: "096443b661a0af36da9006330c08f97e") !2 = !{} !3 = !{i32 2, !"CodeView", i32 1} !4 = !{i32 2, !"Debug Info Version", i32 3} !5 = !{i32 1, !"wchar_size", i32 2} -!6 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git ebca9d67ffca71c9a996bd89844425ee13141f47)"} -!7 = distinct !DISubprogram(name: "call_tail", scope: !8, file: !8, line: 7, type: !9, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) -!8 = !DIFile(filename: "label.cpp", directory: "/usr/local/google/home/akhuang/testing/heapallocsite", checksumkind: CSK_MD5, checksum: "68a8ba93f37944165cfe76612a7073fd") +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 9c8073f44f786fbf47335e53f20abe64429e8e47)"} +!8 = distinct !DISubprogram(name: "call_virtual", scope: !1, file: !1, line: 8, type: !9, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) !9 = !DISubroutineType(types: !10) -!10 = !{null} -!11 = !DILocation(line: 8, scope: !7) -!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !8, line: 1, flags: DIFlagFwdDecl, identifier: ".?AUFoo@@") -!13 = !DILocation(line: 9, scope: !7) -!14 = distinct !DISubprogram(name: "call_virtual", scope: !8, file: !8, line: 10, type: !15, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !19) -!15 = !DISubroutineType(types: !16) -!16 = !{!17, !18} -!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) -!19 = !{!20} -!20 = !DILocalVariable(name: "p", arg: 1, scope: !14, file: !8, line: 10, type: !18) -!21 = !DILocation(line: 0, scope: !14) -!22 = !DILocation(line: 11, scope: !14) -!23 = !{!24, !24, i64 0} -!24 = !{!"vtable pointer", !25, i64 0} -!25 = !{!"Simple C++ TBAA"} -!26 = !DILocation(line: 12, scope: !14) -!27 = distinct !DISubprogram(name: "call_multiple", scope: !8, file: !8, line: 14, type: !28, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) -!28 = !DISubroutineType(types: !29) -!29 = !{!17} -!30 = !DILocation(line: 15, scope: !27) -!31 = !DILocation(line: 16, scope: !27) -!32 = !DILocation(line: 17, scope: !27) +!10 = !{null, !11} +!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) +!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, flags: DIFlagFwdDecl, identifier: ".?AUFoo@@") +!13 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 8, type: !11) +!14 = !DILocation(line: 8, scope: !8) +!15 = !DILocation(line: 9, scope: !8) +!16 = !DILocation(line: 10, scope: !8) +!17 = distinct !DISubprogram(name: "call_multiple", scope: !1, file: !1, line: 12, type: !18, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!18 = !DISubroutineType(types: !19) +!19 = !{null} +!20 = !DILocation(line: 13, scope: !17) +!21 = !DILocation(line: 14, scope: !17) +!22 = !DILocation(line: 15, scope: !17) -- 2.49.0