summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Doffman <mark.doffman@codethink.co.uk>2015-03-10 15:10:19 +0000
committerMark Doffman <mark.doffman@codethink.co.uk>2015-03-10 15:10:19 +0000
commiteba409b689358f1f03ab47aa7b82d47893ee4ad0 (patch)
treec0c70ec6a22195eafadc09f0d001621e7c782e68
parent8dbfe1d20de28d538db690dbfac359651c56788c (diff)
parent2d993f4c126517c037c671df71bf0d65fb92be8b (diff)
downloadflang-eba409b689358f1f03ab47aa7b82d47893ee4ad0.tar.gz
Merge 3.6 update.
-rw-r--r--include/flang/Basic/Diagnostic.h2
-rw-r--r--include/flang/Basic/IdentifierTable.h32
-rw-r--r--include/flang/Frontend/ASTUnit.h4
-rw-r--r--include/flang/Frontend/CompilerInstance.h4
-rw-r--r--include/flang/Frontend/VerifyDiagnosticConsumer.h4
-rw-r--r--lib/CodeGen/BackendUtil.cpp52
-rw-r--r--lib/CodeGen/CodeGenAction.cpp28
-rw-r--r--lib/CodeGen/CodeGenFunction.h4
-rw-r--r--lib/CodeGen/CodeGenModule.h4
-rw-r--r--lib/Sema/SemaEquivalence.cpp2
-rw-r--r--tools/driver/Main.cpp4
11 files changed, 78 insertions, 62 deletions
diff --git a/include/flang/Basic/Diagnostic.h b/include/flang/Basic/Diagnostic.h
index a16c55bc48..597fc0784b 100644
--- a/include/flang/Basic/Diagnostic.h
+++ b/include/flang/Basic/Diagnostic.h
@@ -471,7 +471,7 @@ class DiagnosticBuilder {
/// call to ForceEmit.
mutable bool IsForceEmit;
- void operator=(const DiagnosticBuilder &) LLVM_DELETED_FUNCTION;
+ void operator=(const DiagnosticBuilder &) = delete;
friend class DiagnosticsEngine;
DiagnosticBuilder()
diff --git a/include/flang/Basic/IdentifierTable.h b/include/flang/Basic/IdentifierTable.h
index 64a61c8d00..8077b3e542 100644
--- a/include/flang/Basic/IdentifierTable.h
+++ b/include/flang/Basic/IdentifierTable.h
@@ -121,6 +121,7 @@ class IdentifierTable {
// Shark shows that using MallocAllocator is *much* slower than using this
// BumpPtrAllocator!
typedef llvm::StringMap<IdentifierInfo*, llvm::BumpPtrAllocator> HashTableTy;
+ typedef std::pair<llvm::StringRef, IdentifierInfo*> HashTableEntryTy;
HashTableTy IdentifierHashTable;
HashTableTy KeywordHashTable;
HashTableTy FormatSpecHashTable;
@@ -171,10 +172,7 @@ public:
for (size_t I = 0, E = UCName.size(); I != E; ++I)
UCName[I] = ::tolower(UCName[I]);
- llvm::StringMapEntry<IdentifierInfo*> &Entry =
- IdentifierHashTable.GetOrCreateValue(UCName);
-
- IdentifierInfo *II = Entry.getValue();
+ IdentifierInfo *II = IdentifierHashTable.lookup(UCName);
if (II) return *II;
// No entry; if we have an external lookup, look there first.
@@ -182,7 +180,7 @@ public:
II = ExternalLookup->get(UCName);
if (II) {
// Cache in the StringMap for subsequent lookups.
- Entry.setValue(II);
+ IdentifierHashTable.insert(HashTableEntryTy(UCName, II));
return *II;
}
}
@@ -190,7 +188,7 @@ public:
// Lookups failed, make a new IdentifierInfo.
void *Mem = IdentifierHashTable.getAllocator().Allocate<IdentifierInfo>();
II = new (Mem) IdentifierInfo();
- Entry.setValue(II);
+ auto &Entry = *IdentifierHashTable.insert(HashTableEntryTy(UCName, II)).first;
// Make sure getName() knows how to find the IdentifierInfo
// contents.
@@ -204,10 +202,8 @@ public:
for (size_t I = 0, E = UCName.size(); I != E; ++I)
UCName[I] = ::tolower(UCName[I]);
- llvm::StringMapEntry<IdentifierInfo*> &Entry =
- KeywordHashTable.GetOrCreateValue(UCName);
+ IdentifierInfo *II = KeywordHashTable.lookup(UCName);
- IdentifierInfo *II = Entry.getValue();
if (II) return *II;
// No entry; if we have an external lookup, look there first.
@@ -215,7 +211,7 @@ public:
II = ExternalLookup->get(UCName);
if (II) {
// Cache in the StringMap for subsequent lookups.
- Entry.setValue(II);
+ KeywordHashTable.insert(HashTableEntryTy(UCName, II));
return *II;
}
}
@@ -224,7 +220,7 @@ public:
void *Mem = KeywordHashTable.getAllocator().Allocate<IdentifierInfo>();
II = new (Mem) IdentifierInfo();
II->setTokenID(TokenCode);
- Entry.setValue(II);
+ auto &Entry = *KeywordHashTable.insert(HashTableEntryTy(UCName, II)).first;
// Make sure getName() knows how to find the IdentifierInfo
// contents.
@@ -238,10 +234,8 @@ public:
for (size_t I = 0, E = UCName.size(); I != E; ++I)
UCName[I] = ::tolower(UCName[I]);
- llvm::StringMapEntry<IdentifierInfo*> &Entry =
- FormatSpecHashTable.GetOrCreateValue(UCName);
+ IdentifierInfo *II = FormatSpecHashTable.lookup(UCName);
- IdentifierInfo *II = Entry.getValue();
if (II) return *II;
// No entry; if we have an external lookup, look there first.
@@ -249,7 +243,7 @@ public:
II = ExternalLookup->get(UCName);
if (II) {
// Cache in the StringMap for subsequent lookups.
- Entry.setValue(II);
+ FormatSpecHashTable.insert(HashTableEntryTy(UCName, II));
return *II;
}
}
@@ -258,7 +252,7 @@ public:
void *Mem = FormatSpecHashTable.getAllocator().Allocate<IdentifierInfo>();
II = new (Mem) IdentifierInfo();
II->setTokenID(TokenCode);
- Entry.setValue(II);
+ auto &Entry = *FormatSpecHashTable.insert(HashTableEntryTy(UCName, II)).first;
// Make sure getName() knows how to find the IdentifierInfo
// contents.
@@ -319,16 +313,14 @@ public:
/// routine to build IdentifierInfo nodes and then introduce additional
/// information about those identifiers.
IdentifierInfo &CreateIdentifierInfo(llvm::StringRef Name) {
- llvm::StringMapEntry<IdentifierInfo*> &Entry =
- IdentifierHashTable.GetOrCreateValue(Name);
+ IdentifierInfo *II = IdentifierHashTable.lookup(Name);
- IdentifierInfo *II = Entry.getValue();
assert(!II && "IdentifierInfo already exists");
// Lookups failed, make a new IdentifierInfo.
void *Mem = IdentifierHashTable.getAllocator().Allocate<IdentifierInfo>();
II = new (Mem) IdentifierInfo();
- Entry.setValue(II);
+ auto &Entry = *IdentifierHashTable.insert(HashTableEntryTy(Name, II)).first;
// Make sure getName() knows how to find the IdentifierInfo
// contents.
diff --git a/include/flang/Frontend/ASTUnit.h b/include/flang/Frontend/ASTUnit.h
index 31ab83d522..c3e535324c 100644
--- a/include/flang/Frontend/ASTUnit.h
+++ b/include/flang/Frontend/ASTUnit.h
@@ -80,8 +80,8 @@ private:
/// \brief The language options used when we load an AST file.
LangOptions ASTFileLangOpts;
- ASTUnit(const ASTUnit &) LLVM_DELETED_FUNCTION;
- void operator=(const ASTUnit &) LLVM_DELETED_FUNCTION;
+ ASTUnit(const ASTUnit &) = delete;
+ void operator=(const ASTUnit &) = delete;
explicit ASTUnit(bool MainFileIsAST);
diff --git a/include/flang/Frontend/CompilerInstance.h b/include/flang/Frontend/CompilerInstance.h
index 948e8b336e..040c6416f2 100644
--- a/include/flang/Frontend/CompilerInstance.h
+++ b/include/flang/Frontend/CompilerInstance.h
@@ -127,8 +127,8 @@ class CompilerInstance {
/// The list of active output files.
std::list<OutputFile> OutputFiles;
- CompilerInstance(const CompilerInstance &) LLVM_DELETED_FUNCTION;
- void operator=(const CompilerInstance &) LLVM_DELETED_FUNCTION;
+ CompilerInstance(const CompilerInstance &) = delete;
+ void operator=(const CompilerInstance &) = delete;
public:
CompilerInstance();
~CompilerInstance();
diff --git a/include/flang/Frontend/VerifyDiagnosticConsumer.h b/include/flang/Frontend/VerifyDiagnosticConsumer.h
index ec062870d2..32d0cef416 100644
--- a/include/flang/Frontend/VerifyDiagnosticConsumer.h
+++ b/include/flang/Frontend/VerifyDiagnosticConsumer.h
@@ -171,8 +171,8 @@ public:
}
private:
- Directive(const Directive &) LLVM_DELETED_FUNCTION;
- void operator=(const Directive &) LLVM_DELETED_FUNCTION;
+ Directive(const Directive &) = delete;
+ void operator=(const Directive &) = delete;
};
typedef std::vector<Directive*> DirectiveList;
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp
index 37569cf43e..3e1bde2f36 100644
--- a/lib/CodeGen/BackendUtil.cpp
+++ b/lib/CodeGen/BackendUtil.cpp
@@ -15,6 +15,8 @@
#include "flang/Frontend/FrontendDiagnostic.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/CodeGen/RegAllocRegistry.h"
#include "llvm/CodeGen/SchedulerRegistry.h"
@@ -29,7 +31,6 @@
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO.h"
@@ -56,32 +57,39 @@ class EmitAssemblyHelper {
mutable FunctionPassManager *PerFunctionPasses;
private:
+ TargetIRAnalysis getTargetIRAnalysis() const {
+ if (TM)
+ return TM->getTargetIRAnalysis();
+
+ return TargetIRAnalysis();
+ }
+
PassManager *getCodeGenPasses() const {
if (!CodeGenPasses) {
- CodeGenPasses = new PassManager();
+ CodeGenPasses = new legacy::PassManager();
CodeGenPasses->add(new DataLayoutPass());
- if (TM)
- TM->addAnalysisPasses(*CodeGenPasses);
+ CodeGenPasses->add(
+ createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
}
return CodeGenPasses;
}
PassManager *getPerModulePasses() const {
if (!PerModulePasses) {
- PerModulePasses = new PassManager();
+ PerModulePasses = new legacy::PassManager();
PerModulePasses->add(new DataLayoutPass());
- if (TM)
- TM->addAnalysisPasses(*PerModulePasses);
+ PerModulePasses->add(
+ createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
}
return PerModulePasses;
}
FunctionPassManager *getPerFunctionPasses() const {
if (!PerFunctionPasses) {
- PerFunctionPasses = new FunctionPassManager(TheModule);
+ PerFunctionPasses = new legacy::FunctionPassManager(TheModule);
PerFunctionPasses->add(new DataLayoutPass());
- if (TM)
- TM->addAnalysisPasses(*PerFunctionPasses);
+ PerFunctionPasses->add(
+ createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
}
return PerFunctionPasses;
}
@@ -146,6 +154,14 @@ static void addBoundsCheckingPass(const PassManagerBuilder &Builder,
PM.add(createBoundsCheckingPass());
}
+static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
+ const CodeGenOptions &CodeGenOpts) {
+ TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
+ if (!CodeGenOpts.SimplifyLibCalls)
+ TLII->disableAllFunctions();
+ return TLII;
+}
+
void EmitAssemblyHelper::CreatePasses() {
unsigned OptLevel = CodeGenOpts.OptimizationLevel;
CodeGenOptions::InliningMethod Inlining = CodeGenOpts.getInlining();
@@ -169,10 +185,8 @@ void EmitAssemblyHelper::CreatePasses() {
// Figure out TargetLibraryInfo.
Triple TargetTriple(TheModule->getTargetTriple());
- PMBuilder.LibraryInfo = new TargetLibraryInfo(TargetTriple);
- if (!CodeGenOpts.SimplifyLibCalls)
- PMBuilder.LibraryInfo->disableAllFunctions();
-
+ PMBuilder.LibraryInfo = createTLII(TargetTriple, CodeGenOpts);
+
switch (Inlining) {
case CodeGenOptions::NoInlining: break;
case CodeGenOptions::NormalInlining: {
@@ -388,13 +402,9 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
// Add LibraryInfo.
llvm::Triple TargetTriple(TheModule->getTargetTriple());
- TargetLibraryInfo *TLI = new TargetLibraryInfo(TargetTriple);
- if (!CodeGenOpts.SimplifyLibCalls)
- TLI->disableAllFunctions();
- PM->add(TLI);
-
- // Add Target specific analysis passes.
- TM->addAnalysisPasses(*PM);
+ std::unique_ptr<TargetLibraryInfoImpl> TLII(
+ createTLII(TargetTriple, CodeGenOpts));
+ PM->add(new TargetLibraryInfoWrapperPass(*TLII));
// Normal mode, emit a .s or .o file by running the code generator. Note,
// this also adds codegenerator level optimization passes.
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index 53ee5aafd3..79aaf1df86 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Module.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Linker/Linker.h"
@@ -119,20 +120,18 @@ namespace flang {
// Link LinkModule into this module if present, preserving its validity.
if (LinkModule) {
- std::string ErrorMsg;
- if (Linker::LinkModules(M, LinkModule.get(), Linker::PreserveSource,
- &ErrorMsg)) {
- Diags.Report(diag::err_fe_cannot_link_module)
- << LinkModule->getModuleIdentifier() << ErrorMsg;
+ if (Linker::LinkModules(
+ M, LinkModule.get(),
+ [=](const DiagnosticInfo &DI) { linkerDiagnosticHandler(DI); }))
return;
- }
}
EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
TheModule.get(), Action, AsmOutStream);
-
}
+ void linkerDiagnosticHandler(const llvm::DiagnosticInfo &DI);
+
};
void BackendConsumer::anchor() {}
@@ -151,6 +150,21 @@ CodeGenAction::~CodeGenAction() {
delete VMContext;
}
+void BackendConsumer::linkerDiagnosticHandler(const DiagnosticInfo &DI) {
+ if (DI.getSeverity() != DS_Error)
+ return;
+
+ std::string MsgStorage;
+ {
+ raw_string_ostream Stream(MsgStorage);
+ DiagnosticPrinterRawOStream DP(Stream);
+ DI.print(DP);
+ }
+
+ Diags.Report(diag::err_fe_cannot_link_module)
+ << LinkModule->getModuleIdentifier() << MsgStorage;
+}
+
bool CodeGenAction::hasIRSupport() const { return true; }
void CodeGenAction::EndSourceFileAction() {
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 3326cc2b4d..4353d4fd43 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -52,8 +52,8 @@ namespace CodeGen {
/// CodeGenFunction - This class organizes the per-function state that is used
/// while generating LLVM code.
class CodeGenFunction {
- CodeGenFunction(const CodeGenFunction &) LLVM_DELETED_FUNCTION;
- void operator=(const CodeGenFunction &) LLVM_DELETED_FUNCTION;
+ CodeGenFunction(const CodeGenFunction &) = delete;
+ void operator=(const CodeGenFunction &) = delete;
CodeGenModule &CGM; // Per-module state.
//const TargetInfo &Target;
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index abafbfaa07..6fce9bed5c 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -107,8 +107,8 @@ struct CodeGenTypeCache {
/// CodeGenModule - This class organizes the cross-function state that is used
/// while generating LLVM code.
class CodeGenModule : public CodeGenTypeCache {
- CodeGenModule(const CodeGenModule &) LLVM_DELETED_FUNCTION;
- void operator=(const CodeGenModule &) LLVM_DELETED_FUNCTION;
+ CodeGenModule(const CodeGenModule &) = delete;
+ void operator=(const CodeGenModule &) = delete;
ASTContext &Context;
const LangOptions &LangOpts;
diff --git a/lib/Sema/SemaEquivalence.cpp b/lib/Sema/SemaEquivalence.cpp
index 07d2a2fe91..a1cd6f9d98 100644
--- a/lib/Sema/SemaEquivalence.cpp
+++ b/lib/Sema/SemaEquivalence.cpp
@@ -93,7 +93,7 @@ bool SetCreator::CreateSet(ASTContext &C) {
FindConnections(Obj);
llvm::SmallPtrSet<VarDecl*, 16> ProcessedObjects;
for(auto I : Result) {
- if(ProcessedObjects.insert(I.Obj->Var))
+ if(ProcessedObjects.insert(I.Obj->Var).second)
Objects.push_back(EquivalenceSet::Object(I.Obj->Var, I.E));
}
diff --git a/tools/driver/Main.cpp b/tools/driver/Main.cpp
index 5031daf2cc..ac74ca55db 100644
--- a/tools/driver/Main.cpp
+++ b/tools/driver/Main.cpp
@@ -239,7 +239,7 @@ static bool EmitFile(llvm::raw_ostream &Out,
PassManager PM;
- Target.setAsmVerbosityDefault(true);
+ //Target.setAsmVerbosityDefault(true);
//Target.setMCRelaxAll(true);
llvm::formatted_raw_ostream FOS(Out);
@@ -384,7 +384,7 @@ static bool ParseFile(const std::string &Filename,
auto TheModule = CG->GetModule();
auto PM = new PassManager();
PM->add(new DataLayoutPass());
- TM->addAnalysisPasses(*PM);
+ //TM->addAnalysisPasses(*PM);
PM->add(createPromoteMemoryToRegisterPass());
PassManagerBuilder PMBuilder;