Skip to content

Commit

Permalink
Update for LLVM 7
Browse files Browse the repository at this point in the history
  • Loading branch information
cocreature committed Sep 28, 2018
1 parent 1e512dc commit 8bb3ef0
Show file tree
Hide file tree
Showing 35 changed files with 512 additions and 439 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ cache:
directories:
- $HOME/.cabal/packages
- $HOME/.cabal/store
- $HOME/llvm-build-6.0.0
- $HOME/llvm-src-6.0.0
- $HOME/llvm-build-7.0.0
- $HOME/llvm-src-7.0.0

before_cache:
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
Expand All @@ -23,7 +23,7 @@ env:
global:
- GCC=gcc-5
- GXX=g++-5
- LLVM_VER=6.0.0
- LLVM_VER=7.0.0

matrix:
include:
Expand Down Expand Up @@ -51,15 +51,15 @@ before_install:
- export PATH=$HOME/bin:$PATH

install:
- curl https://cmake.org/files/v3.10/cmake-3.10.1-Linux-x86_64.tar.gz | tar -xzf - -C $HOME
- export PATH=$HOME/cmake-3.10.1-Linux-x86_64/bin:$PATH
- curl https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz | tar -xzf - -C $HOME
- export PATH=$HOME/cmake-3.12.2-Linux-x86_64/bin:$PATH
- curl -L https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip -o ninja-linux.zip
- unzip ninja-linux.zip -d $HOME/bin
# - curl http://releases.llvm.org/${LLVM_VER}/llvm-${LLVM_VER}.src.tar.xz | tar -xJf - -C $HOME
# - rsync -ac $HOME/llvm-${LLVM_VER}.src/ $HOME/llvm-src-${LLVM_VER}
- curl -L https://github.com/llvm-mirror/llvm/archive/089d4c0c490687db6c75f1d074e99c4d42936a50.zip -o out.zip
- unzip -q out.zip -d $HOME
- rsync -ac $HOME/llvm-089d4c0c490687db6c75f1d074e99c4d42936a50/ $HOME/llvm-src-${LLVM_VER}
- curl http://releases.llvm.org/${LLVM_VER}/llvm-${LLVM_VER}.src.tar.xz | tar -xJf - -C $HOME
- rsync -ac $HOME/llvm-${LLVM_VER}.src/ $HOME/llvm-src-${LLVM_VER}
# - curl -L https://github.com/llvm-mirror/llvm/archive/089d4c0c490687db6c75f1d074e99c4d42936a50.zip -o out.zip
# - unzip -q out.zip -d $HOME
# - rsync -ac $HOME/llvm-089d4c0c490687db6c75f1d074e99c4d42936a50/ $HOME/llvm-src-${LLVM_VER}
- cd $HOME/llvm-src-${LLVM_VER}
- mkdir -p build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE=-O0 -DCMAKE_INSTALL_PREFIX=$HOME/llvm-build-${LLVM_VER} -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_LLVM_DYLIB=True -DLLVM_LINK_LLVM_DYLIB=True -GNinja ..
Expand Down
8 changes: 7 additions & 1 deletion llvm-hs-pure/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## unreleased
## 7.0.0 (2018-09-28)

* Track type definitions in `MonadModuleBuilder`. This allows us to
automatically resolve `NamedTypeReference`s in `gep` instructions.
Expand All @@ -8,6 +8,12 @@
`MonadModuleBuilder` constraint.
* Change the type of `typedef` in the `IRBuilder` API to return a
`NamedTypeReference` to the newly defined type.
* Update for LLVM 7.0:
* Add `isUnsigned` field to `DIEnumerator`.
* Change `DISubrange` to use the new `DICount` type instead of an `Int64`.
* Merge `checksum` and `checksumKind` fields of `DIFile` into a
`checksum` field of type `Maybe ChecksumInfo`.
* Rename the `variables` field of `DISubprogram` to `retainedNodes`.

## 6.2.1 (2018-06-12)

Expand Down
4 changes: 2 additions & 2 deletions llvm-hs-pure/llvm-hs-pure.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: llvm-hs-pure
version: 6.2.1
version: 7.0.0
license: BSD3
license-file: LICENSE
author: Anthony Cowley, Stephen Diehl, Moritz Kiefer <[email protected]>, Benjamin S. Scarlet
Expand All @@ -22,7 +22,7 @@ extra-source-files: CHANGELOG.md
source-repository head
type: git
location: git://github.com/llvm-hs/llvm-hs.git
branch: llvm-5
branch: llvm-7

library
default-language: Haskell2010
Expand Down
21 changes: 15 additions & 6 deletions llvm-hs-pure/src/LLVM/AST/Operand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,17 @@ data DIImportedEntity = ImportedEntity

