[compiler-rt] [compiler-rt][test]Simplify instrprof-vtable-value-prof.cpp (PR #97245)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 30 18:12:28 PDT 2024


https://github.com/minglotus-6 updated https://github.com/llvm/llvm-project/pull/97245

>From e96419483327fc84bc8d87e591029702a694e827 Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Sun, 30 Jun 2024 18:03:39 -0700
Subject: [PATCH 1/2] [compiler-rt][test]Simplify
 instrprof-vtable-value-prof.cpp

---
 .../test/profile/Linux/instrprof-vtable-value-prof.cpp    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp
index efb24751da5ff..5d3ec9557beff 100644
--- a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp
+++ b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp
@@ -165,8 +165,8 @@
 //
 // IR: [[MERGE0]]:
 // IR:    [[RES2:%.*]] = phi i32 [ [[RES1]], %[[MERGE1]] ], [ [[RESBB1]], %[[BB1]] ]
-#include <cstdio>
-#include <cstdlib>
+
+#include <stdlib.h>
 class Base {
 public:
   virtual int func(int a, int b) = 0;
@@ -195,8 +195,9 @@ __attribute__((noinline)) Base *createType(int a) {
     base = new Derived2();
   return base;
 }
+
+static volatile int sum = 0;
 int main(int argc, char **argv) {
-  int sum = 0;
   for (int i = 0; i < 1000; i++) {
     int a = rand();
     int b = rand();
@@ -206,6 +207,5 @@ int main(int argc, char **argv) {
 
     delete ptr;
   }
-  printf("sum is %d\n", sum);
   return 0;
 }

>From 0d7a44bba2576dd362a4ebe0774ae639c07d1d55 Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Sun, 30 Jun 2024 18:11:51 -0700
Subject: [PATCH 2/2] add printf back

---
 .../test/profile/Linux/instrprof-vtable-value-prof.cpp        | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp
index 5d3ec9557beff..24a96a227393a 100644
--- a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp
+++ b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp
@@ -166,6 +166,7 @@
 // IR: [[MERGE0]]:
 // IR:    [[RES2:%.*]] = phi i32 [ [[RES1]], %[[MERGE1]] ], [ [[RESBB1]], %[[BB1]] ]
 
+#include <stdio.h>
 #include <stdlib.h>
 class Base {
 public:
@@ -196,8 +197,8 @@ __attribute__((noinline)) Base *createType(int a) {
   return base;
 }
 
-static volatile int sum = 0;
 int main(int argc, char **argv) {
+  int sum = 0;
   for (int i = 0; i < 1000; i++) {
     int a = rand();
     int b = rand();
@@ -207,5 +208,6 @@ int main(int argc, char **argv) {
 
     delete ptr;
   }
+  printf("sum is %d\n", sum);
   return 0;
 }



More information about the llvm-commits mailing list