Hello, I am trying to compile a program to be used for Pool Allocation. The program tries to allocate certain number of nodes inside a function that is called by main. The problem is that llvm-gcc insists in "optimize" the function so that certain number of nodes are created in main and the rest are created inside the original function. In this case the function is called with a minor number of nodes two times. My question is: how to supress this transformation? I am compiling using this line: llvm-gcc -o tree tree.c So that I am not enabling any optimization and I am not running either DSA or PoolAlloc. I use the unoptimized .bc file generated and convert it either to .c or .ll and both formats exhibit this behavior Thanks ======================struct bintree { int data; struct bintree *Left; struct bintree *Right; }; void inorder_traversal(struct bintree *node) { if (node->Left != 0) inorder_traversal( node->Left ); printf("%d\t", node->data); if (node->Right != 0) inorder_traversal( node->Right ); } struct bintree *make_tree(int level) { struct bintree *New = malloc ( sizeof ( struct bintree ) ); New->Left = level ? make_tree (level-1) : 0; New->data = level; New->Right = level ? make_tree (level-1) : 0; return New; } int main() { struct bintree *root; root = make_tree(1000); printf("\n"); inorder_traversal( root ); printf("\n"); return 0; } ======================-------------- next part -------------- A non-text attachment was scrubbed... Name: tree.c Type: application/octet-stream Size: 634 bytes Desc: tree.c URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050425/4a2188c8/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: tree.llvm.c Type: application/octet-stream Size: 9842 bytes Desc: tree.llvm.c URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050425/4a2188c8/attachment-0001.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: tree.ll Type: application/octet-stream Size: 8189 bytes Desc: tree.ll URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050425/4a2188c8/attachment-0002.obj>
On Mon, 25 Apr 2005, Ricardo wrote:> I am trying to compile a program to be used for Pool Allocation. The program tries to allocate > certain number of nodes inside a function that is called by main. The problem is that llvm-gcc > insists in "optimize" the function so that certain number of nodes are created in main and the > rest are created inside the original function. In this case the function is called with a minor > number of nodes two times. My question is: how to supress this transformation? I am compiling > using this line: > > llvm-gcc -o tree tree.c > > So that I am not enabling any optimization and I am not running either DSA or PoolAlloc. I use the > unoptimized .bc file generated and convert it either to .c or .ll and both formats exhibit this > behaviorllvm-gcc is strange in that it runs optimizations even when not asked to. Try this: llvm-gcc -o tree tree.c -Wa,-disable-inlining -Wl,-disable-inlining -Chris> ======================> struct bintree > { > int data; > struct bintree *Left; > struct bintree *Right; > }; > > void inorder_traversal(struct bintree *node) > { > if (node->Left != 0) inorder_traversal( node->Left ); > printf("%d\t", node->data); > if (node->Right != 0) inorder_traversal( node->Right ); > } > > struct bintree *make_tree(int level) > { > struct bintree *New = malloc ( sizeof ( struct bintree ) ); > New->Left = level ? make_tree (level-1) : 0; > New->data = level; > New->Right = level ? make_tree (level-1) : 0; > return New; > } > > int main() > { > struct bintree *root; > root = make_tree(1000); > printf("\n"); > inorder_traversal( root ); > printf("\n"); > return 0; > } > ======================>-Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Thanks, it works fine now I tried -fno-default-inline before, but it is only for C++ programs --Ricardo --- Chris Lattner <sabre at nondot.org> wrote:> On Mon, 25 Apr 2005, Ricardo wrote: > > I am trying to compile a program to be used for Pool Allocation. The program tries to allocate > > certain number of nodes inside a function that is called by main. The problem is that llvm-gcc > > insists in "optimize" the function so that certain number of nodes are created in main and the > > rest are created inside the original function. In this case the function is called with a > minor > > number of nodes two times. My question is: how to supress this transformation? I am compiling > > using this line: > > > > llvm-gcc -o tree tree.c > > > > So that I am not enabling any optimization and I am not running either DSA or PoolAlloc. I use > the > > unoptimized .bc file generated and convert it either to .c or .ll and both formats exhibit > this > > behavior > > llvm-gcc is strange in that it runs optimizations even when not asked to. > Try this: > > llvm-gcc -o tree tree.c -Wa,-disable-inlining -Wl,-disable-inlining > > -Chris > > > > > ======================> > struct bintree > > { > > int data; > > struct bintree *Left; > > struct bintree *Right; > > }; > > > > void inorder_traversal(struct bintree *node) > > { > > if (node->Left != 0) inorder_traversal( node->Left ); > > printf("%d\t", node->data); > > if (node->Right != 0) inorder_traversal( node->Right ); > > } > > > > struct bintree *make_tree(int level) > > { > > struct bintree *New = malloc ( sizeof ( struct bintree ) ); > > New->Left = level ? make_tree (level-1) : 0; > > New->data = level; > > New->Right = level ? make_tree (level-1) : 0; > > return New; > > } > > > > int main() > > { > > struct bintree *root; > > root = make_tree(1000); > > printf("\n"); > > inorder_traversal( root ); > > printf("\n"); > > return 0; > > } > > ======================> > > > -Chris > > -- > http://nondot.org/sabre/ > http://llvm.cs.uiuc.edu/ >