Commit Graph

8 Commits

Author SHA1 Message Date
Michael Gottesman
2f3670f754 [opt-remark] Move Argument::inferArgumentFromValue into OptRemarkGenerator.
I noticed that I kept on needing to hack on this as I added stuff to
OptRemarkGenerator and felt the need to tie it even closer to
OptRemarkGenerator. As I began to think about it, this is really something
specific to that algorithm, so it really doesn't make sense to have it as part
of the general SIL library.

This is a NFC refactoring.
2020-07-24 21:15:34 -07:00
Michael Gottesman
750c8d32ac [opt-remark] Have OptEmitter store a SILFunction instead of a SILModule.
In all of these cases, we already had a SILFunction and were just grabbing its
SILModule instead of passing it in. So this is just an NFC change.

The reason why I am doing this is so that I can force emit opt-remarks on
functions with the semantics attribute "optremark", so I need to be able to
access the SILFunction in the optimization remark infrastructure.
2020-07-24 17:11:47 -07:00
Michael Gottesman
f8d0f474b8 [opt-remark] Teach arg inference how to handle simple loads from globals.
Just adding new patterns.
2020-07-21 22:10:53 -07:00
Michael Gottesman
2c9a34fa01 [opt-remark] Teach opt-remark how to emit notes that point to the value being retained/released.
This is just an initial implementation and doesn't handle all cases. This works
by grabbing the rc-identity root of a retain/release operation and then seeing:

1. If it is an argument, we use the ValueDecl of the argument.
2. If it is an instruction result, we try to infer the ValueDecl by looking for debug_value uses.
3. In the future, we should add support for globals and looking at addresses.

I may do 3 since it is important to have support for that due to inout objects.
2020-07-20 19:43:47 -07:00
Michael Gottesman
aea6d7df80 [opt-remark] Teach opt-remark how to emit "NOTE" arguments that use the loc of the original remark instead of the args own.
This is useful if one wants to emit a note explanation (in my case that we
couldn't find any values) but do not have any other source loc but the original
remark.
2020-07-20 19:43:47 -07:00
Michael Gottesman
9a828bc78f [opt-remark] Teach opt-remarks how to emit notes.
I did this by adding a kind to Arguments and making it so we have a kind that
emits as a separate NOTE when we emit diagnostics, but is emitted as a normal
argument when emitting to the bitstream.
2020-07-20 19:43:47 -07:00
Michael Gottesman
76c7c3e579 [opt-remark] Add support for emitting opt-remark-generator remarks when compiling with optimization.
In order to test this, I implemented a small source loc inference routine for
instructions without valid SILLocations. This is an optional nob that the
opt-remark writer can optionally enable on a per remark basis. The current
behaviors are just forward/backward scans in the same basic block. If we scan
forwards, if we find a valid SourceLoc, we just use ethat. If we are scanning
backwards, instead we grab the SourceRange and if it is valid use the end source
range of the given instruction. This seems to give a good result for retain
(forward scan) and release (backward scan).

The specific reason that I did that is that my test case for this are
retain/release operations. Often times these operations due to code-motion are
moved around (and rightly to prevent user confusion) given by optimizations auto
generated SIL locations. Since that is the test case I am using, to test this I
needed said engine.
2020-07-20 12:01:34 -07:00
Michael Gottesman
e1a19e4173 [sil] Split library into subfolders, while still building as a single library still.
Specifically, I split it into 3 initial categories: IR, Utils, Verifier. I just
did this quickly, we can always split it more later if we want.

I followed the model that we use in SILOptimizer: ./lib/SIL/CMakeLists.txt vends
 a macro (sil_register_sources) to the sub-folders that register the sources of
 the subdirectory with a global state variable that ./lib/SIL/CMakeLists.txt
 defines. Then after including those subdirs, the parent cmake declares the SIL
 library. So the output is the same, but we have the flexibility of having
 subdirectories to categorize source files.
2020-03-30 11:01:00 -07:00