Analyzers
Support for Analyzers (Intel VTune™ Profiler, Intel Advisor, Intel Inspector)
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
4679 Discussions

SSA and preprocessor directives

Kai
Beginner
127 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
127 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.
Reply