From 793d4a8467841aed21564bf6704421e8f83431fb Mon Sep 17 00:00:00 2001 From: Andreas Neustifter Date: Wed, 2 Sep 2009 14:24:08 +0000 Subject: [PATCH] Changed profiling-tool-chain.ll test to use optimal-edge-profiling instead of edge-profiling, this is more useful since the loading of the optimal-edge-profiling is more complicated. The edge-profiling is tested in edge-profiling.ll where only the instrumentation is tested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80791 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Analysis/Profiling/edge-profiling.ll | 138 ++++++++++++++++++ .../Profiling/profiling-tool-chain.ll | 33 ++++- 2 files changed, 164 insertions(+), 7 deletions(-) create mode 100644 test/Analysis/Profiling/edge-profiling.ll diff --git a/test/Analysis/Profiling/edge-profiling.ll b/test/Analysis/Profiling/edge-profiling.ll new file mode 100644 index 00000000000..0d584469503 --- /dev/null +++ b/test/Analysis/Profiling/edge-profiling.ll @@ -0,0 +1,138 @@ +; RUN: llvm-as < %s | opt -insert-edge-profiling | llvm-dis | tee %t1 | FileCheck %s + +; ModuleID = '' + +@.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1] +@.str1 = private constant [6 x i8] c"franz\00", align 1 ; <[6 x i8]*> [#uses=1] +@.str2 = private constant [9 x i8] c"argc > 2\00", align 1 ; <[9 x i8]*> [#uses=1] +@.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1] +@.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1] +@.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1] +; CHECK:@EdgeProfCounters +; CHECK:[19 x i32] +; CHECK:zeroinitializer + +define void @oneblock() nounwind { +entry: +; CHECK:entry: +; CHECK:%OldFuncCounter +; CHECK:load +; CHECK:getelementptr +; CHECK:@EdgeProfCounters +; CHECK:i32 0 +; CHECK:i32 0 +; CHECK:%NewFuncCounter +; CHECK:add +; CHECK:%OldFuncCounter +; CHECK:store +; CHECK:%NewFuncCounter +; CHECK:getelementptr +; CHECK:@EdgeProfCounters + %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; [#uses=0] + ret void +} + +declare i32 @puts(i8*) + +define i32 @main(i32 %argc, i8** %argv) nounwind { +entry: +; CHECK:entry: + %argc_addr = alloca i32 ; [#uses=4] + %argv_addr = alloca i8** ; [#uses=1] + %retval = alloca i32 ; [#uses=2] + %j = alloca i32 ; [#uses=4] + %i = alloca i32 ; [#uses=4] + %0 = alloca i32 ; [#uses=2] +; CHECK:call +; CHECK:@llvm_start_edge_profiling +; CHECK:@EdgeProfCounters + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i32 %argc, i32* %argc_addr + store i8** %argv, i8*** %argv_addr + store i32 0, i32* %i, align 4 + br label %bb10 + +bb: ; preds = %bb10 +; CHECK:bb: + %1 = load i32* %argc_addr, align 4 ; [#uses=1] + %2 = icmp sgt i32 %1, 1 ; [#uses=1] + br i1 %2, label %bb1, label %bb8 + +bb1: ; preds = %bb +; CHECK:bb1: + store i32 0, i32* %j, align 4 + br label %bb6 + +bb2: ; preds = %bb6 +; CHECK:bb2: + %3 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i64 0, i64 0)) nounwind ; [#uses=0] + %4 = load i32* %argc_addr, align 4 ; [#uses=1] + %5 = icmp sgt i32 %4, 2 ; [#uses=1] + br i1 %5, label %bb3, label %bb4 + +bb3: ; preds = %bb2 +; CHECK:bb3: + %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; [#uses=0] + br label %bb5 + +bb4: ; preds = %bb2 +; CHECK:bb4: + %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; [#uses=0] + br label %bb11 + +bb5: ; preds = %bb3 +; CHECK:bb5: + %8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0)) nounwind ; [#uses=0] + %9 = load i32* %j, align 4 ; [#uses=1] + %10 = add nsw i32 %9, 1 ; [#uses=1] + store i32 %10, i32* %j, align 4 + br label %bb6 + +bb6: ; preds = %bb5, %bb1 +; CHECK:bb6: + %11 = load i32* %j, align 4 ; [#uses=1] + %12 = load i32* %argc_addr, align 4 ; [#uses=1] + %13 = icmp slt i32 %11, %12 ; [#uses=1] + br i1 %13, label %bb2, label %bb7 + +bb7: ; preds = %bb6 +; CHECK:bb7: + br label %bb9 + +bb8: ; preds = %bb +; CHECK:bb8: + %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; [#uses=0] + br label %bb9 + +bb9: ; preds = %bb8, %bb7 +; CHECK:bb9: + %15 = load i32* %i, align 4 ; [#uses=1] + %16 = add nsw i32 %15, 1 ; [#uses=1] + store i32 %16, i32* %i, align 4 + br label %bb10 + +bb10: ; preds = %bb9, %entry +; CHECK:bb10: + %17 = load i32* %i, align 4 ; [#uses=1] + %18 = icmp ne i32 %17, 3 ; [#uses=1] + br i1 %18, label %bb, label %bb11 +; CHECK:br +; CHECK:label %bb10.bb11_crit_edge + +; CHECK:bb10.bb11_crit_edge: +; CHECK:br +; CHECK:label %bb11 + +bb11: ; preds = %bb10, %bb4 +; CHECK:bb11: + call void @oneblock() nounwind + store i32 0, i32* %0, align 4 + %19 = load i32* %0, align 4 ; [#uses=1] + store i32 %19, i32* %retval, align 4 + br label %return + +return: ; preds = %bb11 +; CHECK:return: + %retval12 = load i32* %retval ; [#uses=1] + ret i32 %retval12 +} diff --git a/test/Analysis/Profiling/profiling-tool-chain.ll b/test/Analysis/Profiling/profiling-tool-chain.ll index 0f95c17ef29..ba15d5681c1 100644 --- a/test/Analysis/Profiling/profiling-tool-chain.ll +++ b/test/Analysis/Profiling/profiling-tool-chain.ll @@ -1,11 +1,10 @@ ; RUN: llvm-as %s -o %t1 -; RUN: opt %t1 -insert-edge-profiling -o %t2 +; RUN: opt %t1 -insert-optimal-edge-profiling -o %t2 ; RUN: llvm-dis < %t2 | FileCheck --check-prefix=INST %s ; RUN: rm -f llvmprof.out ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t2 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t2 1 2 ; RUN: llvm-prof -print-all-code %t1 | FileCheck --check-prefix=PROF %s -; RUN: rm llvmprof.out ; PROF: 1. 2/4 oneblock ; PROF: 2. 2/4 main @@ -32,9 +31,29 @@ @.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1] @.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1] @.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1] -; INST:@EdgeProfCounters -; INST:[19 x i32] -; INST:zeroinitializer +; INST:@OptEdgeProfCounters +; INST:[21 x i32] +; INST:[i32 0, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 0, +; INST:i32 0, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 0, +; INST:i32 0, +; INST:i32 -1, +; INST:i32 -1, +; INST:i32 0, +; INST:i32 -1, +; INST:i32 -1] ; PROF:;;; %oneblock called 2 times. ; PROF:;;; @@ -61,8 +80,8 @@ entry: %i = alloca i32 ; [#uses=4] %0 = alloca i32 ; [#uses=2] ; INST:call -; INST:@llvm_start_edge_profiling -; INST:@EdgeProfCounters +; INST:@llvm_start_opt_edge_profiling +; INST:@OptEdgeProfCounters %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] store i32 %argc, i32* %argc_addr store i8** %argv, i8*** %argv_addr