Skip to main content

Module outside

Module outside 

Source
Expand description

The handful of module facts a pass handed one function cannot reach, copied out once.

crate::alias is written, tested and documented, and until this existed nothing in the pipeline asked it anything. The reason was structural rather than anybody forgetting. A pass is handed one function, Alias::new wanted the module the function is in, and the manager hands out &mut module[id], so a pass could not borrow the module even to ask a question about it. That is tamnd/rucc#1467.

What the oracle wants from the module is four things and none of them is large.

What each name refers to, so that two symbols are known to be two objects. An alias or an ifunc is exactly a second name for something, so the question is not whether the module has the name but which of the three kinds it is.

What a function a call names is declared to do to memory, which is const, pure and argmemonly as the C programmer wrote them.

The parent of each type node, which is the whole of what the type based layer walks. The nodes are a flat table on the module and the walk only ever goes up, so a vector of parents indexed the way the table is is the same walk with the module left behind.

The data layout, which is two words and is there because the width of a pointer is the target’s answer rather than the type’s.

§Why a copy and not a borrow

The same argument crate::image makes, and the pipeline does the same thing with the result: one of these is built for the module before any pass runs and each function’s analysis cache holds a counted reference to it. A pass then builds its oracle out of the function it was handed and the cache it was handed, and borrows nothing that is being mutated.

The size is the reason this is affordable where a borrow would have been free. A symbol table entry is a word and a tag, a parent is an index, and neither is per instruction. The images this sits beside are a copy of the module’s read only data and are built anyway.

§The empty one

Outside::default knows nothing, and an oracle built on it answers May to everything it would have used the module for. That is what a caller with no module gets, and it is the conservative direction, so a test or a tool that builds a cache without a pipeline is slower rather than wrong.

Structs§

Outside
The module, as much of it as an alias oracle asks about.