Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91752

Forum Post: RE: Optimized code misses stack fill

$
0
0

I don't expect a programming course, so feel free not to answer, but the following question arise:

In the original code the problem seemed to be the source line

int64 tmp = *((int64*)var);

and not

buf[i] = __byte((int *)&tmp,i);

since the first is not present in the annotated assembly and the decoded assembly misses the corresponding instructions to fill the tmp stack variable. The code to read from the tmp stack variable into buf[i] is present in the assembly.

In the first line, the strict aliasing rule is not necessarily violated: If the original variable pointed to by the void pointer 'var' is int64, this C code should be correct, but the compiler does not generate code.

In the second line, the strict aliasing rule is obviously violated since an int64 pointer is cast to an int pointer. The generated code seems to be correct though. I'm now less sure that the original problem is a violation of 'strict aliasing' rule. What do you think?

The second question is: what is the correct way to read 8-bit pieces of anything that isn't int? Is a union with an int array followed by __byte() the only way?

This requires changing the function interface from passing the variable length to passing the variable type since from your answer I understand that I must always convert the pointer back to the original type, thus a pointer to long integer and a pointer to float must not be confused although both types are 32 bits.Is this correct?

Paul


Viewing all articles
Browse latest Browse all 91752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>