Skip to content

Commit 4eaa27f

Browse files
LU-JOHNagainull
authored andcommitted
Fix misuse of dyn_cast (intel#1959)
Signed-off-by: Lu, John <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@548fc2d
1 parent e16352d commit 4eaa27f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,8 +2184,8 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
21842184
GEP->setIsInBounds(IsInbound);
21852185
V = GEP;
21862186
} else {
2187-
V = ConstantExpr::getGetElementPtr(BaseTy, dyn_cast<Constant>(Base),
2188-
Index, IsInbound);
2187+
auto *CT = cast<Constant>(Base);
2188+
V = ConstantExpr::getGetElementPtr(BaseTy, CT, Index, IsInbound);
21892189
}
21902190
return mapValue(BV, V);
21912191
}
@@ -2200,14 +2200,14 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
22002200
switch (static_cast<size_t>(BV->getType()->getOpCode())) {
22012201
case OpTypeVector:
22022202
return mapValue(BV, ConstantVector::get(CV));
2203-
case OpTypeArray:
2204-
return mapValue(
2205-
BV, ConstantArray::get(dyn_cast<ArrayType>(transType(CC->getType())),
2206-
CV));
2207-
case OpTypeStruct:
2208-
return mapValue(BV,
2209-
ConstantStruct::get(
2210-
dyn_cast<StructType>(transType(CC->getType())), CV));
2203+
case OpTypeArray: {
2204+
auto *AT = cast<ArrayType>(transType(CC->getType()));
2205+
return mapValue(BV, ConstantArray::get(AT, CV));
2206+
}
2207+
case OpTypeStruct: {
2208+
auto *ST = cast<StructType>(transType(CC->getType()));
2209+
return mapValue(BV, ConstantStruct::get(ST, CV));
2210+
}
22112211
case internal::OpTypeJointMatrixINTEL:
22122212
return mapValue(BV, transSPIRVBuiltinFromInst(CC, BB));
22132213
default:

0 commit comments

Comments
 (0)