Skip to content

Commit

Permalink
nat,fix: fixed CG for ptr to zero-sized uniform arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
simoll committed Mar 8, 2018
1 parent 7da1f0c commit 6425f4e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/native/NatBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,16 @@ void NatBuilder::addLazyInstruction(Instruction *const instr) {
++numLazy;
}

llvm::Type*
GetPointerElementType(Type * ptrTy) {
auto* innerTy = ptrTy->getPointerElementType();
auto * innerArrTy = cast<ArrayType>(innerTy);
if (innerArrTy && innerArrTy->getNumElements() == 0) {
return innerArrTy->getElementType();
}
return innerTy;
}

void NatBuilder::requestLazyInstructions(Instruction *const upToInstruction) {
assert(!lazyInstructions.empty() && "no lazy instructions to generate!");

Expand Down Expand Up @@ -1644,7 +1654,7 @@ NatBuilder::requestVectorValue(Value *const value) {
if (value->getType()->isPointerTy()) {
auto * scalarPtrTy = vecValue->getType();
auto * intTy = builder.getInt32Ty();
auto * ptrElemTy = scalarPtrTy->getPointerElementType();
auto * ptrElemTy = GetPointerElementType(scalarPtrTy);
int scalarBytes = static_cast<int>(layout.getTypeStoreSize(ptrElemTy));

// vecValue is a single pointer and has to be broadcasted to a vector of pointers first
Expand Down

0 comments on commit 6425f4e

Please sign in to comment.