From 2786e673c7d67ffca531ef38d679620ee3048a1e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 22 Apr 2021 18:07:29 -0700 Subject: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all} The Linux kernel objtool diagnostic `call without frame pointer save/setup` arise in multiple instrumentation passes (asan/tsan/gcov). With the mechanism introduced in D100251, it's trivial to respect the command line -m[no-]omit-leaf-frame-pointer/-f[no-]omit-frame-pointer, so let's do it. Fix: https://github.com/ClangBuiltLinux/linux/issues/1236 (tsan) Fix: https://github.com/ClangBuiltLinux/linux/issues/1238 (asan) Also document the function attribute "frame-pointer" which is long overdue. Differential Revision: https://reviews.llvm.org/D101016 --- clang/lib/CodeGen/CodeGenModule.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 6b966e7ca133..fd5975b4f545 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -744,6 +744,18 @@ void CodeGenModule::Release() { if (CodeGenOpts.UnwindTables) getModule().setUwtable(); + switch (CodeGenOpts.getFramePointer()) { + case CodeGenOptions::FramePointerKind::None: + // 0 ("none") is the default. + break; + case CodeGenOptions::FramePointerKind::NonLeaf: + getModule().setFramePointer(llvm::FramePointerKind::NonLeaf); + break; + case CodeGenOptions::FramePointerKind::All: + getModule().setFramePointer(llvm::FramePointerKind::All); + break; + } + SimplifyPersonality(); if (getCodeGenOpts().EmitDeclMetadata) -- cgit v1.2.3