2 ms·
LTO breaks code which assumes that the compiler has no idea what is behind an external function call and must not assume anything about the values of objects th
by kazinator 1y ago
LTO breaks code which assumes that the compiler has no idea what is behind an external function call and must not assume anything about the values of objects that the code might have access to:
securely_wipe_memory(&obj, sizeof obj);
return;
}
Compiler peeks into securely_wipe_memory and sees that it has no effect because obj is a local variable which has no "next use" in the data flow graph. Thus the call is removed.
Another example:
gc_protect(object);
return
}
Here, gc_protect is an empty function. Without LTO, the compiler must assume that the value of object is required for the gc_protect call and so the generated code has to hang on to that value until that call is made. With LTO, the compiler peeks at the definition of gc_protect and sees the ruse: the function is empty! Therefore, that line of code does not represent a use of the variable. The generated code can use the register or memory location for something else long before that line. If the garbage collector goes off in that part of the code, the object is prematurely collected (if what was lost happens to be the last reference to it).
Some distros have played with turning on LTO as a default compiler option for building packages. It's a very, very bad idea.