Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
4995 Discussions

SSA and preprocessor directives

Kai
Beginner
325 Views

I'm unsure about how the SSA works with the preprocessor directives, does it collects the SSA Information during the build process? And uses then the way through the directives, which is defined in the configuration/flags? Or does it ignore all of the directives? 

For example the following code:

constantVal = 6
#ifdef A
   tmpvar = 10
#else
   tmpvar = 0
#endif !A

tmpvar = tmpvar+1
tmpvar = tmpvar+1
tmpvar = tmpvar+1
tmpvar = tmpvar+1

#ifdef B
   tmpvar = tmpvar+1
#endif !B

#ifdef B
somerandom code here, would it be tested if the B-flag is not set?
#endif !B

tmpvar = tmpvar+1
tmpvar2 = 1/(tmpvar-constantVal)

When I run the build process with the SSA flags and the following configuration:
1. -DA -DB: 1/(16-6)
2. -DA: 1/(15-6)
3. -DB: 1/(6-6)

Does it found in every case the div by zero issue? or would it be ignored in case 1 and 2? 

Thanks,
Kai

0 Kudos
1 Reply
Peter_W_Intel
Employee
325 Views
I just use a simple C program to test, same story for Fortran. macro_ssa.c ------------------------------------------------------------------------ #ifdef A const int tmpvar=10; #else const int tmpvar=6; #endif #include int main() { int a; a = 1/(10-tmpvar); /* will define Macro A in build, check if SSA can detect this error*/ *printf ("a is %d\n", a); return 1; } ------------------------------------------------------------------------ # gcc -g macro_ssa.c // if A is not defined # ./a.out a is 0 # gcc -g -D A macro_ssa.c # ./a.out Floating point exception (core dumped) Use ssa to check if directive is functional. # icc -O0 -diag-enable sv3 -D A macro_ssa.c icc: command line remark #10010: option '-diag-enable sv3' is deprecated and will be removed in a future release. See '-help deprecated' icc: remark #10336: Static analysis complete; results available in "./r000sc/r001sc.inspxe" # inspxe-cl -report problems -r r001sc/ Used suppression file(s): P1: Error: Divide by zero macro_ssa.c(12): error #12061: divide by zero Problem P1.1: Divide by zero: Not fixed macro_ssa.c(12): error #12061: divide by zero X1: Divide by zero: /home/peter/problem_report/macro_ssa.c(12): Function main So the result is expected for SSA.
0 Kudos
Reply