diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2020-11-25 09:32:00 +0800 |
---|---|---|
committer | Moritz Angermann <moritz.angermann@gmail.com> | 2021-05-06 19:42:50 -0400 |
commit | 24316c8320aca26e2cccf581269ed0daeb1b4a51 (patch) | |
tree | 8bcaa3e437a1be792ee6ea246bf6d9be29ee373d | |
parent | c972c4e3c3ac667d5c5081ffa153835cfa3c8f89 (diff) | |
download | haskell-24316c8320aca26e2cccf581269ed0daeb1b4a51.tar.gz |
CmmToLlvm: Declare signature for memcmp
Otherwise `opt` fails with:
error: use of undefined value '@memcmp$def'
-rw-r--r-- | compiler/GHC/CmmToLlvm/Base.hs | 10 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/compiler/GHC/CmmToLlvm/Base.hs b/compiler/GHC/CmmToLlvm/Base.hs index a47bfd3baa..bd0638914b 100644 --- a/compiler/GHC/CmmToLlvm/Base.hs +++ b/compiler/GHC/CmmToLlvm/Base.hs @@ -479,14 +479,17 @@ getUniqMeta s = getEnv (flip lookupUFM s . envUniqMeta) ghcInternalFunctions :: LlvmM () ghcInternalFunctions = do platform <- getPlatform + dflags <- getDynFlags let w = llvmWord platform + cint = LMInt $ widthInBits $ cIntWidth dflags + mk "memcmp" cint [i8Ptr, i8Ptr, w] mk "memcpy" i8Ptr [i8Ptr, i8Ptr, w] mk "memmove" i8Ptr [i8Ptr, i8Ptr, w] mk "memset" i8Ptr [i8Ptr, w, w] mk "newSpark" w [i8Ptr, i8Ptr] where mk n ret args = do - let n' = llvmDefLabel $ fsLit n + let n' = fsLit n decl = LlvmFunctionDecl n' ExternallyVisible CC_Ccc ret FixedArgs (tysToParams args) Nothing renderLlvm $ ppLlvmFunctionDecl decl @@ -519,7 +522,10 @@ getGlobalPtr llvmLbl = do let mkGlbVar lbl ty = LMGlobalVar lbl (LMPointer ty) Private Nothing Nothing case m_ty of -- Directly reference if we have seen it already - Just ty -> return $ mkGlbVar (llvmDefLabel llvmLbl) ty Global + Just ty -> do + if llvmLbl `elem` (map fsLit ["newSpark", "memmove", "memcpy", "memcmp", "memset"]) + then return $ mkGlbVar (llvmLbl) ty Global + else return $ mkGlbVar (llvmDefLabel llvmLbl) ty Global -- Otherwise use a forward alias of it Nothing -> do saveAlias llvmLbl diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index e899d61b84..618827f7c4 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -2196,6 +2196,13 @@ def normalise_errmsg(s: str) -> str: s = re.sub('Failed to remove file (.*); error= (.*)$', '', s) s = re.sub('DeleteFile "(.+)": permission denied \(Access is denied\.\)(.*)$', '', s) + # filter out unsupported GNU_PROPERTY_TYPE (5), which is emitted by LLVM10 + # and not understood by older binutils (ar, ranlib, ...) + s = modify_lines(s, lambda l: re.sub('^(.+)warning: (.+): unsupported GNU_PROPERTY_TYPE \(5\) type: 0xc000000(.*)$', '', l)) + + # filter out nix garbage, that just keeps on showing up as errors on darwin + s = modify_lines(s, lambda l: re.sub('^(.+)\.dylib, ignoring unexpected dylib file$','', l)) + return s # normalise a .prof file, so that we can reasonably compare it against @@ -2266,6 +2273,9 @@ def normalise_output( s: str ) -> str: s = re.sub('([^\\s])\\.exe', '\\1', s) s = normalise_callstacks(s) s = normalise_type_reps(s) + # ghci outputs are pretty unstable with -fexternal-dynamic-refs, which is + # requires for -fPIC + s = re.sub(' -fexternal-dynamic-refs\n','',s) return s def normalise_asm( s: str ) -> str: |