Skip to content

Commit 5d96f3a

Browse files
committed
[CHERI] generate cap for SMUL overflow temporary
This was previously a pointer from AS0 (i32) which trips an assertion later in `getCopyToParts` (called by `LoweCall`) when a capability is copied into that position.
1 parent b50aa39 commit 5d96f3a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_VAARG(SDNode *N) {
17481748
Part = DAG.getNode(
17491749
ISD::SHL, dl, NVT, Part,
17501750
DAG.getConstant(i * RegVT.getSizeInBits(), dl,
1751-
TLI.getPointerRangeTy(DAG.getDataLayout())));
1751+
rogramI.getPointerRangeTy(DAG.getDataLayout())));
17521752
Res = DAG.getNode(ISD::OR, dl, NVT, Res, Part);
17531753
}
17541754

@@ -4822,7 +4822,9 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N,
48224822

48234823
Type *RetTy = VT.getTypeForEVT(*DAG.getContext());
48244824
EVT PtrRangeVT = TLI.getPointerRangeTy(DAG.getDataLayout());
4825-
Type *PtrTy = PtrRangeVT.getTypeForEVT(*DAG.getContext());
4825+
EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout(),
4826+
DAG.getDataLayout().getProgramAddressSpace());
4827+
Type *PtrTy = PtrVT.getTypeForEVT(*DAG.getContext());
48264828

48274829
// Replace this with a libcall that will check overflow.
48284830
RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
@@ -4875,7 +4877,8 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N,
48754877

48764878
// Also pass the address of the overflow check.
48774879
Entry.Node = Temp;
4878-
Entry.Ty = PointerType::getUnqual(PtrTy->getContext());
4880+
Entry.Ty =
4881+
PointerType::get(PtrTy, DAG.getDataLayout().getProgramAddressSpace());
48794882
Entry.IsSExt = true;
48804883
Entry.IsZExt = false;
48814884
Args.push_back(Entry);

0 commit comments

Comments
 (0)