-- | <https://llvm.org/docs/LangRef.html#dienumerator>
data DIEnumerator =
Enumerator { value :: Int64, name :: ShortByteString }
Enumerator { value :: Int64, isUnsigned :: Bool, name :: ShortByteString }
deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

-- | <https://llvm.org/docs/LangRef.html#disubrange>
data DISubrange =
Subrange { count :: Int64, lowerBound :: Int64 }
Subrange { count :: DICount, lowerBound :: Int64 }
deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

data DICount
= DICountConstant Int64
| DICountVariable (MDRef DIVariable)
deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

-- | <https://llvm.org/doxygen/classllvm_1_1DIScope.html>
Expand Down Expand Up @@ -255,11 +260,15 @@ data DICompileUnit = CompileUnit
data DIFile = File
{ filename :: ShortByteString
, directory :: ShortByteString
, checksum :: ShortByteString
, checksumKind :: ChecksumKind
, checksum :: Maybe ChecksumInfo
} deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

data ChecksumInfo = ChecksumInfo
{ checksumKind :: ChecksumKind
, checksumValue :: ShortByteString
} deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

data ChecksumKind = None | MD5 | SHA1
data ChecksumKind = MD5 | SHA1
deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

-- | <https://llvm.org/doxygen/classllvm_1_1DILocalScope.html>
Expand Down Expand Up @@ -288,7 +297,7 @@ data DISubprogram = Subprogram
, unit :: Maybe (MDRef DICompileUnit)
, templateParams :: [MDRef DITemplateParameter]
, declaration :: Maybe (MDRef DISubprogram)
, variables :: [MDRef DILocalVariable]
, retainedNodes :: [MDRef DILocalVariable]
, thrownTypes :: [MDRef DIType]
} deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

Expand Down
12 changes: 11 additions & 1 deletion llvm-hs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
## unreleased
## 7.0.0 (2018-09-28)

* Throw an `EncodeException` if a local variable is defined multiple
times. This is consistent with `llc` which also forbids reusing
variable names.
* Update for LLVM 7.0:
* The ORC JIT API has been changed to reflect the changes in LLVM
itself. The test suite should give you a good idea of how to adapt
your code but here is a summary:
* There is now a separate `ExecutionSession` that tracks module handles.
* `SymbolResolver` only has a single resolver function.
* Creating an `ObjectLinkingLayer` requires a way to get the
symbol resolver for a module.
* Creating a `CompileOnDemandLayer` requires a way to set and get
the symbol resolver for a module.

## 6.3.0 (2018-06-12)

Expand Down
2 changes: 1 addition & 1 deletion llvm-hs/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ lookupFlagAssignment = lookup
#endif

llvmVersion :: Version
llvmVersion = mkVersion [6,0]
llvmVersion = mkVersion [7,0]

llvmConfigNames :: [String]
llvmConfigNames = [
Expand Down
6 changes: 3 additions & 3 deletions llvm-hs/llvm-hs.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: llvm-hs
version: 6.3.0
version: 7.0.0
license: BSD3
license-file: LICENSE
author: Anthony Cowley, Stephen Diehl, Moritz Kiefer <[email protected]>, Benjamin S. Scarlet
Expand Down Expand Up @@ -45,7 +45,7 @@ extra-source-files: CHANGELOG.md
source-repository head
type: git
location: git://github.com/llvm-hs/llvm-hs.git
branch: llvm-4
branch: llvm-7

flag shared-llvm
description: link against llvm shared rather than static library
Expand Down Expand Up @@ -76,7 +76,7 @@ library
template-haskell >= 2.5.0.0,
containers >= 0.4.2.1,
array >= 0.4.0.0,
llvm-hs-pure == 6.2.*
llvm-hs-pure == 7.0.*
hs-source-dirs: src
default-extensions:
NoImplicitPrelude
Expand Down
3 changes: 3 additions & 0 deletions llvm-hs/src/LLVM/Internal/FFI/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
macro(NoAlias,T,T,F) \
macro(NoBuiltin,F,F,T) \
macro(NoCapture,T,F,F) \
macro(NoCfCheck,F,F,T) \
macro(NoDuplicate,F,F,T) \
macro(NoImplicitFloat,F,F,T) \
macro(NoInline,F,F,T) \
Expand All @@ -37,6 +38,7 @@
macro(NoUnwind,F,F,T) \
macro(NonLazyBind,F,F,T) \
macro(NonNull,T,T,F) \
macro(OptForFuzzing,F,F,T) \
macro(OptimizeForSize,F,F,T) \
macro(OptimizeNone,F,F,T) \
macro(ReadNone,T,F,T) \
Expand All @@ -49,6 +51,7 @@
macro(SanitizeHWAddress,F,F,T) \
macro(SanitizeMemory,F,F,T) \
macro(SanitizeThread,F,F,T) \
macro(ShadowCallStack,F,F,T) \
macro(Speculatable,F,F,T) \
macro(StackAlignment,F,F,T) \
macro(StackProtect,F,F,T) \
Expand Down
2 changes: 1 addition & 1 deletion llvm-hs/src/LLVM/Internal/FFI/BitcodeC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LLVMModuleRef LLVM_Hs_ParseBitcode(
}

void LLVM_Hs_WriteBitcode(LLVMModuleRef m, raw_ostream &os) {
WriteBitcodeToFile(unwrap(m), os);
WriteBitcodeToFile(*unwrap(m), os);
}

}
Expand Down
11 changes: 2 additions & 9 deletions llvm-hs/src/LLVM/Internal/FFI/GlobalValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ LLVM_HS_FOR_EACH_COMDAT_SELECTION_KIND(ENUM_CASE)
macro(LocalExecTLSModel)

