[llvm] [CodeGen] Handling Oversized Alloca Types under 32 bit Mode to Avoid Code Generator Crash (PR #71472)
Qiongsi Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 7 06:59:42 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(),
----------------
qiongsiwu wrote:
It seems to me that `getZExtOrTrunc` takes an `SDValue` as its input. `TySize` here is not a `Value *`, but a constant, so I am not sure how to create an `SDValue` out of it, other than using `DAG.getConstant` (which is crashing because `getConstant` does not like oversized constants). That is why an `APInt` is used, similar to the `isScalable` case above. A few lines above (https://github.com/llvm/llvm-project/pull/71472/files#diff-34ee9626bb04949852b8ca80ba74ba7e9a43d7875410dcf993d36720f3ea6058R4132), the code performs the check we want on `AllocaSize`. I could add an additional check there for `TySize` as well, and I was limited by the fact that `TySize` is not a `Value *`.
I must be missing some APIs to do such a thing. Could you kindly point out what I am missing here? Thanks so much!
https://github.com/llvm/llvm-project/pull/71472
More information about the llvm-commits
mailing list