[pypy-svn] r40099 - in pypy/dist/pypy: config doc/config translator/c translator/c/test translator/llvm
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Mar 8 22:22:04 CET 2007
Author: cfbolz
Date: Thu Mar 8 22:22:03 2007
New Revision: 40099
Added:
pypy/dist/pypy/doc/config/translation.noprofopt.txt
Modified:
pypy/dist/pypy/config/translationoption.py
pypy/dist/pypy/translator/c/genc.py
pypy/dist/pypy/translator/c/test/test_standalone.py
pypy/dist/pypy/translator/llvm/buildllvm.py
Log:
add a --noprofopt option to disable profile based optimizations again
Modified: pypy/dist/pypy/config/translationoption.py
==============================================================================
--- pypy/dist/pypy/config/translationoption.py (original)
+++ pypy/dist/pypy/config/translationoption.py Thu Mar 8 22:22:03 2007
@@ -56,6 +56,8 @@
StrOption("cc", "Specify compiler to use for compiling generated C", cmdline="--cc"),
StrOption("profopt", "Specify profile based optimization script",
cmdline="--profopt"),
+ BoolOption("noprofopt", "Don't use profile based optimization",
+ default=False, cmdline="--no-profopt", negation=False),
BoolOption("instrument", "internal: turn instrumentation on",
default=False, cmdline=None),
Added: pypy/dist/pypy/doc/config/translation.noprofopt.txt
==============================================================================
Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py (original)
+++ pypy/dist/pypy/translator/c/genc.py Thu Mar 8 22:22:03 2007
@@ -229,7 +229,7 @@
profbased = self.config.translation.instrumentctl
else:
profopt = self.config.translation.profopt
- if profopt is not None:
+ if profopt is not None and not self.config.translation.noprofopt:
profbased = (ProfOpt, profopt)
return CCompiler(
Modified: pypy/dist/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_standalone.py (original)
+++ pypy/dist/pypy/translator/c/test/test_standalone.py Thu Mar 8 22:22:03 2007
@@ -135,3 +135,32 @@
cbuilder.compile()
data = cbuilder.cmdexec('hi there')
assert map(float, data.split()) == [0.0, 0.0]
+
+def test_profopt():
+ if sys.platform == 'win32':
+ py.test.skip("instrumentation support is unix only for now")
+ def add(a,b):
+ return a + b - b + b - b + b - b + b - b + b - b + b - b + b
+ def entry_point(argv):
+ tot = 0
+ x = int(argv[1])
+ while x > 0:
+ tot = add(tot, x)
+ x -= 1
+ os.write(1, str(tot))
+ return 0
+ from pypy.translator.interactive import Translation
+ # XXX this is mostly a "does not crash option"
+ t = Translation(entry_point, backend='c', standalone=True, profopt="")
+ # no counters
+ t.backendopt()
+ exe = t.compile()
+ out = py.process.cmdexec("%s 500" % exe)
+ assert int(out) == 500*501/2
+ t = Translation(entry_point, backend='c', standalone=True, profopt="",
+ noprofopt=True)
+ # no counters
+ t.backendopt()
+ exe = t.compile()
+ out = py.process.cmdexec("%s 500" % exe)
+ assert int(out) == 500*501/2
Modified: pypy/dist/pypy/translator/llvm/buildllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/buildllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/buildllvm.py Thu Mar 8 22:22:03 2007
@@ -200,7 +200,8 @@
object_files.append("%s.o" % b)
else:
self.cmds.append("llc %s.bc -march=c -f -o %s.c" % (b, b))
- if self.genllvm.config.translation.profopt is not None:
+ if (self.genllvm.config.translation.profopt is not None and
+ not self.genllvm.config.translation.noprofopt):
cmd = "gcc -fprofile-generate %s.c -c -O3 -pipe -o %s.o" % (b, b)
self.cmds.append(cmd)
cmd = "gcc -fprofile-generate %s.o %s %s -lm -pipe -o %s_gen" % \
More information about the Pypy-commit
mailing list