#define LLVM_HS_FOR_EACH_UNNAMED_ADDR(macro) \
macro(None) \
macro(Local) \
macro(No) \
macro(Local) \
macro(Global)

typedef enum {
#define ENUM_CASE(x) LLVMUnnamedAddr ## x,
LLVM_HS_FOR_EACH_UNNAMED_ADDR(ENUM_CASE)
#undef ENUM_CASE
} LLVMUnnamedAddr;

#endif
4 changes: 2 additions & 2 deletions llvm-hs/src/LLVM/Internal/FFI/GlobalValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ foreign import ccall unsafe "LLVMGetAlignment" getAlignment ::
foreign import ccall unsafe "LLVMSetAlignment" setAlignment ::
Ptr GlobalValue -> CUInt -> IO ()

foreign import ccall unsafe "LLVM_Hs_GetUnnamedAddr" getUnnamedAddr ::
foreign import ccall unsafe "LLVMGetUnnamedAddress" getUnnamedAddr ::
Ptr GlobalValue -> IO UnnamedAddr

foreign import ccall unsafe "LLVM_Hs_SetUnnamedAddr" setUnnamedAddr ::
foreign import ccall unsafe "LLVMSetUnnamedAddress" setUnnamedAddr ::
Ptr GlobalValue -> UnnamedAddr -> IO ()

foreign import ccall unsafe "LLVM_Hs_GetThreadLocalMode" getThreadLocalMode ::
Expand Down
26 changes: 0 additions & 26 deletions llvm-hs/src/LLVM/Internal/FFI/GlobalValueC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,6 @@ void LLVM_Hs_SetCOMDATSelectionKind(Comdat &comdat, unsigned csk) {
comdat.setSelectionKind(Comdat::SelectionKind(csk));
}

static LLVMUnnamedAddr unwrap(GlobalValue::UnnamedAddr a) {
switch (a) {
#define ENUM_CASE(x) case GlobalValue::UnnamedAddr::x: return LLVMUnnamedAddr ## x;
LLVM_HS_FOR_EACH_UNNAMED_ADDR(ENUM_CASE)
#undef ENUM_CASE
default: return LLVMUnnamedAddrNone;
}
}

static GlobalValue::UnnamedAddr wrap(LLVMUnnamedAddr a) {
switch (a) {
#define ENUM_CASE(x) case LLVMUnnamedAddr ## x: return GlobalValue::UnnamedAddr::x;
LLVM_HS_FOR_EACH_UNNAMED_ADDR(ENUM_CASE)
#undef ENUM_CASE
default: return GlobalValue::UnnamedAddr::None;
}
}

LLVMUnnamedAddr LLVM_Hs_GetUnnamedAddr(LLVMValueRef globalVal) {
return unwrap(unwrap<GlobalValue>(globalVal)->getUnnamedAddr());
}

void LLVM_Hs_SetUnnamedAddr(LLVMValueRef globalVal, LLVMUnnamedAddr attr) {
unwrap<GlobalValue>(globalVal)->setUnnamedAddr(wrap(attr));
}

