[llvm-bugs] [Bug 52504] New: Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) == To->getValueType(i)) && "Cannot use this version of ReplaceAllUsesWith!"

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 14 12:51:48 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=52504

            Bug ID: 52504
           Summary: Assertion `(!From->hasAnyUseOfValue(i) ||
                    From->getValueType(i) == To->getValueType(i)) &&
                    "Cannot use this version of ReplaceAllUsesWith!"
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: Vsevolod.Livinskij at frtk.ru
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

IR Reproducer:

@b = external global [0 x i16]
@c = external global [0 x i8]

define void @_Z1hv([0 x i16]* %b, i64 %0, i16* %1, i16 %2, <8 x i16> %3, <8 x
i16> %4, <8 x i16> %5, [0 x i8]* %c, i8* %6, i8* %7) {
vector.ph:
  br label %vector.body

vector.body:                                      ; preds = %vector.body,
%vector.ph
  %8 = or i64 0, 0
  %9 = getelementptr inbounds [0 x i16], [0 x i16]* %b, i64 0, i64 %0
  %10 = load i16, i16* %1, align 2
  %11 = insertelement <8 x i16> zeroinitializer, i16 %2, i32 1
  %12 = insertelement <8 x i16> %3, i16 0, i32 0
  %13 = insertelement <8 x i16> %3, i16 0, i32 0
  %14 = sext <8 x i16> %3 to <8 x i64>
  %15 = icmp sgt <8 x i64> %14, <i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64
-1, i64 -1, i64 -1>
  %16 = select <8 x i1> %15, <8 x i64> %14, <8 x i64> <i64 -1, i64 -1, i64 -1,
i64 -1, i64 -1, i64 -1, i64 -1, i64 -1>
  %17 = trunc <8 x i64> %16 to <8 x i32>
  %18 = icmp ne <8 x i32> %17, zeroinitializer
  %19 = getelementptr inbounds [0 x i8], [0 x i8]* %c, i64 0, i64 %0
  %20 = getelementptr inbounds [0 x i8], [0 x i8]* %c, i64 0, i64 undef
  %21 = zext <8 x i1> %18 to <8 x i8>
  %22 = extractelement <8 x i8> %21, i32 1
  store i8 %22, i8* %6, align 1
  %23 = extractelement <8 x i8> %21, i32 0
  store i8 %23, i8* %7, align 1
  br label %vector.body
}

>$ clang++ -c reduced.ll
clang++:
/testing/llvm/llvm_src_main/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:9444:
void llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode*, llvm::SDNode*):
Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) ==
To->getValueType(i)) && "Cannot use this version of ReplaceAllUsesWith!"'
failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang++ -c reduced.ll
1.      Code generation
2.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
3.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z1hv'
 #0 0x0000561d20998344 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000561d20996154 llvm::sys::CleanupOnSignal(unsigned long)
(/testing/llvm/bin_main/bin/clang-14+0x224b154)
 #2 0x0000561d208de158 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007fbfac0d23c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x00007fbfabb8218b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
 #5 0x00007fbfabb61859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #6 0x00007fbfabb61729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #7 0x00007fbfabb72f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x0000561d219e2f9f llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode*,
llvm::SDNode*) (/testing/llvm/bin_main/bin/clang-14+0x3297f9f)
 #9 0x0000561d2190aa89 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults*, llvm::CodeGenOpt::Level)
(/testing/llvm/bin_main/bin/clang-14+0x31bfa89)
#10 0x0000561d21a1a739 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/testing/llvm/bin_main/bin/clang-14+0x32cf739)
#11 0x0000561d21a1df7b
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/testing/llvm/bin_main/bin/clang-14+0x32d2f7b)
#12 0x0000561d21a20191
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0)
SelectionDAGISel.cpp:0:0
#13 0x0000561d1f54c7c0 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
X86ISelDAGToDAG.cpp:0:0
#14 0x0000561d1fbe0e38
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/testing/llvm/bin_main/bin/clang-14+0x1495e38)
#15 0x0000561d201462e5 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/testing/llvm/bin_main/bin/clang-14+0x19fb2e5)
#16 0x0000561d20146529 llvm::FPPassManager::runOnModule(llvm::Module&)
(/testing/llvm/bin_main/bin/clang-14+0x19fb529)
#17 0x0000561d20147612 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/testing/llvm/bin_main/bin/clang-14+0x19fc612)
#18 0x0000561d20ce62c3 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/testing/llvm/bin_main/bin/clang-14+0x259b2c3)
#19 0x0000561d21b5b453 clang::CodeGenAction::ExecuteAction()
(/testing/llvm/bin_main/bin/clang-14+0x3410453)
#20 0x0000561d21405b09 clang::FrontendAction::Execute()
(/testing/llvm/bin_main/bin/clang-14+0x2cbab09)
#21 0x0000561d21394b8e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/testing/llvm/bin_main/bin/clang-14+0x2c49b8e)
#22 0x0000561d214e6e53
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/testing/llvm/bin_main/bin/clang-14+0x2d9be53)
#23 0x0000561d1f44da17 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/testing/llvm/bin_main/bin/clang-14+0xd02a17)
#24 0x0000561d1f44a068 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#25 0x0000561d2121f8d9 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#26 0x0000561d208de2dc
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/testing/llvm/bin_main/bin/clang-14+0x21932dc)
#27 0x0000561d2121ffed
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.0) Job.cpp:0:0
#28 0x0000561d211f157b
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/testing/llvm/bin_main/bin/clang-14+0x2aa657b)
#29 0x0000561d211f2089
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/testing/llvm/bin_main/bin/clang-14+0x2aa7089)
#30 0x0000561d211fb999
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/testing/llvm/bin_main/bin/clang-14+0x2ab0999)
#31 0x0000561d1f3c7b9a main (/testing/llvm/bin_main/bin/clang-14+0xc7cb9a)
#32 0x00007fbfabb630b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#33 0x0000561d1f449bde _start (/testing/llvm/bin_main/bin/clang-14+0xcfebde)
clang-14: error: clang frontend command failed with exit code 134 (use -v to
see invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
51715fbd96c100e08ad5e0afe78eff474e4caa3f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /testing/llvm/bin_main/bin
clang-14: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.

C++ Reproducer:
char a;
extern short b[];
extern bool c[];
long d(long f, long g) { return f > g ? f : g; }
void h() {
#pragma clang loop vectorize(enable)
  for (int e = 0; e < a; e += 4)
    c[e] = int(d(-1LL, b[e]));
}

Error:
>$ clang++ -O1 -c func.cpp

clang version 14.0.0 (https://github.com/llvm/llvm-project.git
51715fbd96c100e08ad5e0afe78eff474e4caa3f)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211114/763c14d8/attachment.html>


More information about the llvm-bugs mailing list