X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FLLVMContextImpl.cpp;h=6513965ae7ad88da2eead12b348685b98a3f4bc4;hb=7ce4ac12fc5b0522c5adae6abdd0d8bb552f6ef1;hp=d34f5b484105b8764bb73294466e787dbebe4e58;hpb=35d647b6f371265519df465ad1e7b28de7515185;p=oota-llvm.git diff --git a/lib/IR/LLVMContextImpl.cpp b/lib/IR/LLVMContextImpl.cpp index d34f5b48410..6513965ae7a 100644 --- a/lib/IR/LLVMContextImpl.cpp +++ b/lib/IR/LLVMContextImpl.cpp @@ -14,14 +14,13 @@ #include "LLVMContextImpl.h" #include "llvm/ADT/STLExtras.h" #include "llvm/IR/Attributes.h" +#include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/Module.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/Regex.h" #include using namespace llvm; LLVMContextImpl::LLVMContextImpl(LLVMContext &C) - : TheTrueVal(0), TheFalseVal(0), + : TheTrueVal(nullptr), TheFalseVal(nullptr), VoidTy(C, Type::VoidTyID), LabelTy(C, Type::LabelTyID), HalfTy(C, Type::HalfTyID), @@ -37,72 +36,20 @@ LLVMContextImpl::LLVMContextImpl(LLVMContext &C) Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64) { - InlineAsmDiagHandler = 0; - InlineAsmDiagContext = 0; - DiagnosticHandler = 0; - DiagnosticContext = 0; + InlineAsmDiagHandler = nullptr; + InlineAsmDiagContext = nullptr; + DiagnosticHandler = nullptr; + DiagnosticContext = nullptr; + YieldCallback = nullptr; + YieldOpaqueHandle = nullptr; NamedStructTypesUniqueID = 0; } -namespace { - -/// \brief Regular expression corresponding to the value given in the -/// command line flag -pass-remarks. Passes whose name matches this -/// regexp will emit a diagnostic when calling -/// LLVMContext::emitOptimizationRemark. -static Regex *OptimizationRemarkPattern = 0; - -/// \brief String to hold all the values passed via -pass-remarks. Every -/// instance of -pass-remarks on the command line will be concatenated -/// to this string. Values are stored inside braces and concatenated with -/// the '|' operator. This implements the expected semantics that multiple -/// -pass-remarks are additive. -static std::string OptimizationRemarkExpr; - -struct PassRemarksOpt { - void operator=(const std::string &Val) const { - // Create a regexp object to match pass names for emitOptimizationRemark. - if (!Val.empty()) { - if (!OptimizationRemarkExpr.empty()) - OptimizationRemarkExpr += "|"; - OptimizationRemarkExpr += "(" + Val + ")"; - delete OptimizationRemarkPattern; - OptimizationRemarkPattern = new Regex(OptimizationRemarkExpr); - std::string RegexError; - if (!OptimizationRemarkPattern->isValid(RegexError)) - report_fatal_error("Invalid regular expression '" + Val + - "' in -pass-remarks: " + RegexError, - false); - } - }; -}; - -static PassRemarksOpt PassRemarksOptLoc; - -// -pass-remarks -// Command line flag to enable LLVMContext::emitOptimizationRemark() -// and LLVMContext::emitOptimizationNote() calls. -static cl::opt> -PassRemarks("pass-remarks", cl::value_desc("pattern"), - cl::desc("Enable optimization remarks from passes whose name match " - "the given regular expression"), - cl::Hidden, cl::location(PassRemarksOptLoc), cl::ValueRequired, - cl::ZeroOrMore); -} - -bool -LLVMContextImpl::optimizationRemarksEnabledFor(const char *PassName) const { - return OptimizationRemarkPattern && - OptimizationRemarkPattern->match(PassName); -} - - namespace { struct DropReferences { // Takes the value_type of a ConstantUniqueMap's internal map, whose 'second' // is a Constant*. - template - void operator()(const PairT &P) { + template void operator()(const PairT &P) { P.second->dropAllReferences(); } }; @@ -119,17 +66,16 @@ struct DropFirst { } LLVMContextImpl::~LLVMContextImpl() { - // NOTE: We need to delete the contents of OwnedModules, but we have to - // duplicate it into a temporary vector, because the destructor of Module - // will try to remove itself from OwnedModules set. This would cause - // iterator invalidation if we iterated on the set directly. - std::vector Modules(OwnedModules.begin(), OwnedModules.end()); - DeleteContainerPointers(Modules); + // NOTE: We need to delete the contents of OwnedModules, but Module's dtor + // will call LLVMContextImpl::removeModule, thus invalidating iterators into + // the container. Avoid iterators during this operation: + while (!OwnedModules.empty()) + delete *OwnedModules.begin(); // Free the constants. This is important to do here to ensure that they are // freed before the LeakDetector is torn down. std::for_each(ExprConstants.map_begin(), ExprConstants.map_end(), - DropReferences()); + DropFirst()); std::for_each(ArrayConstants.map_begin(), ArrayConstants.map_end(), DropFirst()); std::for_each(StructConstants.map_begin(), StructConstants.map_end(),