Skip to content

[SCCP] Assertion `getConstant() == V && "Marking constant with different value"' failed. #173180

@XChy

Description

@XChy

Reproducer: https://godbolt.org/z/6EPEPEvnc
Testcase:

define <32 x i8> @backsmith_pure_1(i1 %cond) {
entry:
  br label %for.cond2

for.cond2:                                        ; preds = %for.cond2, %entry
  %BS_VAR_1.0 = phi <4 x i64> [ <i64 poison, i64 poison, i64 poison, i64 0>, %entry ], [ zeroinitializer, %for.cond2 ]
  %0 = phi <4 x i64> [ zeroinitializer, %entry ], [ splat (i64 1), %for.cond2 ]
  br i1 %cond, label %for.cond2, label %if.then

if.then:                                          ; preds = %for.cond2
  %sub = sub <4 x i64> <i64 poison, i64 poison, i64 poison, i64 0>, %BS_VAR_1.0
  %and = and <4 x i64> %0, %sub
  %1 = bitcast <4 x i64> %and to <32 x i8>
  ret <32 x i8> %1
}

Dump:

opt: /root/llvm-project/llvm/include/llvm/Analysis/ValueLattice.h:319: bool llvm::ValueLatticeElement::markConstant(llvm::Constant*, bool): Assertion `getConstant() == V && "Marking constant with different value"' 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 --passes=sccp <source>
1.	Running pass "function(sccp)" on module "<source>"
2.	Running pass "sccp" on function "backsmith_pure_1"
 #0 0x00000000059be998 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x59be998)
 #1 0x00000000059bb844 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000759af6642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000759af66969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000759af6642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x0000759af66287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000759af662871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x0000759af6639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000004c46f35 llvm::ValueLatticeElement::markConstant(llvm::Constant*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c46f35)
 #9 0x0000000004c57414 llvm::SCCPInstVisitor::markConstant(llvm::Value*, llvm::Constant*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c57414)
#10 0x0000000004c58f4e llvm::SCCPInstVisitor::visitCastInst(llvm::CastInst&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c58f4e)
#11 0x0000000004c592e3 llvm::SCCPInstVisitor::solve() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c592e3)
#12 0x000000000482f15a llvm::SCCPPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x482f15a)
#13 0x0000000002ff434e llvm::detail::PassModel<llvm::Function, llvm::SCCPPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2ff434e)
#14 0x000000000579be41 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x579be41)
#15 0x0000000000f0774e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xf0774e)
#16 0x000000000579a50a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x579a50a)
#17 0x0000000000973a7e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x973a7e)
#18 0x0000000005799ec1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5799ec1)
#19 0x000000000097ddaa llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97ddaa)
#20 0x0000000000971c28 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x971c28)
#21 0x0000759af6629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x0000759af6629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x00000000009686c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9686c5)
Program terminated with signal: SIGSEGV
Compiler returned: 139

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions