summaryrefslogtreecommitdiff
path: root/compiler/GHC/Types/Literal.hs
diff options
context:
space:
mode:
authorAndrew Martin <andrew.thaddeus@gmail.com>2019-11-13 11:20:05 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-23 13:37:01 -0400
commit49301ad6226d9a83d110bee8c419615dd94f5ded (patch)
tree907c00e2c81d1f2025ad569cedf2bc39833bcb07 /compiler/GHC/Types/Literal.hs
parentd830bbc9921bcc59164a0a18f0e0874ae4ce226e (diff)
downloadhaskell-49301ad6226d9a83d110bee8c419615dd94f5ded.tar.gz
Implement cstringLength# and FinalPtr
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.
Diffstat (limited to 'compiler/GHC/Types/Literal.hs')
-rw-r--r--compiler/GHC/Types/Literal.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/GHC/Types/Literal.hs b/compiler/GHC/Types/Literal.hs
index c31f6349db..c57cc2bb97 100644
--- a/compiler/GHC/Types/Literal.hs
+++ b/compiler/GHC/Types/Literal.hs
@@ -114,7 +114,7 @@ data Literal
-- See Note [Types of LitNumbers] below for the
-- Type field.
- | LitString ByteString -- ^ A string-literal: stored and emitted
+ | LitString !ByteString -- ^ A string-literal: stored and emitted
-- UTF-8 encoded, we'll arrange to decode it
-- at runtime. Also emitted with a @\'\\0\'@
-- terminator. Create with 'mkLitString'