[LLVMdev] noinline attribute problem

Sara Elshobaky sara.elshobaky at gmail.com
Tue Feb 25 02:53:40 PST 2014


Hello,

I have the following simple C code below. It should return '8' as a result.
But the returned result is false as it returns '1'. 

When I remove the line of '__attribute__((noinline))' , the returned results
are correct '8'. 

Any idea? Please advice as I need to get the assembly code of the
'getTexSize' function alone.

 

Note: I compile using the following commands

   clang -O2  -emit-llvm test.cpp -c -o test.bc

    lli -use-mcjit test.bc

 

Thanks in advance

Sara Elshbaky

 

=============================

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

 

__attribute__((noinline))

int getTexSize(int n)

{

    if((n & (n - 1)) != 0) // determining if an integer is not a power of 2

    {

        n-- ;

        n |= n >> 1;

        n |= n >> 2;

        n |= n >> 4;

        n |= n >> 8;

        n |= n >> 16;

        n++;// this is the nearest higher power of 2

        n >>= 1;//this is the nearest lower power of 2 value

    }

    return sqrt(n>>2);//divide by 4, then get its square root

}

int main(int argc, char **argv) {

         int n = 257;

         printf("----%d----",getTexSize(n));

        return 0;

}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140225/371c341b/attachment.html>


More information about the llvm-dev mailing list