Skip to content

Commit d3d345b

Browse files
authored
Merge pull request #66333 from al45tair/eng/PR-110260855
[Backtracing][IRGen] Add a semantic attribute to force frame pointer.
2 parents 9c98ee8 + f8fe8b1 commit d3d345b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/swift/AST/SemanticAttrs.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,8 @@ SEMANTICS_ATTR(NO_PERFORMANCE_ANALYSIS, "no_performance_analysis")
144144
// that may cause the user to think there is a bug in the compiler.
145145
SEMANTICS_ATTR(NO_MOVEONLY_DIAGNOSTICS, "sil.optimizer.moveonly.diagnostic.ignore")
146146

147+
// Force the use of the frame pointer for the specified function
148+
SEMANTICS_ATTR(USE_FRAME_POINTER, "use_frame_pointer")
149+
147150
#undef SEMANTICS_ATTR
148151

lib/IRGen/IRGenSIL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/AST/IRGenOptions.h"
2222
#include "swift/AST/ParameterList.h"
2323
#include "swift/AST/Pattern.h"
24+
#include "swift/AST/SemanticAttrs.h"
2425
#include "swift/AST/SubstitutionMap.h"
2526
#include "swift/AST/Types.h"
2627
#include "swift/Basic/ExternalUnion.h"
@@ -1854,6 +1855,11 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f)
18541855
}
18551856
}
18561857

1858+
// If we have @_semantics("use_frame_pointer"), force the use of a
1859+
// frame pointer for this function.
1860+
if (f->hasSemanticsAttr(semantics::USE_FRAME_POINTER))
1861+
CurFn->addFnAttr("frame-pointer", "all");
1862+
18571863
// Disable inlining of coroutine functions until we split.
18581864
if (f->getLoweredFunctionType()->isCoroutine()) {
18591865
CurFn->addFnAttr(llvm::Attribute::NoInline);

0 commit comments

Comments
 (0)