[llvm] [MergeFunc] Fix crash caused by bitcasting ArrayType (PR #133259)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 3 08:16:01 PDT 2025
================
@@ -76,6 +76,41 @@ void IRBuilderBase::SetInstDebugLocation(Instruction *I) const {
}
}
+Value *IRBuilderBase::CreateAggregateCast(Value *V, Type *DestTy) {
+ Type *SrcTy = V->getType();
+ if (SrcTy == DestTy)
+ return V;
+
+ if (SrcTy->isAggregateType()) {
+ unsigned NumElements;
+ if (SrcTy->isStructTy()) {
+ assert(DestTy->isStructTy() && "Expected StructType");
+ assert(SrcTy->getStructNumElements() == DestTy->getStructNumElements() &&
+ "Expected StructTypes with equal number of elements");
+ NumElements = SrcTy->getStructNumElements();
+ } else {
+ assert(SrcTy->isArrayTy());
+ assert(DestTy->isArrayTy() && "Expected ArrayType");
----------------
fhahn wrote:
```suggestion
assert(SrcTy->isArrayTy() && DestTy->isArrayTy() && "Expected ArrayType");
```
https://github.com/llvm/llvm-project/pull/133259
More information about the llvm-commits
mailing list