[Git][ghc/ghc][wip/sjakobi/T26964] StgToCmm: only record primop name when -fcheck-prim-bounds is on
Simon Jakobi pushed to branch wip/sjakobi/T26964 at Glasgow Haskell Compiler / GHC Commits: 7ec0dc61 by Simon Jakobi at 2026-06-03T16:42:48+02:00 StgToCmm: only record primop name when -fcheck-prim-bounds is on Recording the primop name for bounds-check error messages allocated a name thunk and updated FCodeState on every primop compilation. Guard it on the flag so the common unchecked case pays nothing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> - - - - - 1 changed file: - compiler/GHC/StgToCmm/Prim.hs Changes: ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -96,9 +96,13 @@ cmmPrimOpApp cfg primop cmm_args mres_ty = do -- if the result type isn't explicitly given, we directly use the -- result type of the primop. res_ty = fromMaybe (primOpResultType primop) mres_ty - -- Record the primop name so that any -fcheck-prim-bounds failure handler - -- emitted while compiling it can name it in the error message. - withCurrentPrimOpName (occNameString (primOpOcc primop)) (f res_ty) + -- When -fcheck-prim-bounds is on, record the primop name so that any + -- bounds-check failure handler emitted while compiling it can name it in the + -- error message. Guarded by the flag so that the common (unchecked) case pays + -- nothing: no name thunk, no FCodeState update. + if stgToCmmDoBoundsCheck cfg + then withCurrentPrimOpName (occNameString (primOpOcc primop)) (f res_ty) + else f res_ty externalPrimop :: PrimOp -> [CmmExpr] -> PrimopCmmEmit externalPrimop primop args = outOfLinePrimop (callExternalPrimop primop args) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ec0dc614d5dce3e69fd73a85ea7e93e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ec0dc614d5dce3e69fd73a85ea7e93e... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Jakobi (@sjakobi2)