Re: [llvm-dev] [lldb-dev] LLVM-C

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] [lldb-dev] LLVM-C

U.Mutlu via llvm-dev
This doesn't look like an lldb question. Did you mean to send it to
llvm-dev instead?

On Tue, 5 Jun 2018 at 03:13, Giannis Zamanis via lldb-dev
<[hidden email]> wrote:

>
> Hello,
>
> I am writing a compiler using llvm-c api and  i want to have variable-length arrays as arguments in functions.I have tried using zero-sized type array as the typical parameter in the function definition, but when i call the function with a normal-sized array as argument it throws error due to mismatch in types. I can't find a workaround for this.
> Example:
> define i32 @ha([0 x i32]*)
> %funccall = call i32 @ha([20 x i32]* %only_l)
>
> Thank you for your time,
> John
> _______________________________________________
> lldb-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] [lldb-dev] LLVM-C

U.Mutlu via llvm-dev
Why are you passing a zero sized array? Pass a pointer and perhaps a length argument instead. My understanding is that VLAs are not the equivalent of a Java array or a Go slice. There is no way to determine the length at runtime. The type of the array is determined by its size. IIRC, C99 VLAs use alloca and pointers to implement the same functionality. 

On Tue, Jun 5, 2018, 5:13 AM Pavel Labath via llvm-dev <[hidden email]> wrote:
This doesn't look like an lldb question. Did you mean to send it to
llvm-dev instead?

On Tue, 5 Jun 2018 at 03:13, Giannis Zamanis via lldb-dev
<[hidden email]> wrote:
>
> Hello,
>
> I am writing a compiler using llvm-c api and  i want to have variable-length arrays as arguments in functions.I have tried using zero-sized type array as the typical parameter in the function definition, but when i call the function with a normal-sized array as argument it throws error due to mismatch in types. I can't find a workaround for this.
> Example:
> define i32 @ha([0 x i32]*)
> %funccall = call i32 @ha([20 x i32]* %only_l)
>
> Thank you for your time,
> John
> _______________________________________________
> lldb-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev