Skip to content

Commit 0d30491

Browse files
committed
fix while loop
1 parent 318e977 commit 0d30491

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

llvm/lib/Target/DirectX/DXILPrepare.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,25 @@ class DXILPrepareModule : public ModulePass {
167167

168168
// finally, drill down GEP instructions until we get the array
169169
// that is being accessed, and compare element types
170-
if (auto *GEPInstr = llvm::dyn_cast<llvm::ConstantExpr>(Operand)) {
170+
if (llvm::ConstantExpr *GEPInstr =
171+
llvm::dyn_cast<llvm::ConstantExpr>(Operand)) {
171172
while (GEPInstr->getOpcode() == llvm::Instruction::GetElementPtr) {
172173
llvm::Value *OpArg = GEPInstr->getOperand(0);
174+
if (llvm::ConstantExpr *NewGEPInstr =
175+
llvm::dyn_cast<llvm::ConstantExpr>(OpArg)) {
176+
GEPInstr = NewGEPInstr;
177+
continue;
178+
}
173179

174180
if (auto *GlobalVar = llvm::dyn_cast<llvm::GlobalVariable>(OpArg)) {
175-
llvm::Constant *initializer = GlobalVar->getInitializer();
176-
177181
llvm::Type *ValTy = GlobalVar->getValueType();
178182
if (auto *ArrTy = llvm::dyn_cast<llvm::ArrayType>(ValTy)) {
179183
llvm::Type *ElTy = ArrTy->getElementType();
180184
if (ElTy == Ty)
181185
return nullptr;
182186
}
183187
}
188+
break;
184189
}
185190
}
186191

0 commit comments

Comments
 (0)