Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt crash with "-mem2reg -deadargelim -simplifycfg -inline -sroa -early-cse-memssa -jump-threading -instcombine" at "Combine redundant instructions" #47713

Closed
llvmbot opened this issue Dec 3, 2020 · 2 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 3, 2020

Bugzilla Link 48369
Resolution FIXED
Resolved on Dec 06, 2020 08:39
Version trunk
OS Linux
Attachments bc file
Reporter LLVM Bugzilla Contributor
CC @rotateright
Fixed by commit(s) 94f6d36

Extended Description


OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux


Program:
$ cat a.c
short a=0;
int b=0, d=0, f=0;
long c=0;
char e=0;
int main() {
int g = 3;
for (; a;) {
int h = 0;
for (;; d) {
c = (h <= 0) << 8;
h = b;
for (; g;)
;
for (; f;)
for (; e;)
;
}
}
return 0;
}


clang version:
$ clang --version
clang version 12.0.0 (/home/suocy/src/llvm-dev/llvm-project/llvm/tools/clang e52a91e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/suocy/bin/llvm-dev/bin


Command Lines:
$ clang -O3 -mllvm -disable-llvm-optzns -c -emit-llvm a.c -o a.bc
a.c:9:13: warning: expression result unused [-Wunused-value]
for (;; d) {
^
1 warning generated.
$ opt -mem2reg -deadargelim -simplifycfg -inline -sroa -early-cse-memssa -jump-threading -instcombine a.bc -o a.opt.bc
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/suocy/bin/llvm-dev/bin/opt -mem2reg -deadargelim -simplifycfg -inline -sroa -early-cse-memssa -jump-threading -instcombine a.bc -o a.opt.bc

  1.  Running pass 'CallGraph Pass Manager' on module 'a.bc'.
    
  2.  Running pass 'Combine redundant instructions' on function '@main'
    

#​0 0x0000000002a8136c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/suocy/bin/llvm-dev/bin/opt+0x2a8136c)
#​1 0x0000000002a7f1e4 llvm::sys::RunSignalHandlers() (/home/suocy/bin/llvm-dev/bin/opt+0x2a7f1e4)
#​2 0x0000000002a7f343 SignalHandler(int) (/home/suocy/bin/llvm-dev/bin/opt+0x2a7f343)
#​3 0x00007fec2e9b4630 __restore_rt (/lib64/libpthread.so.0+0xf630)
#​4 0x0000000002584f5e llvm::InstCombinerImpl::visitSelectInst(llvm::SelectInst&) (/home/suocy/bin/llvm-dev/bin/opt+0x2584f5e)
#​5 0x00000000024f310a llvm::InstCombinerImpl::run() (/home/suocy/bin/llvm-dev/bin/opt+0x24f310a)
#​6 0x00000000024f4d29 combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, unsigned int, llvm::LoopInfo*) (/home/suocy/bin/llvm-dev/bin/opt+0x24f4d29)
#​7 0x00000000024f698a llvm::InstructionCombiningPass::runOnFunction(llvm::Function&) (/home/suocy/bin/llvm-dev/bin/opt+0x24f698a)
#​8 0x00000000022bf598 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/suocy/bin/llvm-dev/bin/opt+0x22bf598)
#​9 0x0000000001a304f4 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) (/home/suocy/bin/llvm-dev/bin/opt+0x1a304f4)
#​10 0x00000000022bee43 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/suocy/bin/llvm-dev/bin/opt+0x22bee43)
#​11 0x000000000072c61b main (/home/suocy/bin/llvm-dev/bin/opt+0x72c61b)
#​12 0x00007fec2d58e555 __libc_start_main (/lib64/libc.so.6+0x22555)
#​13 0x00000000007ddac5 _start (/home/suocy/bin/llvm-dev/bin/opt+0x7ddac5)
Segmentation fault

@rotateright
Copy link
Contributor

Reduced:
define void @​#48369 (i32 %a, i32* %p) {
entry:
%phi.cmp = icmp sgt i32 %a, 0
br label %bb1

bb1:
%cmp = phi i1 [ %phi.cmp, %deadbb ], [ true, %entry ]
%shl = select i1 %cmp, i32 256, i32 0
store i32 %shl, i32* %p
br label %inf_loop

inf_loop:
br label %inf_loop

deadbb:
br label %bb1

end:
ret void
}


Crashes with "opt -instcombine":
Assertion failed: (Ptr != End && "dereferencing end() iterator"), function operator->, file /llvm-project/llvm/include/llvm/ADT/DenseMap.h, line 1241.

// Find the block's immediate dominator that ends with a conditional branch
// that matches select's condition (maybe inverted).
auto *IDomNode = DT[BB]->getIDom();

@rotateright
Copy link
Contributor

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants