From ab7ae3c8ec7afced236aa2e9fd1d748b8f913dfb Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 22 Jul 2019 21:51:04 +0000 Subject: [PATCH 1/4] Remove Xcode project remnants llvm-svn: 366745 (cherry picked from commit 63b921f01da907fdb68bb7406fc6b556db265068) Conflicts: lldb/tools/debugserver/source/CMakeLists.txt --- lldb/scripts/generate-vers.pl | 56 -------------------- lldb/tools/debugserver/source/CMakeLists.txt | 8 --- 2 files changed, 64 deletions(-) delete mode 100755 lldb/scripts/generate-vers.pl diff --git a/lldb/scripts/generate-vers.pl b/lldb/scripts/generate-vers.pl deleted file mode 100755 index 63374981e01e0..0000000000000 --- a/lldb/scripts/generate-vers.pl +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/perl - -sub usage() -{ - print "Usage: generate-vers.pl /path/toproject.pbxproj program_name"; - exit(0); -} - -(scalar @ARGV == 2) or usage(); - -open $pbxproj, $ARGV[0] or die "Couldn't open ".$ARGV[0]; - -$lldb_version = None; -$lldb_train = None; -$lldb_revision = None; -$lldb_version_string = None; - -$product_name = "lldb"; - -while ($line = <$pbxproj>) -{ - chomp ($line); - - if ($lldb_version == None && - $line =~ /CURRENT_PROJECT_VERSION = ([0-9]+).([0-9]+).([0-9]+)(.[0-9])?/) - { - $lldb_version = $1; - $lldb_train = $2; - $lldb_revision = $3; - $lldb_patchlevel = $4; - - if ($lldb_patchlevel != None) - { - $lldb_version_string = $lldb_version.".".$lldb_train.".".$lldb_revision.".".$lldb_patchlevel; - } - else - { - $lldb_version_string = $lldb_version.".".$lldb_train.".".$lldb_revision; - } - } -} - -if (!$product_name || !$lldb_version_string) -{ - print "Couldn't get needed information from the .pbxproj"; - exit(-1); -} - -$uppercase_name = uc $product_name; -$lowercase_name = lc $product_name; - -close $pbxproj; - -$file_string = " const unsigned char ".$ARGV[1]."VersionString[] __attribute__ ((used)) = \"@(#)PROGRAM:".$uppercase_name." PROJECT:".$lowercase_name."-".$lldb_version_string."\" \"\\n\"; const double ".$ARGV[1]."VersionNumber __attribute__ ((used)) = (double)".$lldb_version.".".$lldb_train.";\n"; - -print $file_string; diff --git a/lldb/tools/debugserver/source/CMakeLists.txt b/lldb/tools/debugserver/source/CMakeLists.txt index 303fd28caf6ce..7a87abf9d8336 100644 --- a/lldb/tools/debugserver/source/CMakeLists.txt +++ b/lldb/tools/debugserver/source/CMakeLists.txt @@ -141,14 +141,6 @@ endif() set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c) set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1) - add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE} - COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl - ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver - > ${DEBUGSERVER_VERS_GENERATED_FILE} - DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl - ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj - ) - set(lldbDebugserverCommonSources DNBArch.cpp DNBBreakpoint.cpp From 35c1e773b2b0794344088a45b4f0be066fe25035 Mon Sep 17 00:00:00 2001 From: Nilanjana Basu Date: Mon, 5 Aug 2019 14:16:58 +0000 Subject: [PATCH 2/4] Changing representation of .cv_def_range directives in Codeview debug info assembly format for better readability llvm-svn: 367867 (cherry picked from commit da60fc813c225209cadbd137ce17b05e993acd8e) Conflicts: llvm/lib/MC/MCAsmStreamer.cpp llvm/test/DebugInfo/COFF/nrvo.ll --- lld/test/COFF/s_udt.s | 6 +- .../SymbolFile/NativePDB/Inputs/s_constant.s | 4 +- .../Plugins/SymbolFile/NativePDB/PdbUtil.cpp | 4 +- llvm/test/DebugInfo/COFF/nrvo.ll | 144 ++++++++++++++++++ 4 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 llvm/test/DebugInfo/COFF/nrvo.ll diff --git a/lld/test/COFF/s_udt.s b/lld/test/COFF/s_udt.s index 900948aa8b53b..63e4099709575 100644 --- a/lld/test/COFF/s_udt.s +++ b/lld/test/COFF/s_udt.s @@ -173,7 +173,7 @@ main: # @main .short 1 # Flags .asciz "argc" .Ltmp13: - .cv_def_range .Ltmp0 .Ltmp1, "B\021\f\000\000\000" + .cv_def_range .Ltmp0 .Ltmp1, frame_ptr_rel, 12 .short .Ltmp15-.Ltmp14 # Record length .Ltmp14: .short 4414 # Record kind: S_LOCAL @@ -181,7 +181,7 @@ main: # @main .short 1 # Flags .asciz "argv" .Ltmp15: - .cv_def_range .Ltmp0 .Ltmp1, "B\021\020\000\000\000" + .cv_def_range .Ltmp0 .Ltmp1, frame_ptr_rel, 16 .short .Ltmp17-.Ltmp16 # Record length .Ltmp16: .short 4414 # Record kind: S_LOCAL @@ -189,7 +189,7 @@ main: # @main .short 0 # Flags .asciz "SPtr" .Ltmp17: - .cv_def_range .Ltmp0 .Ltmp1, "B\021\000\000\000\000" + .cv_def_range .Ltmp0 .Ltmp1, frame_ptr_rel, 0 .short .Ltmp19-.Ltmp18 # Record length .Ltmp18: .short 4360 # Record kind: S_UDT diff --git a/lldb/lit/SymbolFile/NativePDB/Inputs/s_constant.s b/lldb/lit/SymbolFile/NativePDB/Inputs/s_constant.s index 553a5ce06dbf0..6eaa80cf850ac 100644 --- a/lldb/lit/SymbolFile/NativePDB/Inputs/s_constant.s +++ b/lldb/lit/SymbolFile/NativePDB/Inputs/s_constant.s @@ -165,7 +165,7 @@ GlobalSSEC: # @GlobalSSEC .short 1 # Flags .asciz "argc" .Ltmp13: - .cv_def_range .Ltmp0 .Ltmp1, "B\021\004\000\000\000" + .cv_def_range .Ltmp0 .Ltmp1, frame_ptr_rel, 4 .short .Ltmp15-.Ltmp14 # Record length .Ltmp14: .short 4414 # Record kind: S_LOCAL @@ -173,7 +173,7 @@ GlobalSSEC: # @GlobalSSEC .short 1 # Flags .asciz "argv" .Ltmp15: - .cv_def_range .Ltmp0 .Ltmp1, "B\021\b\000\000\000" + .cv_def_range .Ltmp0 .Ltmp1, frame_ptr_rel, 8 .short 2 # Record length .short 4431 # Record kind: S_PROC_ID_END .Ltmp7: diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp index 1f5c97da81cfc..fc047e25a2f40 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp @@ -641,14 +641,14 @@ VariableInfo lldb_private::npdb::GetVariableLocationInfo( llvm::StringRef program; if (GetFrameDataProgram(index, ranges, program)) { result.location = - MakeVFrameRelLocationExpression(program, loc.Offset, module); + MakeVFrameRelLocationExpression(program, loc.Hdr.Offset, module); result.ranges = std::move(ranges); } else { // invalid variable } } else { result.location = - MakeRegRelLocationExpression(base_reg, loc.Offset, module); + MakeRegRelLocationExpression(base_reg, loc.Hdr.Offset, module); result.ranges = std::move(ranges); } } else if (loc_specifier_cvs.kind() == S_DEFRANGE_REGISTER_REL) { diff --git a/llvm/test/DebugInfo/COFF/nrvo.ll b/llvm/test/DebugInfo/COFF/nrvo.ll new file mode 100644 index 0000000000000..e01cbe6e6672f --- /dev/null +++ b/llvm/test/DebugInfo/COFF/nrvo.ll @@ -0,0 +1,144 @@ +; RUN: llc < %s | FileCheck %s --check-prefix=ASM +; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ + +; C++ source to regenerate: +; struct Foo { +; Foo() = default; +; Foo(Foo &&other) { x = other.x; } +; int x; +; }; +; void some_function(int); +; Foo getFoo() { +; Foo foo; +; foo.x = 41; +; some_function(foo.x); +; return foo; +; } +; +; int main() { +; Foo bar = getFoo(); +; return bar.x; +; } +; $ clang t.cpp -S -emit-llvm -g -o t.ll + +; ASM-LABEL: .long 241 # Symbol subsection for GetFoo +; ASM: .short 4414 # Record kind: S_LOCAL +; ASM-NEXT: .long 4113 # TypeIndex +; ASM-NEXT: .short 0 # Flags +; ASM-NEXT: .asciz "foo" +; ASM-NEXT: .p2align 2 +; ASM-NEXT: .Ltmp +; ASM: .cv_def_range .Ltmp{{.*}} .Ltmp{{.*}}, frame_ptr_rel, 40 + +; OBJ: Subsection [ +; OBJ: SubSectionType: Symbols (0xF1) +; OBJ: LocalSym { +; OBJ: Kind: S_LOCAL (0x113E) +; OBJ: Type: Foo& (0x1011) +; OBJ: Flags [ (0x0) +; OBJ: ] +; OBJ: VarName: foo +; OBJ: } +; OBJ: DefRangeFramePointerRelSym { +; OBJ: Kind: S_DEFRANGE_FRAMEPOINTER_REL (0x1142) +; OBJ: Offset: 40 +; OBJ: LocalVariableAddrRange { +; OBJ: OffsetStart: .text+0x1D +; OBJ: ISectStart: 0x0 +; OBJ: Range: 0x16 +; OBJ: } + +; ModuleID = 't.cpp' +source_filename = "t.cpp" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.16.27030" + +%struct.Foo = type { i32 } + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @"?some_function@@YAXH@Z"(i32) #0 !dbg !8 { +entry: + %.addr = alloca i32, align 4 + store i32 %0, i32* %.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %.addr, metadata !12, metadata !DIExpression()), !dbg !13 + ret void, !dbg !13 +} + +; Function Attrs: nounwind readnone speculatable +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @"?GetFoo@@YA?AUFoo@@XZ"(%struct.Foo* noalias sret %agg.result) #0 !dbg !14 { +entry: + %result.ptr = alloca i8*, align 8 + %0 = bitcast %struct.Foo* %agg.result to i8* + store i8* %0, i8** %result.ptr, align 8 + call void @llvm.dbg.declare(metadata i8** %result.ptr, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !29 + %x = getelementptr inbounds %struct.Foo, %struct.Foo* %agg.result, i32 0, i32 0, !dbg !30 + store i32 41, i32* %x, align 4, !dbg !30 + %x1 = getelementptr inbounds %struct.Foo, %struct.Foo* %agg.result, i32 0, i32 0, !dbg !31 + %1 = load i32, i32* %x1, align 4, !dbg !31 + call void @"?some_function@@YAXH@Z"(i32 %1), !dbg !31 + ret void, !dbg !32 +} + +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #2 !dbg !33 { +entry: + %retval = alloca i32, align 4 + %bar = alloca %struct.Foo, align 4 + store i32 0, i32* %retval, align 4 + call void @llvm.dbg.declare(metadata %struct.Foo* %bar, metadata !36, metadata !DIExpression()), !dbg !37 + call void @"?GetFoo@@YA?AUFoo@@XZ"(%struct.Foo* sret %bar), !dbg !37 + %x = getelementptr inbounds %struct.Foo, %struct.Foo* %bar, i32 0, i32 0, !dbg !38 + %0 = load i32, i32* %x, align 4, !dbg !38 + ret i32 %0, !dbg !38 +} + +attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone speculatable } +attributes #2 = { noinline norecurse nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6} +!llvm.ident = !{!7} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git c19ebebac4bf853e77a69c74abe9f7fce98c1d17)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctesting\5Cnrvo", checksumkind: CSK_MD5, checksum: "52a5a20c02c102dfd255d5615680a8bd") +!2 = !{} +!3 = !{i32 2, !"CodeView", i32 1} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 2} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git c19ebebac4bf853e77a69c74abe9f7fce98c1d17)"} +!8 = distinct !DISubprogram(name: "some_function", linkageName: "?some_function@@YAXH@Z", scope: !1, file: !1, line: 13, type: !9, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!9 = !DISubroutineType(types: !10) +!10 = !{null, !11} +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !DILocalVariable(arg: 1, scope: !8, file: !1, line: 13, type: !11) +!13 = !DILocation(line: 13, scope: !8) +!14 = distinct !DISubprogram(name: "GetFoo", linkageName: "?GetFoo@@YA?AUFoo@@XZ", scope: !1, file: !1, line: 15, type: !15, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!15 = !DISubroutineType(types: !16) +!16 = !{!17} +!17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, size: 32, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !18, identifier: ".?AUFoo@@") +!18 = !{!19, !20, !24} +!19 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !17, file: !1, line: 4, baseType: !11, size: 32) +!20 = !DISubprogram(name: "Foo", scope: !17, file: !1, line: 2, type: !21, scopeLine: 2, flags: DIFlagPrototyped, spFlags: 0) +!21 = !DISubroutineType(types: !22) +!22 = !{null, !23} +!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) +!24 = !DISubprogram(name: "Foo", scope: !17, file: !1, line: 3, type: !25, scopeLine: 3, flags: DIFlagPrototyped, spFlags: 0) +!25 = !DISubroutineType(types: !26) +!26 = !{null, !23, !27} +!27 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !17, size: 64) +!28 = !DILocalVariable(name: "foo", scope: !14, file: !1, line: 17, type: !17) +!29 = !DILocation(line: 17, scope: !14) +!30 = !DILocation(line: 18, scope: !14) +!31 = !DILocation(line: 19, scope: !14) +!32 = !DILocation(line: 21, scope: !14) +!33 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 23, type: !34, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!34 = !DISubroutineType(types: !35) +!35 = !{!11} +!36 = !DILocalVariable(name: "bar", scope: !33, file: !1, line: 24, type: !17) +!37 = !DILocation(line: 24, scope: !33) +!38 = !DILocation(line: 25, scope: !33) From 7c84051950c380b18b641c4fbfba643873dd518d Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 28 Oct 2019 21:23:15 -0700 Subject: [PATCH 3/4] XFAIL test that is missing dependencies on this branch. --- llvm/test/DebugInfo/COFF/nrvo.ll | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/test/DebugInfo/COFF/nrvo.ll b/llvm/test/DebugInfo/COFF/nrvo.ll index e01cbe6e6672f..1b640e16de181 100644 --- a/llvm/test/DebugInfo/COFF/nrvo.ll +++ b/llvm/test/DebugInfo/COFF/nrvo.ll @@ -1,3 +1,6 @@ +; XFAIL: * +; missing unidentified cherry-pick. + ; RUN: llc < %s | FileCheck %s --check-prefix=ASM ; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ From 21219849d51eeb7622cc698bb86426fee90ea57c Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 24 Jul 2019 17:28:24 +0000 Subject: [PATCH 4/4] [lldb] Configure debugserver_vers.c from CMake llvm-svn: 366932 (cherry picked from commit e8bffd3ff0289cd317d457e2562e130729c3b8d2) Conflicts: lldb/tools/debugserver/source/CMakeLists.txt --- lldb/tools/debugserver/source/CMakeLists.txt | 2 ++ lldb/tools/debugserver/source/debugserver_vers.c.in | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 lldb/tools/debugserver/source/debugserver_vers.c.in diff --git a/lldb/tools/debugserver/source/CMakeLists.txt b/lldb/tools/debugserver/source/CMakeLists.txt index 7a87abf9d8336..be748eb2310aa 100644 --- a/lldb/tools/debugserver/source/CMakeLists.txt +++ b/lldb/tools/debugserver/source/CMakeLists.txt @@ -140,6 +140,8 @@ endif() set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c) set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1) + configure_file(debugserver_vers.c.in + ${DEBUGSERVER_VERS_GENERATED_FILE} @ONLY) set(lldbDebugserverCommonSources DNBArch.cpp diff --git a/lldb/tools/debugserver/source/debugserver_vers.c.in b/lldb/tools/debugserver/source/debugserver_vers.c.in new file mode 100644 index 0000000000000..00e34c29b07d2 --- /dev/null +++ b/lldb/tools/debugserver/source/debugserver_vers.c.in @@ -0,0 +1,2 @@ +const unsigned char debugserverVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:LLDB PROJECT:lldb-@LLDB_VERSION_MAJOR@.@LLDB_VERSION_MINOR@.@LLDB_VERSION_PATCH@" "\n"; +const double debugserverVersionNumber __attribute__ ((used)) = (double)@LLDB_VERSION_MAJOR@.@LLDB_VERSION_MINOR@;