[llvm] [DirectX] Bug fix for Data Scalarization crash (PR #118426)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 21:30:47 PST 2024
================
@@ -321,6 +321,18 @@ static void collectElements(Constant *Init,
Elements.push_back(Init);
return;
}
+ auto *LLVMArrayType = dyn_cast<ArrayType>(Init->getType());
+ if (isa<ConstantAggregateZero>(Init)) {
+ for (unsigned I = 0; I < LLVMArrayType->getNumElements(); ++I)
----------------
bogner wrote:
It's best not to call a function in the condition of a for loop. It doesn't really matter much here since this happens to be a simple accessor, but it's good form to avoid it.
```suggestion
for (unsigned I = 0, E = LLVMArrayType->getNumElements(); I != E; ++I)
```
Same comment a few lines below.
https://github.com/llvm/llvm-project/pull/118426
More information about the llvm-commits
mailing list