Now that clang supports the 'force_align_arg_pointer' attribute and LLVM
supports the corresponding 'alignstack' attribute, it's time to put the
two together. With this patch, clang will emit the 'alignstack'
attribute (with a value of 16) whenever it encounters a function with
the 'force_align_arg_pointer' attribute. Now all that remains is hooking
up the x86 backend to support this.
This is a very simple patch, but I want feedback on it before I put it in.
Chip
Index: test/CodeGen/function-attributes.c
===================================================================
--- test/CodeGen/function-attributes.c (revision 95872)
+++ test/CodeGen/function-attributes.c (working copy)
@@ -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) {
+}
+
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp (revision 95872)
+++ lib/CodeGen/CodeGenFunction.cpp (working copy)
@@ -171,9 +171,9 @@
CurFn = Fn;
assert(CurFn->isDeclaration() && "Function already has body?");
- // Pass inline keyword to optimizer if it appears explicitly on any
- // declaration.
- if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
+ if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
+ // Pass inline keyword to optimizer if it appears explicitly on any
+ // declaration.
for (FunctionDecl::redecl_iterator RI = FD->redecls_begin(),
RE = FD->redecls_end(); RI != RE; ++RI)
if (RI->isInlineSpecified()) {
@@ -181,6 +181,16 @@
break;
}
+ // Pass force_align_arg_pointer to backend if it appears explicitly
+ // on any declaration.
+ for (FunctionDecl::redecl_iterator RI = FD->redecls_begin(),
+ RE = FD->redecls_end(); RI != RE; ++RI)
+ if (RI->hasAttr<X86ForceAlignArgPointerAttr>()) {
+ Fn->addFnAttr(llvm::Attribute::constructStackAlignmentFromInt(16));
+ break;
+ }
+ }
+
llvm::BasicBlock *EntryBB = createBasicBlock("entry", CurFn);
// Create a marker to make it easy to insert allocas into the entryblock
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits