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.
This PR adds a simple type-based alias analysis (TBAA) using LLVM TBAA metadata generated by Clang.
The analysis is enabled by default and runs in addition to the other core alias analysis.
Overall issues:
-O1. Since we do not want to have-O1optimizations, we can useclang -O1 -Xclang -disable-llvm-passesto disable the-O1LLVM passes. However, Clang still seems to produce slightly different code and I'm not sure how to avoid that (-O3seemed to work better???).r = atomic_load(&x)does not generate TBAA metadata whereasr = xdoes, even if both are translated to the same code (assumingxis marked asatomic)As a result of the above, TBAA seems to add no more precision than the current analysis (only tested on
EBRso far, since our internal benchmarks are generated without TBAA metadata).A case where it could be more precise is if the code uses complex pointer tagging which confuses our standard analysis. But for code that does not do this, TBAA might be useless.
Side notes:
Running Clang with higher optimization level also generates other metadata, in particular,
!rangemetadata that limits the outcome of some loads from memory. It seems to give bounds for indices that are loaded to access an array.This could be valuable both for generating smaller encodings (less bitwidth) and for improving aliasing precision for dynamic indexing into arrays.