]> granicus.if.org Git - clang/commitdiff
Add -femit-all-decls codegen option.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 4 Feb 2009 21:19:06 +0000 (21:19 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 4 Feb 2009 21:19:06 +0000 (21:19 +0000)
 - Emits all declarations, even unused (static) ones.
 - Useful when doing minimization of codegen problems (otherwise
   problems localized to a static function aren't minimized well).

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

Driver/clang.cpp
include/clang/Basic/LangOptions.h
lib/CodeGen/CodeGenModule.cpp

index c6fee1f09e5d771e86c388e2d80f769fba59a958..bf885ea464f9cfd8efe0146f9c61ccc9ce925458 100644 (file)
@@ -500,6 +500,9 @@ static llvm::cl::opt<bool>
 ObjCNonFragileABI("fobjc-nonfragile-abi",
                   llvm::cl::desc("enable objective-c's nonfragile abi"));
 
+static llvm::cl::opt<bool>
+EmitAllDecls("femit-all-decls",
+              llvm::cl::desc("Emit all declarations, even if unused"));
 
 // FIXME: This (and all GCC -f options) really come in -f... and
 // -fno-... forms, and additionally support automagic behavior when
@@ -635,6 +638,9 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
 
   if (ObjCNonFragileABI)
     Options.ObjCNonFragileABI = 1;
+
+  if (EmitAllDecls)
+    Options.EmitAllDecls = 1;
 }
 
 static llvm::cl::opt<bool>
index b615412f20b69a61621c57ed8247af2f354712dd..b85a74bc4abb2b84d9cece6dc56f86eef2973022 100644 (file)
@@ -51,6 +51,8 @@ struct LangOptions {
   unsigned ThreadsafeStatics : 1; // Whether static initializers are protected
                                   // by locks.
   unsigned Blocks            : 1; // block extension to C
+  unsigned EmitAllDecls      : 1; // Emit all declarations, even if
+                                  // they are unused.
 private:
   unsigned GC : 2; // Objective-C Garbage Collection modes.  We declare
                    // this enum as unsigned because MSVC insists on making enums
@@ -72,6 +74,7 @@ public:
     // FIXME: The default should be 1.
     ThreadsafeStatics = 0;
     Blocks = 0;
+    EmitAllDecls = 0;
   }
   
   GCMode getGCMode() const { return (GCMode) GC; }
index 18870722fa2821729d98bb7c61184e9069f125d6..af70a9c8464aa768326dd9e1624e19cd29560a83 100644 (file)
@@ -468,7 +468,7 @@ void CodeGenModule::EmitGlobal(const ValueDecl *Global) {
 
   // If the global is a static, defer code generation until later so
   // we can easily omit unused statics.
-  if (isStatic) {
+  if (isStatic && !Features.EmitAllDecls) {
     StaticDecls.push_back(Global);
     return;
   }