Skip to content

.name is always empty string for blocks and operands #761

Open
@farzonl

Description

@farzonl

Test code:

import sys
import llvmlite.binding as llvm

def ParseBC(bc : str) -> llvm.ModuleRef:
    try:
        module = llvm.parse_bitcode(bc)
        return module
    except Exception as e:
         return None

def Parse(path : str):
    module = None
    with open(path, 'rb') as f:
        module = ParseBC(fileStr)
    return module

def print(module : llvm.ModuleRef):
    for f in module.functions:
        for b in f.blocks:
            *_, last = b.instructions
            print(f'last instruction: {last}')
            print("operands: %s" % [op.name for op in last.operands])
            break
        break

def main():
    module = Parse(sys.argv[1])
    print(module)

if __name__=="__main__":
    main()

Test file:

test.bc.zip

requirements.txt

llvmlite==0.36.0
graphviz==0.17

Setup instructions:

python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
python test.py test.bc

Output:

last instruction br i1 %12, label %13, label %22
operands: ['', '', '']

Expected:

operands: ['i1 %12', 'label %13', ' label %22']

I'm also seeing the same thing happen when I run:
https://github.com/numba/llvmlite/blob/master/examples/llvmir_iter.py#39

print(f'Block: {b.name}/`{b.type}`\n{b}\nEnd of Block')

This leads me to believe there is an overarching issue with ValueRef's name property. I've been testing only on OS X. Don't think thats an issue but this is the otool output just incase:

otool -L env/lib/python3.9/site-packages/llvmlite/binding/libllvmlite.dylib 
env/lib/python3.9/site-packages/llvmlite/binding/libllvmlite.dylib:
	libllvmlite.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions