brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.5 KiB · 72834be Raw
142 lines · plain
1; RUN: llc < %s | FileCheck --check-prefixes=CHECK %s2; RUN: llc -O0 < %s | FileCheck --check-prefixes=CHECK %s3 4 5; Source to regenerate:6; $ clang -cc1 -triple x86_64-windows-msvc t.cpp -debug-info-kind=limited \7;      -gcodeview -O2 -fms-extensions -emit-llvm -o t.ll8;9; extern "C" struct Foo {10;   __declspec(allocator) virtual ptr alloc();11; };12; extern "C" __declspec(allocator) Foo *alloc_foo();13; extern "C" void use_result(ptr);14; extern "C" Foo *call_tail() {15;   return alloc_foo();16; }17; extern "C" int call_virtual(Foo *p) {18;   use_result(p->alloc());19;   return 0;20; }21; extern "C" int call_multiple() {22;   use_result(alloc_foo());23;   use_result(alloc_foo());24;   return 0;25; }26 27; ModuleID = 't.cpp'28source_filename = "t.cpp"29target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"30target triple = "x86_64-unknown-windows-msvc"31 32%struct.Foo = type { ptr }33 34; Function Attrs: nounwind35define dso_local ptr @call_tail() local_unnamed_addr #0 !dbg !7 {36entry:37  %call = tail call ptr @alloc_foo() #3, !dbg !13, !heapallocsite !1238  ret ptr %call, !dbg !1339}40 41declare dso_local ptr @alloc_foo() local_unnamed_addr #142 43; Function Attrs: nounwind44define dso_local i32 @call_virtual(ptr %p) local_unnamed_addr #0 !dbg !14 {45entry:46  call void @llvm.dbg.value(metadata ptr %p, metadata !19, metadata !DIExpression()), !dbg !2047  %vtable = load ptr, ptr %p, align 8, !dbg !21, !tbaa !2248  %0 = load ptr, ptr %vtable, align 8, !dbg !2149  %call = tail call ptr %0(ptr %p) #3, !dbg !21, !heapallocsite !250  tail call void @use_result(ptr %call) #3, !dbg !2151  ret i32 0, !dbg !2552}53 54declare dso_local void @use_result(ptr) local_unnamed_addr #155 56; Function Attrs: nounwind57define dso_local i32 @call_multiple() local_unnamed_addr #0 !dbg !26 {58entry:59  %call = tail call ptr @alloc_foo() #3, !dbg !29, !heapallocsite !1260  tail call void @use_result(ptr %call) #3, !dbg !2961  %call1 = tail call ptr @alloc_foo() #3, !dbg !30, !heapallocsite !1262  tail call void @use_result(ptr %call1) #3, !dbg !3063  ret i32 0, !dbg !3164}65 66; Function Attrs: nounwind readnone speculatable willreturn67declare void @llvm.dbg.value(metadata, metadata, metadata) #268 69 70; Don't emit metadata for tail calls.71; CHECK-LABEL: call_tail:         # @call_tail72; CHECK: jmp alloc_foo73 74; CHECK-LABEL: call_virtual:      # @call_virtual75; CHECK:       callq *{{.*}}%rax{{.*}}76; CHECK-NEXT:  [[LABEL1:.Ltmp[0-9]+]]:77 78; CHECK-LABEL: call_multiple:     # @call_multiple79; CHECK:       callq alloc_foo80; CHECK-NEXT:  [[LABEL3:.Ltmp[0-9]+]]:81; CHECK:       callq alloc_foo82; CHECK-NEXT:  [[LABEL5:.Ltmp[0-9]+]]:83 84; CHECK-LABEL: .short  4423                    # Record kind: S_GPROC32_ID85; CHECK:       .short  4446                    # Record kind: S_HEAPALLOCSITE86; CHECK-NEXT:  .secrel32 [[LABEL0:.Ltmp[0-9]+]]87; CHECK-NEXT:  .secidx [[LABEL0]]88; CHECK-NEXT:  .short [[LABEL1]]-[[LABEL0]]89; CHECK-NEXT:  .long 390; CHECK:       .short  4446                    # Record kind: S_HEAPALLOCSITE91; CHECK-NEXT:  .secrel32 [[LABEL2:.Ltmp[0-9]+]]92; CHECK-NEXT:  .secidx [[LABEL2]]93; CHECK-NEXT:  .short [[LABEL3]]-[[LABEL2]]94; CHECK-NEXT:  .long 409695; CHECK:       .short  4446                    # Record kind: S_HEAPALLOCSITE96; CHECK-NEXT:  .secrel32 [[LABEL4:.Ltmp[0-9]+]]97; CHECK-NEXT:  .secidx [[LABEL4]]98; CHECK-NEXT:  .short [[LABEL5]]-[[LABEL4]]99; CHECK-NEXT:  .long 4096100 101attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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-features"="+cx8,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }102attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }103attributes #2 = { nounwind readnone speculatable willreturn }104attributes #3 = { nounwind }105 106!llvm.dbg.cu = !{!0}107!llvm.module.flags = !{!3, !4, !5}108!llvm.ident = !{!6}109 110!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git fa686ea7650235c6dff988cc8cba49e130b3d5f8)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)111!1 = !DIFile(filename: "<stdin>", directory: "/usr/local/google/home/akhuang/testing/heapallocsite", checksumkind: CSK_MD5, checksum: "e0a04508b4229fc4aee0baa364e25987")112!2 = !{}113!3 = !{i32 2, !"CodeView", i32 1}114!4 = !{i32 2, !"Debug Info Version", i32 3}115!5 = !{i32 1, !"wchar_size", i32 2}116!6 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git fa686ea7650235c6dff988cc8cba49e130b3d5f8)"}117!7 = distinct !DISubprogram(name: "call_tail", scope: !8, file: !8, line: 6, type: !9, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)118!8 = !DIFile(filename: "t.cpp", directory: "/usr/local/google/home/akhuang/testing/heapallocsite", checksumkind: CSK_MD5, checksum: "e0a04508b4229fc4aee0baa364e25987")119!9 = !DISubroutineType(types: !10)120!10 = !{!11}121!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)122!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !8, line: 1, flags: DIFlagFwdDecl, identifier: ".?AUFoo@@")123!13 = !DILocation(line: 7, scope: !7)124!14 = distinct !DISubprogram(name: "call_virtual", scope: !8, file: !8, line: 9, type: !15, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18)125!15 = !DISubroutineType(types: !16)126!16 = !{!17, !11}127!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)128!18 = !{!19}129!19 = !DILocalVariable(name: "p", arg: 1, scope: !14, file: !8, line: 9, type: !11)130!20 = !DILocation(line: 0, scope: !14)131!21 = !DILocation(line: 10, scope: !14)132!22 = !{!23, !23, i64 0}133!23 = !{!"vtable pointer", !24, i64 0}134!24 = !{!"Simple C++ TBAA"}135!25 = !DILocation(line: 11, scope: !14)136!26 = distinct !DISubprogram(name: "call_multiple", scope: !8, file: !8, line: 13, type: !27, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)137!27 = !DISubroutineType(types: !28)138!28 = !{!17}139!29 = !DILocation(line: 14, scope: !26)140!30 = !DILocation(line: 15, scope: !26)141!31 = !DILocation(line: 16, scope: !26)142