Merge pull request #66333 from al45tair/eng/PR-110260855

[Backtracing][IRGen] Add a semantic attribute to force frame pointer.
This commit is contained in:
Alastair Houghton
2023-06-06 17:51:20 +01:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

View File

@@ -144,5 +144,8 @@ SEMANTICS_ATTR(NO_PERFORMANCE_ANALYSIS, "no_performance_analysis")
// that may cause the user to think there is a bug in the compiler. // that may cause the user to think there is a bug in the compiler.
SEMANTICS_ATTR(NO_MOVEONLY_DIAGNOSTICS, "sil.optimizer.moveonly.diagnostic.ignore") SEMANTICS_ATTR(NO_MOVEONLY_DIAGNOSTICS, "sil.optimizer.moveonly.diagnostic.ignore")
// Force the use of the frame pointer for the specified function
SEMANTICS_ATTR(USE_FRAME_POINTER, "use_frame_pointer")
#undef SEMANTICS_ATTR #undef SEMANTICS_ATTR

View File

@@ -21,6 +21,7 @@
#include "swift/AST/IRGenOptions.h" #include "swift/AST/IRGenOptions.h"
#include "swift/AST/ParameterList.h" #include "swift/AST/ParameterList.h"
#include "swift/AST/Pattern.h" #include "swift/AST/Pattern.h"
#include "swift/AST/SemanticAttrs.h"
#include "swift/AST/SubstitutionMap.h" #include "swift/AST/SubstitutionMap.h"
#include "swift/AST/Types.h" #include "swift/AST/Types.h"
#include "swift/Basic/ExternalUnion.h" #include "swift/Basic/ExternalUnion.h"
@@ -1854,6 +1855,11 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f)
} }
} }
// If we have @_semantics("use_frame_pointer"), force the use of a
// frame pointer for this function.
if (f->hasSemanticsAttr(semantics::USE_FRAME_POINTER))
CurFn->addFnAttr("frame-pointer", "all");
// Disable inlining of coroutine functions until we split. // Disable inlining of coroutine functions until we split.
if (f->getLoweredFunctionType()->isCoroutine()) { if (f->getLoweredFunctionType()->isCoroutine()) {
CurFn->addFnAttr(llvm::Attribute::NoInline); CurFn->addFnAttr(llvm::Attribute::NoInline);