Fix Unit tests under LLVM 11 #227
Merged
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.
Resolves #225.
Two issues needed addressed.
Argument Auto-Generated Names
Per LLVM 10.0 release notes:
For example, IR that used to be:
becomes:
Solution: Update file check statements to include argument names.
Default Alignments
Couldn't find it mentioned in the release notes, but a recent LLVM seems to have changed the spec for
alloca
,load
, andstore
such thatalign
is now required to be specified in the IR with the alignment value. (See here.) Functions such asLLVMBuildAlloca
will now auto-generate an alignment, although one can be explicitly specified viaLLVMSetAlignment
.Unfortunately, with this change, calling
LLVMSetAlignment
with an alignment of 0 is unsupported (this could be a bug in LLVM). When 0 is passed, internally LLVM now wraps it in anAlign
rather than aMaybeAlign
and does not perform a 0 check (see here.). Eventually,Log2
is called on the alignment, and the shortcut for Log2 (e.g. 31 - leading zero bit count) results in an overflow of the unsigned integer. This causes a very large alignment value and module verification fails.Solution: Keep the generated alignment value from methods like
LLVMBuildAlloca
and only explicit set one when non-zero.