[PATCH] D139074: Vectorization Of Conditional Statements Using BOSCC

Matt D. via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 20:19:29 PDT 2023


Matt added a comment.

Hi!

While trying out the patch I've run into an internal compiler error (ICE): It looks like an assertion violation coming from `collectPoisonGeneratingRecipes` (on `VPWidenMemoryInstructionRecipe`).

To reproduce, apply the patch on top of a recent LLVM and build with asserts enabled; in particular, I've used b6847edfc235829b37dd6d734ef5bbfa0a58b6fc <https://reviews.llvm.org/rGb6847edfc235829b37dd6d734ef5bbfa0a58b6fc> and `CMAKE_BUILD_TYPE=RelWithDebInfo`.

Then, use the newly built `clang++` to compile the reproducer source code "repro.cpp" (below) as follows :

  clang++ -O2 -march=znver4 -mllvm -enable-boscc-vectorization -c repro.cpp
  clang++ -O2 -march=x86-64-v4 -mllvm -enable-boscc-vectorization -c repro.cpp

Either `-march=znver4` or `-march=x86-64-v4` suffices (or another AVX-512 target, like `-march=skylake-avx512`).
OTOH, the ICE does not occur at other optimization levels (O1 <https://reviews.llvm.org/owners/package/1/>, O3 <https://reviews.llvm.org/owners/package/3/>, Ofast, Os) or pre-AVX-512 x86 targets like `znver1`-`znver3` or `x86-64-v3`.

Reproducer source code:

  // repro.cpp
  
  bool condition;
  double *p_a, *p_b;
  long begin;
  long end;
  
  void f() {
    auto lambda = [](long i) {
      if (condition) {
        p_a[i] = p_b[i];
        if (p_a[i])
          p_a[i] = 0.0;
      }
    };
    for (long i = begin; i != end; ++i) {
      lambda(i);
    }
  }

Backtrace:

  clang++: /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::Instruction; From = llvm::Value]: Assertion `Val && "isa<> used on a null pointer"' 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: /subdir/src/build_x86-release-asserts-boscc/bin/clang++ -O2 -march=x86-64-v4 -mllvm -enable-boscc-vectorization -c repro.cpp
  1.      <eof> parser at end of file
  2.      Optimizer
   #0 0x00007feccea5a2be llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /subdir/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:602:22
   #1 0x00007feccea58266 llvm::sys::RunSignalHandlers() /subdir/src/llvm-project/llvm/lib/Support/Signals.cpp:104:20
   #2 0x00007fecce9820c8 HandleCrash /subdir/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
   #3 0x00007fecce9820c8 CrashRecoverySignalHandler(int) /subdir/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:62
   #4 0x00007feccdf5fd00 __restore_rt (/lib64/libc.so.6+0x4ad00)
   #5 0x00007feccdf5fc6b raise (/lib64/libc.so.6+0x4ac6b)
   #6 0x00007feccdf61305 abort (/lib64/libc.so.6+0x4c305)
   #7 0x00007feccdf57c6a __assert_fail_base (/lib64/libc.so.6+0x42c6a)
   #8 0x00007feccdf57cf2 (/lib64/libc.so.6+0x42cf2)
   #9 0x00007fecd11067b3 (/subdir/src/build_x86-release-asserts-boscc/bin/../lib/libLLVMVectorize.so.18git+0x547b3)
  #10 0x00007fecd110eb8d llvm::isa_impl_cl<llvm::VPWidenMemoryInstructionRecipe, llvm::VPRecipeBase const*>::doit(llvm::VPRecipeBase const*) /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:109:5
  #11 0x00007fecd110eb8d llvm::isa_impl_cl<llvm::VPWidenMemoryInstructionRecipe, llvm::VPRecipeBase const*>::doit(llvm::VPRecipeBase const*) /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:108:22
  #12 0x00007fecd110eb8d llvm::isa_impl_wrap<llvm::VPWidenMemoryInstructionRecipe, llvm::VPRecipeBase const*, llvm::VPRecipeBase const*>::doit(llvm::VPRecipeBase const* const&) /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:137:41
  #13 0x00007fecd110eb8d llvm::isa_impl_wrap<llvm::VPWidenMemoryInstructionRecipe, llvm::VPRecipeBase const* const, llvm::VPRecipeBase const*>::doit(llvm::VPRecipeBase const* const&) /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:129:13
  #14 0x00007fecd110eb8d llvm::CastIsPossible<llvm::VPWidenMemoryInstructionRecipe, llvm::VPRecipeBase const*, void>::isPossible(llvm::VPRecipeBase const* const&) /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:257:62
  #15 0x00007fecd110eb8d llvm::CastInfo<llvm::VPWidenMemoryInstructionRecipe, llvm::VPRecipeBase* const, void>::isPossible(llvm::VPRecipeBase* const&) /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:509:38
  #16 0x00007fecd110eb8d bool llvm::isa<llvm::VPWidenMemoryInstructionRecipe, llvm::VPRecipeBase*>(llvm::VPRecipeBase* const&) /subdir/src/llvm-project/llvm/include/llvm/Support/Casting.h:549:46
  #17 0x00007fecd110eb8d llvm::InnerLoopVectorizer::collectPoisonGeneratingRecipes(llvm::VPTransformState&)::'lambda'(llvm::VPRecipeBase*)::operator()(llvm::VPRecipeBase*) const /subdir/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1133:46
  #18 0x00007fecd11373e7 llvm::InnerLoopVectorizer::collectPoisonGeneratingRecipes(llvm::VPTransformState&) /subdir/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1171:55
  #19 0x00007fecd115d279 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>>*) /subdir/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7795:30
  #20 0x00007fecd116715a llvm::LoopVectorizePass::processLoop(llvm::Loop*) /subdir/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10736:24
  #21 0x00007fecd11692cf llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) /subdir/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10833:27
  #22 0x00007fecd1169c02 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /subdir/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10867:5
  #23 0x00007fecccec45a5 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /subdir/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:3
  #24 0x00007fecd2367373 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /subdir/src/llvm-project/llvm/include/llvm/IR/PassManager.h:521:20
  #25 0x00007fecd2367373 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>&) /subdir/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:41
  #26 0x00007feccf4cde52 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /subdir/src/llvm-project/llvm/lib/IR/PassManager.cpp:129:41
  #27 0x00007fecd2356355 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /subdir/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:3
  #28 0x00007feccf4cb763 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /subdir/src/llvm-project/llvm/include/llvm/IR/PassManager.h:521:20
  #29 0x00007fecd23688d1 llvm::SmallPtrSetImplBase::isSmall() const /subdir/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:195:33
  #30 0x00007fecd23688d1 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /subdir/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:83:17
  #31 0x00007fecd23688d1 llvm::SmallPtrSetImpl<llvm::AnalysisKey*>::~SmallPtrSetImpl() /subdir/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:345:7
  #32 0x00007fecd23688d1 llvm::SmallPtrSet<llvm::AnalysisKey*, 2u>::~SmallPtrSet() /subdir/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:451:7
  #33 0x00007fecd23688d1 llvm::PreservedAnalyses::~PreservedAnalyses() /subdir/src/llvm-project/llvm/include/llvm/IR/PassManager.h:152:7
  #34 0x00007fecd23688d1 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /subdir/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1100:12
  #35 0x00007fecd236bbf9 RunCodegenPipeline /subdir/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1110:23
  #36 0x00007fecd236bbf9 EmitAssembly /subdir/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1158:21
  #37 0x00007fecd236bbf9 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /subdir/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1320:25
  #38 0x00007fecd27d5c1f llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>::release() /subdir/src/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:223:9
  #39 0x00007fecd27d5c1f llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>::~IntrusiveRefCntPtr() /subdir/src/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:191:34
  #40 0x00007fecd27d5c1f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /subdir/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:386:24
  #41 0x00007feccbc03869 clang::ParseAST(clang::Sema&, bool, bool) /subdir/src/llvm-project/clang/lib/Parse/ParseAST.cpp:176:34
  #42 0x00007fecd0facd71 clang::FrontendAction::Execute() /subdir/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058:21
  #43 0x00007fecd0f37bf4 llvm::Error::getPtr() const /subdir/src/llvm-project/llvm/include/llvm/Support/Error.h:270:51
  #44 0x00007fecd0f37bf4 llvm::Error::operator bool() /subdir/src/llvm-project/llvm/include/llvm/Support/Error.h:233:22
  #45 0x00007fecd0f37bf4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /subdir/src/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1053:42
  #46 0x00007fecd2ebd4b5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /subdir/src/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:273:32
  #47 0x00000000004137b6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /subdir/src/llvm-project/clang/tools/driver/cc1_main.cpp:249:40
  #48 0x000000000040ca30 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /subdir/src/llvm-project/clang/tools/driver/driver.cpp:366:20
  #49 0x00007fecd0c4f2d1 operator() /subdir/src/llvm-project/clang/lib/Driver/Job.cpp:440:32
  #50 0x00007fecd0c4f2d1 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) /subdir/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:52
  #51 0x00007fecce982235 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /subdir/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:10
  #52 0x00007fecd0c4f9ee clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) /subdir/src/llvm-project/clang/lib/Driver/Job.cpp:444:10
  #53 0x00007fecd0c14554 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /subdir/src/llvm-project/clang/lib/Driver/Compilation.cpp:200:3
  #54 0x00007fecd0c14d0c clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /subdir/src/llvm-project/clang/lib/Driver/Compilation.cpp:253:5
  #55 0x00007fecd0c2182c llvm::SmallVectorBase<unsigned int>::empty() const /subdir/src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:94:46
  #56 0x00007fecd0c2182c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /subdir/src/llvm-project/clang/lib/Driver/Driver.cpp:1906:28
  #57 0x0000000000411a8a llvm::SmallVectorBase<unsigned int>::size() const /subdir/src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:91:32
  #58 0x0000000000411a8a llvm::SmallVectorTemplateCommon<std::pair<int, clang::driver::Command const*>, void>::end() /subdir/src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:272:41
  #59 0x0000000000411a8a clang_main(int, char**, llvm::ToolContext const&) /subdir/src/llvm-project/clang/tools/driver/driver.cpp:544:26
  #60 0x000000000040b234 main /subdir/src/build_x86-release-asserts-boscc/tools/clang/tools/driver/clang-driver.cpp:16:1
  #61 0x00007feccdf4a24d __libc_start_main (/lib64/libc.so.6+0x3524d)
  #62 0x000000000040b26a _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
  
  clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
  clang version 18.0.0 (https://github.com/llvm/llvm-project.git b6847edfc235829b37dd6d734ef5bbfa0a58b6fc)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /subdir/src/build_x86-release-asserts-boscc/bin




Repository:
  rL LLVM

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

https://reviews.llvm.org/D139074



More information about the llvm-commits mailing list