Consider: @G = global i32 123 @ltmp_0_1 = global i32 123 define i32 @test(i32 *%G) { %A = load i32* %G %B = load i32* @ltmp_0_1 %C = add i32 %A, %B ret i32 %C } The CBE generated code is: unsigned int test(unsigned int *ltmp_0_1) { ... ltmp_1_2 = *ltmp_0_1; // local ltmp_2_2 = *(<mp_0_1); // global return (ltmp_1_2 + ltmp_2_2); ... This is a serious bug. A not-as-serious bug: the CBE ignores the local names of symbols, turning %A into ltmp_1_2? -Chris
IIRC, the global/local patch was yours even though I committed it after getting llvm-upgrade working. I would appreciate it if you could look into this as I am behind on other tasks (the Shift thing set me back several days). If you don't have time, this might have to wait a bit until I'm back on schedule. I have a very important deadline happening in a few weeks .. can't miss it.
btw, yes, I will do this, when I get time. Thanks, -Chris
What would be a good strategy for naming variables? I could do something along these lines: @var = global i32 927 define i32 @test(i32 *%var) { %A = load i32* %var %B = load i32* @var; %C = add i32 %A, %B ret i32 %C } into: unsigned int test(unsigned int *param_var) { ... loc_A = *param_var; loc_B = *(&gbl_var); return (loc_A + loc_B); } This way, there is no ambiguity about what is local, global, or a parameter, there would be no name conflicts, and it uses the original names. -bw
I think using a prefix for local names makes sense. How about "llvm_cbe_"? It could be used for any local name (anything that is !isa<GlobalValue>) including params. -Chris
So then in the example, it would be something like: llvm_cbe_A = ...; llvm_cbe_B = ...; ? I'm wondering if there's still a problem with name conflicts between globals and locals. What if a global's named "llvm_cbe_Foo" and the local's Foo also? -bw
> So then in the example, it would be something like: > llvm_cbe_A = ...; yep > I'm wondering if there's still a problem with name conflicts between globals and locals. What if a global's > named "llvm_cbe_Foo" and the local's Foo also? Just adding a unique prefix like this makes it less likely. To be extremely paranoid, the local symbols should be picked and checked to see if they conflict with any global ones. If so, pick a different name. -Chris
How about this? unsigned int G = ((unsigned int )123); unsigned int ltmp_0_1 = ((unsigned int )123); unsigned int test(unsigned int *llvm_cbe_G) { unsigned int llvm_cbe_A; unsigned int llvm_cbe_B; llvm_cbe_A = *llvm_cbe_G; llvm_cbe_B = *(<mp_0_1); return (llvm_cbe_A + llvm_cbe_B); }
looks great to me!
Fixed: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070219/044959.html http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070219/044960.html -bw