cXprop Postpass optimization for TinyOS applications Summary Pluggable abstract domains

advertisement
cXprop
Postpass optimization for TinyOS applications
Nathan Cooprider
John Regehr
School of Computing, University of Utah
{coop,regehr}@cs.utah.edu
Summary
Creating TinyOS applications from generic
components
often
leads
to
applications
containing dead code and constant variables.
These unnecessarily consume SRAM and Flash
memory. We address the problem with cXprop, a
static-analysis-based post-processing tool for the
C code produced by the nesC compiler. cXprop
performs
"conditional
X
propagation,"
a
generalization of the well-known conditional
constant propagation algorithm where X is an
abstract value propagation domain supplied by
the user. cXprop is interprocedural and achieves
reasonable precision on pointer-rich codes. We
use novel concurrency abstractions to analyze
global state inside of TinyOS' restrictive
concurrency model. The dataflow information
produced by cXprop supports reduction in code
size
through
interprocedural
dead
code
elimination, and reduction in data size by finding
global variables that do not use their full
bitwidth. For example, state variables and
boolean flags often use an entire byte to store a
single bit. We have validated the code produced
by cXprop through random testing and by
dynamically checking its results against actual
executions. cXprop reduces application code
size on average by 9.2% for TinyOS applications.
It is available as open source software.
Features
●
●
●
●
Three modes of execution
● CP and DCE
● Program state assertion
● Dynamic state printing
Pluggable abstract domains
Handles concurrent code
● Three concurrency abstractions
Models pointers and structs
● limited array support at this time
Pluggable abstract domains
Value-set
Bitwise
Interval
Parity
Constant
Current results
Graph 1: The percentage of information collected by cXprop during its analysis with the different domains
Background Work
Patrick Cousot and Radhia Cousot. Abstract interpretation: A unified lattice
model for static analysis of programs by construction or approximation of
fixpoints. In Proc. of the 4th Symp. on Principles of Programming Languages
(POPL), pages 238–252, Los Angeles, CA, January 1977.
George C. Necula, Scott McPeak, S. P. Rahul, and Westley Weimer. CIL:
Intermediate language and tools for analysis and transformation of C
programs. In Proc. of the Intl. Conf. on Compiler Construction (CC), pages
213–228, Grenoble, France, April 2002.
average 9.2% code
size reduction
average 9.2% reduction in global
data size
Graph 2: Comparison of cXprop processed code size code size
from normal nesC compilation
Graph 3: Estimated savings in RAM through global bit
compression
Mark N.Wegman and F. Kenneth Zadeck. Constant propagation with
conditional branches. ACM Transactions on Programming Languages and
Systems (TOPLAS), 13(2):181–210, April 1991.
Tool components
Graph 4: Comparison of dynamic information known with static information known
Table 1: Comparison of analysis time between
different domains and a selection of
benchmarks. The other tables are sorted in order
of ascending analysis time, so benchmarks not
in this table could be interpolated
Future work
The abstract interpreter is made up of several
parts. However, there is a clean interface for the
abstract domains. This makes implementing new
domains straightforward.
cXprop provides a novel concurrency model for
analyzing global variables in the presence of
interrupts and atomic sections. Atomic sections
are connected in the control flow graph.
We are continuing to improve and enhance
cXprop. We plan to continue to improve the
speed, precision, and expressiveness of the
analysis while looking for new ways to apply the
information gained by cXprop.
Acknowledgments
“spaghetti” concurrency mode
This work is supported by National Science
Foundation CAREER Award CNS-0448047
http://www.cs.utah.edu/~coop/research/cxprop
Download