Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Unreachable Code

Morgan_L_
Beginner
566 Views

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 Replies
mecej4
Honored Contributor III
566 Views

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.

0 Kudos
Morgan_L_
Beginner
566 Views

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. 

0 Kudos
mecej4
Honored Contributor III
566 Views

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.

0 Kudos
Steven_L_Intel1
Employee
566 Views

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

0 Kudos
TimP
Honored Contributor III
566 Views

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

0 Kudos
Reply