Skip to content

Commit 2fbbbbe

Browse files
committed
remove llvm:: namespace, and add alloca case
1 parent b42ee72 commit 2fbbbbe

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

llvm/lib/Target/DirectX/DXILPrepare.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,32 +155,35 @@ class DXILPrepareModule : public ModulePass {
155155
}
156156

157157
// Also omit the bitcast for matching global array types
158-
if (auto *GlobalVar = llvm::dyn_cast<llvm::GlobalVariable>(Operand)) {
159-
llvm::Type *ValTy = GlobalVar->getValueType();
158+
if (auto *GlobalVar = dyn_cast<GlobalVariable>(Operand)) {
159+
Type *ValTy = GlobalVar->getValueType();
160160

161-
if (auto *ArrTy = llvm::dyn_cast<llvm::ArrayType>(ValTy)) {
162-
llvm::Type *ElTy = ArrTy->getElementType();
161+
if (auto *ArrTy = dyn_cast<ArrayType>(ValTy)) {
162+
Type *ElTy = ArrTy->getElementType();
163163
if (ElTy == Ty)
164164
return nullptr;
165165
}
166166
}
167167

168+
// Also omit the bitcast for alloca instructions
169+
if (auto *AI = dyn_cast<AllocaInst>(Operand)) {
170+
return nullptr;
171+
}
172+
168173
// finally, drill down GEP instructions until we get the array
169174
// that is being accessed, and compare element types
170-
if (llvm::ConstantExpr *GEPInstr =
171-
llvm::dyn_cast<llvm::ConstantExpr>(Operand)) {
172-
while (GEPInstr->getOpcode() == llvm::Instruction::GetElementPtr) {
173-
llvm::Value *OpArg = GEPInstr->getOperand(0);
174-
if (llvm::ConstantExpr *NewGEPInstr =
175-
llvm::dyn_cast<llvm::ConstantExpr>(OpArg)) {
175+
if (ConstantExpr *GEPInstr = dyn_cast<ConstantExpr>(Operand)) {
176+
while (GEPInstr->getOpcode() == Instruction::GetElementPtr) {
177+
Value *OpArg = GEPInstr->getOperand(0);
178+
if (ConstantExpr *NewGEPInstr = dyn_cast<ConstantExpr>(OpArg)) {
176179
GEPInstr = NewGEPInstr;
177180
continue;
178181
}
179182

180-
if (auto *GlobalVar = llvm::dyn_cast<llvm::GlobalVariable>(OpArg)) {
181-
llvm::Type *ValTy = GlobalVar->getValueType();
182-
if (auto *ArrTy = llvm::dyn_cast<llvm::ArrayType>(ValTy)) {
183-
llvm::Type *ElTy = ArrTy->getElementType();
183+
if (auto *GlobalVar = dyn_cast<GlobalVariable>(OpArg)) {
184+
Type *ValTy = GlobalVar->getValueType();
185+
if (auto *ArrTy = dyn_cast<ArrayType>(ValTy)) {
186+
Type *ElTy = ArrTy->getElementType();
184187
if (ElTy == Ty)
185188
return nullptr;
186189
}

0 commit comments

Comments
 (0)