aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LTO
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2015-04-08 08:55:49 -0700
committerPirama Arumuga Nainar <pirama@google.com>2015-04-09 15:04:38 -0700
commit4c5e43da7792f75567b693105cc53e3f1992ad98 (patch)
tree1b2c9792582e12f5af0b1512e3094425f0dc0df9 /lib/LTO
parentc75239e6119d0f9a74c57099d91cbc9bde56bf33 (diff)
downloadexternal_llvm-4c5e43da7792f75567b693105cc53e3f1992ad98.zip
external_llvm-4c5e43da7792f75567b693105cc53e3f1992ad98.tar.gz
external_llvm-4c5e43da7792f75567b693105cc53e3f1992ad98.tar.bz2
Update aosp/master llvm for rebase to r233350
Change-Id: I07d935f8793ee8ec6b7da003f6483046594bca49
Diffstat (limited to 'lib/LTO')
-rw-r--r--lib/LTO/LTOCodeGenerator.cpp38
-rw-r--r--lib/LTO/LTOModule.cpp5
2 files changed, 26 insertions, 17 deletions
diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp
index 61c2749..a6f980b 100644
--- a/lib/LTO/LTOCodeGenerator.cpp
+++ b/lib/LTO/LTOCodeGenerator.cpp
@@ -71,7 +71,7 @@ LTOCodeGenerator::LTOCodeGenerator()
LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
: OwnedContext(std::move(Context)), Context(*OwnedContext),
- IRLinker(new Module("ld-temp.o", *OwnedContext)) {
+ IRLinker(new Module("ld-temp.o", *OwnedContext)), OptLevel(2) {
initialize();
}
@@ -291,12 +291,11 @@ const void *LTOCodeGenerator::compileOptimized(size_t *length,
bool LTOCodeGenerator::compile_to_file(const char **name,
- bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
bool disableVectorization,
std::string &errMsg) {
- if (!optimize(disableOpt, disableInline, disableGVNLoadPRE,
+ if (!optimize(disableInline, disableGVNLoadPRE,
disableVectorization, errMsg))
return false;
@@ -304,12 +303,11 @@ bool LTOCodeGenerator::compile_to_file(const char **name,
}
const void* LTOCodeGenerator::compile(size_t *length,
- bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
bool disableVectorization,
std::string &errMsg) {
- if (!optimize(disableOpt, disableInline, disableGVNLoadPRE,
+ if (!optimize(disableInline, disableGVNLoadPRE,
disableVectorization, errMsg))
return nullptr;
@@ -363,9 +361,25 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
MCpu = "cyclone";
}
+ CodeGenOpt::Level CGOptLevel;
+ switch (OptLevel) {
+ case 0:
+ CGOptLevel = CodeGenOpt::None;
+ break;
+ case 1:
+ CGOptLevel = CodeGenOpt::Less;
+ break;
+ case 2:
+ CGOptLevel = CodeGenOpt::Default;
+ break;
+ case 3:
+ CGOptLevel = CodeGenOpt::Aggressive;
+ break;
+ }
+
TargetMach = march->createTargetMachine(TripleStr, MCpu, FeatureStr, Options,
RelocModel, CodeModel::Default,
- CodeGenOpt::Aggressive);
+ CGOptLevel);
return true;
}
@@ -457,7 +471,6 @@ void LTOCodeGenerator::applyScopeRestrictions() {
// Start off with a verification pass.
legacy::PassManager passes;
passes.add(createVerifierPass());
- passes.add(createDebugInfoVerifierPass());
// mark which symbols can not be internalized
Mangler Mangler(TargetMach->getDataLayout());
@@ -512,8 +525,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
}
/// Optimize merged modules using various IPO passes
-bool LTOCodeGenerator::optimize(bool DisableOpt,
- bool DisableInline,
+bool LTOCodeGenerator::optimize(bool DisableInline,
bool DisableGVNLoadPRE,
bool DisableVectorization,
std::string &errMsg) {
@@ -529,9 +541,8 @@ bool LTOCodeGenerator::optimize(bool DisableOpt,
legacy::PassManager passes;
// Add an appropriate DataLayout instance for this module...
- mergedModule->setDataLayout(TargetMach->getDataLayout());
+ mergedModule->setDataLayout(*TargetMach->getDataLayout());
- passes.add(new DataLayoutPass());
passes.add(
createTargetTransformInfoWrapperPass(TargetMach->getTargetIRAnalysis()));
@@ -543,8 +554,7 @@ bool LTOCodeGenerator::optimize(bool DisableOpt,
if (!DisableInline)
PMB.Inliner = createFunctionInliningPass();
PMB.LibraryInfo = new TargetLibraryInfoImpl(TargetTriple);
- if (DisableOpt)
- PMB.OptLevel = 0;
+ PMB.OptLevel = OptLevel;
PMB.VerifyInput = true;
PMB.VerifyOutput = true;
@@ -567,8 +577,6 @@ bool LTOCodeGenerator::compileOptimized(raw_ostream &out, std::string &errMsg) {
legacy::PassManager codeGenPasses;
- codeGenPasses.add(new DataLayoutPass());
-
formatted_raw_ostream Out(out);
// If the bitcode files contain ARC code and were compiled with optimization,
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp
index 0d07791..49aa97d 100644
--- a/lib/LTO/LTOModule.cpp
+++ b/lib/LTO/LTOModule.cpp
@@ -179,7 +179,8 @@ static Module *parseBitcodeFileImpl(MemoryBufferRef Buffer,
std::unique_ptr<MemoryBuffer> LightweightBuf =
MemoryBuffer::getMemBuffer(*MBOrErr, false);
ErrorOr<Module *> M = getLazyBitcodeModule(std::move(LightweightBuf), Context,
- DiagnosticHandler);
+ DiagnosticHandler,
+ true/*ShouldLazyLoadMetadata*/);
if (!M)
return nullptr;
return *M;
@@ -229,7 +230,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBufferRef Buffer,
TargetMachine *target = march->createTargetMachine(TripleStr, CPU, FeatureStr,
options);
- M->setDataLayout(target->getDataLayout());
+ M->setDataLayout(*target->getDataLayout());
std::unique_ptr<object::IRObjectFile> IRObj(
new object::IRObjectFile(Buffer, std::move(M)));