[cfe-commits] r96100 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGen/function-attributes.c
Charles Davis
cdavis at mines.edu
Sat Feb 13 07:54:06 PST 2010
Author: cdavis
Date: Sat Feb 13 09:54:06 2010
New Revision: 96100
URL: http://llvm.org/viewvc/llvm-project?rev=96100&view=rev
Log:
Emit the 'alignstack' LLVM function attribute when we encounter a function
marked 'force_align_arg_pointer'. Almost there; now all I need to do is finish
up the backend.
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/function-attributes.c
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=96100&r1=96099&r2=96100&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Sat Feb 13 09:54:06 2010
@@ -325,6 +325,9 @@
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 @@
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 {
Modified: cfe/trunk/test/CodeGen/function-attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-attributes.c?rev=96100&r1=96099&r2=96100&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/function-attributes.c (original)
+++ cfe/trunk/test/CodeGen/function-attributes.c Sat Feb 13 09:54:06 2010
@@ -81,3 +81,11 @@
// CHECK: {
void f15(void) {
}
+
+// PR5254
+// CHECK: define void @f16
+// CHECK: alignstack(16)
+// CHECK: {
+void __attribute__((force_align_arg_pointer)) f16(void) {
+}
+
More information about the cfe-commits
mailing list