[llvm-dev] Creating a global variable for a struct array

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 1 01:15:42 PDT 2020


On Thu, 1 Oct 2020 at 04:50, Niddodi, Chaitra <chaitra at illinois.edu> wrote:
> Along the lines of the code you had sent, I created a GlobalVariable* llist of type [10 x %struct.dlist]* for the field dlist* llist in h1. But this results in an LLVM ERROR: Type mismatch in constant table!.

The type you pass to GlobalVariable's constructor for that variable
should be "[10 x %struct.dlist]" because that's what you want storage
for. Then the GlobalVariable itself will be a Constant of type "[10 x
%struct.dlist]*".

Since that error is coming from the bitcode reader, I suspect you
might have built a version of LLVM without assertions enabled (fixed
with -DLLVM_ENABLE_ASSERTIONS=ON in CMake, or a debug build) so the
crash you'd normally get when actually constructing the constants is
deferred. Hopefully if you turn assertions on it'll point to the exact
line the error is happening on and be much easier to fix.

Cheers.

Tim.


More information about the llvm-dev mailing list