summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/include/lld/Core/LinkingContext.h12
-rw-r--r--lld/lib/Core/LinkingContext.cpp20
-rw-r--r--lld/lib/Driver/Driver.cpp4
3 files changed, 32 insertions, 4 deletions
diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h
index b519373bd53..b8699106f71 100644
--- a/lld/include/lld/Core/LinkingContext.h
+++ b/lld/include/lld/Core/LinkingContext.h
@@ -318,8 +318,15 @@ public:
/// Return the next ordinal and Increment it.
virtual uint64_t getNextOrdinalAndIncrement() const { return _nextOrdinal++; }
- /// @}
+#ifndef NDEBUG
+ void setRunRoundTripPass(bool roundTripPass) {
+ _runRoundTripPasses = roundTripPass;
+ }
+
+ bool runRoundTripPass() const { return _runRoundTripPasses; }
+#endif
+ /// @}
protected:
LinkingContext(); // Must be subclassed
@@ -350,6 +357,9 @@ protected:
bool _allowRemainingUndefines;
bool _logInputFiles;
bool _allowShlibUndefines;
+#ifndef NDEBUG
+ bool _runRoundTripPasses;
+#endif
OutputFileType _outputFileType;
std::vector<StringRef> _deadStripRoots;
std::map<std::string, std::string> _aliasSymbols;
diff --git a/lld/lib/Core/LinkingContext.cpp b/lld/lib/Core/LinkingContext.cpp
index 47942d66efe..ee738660e68 100644
--- a/lld/lib/Core/LinkingContext.cpp
+++ b/lld/lib/Core/LinkingContext.cpp
@@ -13,9 +13,28 @@
#include "lld/Core/Simple.h"
#include "lld/ReaderWriter/Writer.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Process.h"
namespace lld {
+#ifndef NDEBUG
+LinkingContext::LinkingContext()
+ : _deadStrip(false), _allowDuplicates(false),
+ _globalsAreDeadStripRoots(false),
+ _searchArchivesToOverrideTentativeDefinitions(false),
+ _searchSharedLibrariesToOverrideTentativeDefinitions(false),
+ _warnIfCoalesableAtomsHaveDifferentCanBeNull(false),
+ _warnIfCoalesableAtomsHaveDifferentLoadName(false),
+ _printRemainingUndefines(true), _allowRemainingUndefines(false),
+ _logInputFiles(false), _allowShlibUndefines(false),
+ _runRoundTripPasses(false), _outputFileType(OutputFileType::Default),
+ _nextOrdinal(0) {
+ llvm::Optional<std::string> env =
+ llvm::sys::Process::GetEnv("LLD_RUN_ROUNDTRIP_TEST");
+ if (env.hasValue() && !env.getValue().empty())
+ setRunRoundTripPass(true);
+}
+#else
LinkingContext::LinkingContext()
: _deadStrip(false), _allowDuplicates(false),
_globalsAreDeadStripRoots(false),
@@ -26,6 +45,7 @@ LinkingContext::LinkingContext()
_printRemainingUndefines(true), _allowRemainingUndefines(false),
_logInputFiles(false), _allowShlibUndefines(false),
_outputFileType(OutputFileType::Default), _nextOrdinal(0) {}
+#endif
LinkingContext::~LinkingContext() {}
diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp
index 1095051c8bd..148d1003218 100644
--- a/lld/lib/Driver/Driver.cpp
+++ b/lld/lib/Driver/Driver.cpp
@@ -23,7 +23,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/Process.h"
#include "llvm/Support/raw_ostream.h"
#include <mutex>
@@ -114,8 +113,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
context.addPasses(pm);
#ifndef NDEBUG
- llvm::Optional<std::string> env = llvm::sys::Process::GetEnv("LLD_RUN_ROUNDTRIP_TEST");
- if (env.hasValue() && !env.getValue().empty()) {
+ if (context.runRoundTripPass()) {
pm.add(std::unique_ptr<Pass>(new RoundTripYAMLPass(context)));
pm.add(std::unique_ptr<Pass>(new RoundTripNativePass(context)));
}
OpenPOWER on IntegriCloud