[all-commits] [llvm/llvm-project] 022da6: [SimplifyCFG] Change 'LoopHeaders' to be ArrayRef<...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Sat Jan 23 05:54:10 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 022da61f6b30626708e5b4c1c009afb453d12ebe
      https://github.com/llvm/llvm-project/commit/022da61f6b30626708e5b4c1c009afb453d12ebe
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-01-23 (Sat, 23 Jan 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/Local.h
    M llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp

  Log Message:
  -----------
  [SimplifyCFG] Change 'LoopHeaders' to be ArrayRef<WeakVH>, not a naked set, thus avoiding dangling pointers

If i change it to AssertingVH instead, a number of existing tests fail,
which means we don't consistently remove from the set when deleting blocks,
which means newly-created blocks may happen to appear in that set
if they happen to occupy the same memory chunk as did some block
that was in the set originally.

There are many places where we delete blocks,
and while we could probably consistently delete from LoopHeaders
when deleting a block in transforms located in SimplifyCFG.cpp itself,
transforms located elsewhere (Local.cpp/BasicBlockUtils.cpp) also may
delete blocks, and it doesn't seem good to teach them to deal with it.

Since we at most only ever delete from LoopHeaders,
let's just delegate to WeakVH to do that automatically.

But to be honest, personally, i'm not sure that the idea
behind LoopHeaders is sound.




More information about the All-commits mailing list