]> granicus.if.org Git - clang/commitdiff
Emit the 'alignstack' LLVM function attribute when we encounter a function
authorCharles Davis <cdavis@mines.edu>
Sat, 13 Feb 2010 15:54:06 +0000 (15:54 +0000)
committerCharles Davis <cdavis@mines.edu>
Sat, 13 Feb 2010 15:54:06 +0000 (15:54 +0000)
marked 'force_align_arg_pointer'. Almost there; now all I need to do is finish
up the backend.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96100 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGen/function-attributes.c

index 6f650fc2ef70db6af1f548a952c6b45dec2f4d28..a3d76c660af096ba57bac65f5062036c06d4b44d 100644 (file)
@@ -325,6 +325,9 @@ class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   X86_32TargetCodeGenInfo(ASTContext &Context, bool d, bool p)
     :TargetCodeGenInfo(new X86_32ABIInfo(Context, d, p)) {}
+
+  void SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+                           CodeGen::CodeGenModule &CGM) const;
 };
 
 }
@@ -551,6 +554,20 @@ llvm::Value *X86_32ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
   return AddrTyped;
 }
 
+void X86_32TargetCodeGenInfo::SetTargetAttributes(const Decl *D,
+                                                  llvm::GlobalValue *GV,
+                                            CodeGen::CodeGenModule &CGM) const {
+  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+    if (FD->hasAttr<X86ForceAlignArgPointerAttr>()) {
+      // Get the LLVM function.
+      llvm::Function *Fn = cast<llvm::Function>(GV);
+
+      // Now add the 'alignstack' attribute with a value of 16.
+      Fn->addFnAttr(llvm::Attribute::constructStackAlignmentFromInt(16));
+    }
+  }
+}
+
 namespace {
 /// X86_64ABIInfo - The X86_64 ABI information.
 class X86_64ABIInfo : public ABIInfo {
index 8ddaa28eed03db2a9fc5f694581d99862bb2cf69..3a1030a61b903c79cd53f745c4e4459bc49926bb 100644 (file)
@@ -81,3 +81,11 @@ void f14(int a) {
 // CHECK: {
 void f15(void) {
 }
+
+// PR5254
+// CHECK: define void @f16
+// CHECK: alignstack(16)
+// CHECK: {
+void __attribute__((force_align_arg_pointer)) f16(void) {
+}
+