{"id":16336885,"url":"https://github.com/angerman/data-bitcode-plugin","last_synced_at":"2025-09-10T08:15:53.300Z","repository":{"id":79904399,"uuid":"65958138","full_name":"angerman/data-bitcode-plugin","owner":"angerman","description":"ghc plugin to run the data-bitcode llvm backend","archived":false,"fork":false,"pushed_at":"2016-12-12T13:47:47.000Z","size":39,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-21T18:51:54.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/angerman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-18T02:24:45.000Z","updated_at":"2024-11-28T01:56:30.000Z","dependencies_parsed_at":"2023-09-17T02:24:25.685Z","dependency_job_id":null,"html_url":"https://github.com/angerman/data-bitcode-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/angerman/data-bitcode-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angerman%2Fdata-bitcode-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angerman%2Fdata-bitcode-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angerman%2Fdata-bitcode-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angerman%2Fdata-bitcode-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angerman","download_url":"https://codeload.github.com/angerman/data-bitcode-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angerman%2Fdata-bitcode-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274430403,"owners_count":25283605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T23:45:14.419Z","updated_at":"2025-09-10T08:15:53.291Z","avatar_url":"https://github.com/angerman.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A ghc llvm backend plugin\n\nThis is a plugin that hooks into ghc's compiliation pipeline to produce bitcode\nas a result.\n\n## Running it\n\n### via nix\n\nSee [data-bitcode-plugin-env](https://github.com/angerman/data-bitcode-plugin-env).\n\n### via stack\n\n\nCompile the plugin:\n```\ndata-bitcode-plugin $ stack build\n```\n\nAnd compile a test module:\n```\n$ stack ghc -- Test.hs -fplugin Data.BitCode.Plugin -fllvm # -fllvm -keep-llvm-files are useful flags to compare it to the stock llvm backend.\n```\n\nThis however requires that the ghc supports the extended plugin interface.\n\nTo see what the resulting llvm ir is, use the `llvm-dis` tool.\n\n```\n$ llvm-dis \u003c File.bc | less\n```\n\n## Supported plugin flags\n\n- `-dump-ast`: can be used to print the internal module representation for inspection.\n- `-dump-module`: will write a `Data.Binary` serialized version of the internal bitcode representation into a `.bcbin` file. (to be used with `-keep-llvm-files`), that can be used to analyze potential performance issues (from the bitcode represetioatn onwards) in isolation.\n\nPlugin arguments can be specified as `-fplugin-opt Data.BitCode.Plugin:-dump-ast` for example.\n\n## Wishlist (TODOs)\n\n- [ ] The EDSL does not support function level VSTs, and hence we do not have names for variable. This makes reading the produced\n      llvm ir (via llvm-dis) quite hard (e.g. you do not know immediately what which register value is.)\n- [ ] Fix the GHC plugin system, to parse files first before parsing commandline arguments. Otherwise `{-# ... #-}` is lost.\n      e.g. this `{-# OPTIONS_GHC -fplugin Data.BitCode.Plugin #-}` is not picked up correctly.\n- [ ] Properly use plugin arguments. (Would likely required the whole plugin to run through a reader.)\n  - [ ] Allow things like -dump-typetable, -dump-valuetable, -dump-ast, -dump-statements\n- [ ] Turn the plugin into an ExceptT and use catchE to find lower level exceptions.\n- [ ] More pervasive use of `Text.PrettyPrint`\n- [ ] Fix ExternallyVisible. We expose everything right now.\n\n## GHC Compilation Pipeline:\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nin general keep the phases and platform data types. If\nwe wanted to introduce new phases or platforms, adding this\nto GHC should be a minor issue.\n                                                 \n                                                \n class PipelineDriver where\n   (1x) nextPhase :: DynFlags -\u003e Phase -\u003e Phase\n   (3x) startPhase :: String -\u003e Phase\n   (6x) phaseInputExt :: Phase -\u003e String\n\n-- might want to customize the objish_suffixes, ..., dynlib_suffixes as well.\n\nMaybe it's better to have hook functions for these three functions?\nhookedNextPhase :: (DynFlags -\u003e Phase -\u003e Phase) -\u003e DynFlags -\u003e Phase -\u003e Phase\nhookedNextPhase super dflags phase\n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                                \n                                        \n                                        \n                                        \n\n\n\n\n\n\n\n\n  +----------------------------+\n  | runPhase (RealPhase CmmCpp)|\n  +-----------|----------------+\n              |\n              v\n  +--------------------------+   next_phase = hscPostBackendPhase dflags HsSrcFile hsc_lang   +-----------------------------------+\n  | runPhase (RealPhase Cmm) |   output_fn  = phaseOutputFilename next_phase                  | hscPostBackendPhase               |\n  +-----------|--------------+                - phaseOutputFilename stop_phase                | _ HsBootFile   _    = StopLn      |\n              |                                                     output_spec               | _ HsigFile     _    = StopLn      |\n              v                                                     src_basename              | d _            HscC = HCc         |\n   +-------------------------+                                      dflags                    | d _            HscAsm = Splitter if SplitObj            \n   | hscCompileCmmFile       |                                      next_phase                |                         As False else       \n   +----------|--------------+                                      maybe_loc                 | d _            HscLlvm = LlvmOpt  |\n              |                                 - getOutputFilename                           | d _            HscNothing = StopLn|\n              |                                   nextPhase == stopPhase                      | d _            HscInterpreted = StopLn\n              v                                    \u0026\u0026 Persistent - persistent_fn              +-----------------------------------+\n  +---------------------------+                    \u0026\u0026 SpecificFile - outputfile dflags\n  | codeOutput                |                   As \u0026\u0026 Opt_KeepS - persistent_fn     \n  |                           |                   HCc \u0026\u0026 Opt_KeepHc - persistent_fn  \n  |                           |                   LlvmOpt \u0026\u0026 Opt_KeepLlvmFiles - persistent_fn \n  |                           |                   ^\n  +---------------------------+                   +- nextPhase  \n                                                  Otherwise - newTempName dflags suffix\n\n                                                  suffix Hcc       -\u003e hcsuf\n                                                         MergeStug -\u003e osuf\n                                                         StopLn    -\u003e osuf\n                                                         _other    -\u003e phaseInputExt _other\n\n\n\n                                                  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangerman%2Fdata-bitcode-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangerman%2Fdata-bitcode-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangerman%2Fdata-bitcode-plugin/lists"}