summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-08-30 21:17:40 +0000
committerErich Keane <erich.keane@intel.com>2017-08-30 21:17:40 +0000
commitbb9c704784dc0920e185e72090cef18cbe73e8cd (patch)
treecd5593d9c3b64f67c6cb531cb4a0062f14e38a6d /clang/lib/CodeGen/TargetInfo.cpp
parent4f44bf7f212205327b72849400d3ed9a8bae11d2 (diff)
downloadbcm5719-llvm-bb9c704784dc0920e185e72090cef18cbe73e8cd.tar.gz
bcm5719-llvm-bb9c704784dc0920e185e72090cef18cbe73e8cd.zip
[CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64
This attribute is useful in OS development when we jump from 32 to 64 bit code and expect that 64bit function forces correct stack alignment. Related discussion: http://lists.llvm.org/pipermail/cfe-dev/2017-June/054358.html Patch By: anatol.pomozov (anatol.pomozov@gmail.com) Differential Revision:https://reviews.llvm.org/D36272 llvm-svn: 312173
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 77b9b4caab5..10fa2ea322c 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -2297,6 +2297,15 @@ public:
if (!IsForDefinition)
return;
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
+ if (FD->hasAttr<X86ForceAlignArgPointerAttr>()) {
+ // Get the LLVM function.
+ auto *Fn = cast<llvm::Function>(GV);
+
+ // Now add the 'alignstack' attribute with a value of 16.
+ llvm::AttrBuilder B;
+ B.addStackAlignmentAttr(16);
+ Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+ }
if (FD->hasAttr<AnyX86InterruptAttr>()) {
llvm::Function *Fn = cast<llvm::Function>(GV);
Fn->setCallingConv(llvm::CallingConv::X86_INTR);
@@ -2425,6 +2434,15 @@ void WinX86_64TargetCodeGenInfo::setTargetAttributes(
if (!IsForDefinition)
return;
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
+ if (FD->hasAttr<X86ForceAlignArgPointerAttr>()) {
+ // Get the LLVM function.
+ auto *Fn = cast<llvm::Function>(GV);
+
+ // Now add the 'alignstack' attribute with a value of 16.
+ llvm::AttrBuilder B;
+ B.addStackAlignmentAttr(16);
+ Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+ }
if (FD->hasAttr<AnyX86InterruptAttr>()) {
llvm::Function *Fn = cast<llvm::Function>(GV);
Fn->setCallingConv(llvm::CallingConv::X86_INTR);
OpenPOWER on IntegriCloud