146 lines · plain
1; RUN: llc < %s | FileCheck %s --check-prefix=ASM2; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ3 4 5; C++ source to regenerate:6; struct Foo {7; Foo() = default;8; Foo(Foo &&other) { x = other.x; }9; int x;10; };11; void some_function(int);12; Foo getFoo() {13; Foo foo;14; foo.x = 41;15; some_function(foo.x);16; return foo;17; }18;19; int main() {20; Foo bar = getFoo();21; return bar.x;22; }23; $ clang t.cpp -S -emit-llvm -g -o t.ll24 25; ASM-LABEL: .long 241 # Symbol subsection for GetFoo26; ASM: .short 4414 # Record kind: S_LOCAL27; ASM-NEXT: .long 4113 # TypeIndex28; ASM-NEXT: .short 0 # Flags29; ASM-NEXT: .asciz "foo"30; ASM-NEXT: .p2align 231; ASM-NEXT: .Ltmp32; ASM: .cv_def_range .Ltmp{{.*}} .Ltmp{{.*}}, frame_ptr_rel, 4033 34; OBJ: Subsection [35; OBJ: SubSectionType: Symbols (0xF1)36; OBJ: LocalSym {37; OBJ: Kind: S_LOCAL (0x113E)38; OBJ: Type: Foo& (0x1011)39; OBJ: Flags [ (0x0)40; OBJ: ]41; OBJ: VarName: foo42; OBJ: }43; OBJ: DefRangeFramePointerRelSym {44; OBJ: Kind: S_DEFRANGE_FRAMEPOINTER_REL (0x1142)45; OBJ: Offset: 4046; OBJ: LocalVariableAddrRange {47; OBJ: OffsetStart: .text+0x1D48; OBJ: ISectStart: 0x049; OBJ: Range: 0x1650; OBJ: }51 52; ModuleID = 't.cpp'53source_filename = "t.cpp"54target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"55target triple = "x86_64-pc-windows-msvc19.16.27030"56 57%struct.Foo = type { i32 }58 59; Function Attrs: noinline nounwind optnone uwtable60define dso_local void @"?some_function@@YAXH@Z"(i32) #0 !dbg !8 {61entry:62 %.addr = alloca i32, align 463 store i32 %0, ptr %.addr, align 464 call void @llvm.dbg.declare(metadata ptr %.addr, metadata !12, metadata !DIExpression()), !dbg !1365 ret void, !dbg !1366}67 68; Function Attrs: nounwind readnone speculatable69declare void @llvm.dbg.declare(metadata, metadata, metadata) #170 71; Function Attrs: noinline nounwind optnone uwtable72define dso_local void @"?GetFoo@@YA?AUFoo@@XZ"(ptr noalias sret(%struct.Foo) %agg.result) #0 !dbg !14 {73entry:74 %result.ptr = alloca ptr, align 875 %0 = bitcast ptr %agg.result to ptr76 store ptr %0, ptr %result.ptr, align 877 call void @llvm.dbg.declare(metadata ptr %result.ptr, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !2978 %x = getelementptr inbounds %struct.Foo, ptr %agg.result, i32 0, i32 0, !dbg !3079 store i32 41, ptr %x, align 4, !dbg !3080 %x1 = getelementptr inbounds %struct.Foo, ptr %agg.result, i32 0, i32 0, !dbg !3181 %1 = load i32, ptr %x1, align 4, !dbg !3182 call void @"?some_function@@YAXH@Z"(i32 %1), !dbg !3183 ret void, !dbg !3284}85 86; Function Attrs: noinline norecurse nounwind optnone uwtable87define dso_local i32 @main() #2 !dbg !33 {88entry:89 %retval = alloca i32, align 490 %bar = alloca %struct.Foo, align 491 store i32 0, ptr %retval, align 492 call void @llvm.dbg.declare(metadata ptr %bar, metadata !36, metadata !DIExpression()), !dbg !3793 call void @"?GetFoo@@YA?AUFoo@@XZ"(ptr sret(%struct.Foo) %bar), !dbg !3794 %x = getelementptr inbounds %struct.Foo, ptr %bar, i32 0, i32 0, !dbg !3895 %0 = load i32, ptr %x, align 4, !dbg !3896 ret i32 %0, !dbg !3897}98 99attributes #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" "frame-pointer"="none" "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" "use-soft-float"="false" }100attributes #1 = { nounwind readnone speculatable }101attributes #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" "frame-pointer"="none" "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" "use-soft-float"="false" }102 103!llvm.dbg.cu = !{!0}104!llvm.module.flags = !{!3, !4, !5, !6}105!llvm.ident = !{!7}106 107!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)108!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctesting\5Cnrvo", checksumkind: CSK_MD5, checksum: "52a5a20c02c102dfd255d5615680a8bd")109!2 = !{}110!3 = !{i32 2, !"CodeView", i32 1}111!4 = !{i32 2, !"Debug Info Version", i32 3}112!5 = !{i32 1, !"wchar_size", i32 2}113!6 = !{i32 7, !"PIC Level", i32 2}114!7 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git c19ebebac4bf853e77a69c74abe9f7fce98c1d17)"}115!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)116!9 = !DISubroutineType(types: !10)117!10 = !{null, !11}118!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)119!12 = !DILocalVariable(arg: 1, scope: !8, file: !1, line: 13, type: !11)120!13 = !DILocation(line: 13, scope: !8)121!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)122!15 = !DISubroutineType(types: !16)123!16 = !{!17}124!17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, size: 32, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !18, identifier: ".?AUFoo@@")125!18 = !{!19, !20, !24}126!19 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !17, file: !1, line: 4, baseType: !11, size: 32)127!20 = !DISubprogram(name: "Foo", scope: !17, file: !1, line: 2, type: !21, scopeLine: 2, flags: DIFlagPrototyped, spFlags: 0)128!21 = !DISubroutineType(types: !22)129!22 = !{null, !23}130!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)131!24 = !DISubprogram(name: "Foo", scope: !17, file: !1, line: 3, type: !25, scopeLine: 3, flags: DIFlagPrototyped, spFlags: 0)132!25 = !DISubroutineType(types: !26)133!26 = !{null, !23, !27}134!27 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !17, size: 64)135!28 = !DILocalVariable(name: "foo", scope: !14, file: !1, line: 17, type: !17)136!29 = !DILocation(line: 17, scope: !14)137!30 = !DILocation(line: 18, scope: !14)138!31 = !DILocation(line: 19, scope: !14)139!32 = !DILocation(line: 21, scope: !14)140!33 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 23, type: !34, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)141!34 = !DISubroutineType(types: !35)142!35 = !{!11}143!36 = !DILocalVariable(name: "bar", scope: !33, file: !1, line: 24, type: !17)144!37 = !DILocation(line: 24, scope: !33)145!38 = !DILocation(line: 25, scope: !33)146