Set clang code generation's frame pointer kind.

This commit is contained in:
Arnold Schwaighofer
2020-05-22 05:34:54 -07:00
parent 109813ffe5
commit 35dceab8a0

View File

@@ -90,6 +90,20 @@ static llvm::PointerType *createStructPointerType(IRGenModule &IGM,
return createStructType(IGM, name, types)->getPointerTo(DefaultAS);
};
static clang::CodeGenOptions::FramePointerKind
shouldUseFramePointer(const IRGenOptions &Opts) {
if (Opts.DisableFPElim) {
// General frame pointer elimination is disabled.
// Should we at least eliminate in leaf functions?
return Opts.DisableFPElimLeaf
? clang::CodeGenOptions::FramePointerKind::All
: clang::CodeGenOptions::FramePointerKind::NonLeaf;
}
return clang::CodeGenOptions::FramePointerKind::None;
}
static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
llvm::LLVMContext &LLVMContext,
const IRGenOptions &Opts,
@@ -102,9 +116,7 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
auto &CGO = Importer->getClangCodeGenOpts();
CGO.OptimizationLevel = Opts.shouldOptimize() ? 3 : 0;
CGO.setFramePointer(Opts.DisableFPElim
? clang::CodeGenOptions::FramePointerKind::All
: clang::CodeGenOptions::FramePointerKind::None);
CGO.setFramePointer(shouldUseFramePointer(Opts));
CGO.DiscardValueNames = !Opts.shouldProvideValueNames();
switch (Opts.DebugInfoLevel) {
case IRGenDebugInfoLevel::None: