[llvm] [DirectX] Bug fix for Data Scalarization crash (PR #118426)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 18 09:46:18 PST 2024
================
@@ -106,6 +90,21 @@ bool DataScalarizerVisitor::visitLoadInst(LoadInst &LI) {
unsigned NumOperands = LI.getNumOperands();
for (unsigned I = 0; I < NumOperands; ++I) {
Value *CurrOpperand = LI.getOperand(I);
+ ConstantExpr *CE = dyn_cast<ConstantExpr>(CurrOpperand);
+ if (CE && CE->getOpcode() == Instruction::GetElementPtr) {
+ GetElementPtrInst *OldGEP =
+ cast<GetElementPtrInst>(CE->getAsInstruction());
+ OldGEP->insertBefore(&LI);
+ Value *NewGEP = createNewGetElementPtr(*OldGEP);
----------------
bogner wrote:
I think I prefer the version where this calls `visitGetElementPtrInstruction` rather than calling `createNewGetElementPtr`, for consistency with the other, similar pass. If you'd like to keep this one as is though, we should at least add an `assert(NewGEP)` here to make it clear that the failure path in `createNewGetElementPtr` isn't expected in these cases.
https://github.com/llvm/llvm-project/pull/118426
More information about the llvm-commits
mailing list