From b377e5904ec00cb2e8c99ae53b5a3ddbaedd5c93 Mon Sep 17 00:00:00 2001 From: James Wainwright Date: Tue, 18 Mar 2025 19:28:56 +0000 Subject: [PATCH] [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. --- llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index c1c246adf00e3..ffda40da227ff 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -4822,7 +4822,9 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N, Type *RetTy = VT.getTypeForEVT(*DAG.getContext()); EVT PtrRangeVT = TLI.getPointerRangeTy(DAG.getDataLayout()); - Type *PtrTy = PtrRangeVT.getTypeForEVT(*DAG.getContext()); + EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout(), + DAG.getDataLayout().getProgramAddressSpace()); + Type *PtrTy = PtrVT.getTypeForEVT(*DAG.getContext()); // Replace this with a libcall that will check overflow. RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL; @@ -4875,7 +4877,8 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N, // Also pass the address of the overflow check. Entry.Node = Temp; - Entry.Ty = PointerType::getUnqual(PtrTy->getContext()); + Entry.Ty = + PointerType::get(PtrTy, DAG.getDataLayout().getProgramAddressSpace()); Entry.IsSExt = true; Entry.IsZExt = false; Args.push_back(Entry);