diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-04 21:19:06 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-04 21:19:06 +0000 |
commit | 1e8052b36d17af63d669d41a1a5893f255a1f370 (patch) | |
tree | 9bb42aeb8a1194db73ad70699767bfe5d2807e08 | |
parent | a45bdbbb6abcd3c8c16288de5110d9605b7b9c05 (diff) | |
download | bcm5719-llvm-1e8052b36d17af63d669d41a1a5893f255a1f370.tar.gz bcm5719-llvm-1e8052b36d17af63d669d41a1a5893f255a1f370.zip |
Add -femit-all-decls codegen option.
- 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).
llvm-svn: 63776
-rw-r--r-- | clang/Driver/clang.cpp | 6 | ||||
-rw-r--r-- | clang/include/clang/Basic/LangOptions.h | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index c6fee1f09e5..bf885ea464f 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -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> diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index b615412f20b..b85a74bc4ab 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -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; } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 18870722fa2..af70a9c8464 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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; } |