[llvm-commits] [PATCH] llvm/tools/TableGen/RegisterInfoEmitter.cpp (wrong use of set_difference)

Denis 2korden at gmail.com
Fri Mar 30 22:32:40 PDT 2012


Hi, guys,

There is a bug in llvm-tblgen project that crashes it at runtime,
preventing many depending libraries to compile. The patch is fairly
simple and shows both problem and the fix:

Index: RegisterInfoEmitter.cpp
===================================================================
--- RegisterInfoEmitter.cpp	(revision 153767)
+++ RegisterInfoEmitter.cpp	(working copy)
@@ -321,7 +321,7 @@
     const CodeGenRegister::Set &OSet = Overlaps[Reg];
     std::set_difference(OSet.begin(), OSet.end(),
                         Omit.begin(), Omit.end(),
-                        std::back_inserter(OverlapList));
+                        std::back_inserter(OverlapList), OSet.key_comp());

As you see, the set_difference algorithm is called without a
comparator, which results in a crash (or worse - wrong algorithm
behavior).

The CodeGenRegistner::Set class is using not default comparator, and
its iterator don't carry it on, which is why you need to pass it
manually.

Best regards,
Denis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RegisterInfoEmitter.cpp.patch
Type: application/octet-stream
Size: 613 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120331/a3762845/attachment.obj>


More information about the llvm-commits mailing list