[DebugInfo][SIL] Introduce the 'implicit' attribute for debug variable

Debug variables that are marked 'implicit' on its `debug_value`
instruction mean that they were generated by compiler. Optimizers are
free to remove them (if it becomes a dead code, for instance) even in
-Onone. Since they are barely used by users and keeping them might lead
to incorrect IRGen results.
This commit is contained in:
Min-Yih Hsu
2021-08-03 10:17:55 -07:00
parent 2bb6498731
commit e63632fda8
7 changed files with 61 additions and 19 deletions

View File

@@ -222,7 +222,11 @@ bool swift::hasOnlyEndOfScopeOrDestroyUses(SILInstruction *inst) {
// Include debug uses only in Onone mode.
if (isDebugUser && inst->getFunction()->getEffectiveOptimizationMode() <=
OptimizationMode::NoOptimization)
return false;
if (auto DbgVarInst = DebugVarCarryingInst(user)) {
auto VarInfo = DbgVarInst.getVarInfo();
if (VarInfo && !VarInfo->Implicit)
return false;
}
}
}
return true;