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>
Hi Sara,> clang -O2 -emit-llvm test.cpp -c -o test.bc > lli -use-mcjit test.bcI'm not seeing the issue here. Could you tell us what version of Clang & lli you're using, and what the platform is? If you're not using trunk, it would be useful to know if the problem is still present there. Attaching the bad test.bc could also be helpful. Cheers. Tim.
Hi Tim, I attached the .cpp file and the .bc one I'm using clang and lli version 3.3 on ARM PC I modified the code to send n as an argument to the main function. As a result, the wrong '1' is returned always even if the no_inline attribute is available or not. But, including the printf function in the getTexSize function solve it. Is it normal? Also I do not need to printf anything .. Thanks in advance Sara -----Original Message----- From: Tim Northover [mailto:t.p.northover at gmail.com] Sent: Tuesday, February 25, 2014 1:33 PM To: Sara Elshobaky Cc: LLVM Developers Mailing List Subject: Re: [LLVMdev] noinline attribute problem Hi Sara,> clang -O2 -emit-llvm test.cpp -c -o test.bc > lli -use-mcjit test.bcI'm not seeing the issue here. Could you tell us what version of Clang & lli you're using, and what the platform is? If you're not using trunk, it would be useful to know if the problem is still present there. Attaching the bad test.bc could also be helpful. Cheers. Tim. -------------- next part -------------- A non-text attachment was scrubbed... Name: test.bc Type: application/octet-stream Size: 2056 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140225/e60082a9/attachment.obj> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: test.cpp URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140225/e60082a9/attachment.ksh>