[PATCH] Fixing PR21811 by applying attributes to global init function
Yunzhong Gao
Yunzhong_Gao at playstation.sony.com
Wed Apr 22 11:03:14 PDT 2015
Hi,
This patch attempts to fix bug#21811 by attaching the no-frame-pointer-elim-non-leaf
attribute to the compiler-created global init function. It would be helpful if
someone can review this,
- Gao
http://reviews.llvm.org/D9203
Files:
lib/CodeGen/CGDeclCXX.cpp
test/CodeGenCXX/global-init.cpp
Index: lib/CodeGen/CGDeclCXX.cpp
===================================================================
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -272,6 +272,10 @@
if (getLangOpts().Sanitize.has(SanitizerKind::Memory))
Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
}
+
+ if (getCodeGenOpts().DisableFPElim &&
+ getCodeGenOpts().OmitLeafFramePointer)
+ Fn->addFnAttr("no-frame-pointer-elim-non-leaf");
return Fn;
}
Index: test/CodeGenCXX/global-init.cpp
===================================================================
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -1,6 +1,10 @@
// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -fexceptions %s -o - |FileCheck %s
// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck -check-prefix CHECK-NOEXC %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm \
+// RUN: -momit-leaf-frame-pointer -mdisable-fp-elim %s -o - \
+// RUN: | FileCheck -check-prefix CHECK-FP %s
+
struct A {
A();
~A();
@@ -203,3 +207,7 @@
// CHECK-NOEXC: define internal void @_GLOBAL__sub_I_global_init.cpp() [[NUW:#[0-9]+]] section "__TEXT,__StaticInit,regular,pure_instructions" {
// CHECK-NOEXC: attributes [[NUW]] = { nounwind }
+
+// PR21811: attach the appropriate attribute to the global init function
+// CHECK-FP: define internal void @_GLOBAL__sub_I_global_init.cpp() [[NUX:#[0-9]+]] section "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK-FP: attributes [[NUX]] = { nounwind "no-frame-pointer-elim-non-leaf" }
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9203.24245.patch
Type: text/x-patch
Size: 1598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150422/4a6914ae/attachment.bin>
More information about the cfe-commits
mailing list