-
Notifications
You must be signed in to change notification settings - Fork 126
Merge llvm-12 into llvm-head-unstable #386
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
Merged
apaszke
merged 50 commits into
llvm-hs:llvm-head-unstable
from
apaszke:llvm-head-unstable
Mar 7, 2022
Merged
Merge llvm-12 into llvm-head-unstable #386
apaszke
merged 50 commits into
llvm-hs:llvm-head-unstable
from
apaszke:llvm-head-unstable
Mar 7, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For a constant structure `c`, `typeOf c` would always return a structure type with the type of all the values. However, when the constant structure has a named type reference as type, that should be used instead. This issue manifests when using llvm-hs-pretty, that can then produce invalid LLVM IR. For example, if we read the following code: ``` %t = type { i8 } @g = global { i32, %t } {i32 42, %t {i8 42}} ``` When pretty-printed we get: ``` %t = type { i8 } @g = global { i32, %t } {i32 42, {i8} {i8 42}} ``` which LLVM rejects due to the `%t` vs `{i8}` mismatch.
Fix typeOf const struct whose type is named. Previously, the explicit struct type was emitted instead of the associated type name, making the AST uneccesarily verbose.
`extractValue` is modified so that it can reconstruct its return type even in the presence of `NamedTypeReference`. This implies a MonadModuleBuilder dependency as in `gep` because named type references need to be looked up in the module builder state. Co-authored-by: Guerric Chupin <guerric@chnik.fr> Co-authored-by: Andrew Anderson <aanderso@tcd.ie>
* Handle NamedTypeReference in extractValue extractValue would error if given an alias to a struct/array, since it relied on extractValueType that doesn't know about aliases. Now it calls out the same function gep uses for type resolution. Because gep also accepts pointers and vector types, we check beforehand that only the the expected types were given Fixes llvm-hs#295 * Add missing HasCallStack for gep / extractValue Errors in `gep` would not show the call stack due to this Co-authored-by: Andrew Anderson <aanderso@tcd.ie>
- Fix all outstanding warnings when building against LLVM 9.0.1 - Remove deprecated `ListT` instances - Remove redundant imports - Correct hard-coded assumption that size_t is 32 bits in `LLVM.AST.Constant` - Add a matching non-constant sizeof in `LLVM.IRBuilder.Instruction` - Update test for extractValue in `LLVM.Test.Constants` and add a link to the upstream bug filed on the LLVM bugzilla
There is still a lot of stuff missing but given that the existing API is going to go away in the next major LLVM release, I’m going to merge this in the current state so we have at least something after that.
This reverts commit 5eac408. This functionality is not in LLVM 9 and so shouldn't be on this branch
* Add support for atomicrmw on floating point types * Generate rmw operation enum instead of defining separately
Update llvm-hs from LLVM 9 to LLVM 12. List of changes: - Attributes - Various minor changes, not listed in detail. - Debug information - DIFlag: BlockByrefStruct and ArgumentNotModified removed. - DISubrange - New arguments: upperBound and stride. - Arguments {lowerBound,upperBound,stride} are generalized and may be DIVariable or DIExpression in addition to Constant Int64. - DIModule - New arguments: apiNotesFile and lineNo. - Removed arguments: isysroot. - Instructions - New instructions: freeze. - Modified instructions - shufflevector: now takes mask as [Int32] instead of Constant. - JIT - Some deprecated OrcJIT v1 APIs are now removed: VModuleKey, SymbolResolver. - Start updating APIs and tests using OrcJIT v2 APIs. Work-in-progress. - Target - Target option flag changes, not listed in detail. - Transforms - Some existing transforms were removed or merged into others. Some had options modified. - Newly added APIs - Added Triple (target triple) API to llvm-hs-pure, along with string conversion and parsing. - Added debugging utilities: dumpMetadata. - Tests - Textual LLVM IR changes - Function parameters are now printed with local identifiers (e.g. `%0`). - Instruction alignment arguments must now be explicit: 0 no longer seems like a valid default value. - Instrumentation tests - Update MemorySanitizer test to run only on supported platforms: matching the implementation at https://github.com/llvm/llvm-project/blob/release/12.x/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp. - Optimization tests - Add a more robust "is module vectorized?" check for the SLPVectorization test. Current status: all tests pass via `stack test`. Todos: - Relevant comments to resolve: `{FIXME,TODO,NOTE}(llvm-12)` - Lots of code cleanup and API design finalization for OrcJIT v2. - Update installation instructions for llvm-hs@llvm-12. - Fix CI for llvm-hs@llvm-12. - Vote for using GitHub Actions instead of Travis CI. Co-authored-by: Adam Paszke <apaszke@google.com>
The symbols they call in the LLVM C bindings are not resolved (as of 12 Apr 2021 and possibly before). (llvm-hs#322) It seems reasonable to expect users of llvm-hs to be able to compose `writeFile stderr <$> ppLlvm <$> moduleAST` Since LLVM 12 changed the mask argument of `shufflevector` to a constant vector of `Int32`, `ppLlvm` requires a `Typed` instance for `[Int32]` for the above snippet to work properly.
…y LLVM components, remove hardcoded parallelism limits and let cmake figure things out automatically
…e getElementPtrType or getElementType
…nings generated by code in the LLVM release/9.x branch
…ileUnit -- change it in llvm-hs also to avoid divergence
* Apply fix for llvm-hs#315 and update C++ standard version (LLVM 12 uses C++14) * Update build options and README to address llvm-hs#315
* Handle NamedTypeReference in typeOf * Fix warning due to unused captures * Add a test for the resolution of typedefs (i.e. NamedTypeReference) in constant expressions * Add support for more DWARF operators (partially addresses llvm-hs#306) * Print an explicit error message for unhandled top-level DINodes, instead of the inscrutable "Unknown sublass id for DINode: <integer>" error message. * Rather than crash when we encounter a DINode for which lifting to Haskell is not implemented, simply ignore it. This way, the input program at least loads, with some debug information missing. Otherwise, llvm-hs simply cannot be used with IR produced from the LLVM tools with debug info emission turned on (for example, 'clang -g' will produce IR that crashes llvm-hs). * Fix two type signatures that got lost in the cherry-picking from the llvm-9 branch
* Build fix for GHC-9 Fixes llvm-hs#338 * Build fix for GHC-8.6 * Build fix for GHC>=8.10 Fixes llvm-hs#315 (properly) Co-authored-by: Andrew Anderson <aanderso@tcd.ie>
…ith or without RTTI. Reinstate the unfortunately necessary stanza in . Fixes llvm-hs#354.
…type of a getelementptr instruction, show the invalid index so the user has some chance of fixing the problem.
…strip off an index while processing 'NamedTypeReference's in constant expressions
…diagnose what is causing the failures. Audit LLVM.Internal.FFI.Type for duplication of the LLVM C API and remove it (addresses llvm-hs#358).
…o remove old, stale text, and encourage creation of issues for incomplete LLVM API coverage.
…I layer to make it easier to debug when things go wrong
Add int16 helper function
* IR-builder: use first terminator during codegen Previously, the latest terminator instruction was always used (`br`, `condBr`, `ret`, ...). This limited composability when creating combinators based on the IR builder. Now, we keep track of the first terminator which is more in line with how LLVM semantics work (terminators that appear later in a basic block are dead code). With this change, we can now create control flow combinators that work like we expect them to: ```haskell -- A combinator for a "one sided if statement" if' condition asm = mdo condBr condition begin end begin <- block `named` "if.begin" asm br end end <- block `named` "if.end" return () example = do function "f" [(AST.i1, "a"), (AST.i1, "b")] AST.i1 $ \[a, b] -> mdo entry <- block `named` "entry"; do if' a $ do if' b $ do -- Previously, this ret instruction would not be emitted! ret (bit 0) ret (bit 1) ``` * Add tests for emitting only first terminator * Update CHANGELOG * Add nested control flow test
`cxx-flags` aren't applied to `c-sources`, causing build errors on macOS.
llvm-12 has gotten quite a few updates that weren't included here, so this is an attempt to sync them up.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
llvm-12 has gotten quite a few updates that weren't included here, so
this is an attempt to sync them up.