Merging r218054:
------------------------------------------------------------------------
r218054 | kongyi | 2014-09-18 16:50:47 +0100 (Thu, 18 Sep 2014) | 9 lines
Make the use of Perf optional
Do not try to automatically detect and use perf on Linux, thus giving
user more control of which tool to use.
Also this fixes the mistake that Perf wasn't used when not using
user mode emulation.
------------------------------------------------------------------------
llvm-svn: 224573
diff --git a/tools/Makefile b/tools/Makefile
index 01cf692..15cf009 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -8,20 +8,21 @@
all:: timeit-target
endif
-ifeq ($(TARGET_OS),Linux)
-all:: ctimeit
-timeit: timeit.sh
- cp -f $< $@
- chmod u+x $@
-ctimeit: timeit.c
- $(ORIGINAL_CC) $(CFLAGS) -O3 -o $@ $<
-else
+ifndef USE_PERF
timeit: timeit.c
$(ORIGINAL_CC) $(CFLAGS) -O3 -o $@ $<
-endif
timeit-target: timeit.c
$(LD_ENV_OVERRIDES) $(LCC) -o $@ $< $(LDFLAGS) $(CFLAGS) $(TARGET_FLAGS) -O3
+else
+timeit: timeit.sh
+ cp -f $< $@
+ chmod u+x $@
+
+timeit-target: timeit.sh
+ cp -f $< $@
+ chmod u+x $@
+endif
fpcmp: fpcmp.c
$(ORIGINAL_CC) $(CFLAGS) -O3 -o $@ $<
diff --git a/tools/timeit.sh b/tools/timeit.sh
index 0cbfc29..294ec17 100644
--- a/tools/timeit.sh
+++ b/tools/timeit.sh
@@ -1,16 +1,6 @@
#! /bin/bash
# A wrapper over perf to provide similar functionality to timeit.c
-DEPENDS="perf"
-
-# Fallback to ctimeit if dependencies are not met
-for cmd in ${DEPENDS} ; do
- if ! command -v ${cmd} &> /dev/null ; then
- $(dirname $0)/ctimeit $@
- exit $?
- fi
-done
-
REPORT=/dev/stderr
INPUT=/dev/stdin
OUTPUT=/dev/stdout
@@ -26,7 +16,7 @@
shift 2
done
-perf stat -o stats $@ < $INPUT > $OUTPUT
+perf stat -o $PERFSTAT $@ < $INPUT &> $OUTPUT
EXITCODE=$?