[llvm] r329865 - Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." one more time.

David Zarzycki via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 05:44:02 PDT 2018


This change crashes the compiler to crash when building top-of-tree swift/swift-llvm/swift-clang on Linux:


FAILED: tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.o 
/usr/local/bin/clang++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/Sema -I../tools/clang/lib/Sema -I../tools/clang/include -Itools/clang/include -I/usr/include/libxml2 -Iinclude -I../include -Wno-c11-extensions -Wno-gnu-anonymous-struct -Wno-unused-local-typedef -Wno-dollar-in-identifier-extension -Wno-unused-private-field -Wno-gnu-statement-expression -Wno-c99-extensions -Wno-nullability-extension -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fcolor-diagnostics -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O2    -UNDEBUG  -march=native -fno-omit-frame-pointer -fno-vectorize -fno-slp-vectorize -mno-omit-leaf-frame-pointer -fno-exceptions -fno-rtti -MD -MT tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.o -MF tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.o.d -o tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.o -c ../tools/clang/lib/Sema/SemaTemplateDeduction.cpp
#0 0x0000000001eb3558 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/bin/clang-7+0x1eb3558)
#1 0x0000000001eb37e6 SignalHandler(int) (/usr/local/bin/clang-7+0x1eb37e6)
#2 0x00007f727d834fb0 __restore_rt (/lib64/libpthread.so.0+0x11fb0)
#3 0x0000000001f2c41c llvm::SSAUpdaterBulk::RewriteAllUses(llvm::DominatorTree*, llvm::SmallVectorImpl<llvm::PHINode*>*) (/usr/local/bin/clang-7+0x1f2c41c)
#4 0x0000000001d45fc3 llvm::JumpThreadingPass::ThreadEdge(llvm::BasicBlock*, llvm::SmallVectorImpl<llvm::BasicBlock*> const&, llvm::BasicBlock*) (/usr/local/bin/clang-7+0x1d45fc3)
#5 0x0000000001d43000 llvm::JumpThreadingPass::ProcessThreadableEdges(llvm::Value*, llvm::BasicBlock*, llvm::jumpthreading::ConstantPreference, llvm::Instruction*) (/usr/local/bin/clang-7+0x1d43000)
#6 0x0000000001d3fef7 llvm::JumpThreadingPass::ProcessBlock(llvm::BasicBlock*) (/usr/local/bin/clang-7+0x1d3fef7)
#7 0x0000000001d3ee3b llvm::JumpThreadingPass::runImpl(llvm::Function&, llvm::TargetLibraryInfo*, llvm::LazyValueInfo*, llvm::AAResults*, llvm::DeferredDominance*, bool, std::__1::unique_ptr<llvm::BlockFrequencyInfo, std::__1::default_delete<llvm::BlockFrequencyInfo> >, std::__1::unique_ptr<llvm::BranchProbabilityInfo, std::__1::default_delete<llvm::BranchProbabilityInfo> >) (/usr/local/bin/clang-7+0x1d3ee3b)
#8 0x0000000001d48aa3 (anonymous namespace)::JumpThreading::runOnFunction(llvm::Function&) (/usr/local/bin/clang-7+0x1d48aa3)
#9 0x0000000001ac495f llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/bin/clang-7+0x1ac495f)
#10 0x0000000001937e94 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) (/usr/local/bin/clang-7+0x1937e94)
#11 0x0000000001ac4fae llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/clang-7+0x1ac4fae)
#12 0x0000000001ff9f35 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) (/usr/local/bin/clang-7+0x1ff9f35)
#13 0x000000000250193f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/bin/clang-7+0x250193f)
#14 0x0000000002d088f4 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/bin/clang-7+0x2d088f4)
#15 0x000000000247d440 clang::FrontendAction::Execute() (/usr/local/bin/clang-7+0x247d440)
#16 0x0000000002412598 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/bin/clang-7+0x2412598)
#17 0x00000000024fcd1e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/bin/clang-7+0x24fcd1e)
#18 0x000000000127f80d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/bin/clang-7+0x127f80d)
#19 0x000000000127dabe main (/usr/local/bin/clang-7+0x127dabe)
#20 0x00007f727c1971bb __libc_start_main (/lib64/libc.so.6+0x231bb)
#21 0x000000000127b02a _start (/usr/local/bin/clang-7+0x127b02a)
Stack dump:
0.	Program arguments: /usr/local/bin/clang-7 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name SemaTemplateDeduction.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu skylake-avx512 -target-feature +sse2 -target-feature +cx16 -target-feature +sahf -target-feature -tbm -target-feature -avx512ifma -target-feature -sha -target-feature -gfni -target-feature -fma4 -target-feature -vpclmulqdq -target-feature +prfchw -target-feature +bmi2 -target-feature +xsavec -target-feature +fsgsbase -target-feature +popcnt -target-feature +aes -target-feature -avx512bitalg -target-feature +xsaves -target-feature -avx512er -target-feature -avx512vnni -target-feature -avx512vpopcntdq -target-feature +clwb -target-feature +avx512f -target-feature -clzero -target-feature +pku -target-feature +mmx -target-feature -lwp -target-feature -rdpid -target-feature -xop -target-feature +rdseed -target-feature -ibt -target-feature -sse4a -target-feature +avx512bw -target-feature +clflushopt -target-feature +xsave -target-feature -avx512vbmi2 -target-feature +avx512vl -target-feature +avx512cd -target-feature +avx -target-feature -vaes -target-feature +rtm -target-feature +fma -target-feature +bmi -target-feature +rdrnd -target-feature -mwaitx -target-feature +sse4.1 -target-feature +sse4.2 -target-feature +avx2 -target-feature -wbnoinvd -target-feature +sse -target-feature +lzcnt -target-feature +pclmul -target-feature -prefetchwt1 -target-feature +f16c -target-feature +ssse3 -target-feature -sgx -target-feature -shstk -target-feature +cmov -target-feature -avx512vbmi -target-feature +movbe -target-feature +xsaveopt -target-feature +avx512dq -target-feature +adx -target-feature -avx512pf -target-feature +sse3 -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -coverage-notes-file /home/dave/s/u/t/tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.gcno -resource-dir /usr/local/lib/clang/7.0.0 -dependency-file tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.o.d -sys-header-deps -MT tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.o -D GTEST_HAS_RTTI=0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/clang/lib/Sema -I ../tools/clang/lib/Sema -I ../tools/clang/include -I tools/clang/include -I /usr/include/libxml2 -I include -I ../include -U NDEBUG -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/local/lib/clang/7.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-c11-extensions -Wno-gnu-anonymous-struct -Wno-unused-local-typedef -Wno-dollar-in-identifier-extension -Wno-unused-private-field -Wno-gnu-statement-expression -Wno-c99-extensions -Wno-nullability-extension -Werror=date-time -Werror=unguarded-availability-new -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Woverloaded-virtual -Wno-nested-anon-types -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/dave/s/u/t -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fno-rtti -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -fcolor-diagnostics -o tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplateDeduction.cpp.o -x c++ ../tools/clang/lib/Sema/SemaTemplateDeduction.cpp 
1.	<eof> parser at end of file
2.	Per-module optimization passes
3.	Running pass 'CallGraph Pass Manager' on module '../tools/clang/lib/Sema/SemaTemplateDeduction.cpp'.
4.	Running pass 'Jump Threading' on function '@_ZN5clang13TreeTransformIN12_GLOBAL__N_130SubstituteDeducedTypeTransformEE30TransformObjCDictionaryLiteralEPNS_21ObjCDictionaryLiteralE'
clang-7: error: unable to execute command: Segmentation fault
clang-7: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 7.0.0 (https://git.llvm.org/git/clang.git e4c4700eca75dd5a18392d39542697b9e885f2b4) (https://git.llvm.org/git/llvm.git b33a02496a4fb835610a575c7e8419711217dda6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-7: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-7: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7: note: diagnostic msg: /tmp/SemaTemplateDeduction-3901a1.cpp
clang-7: note: diagnostic msg: /tmp/SemaTemplateDeduction-3901a1.sh
clang-7: note: diagnostic msg: 


http://znu.io/SemaTemplateDeduction-3901a1.cpp
http://znu.io/SemaTemplateDeduction-3901a1.sh


> On Apr 11, 2018, at 19:37, Michael Zolotukhin via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: mzolotukhin
> Date: Wed Apr 11 16:37:53 2018
> New Revision: 329865
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=329865&view=rev
> Log:
> Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." one more time.
> 
> This reapplies commit r329644.
> 
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=329865&r1=329864&r2=329865&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Apr 11 16:37:53 2018
> @@ -66,6 +66,7 @@
> #include "llvm/Transforms/Utils/BasicBlockUtils.h"
> #include "llvm/Transforms/Utils/Cloning.h"
> #include "llvm/Transforms/Utils/SSAUpdater.h"
> +#include "llvm/Transforms/Utils/SSAUpdaterBulk.h"
> #include "llvm/Transforms/Utils/ValueMapper.h"
> #include <algorithm>
> #include <cassert>
> @@ -1989,9 +1990,13 @@ bool JumpThreadingPass::ThreadEdge(Basic
>   // now have to update all uses of the value to use either the original value,
>   // the cloned value, or some PHI derived value.  This can require arbitrary
>   // PHI insertion, of which we are prepared to do, clean these up now.
> -  SSAUpdater SSAUpdate;
> +  SSAUpdaterBulk SSAUpdate;
>   SmallVector<Use*, 16> UsesToRename;
> +
> +  unsigned VarNum = 0;
>   for (Instruction &I : *BB) {
> +    UsesToRename.clear();
> +
>     // Scan all uses of this instruction to see if it is used outside of its
>     // block, and if so, record them in UsesToRename.
>     for (Use &U : I.uses()) {
> @@ -2008,19 +2013,15 @@ bool JumpThreadingPass::ThreadEdge(Basic
>     // If there are no uses outside the block, we're done with this instruction.
>     if (UsesToRename.empty())
>       continue;
> +    SSAUpdate.AddVariable(VarNum, I.getName(), I.getType());
> 
> -    DEBUG(dbgs() << "JT: Renaming non-local uses of: " << I << "\n");
> -
> -    // We found a use of I outside of BB.  Rename all uses of I that are outside
> -    // its block to be uses of the appropriate PHI node etc.  See ValuesInBlocks
> -    // with the two values we know.
> -    SSAUpdate.Initialize(I.getType(), I.getName());
> -    SSAUpdate.AddAvailableValue(BB, &I);
> -    SSAUpdate.AddAvailableValue(NewBB, ValueMapping[&I]);
> -
> -    while (!UsesToRename.empty())
> -      SSAUpdate.RewriteUse(*UsesToRename.pop_back_val());
> -    DEBUG(dbgs() << "\n");
> +    // We found a use of I outside of BB - we need to rename all uses of I that
> +    // are outside its block to be uses of the appropriate PHI node etc.
> +    SSAUpdate.AddAvailableValue(VarNum, BB, &I);
> +    SSAUpdate.AddAvailableValue(VarNum, NewBB, ValueMapping[&I]);
> +    for (auto U : UsesToRename)
> +      SSAUpdate.AddUse(VarNum, U);
> +    VarNum++;
>   }
> 
>   // Ok, NewBB is good to go.  Update the terminator of PredBB to jump to
> @@ -2037,6 +2038,10 @@ bool JumpThreadingPass::ThreadEdge(Basic
>                      {DominatorTree::Insert, PredBB, NewBB},
>                      {DominatorTree::Delete, PredBB, BB}});
> 
> +  // Apply all updates we queued with DDT and get the updated Dominator Tree.
> +  DominatorTree *DT = &DDT->flush();
> +  SSAUpdate.RewriteAllUses(DT);
> +
>   // At this point, the IR is fully up to date and consistent.  Do a quick scan
>   // over the new instructions and zap any that are constants or dead.  This
>   // frequently happens because of phi translation.
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list