Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -2041,7 +2041,7 @@ let Documentation = [AnyX86NoCallerSavedRegistersDocs]; } -def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr { +def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr { let Spellings = [GNU<"force_align_arg_pointer">]; // Technically, this appertains to a FunctionDecl, but the target-specific // code silently allows anything function-like (such as typedefs or function Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -2279,6 +2279,15 @@ if (!IsForDefinition) return; if (const FunctionDecl *FD = dyn_cast_or_null(D)) { + if (FD->hasAttr()) { + // Get the LLVM function. + llvm::Function *Fn = cast(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()) { llvm::Function *Fn = cast(GV); Fn->setCallingConv(llvm::CallingConv::X86_INTR); @@ -2407,6 +2416,15 @@ if (!IsForDefinition) return; if (const FunctionDecl *FD = dyn_cast_or_null(D)) { + if (FD->hasAttr()) { + // Get the LLVM function. + llvm::Function *Fn = cast(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()) { llvm::Function *Fn = cast(GV); Fn->setCallingConv(llvm::CallingConv::X86_INTR); Index: test/CodeGen/function-attributes.c =================================================================== --- test/CodeGen/function-attributes.c +++ test/CodeGen/function-attributes.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -disable-llvm-passes -Os -o - %s | FileCheck %s // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s // CHECK: define signext i8 @f0(i32 %x) [[NUW:#[0-9]+]] // CHECK: define zeroext i8 @f1(i32 %x) [[NUW]] // CHECK: define void @f2(i8 signext %x) [[NUW]]