Index: include/llvm/IR/LLVMContext.h =================================================================== --- include/llvm/IR/LLVMContext.h +++ include/llvm/IR/LLVMContext.h @@ -32,6 +32,7 @@ template class SmallVectorImpl; class Function; class DebugLoc; +class OptionStore; /// This is an important class for using LLVM in a threaded context. It /// (opaquely) owns and manages the core "global" data of LLVM's core @@ -167,13 +168,8 @@ void emitError(const Instruction *I, const Twine &ErrorStr); void emitError(const Twine &ErrorStr); - /// \brief Query for a debug option's value. - /// - /// This function returns typed data populated from command line parsing. - template - ValT getOption() const { - return OptionRegistry::instance().template get(); - } + /// \brief Query for a debug option storage object. + OptionStore& getOptionStore(); private: LLVMContext(LLVMContext&) LLVM_DELETED_FUNCTION; Index: include/llvm/Support/OptionStore.h =================================================================== --- /dev/null +++ include/llvm/Support/OptionStore.h @@ -0,0 +1,45 @@ +//===- llvm/Support/OptionStore.h - Debug options support -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// \file +/// This file declares the OptionStore class used for storing parsed option data +/// for debug options registered with the new debug option API. For more +/// information on the new API see llvm/Support/Options.h +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OPTION_OPTIONSTORE_H +#define LLVM_OPTION_OPTIONSTORE_H + +#include "llvm/Support/Options.h" + +namespace llvm { + + +/// \brief This is a stub class for accessing debug options +/// +/// The OptionStore is populated by parsing command line options and reading +/// the default values of non-specified options. This abstraction is required +/// because libSupport can't store data directly into LLVMContext objects. The +/// current implementation in this file is just a stub to prototype the client +/// visible API. +class OptionStore { + +public: + /// \brief Query for a debug option's value. + /// + /// This function returns typed data populated from command line parsing. + template + ValT getOption() const { + return OptionRegistry::instance().template get(); + } +}; + +} // namespace llvm + +#endif Index: lib/IR/LLVMContext.cpp =================================================================== --- lib/IR/LLVMContext.cpp +++ lib/IR/LLVMContext.cpp @@ -266,3 +266,7 @@ E = pImpl->CustomMDKindNames.end(); I != E; ++I) Names[I->second] = I->first(); } + +OptionStore& LLVMContext::getOptionStore() { + return pImpl->OptionData; +} Index: lib/IR/LLVMContextImpl.h =================================================================== --- lib/IR/LLVMContextImpl.h +++ lib/IR/LLVMContextImpl.h @@ -31,6 +31,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Metadata.h" #include "llvm/IR/ValueHandle.h" +#include "llvm/Support/OptionStore.h" #include namespace llvm { @@ -373,6 +374,10 @@ typedef DenseMap PrefixDataMapTy; PrefixDataMapTy PrefixDataMap; + /// \brief OptionStore object that maintains a local copy of typed debug + /// option values. + OptionStore OptionData; + int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx); int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx); Index: lib/Transforms/Scalar/Scalarizer.cpp =================================================================== --- lib/Transforms/Scalar/Scalarizer.cpp +++ lib/Transforms/Scalar/Scalarizer.cpp @@ -18,7 +18,7 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InstVisitor.h" #include "llvm/Pass.h" -#include "llvm/Support/CommandLine.h" +#include "llvm/Support/OptionStore.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -243,7 +243,9 @@ ParallelLoopAccessMDKind = M.getContext().getMDKindID("llvm.mem.parallel_loop_access"); ScalarizeLoadStore = - M.getContext().getOption(); + M.getContext() + .getOptionStore() + .getOption(); return false; }