Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    λtlas
    @atlx
    this is like the self help desk lmao
    Dan Kolsoi
    @TheDan64
    Sorry, we don't get a lot of traffic here lol
    Dan Kolsoi
    @TheDan64
    Maybe we should switch to discord and I'll see these messages more quickly lol
    MrF4bulus
    @MrF4bulus
    Hi everyone, I am getting a problem with global values. How can I mark a global value with a dso_local?
    1 reply
    λtlas
    @atlx
    quick question, when cloning a basicvalueenum, does the actual LLVM value get cloned or just the pointer?
    so, value gets duplicated or just another reference to the same LLVM underlying value?
    Ronit Rahaman
    @n0t-r0n1t
    Reference to same value
    Bart Goossens
    @b0g2
    Indeed. LLVM in general tends to avoid duplicating objects/values/... Instead, values are defined and then reused several times, as part of the SSA representation.
    Pyxyne
    @Pyxyne_twitter
    hello everyone. i'm very new to LLVM and Inkwell, and i've been wondering about how to use address spaces.
    from what i've read, the meaning of address spaces in LLVM is completely target-dependent, and most of the time, it's either left unspecified in the IR, or 0 is used.
    and yet, the AddressSpace enum in Inkwell seems to imply there is a specific set of possible values with specific meanings.
    given that the docs specifically reference the source for the Nvidia PTX target, is there a reason to use this set of address spaces is valid for other targets, or might this be an oversight?
    1 reply
    λtlas
    @atlx
    SO I'm getting this weird bug where instructions are duplicated with a 1 suffix. I think it's because I'm using .clone() on BasicValueEnum. I have to do this because I have a cached stored on a HashMap (Rust), so when I do .get() it returns a reference; which then I clone to be used as an owned value. Are you sure instructions/values aren't actually cloned when you do .clone()?
    3 replies
    λtlas
    @atlx
    Or maybe it's a logic problem around my compiler's codebase
    Marc Soda
    @MarcSodaSr_twitter
    I have what seems like a silly question. How do I add more than 1 expression to a function? Looking at the Kaleidoscope example, it's seems that only one expression is added in compile_fn(). In my AST, the body of a function contains Vec<Expression>. How can I add more than one?
    1 reply
    λtlas
    @atlx
    What's the method for accessing an array element via index?
    like arr[0]
    build_extract_value or build_gep?
    9 replies
    λtlas
    @atlx
    weirdly using build_extract_value I can't provide IntValue, instead it takes a literal int parameter
    leifhelm
    @leifhelm
    What program do you use to format inkwell source code?
    λtlas
    @atlx
    what is the difference between: build_int_s_extend_or_bit_cast and build_int_z_extend_or_bit_cast? (z vs s)?
    2 replies
    λtlas
    @atlx
    Quick question about API.
    I'm currently building struct values via:
    1. alloca struct type
    2. gep per-field,
    3. store per-field
      isn't there a better way to do that all in one go or something ?
    1 reply
    Kane
    @kanersps
    Hey! I'm working on a JIT-engine and right now I'm struggling to remove from an element from VectorValue. How would I go about doing this?
    1 reply
    Lukas Dresel
    @Lukas-Dresel
    This message was deleted
    Hey! So I'm working on a Z3 constraint JIT and I'm having some trouble. I'm declaring a char* buffer type like this
    let byte_type = context.i8_type();
    let bool_type = context.bool_type();
    let buf_type = byte_type.ptr_type(AddressSpace::Generic);
    let fn_type = bool_type.fn_type(&[buf_type.into(), i64_type.into()], false);
    Then in the function itself I attempt to retrieve a value via
    let llvm_idx = i64type.const_int(index.try_into().unwrap(), false);
    let element_ptr = unsafe {
        self.builder.build_gep(self.input_buffer, &[llvm_idx], "gep")
    };
    This segfaults for me with a NULL-deref from the input_buffer pointer. I read the docs about how build_gep is very easy to mess up, so I guess I have two related questions
    1. If not with build_gep, is there another (safe) way to get the elements out of my char*?
    1. If there is not, any idea what I could be doing wrong?
    Lukas Dresel
    @Lukas-Dresel
    I've been trying to debug and match alongside the LLVM source code for LLVMBuildGEP
    And as best as I can tell I would say either the getType() call returns NULL, or the getScalarType()returns NULL
    Any ideas for why that might be? Just wanted to see that I'm not making any dumb obvious mistakes here
    Lukas Dresel
    @Lukas-Dresel
    Oh btw, input_buffer is
    let function = module.add_function(name, fn_type, None);
    let input_buffer = function.get_nth_param(0).expect("huh? we defined these args").into_pointer_value();
    Lukas Dresel
    @Lukas-Dresel
    Btw, for anyone wondering, I ended up compiling LLVM from source with debug symbols and tracked down the issue. llvm-sys apparently just takes the first llvm-config it finds on your path and expects it to match the one for the given version, I figured it would error out if it detected a mismatch, but it didn't
    so it ended up compiling with LLVM-15 instead of 12
    which has opaque pointers instead, so that code NULL-derefed when trying to access the type
    Rom Grk
    @romgrk
    hey, I want to parallelize an algo that uses a jitted function, but I'm getting something about ExecutionEngine not being safe to share across threads. is there an example/recommandation to do MT calls to jitted functions?
    1 reply
    Rom Grk
    @romgrk
    hey, I'm a bit confused, how to I create signed int constants? I see i64type().const_int(...) but that only takes an unsigned input
    2 replies
    tttmmmyyyy
    @tttmmmyyyy

    Hey! how can I build a function that takes a function pointer as an argument and call it? I want to do something like below:

    let context = Context::create();
    let module = context.create_module("main");
    let builder = context.create_builder();
    
    let callee_type = context.void_type().fn_type(&[], false);
    let func_type = context
        .void_type()
        .fn_type(&[callee_type.ptr_type(AddressSpace::Generic).into()], false);
    let func = module.add_function("func", func_type, None);
    let bb = context.append_basic_block(func, "entry");
    builder.position_at_end(bb);
    let callable =
        CallableValue::try_from(func.get_first_param().unwrap().into_pointer_value()).unwrap();
    builder.build_call(callable, &[], "call");
    builder.build_return(None);

    which panics at unwrap() of CallableValue::try_from().

    3 replies
    λtlas
    @atlx
    Hi, why isn't the crate published to crates.io? Also, I set feature version to 14.0 and it says that it doesn't exist...
    2 replies
    Dan Kolsoi
    @TheDan64
    Is anyone still using Llvm 3.X? Leaning towards removing support for them since there's a lot of baggage in those older versions
    Discreater
    @Discreater
    Hi, I'm newbie in llvm. As the type is i64, why my build_store and build_load result two align 4 llvm ir?
    define i64 @main() {
    entry:
      %a = alloca i64, align 8
      store i64 3, i64* %a, align 4
      %load = load i64, i64* %a, align 4
      ret i64 %load
    
    return_next:                                      ; No predecessors!
      ret i64 0
    }
    1 reply
    Anas Elgarhy
    @anas-elgarhy
    Hi!
    How I can install the llvm?
    I'm running arch Linux
    And I install it from pacman but I can't run the Kaleidoscope example
    4 replies
    Anas Elgarhy
    @anas-elgarhy
    And I tried "llvmenv" tool, but I got a compilation error
    like this: image
    Anas Elgarhy
    @anas-elgarhy
    Please help me, And I really appreciate that
    Anas Elgarhy
    @anas-elgarhy:matrix.org
    [m]
    ؟
    Dan Kolsoi
    @TheDan64
    llvmenv isn't very robust unfortunately
    Jack Whitehorn
    @jw2476
    o/ how can I output debug info into my Object file output?