[lld] r204285 - [PECOFF] Fix parallel read bug.

Rui Ueyama ruiu at google.com
Wed Mar 19 17:06:04 PDT 2014


Author: ruiu
Date: Wed Mar 19 19:06:04 2014
New Revision: 204285

URL: http://llvm.org/viewvc/llvm-project?rev=204285&view=rev
Log:
[PECOFF] Fix parallel read bug.

InputElement::parse() may recursively call WinLinkDriver::parse() to handle
.drectve section contents, and if /defaultlib option exists in the section,
the driver will mutate the input graph to add a new input file to the graph.
So the access to input graph needs to be protected with mutext.

Modified:
    lld/trunk/include/lld/Driver/WinLinkInputGraph.h

Modified: lld/trunk/include/lld/Driver/WinLinkInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=204285&r1=204284&r2=204285&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WinLinkInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/WinLinkInputGraph.h Wed Mar 19 19:06:04 2014
@@ -66,10 +66,14 @@ public:
 
   /// \brief Parse the group members.
   error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override {
+    auto *pctx = (PECOFFLinkingContext *)(&ctx);
+    error_code ec = error_code::success();
+    pctx->lock();
     for (auto &elem : _elements)
-      if (error_code ec = elem->parse(ctx, diagnostics))
-        return ec;
-    return error_code::success();
+      if ((ec = elem->parse(ctx, diagnostics)))
+        break;
+    pctx->unlock();
+    return ec;
   }
 };
 





More information about the llvm-commits mailing list