132 lines · plain
1; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY2; RUN: llvm-profdata merge %S/Inputs/landingpad.proftext -o %t.profdata3; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE4;5; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY6; RUN: llvm-profdata merge %S/Inputs/landingpad_entry.proftext -o %t2.profdata7; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE8target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"9target triple = "x86_64-unknown-linux-gnu"10 11@val = global i32 0, align 412@_ZTIi = external constant ptr13; GEN: $__llvm_profile_raw_version = comdat any14; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat15; GEN: @__profn_bar = private constant [3 x i8] c"bar"16; GEN: @__profn_foo = private constant [3 x i8] c"foo"17 18define i32 @bar(i32 %i) {19entry:20; GEN: entry:21; GEN: call void @llvm.instrprof.increment(ptr @__profn_bar, i64 {{[0-9]+}}, i32 2, i32 0)22 %rem = srem i32 %i, 323 %tobool = icmp ne i32 %rem, 024 br i1 %tobool, label %if.then, label %if.end25; USE: br i1 %tobool, label %if.then, label %if.end26; USE-SAME: !prof ![[BW_BAR_ENTRY:[0-9]+]]27 28if.then:29; GEN: if.then:30; GEN: call void @llvm.instrprof.increment(ptr @__profn_bar, i64 {{[0-9]+}}, i32 2, i32 1)31 %exception = call ptr @__cxa_allocate_exception(i64 4)32 store i32 %i, ptr %exception, align 1633 call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null)34 unreachable35 36if.end:37; GEN: if.end:38; GEN-NOT: call void @llvm.instrprof.increment39; GEN: ret i3240 ret i32 041}42 43declare ptr @__cxa_allocate_exception(i64)44 45declare void @__cxa_throw(ptr, ptr, ptr)46 47define i32 @foo(i32 %i) personality ptr @__gxx_personality_v0 {48entry:49; GEN: entry:50; NOTENTRY-NOT: call void @llvm.instrprof.increment51; ENTRY: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 0)52 %rem = srem i32 %i, 253 %tobool = icmp ne i32 %rem, 054 br i1 %tobool, label %if.then, label %if.end55; USE: br i1 %tobool, label %if.then, label %if.end56; USE-SAME: !prof ![[BW_FOO_ENTRY:[0-9]+]]57 58if.then:59; GEN: if.then:60; GEN-NOT: call void @llvm.instrprof.increment61 %mul = mul nsw i32 %i, 762 %call = invoke i32 @bar(i32 %mul)63 to label %invoke.cont unwind label %lpad64 65invoke.cont:66; GEN: invoke.cont:67; GEN: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 1)68 br label %if.end69 70lpad:71; GEN: lpad:72; GEN-NOT: call void @llvm.instrprof.increment73 %tmp = landingpad { ptr, i32 }74 catch ptr @_ZTIi75 %tmp1 = extractvalue { ptr, i32 } %tmp, 076 %tmp2 = extractvalue { ptr, i32 } %tmp, 177 br label %catch.dispatch78 79catch.dispatch:80; GEN: catch.dispatch:81; GEN-NOT: call void @llvm.instrprof.increment82 %tmp3 = call i32 @llvm.eh.typeid.for(ptr @_ZTIi)83 %matches = icmp eq i32 %tmp2, %tmp384 br i1 %matches, label %catch, label %eh.resume85; USE: br i1 %matches, label %catch, label %eh.resume86; USE-SAME: !prof ![[BW_CATCH_DISPATCH:[0-9]+]]87 88catch:89; GEN: catch:90; GEN: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 2)91 %tmp4 = call ptr @__cxa_begin_catch(ptr %tmp1)92 %tmp6 = load i32, ptr %tmp4, align 493 %tmp7 = load i32, ptr @val, align 494 %sub = sub nsw i32 %tmp7, %tmp695 store i32 %sub, ptr @val, align 496 call void @__cxa_end_catch()97 br label %try.cont98 99try.cont:100; GEN: try.cont:101; GEN-NOT: call void @llvm.instrprof.increment102 ret i32 -1103 104if.end:105; GEN: if.end:106; NOTENTRY: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 0)107; ENTRY-NOT: call void @llvm.instrprof.increment108 %tmp8 = load i32, ptr @val, align 4109 %add = add nsw i32 %tmp8, %i110 store i32 %add, ptr @val, align 4111 br label %try.cont112 113eh.resume:114; GEN: eh.resume:115; GEN: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 {{[0-9]+}}, i32 4, i32 3)116 %lpad.val = insertvalue { ptr, i32 } undef, ptr %tmp1, 0117 %lpad.val3 = insertvalue { ptr, i32 } %lpad.val, i32 %tmp2, 1118 resume { ptr, i32 } %lpad.val3119}120 121declare i32 @__gxx_personality_v0(...)122 123declare i32 @llvm.eh.typeid.for(ptr)124 125declare ptr @__cxa_begin_catch(ptr)126 127declare void @__cxa_end_catch()128 129; USE: ![[BW_BAR_ENTRY]] = !{!"branch_weights", i32 2, i32 1}130; USE: ![[BW_FOO_ENTRY]] = !{!"branch_weights", i32 3, i32 2}131; USE: ![[BW_CATCH_DISPATCH]] = !{!"branch_weights", i32 2, i32 0}132