Home | History | Annotate | Download | only in COFF
      1 ; This tests that emitting CodeView arrays doesn't assert when an ODR violation
      2 ; makes our array dimension size calculations inaccurate. (PR32383)
      3 
      4 ; Here was the scenario:
      5 ; $ cat a.cpp
      6 ; typedef union YYSTYPE { int x; } YYSTYPE;
      7 ; YYSTYPE a;
      8 ; $ cat b.cpp
      9 ; typedef union YYSTYPE { char x; } YYSTYPE;
     10 ; void fn1() { YYSTYPE a[1]; }
     11 ; $ clang-cl -c -Zi -flto a.cpp b.cpp
     12 ; $ llvm-link a.obj b.obj -S -o t.ll  # This is the test case IR.
     13 ; $ llc t.ll  # Used to assert
     14 
     15 ; RUN: llc < %s | FileCheck %s
     16 
     17 ; FIXME: sizeof(a) in the user program is 1, but we claim it is 4 because
     18 ; sometimes the frontend lies to us. See array-types-advanced.ll for an example.
     19 ;
     20 ; CHECK: Array ({{.*}}) {
     21 ; CHECK:   TypeLeafKind: LF_ARRAY (0x1503)
     22 ; CHECK:   ElementType: YYSTYPE ({{.*}})
     23 ; CHECK:   IndexType: unsigned __int64 (0x23)
     24 ; CHECK:   SizeOf: 4
     25 ; CHECK:   Name:
     26 ; CHECK: }
     27 
     28 ; sizeof(YYSTYPE) == 4
     29 ; CHECK: Union ({{.*}}) {
     30 ; CHECK:   TypeLeafKind: LF_UNION (0x1506)
     31 ; CHECK:   MemberCount: 1
     32 ; CHECK:   Properties [ (0x600)
     33 ; CHECK:     HasUniqueName (0x200)
     34 ; CHECK:     Sealed (0x400)
     35 ; CHECK:   ]
     36 ; CHECK:   FieldList: <field list>
     37 ; CHECK:   SizeOf: 4
     38 ; CHECK:   Name: YYSTYPE
     39 ; CHECK:   LinkageName: .?ATYYSTYPE@@
     40 ; CHECK: }
     41 
     42 ; ModuleID = 'llvm-link'
     43 source_filename = "llvm-link"
     44 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
     45 target triple = "x86_64-pc-windows-msvc19.10.24728"
     46 
     47 %union.YYSTYPE = type { i32 }
     48 %union.YYSTYPE.0 = type { i8 }
     49 
     50 @"\01?a@@3TYYSTYPE@@A" = global %union.YYSTYPE zeroinitializer, align 4, !dbg !0
     51 
     52 ; Function Attrs: noinline nounwind sspstrong uwtable
     53 define void @"\01?fn1@@YAXXZ"() #0 !dbg !21 {
     54 entry:
     55   %a = alloca [1 x %union.YYSTYPE.0], align 1
     56   call void @llvm.dbg.declare(metadata [1 x %union.YYSTYPE.0]* %a, metadata !24, metadata !29), !dbg !30
     57   ret void, !dbg !30
     58 }
     59 
     60 ; Function Attrs: nounwind readnone
     61 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
     62 
     63 attributes #0 = { noinline nounwind sspstrong uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "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"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
     64 attributes #1 = { nounwind readnone }
     65 
     66 !llvm.dbg.cu = !{!2, !11}
     67 !llvm.ident = !{!13, !13}
     68 !llvm.module.flags = !{!18, !19, !20}
     69 
     70 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
     71 !1 = distinct !DIGlobalVariable(name: "a", linkageName: "\01?a@@3TYYSTYPE@@A", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
     72 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 5.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
     73 !3 = !DIFile(filename: "a.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "c0005139aa3df153c30d8c6953390a4b")
     74 !4 = !{}
     75 !5 = !{!0}
     76 !6 = !DIDerivedType(tag: DW_TAG_typedef, name: "YYSTYPE", file: !3, line: 1, baseType: !7)
     77 !7 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "YYSTYPE", file: !3, line: 1, size: 32, elements: !8, identifier: ".?ATYYSTYPE@@")
     78 !8 = !{!9}
     79 !9 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !7, file: !3, line: 1, baseType: !10, size: 32)
     80 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
     81 !11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !12, producer: "clang version 5.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4)
     82 !12 = !DIFile(filename: "b.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "9cfd390d8827beab36769147bb037abc")
     83 !13 = !{!"clang version 5.0.0 "}
     84 !18 = !{i32 2, !"CodeView", i32 1}
     85 !19 = !{i32 2, !"Debug Info Version", i32 3}
     86 !20 = !{i32 1, !"PIC Level", i32 2}
     87 !21 = distinct !DISubprogram(name: "fn1", linkageName: "\01?fn1@@YAXXZ", scope: !12, file: !12, line: 2, type: !22, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !11, retainedNodes: !4)
     88 !22 = !DISubroutineType(types: !23)
     89 !23 = !{null}
     90 !24 = !DILocalVariable(name: "a", scope: !21, file: !12, line: 2, type: !25)
     91 !25 = !DICompositeType(tag: DW_TAG_array_type, baseType: !26, size: 8, elements: !27)
     92 !26 = !DIDerivedType(tag: DW_TAG_typedef, name: "YYSTYPE", file: !12, line: 1, baseType: !7)
     93 !27 = !{!28}
     94 !28 = !DISubrange(count: 1)
     95 !29 = !DIExpression()
     96 !30 = !DILocation(line: 2, scope: !21)
     97