Doug Christman via llvm-dev
2016-Sep-08 17:37 UTC
[llvm-dev] PtrToInt in array initializer
Hello all, I'm trying to use the C API to initialize a global integer array with the address of another global, but ptrtoint yields an array instead of an integer. You can see a short program demonstrating the issue here (tested with LLVM 3.8.1 and 4.0.0svn-r280709 on Linux x86_64): https://raw.githubusercontent.com/dobyrch/dbc/master/llvm_bug/example.c Note that the use of ptrtoint in the array initializer causes all array elements to take on the type [2 x i64] instead of i64. If the output is manually edited to change the element types to i64, llc compiles it without error. Is this a bug, or am I misunderstanding/misusing ptrtoint? Thanks, Doug
Hi Doug, On 8 September 2016 at 18:37, Doug Christman via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Note that the use of ptrtoint in the array initializer causes all array > elements to take on the type [2 x i64] instead of i64. If the output > is manually edited to change the element types to i64, llc compiles it > without error.I think the problem is on the "LLVMConstArray" line. The first argument is called "ElementTy" so it should probably just be TYPE_INT. Cheers. Tim.
Doug Christman via llvm-dev
2016-Sep-09 12:48 UTC
[llvm-dev] PtrToInt in array initializer
On Fri, Sep 09, 2016 at 08:53:32AM +0100, Tim Northover wrote:> I think the problem is on the "LLVMConstArray" line. The first > argument is called "ElementTy" so it should probably just be TYPE_INT.Thank you, I can't believe I missed that. Regards, Doug