How to avoid this transformation

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

tree.c (634 Bytes)

tree.llvm.c (9.61 KB)

tree.ll (8 KB)

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

Thanks, it works fine now

I tried -fno-default-inline before, but it is only for C++ programs

--Ricardo