#define ENUM_CASE(n) \
static_assert(unsigned(GlobalValue::n) == unsigned(LLVM##n), \
"TLS Model Enum mismatch");
Expand Down
2 changes: 1 addition & 1 deletion llvm-hs/src/LLVM/Internal/FFI/LLVMCTypes.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ newtype MemoryOrdering = MemoryOrdering CUInt

newtype UnnamedAddr = UnnamedAddr CUInt
deriving (Eq, Show, Typeable, Data, Generic)
#define UA_Rec(n) { #n, LLVMUnnamedAddr ## n },
#define UA_Rec(n) { #n, LLVM ## n ## UnnamedAddr },
#{inject UNNAMED_ADDR, UnnamedAddr, UnnamedAddr, unnamedAddr, UA_Rec}

newtype SynchronizationScope = SynchronizationScope CUInt
Expand Down
22 changes: 17 additions & 5 deletions llvm-hs/src/LLVM/Internal/FFI/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,14 @@ namedMetadataAddOperands nm (n, vs) = namedMetadataAddOperands' nm vs n
-- DIEnumerator

foreign import ccall unsafe "LLVM_Hs_Get_DIEnumerator" getDIEnumerator ::
Ptr Context -> Int64 -> Ptr MDString -> IO (Ptr DIEnumerator)
Ptr Context -> Int64 -> LLVMBool -> Ptr MDString -> IO (Ptr DIEnumerator)

foreign import ccall unsafe "LLVM_Hs_DIEnumerator_GetValue" getDIEnumeratorValue ::
Ptr DIEnumerator -> IO Int64

foreign import ccall unsafe "LLVM_Hs_DIEnumerator_GetIsUnsigned" getDIEnumeratorIsUnsigned ::
Ptr DIEnumerator -> IO LLVMBool

foreign import ccall unsafe "LLVM_Hs_DIEnumerator_GetName" getDIEnumeratorName ::
Ptr DIEnumerator -> IO (Ptr MDString)

Expand All @@ -135,7 +138,7 @@ foreign import ccall unsafe "LLVM_Hs_DIFileGetFilename" getFileFilename ::
foreign import ccall unsafe "LLVM_Hs_DIFileGetDirectory" getFileDirectory ::
Ptr DIFile -> IO (Ptr MDString)

foreign import ccall unsafe "LLVM_Hs_DIFileGetChecksum" getFileChecksum ::
foreign import ccall unsafe "LLVM_Hs_DIFileGetChecksum" getFileChecksumValue ::
Ptr DIFile -> IO (Ptr MDString)

foreign import ccall unsafe "LLVM_Hs_DIFileGetChecksumKind" getFileChecksumKind ::
Expand Down Expand Up @@ -282,10 +285,19 @@ foreign import ccall unsafe "LLVM_Hs_Get_DIFile" getDIFile ::
Ptr Context -> Ptr MDString -> Ptr MDString -> ChecksumKind -> Ptr MDString -> IO (Ptr DIFile)

-- DISubrange
foreign import ccall unsafe "LLVM_Hs_Get_DISubrange" getDISubrange ::
foreign import ccall unsafe "LLVM_Hs_Get_DISubrangeConstantCount" getDISubrangeConstantCount ::
Ptr Context -> Int64 -> Int64 -> IO (Ptr DISubrange)

foreign import ccall unsafe "LLVM_Hs_DISubrange_GetCount" getDISubrangeCount ::
foreign import ccall unsafe "LLVM_Hs_Get_DISubrangeVariableCount" getDISubrangeVariableCount ::
Ptr Context -> Ptr DIVariable -> Int64 -> IO (Ptr DISubrange)

foreign import ccall unsafe "LLVM_Hs_DISubrange_HasConstantCount" getDISubrangeHasConstantCount ::
Ptr DISubrange -> IO LLVMBool

foreign import ccall unsafe "LLVM_Hs_DISubrange_GetVariableCount" getDISubrangeCountVariable ::
Ptr DISubrange -> IO (Ptr DIVariable)

foreign import ccall unsafe "LLVM_Hs_DISubrange_GetConstantCount" getDISubrangeCountConstant ::
Ptr DISubrange -> IO Int64

foreign import ccall unsafe "LLVM_Hs_DISubrange_GetLowerBound" getDISubrangeLowerBound ::
Expand Down Expand Up @@ -335,7 +347,7 @@ foreign import ccall unsafe "LLVM_Hs_DISubprogram_GetUnit" getDISubprogramUnit :
foreign import ccall unsafe "LLVM_Hs_DISubprogram_GetTemplateParams" getDISubprogramTemplateParams ::
Ptr DISubprogram -> IO (TupleArray DITemplateParameter)

foreign import ccall unsafe "LLVM_Hs_DISubprogram_GetVariables" getDISubprogramVariables ::
foreign import ccall unsafe "LLVM_Hs_DISubprogram_GetRetainedNodes" getDISubprogramRetainedNodes ::
Ptr DISubprogram -> IO (TupleArray DILocalVariable)

foreign import ccall unsafe "LLVM_Hs_DISubprogram_GetThrownTypes" getDISubprogramThrownTypes ::
Expand Down
Loading

0 comments on commit 8bb3ef0

Please sign in to comment.