[llvm] [SelectionDAG] Handling Oversized Alloca Types under 32 bit Mode to Avoid Code Generator Crash (PR #71472)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 01:49:16 PST 2023
================
@@ -4138,9 +4138,10 @@ void SelectionDAGBuilder::visitAlloca(const AllocaInst &I) {
APInt(IntPtr.getScalarSizeInBits(),
TySize.getKnownMinValue())));
else
- AllocSize =
- DAG.getNode(ISD::MUL, dl, IntPtr, AllocSize,
- DAG.getConstant(TySize.getFixedValue(), dl, IntPtr));
+ AllocSize = DAG.getNode(ISD::MUL, dl, IntPtr, AllocSize,
+ DAG.getConstant(APInt(IntPtr.getScalarSizeInBits(),
----------------
arsenm wrote:
The code immediately above already does this for the scalable vector case.
```
EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout(), I.getAddressSpace());
if (AllocSize.getValueType() != IntPtr)
AllocSize = DAG.getZExtOrTrunc(AllocSize, dl, IntPtr);
```
You just need to produce the IntVT based on the size (e.g. MVT::getIntegerVT(IntPtr.getScalarSizeInBits()). You also don't need the type check here, getZExtOrTrunc does that for you
https://github.com/llvm/llvm-project/pull/71472
More information about the llvm-commits
mailing list