LLVM-C changes in LLVM-15

I’m starting to explore LLVM-15 and I’m finding some changes that seem unusual. I understand the move to opaque pointers but I’m seeing an issue with LLVMBuildInsertElement and LLVMBuildInsertValue. The values these return seem to be of type pointer rather than the type of the aggregate or vector. For example, generating a test function creates this:

declare i32 @test_function(i32 %0, i32 %1)
  %3 = alloca <2 x i32>, align 8
  %4 = insertelement ptr %3, i32 %0, i32 0  test_vector_elements      

I would expect:

declare i32 @test_function(i32 %0, i32 %1)
  %3 = alloca <2 x i32>, align 8
  %4 = insertelement <2 x i32> %3, i32 %0, i32 0  test_vector_elements      

If I’m missing something then the sooner I can figure it out the better. Thanks!

The value %3 defined by the alloca is indeed a pointer. Previously it was <2 x i32>*, with opaque pointers it’s just ptr.

You may want IR like:

%3 = alloca <2 x i32>, align 8
%4 = load <2 x i32>, ptr %3
%5 = insertelement <2 x i32> %4, i32 %0, i32 0
store <2 x i32> %5, ptr %3

Ah yes, that is helpful. There is another change in the code that must be causing the issue. I will investigate further.