diff options
| author | Eric Christopher <echristo@gmail.com> | 2019-04-17 04:52:47 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2019-04-17 04:52:47 +0000 |
| commit | cee313d288a4faf0355d76fb6e0e927e211d08a5 (patch) | |
| tree | d386075318d761197779a96e5d8fc0dc7b06342b /llvm/test/Transforms/EntryExitInstrumenter | |
| parent | c3d6a929fdd92fd06d4304675ade8d7210ee711a (diff) | |
| download | bcm5719-llvm-cee313d288a4faf0355d76fb6e0e927e211d08a5.tar.gz bcm5719-llvm-cee313d288a4faf0355d76fb6e0e927e211d08a5.zip | |
Revert "Temporarily Revert "Add basic loop fusion pass.""
The reversion apparently deleted the test/Transforms directory.
Will be re-reverting again.
llvm-svn: 358552
Diffstat (limited to 'llvm/test/Transforms/EntryExitInstrumenter')
| -rw-r--r-- | llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll | 43 | ||||
| -rw-r--r-- | llvm/test/Transforms/EntryExitInstrumenter/mcount.ll | 114 |
2 files changed, 157 insertions, 0 deletions
diff --git a/llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll b/llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll new file mode 100644 index 00000000000..64361db2be6 --- /dev/null +++ b/llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll @@ -0,0 +1,43 @@ +; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define i32 @f(i32 %x) #0 !dbg !7 { +entry: + %x.addr = alloca i32, align 4 + store i32 %x, i32* %x.addr, align 4 + ret i32 42, !dbg !12 + +; CHECK-LABEL: define i32 @f(i32 %x) +; CHECK: call i8* @llvm.returnaddress(i32 0), !dbg ![[ENTRYLOC:[0-9]+]] +; CHECK: call void @__cyg_profile_func_enter{{.*}}, !dbg ![[ENTRYLOC]] + +; CHECK: call i8* @llvm.returnaddress(i32 0), !dbg ![[EXITLOC:[0-9]+]] +; CHECK: call void @__cyg_profile_func_exit{{.*}}, !dbg ![[EXITLOC]] +; CHECK: ret i32 42, !dbg ![[EXITLOC]] +} + +; CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f" +; CHECK: ![[ENTRYLOC]] = !DILocation(line: 2, scope: ![[SP]]) +; CHECK: ![[EXITLOC]] = !DILocation(line: 4, column: 3, scope: ![[SP]]) + +attributes #0 = { "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 319007) (llvm/trunk 319050)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) +!1 = !DIFile(filename: "a.c", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 6.0.0 (trunk 319007) (llvm/trunk 319050)"} +!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) +!8 = !DISubroutineType(types: !9) +!9 = !{!10, !10} +!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!11 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 2, type: !10) +!12 = !DILocation(line: 4, column: 3, scope: !7) diff --git a/llvm/test/Transforms/EntryExitInstrumenter/mcount.ll b/llvm/test/Transforms/EntryExitInstrumenter/mcount.ll new file mode 100644 index 00000000000..30483606caf --- /dev/null +++ b/llvm/test/Transforms/EntryExitInstrumenter/mcount.ll @@ -0,0 +1,114 @@ +; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s + +; Running the passes twice should not result in more instrumentation. +; RUN: opt -passes="function(ee-instrument),function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument),function(post-inline-ee-instrument)" -S < %s | FileCheck %s + +target datalayout = "E-m:e-i64:64-n32:64" +target triple = "powerpc64-bgq-linux" + +define void @leaf_function() #0 { +entry: + ret void + +; CHECK-LABEL: define void @leaf_function() +; CHECK: entry: +; CHECK-NEXT: call void @mcount() +; CHECK-NEXT: %0 = call i8* @llvm.returnaddress(i32 0) +; CHECK-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* @leaf_function to i8*), i8* %0) +; CHECK-NEXT: %1 = call i8* @llvm.returnaddress(i32 0) +; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %1) +; CHECK-NEXT: ret void +} + + +define void @root_function() #0 { +entry: + call void @leaf_function() + ret void + +; CHECK-LABEL: define void @root_function() +; CHECK: entry: +; CHECK-NEXT: call void @mcount() + +; CHECK-NEXT %0 = call i8* @llvm.returnaddress(i32 0) +; CHECK-NEXT call void @__cyg_profile_func_enter(i8* bitcast (void ()* @root_function to i8*), i8* %0) + +; Entry and exit calls, inlined from @leaf_function() +; CHECK-NEXT %1 = call i8* @llvm.returnaddress(i32 0) +; CHECK-NEXT call void @__cyg_profile_func_enter(i8* bitcast (void ()* @leaf_function to i8*), i8* %1) +; CHECK-NEXT %2 = call i8* @llvm.returnaddress(i32 0) +; CHECK-NEXT call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %2) +; CHECK-NEXT %3 = call i8* @llvm.returnaddress(i32 0) + +; CHECK-NEXT call void @__cyg_profile_func_exit(i8* bitcast (void ()* @root_function to i8*), i8* %3) +; CHECK-NEXT ret void +} + + + +; The mcount function has many different names. + +define void @f1() #1 { entry: ret void } +; CHECK-LABEL: define void @f1 +; CHECK: call void @.mcount + +define void @f2() #2 { entry: ret void } +; CHECK-LABEL: define void @f2 +; CHECK: call void @"\01__gnu_mcount_nc" + +define void @f3() #3 { entry: ret void } +; CHECK-LABEL: define void @f3 +; CHECK: call void @"\01_mcount" + +define void @f4() #4 { entry: ret void } +; CHECK-LABEL: define void @f4 +; CHECK: call void @"\01mcount" + +define void @f5() #5 { entry: ret void } +; CHECK-LABEL: define void @f5 +; CHECK: call void @__mcount + +define void @f6() #6 { entry: ret void } +; CHECK-LABEL: define void @f6 +; CHECK: call void @_mcount + +define void @f7() #7 { entry: ret void } +; CHECK-LABEL: define void @f7 +; CHECK: call void @__cyg_profile_func_enter_bare + + +; Treat musttail calls as terminators; inserting between the musttail call and +; ret is not allowed. +declare i32* @tailcallee() +define i32* @tailcaller() #8 { + %1 = musttail call i32* @tailcallee() + ret i32* %1 +; CHECK-LABEL: define i32* @tailcaller +; CHECK: call void @__cyg_profile_func_exit +; CHECK: musttail call i32* @tailcallee +; CHECK: ret +} +define i8* @tailcaller2() #8 { + %1 = musttail call i32* @tailcallee() + %2 = bitcast i32* %1 to i8* + ret i8* %2 +; CHECK-LABEL: define i8* @tailcaller2 +; CHECK: call void @__cyg_profile_func_exit +; CHECK: musttail call i32* @tailcallee +; CHECK: bitcast +; CHECK: ret +} + +; The attributes are "consumed" when the instrumentation is inserted. +; CHECK: attributes +; CHECK-NOT: instrument-function + +attributes #0 = { "instrument-function-entry-inlined"="mcount" "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" } +attributes #1 = { "instrument-function-entry-inlined"=".mcount" } +attributes #2 = { "instrument-function-entry-inlined"="\01__gnu_mcount_nc" } +attributes #3 = { "instrument-function-entry-inlined"="\01_mcount" } +attributes #4 = { "instrument-function-entry-inlined"="\01mcount" } +attributes #5 = { "instrument-function-entry-inlined"="__mcount" } +attributes #6 = { "instrument-function-entry-inlined"="_mcount" } +attributes #7 = { "instrument-function-entry-inlined"="__cyg_profile_func_enter_bare" } +attributes #8 = { "instrument-function-exit"="__cyg_profile_func_exit" } |

