[cfe-commits] r64411 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGen/attributes.c

Daniel Dunbar daniel at zuster.org
Thu Feb 12 15:32:54 PST 2009


Author: ddunbar
Date: Thu Feb 12 17:32:54 2009
New Revision: 64411

URL: http://llvm.org/viewvc/llvm-project?rev=64411&view=rev
Log:
Honor attribute section on static block var decls.

Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/test/CodeGen/attributes.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=64411&r1=64410&r2=64411&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Thu Feb 12 17:32:54 2009
@@ -126,6 +126,7 @@
   GV = GenerateStaticBlockVarDecl(D, false, ".",
                                   llvm::GlobalValue::InternalLinkage);
 
+  // FIXME: Merge attribute handling.
   if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) {
     SourceManager &SM = CGM.getContext().getSourceManager();
     llvm::Constant *Ann =
@@ -134,6 +135,9 @@
     CGM.AddAnnotation(Ann);
   }
 
+  if (const SectionAttr *SA = D.getAttr<SectionAttr>())
+    GV->setSection(SA->getName());
+  
   const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(D.getType());
   const llvm::Type *LPtrTy =
     llvm::PointerType::get(LTy, D.getType().getAddressSpace());

Modified: cfe/trunk/test/CodeGen/attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attributes.c?rev=64411&r1=64410&r2=64411&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/attributes.c (original)
+++ cfe/trunk/test/CodeGen/attributes.c Thu Feb 12 17:32:54 2009
@@ -11,7 +11,8 @@
 // RUN: grep '@t10().*section "SECT"' %t &&
 // RUN: grep '@t11().*section "SECT"' %t &&
 // RUN: grep '@t12 =.*section "SECT"' %t &&
-// RUN: grep '@t13 =.*section "SECT"' %t
+// RUN: grep '@t13 =.*section "SECT"' %t &&
+// RUN: grep '@t14.x =.*section "SECT"' %t
 
 void t1() __attribute__((noreturn));
 void t1() {}
@@ -41,4 +42,8 @@
 
 int t12 __attribute__((section("SECT")));
 struct s0 { int x; };
-struct s0 t13 __attribute__ ((section ("SECT"))) = { 0 };
+struct s0 t13 __attribute__((section("SECT"))) = { 0 };
+
+void t14(void) {
+  static int x __attribute__((section("SECT"))) = 0;
+}





More information about the cfe-commits mailing list