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,384
    • Issues 4,384
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 372
    • Merge Requests 372
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18539

Closed
Open
Opened Aug 05, 2020 by Andreas Klebinger@AndreasKDeveloper

Core and simplifier dumps should list the name of ffi functions called.

Motivation

Given this code

{-# LANGUAGE ForeignFunctionInterface, CPP #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Bits (setBit)
import Data.Word (Word32)
import Data.Int (Int64)

main :: IO ()
main = offending 100 0 1

offending :: Int64 -> Int64 -> Word32 -> IO ()
offending h i id = do
    oldMask <- sendMessage h (2245) 0
    let newMask = setBit oldMask (fromIntegral id)
    sendMessage h (2244) newMask
    return ()

foreign import ccall "func" sendMessage :: Int64 -> Word32 -> Int64 -> IO Int64


--------------------------------
// C Code

#include <stdio.h>
#include <stdint.h>

int64_t func(int64_t a, int64_t d) {
    printf("ffi call");
    if (a == 1) {
        printf(" with corrupted convention\n");
    }
    else {
        printf("\n");
    }
    return 0;
}

The FFI calls show up as something like this:

  case {__pkg_ccall_GC main Int#
                     -> Word#
                     -> Int#
                     -> State# RealWorld
                     -> (# State# RealWorld, Int# #)}_d14o
                     ww_s2eI 2244## ds1_d14l ds_d14m
              of
              { (# ds2_X15i, ds3_X16f #) ->
              src<Main.hs:18:5-13>
              (# ds2_X15i, src<Main.hs:18:12-13> GHC.Tuple.() #)
              }

But it would really help readability and grepability of these things if they contained the name of the function we are calling.

Proposal

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18539