Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,321
    • Issues 4,321
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 371
    • Merge Requests 371
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Merge Requests
  • !3013

Open
Opened Apr 01, 2020 by Sebastian Graf@sgraf812Developer
  • Report abuse
Report abuse

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b "wip/primop-traits" "origin/wip/primop-traits"

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout "master"
git merge --no-ff "wip/primop-traits"

Step 4. Push the result of the merge to GitLab

git push origin "master"

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

WIP: Clear up PrimOp effect semantics

  • Overview 10
  • Commits 3
  • Pipelines 5
  • Changes 7

Previously we classified PrimOps with two boolean flags, can_fail and has_side_effects. Although there is quite a slew of documentation surrounding them, see Note [PrimOp can_fail and has_side_effects] and Note [Transformations affected by can_fail and has_side_effects], I found it quite hard to understand and also was confused of conservative misclassifications for some read-only primops like readMutVar# (which is marked as has_side_effect, although it actually shouldn't per semantics of has_side_effect, see #3207 (closed)), but not for others (indexIntArr#, which is just can_fail).

This patch defines a total order of 5 different PrimOpEffects:

  • NoEffect: A pure primop
  • ThrowsImprecise: Possibly throws an imprecise exception (and may perform read effects)
  • WriteEffect: May write to a mutable ref cell, array or the world (or read from them or throw an imprecise exception)
  • ThrowsPrecise: May throw a precise exception, or do any of the aforementioned effects.

Each effect is strictly "stronger" than its predecessor in this list wrt. to program transformation that are sound to apply to it. For example, we may speculatively execute read effects (as long as their data dependencies such as the state token are satisfied), but we may not speculate division (for fear of imprecise division-by-zero errors).

Which PrimOpEffect inhibits which transformation, including examples, is spelled out in the rewritten Note [Transformations affected by PrimOpEffect].

Fixes #17900.

Edited May 28, 2020 by Sebastian Graf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
Reference: ghc/ghc!3013
Source branch: wip/primop-traits