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

Removing "dead variables" and "dead code"

cjosefy
初學者
1,397 檢視
I'm using 8.1.023.
I have code that includes SCCS keywords. After compiling, I then search for the keyword string @(#) in the object code. When compiling with -g, the string is there. When compiling with no options it isn't there (not surprising since O2 removes dead storage). However, when I specify O0 without using -g, the string still is not in the object code.
Does the Intel compiler remove dead storage even when optimizations are turned off with O0?
Thanks,
Chris Josefy
0 積分
10 回應
Steven_L_Intel1
1,397 檢視
Yes, it does. Add the VOLATILE declaration if you don't want it to do so.
cjosefy
初學者
1,397 檢視
I have added code as such:
Code:
CHARACTER*80, VOLATILE :: SCCSID
DATA SCCSID /'"...."'/
However, the SCCSID still doesn't show up. Any help is appreciated.
Steven_L_Intel1
1,397 檢視
Hmm. I suggest then that you use !DEC$ IDENT for this, as that is its intended purpose. For example:

!DEC$ IDENT "string"
cjosefy
初學者
1,397 檢視
Thanks for the help Steve, but that code still didn't work for me.
With both the VOLATILE and the way you just mentioned, compiling with no options takes out the string, but using -g leaves it in.
Any other thoughts?
Thanks,
Chris
Steven_L_Intel1
1,397 檢視
Hmm. That's a bug. I'll report it.

Do you need this just once in a program or once per routine? If for a program, this works:

character(30) ident :: ident = "My ident string"
common /ident/ ident
cjosefy
初學者
1,394 檢視
Because the strings are SCCS keywords, they are unique to each routine. What would really be nice is a compiler option to not remove dead storage.
Thanks for all your help.
Steven_L_Intel1
1,397 檢視
The IDENT directive is what should be used for this, if it worked.... I can't think of a reasonable workaround for subroutines - sorry. The bug will be fixed.
cjosefy
初學者
1,397 檢視
I understand the logic behind IDENT, but shouldn't there be an option to turn off the "dead storage" and "dead code" removal? It seems strange that there is no way to compile code and have the object code contain exactly the same variables as the source.
This is a huge problem for companies that want to use optimizations and source control at the same time.
Even if IDENT worked, that would require code changes in every single module. A compiler option that removes this "optimization" would be much better.

Message Edited by cjosefy on 03-10-2005 10:38 AM

Steven_L_Intel1
1,397 檢視
I don't understand what difference it makes as to whether the ident string is in an IDENT directive or in a variable.

The program executes correctly with or without the dead storage eliminated. As you noted, the storage is preserved if you ask for debugging. What purpose would such an option have that isn't already provided by a supported feature? Disabling optimizations is always a tricky issue, as it can cause instability in other parts of the compiler that assumes the optimization was done. It also has a cost in testing and documentation.
cjosefy
初學者
1,397 檢視
The option would be useful for porting legacy code. If you have thousands of modules that would require this IDENT string instead of a variable, that isn't very feasible for a large company.
I say this because I would think the target consumer for this compiler is companies that are using legacy code. I can't imagine much new code is being written in FORTRAN, and any option that enables less change when porting code is good.
The AIX FORTRAN compiler did not remove dead storage by default as the Intel compiler does. I bet Intel has many customers transitioning off the AIX platform. This option could be invaluable to them.
回覆