-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DebugInfo: Use clang's preferred names for integer types
This reverts c7f16ab / r109694 - which suggested this was done to improve consistency with the gdb test suite. Possible that at the time GCC did not canonicalize integer types, and so matching types was important for cross-compiler validity, or that it was only a case of over-constrained test cases that printed out/tested the exact names of integer types. In any case neither issue seems to exist today based on my limited testing - both gdb and lldb canonicalize integer types (in a way that happens to match Clang's preferred naming, incidentally) and so never print the original text name produced in the DWARF by GCC or Clang. This canonicalization appears to be in `integer_types_same_name_p` for GDB and in `TypeSystemClang::GetBasicTypeEnumeration` for lldb. (I tested this with one translation unit defining 3 variables - `long`, `long (*)()`, and `int (*)()`, and another translation unit that had main, and a function that took `long (*)()` as a parameter - then compiled them with mismatched compilers (either GCC+Clang, or Clang+(Clang with this patch applied)) and no matter the combination, despite the debug info for one CU naming the type "long int" and the other naming it "long", both debuggers printed out the name as "long" and were able to correctly perform overload resolution and pass the `long int (*)()` variable to the `long (*)()` function parameter) Did find one hiccup, identified by the lldb test suite - that CodeView was relying on these names to map them to builtin types in that format. So added some handling for that in LLVM. (these could be split out into separate patches, but seems small enough to not warrant it - will do that if there ends up needing any reverti/revisiting) Differential Revision: https://reviews.llvm.org/D110455
- Loading branch information
Showing
14 changed files
with
108 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s | ||
|
||
; Tests that CodeView integer types are generated even when using Clang's old integer type names. | ||
|
||
; C++ source to regenerate: | ||
; $ cat t.cpp | ||
; void usevars(long, ...); | ||
; void f() { | ||
; long l1 = 0; | ||
; unsigned long l2 = 0; | ||
; usevars(l1, l2); | ||
; } | ||
; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll -target x86_64-pc-windows-msvc19.0.23918 | ||
|
||
; CHECK: LocalSym { | ||
; CHECK: Type: long (0x12) | ||
; CHECK: VarName: l1 | ||
; CHECK: } | ||
; CHECK: LocalSym { | ||
; CHECK: Type: unsigned long (0x22) | ||
; CHECK: VarName: l2 | ||
; CHECK: } | ||
|
||
; ModuleID = '/usr/local/google/home/blaikie/dev/scratch/t.cpp' | ||
source_filename = "/usr/local/google/home/blaikie/dev/scratch/t.cpp" | ||
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-pc-windows-msvc19.0.23918" | ||
|
||
; Function Attrs: mustprogress noinline optnone uwtable | ||
define dso_local void @"?f@@YAXXZ"() #0 !dbg !8 { | ||
entry: | ||
%l1 = alloca i32, align 4 | ||
%l2 = alloca i32, align 4 | ||
call void @llvm.dbg.declare(metadata i32* %l1, metadata !13, metadata !DIExpression()), !dbg !15 | ||
store i32 0, i32* %l1, align 4, !dbg !15 | ||
call void @llvm.dbg.declare(metadata i32* %l2, metadata !16, metadata !DIExpression()), !dbg !18 | ||
store i32 0, i32* %l2, align 4, !dbg !18 | ||
%0 = load i32, i32* %l2, align 4, !dbg !19 | ||
%1 = load i32, i32* %l1, align 4, !dbg !19 | ||
call void (i32, ...) @"?usevars@@YAXJZZ"(i32 %1, i32 %0), !dbg !19 | ||
ret void, !dbg !20 | ||
} | ||
|
||
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn | ||
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 | ||
|
||
declare dso_local void @"?usevars@@YAXJZZ"(i32, ...) #2 | ||
|
||
attributes #0 = { mustprogress noinline optnone uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } | ||
attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } | ||
attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!2, !3, !4, !5, !6} | ||
!llvm.ident = !{!7} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0 (git@github.com:llvm/llvm-project.git 3709fb72c86bea1f0e6c51ab334ed6417cbe1c07)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "/usr/local/google/home/blaikie/dev/scratch/t.cpp", directory: "/usr/local/google/home/blaikie/dev/llvm/src", checksumkind: CSK_MD5, checksum: "a8e7ccc989ea91d67d3cb95afa046aa5") | ||
!2 = !{i32 2, !"CodeView", i32 1} | ||
!3 = !{i32 2, !"Debug Info Version", i32 3} | ||
!4 = !{i32 1, !"wchar_size", i32 2} | ||
!5 = !{i32 7, !"PIC Level", i32 2} | ||
!6 = !{i32 7, !"uwtable", i32 1} | ||
!7 = !{!"clang version 14.0.0 (git@github.com:llvm/llvm-project.git 3709fb72c86bea1f0e6c51ab334ed6417cbe1c07)"} | ||
!8 = distinct !DISubprogram(name: "f", linkageName: "?f@@YAXXZ", scope: !9, file: !9, line: 2, type: !10, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12) | ||
!9 = !DIFile(filename: "scratch/t.cpp", directory: "/usr/local/google/home/blaikie/dev", checksumkind: CSK_MD5, checksum: "a8e7ccc989ea91d67d3cb95afa046aa5") | ||
!10 = !DISubroutineType(types: !11) | ||
!11 = !{null} | ||
!12 = !{} | ||
!13 = !DILocalVariable(name: "l1", scope: !8, file: !9, line: 3, type: !14) | ||
!14 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) | ||
!15 = !DILocation(line: 3, scope: !8) | ||
!16 = !DILocalVariable(name: "l2", scope: !8, file: !9, line: 4, type: !17) | ||
!17 = !DIBasicType(name: "long unsigned int", size: 32, encoding: DW_ATE_unsigned) | ||
!18 = !DILocation(line: 4, scope: !8) | ||
!19 = !DILocation(line: 5, scope: !8) | ||
!20 = !DILocation(line: 6, scope: !8) |