User Tools

Site Tools


Bugs and their Fixes - Introduction

Bugs are both fun and frustrating to discover and fix. Here are some of the weird bugs we've encountered through LegUp. Maybe some day this list will help solve future bugs by example.

gsm bug - phi dependencies

Due to the SSA nature of LLVM, the phi instruction is a necessity. Since it's not found in either software or normal assembly, it's trickier. A phi instruction assigns a variable depending on which basic block branched to the current one. After upgrading llvm-gcc from 2.6svn to 2.7, this bug showed up on gsm. It was also the cause of Andrew fixed this bug after looking for the cause for several days by adding display statements in Verilog. A well-placed printf fixed the result, but did not fix the underlying cause.;a=commit;h=15869e30493a50f2cd4bcf9af4a85151a94a0bf1 was the result after finding the bug. After this, LegUp became more methodical at finding bugs, with the assert statements and a debugger that just printed out variable dumps, that could diff with the expected result.

switch/case and select - problems with LLVM mips backend

Mark discovered two bugs with the LLVM mips backend and filed them to LLVM. switch/case: and 64-bit comparision: Running the debugger, I found a third bug with select This turned out to be the underlying problem to 64-bit comparison. Select is the ternary if/else operator. Since the result is binary, I just naively switched the true and false results of the statement in the backend and select was fully operational.

switch/case outputted incorrect assembly syntax, but which made sense otherwise. I initially wrote a script to parse the assembly and output the correct result. This worked, but was an ugly hack. In the mips backend, I searched for JT, which was where the bad syntax started. No results, so I searched JumpTable and found the code that lowered switch/case into a form that the mips backend would then output. After playing around with a few flags, I stumbled upon a working solution by adding a ! in an if statement. In a function that lowered another function, the ! was equivalently present in the if statement.

Mark and I looked at the reason behind the select problem and we were able to quickly trace down the cause to a piece of code which contradicted its comment. A simple fix was now satisfactory. I posted a patch of my switch/case fix and the LLVM mips backend maintainer was able to confirm that it was a correct fix that made sense.

getelementptr - the other tricky LLVM instruction

elf2sdram - wrong assumption about spacing

lbu with a negative immediate - bug in Tiger MIPS

a_brief_history_of_bugs.txt · Last modified: 2010/12/15 15:53 (external edit)