r293415 - Modules: Fix a minor performance bug from r293393

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 28 20:42:21 PST 2017


Author: dexonsmith
Date: Sat Jan 28 22:42:21 2017
New Revision: 293415

URL: http://llvm.org/viewvc/llvm-project?rev=293415&view=rev
Log:
Modules: Fix a minor performance bug from r293393

Oops... r293393 started calling ReadSignature in
ModuleManager::addModule even when there was no ExpectedSignature.

Whether or not this would have a measurable performance impact (I
spotted this by inspection, and ReadSignature should be fairly fast), we
might as well get what we can.  Add an extra check against
ExpectedSignature to avoid the hit.

Modified:
    cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=293415&r1=293414&r2=293415&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Sat Jan 28 22:42:21 2017
@@ -165,9 +165,10 @@ ModuleManager::addModule(StringRef FileN
   // Initialize the stream.
   NewModule->Data = PCHContainerRdr.ExtractPCH(*NewModule->Buffer);
 
-  // Read the signature eagerly now so that we can check it.
-  if (checkSignature(ReadSignature(NewModule->Data), ExpectedSignature,
-                     ErrorStr))
+  // Read the signature eagerly now so that we can check it.  Avoid calling
+  // ReadSignature unless there's something to check though.
+  if (ExpectedSignature && checkSignature(ReadSignature(NewModule->Data),
+                                          ExpectedSignature, ErrorStr))
     return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.




More information about the cfe-commits mailing list