Skip to content

Commit 28c850a

Browse files
committed
Guard e65cabb
1 parent fe36453 commit 28c850a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,23 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
988988
}
989989

990990
// Create a GEP.
991+
#ifdef INTEL_SYCL_OPAQUEPOINTER_READY
991992
return ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs, InBounds,
992993
InRangeIndex);
994+
#else // INTEL_SYCL_OPAQUEPOINTER_READY
995+
Constant *C = ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs,
996+
InBounds, InRangeIndex);
997+
assert(
998+
cast<PointerType>(C->getType())->isOpaqueOrPointeeTypeMatches(ElemTy) &&
999+
"Computed GetElementPtr has unexpected type!");
1000+
1001+
// If we ended up indexing a member with a type that doesn't match
1002+
// the type of what the original indices indexed, add a cast.
1003+
if (C->getType() != ResTy)
1004+
C = FoldBitCast(C, ResTy, DL);
1005+
1006+
return C;
1007+
#endif // INTEL_SYCL_OPAQUEPOINTER_READY
9931008
}
9941009

9951010
/// Attempt to constant fold an instruction with the

0 commit comments

Comments
 (0)