Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Ankündigungen
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Unreachable Code

Morgan_L_
Einsteiger
1.204Aufrufe

I have inherited a code that has a lot of poor coding techniques.  In the ~50,000 lines of FORTRAN there is a significant amount of code that can never be reached.  In older mainframe compilers (e.g., FTN for CDC machines) the compiler cross-reference map would help to find such coding problems.  Is there  a way to use Intel's compiler to find such problems?

0 Kudos
5 Antworten
mecej4
Geehrter Beitragender III
1.204Aufrufe

The key is to distinguish between truly dead code and code that may be dead most of the time but, for certain input data, may be executed. The compiler and the linker are pretty good at removing dead code from the EXE. However, if you want to prune the source code itself, you can run the static analysis tool (not supplied with the Composer editions) on the source code or use Amplifier to profile your source code in one or more runs.

The compiler does generate a cross-reference listing for each program unit, if you ask it to. Similarly, the linker can produce a map. 

There are third party tools that specialize in such tasks, such as SPAG and Forcheck.

Morgan_L_
Einsteiger
1.204Aufrufe

We have found code that is truly dead, but not given a proper funeral.  We are sure there is a lot more of the same.

I have looked for the ability to generate a cross-reference map (variables and labels) but have not found it.  Can you direct me to the proper option to invoke?

I will check into the static analysis tool and the third party tools.  Thanks. 

mecej4
Geehrter Beitragender III
1.204Aufrufe

The /list option outputs a listing file (.lst) with a line-numbered listing, followed by a list of labels and references, a list of variables and references, and finally a list of the compiler options in effect. I do not remember the exact version of Ifort in which cross-reference lists were made available, but I remember some threads in which Dr. Fortran announced that it was in the works.

Steven_L_Intel1
Mitarbeiter
1.204Aufrufe

In some cases the optimization report will mention code it found to be unreachable.

TimP
Geehrter Beitragender III
1.204Aufrufe

And in some cases dead code isn't mentioned in opt-report, where it would be mentioned otherwise.

Antworten