-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Initial support for LLVM > 4.0 #66
Conversation
IntegerType::get(context, 32), | ||
NULL)); | ||
IntegerType::get(context, 32))); | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could do something like:
#if LLVM_VERSION_MAJOR > 4
#define getOrInsertFunction(M, a, b, c, d, e) \
M->getOrInsertFunction(a,b,c,d,e,0)
#else
#define getOrInsertFunction(M, a, b, c, d, e) \
M->getOrInsertFunction(a,b,c,d,e)
#endif
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about this too. I wasn't certain if this solution would actually lead to cleaner code or if all these macros cluttering the code would be detrimental for code clarity in the long run.
If you prefer the macro solution, I can of course change it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A solution not involving macros, but that also reduces code duplication would be of course nicer. I guess we might be able to make this macro into a standard function in fact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, something like that might work (not yet tested):
template<typename... ArgsTy>
Constant *getOrInsertFunction(Module* m, StringRef Name, Type *RetTy, ArgsTy... Args) {
#if LLVM_VERSION_MAJOR > 4
return m->getOrInsertFunction(Name, RetTy, Args...);
#else
return m->getOrInsertFunction(Name, RetTy, Args..., NULL);
#endif
}
Type-safe and no macro magic :) I'll implement/test that tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, nice! :)
Awesome. Thank you! :) |
These changes allow coriander to be compiled with LLVM > 4.0. (I have tested with LLVM 6.0). The changes are backwards compatible to LLVM 4.0.
This also fixes issue #55 on all systems where LLVM is newer than 4.0 since it allows compiling coriander against the LLVM installed on the system. This then avoids the LLVM version mismatch.
At the moment, there is still a small caveat: When compiling coriander programs, clang 4.0 must still be used, otherwise weird standard library errors related to clang's cuda support start appearing. I don't know how to fix these at the moment.