[lld] r203322 - Fix a bug that mergeCases table does not match the merge constants.

Rui Ueyama ruiu at google.com
Fri Mar 7 16:44:01 PST 2014


Author: ruiu
Date: Fri Mar  7 18:44:01 2014
New Revision: 203322

URL: http://llvm.org/viewvc/llvm-project?rev=203322&view=rev
Log:
Fix a bug that mergeCases table does not match the merge constants.

MergeCases table should not have an entry for MergeContents because atoms with
MergeContents attribute should never have name. This issue was not caught by a
test because getting a value of 6th element of an array of array actually gets
the first element's value of the next array, and that happened to be a valid
value. Added asserts to catch that error.

Modified:
    lld/trunk/include/lld/Core/DefinedAtom.h
    lld/trunk/lib/Core/SymbolTable.cpp

Modified: lld/trunk/include/lld/Core/DefinedAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/DefinedAtom.h?rev=203322&r1=203321&r2=203322&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/DefinedAtom.h (original)
+++ lld/trunk/include/lld/Core/DefinedAtom.h Fri Mar  7 18:44:01 2014
@@ -98,8 +98,8 @@ public:
                             // by linker
     mergeAsWeakAndAddressUsed, // Is C++ definition inline definition whose
                                // address was taken.
-    mergeByContent,         // Merge with other constants with same content
     mergeSameNameAndSize,   // Another atom with different size is error
+    mergeByContent,         // Merge with other constants with same content.
   };
 
   enum ContentType {

Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=203322&r1=203321&r2=203322&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Fri Mar  7 18:44:01 2014
@@ -113,6 +113,8 @@ static MergeResolution mergeCases[][5] =
 
 static MergeResolution mergeSelect(DefinedAtom::Merge first,
                                    DefinedAtom::Merge second) {
+  assert(first != DefinedAtom::mergeByContent);
+  assert(second != DefinedAtom::mergeByContent);
   return mergeCases[first][second];
 }
 





More information about the llvm-commits mailing list