diff options
author | Fangrui Song <i@maskray.me> | 2021-04-22 18:07:29 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-04-22 18:07:30 -0700 |
commit | 2786e673c7d67ffca531ef38d679620ee3048a1e (patch) | |
tree | bfa8a40a80741ad2fd9565e50be742b9ad70bc4a /llvm/lib/CodeGen/CommandFlags.cpp | |
parent | 879cbac08ba17566ad61ff2b9d7180bcab4a0d1e (diff) | |
download | llvm-2786e673c7d67ffca531ef38d679620ee3048a1e.zip llvm-2786e673c7d67ffca531ef38d679620ee3048a1e.tar.gz llvm-2786e673c7d67ffca531ef38d679620ee3048a1e.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/CodeGen/CommandFlags.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CommandFlags.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index de56055..76d8719 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -53,7 +53,7 @@ CGOPT(ThreadModel::Model, ThreadModel) CGOPT_EXP(CodeModel::Model, CodeModel) CGOPT(ExceptionHandling, ExceptionModel) CGOPT_EXP(CodeGenFileType, FileType) -CGOPT(FramePointer::FP, FramePointerUsage) +CGOPT(FramePointerKind, FramePointerUsage) CGOPT(bool, EnableUnsafeFPMath) CGOPT(bool, EnableNoInfsFPMath) CGOPT(bool, EnableNoNaNsFPMath) @@ -183,16 +183,16 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() { "Emit nothing, for performance testing"))); CGBINDOPT(FileType); - static cl::opt<FramePointer::FP> FramePointerUsage( + static cl::opt<FramePointerKind> FramePointerUsage( "frame-pointer", cl::desc("Specify frame pointer elimination optimization"), - cl::init(FramePointer::None), + cl::init(FramePointerKind::None), cl::values( - clEnumValN(FramePointer::All, "all", + clEnumValN(FramePointerKind::All, "all", "Disable frame pointer elimination"), - clEnumValN(FramePointer::NonLeaf, "non-leaf", + clEnumValN(FramePointerKind::NonLeaf, "non-leaf", "Disable frame pointer elimination for non-leaf frame"), - clEnumValN(FramePointer::None, "none", + clEnumValN(FramePointerKind::None, "none", "Enable frame pointer elimination"))); CGBINDOPT(FramePointerUsage); @@ -662,11 +662,11 @@ void codegen::setFunctionAttributes(StringRef CPU, StringRef Features, } if (FramePointerUsageView->getNumOccurrences() > 0 && !F.hasFnAttribute("frame-pointer")) { - if (getFramePointerUsage() == FramePointer::All) + if (getFramePointerUsage() == FramePointerKind::All) NewAttrs.addAttribute("frame-pointer", "all"); - else if (getFramePointerUsage() == FramePointer::NonLeaf) + else if (getFramePointerUsage() == FramePointerKind::NonLeaf) NewAttrs.addAttribute("frame-pointer", "non-leaf"); - else if (getFramePointerUsage() == FramePointer::None) + else if (getFramePointerUsage() == FramePointerKind::None) NewAttrs.addAttribute("frame-pointer", "none"); } if (DisableTailCallsView->getNumOccurrences() > 0) |