[PATCH] D124159: [SimplifyCFG] Thread branches on same condition in more cases (PR54980)

Nathan Chancellor via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 5 14:04:58 PDT 2022


nathanchance added a comment.

Should dc969061c68e62328607d68215ed8b9ef4a1e4b1 <https://reviews.llvm.org/rGdc969061c68e62328607d68215ed8b9ef4a1e4b1> be reverted as well? I just bisected an assertion failure while building the Linux kernel for arm64 to that change:

  clang: /home/nathan/cbl/src/llvm-project/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1136: llvm::BasicBlock *SplitBlockPredecessorsImpl(llvm::BasicBlock *, ArrayRef<llvm::BasicBlock *>, const char *, llvm::DomTreeUpdater *, llvm::DominatorTree *, llvm::LoopInfo *, llvm::MemorySSAUpdater *, bool): Assertion `!isa<CallBrInst>(Preds[i]->getTerminator()) && "Cannot split an edge from a CallBrInst"' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.      Program arguments: /home/nathan/tmp/build/llvm-bisect/stage1/bin/clang -mlittle-endian -Qunused-arguments -fmacro-prefix-map=/home/nathan/cbl/src/linux/= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu11 --target=aarch64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -mgeneral-regs-only -Wno-psabi -fno-asynchronous-unwind-tables -fno-unwind-tables -mbranch-protection=pac-ret+leaf+bti -fno-delete-null-pointer-checks -Wno-frame-address -Wno-address-of-packed-member -O2 -Wframe-larger-than=2048 -fstack-protector-strong -Wimplicit-fallthrough -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -fno-stack-clash-protection -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wcast-function-type -fno-strict-overflow -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1184 -Wa,-march=armv8.5-a -nostdinc -I/home/nathan/cbl/src/linux/arch/arm64/include -I./arch/arm64/include/generated -I/home/nathan/cbl/src/linux/include -I./include -I/home/nathan/cbl/src/linux/arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I/home/nathan/cbl/src/linux/include/uapi -I./include/generated/uapi -include /home/nathan/cbl/src/linux/include/linux/compiler-version.h -include /home/nathan/cbl/src/linux/include/linux/kconfig.h -include /home/nathan/cbl/src/linux/include/linux/compiler_types.h -D__KERNEL__ -DKASAN_SHADOW_SCALE_SHIFT= -DCONFIG_CC_HAS_K_CONSTRAINT=1 -DARM64_ASM_ARCH=\"armv8.5-a\" -DKASAN_SHADOW_SCALE_SHIFT= -I /home/nathan/cbl/src/linux/arch/arm64/crypto -I ./arch/arm64/crypto -DKBUILD_MODFILE=\"arch/arm64/crypto/aes-ce-cipher\" -DKBUILD_BASENAME=\"aes_ce_glue\" -DKBUILD_MODNAME=\"aes_ce_cipher\" -D__KBUILD_MODNAME=kmod_aes_ce_cipher -c -Wp,-MMD,arch/arm64/crypto/.aes-ce-glue.o.d -fcolor-diagnostics -o arch/arm64/crypto/aes-ce-glue.o /home/nathan/cbl/src/linux/arch/arm64/crypto/aes-ce-glue.c
  1.      <eof> parser at end of file
  2.      Optimizer
   #0 0x000055aae2db8b83 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3e2fb83)
   #1 0x000055aae2db6b1e llvm::sys::RunSignalHandlers() (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3e2db1e)
   #2 0x000055aae2d40c13 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
   #3 0x000055aae2d40d8e CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
   #4 0x00007fdd27ea18e0 (/usr/lib/libc.so.6+0x3e8e0)
   #5 0x00007fdd27ef136c (/usr/lib/libc.so.6+0x8e36c)
   #6 0x00007fdd27ea1838 gsignal (/usr/lib/libc.so.6+0x3e838)
   #7 0x00007fdd27e8b535 abort (/usr/lib/libc.so.6+0x28535)
   #8 0x00007fdd27e8b45c (/usr/lib/libc.so.6+0x2845c)
   #9 0x00007fdd27e9a366 (/usr/lib/libc.so.6+0x37366)
  #10 0x000055aae2dcb9b6 SplitBlockPredecessorsImpl(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DomTreeUpdater*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) BasicBlockUtils.cpp:0:0
  #11 0x000055aae2dcba4c llvm::SplitBlockPredecessors(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DomTreeUpdater*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3e42a4c)
  #12 0x000055aae2ef5b01 (anonymous namespace)::SimplifyCFGOpt::simplifyCondBranch(llvm::BranchInst*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) SimplifyCFG.cpp:0:0
  #13 0x000055aae2ee2e29 (anonymous namespace)::SimplifyCFGOpt::run(llvm::BasicBlock*) SimplifyCFG.cpp:0:0
  #14 0x000055aae2edfe84 llvm::simplifyCFG(llvm::BasicBlock*, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&, llvm::ArrayRef<llvm::WeakVH>) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3f56e84)
  #15 0x000055aae2ce66da iterativelySimplifyCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
  #16 0x000055aae2ce6127 simplifyFunctionCFGImpl(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
  #17 0x000055aae2ce4d0d simplifyFunctionCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
  #18 0x000055aae2ce4a6b llvm::SimplifyCFGPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3d5ba6b)
  #19 0x000055aae3f9d10d llvm::detail::PassModel<llvm::Function, llvm::SimplifyCFGPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
  #20 0x000055aae268c68d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x370368d)
  #21 0x000055aae35ccbbd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) BackendUtil.cpp:0:0
  #22 0x000055aae26ec953 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3763953)
  #23 0x000055aae3f9f50d llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) PassBuilder.cpp:0:0
  #24 0x000055aae26e7067 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x375e067)
  #25 0x000055aae2810d7d llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) Inliner.cpp:0:0
  #26 0x000055aae26eaae8 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3761ae8)
  #27 0x000055aae281155d llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) Inliner.cpp:0:0
  #28 0x000055aae26e9259 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang+0x3760259)
  ...



  # bad: [a1cd3f49b68022337c356482c8c4ec36221f4d1b] [RISCV] Use a switch statement in PreprocessISelDAG. NFC
  # good: [142aca7741d5b06207e87bf4880fbe308c8d6823] [InstCombine] fold sub of min/max of sub with common operand
  git bisect start 'a1cd3f49b68022337c356482c8c4ec36221f4d1b' '142aca7741d5b06207e87bf4880fbe308c8d6823'
  # good: [ebb78a95cede526ece9b904e9ba623d4b963df60] [LV] Remove stray dbgs() call after  774fc63490939.
  git bisect good ebb78a95cede526ece9b904e9ba623d4b963df60
  # bad: [e7a0fa4df00c6386632d1395799c6150f39a3e33] [DAG] foldAddSubOfSignBit - don't bother creating the new shift node unless constant folding succeeds
  git bisect bad e7a0fa4df00c6386632d1395799c6150f39a3e33
  # bad: [935570b2ad808035a1fd9bf6fa894657babc8694] [ConstExpr] Don't create div/rem expressions
  git bisect bad 935570b2ad808035a1fd9bf6fa894657babc8694
  # bad: [6e2058e58832058f05372c93e8be50695efcc6be] [Compiler-RT]  Remove FlushViewOfFile call when unmapping gcda files on win32.
  git bisect bad 6e2058e58832058f05372c93e8be50695efcc6be
  # bad: [8cd79bc12c366de01cedb88e2e2fc026619e64ea] [AMDGPU][GlobalISel] Support register offsets for SMRDs.
  git bisect bad 8cd79bc12c366de01cedb88e2e2fc026619e64ea
  # bad: [9fbf1107cc763783a82b89953be8a45097ba3390] [pseudo] Eliminate LRTable::Action. NFC
  git bisect bad 9fbf1107cc763783a82b89953be8a45097ba3390
  # bad: [dc969061c68e62328607d68215ed8b9ef4a1e4b1] [SimplifyCFG] Thread all predecessors with same value at once
  git bisect bad dc969061c68e62328607d68215ed8b9ef4a1e4b1
  # first bad commit: [dc969061c68e62328607d68215ed8b9ef4a1e4b1] [SimplifyCFG] Thread all predecessors with same value at once

I can reduce something down if necessary.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124159/new/

https://reviews.llvm.org/D124159



More information about the cfe-commits mailing list