-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Open
Description
This IR:
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-unknown-linux-gnu"
define i8 @_Z3fn1ssb() {
entry:
br label %for.body11.1
for.body11.1: ; preds = %for.body11.1, %entry
%indvars.iv.1 = phi i64 [ %indvars.iv.next.1, %for.body11.1 ], [ 2, %entry ]
%indvars.iv.next.1 = add i64 %indvars.iv.1, 1
%exitcond.1.not = icmp eq i64 %indvars.iv.next.1, 0
br i1 %exitcond.1.not, label %for.body11.2.preheader, label %for.body11.1
for.body11.2.preheader: ; preds = %for.body11.1
%.sroa.speculated.1.lcssa = phi i8 [ 0, %for.body11.1 ]
br label %for.body11.2
for.body11.2: ; preds = %for.body11.2, %for.body11.2.preheader
%indvars.iv.2 = phi i64 [ %indvars.iv.next.2, %for.body11.2 ], [ 2, %for.body11.2.preheader ]
%indvars.iv.next.2 = add i64 %indvars.iv.2, 1
%exitcond.2.not = icmp eq i64 %indvars.iv.next.2, 0
br i1 %exitcond.2.not, label %for.cond.cleanup6.2.loopexit, label %for.body11.2
for.cond.cleanup6.2.loopexit: ; preds = %for.body11.2
%.sroa.speculated.2.lcssa = phi i8 [ %.sroa.speculated.1.lcssa, %for.body11.2 ]
ret i8 %.sroa.speculated.2.lcssa
}
compiled with opt -S -passes=loop-fusion , triggers this assert:
Instruction does not dominate all uses!
%.sroa.speculated.1.lcssa = phi i8 [ 0, %for.body11.1 ]
%.sroa.speculated.2.lcssa = phi i8 [ %.sroa.speculated.1.lcssa, %for.body11.1 ]
opt: /root/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp:1827: llvm::Loop* {anonymous}::LoopFuser::performFusion(const {anonymous}::FusionCandidate&, const {anonymous}::FusionCandidate&): Assertion `!verifyFunction(*FC0.Header->getParent(), &errs())' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -S -passes=loop-fusion <source>
1. Running pass "function(loop-fusion)" on module "<source>"
2. Running pass "loop-fusion" on function "_Z3fn1ssb"
#0 0x0000000005965e58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5965e58)
#1 0x0000000005962d04 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x0000785d49242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x0000785d492969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x0000785d49242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x0000785d492287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x0000785d4922871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x0000785d49239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x000000000468b1fc (anonymous namespace)::LoopFuser::performFusion((anonymous namespace)::FusionCandidate const&, (anonymous namespace)::FusionCandidate const&) LoopFuse.cpp:0:0
#9 0x000000000468fcfe (anonymous namespace)::LoopFuser::fuseCandidates() LoopFuse.cpp:0:0
#10 0x0000000004691861 llvm::LoopFusePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4691861)
#11 0x0000000002f977be llvm::detail::PassModel<llvm::Function, llvm::LoopFusePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f977be)
See also: https://godbolt.org/z/bW9rMf7dj
IR was reproduced from this C reproducer:
#include <algorithm>
unsigned char a;
extern int d[][1][1];
char b;
int c;
void fn1(short e, short f, bool g) {
for (; b;)
for (short h = 0; h < 011; h += 3)
for (short i = 0; i < 2; i = 0201)
for (int j = 2; j < c; j += 0 >= 0) {
d[i][i][j] = std::max((long long)4, (long long)0);
a = std::max(a, (unsigned char)(f && (e || g)));
}
}