Index: cfe/trunk/include/clang/Basic/Attr.td =================================================================== --- cfe/trunk/include/clang/Basic/Attr.td +++ cfe/trunk/include/clang/Basic/Attr.td @@ -2042,7 +2042,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: cfe/trunk/lib/CodeGen/TargetInfo.cpp =================================================================== --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -2297,6 +2297,15 @@ if (!IsForDefinition) return; if (const FunctionDecl *FD = dyn_cast_or_null(D)) { + if (FD->hasAttr()) { + // Get the LLVM function. + auto *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); @@ -2425,6 +2434,15 @@ if (!IsForDefinition) return; if (const FunctionDecl *FD = dyn_cast_or_null(D)) { + if (FD->hasAttr()) { + // Get the LLVM function. + auto *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: cfe/trunk/test/CodeGen/function-attributes.c =================================================================== --- cfe/trunk/test/CodeGen/function-attributes.c +++ cfe/trunk/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]]