Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ghc/ghc
  • bgamari/ghc
  • syd/ghc
  • ggreif/ghc
  • watashi/ghc
  • RolandSenn/ghc
  • mpickering/ghc
  • DavidEichmann/ghc
  • carter/ghc
  • harpocrates/ghc
  • ethercrow/ghc
  • mijicd/ghc
  • adamse/ghc
  • alexbiehl/ghc
  • gridaphobe/ghc
  • trofi/ghc
  • supersven/ghc
  • ppk/ghc
  • ulysses4ever/ghc
  • AndreasK/ghc
  • ghuntley/ghc
  • shayne-fletcher-da/ghc
  • fgaz/ghc
  • yav/ghc
  • osa1/ghc
  • mbbx6spp/ghc
  • JulianLeviston/ghc
  • reactormonk/ghc
  • rae/ghc
  • takenobu-hs/ghc
  • michalt/ghc
  • andrewthad/ghc
  • hsyl20/ghc
  • scottgw/ghc
  • sjakobi/ghc
  • angerman/ghc
  • RyanGlScott/ghc
  • hvr/ghc
  • howtonotwin/ghc
  • chessai/ghc
  • m-renaud/ghc
  • brprice/ghc
  • stevehartdata/ghc
  • sighingnow/ghc
  • kgardas/ghc
  • ckoparkar/ghc
  • alp/ghc
  • smaeul/ghc
  • kakkun61/ghc
  • sykloid/ghc
  • newhoggy/ghc
  • toonn/ghc
  • nineonine/ghc
  • Phyx/ghc
  • ezyang/ghc
  • tweag/ghc
  • langston/ghc
  • ndmitchell/ghc
  • rockbmb/ghc
  • artempyanykh/ghc
  • mniip/ghc
  • mynguyenbmc/ghc
  • alexfmpe/ghc
  • crockeea/ghc
  • nh2/ghc
  • vaibhavsagar/ghc
  • phadej/ghc
  • Haskell-mouse/ghc
  • lolotp/ghc
  • spacekitteh/ghc
  • michaelpj/ghc
  • mgsloan/ghc
  • HPCohen/ghc
  • tmobile/ghc
  • radrow/ghc
  • simonmar/ghc
  • _deepfire/ghc
  • Ericson2314/ghc
  • leitao/ghc
  • fumieval/ghc
  • trac-isovector/ghc
  • cblp/ghc
  • xich/ghc
  • ciil/ghc
  • erthalion/ghc
  • xldenis/ghc
  • autotaker/ghc
  • haskell-wasm/ghc
  • kcsongor/ghc
  • agander/ghc
  • Baranowski/ghc
  • trac-dredozubov/ghc
  • 23Skidoo/ghc
  • iustin/ghc
  • ningning/ghc
  • josefs/ghc
  • kabuhr/ghc
  • gallais/ghc
  • dten/ghc
  • expipiplus1/ghc
  • Pluralia/ghc
  • rohanjr/ghc
  • intricate/ghc
  • kirelagin/ghc
  • Javran/ghc
  • DanielG/ghc
  • trac-mizunashi_mana/ghc
  • pparkkin/ghc
  • bollu/ghc
  • ntc2/ghc
  • jaspervdj/ghc
  • JoshMeredith/ghc
  • wz1000/ghc
  • zkourouma/ghc
  • code5hot/ghc
  • jdprice/ghc
  • tdammers/ghc
  • J-mie6/ghc
  • trac-lantti/ghc
  • ch1bo/ghc
  • cgohla/ghc
  • lucamolteni/ghc
  • acairncross/ghc
  • amerocu/ghc
  • chreekat/ghc
  • txsmith/ghc
  • trupill/ghc
  • typetetris/ghc
  • sergv/ghc
  • fryguybob/ghc
  • erikd/ghc
  • trac-roland/ghc
  • setupminimal/ghc
  • Friede80/ghc
  • SkyWriter/ghc
  • xplorld/ghc
  • abrar/ghc
  • obsidiansystems/ghc
  • Icelandjack/ghc
  • adinapoli/ghc
  • trac-matthewbauer/ghc
  • heatsink/ghc
  • dwijnand/ghc
  • Cmdv/ghc
  • alinab/ghc
  • pepeiborra/ghc
  • fommil/ghc
  • luochen1990/ghc
  • rlupton20/ghc
  • applePrincess/ghc
  • lehins/ghc
  • ronmrdechai/ghc
  • leeadam/ghc
  • harendra/ghc
  • mightymosquito1991/ghc
  • trac-gershomb/ghc
  • lucajulian/ghc
  • Rizary/ghc
  • VictorCMiraldo/ghc
  • jamesbrock/ghc
  • andrewdmeier/ghc
  • luke/ghc
  • pranaysashank/ghc
  • cocreature/ghc
  • hithroc/ghc
  • obreitwi/ghc
  • slrtbtfs/ghc
  • kaol/ghc
  • yairchu/ghc
  • Mathemagician98/ghc
  • trac-taylorfausak/ghc
  • leungbk/ghc
  • MichaWiedenmann/ghc
  • chris-martin/ghc
  • TDecki/ghc
  • adithyaov/ghc
  • trac-gelisam/ghc
  • Lysxia/ghc
  • complyue/ghc
  • bwignall/ghc
  • sternmull/ghc
  • sonika/ghc
  • leif/ghc
  • broadwaylamb/ghc
  • myszon/ghc
  • danbroooks/ghc
  • Mechachleopteryx/ghc
  • zardyh/ghc
  • trac-vdukhovni/ghc
  • OmarKhaledAbdo/ghc
  • arrowd/ghc
  • Bodigrim/ghc
  • matheus23/ghc
  • cardenaso11/ghc
  • trac-Athas/ghc
  • mb720/ghc
  • DylanZA/ghc
  • liff/ghc
  • typedrat/ghc
  • trac-claude/ghc
  • jbm/ghc
  • Gertjan423/ghc
  • PHO/ghc
  • JKTKops/ghc
  • kockahonza/ghc
  • msakai/ghc
  • Sir4ur0n/ghc
  • barambani/ghc
  • vishnu.c/ghc
  • dcoutts/ghc
  • trac-runeks/ghc
  • trac-MaxGabriel/ghc
  • lexi.lambda/ghc
  • strake/ghc
  • spavikevik/ghc
  • JakobBruenker/ghc
  • rmanne/ghc
  • gdziadkiewicz/ghc
  • ani/ghc
  • iliastsi/ghc
  • smunix/ghc
  • judah/ghc
  • blackgnezdo/ghc
  • emilypi/ghc
  • trac-bpfoley/ghc
  • muesli4/ghc
  • trac-gkaracha/ghc
  • Kleidukos/ghc
  • nek0/ghc
  • TristanCacqueray/ghc
  • dwulive/ghc
  • mbakke/ghc
  • arybczak/ghc
  • Yang123321/ghc
  • maksbotan/ghc
  • QuietMisdreavus/ghc
  • trac-olshanskydr/ghc
  • emekoi/ghc
  • samuela/ghc
  • josephcsible/ghc
  • dramforever/ghc
  • lpsmith/ghc
  • DenisFrezzato/ghc
  • michivi/ghc
  • jneira/ghc
  • jeffhappily/ghc
  • Ivan-Yudin/ghc
  • nakaji-dayo/ghc
  • gdevanla/ghc
  • galen/ghc
  • fendor/ghc
  • yaitskov/ghc
  • rcythr/ghc
  • awpr/ghc
  • jeremyschlatter/ghc
  • Aver1y/ghc
  • mitchellvitez/ghc
  • merijn/ghc
  • tomjaguarpaw1/ghc
  • trac-NoidedSuper/ghc
  • erewok/ghc
  • trac-junji.hashimoto/ghc
  • adamwespiser/ghc
  • bjaress/ghc
  • jhrcek/ghc
  • leonschoorl/ghc
  • lukasz-golebiewski/ghc
  • sheaf/ghc
  • last-g/ghc
  • carassius1014/ghc
  • eschwartz/ghc
  • dwincort/ghc
  • felixwiemuth/ghc
  • TimWSpence/ghc
  • marcusmonteirodesouza/ghc
  • WJWH/ghc
  • vtols/ghc
  • theobat/ghc
  • BinderDavid/ghc
  • ckoparkar0/ghc
  • alexander-kjeldaas/ghc
  • dme2/ghc
  • philderbeast/ghc
  • aaronallen8455/ghc
  • rayshih/ghc
  • benkard/ghc
  • mpardalos/ghc
  • saidelman/ghc
  • leiftw/ghc
  • ca333/ghc
  • bwroga/ghc
  • nmichael44/ghc
  • trac-crobbins/ghc
  • felixonmars/ghc
  • adityagupta1089/ghc
  • hgsipiere/ghc
  • treeowl/ghc
  • alexpeits/ghc
  • CraigFe/ghc
  • dnlkrgr/ghc
  • kerckhove_ts/ghc
  • cptwunderlich/ghc
  • eiais/ghc
  • hahohihu/ghc
  • sanchayan/ghc
  • lemmih/ghc
  • sehqlr/ghc
  • trac-dbeacham/ghc
  • luite/ghc
  • trac-f-a/ghc
  • vados/ghc
  • luntain/ghc
  • fatho/ghc
  • alexbiehl-gc/ghc
  • dcbdan/ghc
  • tvh/ghc
  • liam-ly/ghc
  • timbobbarnes/ghc
  • GovanifY/ghc
  • shanth2600/ghc
  • gliboc/ghc
  • duog/ghc
  • moxonsghost/ghc
  • zander/ghc
  • masaeedu/ghc
  • georgefst/ghc
  • guibou/ghc
  • nicuveo/ghc
  • mdebruijne/ghc
  • stjordanis/ghc
  • emiflake/ghc
  • wygulmage/ghc
  • frasertweedale/ghc
  • coot/ghc
  • aratamizuki/ghc
  • tsandstr/ghc
  • mrBliss/ghc
  • Anton-Latukha/ghc
  • tadfisher/ghc
  • vapourismo/ghc
  • Sorokin-Anton/ghc
  • basile-henry/ghc
  • trac-mightybyte/ghc
  • AbsoluteNikola/ghc
  • cobrien99/ghc
  • songzh/ghc
  • blamario/ghc
  • aj4ayushjain/ghc
  • trac-utdemir/ghc
  • tangcl/ghc
  • hdgarrood/ghc
  • maerwald/ghc
  • arjun/ghc
  • ratherforky/ghc
  • haskieLambda/ghc
  • EmilGedda/ghc
  • Bogicevic/ghc
  • eddiejessup/ghc
  • kozross/ghc
  • AlistairB/ghc
  • 3Rafal/ghc
  • christiaanb/ghc
  • trac-bit/ghc
  • matsumonkie/ghc
  • trac-parsonsmatt/ghc
  • chisui/ghc
  • jaro/ghc
  • trac-kmiyazato/ghc
  • davidsd/ghc
  • Tritlo/ghc
  • I-B-3/ghc
  • lykahb/ghc
  • AriFordsham/ghc
  • turion1/ghc
  • berberman/ghc
  • christiantakle/ghc
  • zyklotomic/ghc
  • trac-ocramz/ghc
  • CSEdd/ghc
  • doyougnu/ghc
  • mmhat/ghc
  • why-not-try-calmer/ghc
  • plutotulp/ghc
  • kjekac/ghc
  • Manvi07/ghc
  • teo/ghc
  • cactus/ghc
  • CarrieMY/ghc
  • abel/ghc
  • yihming/ghc
  • tsakki/ghc
  • jessicah/ghc
  • oliverbunting/ghc
  • meld/ghc
  • friedbrice/ghc
  • Joald/ghc
  • abarbu/ghc
  • DigitalBrains1/ghc
  • sterni/ghc
  • alexDarcy/ghc
  • hexchain/ghc
  • minimario/ghc
  • zliu41/ghc
  • tommd/ghc
  • jazcarate/ghc
  • peterbecich/ghc
  • alirezaghey/ghc
  • solomon/ghc
  • mikael.urankar/ghc
  • davjam/ghc
  • int-index/ghc
  • MorrowM/ghc
  • nrnrnr/ghc
  • Sonfamm/ghc-test-only
  • afzt1/ghc
  • nguyenhaibinh-tpc/ghc
  • trac-lierdakil/ghc
  • MichaWiedenmann1/ghc
  • jmorag/ghc
  • Ziharrk/ghc
  • trac-MitchellSalad/ghc
  • juampe/ghc
  • jwaldmann/ghc
  • snowleopard/ghc
  • juhp/ghc
  • normalcoder/ghc
  • ksqsf/ghc
  • trac-jberryman/ghc
  • roberth/ghc
  • 1ntEgr8/ghc
  • epworth/ghc
  • MrAdityaAlok/ghc
  • JunmingZhao42/ghc
  • jappeace/ghc
  • trac-Gabriel439/ghc
  • alt-romes/ghc
  • HugoPeters1024/ghc
  • 10ne1/ghc-fork
  • agentultra/ghc
  • Garfield1002/ghc
  • ChickenProp/ghc
  • clyring/ghc
  • MaxHearnden/ghc
  • jumper149/ghc
  • vem/ghc
  • ketzacoatl/ghc
  • Rosuavio/ghc
  • jackohughes/ghc
  • p4l1ly/ghc
  • konsumlamm/ghc
  • shlevy/ghc
  • torsten.schmits/ghc
  • andremarianiello/ghc
  • amesgen/ghc
  • googleson78/ghc
  • InfiniteVerma/ghc
  • uhbif19/ghc
  • yiyunliu/ghc
  • raehik/ghc
  • mrkun/ghc
  • telser/ghc
  • 1Jajen1/ghc
  • slotThe/ghc
  • WinstonHartnett/ghc
  • mpilgrem/ghc
  • dreamsmasher/ghc
  • schuelermine/ghc
  • trac-Viwor/ghc
  • undergroundquizscene/ghc
  • evertedsphere/ghc
  • coltenwebb/ghc
  • oberblastmeister/ghc
  • agrue/ghc
  • lf-/ghc
  • zacwood9/ghc
  • steshaw/ghc
  • high-cloud/ghc
  • SkamDart/ghc
  • PiDelport/ghc
  • maoif/ghc
  • RossPaterson/ghc
  • CharlesTaylor7/ghc
  • ribosomerocker/ghc
  • trac-ramirez7/ghc
  • daig/ghc
  • NicolasT/ghc
  • FinleyMcIlwaine/ghc
  • lawtonnichols/ghc
  • jmtd/ghc
  • ozkutuk/ghc
  • wildsebastian/ghc
  • nikshalark/ghc
  • lrzlin/ghc
  • tobias/ghc
  • fw/ghc
  • hawkinsw/ghc
  • type-dance/ghc
  • rui314/ghc
  • ocharles/ghc
  • wavewave/ghc
  • TheKK/ghc
  • nomeata/ghc
  • trac-csabahruska/ghc
  • jonathanjameswatson/ghc
  • L-as/ghc
  • Axman6/ghc
  • barracuda156/ghc
  • trac-jship/ghc
  • jake-87/ghc
  • meooow/ghc
  • rebeccat/ghc
  • hamana55/ghc
  • Enigmage/ghc
  • kokobd/ghc
  • agevelt/ghc
  • gshen42/ghc
  • chrismwendt/ghc
  • MangoIV/ghc
  • teto/ghc
  • Sookr1/ghc
  • trac-thomasjm/ghc
  • barci2/ghc-dev
  • trac-m4dc4p/ghc
  • dixonary/ghc
  • breakerzirconia/ghc
  • alexsio27444/ghc
  • glocq/ghc
  • sourabhxyz/ghc
  • ryantrinkle/ghc
  • Jade/ghc
  • scedfaliako/ghc
  • martijnbastiaan/ghc
  • trac-george.colpitts/ghc
  • ammarbinfaisal/ghc
  • mimi.vx/ghc
  • lortabac/ghc
  • trac-zyla/ghc
  • benbellick/ghc
  • aadaa-fgtaa/ghc
  • jvanbruegge/ghc
  • archbung/ghc
  • gilmi/ghc
  • mfonism/ghc
  • alex-mckenna/ghc
  • Ei30metry/ghc
  • DiegoDiverio/ghc
  • jorgecunhamendes/ghc
  • liesnikov/ghc
  • akrmn/ghc
  • trac-simplifierticks/ghc
  • jacco/ghc
  • rhendric/ghc
  • damhiya/ghc
  • ryndubei/ghc
  • DaveBarton/ghc
  • trac-Profpatsch/ghc
  • GZGavinZhao/ghc
  • ncfavier/ghc
  • jameshaydon/ghc
  • ajccosta/ghc
  • dschrempf/ghc
  • cydparser/ghc
  • LinuxUserGD/ghc
  • elodielander/ghc
  • facundominguez/ghc
  • psilospore/ghc
  • lachrimae/ghc
  • dylan-thinnes/ghc-type-errors-plugin
  • hamishmack/ghc
  • Leary/ghc
  • lzszt/ghc
  • lyokha/ghc
  • trac-glaubitz/ghc
  • Rewbert/ghc
  • andreabedini/ghc
  • Jasagredo/ghc
  • sol/ghc
  • OlegAlexander/ghc
  • trac-sthibaul/ghc
  • avdv/ghc
  • Wendaolee/ghc
  • ur4t/ghc
  • daylily/ghc
  • boltzmannrain/ghc
  • mmzk1526/ghc
  • trac-fizzixnerd/ghc
  • soulomoon/ghc
  • rwmjones/ghc
  • j14i/ghc
  • tracsis/ghc
  • gesh/ghc
  • flip101/ghc
  • eldritch-cookie/ghc
  • LemonjamesD/ghc
  • pgujjula/ghc
  • skeuchel/ghc
  • noteed/ghc
  • gulin.serge/ghc
  • Torrekie/ghc
  • jlwoodwa/ghc
  • ayanamists/ghc
  • husong998/ghc
  • trac-edmundnoble/ghc
  • josephf/ghc
  • contrun/ghc
  • baulig/ghc
  • edsko/ghc
  • mzschr/ghc-issue-24732
  • ulidtko/ghc
  • Arsen/ghc
  • trac-sjoerd_visscher/ghc
  • crumbtoo/ghc
  • L0neGamer/ghc
  • DrewFenwick/ghc
  • benz0li/ghc
  • MaciejWas/ghc
  • jordanrule/ghc
  • trac-qqwy/ghc
  • LiamGoodacre/ghc
  • isomorpheme/ghc
  • trac-danidiaz/ghc
  • Kariim/ghc
  • MTaimoorZaeem/ghc
  • hololeap/ghc
  • ticat-fp/ghc
  • meritamen/ghc
  • criskell/ghc
  • trac-kraai/ghc
  • aergus/ghc
  • jdral/ghc
  • SamB/ghc
  • Tristian/ghc
  • ywgrit/ghc
  • KatsuPatrick/ghc
  • OsePedro/ghc
  • mpscholten/ghc
  • fp/ghc
  • zaquest/ghc
  • fangyi-zhou/ghc
  • augyg/ghc
