llvm-project/llvm/test/DebugInfo/Mips/dsr-non-fixed-objects.ll

125 lines
5.5 KiB
LLVM
Raw Normal View History

; RUN: llc -march=mips -mcpu=mips32r2 -O0 -filetype=obj <%s | \
; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F2
; RUN: llc -march=mips -mcpu=mips32r2 -O0 -filetype=obj <%s | \
; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F3
declare void @llvm.dbg.declare(metadata, metadata, metadata)
declare void @foo(i32*)
; void foo(int *);
;
; int f2(int a, int b) {
; int c __attribute__((aligned(16))) = a + b;
; foo(&c);
; return c;
; }
;
; int *f3(int a, int b) {
; int c __attribute__((aligned(16))) = a + b;
; int *w = alloca(c);
; foo(&c);
; return w;
; }
; c -> DW_OP_breg29(r29): 16
; F2: DW_AT_location [DW_FORM_exprloc] (<0x2> 8d 10 )
; F2: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c")
; Function Attrs: nounwind
define i32 @f2(i32 signext %a, i32 signext %b) !dbg !4 {
entry:
%a.addr = alloca i32, align 4
%b.addr = alloca i32, align 4
%c = alloca i32, align 16
store i32 %a, i32* %a.addr, align 4
call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !15, metadata !16), !dbg !17
store i32 %b, i32* %b.addr, align 4
call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !18, metadata !16), !dbg !19
call void @llvm.dbg.declare(metadata i32* %c, metadata !20, metadata !16), !dbg !21
%0 = load i32, i32* %a.addr, align 4, !dbg !22
%1 = load i32, i32* %b.addr, align 4, !dbg !23
%add = add nsw i32 %0, %1, !dbg !24
store i32 %add, i32* %c, align 16, !dbg !21
call void @foo(i32* %c), !dbg !25
%2 = load i32, i32* %c, align 16, !dbg !26
ret i32 %2, !dbg !27
}
; c -> DW_OP_breg23(r23): 16
; F3: DW_AT_location [DW_FORM_exprloc] (<0x2> 87 10 )
; F3: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c")
define i32* @f3(i32 signext %a, i32 signext %b) !dbg !8 {
entry:
%a.addr = alloca i32, align 4
%b.addr = alloca i32, align 4
%c = alloca i32, align 16
%w = alloca i32*, align 4
store i32 %a, i32* %a.addr, align 4
call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !28, metadata !16), !dbg !29
store i32 %b, i32* %b.addr, align 4
call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !30, metadata !16), !dbg !31
call void @llvm.dbg.declare(metadata i32* %c, metadata !32, metadata !16), !dbg !33
%0 = load i32, i32* %a.addr, align 4, !dbg !34
%1 = load i32, i32* %b.addr, align 4, !dbg !35
%add = add nsw i32 %0, %1, !dbg !36
store i32 %add, i32* %c, align 16, !dbg !33
Reapply r257105 "[Verifier] Check that debug values have proper size" I originally reapplied this in 257550, but had to revert again due to bot breakage. The only change in this version is to allow either the TypeSize or the TypeAllocSize of the variable to be the one represented in debug info (hopefully in the future we can figure out how to encode the difference). Additionally, several bot failures following r257550, were due to optimizer bugs now fixed in r257787 and r257795. r257550 commit message was: ``` The follow extra changes were made to test cases: Manually making the variable be the actual type instead of a pointer to avoid pointer-size differences in generic code: LLVM :: DebugInfo/Generic/2010-03-24-MemberFn.ll LLVM :: DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll LLVM :: DebugInfo/Generic/2010-05-03-DisableFramePtr.ll LLVM :: DebugInfo/Generic/varargs.ll Delete sizing information from debug info for the same reason (but the presence of the pointer was important to the test case): LLVM :: DebugInfo/Generic/restrict.ll LLVM :: DebugInfo/Generic/tu-composite.ll LLVM :: Linker/type-unique-type-array-a.ll LLVM :: Linker/type-unique-simple2.ll Fixing an incorrect DW_OP_deref LLVM :: DebugInfo/Generic/2010-05-03-OriginDIE.ll Fixing a missing DW_OP_deref LLVM :: DebugInfo/Generic/incorrect-variable-debugloc.ll Additionally, clang should no longer complain during bootstrap should no longer happen after r257534. The original commit message was: `` Summary: Teach the Verifier to make sure that the storage size given to llvm.dbg.declare or the value size given to llvm.dbg.value agree with what is declared in DebugInfo. This is implicitly assumed in a number of passes (e.g. in SROA). Additionally this catches a number of common mistakes, such as passing a pointer when a value was intended or vice versa. One complication comes from stack coloring which modifies the original IR when it merges allocas in order to make sure that if AA falls back to the IR it gets the correct result. However, given this new invariant, indiscriminately replacing one alloca by a different (differently sized one) is no longer valid. Fix this by just undefing out any use of the alloca in a dbg.declare in this case. Additionally, I had to fix a number of test cases. Of particular note: - I regenerated dbg-changes-codegen-branch-folding.ll from the given source as it was affected by the bug fixed in r256077 - two-cus-from-same-file.ll was changed to avoid having a variable-typed debug variable as that would depend on the target, even though this test is supposed to be generic - I had to manually declared size/align for reference type. See also the discussion for D14275/r253186. - fpstack-debuginstr-kill.ll required changing `double` to `long double` - most others were just a question of adding OP_deref `` ``` llvm-svn: 257850
2016-01-15 08:46:17 +08:00
call void @llvm.dbg.declare(metadata i32** %w, metadata !37, metadata !DIExpression(DW_OP_deref)), !dbg !38
%2 = load i32, i32* %c, align 16, !dbg !39
%3 = alloca i8, i32 %2, !dbg !40
%4 = bitcast i8* %3 to i32*, !dbg !40
store i32* %4, i32** %w, align 4, !dbg !38
call void @foo(i32* %c), !dbg !41
%5 = load i32*, i32** %w, align 4, !dbg !42
ret i32* %5, !dbg !43
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!12, !13}
!llvm.ident = !{!14}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251783) (llvm/trunk 251781)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "test.c", directory: "/home/vk/repos/tmp/dwarf")
!2 = !{}
!4 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 20, type: !5, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!5 = !DISubroutineType(types: !6)
!6 = !{!7, !7, !7}
!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!8 = distinct !DISubprogram(name: "f3", scope: !1, file: !1, line: 27, type: !9, isLocal: false, isDefinition: true, scopeLine: 27, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!9 = !DISubroutineType(types: !10)
!10 = !{!11, !7, !7}
!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32)
!12 = !{i32 2, !"Dwarf Version", i32 4}
!13 = !{i32 2, !"Debug Info Version", i32 3}
!14 = !{!"clang version 3.8.0 (trunk 251783) (llvm/trunk 251781)"}
!15 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 20, type: !7)
!16 = !DIExpression()
!17 = !DILocation(line: 20, column: 12, scope: !4)
!18 = !DILocalVariable(name: "b", arg: 2, scope: !4, file: !1, line: 20, type: !7)
!19 = !DILocation(line: 20, column: 19, scope: !4)
!20 = !DILocalVariable(name: "c", scope: !4, file: !1, line: 21, type: !7)
!21 = !DILocation(line: 21, column: 7, scope: !4)
!22 = !DILocation(line: 21, column: 40, scope: !4)
!23 = !DILocation(line: 21, column: 44, scope: !4)
!24 = !DILocation(line: 21, column: 42, scope: !4)
!25 = !DILocation(line: 22, column: 3, scope: !4)
!26 = !DILocation(line: 23, column: 10, scope: !4)
!27 = !DILocation(line: 23, column: 3, scope: !4)
!28 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 27, type: !7)
!29 = !DILocation(line: 27, column: 13, scope: !8)
!30 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 27, type: !7)
!31 = !DILocation(line: 27, column: 20, scope: !8)
!32 = !DILocalVariable(name: "c", scope: !8, file: !1, line: 28, type: !7)
!33 = !DILocation(line: 28, column: 7, scope: !8)
!34 = !DILocation(line: 28, column: 40, scope: !8)
!35 = !DILocation(line: 28, column: 44, scope: !8)
!36 = !DILocation(line: 28, column: 42, scope: !8)
!37 = !DILocalVariable(name: "w", scope: !8, file: !1, line: 29, type: !11)
!38 = !DILocation(line: 29, column: 8, scope: !8)
!39 = !DILocation(line: 29, column: 19, scope: !8)
!40 = !DILocation(line: 29, column: 12, scope: !8)
!41 = !DILocation(line: 30, column: 3, scope: !8)
!42 = !DILocation(line: 31, column: 10, scope: !8)
!43 = !DILocation(line: 31, column: 3, scope: !8)