sunfishcode / llvm2cranelift

LLVM IR to Cranelift IR translator
Apache License 2.0
36 stars 4 forks source link

symbols: put data symbols into namespace 1 and funcs into 0 #9

Open undingen opened 5 years ago

undingen commented 5 years ago

Before this change we but everything into namespace 0 (so is_function() always returned true). cranelift-simplejit/src/backend.rs::get_definition: calls namespace.is_function(name) to figure out if it has to lookup a function or data definition. But cranelift-module is_function() does this by comparing the namespace with 0:


    // Return whether `name` names a function, rather than a data object.
    pub fn is_function(&self, name: &ir::ExternalName) -> bool {
        if let ir::ExternalName::User { namespace, .. } = *name {
            namespace == 0
        } else {
            panic!("unexpected ExternalName kind {}", name)
        }
    }
sunfishcode commented 4 years ago

This makes sense to me.

undingen commented 4 years ago

rebased the PR - no other changes

undingen commented 4 years ago

is there anything to do to get this merged?