<div dir="ltr">I don't actually like these tests and the very idea of supporting object file serialization to a YAML and "Native" format, but they are there and it's supposed to be able to serialize and de-serialize all information. These tests are to ensure the capability by dumping and reloading a file two times, in YAML and Native format, and verifying nothing was broken.<div><br></div><div>Any files that lld is able to handle should pass the round-trip test. Even if it's a platform-specific one, because every object file is in some degree platform-dependent.</div><div><br></div><div>So, in the above sense, this patch doesn't look good to me. It provides a way to circumvent the tests. If we enable this, YAML and Native format support will silently regress over time.</div><div><br></div><div>If we take this way, I'd suggest removing YAML and Native support.</div><div><br></div><div>If not, we should add the property you need to File and properly save and restore from YAML/Native files.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 30, 2014 at 5:04 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: shankare<br>
Date: Sun Nov 30 19:04:11 2014<br>
New Revision: 222983<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=222983&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=222983&view=rev</a><br>
Log:<br>
[Core] Add flag to check if RoundTripPasses need to be run.<br>
<br>
This would allow other flavor specific contexts to override the default value,<br>
if they want to optionally run the round trip passes.<br>
<br>
There is some information lost like the original file owner of the atom with<br>
RoundTripPasses. The Gnu flavor needs this information inorder to implement<br>
LinkerScript matching and for other diagnostic outputs such as Map files.<br>
<br>
The flag also can be used to record information in the Atom if the information<br>
to the Writer needs to be conveyed through References too.<br>
<br>
Modified:<br>
    lld/trunk/include/lld/Core/LinkingContext.h<br>
    lld/trunk/lib/Core/LinkingContext.cpp<br>
    lld/trunk/lib/Driver/Driver.cpp<br>
<br>
Modified: lld/trunk/include/lld/Core/LinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=222983&r1=222982&r2=222983&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=222983&r1=222982&r2=222983&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/Core/LinkingContext.h (original)<br>
+++ lld/trunk/include/lld/Core/LinkingContext.h Sun Nov 30 19:04:11 2014<br>
@@ -318,8 +318,15 @@ public:<br>
   /// Return the next ordinal and Increment it.<br>
   virtual uint64_t getNextOrdinalAndIncrement() const { return _nextOrdinal++; }<br>
<br>
-  /// @}<br>
+#ifndef NDEBUG<br>
+  void setRunRoundTripPass(bool roundTripPass) {<br>
+    _runRoundTripPasses = roundTripPass;<br>
+  }<br>
+<br>
+  bool runRoundTripPass() const { return _runRoundTripPasses; }<br>
+#endif<br>
<br>
+  /// @}<br>
 protected:<br>
   LinkingContext(); // Must be subclassed<br>
<br>
@@ -350,6 +357,9 @@ protected:<br>
   bool _allowRemainingUndefines;<br>
   bool _logInputFiles;<br>
   bool _allowShlibUndefines;<br>
+#ifndef NDEBUG<br>
+  bool _runRoundTripPasses;<br>
+#endif<br>
   OutputFileType _outputFileType;<br>
   std::vector<StringRef> _deadStripRoots;<br>
   std::map<std::string, std::string> _aliasSymbols;<br>
<br>
Modified: lld/trunk/lib/Core/LinkingContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=222983&r1=222982&r2=222983&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=222983&r1=222982&r2=222983&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Core/LinkingContext.cpp (original)<br>
+++ lld/trunk/lib/Core/LinkingContext.cpp Sun Nov 30 19:04:11 2014<br>
@@ -13,9 +13,28 @@<br>
 #include "lld/Core/Simple.h"<br>
 #include "lld/ReaderWriter/Writer.h"<br>
 #include "llvm/ADT/Triple.h"<br>
+#include "llvm/Support/Process.h"<br>
<br>
 namespace lld {<br>
<br>
+#ifndef NDEBUG<br>
+LinkingContext::LinkingContext()<br>
+    : _deadStrip(false), _allowDuplicates(false),<br>
+      _globalsAreDeadStripRoots(false),<br>
+      _searchArchivesToOverrideTentativeDefinitions(false),<br>
+      _searchSharedLibrariesToOverrideTentativeDefinitions(false),<br>
+      _warnIfCoalesableAtomsHaveDifferentCanBeNull(false),<br>
+      _warnIfCoalesableAtomsHaveDifferentLoadName(false),<br>
+      _printRemainingUndefines(true), _allowRemainingUndefines(false),<br>
+      _logInputFiles(false), _allowShlibUndefines(false),<br>
+      _runRoundTripPasses(false), _outputFileType(OutputFileType::Default),<br>
+      _nextOrdinal(0) {<br>
+  llvm::Optional<std::string> env =<br>
+      llvm::sys::Process::GetEnv("LLD_RUN_ROUNDTRIP_TEST");<br>
+  if (env.hasValue() && !env.getValue().empty())<br>
+    setRunRoundTripPass(true);<br>
+}<br>
+#else<br>
 LinkingContext::LinkingContext()<br>
     : _deadStrip(false), _allowDuplicates(false),<br>
       _globalsAreDeadStripRoots(false),<br>
@@ -26,6 +45,7 @@ LinkingContext::LinkingContext()<br>
       _printRemainingUndefines(true), _allowRemainingUndefines(false),<br>
       _logInputFiles(false), _allowShlibUndefines(false),<br>
       _outputFileType(OutputFileType::Default), _nextOrdinal(0) {}<br>
+#endif<br>
<br>
 LinkingContext::~LinkingContext() {}<br>
<br>
<br>
Modified: lld/trunk/lib/Driver/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=222983&r1=222982&r2=222983&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=222983&r1=222982&r2=222983&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/Driver.cpp (original)<br>
+++ lld/trunk/lib/Driver/Driver.cpp Sun Nov 30 19:04:11 2014<br>
@@ -23,7 +23,6 @@<br>
 #include "llvm/Support/CommandLine.h"<br>
 #include "llvm/Support/FileSystem.h"<br>
 #include "llvm/Support/Path.h"<br>
-#include "llvm/Support/Process.h"<br>
 #include "llvm/Support/raw_ostream.h"<br>
 #include <mutex><br>
<br>
@@ -114,8 +113,7 @@ bool Driver::link(LinkingContext &contex<br>
   context.addPasses(pm);<br>
<br>
 #ifndef NDEBUG<br>
-  llvm::Optional<std::string> env = llvm::sys::Process::GetEnv("LLD_RUN_ROUNDTRIP_TEST");<br>
-  if (env.hasValue() && !env.getValue().empty()) {<br>
+  if (context.runRoundTripPass()) {<br>
     pm.add(std::unique_ptr<Pass>(new RoundTripYAMLPass(context)));<br>
     pm.add(std::unique_ptr<Pass>(new RoundTripNativePass(context)));<br>
   }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>