Skip to content
  • Andrew Martin's avatar
    Implement cstringLength# and FinalPtr · 49301ad6
    Andrew Martin authored and Marge Bot's avatar Marge Bot committed
    This function and its accompanying rule resolve issue #5218.
    A future PR to the bytestring library will make the internal
    Data.ByteString.Internal.unsafePackAddress compute string length
    with cstringLength#. This will improve the status quo because it is
    eligible for constant folding.
    
    Additionally, introduce a new data constructor to ForeignPtrContents
    named FinalPtr. This additional data constructor, when used in the
    IsString instance for ByteString, leads to more Core-to-Core
    optimization opportunities, fewer runtime allocations, and smaller
    binaries.
    
    Also, this commit re-exports all the functions from GHC.CString
    (including cstringLength#) in GHC.Exts. It also adds a new test
    driver. This test driver is used to perform substring matches on Core
    that is dumped after all the simplifier passes. In this commit, it is
    used to check that constant folding of cstringLength# works.
    49301ad6