mewmew / uc

A compiler for the µC language.
58 stars 5 forks source link

irgen: `invalid use of function-local name` in gep constant expression #77

Closed mewmew closed 8 years ago

mewmew commented 8 years ago

Introduced in dbec8c9d42f285b880f3216c60af0f09761c2c55.

Only emit gep constant expressions for globals if all indicies are constants.

u@x1 ~/D/g/s/g/m/uc> ./compile.sh testdata/noisy/advanced/8queens.c 
Compiling "testdata/noisy/advanced/8queens.c"
llvm-link: a.ll:49:79: error: invalid use of function-local name
        %11 = load i32, i32* getelementptr ([8 x i32], [8 x i32]* @board, i64 0, i64 %10)
                                                                                     ^
#0 0x00007f5b407e87d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/../lib/libLLVM-3.8.so+0x5ef7d8)
#1 0x00007f5b407e63c6 llvm::sys::RunSignalHandlers() (/usr/bin/../lib/libLLVM-3.8.so+0x5ed3c6)
#2 0x00007f5b407e65aa (/usr/bin/../lib/libLLVM-3.8.so+0x5ed5aa)
#3 0x00007f5b3fb060f0 __restore_rt (/usr/bin/../lib/libc.so.6+0x330f0)
#4 0x00007f5b4094ac94 llvm::Module::materializeMetadata() (/usr/bin/../lib/libLLVM-3.8.so+0x751c94)
#5 0x0000000000405287 (/usr/bin/llvm-link+0x405287)
#6 0x0000000000405cf9 (/usr/bin/llvm-link+0x405cf9)
#7 0x0000000000403802 _init (/usr/bin/llvm-link+0x403802)
#8 0x00007f5b3faf32d1 __libc_start_main (/usr/bin/../lib/libc.so.6+0x202d1)
#9 0x0000000000404cb9 _init (/usr/bin/llvm-link+0x404cb9)
Stack dump:
0.  Program arguments: llvm-link -S -o out.ll a.ll testdata/uc.ll 
./compile.sh: line 12: 29516 Segmentation fault      (core dumped) llvm-link -S -o out.ll a.ll testdata/uc.ll
SUCCESS: testdata/noisy/advanced/8queens.c
mewmew commented 8 years ago

Fixed as of commit ccd2f6d.