Skip to content

Commit 9ec8fc4

Browse files
committed
Do not flatten GEP chains for unsupported types
1 parent 033df38 commit 9ec8fc4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/lib/Target/DirectX/DXILFlattenArrays.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,13 @@ bool DXILFlattenArraysVisitor::visitGetElementPtrInst(GetElementPtrInst &GEP) {
263263
// merge the byte offsets. Otherwise, this GEP is itself the root of a GEP
264264
// chain and we need to deterine the root array type
265265
if (auto *PtrOpGEP = dyn_cast<GEPOperator>(PtrOperand)) {
266-
assert(GEPChainInfoMap.contains(PtrOpGEP) &&
267-
"Expected parent GEP to be visited before this GEP");
266+
267+
// If the parent GEP was not processed, then we do not want to process its
268+
// descendants. This can happen if the GEP chain is for an unsupported type
269+
// such as structs -- we do not flatten structs.
270+
if (!GEPChainInfoMap.contains(PtrOpGEP))
271+
return false;
272+
268273
GEPInfo &PGEPInfo = GEPChainInfoMap[PtrOpGEP];
269274
Info.RootFlattenedArrayType = PGEPInfo.RootFlattenedArrayType;
270275
Info.RootPointerOperand = PGEPInfo.RootPointerOperand;

0 commit comments

Comments
 (0)