Skip to content

Commit 321351c

Browse files
committed
Add SILFunction::preserveDebugInfo()
1 parent fe961e7 commit 321351c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,15 @@ class SILFunction
839839
OptMode = unsigned(mode);
840840
}
841841

842+
/// True if debug information must be preserved (-Onone).
843+
///
844+
/// If this is false (-O), then the presence of debug info must not affect the
845+
/// outcome of any transformations.
846+
///
847+
/// Typically used to determine whether a debug_value is a normal SSA use or
848+
/// incidental use.
849+
bool preserveDebugInfo() const;
850+
842851
PerformanceConstraints getPerfConstraints() const { return perfConstraints; }
843852

844853
void setPerfConstraints(PerformanceConstraints perfConstr) {

lib/SIL/IR/SILFunction.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ OptimizationMode SILFunction::getEffectiveOptimizationMode() const {
281281
return getModule().getOptions().OptMode;
282282
}
283283

284+
bool SILFunction::preserveDebugInfo() const {
285+
return getEffectiveOptimizationMode() <= OptimizationMode::NoOptimization;
286+
}
287+
284288
bool SILFunction::shouldOptimize() const {
285289
return getEffectiveOptimizationMode() != OptimizationMode::NoOptimization;
286290
}

0 commit comments

Comments
 (0)