pyqir
pyqir copied to clipboard
Block names to use enumerated strings.
Right now, if someone generates llvm files where they don't set block names in the IR, the pyqir.BasicBlock.name field will hold the empty string. This is suboptimal for being able to easily hash blocks in a unique manner since all blocks in the entry point function of the IR will have the same name, ''.
When visually inspecting the IR for a function where blocks are generated without setting the name fields, then you see a function similar to the following:
declare void @main() {
; instructions
br i1 ..., label %1, label %2 ; placeholder ... for i1 value
1:
; more. instructions
2:
; more instructions
ret void
}
If the pyqir.BasicBlock.name field can be set such that the entry block's name is '0', the next block's name is '1', and the final block's name is: '2' (similar to the format in the human readable .ll file) then each block could easily be uniquely hashable. This would allow compilers to more easily keep track of blocks and without needing the entire block object to be hashable.
Could number ids collide automatic local ids and cause IR validation to fail?