brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · d69768d Raw
95 lines · plain
1; REQUIRES: asserts && x86_64-linux2; Check that the profile annotator works: we hit an exit and non-zero paths to3; already visited blocks count as taken (i.e. the flow continues through them).4;5; RUN: split-file %s %t6; RUN: llvm-ctxprof-util fromYAML --input=%t/profile_ok.yaml --output=%t/profile_ok.ctxprofdata7; RUN: llvm-ctxprof-util fromYAML --input=%t/profile_pump.yaml --output=%t/profile_pump.ctxprofdata8; RUN: llvm-ctxprof-util fromYAML --input=%t/profile_unreachable.yaml --output=%t/profile_unreachable.ctxprofdata9;10; RUN: opt -passes=ctx-prof-flatten %t/example_ok.ll -ctx-profile-force-is-specialized -use-ctx-profile=%t/profile_ok.ctxprofdata -S -o - | FileCheck %s11; RUN: not --crash opt -passes=ctx-prof-flatten %t/message_pump.ll -ctx-profile-force-is-specialized -use-ctx-profile=%t/profile_pump.ctxprofdata -S 2>&1 | FileCheck %s --check-prefix=ASSERTION12; RUN: not --crash opt -passes=ctx-prof-flatten %t/unreachable.ll -ctx-profile-force-is-specialized -use-ctx-profile=%t/profile_unreachable.ctxprofdata -S 2>&1 | FileCheck %s --check-prefix=ASSERTION13 14; CHECK: br i1 %x, label %b1, label %exit, !prof ![[PROF1:[0-9]+]]15; CHECK: br i1 %y, label %blk, label %exit, !prof ![[PROF2:[0-9]+]]16; CHECK: ![[PROF1]] = !{!"branch_weights", i32 2, i32 2}17; CHECK: ![[PROF2]] = !{!"branch_weights", i32 0, i32 2}18; ASSERTION: Assertion `allTakenPathsExit()19 20; b1->exit is the only way out from b1, but the exit block would have been21; already visited from blk. That should not result in an assertion, though.22;--- example_ok.ll23define void @foo(i32 %t) !guid !0 {24entry:25  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 0)26  br label %blk27blk:28  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 1)29  %x = icmp eq i32 %t, 030  br i1 %x, label %b1, label %exit31b1:32  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 2)33  %y = icmp eq i32 %t, 034  br i1 %y, label %blk, label %exit35exit:36  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 3)37  ret void38}39!0 = !{i64 1234}40 41;--- profile_ok.yaml42Contexts:43  - Guid: 1234 44    TotalRootEntryCount: 245    Counters: [2, 2, 1, 2]46 47;--- message_pump.ll48; This is a message pump: the loop never exits. This should result in an49; assertion because we can't reach an exit BB50 51define void @foo(i32 %t) !guid !0 {52entry:53  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 0)  54  br label %blk55blk:56  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 1)57  %x = icmp eq i32 %t, 058  br i1 %x, label %blk, label %exit59exit:60  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 2)61  ret void62}63!0 = !{i64 1234}64 65;--- profile_pump.yaml66Contexts:67  - Guid: 123468    TotalRootEntryCount: 269    Counters: [2, 10, 0]70 71;--- unreachable.ll72; An unreachable block is reached, that's an error73define void @foo(i32 %t) !guid !0 {74entry:75  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 0)76  br label %blk77blk:78  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 1)79  %x = icmp eq i32 %t, 080  br i1 %x, label %b1, label %exit81b1:82  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 2)83  unreachable84exit:85  call void @llvm.instrprof.increment(ptr @foo, i64 42, i32 42, i32 3)86  ret void87}88!0 = !{i64 1234}89 90;--- profile_unreachable.yaml91Contexts:92  - Guid: 123493    TotalRootEntryCount: 294    Counters: [2, 1, 1, 2]95