brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.1 KiB · 7cd782d Raw
150 lines · plain
1; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s2; RUN: llc < %s | llvm-mc -filetype=obj --triple=i686-windows | llvm-readobj - --codeview | FileCheck %s3;4;5; Verify lambda routines are emitted properly in CodeView.6;7; The original source code:8; -----------------------------------------------------------------------------9; int main(int argc, char* argv[], char* arge[]) {10;   auto Lambda = [argc](int count) -> int { return argc == count ? 1 : 0; };11;   return Lambda(0);12; }13; -----------------------------------------------------------------------------14;15; To regenerate the IR below compile the source code:16;   $ clang lambda.cxx -S -emit-llvm -g -gcodeview17;18; CHECK:      FieldList ([[FIELDLIST_ID:0x[0-9A-F]+]]) {19; CHECK-NEXT:   TypeLeafKind: LF_FIELDLIST ({{.*}})20; CHECK-NEXT:   DataMember {21; CHECK-NEXT:     TypeLeafKind: LF_MEMBER ({{.*}})22; CHECK-NEXT:     AccessSpecifier: Private ({{.*}})23; CHECK-NEXT:     Type: int ({{.*}})24; CHECK-NEXT:     FieldOffset: {{.*}}25; CHECK-NEXT:     Name: argc26; CHECK-NEXT:   }27; CHECK-NEXT:   OneMethod {28; CHECK-NEXT:     TypeLeafKind: LF_ONEMETHOD (0x1511)29; CHECK-NEXT:     AccessSpecifier: Public (0x3)30; CHECK-NEXT:     Type: int main::<unnamed-tag>::(int) ({{.*}})31; CHECK-NEXT:     Name: operator()32; CHECK-NEXT:   }33; CHECK-NEXT: }34; CHECK-NEXT: Class ([[CLASS_ID:0x[0-9A-F]+]]) {35; CHECK-NEXT:   TypeLeafKind: LF_CLASS ({{.*}})36; CHECK-NEXT:   MemberCount: {{.*}}37; CHECK-NEXT:   Properties [ ({{.*}})38; CHECK-NEXT:     HasUniqueName ({{.*}})39; CHECK-NEXT:     Scoped ({{.*}})40; CHECK-NEXT:   ]41; CHECK-NEXT:   FieldList: <field list> ([[FIELDLIST_ID]])42; CHECK-NEXT:   DerivedFrom: {{.*}}43; CHECK-NEXT:   VShape: {{.*}}44; CHECK-NEXT:   SizeOf: {{.*}}45; CHECK-NEXT:   Name: main::<unnamed-tag>46; CHECK-NEXT:   LinkageName: {{.*lambda.*}}47; CHECK-NEXT: }48;             LocalSym {49;               Kind: S_LOCAL ({{.*}})50; CHECK:        Type: main::<unnamed-tag> ([[CLASS_ID]])51;               Flags [ (0x0)52;               ]53; CHECK:        VarName: Lambda54;             }55 56; ModuleID = 'lambda.cxx'57source_filename = "lambda.cxx"58target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"59target triple = "i686-pc-windows-msvc19.0.24210"60 61%class.anon = type { i32 }62 63; Function Attrs: noinline norecurse optnone64define dso_local i32 @main(i32 %argc, ptr %argv, ptr %arge) #0 !dbg !8 {65entry:66  %retval = alloca i32, align 467  %arge.addr = alloca ptr, align 468  %argv.addr = alloca ptr, align 469  %argc.addr = alloca i32, align 470  %Lambda = alloca %class.anon, align 471  store i32 0, ptr %retval, align 472  store ptr %arge, ptr %arge.addr, align 473  call void @llvm.dbg.declare(metadata ptr %arge.addr, metadata !15, metadata !DIExpression()), !dbg !1674  store ptr %argv, ptr %argv.addr, align 475  call void @llvm.dbg.declare(metadata ptr %argv.addr, metadata !17, metadata !DIExpression()), !dbg !1676  store i32 %argc, ptr %argc.addr, align 477  call void @llvm.dbg.declare(metadata ptr %argc.addr, metadata !18, metadata !DIExpression()), !dbg !1678  call void @llvm.dbg.declare(metadata ptr %Lambda, metadata !19, metadata !DIExpression()), !dbg !2879  %0 = load i32, ptr %argc.addr, align 4, !dbg !2880  store i32 %0, ptr %Lambda, align 4, !dbg !2881  %call = call x86_thiscallcc i32 @"??R<lambda_0>@?0??main@@9@QBE@H@Z"(ptr %Lambda, i32 0), !dbg !2982  ret i32 %call, !dbg !2983}84 85; Function Attrs: nounwind readnone speculatable86declare void @llvm.dbg.declare(metadata, metadata, metadata) #187 88; Function Attrs: noinline nounwind optnone89define internal x86_thiscallcc i32 @"??R<lambda_0>@?0??main@@9@QBE@H@Z"(ptr %this, i32 %count) #2 align 2 !dbg !30 {90entry:91  %count.addr = alloca i32, align 492  %this.addr = alloca ptr, align 493  store i32 %count, ptr %count.addr, align 494  call void @llvm.dbg.declare(metadata ptr %count.addr, metadata !31, metadata !DIExpression()), !dbg !3295  store ptr %this, ptr %this.addr, align 496  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !33, metadata !DIExpression()), !dbg !3597  %this1 = load ptr, ptr %this.addr, align 498  %0 = load i32, ptr %this1, align 4, !dbg !3299  %1 = load i32, ptr %count.addr, align 4, !dbg !32100  %cmp = icmp eq i32 %0, %1, !dbg !32101  %2 = zext i1 %cmp to i64, !dbg !32102  %cond = select i1 %cmp, i32 1, i32 0, !dbg !32103  ret i32 %cond, !dbg !32104}105 106attributes #0 = { noinline norecurse optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }107attributes #1 = { nounwind readnone speculatable }108attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }109 110!llvm.dbg.cu = !{!0}111!llvm.module.flags = !{!3, !4, !5, !6}112!llvm.ident = !{!7}113 114!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)115!1 = !DIFile(filename: "lambda.cxx", directory: "C:\5Cpath\5Cto", checksumkind: CSK_MD5, checksum: "8d860c432e3763effaf1658460a496c0")116!2 = !{}117!3 = !{i32 1, !"NumRegisterParameters", i32 0}118!4 = !{i32 2, !"CodeView", i32 1}119!5 = !{i32 2, !"Debug Info Version", i32 3}120!6 = !{i32 1, !"wchar_size", i32 2}121!7 = !{!"clang version 7.0.0 (trunk)"}122!8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)123!9 = !DISubroutineType(types: !10)124!10 = !{!11, !11, !12, !12}125!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)126!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 32)127!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)128!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)129!15 = !DILocalVariable(name: "arge", arg: 3, scope: !8, file: !1, line: 1, type: !12)130!16 = !DILocation(line: 1, scope: !8)131!17 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !1, line: 1, type: !12)132!18 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !1, line: 1, type: !11)133!19 = !DILocalVariable(name: "Lambda", scope: !8, file: !1, line: 2, type: !20)134!20 = distinct !DICompositeType(tag: DW_TAG_class_type, scope: !8, file: !1, line: 2, size: 32, flags: DIFlagTypePassByValue, elements: !21, identifier: "??R<lambda_0>@?0??main@@9@QBE@H@Z")135!21 = !{!22, !23}136!22 = !DIDerivedType(tag: DW_TAG_member, name: "argc", scope: !20, file: !1, line: 2, baseType: !11, size: 32)137!23 = !DISubprogram(name: "operator()", scope: !20, file: !1, line: 2, type: !24, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false)138!24 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !25)139!25 = !{!11, !26, !11}140!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)141!27 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !20)142!28 = !DILocation(line: 2, scope: !8)143!29 = !DILocation(line: 3, scope: !8)144!30 = distinct !DISubprogram(name: "operator()", linkageName: "??R<lambda_0>@?0??main@@9@QBE@H@Z", scope: !20, file: !1, line: 2, type: !24, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !23, retainedNodes: !2)145!31 = !DILocalVariable(name: "count", arg: 2, scope: !30, file: !1, line: 2, type: !11)146!32 = !DILocation(line: 2, scope: !30)147!33 = !DILocalVariable(name: "this", arg: 1, scope: !30, type: !34, flags: DIFlagArtificial | DIFlagObjectPointer)148!34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 32)149!35 = !DILocation(line: 0, scope: !30)150