640 results
Show changes
Commits on Source (36)
  • Moritz Angermann's avatar
    [Sized Cmm] properly retain sizes. · be5d74ca
    Moritz Angermann authored and Marge Bot's avatar Marge Bot committed
    
    This replaces all Word<N> = W<N># Word# and Int<N> = I<N># Int#  with
    Word<N> = W<N># Word<N># and Int<N> = I<N># Int<N>#, thus providing us
    with properly sized primitives in the codegenerator instead of pretending
    they are all full machine words.
    
    This came up when implementing darwinpcs for arm64.  The darwinpcs reqires
    us to pack function argugments in excess of registers on the stack.  While
    most procedure call standards (pcs) assume arguments are just passed in
    8 byte slots; and thus the caller does not know the exact signature to make
    the call, darwinpcs requires us to adhere to the prototype, and thus have
    the correct sizes.  If we specify CInt in the FFI call, it should correspond
    to the C int, and not just be Word sized, when it's only half the size.
    
    This does change the expected output of T16402 but the new result is no
    less correct as it eliminates the narrowing (instead of the `and` as was
    previously done).
    
    Bumps the array, bytestring, text, and binary submodules.
    
    Co-Authored-By: default avatarBen Gamari <ben@well-typed.com>
    
    Metric Increase:
        T13701
        T14697
    be5d74ca
  • Andreas Klebinger's avatar
    RTS: Fix failed inlining of copy_tag. · a84e53f9
    Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
    On windows using gcc-10 gcc failed to inline copy_tag into evacuate.
    
    To fix this we now set the always_inline attribute for the various
    copy* functions in Evac.c. The main motivation here is not the
    overhead of the function call, but rather that this allows the code
    to "specialize" for the size of the closure we copy which is often
    known at compile time.
    
    An earlier commit also tried to avoid evacuate_large inlining. But
    didn't quite succeed. So I also marked evacuate_large as noinline.
    
    Fixes #12416
    a84e53f9
  • Sylvain Henry's avatar
    Fix toArgRep to support 64-bit reps on all systems · cdbd16f5
    Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
    [This is @Ericson2314 writing a commit message for @hsyl20's patch.]
    
    (Progress towards #11953, #17377, #17375)
    
    `Int64Rep` and `Word64Rep` are currently broken on 64-bit systems.  This
    is because they should use "native arg rep" but instead use "large arg
    rep" as they do on 32-bit systems, which is either a non-concept or a
    128-bit rep depending on one's vantage point.
    
    Now, these reps currently aren't used during 64-bit compilation, so the
    brokenness isn't observed, but I don't think that constitutes reasons
    not to fix it. Firstly, the linked issues there is a clearly expressed
    desire to use explicit-bitwidth constructs in more places. Secondly, per
    [1], there are other bugs that *do* manifest from not threading
    explicit-bitwidth information all the way through the compilation
    pipeline. One can therefore view this as one piece of the larger effort
    to do that, improve ergnomics, and squash remaining bugs.
    
    Also, this is needed for !3658. I could just merge this as part of that,
    but I'm keen on merging fixes "as they are ready" so the fixes that
    aren't ready are isolated and easier to debug.
    
    [1]: https://mail.haskell.org/pipermail/ghc-devs/2020-October/019332.html
    cdbd16f5
  • Tim Barnes's avatar
    Set dynamic users-guide TOC spacing (fixes #18554) · a9378e69
    Tim Barnes authored and Marge Bot's avatar Marge Bot committed
    a9378e69
  • Ben Gamari's avatar
    rts: Use RTS_LIKELY in CHECK · 86a59d93
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Most compilers probably already infer that
    `barf` diverges but it nevertheless doesn't
    hurt to be explicit.
    86a59d93
  • Matthew Pickering's avatar
    Remove special case for GHC.ByteCode.Instr · 5757e82b
    Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
    This was added in
    https://github.com/nomeata/ghc-heap-view/commit/34935206e51b9c86902481d84d2f368a6fd93423
    
    GHC.ByteCode.Instr.BreakInfo no longer exists so the special case is dead code.
    
    Any check like this can be easily dealt with in client code.
    5757e82b
  • Matthew Pickering's avatar
    Split Up getClosureDataFromHeapRep · d9c8b5b4
    Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
    Motivation
    
    1. Don't enforce the repeated decoding of an info table, when the client
    can cache it (ghc-debug)
    2. Allow the constructor information decoding to be overridden, this
    casues segfaults in ghc-debug
    d9c8b5b4
  • Andreas Klebinger's avatar
    RegAlloc: Add missing raPlatformfield to RegAllocStatsSpill · 3e3555cc
    Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
    Fixes #18994
    
    Co-Author: Benjamin Maurer <maurer.benjamin@gmail.com>
    3e3555cc
  • Ben Gamari's avatar
    rts: Allocate MBlocks with MAP_TOP_DOWN on Windows · a1a75aa9
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    As noted in #18991, we would previously allocate heap in low memory.
    Due to this the linker, which typically *needs* low memory, would end up
    competing with the heap. In longer builds we end up running out of
    low memory entirely, leading to linking failures.
    a1a75aa9
  • Sylvain Henry's avatar
    Hadrian: fix detection of ghc-pkg for cross-compilers · 75fc1ed5
    Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
    75fc1ed5
  • Sylvain Henry's avatar
    hadrian: fix ghc-pkg uses (#17601) · 7cb5df96
    Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
    Make sure ghc-pkg doesn't read the compiler "settings" file by passing
    --no-user-package-db.
    7cb5df96
  • Ben Gamari's avatar
    gitlab-ci: Introduce a nightly cross-compilation job · e3fd4226
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    This adds a job to test cross-compilation from x86-64 to AArch64 with
    Hadrian.
    
    Fixes #18234
    e3fd4226
  • Ben Gamari's avatar
    gitlab-ci: Only deploy GitLab Pages in ghc/ghc> · 698d3d96
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    The deployments are quite large and yet are currently only served for
    the ghc/ghc> project.
    698d3d96
  • davide's avatar
    ghc-heap: partial TSO/STACK decoding · 625726f9
    davide authored and Marge Bot's avatar Marge Bot committed
    
    Co-authored-by: default avatarSven Tennie <sven.tennie@gmail.com>
    Co-authored-by: default avatarMatthew Pickering <matthewtpickering@gmail.com>
    Co-authored-by: default avatarBen Gamari <bgamari.foss@gmail.com>
    625726f9
  • Andreas Klebinger's avatar
    Small optimization to CmmSink. · 22ea9c29
    Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
    Inside `regsUsedIn` we can avoid some thunks by specializing the
    recursion. In particular we avoid the thunk for `(f e z)` in the
    MachOp/Load branches, where we know this will evaluate to z.
    
    Reduces allocations for T3294 by ~1%.
    22ea9c29
  • John Ericson's avatar
    Make primop handler indentation more consistent · bba42c62
    John Ericson authored and Marge Bot's avatar Marge Bot committed
    bba42c62
  • John Ericson's avatar
    Cleanup some primop constructor names · c82bc8e9
    John Ericson authored and Marge Bot's avatar Marge Bot committed
    Harmonize the internal (big sum type) names of the native vs fixed-sized
    number primops a bit. (Mainly by renaming the former.)
    
    No user-facing names are changed.
    c82bc8e9
  • Ben Gamari's avatar
    testsuite: Mark T14702 as fragile on Windows · ae14f160
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Due to #18953.
    ae14f160
  • Ben Gamari's avatar
    withTimings: Emit allocations counter · 1bc104b0
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    This will allow us to back out the allocations per compiler pass from
    the eventlog. Note that we dump the allocation counter rather than the
    difference since this will allow us to determine how much work is done
    *between* `withTiming` blocks.
    1bc104b0
  • GHC GitLab CI's avatar
    ThreadPaused: Don't zero slop until free vars are pushed · e992ea84
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    When threadPaused blackholes a thunk it calls `OVERWRITING_CLOSURE` to
    zero the slop for the benefit of the sanity checker. Previously this was
    done *before* pushing the thunk's free variables to the update
    remembered set. Consequently we would pull zero'd pointers to the update
    remembered set.
    e992ea84
  • GHC GitLab CI's avatar
    nonmoving: Fix regression from TSAN work · e82cd140
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    The TSAN rework (specifically aad1f803) introduced a subtle regression
    in GC.c, swapping `g0` in place of `gen`. Whoops!
    
    Fixes #18997.
    e82cd140
  • GHC GitLab CI's avatar
    rts/Messages: Add missing write barrier in THROWTO message update · 35a5207e
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    After a THROWTO message has been handle the message closure is
    overwritten by a NULL message. We must ensure that the original
    closure's pointers continue to be visible to the nonmoving GC.
    35a5207e
  • GHC GitLab CI's avatar
    nonmoving: Add missing write barrier in shrinkSmallByteArray · 0120829f
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    0120829f
  • GHC GitLab CI's avatar
    Updates: Don't zero slop until closure has been pushed · 8a4d8fb6
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    Ensure that the the free variables have been pushed to the update
    remembered set before we zero the slop.
    8a4d8fb6
  • GHC GitLab CI's avatar
    OSThreads: Fix error code checking · 2793cfdc
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    pthread_join returns its error code and apparently doesn't set errno.
    2793cfdc
  • GHC GitLab CI's avatar
    nonmoving: Don't join to mark_thread on shutdown · e391a16f
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    The mark thread is not joinable as we detach from it on creation.
    e391a16f
  • Ben Gamari's avatar
    nonmoving: Add reference to Ueno 2016 · 60d088ab
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    60d088ab
  • GHC GitLab CI's avatar
    nonmoving: Ensure that evacuated large objects are marked · 3aa60362
    GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
    See Note [Non-moving GC: Marking evacuated objects].
    3aa60362
  • Ben Gamari's avatar
    rts/m32: Refactor handling of allocator seeding · 8d304a99
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Previously, in an attempt to reduce fragmentation, each new allocator
    would map a region of M32_MAX_PAGES fresh pages to seed itself. However,
    this ends up being extremely wasteful since it turns out that we often
    use fewer than this.  Consequently, these pages end up getting freed
    which, ends up fragmenting our address space more than than we would
    have if we had naively allocated pages on-demand.
    
    Here we refactor m32 to avoid this waste while achieving the
    fragmentation mitigation previously desired. In particular, we move all
    page allocation into the global m32_alloc_page, which will pull a page
    from the free page pool. If the free page pool is empty we then refill
    it by allocating a region of M32_MAP_PAGES and adding them to the pool.
    
    Furthermore, we do away with the initial seeding entirely. That is, the
    allocator starts with no active pages: pages are rather allocated on an
    as-needed basis.
    
    On the whole this ends up being a pleasingly simple change,
    simultaneously making m32 more efficient, more robust, and simpler.
    
    Fixes #18980.
    8d304a99
  • Ben Gamari's avatar
    rts: Use CHECK instead of assert · b6629289
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Use the GHC wrappers instead of <assert.h>.
    b6629289
  • Ben Gamari's avatar
    rts/linker: Replace some ASSERTs with CHECK · 9f4efa6a
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    In the past some people have confused ASSERT, which is for checking
    internal invariants, which CHECK, which should be used when checking
    things that might fail due to bad input (and therefore should be enabled
    even in the release compiler). Change some of these cases in the linker
    to use CHECK.
    9f4efa6a
  • Ryan Scott's avatar
    Allow deploy:pages job to fail · 0f8a4655
    Ryan Scott authored and Marge Bot's avatar Marge Bot committed
    See #18973.
    0f8a4655
  • Richard Eisenberg's avatar
    Move core flattening algorithm to Core.Unify · 636db9ef
    Richard Eisenberg authored
    This sets the stage for a later change, where this
    algorithm will be needed from GHC.Core.InstEnv.
    
    This commit also splits GHC.Core.Map into
    GHC.Core.Map.Type and GHC.Core.Map.Expr,
    in order to avoid module import cycles
    with GHC.Core.
    636db9ef
  • Richard Eisenberg's avatar
    Bump the # of commits searched for perf baseline · da912d0a
    Richard Eisenberg authored
    The previous value of 75 meant that a feature branch with
    more than 75 commits would get spurious CI passes.
    
    This affects #18692, but does not fix that ticket, because
    if a baseline cannot be found, we should fail, not succeed.
    da912d0a
  • Richard Eisenberg's avatar
    Remove flattening variables · 50b22545
    Richard Eisenberg authored
    This patch redesigns the flattener to simplify type family applications
    directly instead of using flattening meta-variables and skolems. The key new
    innovation is the CanEqLHS type and the new CEqCan constraint (Ct). A CanEqLHS
    is either a type variable or exactly-saturated type family application; either
    can now be rewritten using a CEqCan constraint in the inert set.
    
    Because the flattener no longer reduces all type family applications to
    variables, there was some performance degradation if a lengthy type family
    application is now flattened over and over (not making progress). To
    compensate, this patch contains some extra optimizations in the flattener,
    leading to a number of performance improvements.
    
    Close #18875.
    Close #18910.
    
    There are many extra parts of the compiler that had to be affected in writing
    this patch:
    
    * The family-application cache (formerly the flat-cache) sometimes stores
      coercions built from Given inerts. When these inerts get kicked out, we must
      kick out from the cache as well. (This was, I believe, true previously, but
      somehow never caused trouble.) Kicking out from the cache requires adding a
      filterTM function to TrieMap.
    
    * This patch obviates the need to distinguish "blocking" coercion holes from
      non-blocking ones (which, previously, arose from CFunEqCans). There is thus
      some simplification around coercion holes.
    
    * Extra commentary throughout parts of the code I read through, to preserve
      the knowledge I gained while working.
    
    * A change in the pure unifier around unifying skolems with other types.
      Unifying a skolem now leads to SurelyApart, not MaybeApart, as documented
      in Note [Binding when looking up instances] in GHC.Core.InstEnv.
    
    * Some more use of MCoercion where appropriate.
    
    * Previously, class-instance lookup automatically noticed that e.g. C Int was
      a "unifier" to a target [W] C (F Bool), because the F Bool was flattened to
      a variable. Now, a little more care must be taken around checking for
      unifying instances.
    
    * Previously, tcSplitTyConApp_maybe would split (Eq a => a). This is silly,
      because (=>) is not a tycon in Haskell. Fixed now, but there are some
      knock-on changes in e.g. TrieMap code and in the canonicaliser.
    
    * New function anyFreeVarsOf{Type,Co} to check whether a free variable
      satisfies a certain predicate.
    
    * Type synonyms now remember whether or not they are "forgetful"; a forgetful
      synonym drops at least one argument. This is useful when flattening; see
      flattenView.
    
    * The pattern-match completeness checker invokes the solver. This invocation
      might need to look through newtypes when checking representational equality.
      Thus, the desugarer needs to keep track of the in-scope variables to know
      what newtype constructors are in scope. I bet this bug was around before but
      never noticed.
    
    * Extra-constraints wildcards are no longer simplified before printing.
      See Note [Do not simplify ConstraintHoles] in GHC.Tc.Solver.
    
    * Whether or not there are Given equalities has become slightly subtler.
      See the new HasGivenEqs datatype.
    
    * Note [Type variable cycles in Givens] in GHC.Tc.Solver.Canonical
      explains a significant new wrinkle in the new approach.
    
    * See Note [What might match later?] in GHC.Tc.Solver.Interact, which
      explains the fix to #18910.
    
    * The inert_count field of InertCans wasn't actually used, so I removed
      it.
    
    Though I (Richard) did the implementation, Simon PJ was very involved
    in design and review.
    
    This updates the Haddock submodule to avoid #18932 by adding
    a type signature.
    
    -------------------------
    Metric Decrease:
        T12227
        T5030
        T9872a
        T9872b
        T9872c
    Metric Increase:
        T9872d
    -------------------------
    50b22545
  • Richard Eisenberg's avatar
    Rename the flattener to become the rewriter. · 973fb509
    Richard Eisenberg authored
    Now that flattening doesn't produce flattening variables,
    it's not really flattening anything: it's rewriting. This
    change also means that the rewriter can no longer be confused
    the core flattener (in GHC.Core.Unify), which is sometimes used
    during type-checking.
    973fb509
Showing
with 376 additions and 225 deletions
......@@ -257,6 +257,33 @@ validate-x86_64-linux-deb9-unreg-hadrian:
CONFIGURE_ARGS: --enable-unregisterised
TEST_ENV: "x86_64-linux-deb9-unreg-hadrian"
validate-x86_64-linux-deb10-hadrian-cross-aarch64:
<<: *nightly
extends: .validate-linux-hadrian
stage: full-build
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV"
variables:
BIN_DIST_NAME: "ghc-x86_64-deb9-linux"
rules:
- if: '$CI_MERGE_REQUEST_LABELS =~ /.*cross-compilation.*/'
variables:
CONFIGURE_ARGS: --with-intree-gmp
CROSS_TARGET: "aarch64-linux-gnu"
nightly-x86_64-linux-deb10-hadrian-cross-aarch64:
<<: *nightly
extends: .validate-linux-hadrian
stage: full-build
variables:
CONFIGURE_ARGS: --with-intree-gmp
CROSS_TARGET: "aarch64-linux-gnu"
############################################################
# GHC-in-GHCi (Hadrian)
############################################################
hadrian-ghc-in-ghci:
stage: quick-build
needs: [lint-linters, lint-submods]
......@@ -1210,6 +1237,8 @@ pages:
dependencies:
- doc-tarball
image: ghcci/x86_64-linux-deb9:0.2
# See #18973
allow_failure: true
tags:
- x86_64-linux
script:
......@@ -1225,7 +1254,9 @@ pages:
EOF
- cp -f index.html public/doc
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
# N.B. only run this on ghc/ghc since the deployed pages are quite large
# and we only serve GitLab Pages for ghc/ghc.
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_NAMESPACE == "ghc"'
artifacts:
paths:
- public
......@@ -40,9 +40,9 @@ Hadrian build system
build_hadrian Build GHC via the Hadrian build system
test_hadrian Test GHC via the Hadrian build system
Environment variables affecting both build systems:
CROSS_TARGET Triple of cross-compilation target.
VERBOSE Set to non-empty for verbose build output
MSYSTEM (Windows-only) Which platform to build form (MINGW64 or MINGW32).
......@@ -111,11 +111,11 @@ function setup_locale() {
function mingw_init() {
case "$MSYSTEM" in
MINGW32)
triple="i386-unknown-mingw32"
target_triple="i386-unknown-mingw32"
boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC
;;
MINGW64)
triple="x86_64-unknown-mingw32"
target_triple="x86_64-unknown-mingw32"
boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC
;;
*)
......@@ -378,8 +378,8 @@ function configure() {
end_section "booting"
local target_args=""
if [[ -n "$triple" ]]; then
target_args="--target=$triple"
if [[ -n "$target_triple" ]]; then
target_args="--target=$target_triple"
fi
start_section "configuring"
......@@ -430,6 +430,11 @@ function determine_metric_baseline() {
}
function test_make() {
if [ -n "$CROSS_TARGET" ]; then
info "Can't test cross-compiled build."
return
fi
run "$MAKE" test_bindist TEST_PREP=YES
run "$MAKE" V=0 test \
THREADS="$cores" \
......@@ -450,6 +455,11 @@ function build_hadrian() {
}
function test_hadrian() {
if [ -n "$CROSS_TARGET" ]; then
info "Can't test cross-compiled build."
return
fi
cd _build/bindist/ghc-*/
run ./configure --prefix="$TOP"/_build/install
run "$MAKE" install
......@@ -537,6 +547,11 @@ case "$(uname)" in
*) fail "uname $(uname) is not supported" ;;
esac
if [ -n "$CROSS_TARGET" ]; then
info "Cross-compiling for $CROSS_TARGET..."
target_triple="$CROSS_TARGET"
fi
set_toolchain_paths
case $1 in
......
......@@ -336,7 +336,7 @@ basicKnownKeyNames
-- FFI primitive types that are not wired-in.
stablePtrTyConName, ptrTyConName, funPtrTyConName,
int8TyConName, int16TyConName, int32TyConName, int64TyConName,
word16TyConName, word32TyConName, word64TyConName,
word8TyConName, word16TyConName, word32TyConName, word64TyConName,
-- Others
otherwiseIdName, inlineIdName,
......@@ -1463,7 +1463,8 @@ int32TyConName = tcQual gHC_INT (fsLit "Int32") int32TyConKey
int64TyConName = tcQual gHC_INT (fsLit "Int64") int64TyConKey
-- Word module
word16TyConName, word32TyConName, word64TyConName :: Name
word8TyConName, word16TyConName, word32TyConName, word64TyConName :: Name
word8TyConName = tcQual gHC_WORD (fsLit "Word8") word8TyConKey
word16TyConName = tcQual gHC_WORD (fsLit "Word16") word16TyConKey
word32TyConName = tcQual gHC_WORD (fsLit "Word32") word32TyConKey
word64TyConName = tcQual gHC_WORD (fsLit "Word64") word64TyConKey
......
......@@ -55,7 +55,7 @@ module GHC.Builtin.Types (
wordTyCon, wordDataCon, wordTyConName, wordTy,
-- * Word8
word8TyCon, word8DataCon, word8TyConName, word8Ty,
word8TyCon, word8DataCon, word8Ty,
-- * List
listTyCon, listTyCon_RDR, listTyConName, listTyConKey,
......@@ -251,7 +251,6 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because they
, floatTyCon
, intTyCon
, wordTyCon
, word8TyCon
, listTyCon
, orderingTyCon
, maybeTyCon
......@@ -354,10 +353,9 @@ nothingDataConName = mkWiredInDataConName UserSyntax gHC_MAYBE (fsLit "Nothing")
justDataConName = mkWiredInDataConName UserSyntax gHC_MAYBE (fsLit "Just")
justDataConKey justDataCon
wordTyConName, wordDataConName, word8TyConName, word8DataConName :: Name
wordTyConName, wordDataConName, word8DataConName :: Name
wordTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Word") wordTyConKey wordTyCon
wordDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "W#") wordDataConKey wordDataCon
word8TyConName = mkWiredInTyConName UserSyntax gHC_WORD (fsLit "Word8") word8TyConKey word8TyCon
word8DataConName = mkWiredInDataConName UserSyntax gHC_WORD (fsLit "W8#") word8DataConKey word8DataCon
floatTyConName, floatDataConName, doubleTyConName, doubleDataConName :: Name
......@@ -1641,7 +1639,7 @@ word8TyCon = pcTyCon word8TyConName
(NoSourceText, fsLit "HsWord8"))) []
[word8DataCon]
word8DataCon :: DataCon
word8DataCon = pcDataCon word8DataConName [] [wordPrimTy] word8TyCon
word8DataCon = pcDataCon word8DataConName [] [word8PrimTy] word8TyCon
floatTy :: Type
floatTy = mkTyConTy floatTyCon
......
......@@ -291,8 +291,8 @@ section "Int8#"
primtype Int8#
primop Int8Extend "extendInt8#" GenPrimOp Int8# -> Int#
primop Int8Narrow "narrowInt8#" GenPrimOp Int# -> Int8#
primop Int8ExtendOp "extendInt8#" GenPrimOp Int8# -> Int#
primop Int8NarrowOp "narrowInt8#" GenPrimOp Int# -> Int8#
primop Int8NegOp "negateInt8#" GenPrimOp Int8# -> Int8#
......@@ -327,13 +327,13 @@ primop Int8NeOp "neInt8#" Compare Int8# -> Int8# -> Int#
------------------------------------------------------------------------
section "Word8#"
{Operations on 8-bit unsigned integers.}
{Operations on 8-bit unsigned words.}
------------------------------------------------------------------------
primtype Word8#
primop Word8Extend "extendWord8#" GenPrimOp Word8# -> Word#
primop Word8Narrow "narrowWord8#" GenPrimOp Word# -> Word8#
primop Word8ExtendOp "extendWord8#" GenPrimOp Word8# -> Word#
primop Word8NarrowOp "narrowWord8#" GenPrimOp Word# -> Word8#
primop Word8NotOp "notWord8#" GenPrimOp Word8# -> Word8#
......@@ -373,8 +373,8 @@ section "Int16#"
primtype Int16#
primop Int16Extend "extendInt16#" GenPrimOp Int16# -> Int#
primop Int16Narrow "narrowInt16#" GenPrimOp Int# -> Int16#
primop Int16ExtendOp "extendInt16#" GenPrimOp Int16# -> Int#
primop Int16NarrowOp "narrowInt16#" GenPrimOp Int# -> Int16#
primop Int16NegOp "negateInt16#" GenPrimOp Int16# -> Int16#
......@@ -409,13 +409,13 @@ primop Int16NeOp "neInt16#" Compare Int16# -> Int16# -> Int#
------------------------------------------------------------------------
section "Word16#"
{Operations on 16-bit unsigned integers.}
{Operations on 16-bit unsigned words.}
------------------------------------------------------------------------
primtype Word16#
primop Word16Extend "extendWord16#" GenPrimOp Word16# -> Word#
primop Word16Narrow "narrowWord16#" GenPrimOp Word# -> Word16#
primop Word16ExtendOp "extendWord16#" GenPrimOp Word16# -> Word#
primop Word16NarrowOp "narrowWord16#" GenPrimOp Word# -> Word16#
primop Word16NotOp "notWord16#" GenPrimOp Word16# -> Word16#
......@@ -448,6 +448,26 @@ primop Word16LeOp "leWord16#" Compare Word16# -> Word16# -> Int#
primop Word16LtOp "ltWord16#" Compare Word16# -> Word16# -> Int#
primop Word16NeOp "neWord16#" Compare Word16# -> Word16# -> Int#
------------------------------------------------------------------------
section "Int32#"
{Operations on 32-bit integers.}
------------------------------------------------------------------------
primtype Int32#
primop Int32ExtendOp "extendInt32#" GenPrimOp Int32# -> Int#
primop Int32NarrowOp "narrowInt32#" GenPrimOp Int# -> Int32#
------------------------------------------------------------------------
section "Word32#"
{Operations on 32-bit unsigned integers.}
------------------------------------------------------------------------
primtype Word32#
primop Word32ExtendOp "extendWord32#" GenPrimOp Word32# -> Word#
primop Word32NarrowOp "narrowWord32#" GenPrimOp Word# -> Word32#
#if WORD_SIZE_IN_BITS < 64
------------------------------------------------------------------------
section "Int64#"
......@@ -540,19 +560,19 @@ primop IntQuotRemOp "quotRemInt#" GenPrimOp
{Rounds towards zero.}
with can_fail = True
primop AndIOp "andI#" GenPrimOp Int# -> Int# -> Int#
primop IntAndOp "andI#" GenPrimOp Int# -> Int# -> Int#
{Bitwise "and".}
with commutable = True
primop OrIOp "orI#" GenPrimOp Int# -> Int# -> Int#
primop IntOrOp "orI#" GenPrimOp Int# -> Int# -> Int#
{Bitwise "or".}
with commutable = True
primop XorIOp "xorI#" GenPrimOp Int# -> Int# -> Int#
primop IntXorOp "xorI#" GenPrimOp Int# -> Int# -> Int#
{Bitwise "xor".}
with commutable = True
primop NotIOp "notI#" GenPrimOp Int# -> Int#
primop IntNotOp "notI#" GenPrimOp Int# -> Int#
{Bitwise "not", also known as the binary complement.}
primop IntNegOp "negateInt#" GenPrimOp Int# -> Int#
......@@ -612,13 +632,13 @@ primop IntToDoubleOp "int2Double#" GenPrimOp Int# -> Double#
primop WordToFloatOp "word2Float#" GenPrimOp Word# -> Float#
primop WordToDoubleOp "word2Double#" GenPrimOp Word# -> Double#
primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
primop IntSllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
{Shift left. Result undefined if shift amount is not
in the range 0 to word size - 1 inclusive.}
primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
primop IntSraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
{Shift right arithmetic. Result undefined if shift amount is not
in the range 0 to word size - 1 inclusive.}
primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
primop IntSrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
{Shift right logical. Result undefined if shift amount is not
in the range 0 to word size - 1 inclusive.}
......@@ -678,21 +698,21 @@ primop WordQuotRem2Op "quotRemWord2#" GenPrimOp
Requires that high word < divisor.}
with can_fail = True
primop AndOp "and#" GenPrimOp Word# -> Word# -> Word#
primop WordAndOp "and#" GenPrimOp Word# -> Word# -> Word#
with commutable = True
primop OrOp "or#" GenPrimOp Word# -> Word# -> Word#
primop WordOrOp "or#" GenPrimOp Word# -> Word# -> Word#
with commutable = True
primop XorOp "xor#" GenPrimOp Word# -> Word# -> Word#
primop WordXorOp "xor#" GenPrimOp Word# -> Word# -> Word#
with commutable = True
primop NotOp "not#" GenPrimOp Word# -> Word#
primop WordNotOp "not#" GenPrimOp Word# -> Word#
primop SllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word#
primop WordSllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word#
{Shift left logical. Result undefined if shift amount is not
in the range 0 to word size - 1 inclusive.}
primop SrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word#
primop WordSrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word#
{Shift right logical. Result undefined if shift amount is not
in the range 0 to word size - 1 inclusive.}
......
......@@ -464,6 +464,12 @@ assembleI platform i = case i of
literal (LitNumber nt i) = case nt of
LitNumInt -> int (fromIntegral i)
LitNumWord -> int (fromIntegral i)
LitNumInt8 -> int8 (fromIntegral i)
LitNumWord8 -> int8 (fromIntegral i)
LitNumInt16 -> int16 (fromIntegral i)
LitNumWord16 -> int16 (fromIntegral i)
LitNumInt32 -> int32 (fromIntegral i)
LitNumWord32 -> int32 (fromIntegral i)
LitNumInt64 -> int64 (fromIntegral i)
LitNumWord64 -> int64 (fromIntegral i)
LitNumInteger -> panic "GHC.ByteCode.Asm.literal: LitNumInteger"
......@@ -478,6 +484,9 @@ assembleI platform i = case i of
float = words . mkLitF
double = words . mkLitD platform
int = words . mkLitI
int8 = words . mkLitI64 platform
int16 = words . mkLitI64 platform
int32 = words . mkLitI64 platform
int64 = words . mkLitI64 platform
words ws = lit (map BCONPtrWord ws)
word w = words [w]
......
......@@ -37,7 +37,7 @@ import Data.ByteString (ByteString)
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.Maybe (catMaybes)
import GHC.Exts.Heap
import qualified GHC.Exts.Heap as Heap
import GHC.Stack.CCS
-- -----------------------------------------------------------------------------
......@@ -72,7 +72,7 @@ type ItblEnv = NameEnv (Name, ItblPtr)
-- We need the Name in the range so we know which
-- elements to filter out when unloading a module
newtype ItblPtr = ItblPtr (RemotePtr StgInfoTable)
newtype ItblPtr = ItblPtr (RemotePtr Heap.StgInfoTable)
deriving (Show, NFData)
data UnlinkedBCO
......
......@@ -228,6 +228,12 @@ data CmmStatic
| CmmFileEmbed FilePath
-- ^ an embedded binary file
instance Outputable CmmStatic where
ppr (CmmStaticLit lit) = text "CmmStaticLit" <+> ppr lit
ppr (CmmUninitialised n) = text "CmmUninitialised" <+> ppr n
ppr (CmmString _) = text "CmmString"
ppr (CmmFileEmbed fp) = text "CmmFileEmbed" <+> text fp
-- Static data before SRT generation
data GenCmmStatics (rawOnly :: Bool) where
CmmStatics
......
......@@ -301,7 +301,7 @@ copyTicks env g
foldr blockCons code (map CmmTick ticks)
-- Group by [Label]
-- See Note [Compressed TrieMap] in GHC.Core.Map about the usage of GenMap.
-- See Note [Compressed TrieMap] in GHC.Core.Map.Expr about the usage of GenMap.
groupByLabel :: [(Key, DistinctBlocks)] -> [(Key, [DistinctBlocks])]
groupByLabel =
go (TM.emptyTM :: TM.ListMap (TM.GenMap LabelMap) (Key, [DistinctBlocks]))
......
......@@ -141,6 +141,7 @@ instance TrieMap LabelMap where
alterTM k f m = mapAlter f k m
foldTM k m z = mapFoldr k z m
mapTM f m = mapMap f m
filterTM f m = mapFilter f m
-----------------------------------------------------------------------------
-- FactBase
......
......@@ -39,6 +39,7 @@ import GHC.Cmm.CLabel
import GHC.Cmm.MachOp
import GHC.Cmm.Type
import GHC.Utils.Panic (panic)
import GHC.Utils.Outputable
import GHC.Types.Unique
import Data.Set (Set)
......@@ -210,6 +211,16 @@ data CmmLit
-- of bytes used
deriving Eq
instance Outputable CmmLit where
ppr (CmmInt n w) = text "CmmInt" <+> ppr n <+> ppr w
ppr (CmmFloat n w) = text "CmmFloat" <+> text (show n) <+> ppr w
ppr (CmmVec xs) = text "CmmVec" <+> ppr xs
ppr (CmmLabel _) = text "CmmLabel"
ppr (CmmLabelOff _ _) = text "CmmLabelOff"
ppr (CmmLabelDiffOff _ _ _ _) = text "CmmLabelDiffOff"
ppr (CmmBlock blk) = text "CmmBlock" <+> ppr blk
ppr CmmHighStackMark = text "CmmHighStackMark"
cmmExprType :: Platform -> CmmExpr -> CmmType
cmmExprType platform = \case
(CmmLit lit) -> cmmLitType platform lit
......
......@@ -449,6 +449,7 @@ tryToInline platform live node assigs = go usages node emptyLRegSet assigs
|| l `elemLRegSet` skipped
|| not (okToInline platform rhs node)
-- How often is l used in the current node.
l_usages = lookupUFM usages l
l_live = l `elemRegSet` live
......@@ -554,10 +555,16 @@ addUsage m r = addToUFM_C (+) m r 1
regsUsedIn :: LRegSet -> CmmExpr -> Bool
regsUsedIn ls _ | nullLRegSet ls = False
regsUsedIn ls e = wrapRecExpf f e False
where f (CmmReg (CmmLocal l)) _ | l `elemLRegSet` ls = True
f (CmmRegOff (CmmLocal l) _) _ | l `elemLRegSet` ls = True
f _ z = z
regsUsedIn ls e = go ls e False
where use :: LRegSet -> CmmExpr -> Bool -> Bool
use ls (CmmReg (CmmLocal l)) _ | l `elemLRegSet` ls = True
use ls (CmmRegOff (CmmLocal l) _) _ | l `elemLRegSet` ls = True
use _ls _ z = z
go :: LRegSet -> CmmExpr -> Bool -> Bool
go ls (CmmMachOp _ es) z = foldr (go ls) z es
go ls (CmmLoad addr _) z = go ls addr z
go ls e z = use ls e z
-- we don't inline into CmmUnsafeForeignCall if the expression refers
-- to global registers. This is a HACK to avoid global registers
......
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE CPP, MagicHash #-}
-----------------------------------------------------------------------------
--
......@@ -38,9 +38,17 @@ import Data.Word
import Data.Bits
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import GHC.Exts
import GHC.Exts hiding (extendWord8#)
import GHC.Word
#if MIN_VERSION_base(4,16,0)
import GHC.Base (extendWord8#)
#else
extendWord8# :: Word# -> Word#
extendWord8# w = w
{-# INLINE extendWord8# #-}
#endif
-- -----------------------------------------------------------------------------
-- Converting floating-point literals to integrals for printing
......@@ -103,7 +111,7 @@ pprASCII str
-- we know that the Chars we create are in the ASCII range
-- so we bypass the check in "chr"
chr' :: Word8 -> Char
chr' (W8# w#) = C# (chr# (word2Int# w#))
chr' (W8# w#) = C# (chr# (word2Int# (extendWord8# w#)))
octal :: Word8 -> String
octal w = [ chr' (ord0 + (w `unsafeShiftR` 6) .&. 0x07)
......
......@@ -283,7 +283,8 @@ regAlloc_spin config spinCount triv regsFree slotsFree slotsCount debug_codeGrap
, raCoalesced = rmCoalesce
, raSpillStats = spillStats
, raSpillCosts = spillCosts
, raSpilled = code_spilled }
, raSpilled = code_spilled
, raPlatform = platform }
-- Bundle up all the register allocator statistics.
-- .. but make sure to drop them on the floor if they're not
......
......@@ -79,7 +79,11 @@ data RegAllocStats statics instr
, raSpillCosts :: SpillCostInfo
-- | Code with spill instructions added.
, raSpilled :: [LiveCmmDecl statics instr] }
, raSpilled :: [LiveCmmDecl statics instr]
-- | Target platform
, raPlatform :: !Platform
}
-- a successful coloring
......
......@@ -159,8 +159,14 @@ pprWordArray platform is_ro lbl ds
-- See Note [StgWord alignment]
, pprAlignment (wordWidth platform)
, text "= {" ]
$$ nest 8 (commafy (pprStatics platform ds))
$$ nest 8 (commafy (staticLitsToWords platform $ toLits ds))
$$ text "};"
where
toLits :: [CmmStatic] -> [CmmLit]
toLits = map f
where
f (CmmStaticLit lit) = lit
f static = pprPanic "pprWordArray: Unexpected literal" (pprStatic platform static)
pprAlignment :: Width -> SDoc
pprAlignment words =
......@@ -501,59 +507,69 @@ pprLit1 platform lit = case lit of
-- ---------------------------------------------------------------------------
-- Static data
pprStatics :: Platform -> [CmmStatic] -> [SDoc]
pprStatics platform = pprStatics'
-- | Produce a list of word sized literals encoding the given list of 'CmmLit's.
staticLitsToWords :: Platform -> [CmmLit] -> [SDoc]
staticLitsToWords platform = go . foldMap decomposeMultiWord
where
pprStatics' = \case
[] -> []
(CmmStaticLit (CmmFloat f W32) : rest)
-- odd numbers of floats are padded to a word by mkVirtHeapOffsetsWithPadding
| wordWidth platform == W64, CmmStaticLit (CmmInt 0 W32) : rest' <- rest
-> pprLit1 platform (floatToWord platform f) : pprStatics' rest'
-- adjacent floats aren't padded but combined into a single word
| wordWidth platform == W64, CmmStaticLit (CmmFloat g W32) : rest' <- rest
-> pprLit1 platform (floatPairToWord platform f g) : pprStatics' rest'
| wordWidth platform == W32
-> pprLit1 platform (floatToWord platform f) : pprStatics' rest
| otherwise
-> pprPanic "pprStatics: float" (vcat (map ppr' rest))
where ppr' (CmmStaticLit l) = ppr (cmmLitType platform l)
ppr' _other = text "bad static!"
(CmmStaticLit (CmmFloat f W64) : rest)
-> map (pprLit1 platform) (doubleToWords platform f) ++ pprStatics' rest
(CmmStaticLit (CmmInt i W64) : rest)
| wordWidth platform == W32
-> case platformByteOrder platform of
BigEndian -> pprStatics' (CmmStaticLit (CmmInt q W32) :
CmmStaticLit (CmmInt r W32) : rest)
LittleEndian -> pprStatics' (CmmStaticLit (CmmInt r W32) :
CmmStaticLit (CmmInt q W32) : rest)
where r = i .&. 0xffffffff
q = i `shiftR` 32
(CmmStaticLit (CmmInt a W32) : CmmStaticLit (CmmInt b W32) : rest)
| wordWidth platform == W64
-> case platformByteOrder platform of
BigEndian -> pprStatics' (CmmStaticLit (CmmInt ((shiftL a 32) .|. b) W64) : rest)
LittleEndian -> pprStatics' (CmmStaticLit (CmmInt ((shiftL b 32) .|. a) W64) : rest)
(CmmStaticLit (CmmInt a W16) : CmmStaticLit (CmmInt b W16) : rest)
| wordWidth platform == W32
-> case platformByteOrder platform of
BigEndian -> pprStatics' (CmmStaticLit (CmmInt ((shiftL a 16) .|. b) W32) : rest)
LittleEndian -> pprStatics' (CmmStaticLit (CmmInt ((shiftL b 16) .|. a) W32) : rest)
(CmmStaticLit (CmmInt _ w) : _)
| w /= wordWidth platform
-> pprPanic "pprStatics: cannot emit a non-word-sized static literal" (ppr w)
(CmmStaticLit lit : rest)
-> pprLit1 platform lit : pprStatics' rest
(other : _)
-> pprPanic "pprStatics: other" (pprStatic platform other)
-- rem_bytes is how many bytes remain in the word we are currently filling.
-- accum is the word we are filling.
go :: [CmmLit] -> [SDoc]
go [] = []
go lits@(lit : _)
| Just _ <- isSubWordLit lit
= goSubWord wordWidthBytes 0 lits
go (lit : rest)
= pprLit1 platform lit : go rest
goSubWord :: Int -> Integer -> [CmmLit] -> [SDoc]
goSubWord rem_bytes accum (lit : rest)
| Just (bytes, w) <- isSubWordLit lit
, rem_bytes >= widthInBytes w
= let accum' =
case platformByteOrder platform of
BigEndian -> (accum `shiftL` widthInBits w) .|. bytes
LittleEndian -> (accum `shiftL` widthInBits w) .|. byteSwap w bytes
in goSubWord (rem_bytes - widthInBytes w) accum' rest
goSubWord rem_bytes accum rest
= pprWord (byteSwap (wordWidth platform) $ accum `shiftL` (8*rem_bytes)) : go rest
-- Decompose multi-word or floating-point literals into multiple
-- single-word (or smaller) literals.
decomposeMultiWord :: CmmLit -> [CmmLit]
decomposeMultiWord (CmmFloat n W64)
-- This will produce a W64 integer, which will then be broken up further
-- on the next iteration on 32-bit platforms.
= [doubleToWord64 n]
decomposeMultiWord (CmmFloat n W32)
= [floatToWord32 n]
decomposeMultiWord (CmmInt n W64)
| W32 <- wordWidth platform
= [CmmInt hi W32, CmmInt lo W32]
where
hi = n `shiftR` 32
lo = n .&. 0xffffffff
decomposeMultiWord lit = [lit]
-- Decompose a sub-word-sized literal into the integer value and its
-- (sub-word-sized) width.
isSubWordLit :: CmmLit -> Maybe (Integer, Width)
isSubWordLit lit =
case lit of
CmmInt n w
| w < wordWidth platform -> Just (n, w)
_ -> Nothing
wordWidthBytes = widthInBytes $ wordWidth platform
pprWord :: Integer -> SDoc
pprWord n = pprHexVal platform n (wordWidth platform)
byteSwap :: Width -> Integer -> Integer
byteSwap width n = foldl' f 0 bytes
where
f acc m = (acc `shiftL` 8) .|. m
bytes = [ byte i | i <- [0..widthInBytes width - 1] ]
byte i = (n `shiftR` (i*8)) .&. 0xff
pprStatic :: Platform -> CmmStatic -> SDoc
pprStatic platform s = case s of
......@@ -1252,69 +1268,30 @@ pprStringInCStyle s = doubleQuotes (text (concatMap charToC (BS.unpack s)))
-- This is a hack to turn the floating point numbers into ints that we
-- can safely initialise to static locations.
castFloatToWord32Array :: STUArray s Int Float -> ST s (STUArray s Int Word32)
castFloatToWord32Array = U.castSTUArray
castDoubleToWord64Array :: STUArray s Int Double -> ST s (STUArray s Int Word64)
castDoubleToWord64Array = U.castSTUArray
floatToWord :: Platform -> Rational -> CmmLit
floatToWord platform r
= runST (do
floatToWord32 :: Rational -> CmmLit
floatToWord32 r
= runST $ do
arr <- newArray_ ((0::Int),0)
writeArray arr 0 (fromRational r)
arr' <- castFloatToWord32Array arr
w32 <- readArray arr' 0
return (CmmInt (toInteger w32 `shiftL` wo) (wordWidth platform))
)
where wo | wordWidth platform == W64
, BigEndian <- platformByteOrder platform
= 32
| otherwise
= 0
floatPairToWord :: Platform -> Rational -> Rational -> CmmLit
floatPairToWord platform r1 r2
= runST (do
arr <- newArray_ ((0::Int),1)
writeArray arr 0 (fromRational r1)
writeArray arr 1 (fromRational r2)
arr' <- castFloatToWord32Array arr
w32_1 <- readArray arr' 0
w32_2 <- readArray arr' 1
return (pprWord32Pair w32_1 w32_2)
)
where pprWord32Pair w32_1 w32_2
| BigEndian <- platformByteOrder platform =
CmmInt ((shiftL i1 32) .|. i2) W64
| otherwise =
CmmInt ((shiftL i2 32) .|. i1) W64
where i1 = toInteger w32_1
i2 = toInteger w32_2
doubleToWords :: Platform -> Rational -> [CmmLit]
doubleToWords platform r
= runST (do
return (CmmInt (toInteger w32) W32)
where
castFloatToWord32Array :: STUArray s Int Float -> ST s (STUArray s Int Word32)
castFloatToWord32Array = U.castSTUArray
doubleToWord64 :: Rational -> CmmLit
doubleToWord64 r
= runST $ do
arr <- newArray_ ((0::Int),1)
writeArray arr 0 (fromRational r)
arr' <- castDoubleToWord64Array arr
w64 <- readArray arr' 0
return (pprWord64 w64)
)
where targetWidth = wordWidth platform
pprWord64 w64
| targetWidth == W64 =
[ CmmInt (toInteger w64) targetWidth ]
| targetWidth == W32 =
[ CmmInt (toInteger targetW1) targetWidth
, CmmInt (toInteger targetW2) targetWidth
]
| otherwise = panic "doubleToWords.pprWord64"
where (targetW1, targetW2) = case platformByteOrder platform of
BigEndian -> (wHi, wLo)
LittleEndian -> (wLo, wHi)
wHi = w64 `shiftR` 32
wLo = w64 .&. 0xFFFFffff
return $ CmmInt (toInteger w64) W64
where
castDoubleToWord64Array :: STUArray s Int Double -> ST s (STUArray s Int Word64)
castDoubleToWord64Array = U.castSTUArray
-- ---------------------------------------------------------------------------
-- Utils
......
......@@ -29,6 +29,7 @@ module GHC.Core (
mkIntLit, mkIntLitWrap,
mkWordLit, mkWordLitWrap,
mkWord8Lit,
mkWord64LitWord64, mkInt64LitInt64,
mkCharLit, mkStringLit,
mkFloatLit, mkFloatLitFloat,
......@@ -1997,6 +1998,9 @@ mkWordLit platform w = Lit (mkLitWord platform w)
mkWordLitWrap :: Platform -> Integer -> Expr b
mkWordLitWrap platform w = Lit (mkLitWordWrap platform w)
mkWord8Lit :: Integer -> Expr b
mkWord8Lit w = Lit (mkLitWord8 w)
mkWord64LitWord64 :: Word64 -> Expr b
mkWord64LitWord64 w = Lit (mkLitWord64 (toInteger w))
......
......@@ -13,8 +13,8 @@
--
module GHC.Core.Coercion (
-- * Main data type
Coercion, CoercionN, CoercionR, CoercionP, MCoercion(..), MCoercionR,
UnivCoProvenance, CoercionHole(..), BlockSubstFlag(..),
Coercion, CoercionN, CoercionR, CoercionP, MCoercion(..), MCoercionN, MCoercionR,
UnivCoProvenance, CoercionHole(..),
coHoleCoVar, setCoHoleCoVar,
LeftOrRight(..),
Var, CoVar, TyCoVar,
......@@ -69,8 +69,10 @@ module GHC.Core.Coercion (
pickLR,
isGReflCo, isReflCo, isReflCo_maybe, isGReflCo_maybe, isReflexiveCo, isReflexiveCo_maybe,
isReflCoVar_maybe, isGReflMCo,
coToMCo, mkTransMCo, mkTransMCoL,
isReflCoVar_maybe, isGReflMCo, mkGReflLeftMCo, mkGReflRightMCo,
mkCoherenceRightMCo,
coToMCo, mkTransMCo, mkTransMCoL, mkCastTyMCo, mkSymMCo, isReflMCo,
-- ** Coercion variables
mkCoVar, isCoVar, coVarName, setCoVarName, setCoVarUnique,
......@@ -79,7 +81,7 @@ module GHC.Core.Coercion (
-- ** Free variables
tyCoVarsOfCo, tyCoVarsOfCos, coVarsOfCo,
tyCoFVsOfCo, tyCoFVsOfCos, tyCoVarsOfCoDSet,
coercionSize,
coercionSize, anyFreeVarsOfCo,
-- ** Substitution
CvSubstEnv, emptyCvSubstEnv,
......@@ -121,7 +123,8 @@ module GHC.Core.Coercion (
simplifyArgsWorker,
badCoercionHole, badCoercionHoleCo
hasCoercionHoleTy, hasCoercionHoleCo,
HoleSet, coercionHolesOfType, coercionHolesOfCo
) where
#include "HsVersions.h"
......@@ -154,6 +157,7 @@ import GHC.Builtin.Types.Prim
import GHC.Data.List.SetOps
import GHC.Data.Maybe
import GHC.Types.Unique.FM
import GHC.Types.Unique.Set
import GHC.Utils.Misc
import GHC.Utils.Outputable
......@@ -331,6 +335,32 @@ mkTransMCoL :: MCoercion -> Coercion -> MCoercion
mkTransMCoL MRefl co2 = MCo co2
mkTransMCoL (MCo co1) co2 = MCo (mkTransCo co1 co2)
-- | Get the reverse of an 'MCoercion'
mkSymMCo :: MCoercion -> MCoercion
mkSymMCo MRefl = MRefl
mkSymMCo (MCo co) = MCo (mkSymCo co)
-- | Cast a type by an 'MCoercion'
mkCastTyMCo :: Type -> MCoercion -> Type
mkCastTyMCo ty MRefl = ty
mkCastTyMCo ty (MCo co) = ty `mkCastTy` co
mkGReflLeftMCo :: Role -> Type -> MCoercionN -> Coercion
mkGReflLeftMCo r ty MRefl = mkReflCo r ty
mkGReflLeftMCo r ty (MCo co) = mkGReflLeftCo r ty co
mkGReflRightMCo :: Role -> Type -> MCoercionN -> Coercion
mkGReflRightMCo r ty MRefl = mkReflCo r ty
mkGReflRightMCo r ty (MCo co) = mkGReflRightCo r ty co
-- | Like 'mkCoherenceRightCo', but with an 'MCoercion'
mkCoherenceRightMCo :: Role -> Type -> MCoercionN -> Coercion -> Coercion
mkCoherenceRightMCo _ _ MRefl co2 = co2
mkCoherenceRightMCo r ty (MCo co) co2 = mkCoherenceRightCo r ty co co2
isReflMCo :: MCoercion -> Bool
isReflMCo MRefl = True
isReflMCo _ = False
{-
%************************************************************************
......@@ -1219,7 +1249,7 @@ mkKindCo co
| otherwise
= KindCo co
mkSubCo :: Coercion -> Coercion
mkSubCo :: HasDebugCallStack => Coercion -> Coercion
-- Input coercion is Nominal, result is Representational
-- see also Note [Role twiddling functions]
mkSubCo (Refl ty) = GRefl Representational ty MRefl
......@@ -1620,7 +1650,7 @@ where the two kind coercions are identical. In that case we can exploit the
situation where the main coercion is reflexive, via the special cases for Refl
and GRefl.
This is important when flattening (ty |> co). We flatten ty, yielding
This is important when rewriting (ty |> co). We rewrite ty, yielding
fco :: ty ~ ty'
and now we want a coercion xco between
xco :: (ty |> co) ~ (ty' |> co)
......@@ -1675,6 +1705,11 @@ data NormaliseStepResult ev
-- ^ ev is evidence;
-- Usually a co :: old type ~ new type
instance Outputable ev => Outputable (NormaliseStepResult ev) where
ppr NS_Done = text "NS_Done"
ppr NS_Abort = text "NS_Abort"
ppr (NS_Step _ ty ev) = sep [text "NS_Step", ppr ty, ppr ev]
mapStepResult :: (ev1 -> ev2)
-> NormaliseStepResult ev1 -> NormaliseStepResult ev2
mapStepResult f (NS_Step rec_nts ty ev) = NS_Step rec_nts ty (f ev)
......@@ -2629,18 +2664,19 @@ buildCoercion orig_ty1 orig_ty2 = go orig_ty1 orig_ty2
%* *
%************************************************************************
The function below morally belongs in GHC.Tc.Solver.Flatten, but it is used also in
The function below morally belongs in GHC.Tc.Solver.Rewrite, but it is used also in
FamInstEnv, and so lives here.
Note [simplifyArgsWorker]
~~~~~~~~~~~~~~~~~~~~~~~~~
Invariant (F2) of Note [Flattening] says that flattening is homogeneous.
This causes some trouble when flattening a function applied to a telescope
Invariant (F2) of Note [Rewriting] in GHC.Tc.Solver.Rewrite says that
rewriting is homogeneous.
This causes some trouble when rewriting a function applied to a telescope
of arguments, perhaps with dependency. For example, suppose
type family F :: forall (j :: Type) (k :: Type). Maybe j -> Either j k -> Bool -> [k]
and we wish to flatten the args of (with kind applications explicit)
and we wish to rewrite the args of (with kind applications explicit)
F a b (Just a c) (Right a b d) False
......@@ -2656,7 +2692,7 @@ where all variables are skolems and
[G] cco :: c ~ fc
[G] dco :: d ~ fd
The first step is to flatten all the arguments. This is done before calling
The first step is to rewrite all the arguments. This is done before calling
simplifyArgsWorker. We start from
a
......@@ -2677,26 +2713,26 @@ where
co6 :: Maybe fa ~ Maybe a
co7 :: Either fa fb ~ Either a b
We now process the flattened args in left-to-right order. The first two args
need no further processing. But now consider the third argument. Let f3 = the flattened
We now process the rewritten args in left-to-right order. The first two args
need no further processing. But now consider the third argument. Let f3 = the rewritten
result, Just fa (fc |> aco) |> co6.
This f3 flattened argument has kind (Maybe a), due to
This f3 rewritten argument has kind (Maybe a), due to
(F2). And yet, when we build the application (F fa fb ...), we need this
argument to have kind (Maybe fa), not (Maybe a). We must cast this argument.
The coercion to use is
determined by the kind of F: we see in F's kind that the third argument has
kind Maybe j. Critically, we also know that the argument corresponding to j
(in our example, a) flattened with a coercion co1. We can thus know the
(in our example, a) rewrote with a coercion co1. We can thus know the
coercion needed for the 3rd argument is (Maybe (sym co1)), thus building
(f3 |> Maybe (sym co1))
More generally, we must use the Lifting Lemma, as implemented in
Coercion.liftCoSubst. As we work left-to-right, any variable that is a
dependent parameter (j and k, in our example) gets mapped in a lifting context
to the coercion that is output from flattening the corresponding argument (co1
and co2, in our example). Then, after flattening later arguments, we lift the
to the coercion that is output from rewriting the corresponding argument (co1
and co2, in our example). Then, after rewriting later arguments, we lift the
kind of these arguments in the lifting context that we've be building up.
This coercion is then used to keep the result of flattening well-kinded.
This coercion is then used to keep the result of rewriting well-kinded.
Working through our example, this is what happens:
......@@ -2712,7 +2748,7 @@ Working through our example, this is what happens:
4. Lifting the kind (Either j k) with our LC
yields co9 :: Either fa fb ~ Either a b. Use (f4 |> sym co9) as the 4th
argument to F, where f4 is the flattened form of argument 4, written above.
argument to F, where f4 is the rewritten form of argument 4, written above.
5. We lift Bool with our LC, getting <Bool>;
casting has no effect.
......@@ -2753,14 +2789,14 @@ Here is an example.
co :: (forall j. j -> Type) ~ (forall (j :: Star). (j |> axStar) -> Star)
co = forall (j :: sym axStar). (<j> -> sym axStar)
We are flattening:
We are rewriting:
a (forall (j :: Star). (j |> axStar) -> Star) -- 1
(Proxy |> co) -- 2
(bo |> sym axStar) -- 3
(NoWay |> sym bc) -- 4
:: Star
First, we flatten all the arguments (before simplifyArgsWorker), like so:
First, we rewrite all the arguments (before simplifyArgsWorker), like so:
(forall j. j -> Type, co1 :: (forall j. j -> Type) ~
(forall (j :: Star). (j |> axStar) -> Star)) -- 1
......@@ -2772,7 +2808,7 @@ Then we do the process described in Note [simplifyArgsWorker].
1. Lifting Type (the kind of the first arg) gives us a reflexive coercion, so we
don't use it. But we do build a lifting context [k -> co1] (where co1 is a
result of flattening an argument, written above).
result of rewriting an argument, written above).
2. Lifting k gives us co1, so the second argument becomes (Proxy |> co |> sym co1).
This is not a dependent argument, so we don't extend the lifting context.
......@@ -2791,10 +2827,10 @@ to instantiate any kind parameters. Look at the type of co1. If we just
decomposed it, we would end up with coercions whose types include j, which is
out of scope here. Accordingly, decomposePiCos takes a list of types whose
kinds are the *right-hand* types in the decomposed coercion. (See comments on
decomposePiCos.) Because the flattened types have unflattened kinds (because
flattening is homogeneous), passing the list of flattened types to decomposePiCos
decomposePiCos.) Because the rewritten types have unrewritten kinds (because
rewriting is homogeneous), passing the list of rewritten types to decomposePiCos
just won't do: later arguments' kinds won't be as expected. So we need to get
the *unflattened* types to pass to decomposePiCos. We can do this easily enough
the *unrewritten* types to pass to decomposePiCos. We can do this easily enough
by taking the kind of the argument coercions, passed in originally.
(Alternative 1: We could re-engineer decomposePiCos to deal with this situation.
......@@ -2806,7 +2842,7 @@ behavior into simplifyArgsWorker. This would work, I think, but then all of the
complication of decomposePiCos would end up layered on top of all the complication
here. Please, no.)
(Alternative 3: We could pass the unflattened arguments into simplifyArgsWorker
(Alternative 3: We could pass the unrewritten arguments into simplifyArgsWorker
so that we don't have to recreate them. But that would complicate the interface
of this function to handle a very dark, dark corner case. Better to keep our
demons to ourselves here instead of exposing them to callers. This decision is
......@@ -2827,7 +2863,7 @@ to get
== bo ~ bo
res_co :: Type ~ Star
We then use these casts on (the flattened) (3) and (4) to get
We then use these casts on (the rewritten) (3) and (4) to get
(Bool |> sym axStar |> co5 :: Type) -- (C3)
(False |> sym bc |> co6 :: bo) -- (C4)
......@@ -2848,9 +2884,9 @@ it.
This recursive call returns ([Bool, False], [...], Refl). The Bool and False
are the correct arguments we wish to return. But we must be careful about the
result coercion: our new, flattened application will have kind Type, but we
result coercion: our new, rewritten application will have kind Type, but we
want to make sure that the result coercion casts this back to Star. (Why?
Because we started with an application of kind Star, and flattening is homogeneous.)
Because we started with an application of kind Star, and rewriting is homogeneous.)
So, we have to twiddle the result coercion appropriately.
......@@ -2894,7 +2930,7 @@ be an application of a variable. Here is the example:
k :: Type
x :: k
flatten (f @Type @((->) k) x)
rewrite (f @Type @((->) k) x)
After instantiating [a |-> Type, b |-> ((->) k)], we see that `b (Any @a)`
is `k -> Any @a`, and thus the third argument of `x :: k` is well-kinded.
......@@ -2902,7 +2938,7 @@ is `k -> Any @a`, and thus the third argument of `x :: k` is well-kinded.
-}
-- This is shared between the flattener and the normaliser in GHC.Core.FamInstEnv.
-- This is shared between the rewriter and the normaliser in GHC.Core.FamInstEnv.
-- See Note [simplifyArgsWorker]
{-# INLINE simplifyArgsWorker #-}
simplifyArgsWorker :: [TyCoBinder] -> Kind
......@@ -2910,15 +2946,15 @@ simplifyArgsWorker :: [TyCoBinder] -> Kind
-- list of binders can be shorter or longer than the list of args
-> TyCoVarSet -- free vars of the args
-> [Role] -- list of roles, r
-> [(Type, Coercion)] -- flattened type arguments, arg
-- each comes with the coercion used to flatten it,
-- with co :: flattened_type ~ original_type
-> ([Type], [Coercion], CoercionN)
-> [(Type, Coercion)] -- rewritten type arguments, arg
-- each comes with the coercion used to rewrite it,
-- with co :: rewritten_type ~ original_type
-> ([Type], [Coercion], MCoercionN)
-- Returns (xis, cos, res_co), where each co :: xi ~ arg,
-- and res_co :: kind (f xis) ~ kind (f tys), where f is the function applied to the args
-- Precondition: if f :: forall bndrs. inner_ki (where bndrs and inner_ki are passed in),
-- then (f orig_tys) is well kinded. Note that (f flattened_tys) might *not* be well-kinded.
-- Massaging the flattened_tys in order to make (f flattened_tys) well-kinded is what this
-- then (f orig_tys) is well kinded. Note that (f rewritten_tys) might *not* be well-kinded.
-- Massaging the rewritten_tys in order to make (f rewritten_tys) well-kinded is what this
-- function is all about. That is, (f xis), where xis are the returned arguments, *is*
-- well kinded.
simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs
......@@ -2930,25 +2966,26 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs
go :: [Type] -- Xis accumulator, in reverse order
-> [Coercion] -- Coercions accumulator, in reverse order
-- These are in 1-to-1 correspondence
-> LiftingContext -- mapping from tyvars to flattening coercions
-> LiftingContext -- mapping from tyvars to rewriting coercions
-> [TyCoBinder] -- Unsubsted binders of function's kind
-> Kind -- Unsubsted result kind of function (not a Pi-type)
-> [Role] -- Roles at which to flatten these ...
-> [(Type, Coercion)] -- flattened arguments, with their flattening coercions
-> ([Type], [Coercion], CoercionN)
-> [Role] -- Roles at which to rewrite these ...
-> [(Type, Coercion)] -- rewritten arguments, with their rewriting coercions
-> ([Type], [Coercion], MCoercionN)
go acc_xis acc_cos !lc binders inner_ki _ []
-- The !lc makes the function strict in the lifting context
-- which means GHC can unbox that pair. A modest win.
= (reverse acc_xis, reverse acc_cos, kind_co)
where
final_kind = mkPiTys binders inner_ki
kind_co = liftCoSubst Nominal lc final_kind
kind_co | noFreeVarsOfType final_kind = MRefl
| otherwise = MCo $ liftCoSubst Nominal lc final_kind
go acc_xis acc_cos lc (binder:binders) inner_ki (role:roles) ((xi,co):args)
= -- By Note [Flattening] in GHC.Tc.Solver.Flatten invariant (F2),
= -- By Note [Rewriting] in GHC.Tc.Solver.Rewrite invariant (F2),
-- tcTypeKind(xi) = tcTypeKind(ty). But, it's possible that xi will be
-- used as an argument to a function whose kind is different, if
-- earlier arguments have been flattened to new types. We thus
-- earlier arguments have been rewritten to new types. We thus
-- need a coercion (kind_co :: old_kind ~ new_kind).
--
-- The bangs here have been observed to improve performance
......@@ -2977,8 +3014,8 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs
go acc_xis acc_cos lc [] inner_ki roles args
= let co1 = liftCoSubst Nominal lc inner_ki
co1_kind = coercionKind co1
unflattened_tys = map (coercionRKind . snd) args
(arg_cos, res_co) = decomposePiCos co1 co1_kind unflattened_tys
unrewritten_tys = map (coercionRKind . snd) args
(arg_cos, res_co) = decomposePiCos co1 co1_kind unrewritten_tys
casted_args = ASSERT2( equalLength args arg_cos
, ppr args $$ ppr arg_cos )
[ (casted_xi, casted_co)
......@@ -2992,20 +3029,20 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs
-- ... -> k, that k will be substituted to perhaps reveal more
-- binders.
zapped_lc = zapLiftingContext lc
Pair flattened_kind _ = co1_kind
(bndrs, new_inner) = splitPiTys flattened_kind
Pair rewritten_kind _ = co1_kind
(bndrs, new_inner) = splitPiTys rewritten_kind
(xis_out, cos_out, res_co_out)
= go acc_xis acc_cos zapped_lc bndrs new_inner roles casted_args
in
(xis_out, cos_out, res_co_out `mkTransCo` res_co)
(xis_out, cos_out, res_co_out `mkTransMCoL` res_co)
go _ _ _ _ _ _ _ = panic
"simplifyArgsWorker wandered into deeper water than usual"
-- This debug information is commented out because leaving it in
-- causes a ~2% increase in allocations in T9872d.
-- That's independent of the analogous case in flatten_args_fast
-- in GHC.Tc.Solver.Flatten:
-- That's independent of the analogous case in rewrite_args_fast
-- in GHC.Tc.Solver.Rewrite:
-- each of these causes a 2% increase on its own, so commenting them
-- both out gives a 4% decrease in T9872d.
{-
......@@ -3024,31 +3061,40 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs
%************************************************************************
-}
bad_co_hole_ty :: Type -> Monoid.Any
bad_co_hole_co :: Coercion -> Monoid.Any
(bad_co_hole_ty, _, bad_co_hole_co, _)
has_co_hole_ty :: Type -> Monoid.Any
has_co_hole_co :: Coercion -> Monoid.Any
(has_co_hole_ty, _, has_co_hole_co, _)
= foldTyCo folder ()
where
folder = TyCoFolder { tcf_view = const Nothing
, tcf_tyvar = const2 (Monoid.Any False)
, tcf_covar = const2 (Monoid.Any False)
, tcf_hole = const hole
, tcf_hole = const2 (Monoid.Any True)
, tcf_tycobinder = const2
}
const2 :: a -> b -> c -> a
const2 x _ _ = x
hole :: CoercionHole -> Monoid.Any
hole (CoercionHole { ch_blocker = YesBlockSubst }) = Monoid.Any True
hole _ = Monoid.Any False
-- | Is there a coercion hole in this type?
hasCoercionHoleTy :: Type -> Bool
hasCoercionHoleTy = Monoid.getAny . has_co_hole_ty
-- | Is there a coercion hole in this coercion?
hasCoercionHoleCo :: Coercion -> Bool
hasCoercionHoleCo = Monoid.getAny . has_co_hole_co
-- | Is there a blocking coercion hole in this type? See
-- "GHC.Tc.Solver.Canonical" Note [Equalities with incompatible kinds]
badCoercionHole :: Type -> Bool
badCoercionHole = Monoid.getAny . bad_co_hole_ty
-- | A set of 'CoercionHole's
type HoleSet = UniqSet CoercionHole
-- | Is there a blocking coercion hole in this coercion? See
-- GHC.Tc.Solver.Canonical Note [Equalities with incompatible kinds]
badCoercionHoleCo :: Coercion -> Bool
badCoercionHoleCo = Monoid.getAny . bad_co_hole_co
-- | Extract out all the coercion holes from a given type
coercionHolesOfType :: Type -> UniqSet CoercionHole
coercionHolesOfCo :: Coercion -> UniqSet CoercionHole
(coercionHolesOfType, _, coercionHolesOfCo, _) = foldTyCo folder ()
where
folder = TyCoFolder { tcf_view = const Nothing -- don't look through synonyms
, tcf_tyvar = \ _ _ -> mempty
, tcf_covar = \ _ _ -> mempty
, tcf_hole = const unitUniqSet
, tcf_tycobinder = \ _ _ _ -> ()
}
......@@ -30,7 +30,7 @@ mkInstCo :: Coercion -> Coercion -> Coercion
mkGReflCo :: Role -> Type -> MCoercionN -> Coercion
mkNomReflCo :: Type -> Coercion
mkKindCo :: Coercion -> Coercion
mkSubCo :: Coercion -> Coercion
mkSubCo :: HasDebugCallStack => Coercion -> Coercion
mkProofIrrelCo :: Role -> Coercion -> Coercion -> Coercion -> Coercion
mkAxiomRuleCo :: CoAxiomRule -> [Coercion] -> Coercion
......
......@@ -584,9 +584,21 @@ instance Outputable CoAxiomRule where
-- Type checking of built-in families
data BuiltInSynFamily = BuiltInSynFamily
{ sfMatchFam :: [Type] -> Maybe (CoAxiomRule, [Type], Type)
-- Does this reduce on the given arguments?
-- If it does, returns (CoAxiomRule, types to instantiate the rule at, rhs type)
-- That is: mkAxiomRuleCo coax (zipWith mkReflCo (coaxrAsmpRoles coax) ts)
-- :: F tys ~r rhs,
-- where the r in the output is coaxrRole of the rule. It is up to the
-- caller to ensure that this role is appropriate.
, sfInteractTop :: [Type] -> Type -> [TypeEqn]
-- If given these type arguments and RHS, returns the equalities that
-- are guaranteed to hold.
, sfInteractInert :: [Type] -> Type ->
[Type] -> Type -> [TypeEqn]
-- If given one set of arguments and result, and another set of arguments
-- and result, returns the equalities that are guaranteed to hold.
}
-- Provides default implementations that do nothing.
......