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

Add missing LLVM::Attribute members #8358

Merged
merged 1 commit into from
Oct 21, 2019
Merged

Conversation

RX14
Copy link
Member

@RX14 RX14 commented Oct 21, 2019

cc @anatol

Applying this patch (or actually a subset of it, only ImmArg needs to be added) should allow building crystal for LLVM 9.

ImmArg is set on some function args by default, it can be ignored, just needs to be mapped correctly so as to not fail.

Fixes #8294.

This enables support for LLVM 9.
Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I don't understand: did some enum values change? Does this mean some values work for llvm 8 but for llvm you need other (integer) values for the same enum members? If so, this change should include mapping between these values between versions.

@RX14
Copy link
Member Author

RX14 commented Oct 21, 2019

LLVM completely uses the "kind ids" internally, which we query LLVM for at runtime by string literal and store them. The raw enum values are only used for crystal. A look at the llvm bindings and the context for this diff is probaby the best way to grok this.

For reference, here is the LLVM-internal enum IDs for my particular build of LLVM:

{Alignment => 1, AllocSize => 2, AlwaysInline => 3, ArgMemOnly => 4, Builtin => 5, ByVal => 6, Cold => 7, Convergent => 8, Dereferenceable => 9, DereferenceableOrNull => 10, InAlloca => 12, InReg => 13, InaccessibleMemOnly => 14, InaccessibleMemOrArgMemOnly => 15, InlineHint => 16, JumpTable => 17, MinSize => 18, Naked => 19, Nest => 20, NoAlias => 21, NoBuiltin => 22, NoCapture => 23, NoDuplicate => 25, NoFree => 26, NoImplicitFloat => 27, NoInline => 28, NoRecurse => 29, NoRedZone => 30, NoReturn => 31, NoSync => 32, NoUnwind => 33, NonLazyBind => 34, NonNull => 35, OptimizeForSize => 37, OptimizeNone => 38, ReadNone => 39, ReadOnly => 40, Returned => 41, ImmArg => 11, ReturnsTwice => 42, SExt => 43, SafeStack => 44, SanitizeAddress => 45, SanitizeMemory => 48, SanitizeThread => 49, StackAlignment => 53, StackProtect => 54, StackProtectReq => 55, StackProtectStrong => 56, StructRet => 58, SwiftError => 59, SwiftSelf => 60, UWTable => 61, WillReturn => 62, WriteOnly => 63, ZExt => 64}

Notice how some of them are completely out of order, especially ImmArg (which was the "11" in the original error)

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Thank you for the explanation too.

@bcardiff bcardiff added topic:compiler kind:bug A bug in the code. Does not apply to documentation, specs, etc. labels Oct 21, 2019
Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested in osx against llvm@9 👍

@bcardiff bcardiff added this to the 0.32.0 milestone Oct 21, 2019
@bcardiff bcardiff merged commit 200b76e into crystal-lang:master Oct 21, 2019
@anatol
Copy link
Contributor

anatol commented Oct 21, 2019

It works fine at Arch Linux. Thank you very much @RX14 for the fix.

@RX14
Copy link
Member Author

RX14 commented Oct 21, 2019

Note this still isn't the entire set of missing enum members, only the ones that changed between LLVM 8 and 9 which I thought were likely to be culprits. More work could be done on the bindings in the future, this just fixed the immediate fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port Crystal to LLVM9
4 participants