[all-commits] [llvm/llvm-project] c5592f: [InstCombine] Fix use after free when removing unr...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Aug 1 01:19:45 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c5592f7acdf2e505b0431f44775b4339444a4711
      https://github.com/llvm/llvm-project/commit/c5592f7acdf2e505b0431f44775b4339444a4711
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2023-08-01 (Tue, 01 Aug 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/unreachable-code.ll

  Log Message:
  -----------
  [InstCombine] Fix use after free when removing unreachable code (PR64235)

In degenerate cases, it is possible for unreachable code removal
to remove the current instruction. However, we still return the
instruction to report a change, resulting in a use after free.

Instead, perform the change reporting in the same way as
eraseInstFromFunction() does, by directly setting MadeIRChange
and returning nullptr.

Fixes https://github.com/llvm/llvm-project/issues/64235.




More information about the All-commits mailing list