[compiler-rt] r307864 - [PGO] Add a test for 2-deep loop nest
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 12 16:28:45 PDT 2017
Author: davidxl
Date: Wed Jul 12 16:28:45 2017
New Revision: 307864
URL: http://llvm.org/viewvc/llvm-project?rev=307864&view=rev
Log:
[PGO] Add a test for 2-deep loop nest
Added:
compiler-rt/trunk/test/profile/Linux/counter_promo_nest.c
Added: compiler-rt/trunk/test/profile/Linux/counter_promo_nest.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Linux/counter_promo_nest.c?rev=307864&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/Linux/counter_promo_nest.c (added)
+++ compiler-rt/trunk/test/profile/Linux/counter_promo_nest.c Wed Jul 12 16:28:45 2017
@@ -0,0 +1,51 @@
+// RUN: rm -fr %t.promo.prof
+// RUN: rm -fr %t.nopromo.prof
+// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen -O2 %s
+// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen.ll -emit-llvm -S -O2 %s
+// RUN: cat %t.promo.gen.ll | FileCheck --check-prefix=PROMO %s
+// RUN: %run %t.promo.gen
+// RUN: llvm-profdata merge -o %t.promo.profdata %t.promo.prof/
+// RUN: llvm-profdata show --counts --all-functions %t.promo.profdata > %t.promo.dump
+// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -o %t.nopromo.gen -O2 %s
+// RUN: %run %t.nopromo.gen
+// RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/
+// RUN: llvm-profdata show --counts --all-functions %t.nopromo.profdata > %t.nopromo.dump
+// RUN: diff %t.promo.profdata %t.nopromo.profdata
+int g;
+__attribute__((noinline)) void bar() {
+ g++;
+}
+
+extern int printf(const char*,...);
+
+int c = 10;
+
+int main()
+// PROMO-LABEL: @main
+// PROMO: load{{.*}}@__profc_main{{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_main{{.*}}
+// PROMO-NEXT: load{{.*}}@__profc_main{{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_main{{.*}}
+// PROMO-NEXT: load{{.*}}@__profc_main{{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_main{{.*}}
+{
+ int i, j, k;
+
+ g = 0;
+ for (i = 0; i < c; i++)
+ for (j = 0; j < c; j++)
+ for (k = 0; k < c; k++)
+ bar();
+
+ for (i = 0; i < c; i++)
+ for (j = 0; j < 10*c;j++)
+ bar();
+
+ for (i = 0; i < 100*c; i++)
+ bar();
+
+ return 0;
+}
More information about the llvm-commits
mailing list