static LoadInst *createLoad(IRBuilder<> &B, Value *addr, bool isVolatile = false)
{
-#if LLVM_MAJOR_VERSION >= 14
+#if LLVM_MAJOR_VERSION >= 15
+ if (isa<AllocaInst>(addr))
+ return B.CreateLoad(dyn_cast<AllocaInst>(addr)->getAllocatedType(), addr, isVolatile);
+ else
+ return B.CreateLoad(addr->getType(), addr, isVolatile);
+#elif LLVM_MAJOR_VERSION >= 14
return B.CreateLoad(addr->getType()->getPointerElementType(), addr, isVolatile);
#else
return B.CreateLoad(addr, isVolatile);
static Value *createInBoundsGEP(IRBuilder<> &B, Value *ptr, ArrayRef<Value *>idxlist)
{
-#if LLVM_MAJOR_VERSION >= 14
+#if LLVM_MAJOR_VERSION >= 15
+ if (isa<GlobalValue>(ptr))
+ return B.CreateInBoundsGEP(dyn_cast<GlobalValue>(ptr)->getValueType(), ptr, idxlist);
+ else
+ return B.CreateInBoundsGEP(ptr->getType(), ptr, idxlist);
+#elif LLVM_MAJOR_VERSION >= 14
return B.CreateInBoundsGEP(ptr->getType()->getScalarType()->getPointerElementType(),
ptr, idxlist);
#else
B.SetInsertPoint(label_false);
// s = &s[nread];
B.CreateStore(
- createInBoundsGEP(B, createLoad(B, sptr), createLoad(B, nread, true)), sptr);
+ createInBoundsGEP(B, createLoad(B, sptr), {createLoad(B, nread, true)}), sptr);
args->resize(2);
fmt->clear();
table_names_[table.name] = id++;
GlobalValue *gvar = mod_->getNamedValue(table.name);
if (!gvar) continue;
- if (PointerType *pt = dyn_cast<PointerType>(gvar->getType())) {
#if LLVM_MAJOR_VERSION >= 15
- StructType *st = dyn_cast<StructType>(pt->getPointerElementType());
+ {
+ Type *t = gvar->getValueType();
+ StructType *st = dyn_cast<StructType>(t);
#else
+ if (PointerType *pt = dyn_cast<PointerType>(gvar->getType())) {
StructType *st = dyn_cast<StructType>(pt->getElementType());
#endif
if (st) {