Skip to content

Commit 952a4f5

Browse files
committed
Fixup
1 parent c1a1f22 commit 952a4f5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

enzyme/Enzyme/Utils.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ LLVMValueRef (*CustomAllocator)(LLVMBuilderRef, LLVMTypeRef,
5050
/*Count*/ LLVMValueRef,
5151
/*Align*/ LLVMValueRef, uint8_t,
5252
LLVMValueRef *) = nullptr;
53-
LLVMValueRef (*CustomZero)(LLVMBuilderRef, LLVMTypeRef,
54-
/*Ptr*/ LLVMValueRef, uint8_t) = nullptr;
53+
void (*CustomZero)(LLVMBuilderRef, LLVMTypeRef,
54+
/*Ptr*/ LLVMValueRef, uint8_t) = nullptr;
5555
LLVMValueRef (*CustomDeallocator)(LLVMBuilderRef, LLVMValueRef) = nullptr;
5656
void (*CustomRuntimeInactiveError)(LLVMBuilderRef, LLVMValueRef,
5757
LLVMValueRef) = nullptr;
@@ -183,10 +183,10 @@ Function *getOrInsertExponentialAllocator(Module &M, Function *newFunc,
183183
Instruction *SubZero = nullptr;
184184
gVal = CreateAllocation(B, RT, elSize, "", nullptr, &SubZero);
185185

186-
gVal = B.CreatePointerCast(
187-
gVal, PointerType::get(
188-
Type::getInt8Ty(gVal->getContext()),
189-
cast<PointerType>(gVal->getType())->getAddressSpace()));
186+
Type *bTy =
187+
PointerType::get(Type::getInt8Ty(gVal->getContext()),
188+
cast<PointerType>(gVal->getType())->getAddressSpace());
189+
gVal = B.CreatePointerCast(gVal, bTy);
190190
auto pVal = B.CreatePointerCast(ptr, gVal->getType());
191191

192192
Value *margs[] = {gVal, pVal, prevSize,
@@ -200,13 +200,16 @@ Function *getOrInsertExponentialAllocator(Module &M, Function *newFunc,
200200
IRBuilder<> BB(SubZero);
201201
Value *zeroSize = BB.CreateSub(next, prevSize);
202202
Value *tmp = SubZero->getOperand(0);
203+
Type *tmpT = tmp->getType();
204+
tmp = BB.CreatePointerCast(tmp, bTy);
203205

204206
#if LLVM_VERSION_MAJOR > 7
205207
tmp = BB.CreateInBoundsGEP(tmp->getType()->getPointerElementType(), tmp,
206208
prevSize);
207209
#else
208210
tmp = BB.CreateInBoundsGEP(tmp, prevSize);
209211
#endif
212+
tmp = BB.CreatePointerCast(tmp, tmpT);
210213
SubZero->setOperand(0, tmp);
211214
SubZero->setOperand(2, zeroSize);
212215
}

0 commit comments

Comments
 (0)