Skip to content

Commit 35dceab

Browse files
committed
Set clang code generation's frame pointer kind.
1 parent 109813f commit 35dceab

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ static llvm::PointerType *createStructPointerType(IRGenModule &IGM,
9090
return createStructType(IGM, name, types)->getPointerTo(DefaultAS);
9191
};
9292

93+
static clang::CodeGenOptions::FramePointerKind
94+
shouldUseFramePointer(const IRGenOptions &Opts) {
95+
if (Opts.DisableFPElim) {
96+
// General frame pointer elimination is disabled.
97+
// Should we at least eliminate in leaf functions?
98+
return Opts.DisableFPElimLeaf
99+
? clang::CodeGenOptions::FramePointerKind::All
100+
: clang::CodeGenOptions::FramePointerKind::NonLeaf;
101+
}
102+
103+
return clang::CodeGenOptions::FramePointerKind::None;
104+
105+
}
106+
93107
static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
94108
llvm::LLVMContext &LLVMContext,
95109
const IRGenOptions &Opts,
@@ -102,9 +116,7 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
102116

103117
auto &CGO = Importer->getClangCodeGenOpts();
104118
CGO.OptimizationLevel = Opts.shouldOptimize() ? 3 : 0;
105-
CGO.setFramePointer(Opts.DisableFPElim
106-
? clang::CodeGenOptions::FramePointerKind::All
107-
: clang::CodeGenOptions::FramePointerKind::None);
119+
CGO.setFramePointer(shouldUseFramePointer(Opts));
108120
CGO.DiscardValueNames = !Opts.shouldProvideValueNames();
109121
switch (Opts.DebugInfoLevel) {
110122
case IRGenDebugInfoLevel::None:

0 commit comments

Comments
 (0)