GCC 11.2.0 Not Generating Correct Object File for Function Attributes
I've searched everywhere and can't find a clear answer... Hey everyone, I'm running into an issue that's driving me crazy. I'm having an scenario with GCC 11.2.0 where it's not applying function attributes correctly when compiling my C code. I have a function that is supposed to be inlined and also marked as `pure`, yet upon inspection of the generated assembly, it seems like GCC is treating it as a regular function which is causing performance optimization. Hereβs the code Iβm working with: ```c #include <stdio.h> inline __attribute__((pure)) int compute(int x) { return x * x; } int main() { int result = compute(5); printf("Result: %d\n", result); return 0; } ``` When I compile this code with the command `gcc -O3 -S -o output.s myfile.c`, I expect the `compute` function to be inlined or at least optimized significantly due to the `pure` attribute. However, in the `output.s` file, I see that `compute` is not inlined, and there are unnecessary calls to it instead of direct computation. I've tried changing optimization flags, like using `-O2` instead of `-O3`, and even used `-fno-inline` to see if it had any impact, but the behavior remains the same. Additionally, I verified that the function is only called once, so I thought inlining should have been straightforward. Is there something specific about the attributes or my GCC setup that I'm missing? Would using different attributes or a different GCC version help resolve this scenario? Any insights or suggestions would be greatly appreciated! I'm open to any suggestions. Thanks for your help in advance!