Real-Time Systems

, Volume 45, Issue 1–2, pp 72–105 | Cite as

Transforming flow information during code optimization for timing analysis

  • Raimund Kirner
  • Peter Puschner
  • Adrian Prantl
Open Access


The steadily growing embedded-systems market comprises many application domains in which real-time constraints must be satisfied. To guarantee that these constraints are met, the analysis of the worst-case execution time (WCET) of software components is mandatory. In general WCET analysis needs additional control-flow information, which may be provided manually by the user or calculated automatically by program analysis. For flexibility and simplicity reasons it is desirable to specify the flow information at the same level at which the program is developed, i.e., at the source level. In contrast, to obtain precise WCET bounds the WCET analysis has to be performed at machine-code level. Mapping and transforming the flow information from the source-level down to the machine code, where flow information is used in the WCET analysis, is challenging, even more so if the compiler generates highly optimized code.

In this article we present a method for transforming flow information from source code to machine code. To obtain a mapping that is safe and accurate, flow information is transformed in parallel to code transformations performed by an optimizing compiler. This mapping is not only useful for transforming manual code annotations but also if platform-independent flow information is automatically calculated at the source level.

We show that our method can be applied to every type of semantics-preserving code transformation. The precision of this flow-information transformation allows its users to calculate tight WCET bounds.


Worst-case execution time analysis Real-time languages Compiler optimizations Code transformation Abstract interpretation Graph transformation 



Worst-case execution time


Best-case execution time


Implicit path enumeration technique


