[LLVMdev] How to avoid this transformation

Ricardo rmivs-jygf at yahoo.com
Mon Apr 25 19:28:44 PDT 2005


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


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);
	inorder_traversal( root );
	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>

More information about the llvm-dev mailing list