[PATCH] D15857: [InstCombine] Defend against worst-case exponential execution time

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 8 16:25:10 PST 2016


On Fri, Jan 08, 2016 at 11:14:25AM +0000, James Molloy wrote:
> I think this version should tick all the boxes. There are several requirements that ended up with this design;
> 
> 1. Matching bitreversals is too heavyweight for InstCombine and doesn't really need to be done so early.
> 2. Bitreversals and byteswaps are very related in their matching logic.
> 3. We want to implement support for matching more advanced bswap/bitreverse patterns like partial bswaps/bitreverses.
> 4. Bswaps are best matched early in InstCombine.

Running with this text, I see: 

==26562== Invalid read of size 1
==26562==    at 0x219D128: llvm::Optional<BitPart>::operator=(llvm::Optional<BitPart> const&) (in /home/joerg/work/NetBSD/clean/obj/amd64/tooldir/bin/x86_64--netbsd-clang)
==26562==    by 0x219B967: collectBitParts(llvm::Value*, bool, bool, llvm::DenseMap<llvm::Value*, llvm::Optional<BitPart>, llvm::DenseMapInfo<llvm::Value*>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Optional<BitPart> > >&) (in /home/joerg/work/NetBSD/clean/obj/amd64/tooldir/bin/x86_64--netbsd-clang)
==26562==    by 0x219BCCD: collectBitParts(llvm::Value*, bool, bool, llvm::DenseMap<llvm::Value*, llvm::Optional<BitPart>, llvm::DenseMapInfo<llvm::Value*>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Optional<BitPart> > >&) (in /home/joerg/work/NetBSD/clean/obj/amd64/tooldir/bin/x86_64--netbsd-clang)
==26562==    by 0x219BA79: collectBitParts(llvm::Value*, bool, bool, llvm::DenseMap<llvm::Value*, llvm::Optional<BitPart>, llvm::DenseMapInfo<llvm::Value*>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Optional<BitPart> > >&) (in /home/joerg/work/NetBSD/clean/obj/amd64/tooldir/bin/x86_64--netbsd-clang)
==26562==    by 0x219C152: llvm::recognizeBitReverseOrBSwapIdiom(llvm::Instruction*, bool, bool, llvm::SmallVectorImpl<llvm::Instruction*>&) (in /home/joerg/work/NetBSD/clean/obj/amd64/tooldir/bin/x86_64--netbsd-clang)
==26562==    by 0x1EEAA1C: llvm::InstCombiner::MatchBSwapOrBitReverse(llvm::BinaryOperator&) (in /home/joerg/work/NetBSD/clean/obj/amd64/tooldir/bin/x86_64--netbsd-clang)

Joerg


More information about the llvm-commits mailing list