Control-flow graph with loop-scope information


  1. Allen R, Kennedy K (2002) Optimizing compilers for modern architectures. Morgan Kaufmann, San Mateo Google Scholar
  2. Ball T, Larus JR (1996) Efficient path profiling. In: Proc IEEE international symposium on microarchitecture, pp 46–57 Google Scholar
  3. Cullmann C, Martin F (2007) Data-flow based detection of loop bounds. In: Proc 7th international workshop on worst-case execution time analysis, Pisa, Italy Google Scholar
  4. Drewes F, Hoffmann B, Plump D (2002) Hierarchical graph transformation. J Comput Syst Sci 64:249–283. Short version in Proc FOSSACS 2000, LNCS, vol 1784 zbMATHCrossRefMathSciNetGoogle Scholar
  5. Engblom J (1997) Worst-case execution time analysis for optimized code. Master’s thesis, Uppsala University, Uppsala, Sweden Google Scholar
  6. Engblom J, Ermedahl A, Altenbernd P (1998) Facilitating worst-case execution time analysis for optimized code. In: Proc 10th Euromicro real-time workshop, Berlin, Germany Google Scholar
  7. Ferdinand C, Heckmann R, Langenbach M, Martin F, Schmidt M, Theiling H, Thesing S, Wilhelm R (2001) Reliable and precise WCET determination for a real-life processor. In: Proc of the 1st international workshop on embedded software (EMSOFT 2001), Tahoe City, CA, USA, pp 469–485 Google Scholar
  8. Gustafsson J, Ermedahl A (1998) Automatic derivation of path and loop annotations in object-oriented real-time programs. Parallel Distrib Comput Pract 1(2) Google Scholar
  9. Gustafsson J, Ermedahl A, Sandberg C, Lisper B (2006) Automatic derivation of loop bounds and infeasible paths for WCET analysis using abstract execution. In: Proc 27th IEEE real-time systems symposium (RTSS 2006), Rio de Janeiro, Brazil Google Scholar
  10. Healy CA, Arnold RD, Mueller F, Whalley D, Harmon MG (1999) Bounding pipeline and instruction cache performance. IEEE Trans Comput 48(1) Google Scholar
  11. Healy CA, Sjödin M, Rustagi V, Whalley D, van Engelen R (2000) Supporting timing analysis by automatic bounding of loop iterations. Real-Time Syst 18:121–148 CrossRefGoogle Scholar
  12. Healy CA, Whalley DB (2002) Automatic detection and exploitation of branch constraints for timing analysis. IEEE Trans Softw Eng 28:763–781 CrossRefGoogle Scholar
  13. INFINEON (2000) C167CR derivatives. 16-bit single-chip microcontroller. User’s manual, Version 3.0. Infineon Technologies AG Google Scholar
  14. Jaramillo CI, Gupta R, Soffa ML (1998) Capturing the effects of code improving transformations. In: Proc international conference on parallel architectures and compilation techniques (PACT’98), Paris, France, pp 118–123 Google Scholar
  15. Kirner R (2002) The programming language wcetC. Technical Report 02/2002, Technische Universität Wien, Institut für Technische Informatik, Treitlstr 1-3/182-1, 1040 Vienna, Austria Google Scholar
  16. Kirner R (2003) Extending optimising compilation to support worst-case execution time analysis. PhD thesis, Technische Universität Wien, Vienna, Austria Google Scholar
  17. Kirner R (2008) Compiler support for timing analysis of optimized code: precise timing analysis of machine code with convenient annotation of source code. VDM Verlag, Saarbrücken Google Scholar
  18. Kirner R, Puschner P (2001) Transformation of path information for WCET analysis during compilation. In: Proc 13th IEEE Euromicro conference on real-time systems, Delft, The Netherlands, pp 29–36 Google Scholar
  19. Kirner R, Puschner P (2003) Timing analysis of optimised code. In: Proc 8th IEEE international workshop on object-oriented real-time dependable systems (WORDS 2003), Guadalajara, Mexico, pp 100–105 Google Scholar
  20. Kirner R, Knoop J, Prantl A, Schordan M, Wenzel I (2007) WCET analysis: the annotation language challenge. In: Proc 7th international workshop on worst-case execution time analysis, Pisa, Italy, pp 83–99 Google Scholar
  21. Kirner R, Kadlec A, Puschner P, Prantl A, Schordan M, Knoop J (2008) Towards a common WCET annotation language: essential ingredients. In: Proc 8th international workshop on worst-case execution time analysis, Prague, Czech Republic, pp 53–65 Google Scholar
  22. Li Y-TS, Malik S (1995) Performance analysis of embedded software using implicit path enumeration. In: Proc 32nd ACM/IEEE design automation conference, pp 456–461 Google Scholar
  23. Lim S-S, Bae YH, Jang GT, Rhee B-D, Min SL, Park CY, Shin H, Park K, Moon S-M, Kim C-S (1995) An accurate worst case timing analysis for RISC processors. Softw Eng 21(7):593–604 CrossRefGoogle Scholar
  24. Lim S-S, Kim J, Min SL (1998) A worst case timing analysis technique for optimized programs. In: Proc 5th international conference on real-time computing systems and applications (RTCSA), Hiroshima, Japan, pp 151–157 Google Scholar
  25. Lokuciejewski P (2007) A WCET-aware compiler. Design, concepts and realization. VDM Verlag, Saarbrücken Google Scholar
  26. Lokuciejewski P, Marwedel P (2009) Combining worst-case timing models, loop unrolling, and static loop analysis for WCET minimization. In: Proc 21st Euromicro conference on real-time systems, Dublin, Ireland Google Scholar
  27. Lokuciejewski P, Falk H, Marwedel P, Theiling H (2008) WCET-driven, code-size critical procedure cloning. In: Proc 11th international workshop on software and compilers for embedded systems, Munich, Germany, pp 21–30 Google Scholar
  28. Lokuciejewski P, Cordes D, Falk H, Marwedel P (2009) A fast and precise static loop analysis based on abstract interpretation program slicing and polytope models. In: Proc international symposium on code generation and optimization, Seattle, USA Google Scholar
  29. Marlowe TJ, Masticola SP (1992) Safe optimization for hard real-time programming. In: Proc 2nd international conference on systems integration (ICSI), pp 436–445 Google Scholar
  30. Mok AK, Amerasinghe P, Chen M, Tantisirivat K (1989) Evaluating tight execution time bounds of programs by annotations. In: Proc 6th IEEE workshop on real-time operating systems and software, Pittsburgh, PA, USA, pp 74–80 Google Scholar
  31. MRTC Benchmarks (2009) Mälardalen research and technology centre WCET benchmarks. Web page Accessed online in January 2010
  32. Muchnick SS (1997) Advanced compiler design & implementation. Morgan Kaufmann, San Mateo Google Scholar
  33. Park CY (1993) Predicting program execution times by analyzing static and dynamic program paths. Real-Time Syst 5(1):31–62 CrossRefGoogle Scholar
  34. Park CY, Shaw AC (1991) Experiments with a program timing tool based on a source-level timing schema. Computer 24(5):48–57 CrossRefGoogle Scholar
  35. Pop S, Cohen A, Bastoul C, Girbal S, Silber GA, Vasilache N (2006) GRAPHITE: Loop optimizations based on the polyhedral model for GCC. In: Proc 4th GCC developer’s summit, pp 179–198 Google Scholar
  36. Prantl A (2007a) The CoSTA transformer: integrating optimizing compilation and WCET flow facts transformation. In: Proceedings 14 Kolloquium Programmiersprachen und Grundlagen der Programmierung (KPS’07) Google Scholar
  37. Prantl A (2007b) Source-to-source transformations for WCET analysis: the CoSTA approach. In: Proc 24. Workshop der GI-Fachgruppe Programmiersprachen und Rechenkonzepte, Christian-Albrechts-Universität zu Kiel, Bad Honnef, Germany Google Scholar
  38. Prantl A, Schordan M, Knoop J (2008) TuBound—a conceptually new tool for worst-case execution time analysis. In: Proc 8th international workshop on worst-case execution time analysis, Prague, Czech Republic Google Scholar
  39. Puschner P, Schedl AV (1997) Computing maximum task execution times—a graph-based approach. Real-Time Syst 13:67–91 CrossRefGoogle Scholar
  40. Quinlan DJ, Schordan M, Miller B, Kowarschik M (2004) Parallel object-oriented framework optimization. Concurr Comput Pract Exper 16(2–3):293–302 CrossRefGoogle Scholar
  41. Ramalingam G (2002) On loops, dominators, and dominance frontiers. ACM Trans Program Lang Syst 24(5):455–490 CrossRefGoogle Scholar
  42. Schulte D (2007) Flow Facts für WCET-optimierende Compiler: Modellierung und Transformation. VDM Verlag, Saarbrücken Google Scholar
  43. Vrchoticky A (1994) Compilation support for fine-grained execution time analysis. In: Proc ACM SIGPLAN workshop on language, compiler and tool support for real-time systems, Orlando, FL Google Scholar
  44. Wilhelm R, Engblom J, Ermedahl A, Holsti N, Thesing S, Whalley D, Bernat G, Ferdinand C, Heckman R, Mitra T, Mueller F, Puaut I, Puschner P, Staschulat J, Stenstrom P (2008) The worst-case execution time problem—overview of methods and survey of tools. ACM Trans Embed Comput Syst (TECS) 7(3) Google Scholar
  45. Younis MF, Marlowe TJ, Tsai G, Stoyenko AD (1996) Toward compiler optimization of distributed real-time processes. In: Proc 2nd international conference on engineering of complex computer systems, pp 35–42 Google Scholar

Copyright information

© The Author(s) 2010

Authors and Affiliations

  1. 1.Institut für Technische InformatikVienna University of TechnologyViennaAustria
  2. 2.Institut für ComputersprachenVienna University of TechnologyViennaAustria

Personalised recommendations