OSDN Git Service

Merging r369168:
authorHans Wennborg <hans@hanshq.net>
Tue, 20 Aug 2019 09:45:09 +0000 (09:45 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 20 Aug 2019 09:45:09 +0000 (09:45 +0000)
commit5571053b73c4b3e0baa46f7c39825a8113d6521b
tree067da2b9b98e1f544664092044903c3cb93aa75c
parent55ae22be6f0a3680bfc41bbff5bc07e313d7d749
Merging r369168:
------------------------------------------------------------------------
r369168 | spatel | 2019-08-17 01:10:34 +0200 (Sat, 17 Aug 2019) | 16 lines

[CodeGenPrepare] Fix use-after-free

If OptimizeExtractBits() encountered a shift instruction with no operands at all,
it would erase the instruction, but still return false.

This previously didn’t matter because its caller would always return after
processing the instruction, but https://reviews.llvm.org/D63233 changed the
function’s caller to fall through if it returned false, which would then cause
a use-after-free detectable by ASAN.

This change makes OptimizeExtractBits return true if it removes a shift
instruction with no users, terminating processing of the instruction.

Patch by: @brentdax (Brent Royal-Gordon)

Differential Revision: https://reviews.llvm.org/D66330
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_90@369355 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CodeGenPrepare.cpp
test/Transforms/CodeGenPrepare/sink-shift-and-trunc.ll