Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM 3.5 backports #198

Merged
merged 5 commits into from
Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ out
.DS_Store
.cabal-sandbox
cabal.sandbox.config
.stack-work
/dist-newstyle/
*~
/stack.yaml
4 changes: 2 additions & 2 deletions llvm-general/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ addLLVMToLdLibraryPath configFlags = do
-- linking against LLVM build with Clang using GCC
ignoredCxxFlags :: [String]
ignoredCxxFlags =
["-Wcovered-switch-default"] ++ map ("-D" ++) uncheckedHsFFIDefines
["-Wcovered-switch-default", "-fcolor-diagnostics"] ++ map ("-D" ++) uncheckedHsFFIDefines

ignoredCFlags :: [String]
ignoredCFlags = ["-Wcovered-switch-default", "-Wdelete-non-virtual-dtor"]
ignoredCFlags = ["-Wcovered-switch-default", "-Wdelete-non-virtual-dtor", "-fcolor-diagnostics"]

main = do
let origUserHooks = simpleUserHooks
Expand Down
8 changes: 8 additions & 0 deletions llvm-general/src/LLVM/General/Internal/Attribute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import LLVM.General.Internal.Context
import LLVM.General.Internal.EncodeAST
import LLVM.General.Internal.DecodeAST

inconsistentCases :: Show a => String -> a -> b
inconsistentCases name attr =
error $ "llvm-general internal error: cases inconstistent in " ++ name ++ " encoding for " ++ show attr

instance Monad m => EncodeM m A.PA.ParameterAttribute (Ptr FFI.ParameterAttrBuilder -> EncodeAST ()) where
encodeM a = return $ \b -> liftIO $ case a of
A.PA.Alignment v -> FFI.attrBuilderAddAlignment b v
Expand All @@ -50,6 +54,8 @@ instance Monad m => EncodeM m A.PA.ParameterAttribute (Ptr FFI.ParameterAttrBuil
A.PA.InAlloca -> FFI.parameterAttributeKindInAlloca
A.PA.NonNull -> FFI.parameterAttributeKindNonNull
A.PA.Returned -> FFI.parameterAttributeKindReturned
A.PA.Alignment _ -> inconsistentCases "ParameterAttribute" a
A.PA.Dereferenceable _ -> inconsistentCases "ParameterAttribute" a

instance Monad m => EncodeM m A.FA.FunctionAttribute (Ptr FFI.FunctionAttrBuilder -> EncodeAST ()) where
encodeM (A.FA.StringAttribute kind value) = return $ \b -> do
Expand Down Expand Up @@ -86,6 +92,8 @@ instance Monad m => EncodeM m A.FA.FunctionAttribute (Ptr FFI.FunctionAttrBuilde
A.FA.SanitizeAddress -> FFI.functionAttributeKindSanitizeAddress
A.FA.SanitizeThread -> FFI.functionAttributeKindSanitizeThread
A.FA.SanitizeMemory -> FFI.functionAttributeKindSanitizeMemory
A.FA.StackAlignment _ -> inconsistentCases "FunctionAttribute" a
A.FA.StringAttribute _ _ -> inconsistentCases "FunctionAttribute" a

instance DecodeM DecodeAST A.PA.ParameterAttribute FFI.ParameterAttribute where
decodeM a = do
Expand Down
3 changes: 3 additions & 0 deletions llvm-general/src/LLVM/General/Internal/FFI/Attribute.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef __LLVM_GENERAL_INTERNAL_FFI__ATTRIBUTES__H__
#define __LLVM_GENERAL_INTERNAL_FFI__ATTRIBUTES__H__


// The last three arguments are flags indicating if this is a
// parameter attribute, function result attribute or function attribute.
#define LLVM_GENERAL_FOR_EACH_ATTRIBUTE_KIND(macro) \
macro(None,F,F,F) \
macro(Alignment,T,F,F) \
Expand Down