[llvm-bugs] [Bug 48379] New: aarch64: Some casting/shifting of __uint128_t hits an UNREACHABLE after regalloc in AArch64InstrInfo::copyPhysReg
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Dec 3 13:41:12 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48379
Bug ID: 48379
Summary: aarch64: Some casting/shifting of __uint128_t hits an
UNREACHABLE after regalloc in
AArch64InstrInfo::copyPhysReg
Product: libraries
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: AArch64
Assignee: unassignedbugs at nondot.org
Reporter: nathan at lanza.io
CC: arnaud.degrandmaison at arm.com,
llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
Ties.Stuij at arm.com
The following code hits an error with clang11 when compiled as so:
```
clang++ -march=armv8-a -target aarch64-none-linux-android21 file.cpp
```
```
long multiply() {
auto a = static_cast<__uint128_t>(0);
return (static_cast<unsigned long>(a) & (1ULL << 63)) != 0 ? a : a;
}
```
Here' the IR that is generated via `-S -emit-llvm`:
```
; ModuleID = 'third-party/fmt/fmt/src/format.cc'
source_filename = "third-party/fmt/fmt/src/format.cc"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-none-linux-android21"
; Function Attrs: noinline nounwind optnone
define dso_local i64 @_Z8multiplyv() #0 {
entry:
%a = alloca i128, align 16
store i128 0, i128* %a, align 16
%0 = load i128, i128* %a, align 16
%conv = trunc i128 %0 to i64
%and = and i64 %conv, -9223372036854775808
%cmp = icmp ne i64 %and, 0
br i1 %cmp, label %cond.true, label %cond.false
cond.true: ; preds = %entry
%1 = load i128, i128* %a, align 16
br label %cond.end
cond.false: ; preds = %entry
%2 = load i128, i128* %a, align 16
br label %cond.end
cond.end: ; preds = %cond.false,
%cond.true
%cond = phi i128 [ %1, %cond.true ], [ %2, %cond.false ]
%conv1 = trunc i128 %cond to i64
ret i64 %conv1
}
attributes #0 = { noinline nounwind optnone
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"frame-pointer"="non-leaf" "less-precise-fpmad"="false"
"min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false"
"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
"no-trapping-math"="true" "stack-protector-buffer-size"="8"
"target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false"
"use-soft-float"="false" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!"Facebook clang version 11.0.1 (llvm:
81c8deff8cbad869e7238842ebf9c94f3220a73d, cfe:
81c8deff8cbad869e7238842ebf9c94f3220a73d, compiler-rt:
81c8deff8cbad869e7238842ebf9c94f3220a73d, lld:
81c8deff8cbad869e7238842ebf9c94f3220a73d)"}
```
Here's the error:
```
unimplemented reg-to-reg copy
UNREACHABLE executed at
/mnt/btrfs/trunk-grepo-llvm-c2-122478666-1604424455/external/llvm-project/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:3012!
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:
/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang++
-march=armv8-a -target aarch64-none-linux-android21 -c
third-party/fmt/fmt/src/format.cc
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module
'third-party/fmt/fmt/src/format.cc'.
4. Running pass 'Post-RA pseudo instruction expansion pass' on function
'@_Z8multiplyv'
#0 0x00000000039dedcf llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x39dedcf)
#1 0x00000000039dcfd0 llvm::sys::RunSignalHandlers()
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x39dcfd0)
#2 0x00000000039de46d llvm::sys::CleanupOnSignal(unsigned long)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x39de46d)
#3 0x0000000003967203
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x3967203)
#4 0x0000000003967356
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x3967356)
#5 0x00007fcb272e4b80 __restore_rt
(/usr/local/fbcode/platform007/lib/libpthread.so.0+0x12b80)
#6 0x00007fcb25de80ff raise
/home/engshare/third-party2/glibc/2.26/src/glibc-2.26/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#7 0x00007fcb25dd1935 abort
/home/engshare/third-party2/glibc/2.26/src/glibc-2.26/stdlib/abort.c:92:7
#8 0x000000000396bee1
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x396bee1)
#9 0x0000000002586d29
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x2586d29)
#10 0x00000000031d0660
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x31d0660)
#11 0x0000000002fdcece
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x2fdcece)
#12 0x00000000033951c1 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x33951c1)
#13 0x000000000339b508 llvm::FPPassManager::runOnModule(llvm::Module&)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x339b508)
#14 0x000000000339581e llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x339581e)
#15 0x0000000003bdbf5d clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x3bdbf5d)
#16 0x000000000434b08f
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x434b08f)
#17 0x0000000005197933 clang::ParseAST(clang::Sema&, bool, bool)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x5197933)
#18 0x000000000429bc34 clang::FrontendAction::Execute()
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x429bc34)
#19 0x0000000004217ec3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x4217ec3)
#20 0x0000000004345808
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x4345808)
#21 0x00000000024d4f49 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x24d4f49)
#22 0x00000000024d3239
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x24d3239)
#23 0x000000000411e242
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x411e242)
#24 0x0000000003967121
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x3967121)
#25 0x000000000411d71d
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x411d71d)
#26 0x00000000040f21a5
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x40f21a5)
#27 0x00000000040f2587
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x40f2587)
#28 0x00000000041057ec
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x41057ec)
#29 0x00000000024d2b6e main
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x24d2b6e)
#30 0x00007fcb25dd21a6 __libc_start_main
/home/engshare/third-party2/glibc/2.26/src/glibc-2.26/csu/../csu/libc-start.c:342:3
#31 0x00000000024d014a _start
(/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin/clang+++0x24d014a)
clang++: error: clang frontend command failed due to signal (use -v to see
invocation)
Facebook clang version 11.0.1 (llvm: 81c8deff8cbad869e7238842ebf9c94f3220a73d,
cfe: 81c8deff8cbad869e7238842ebf9c94f3220a73d, compiler-rt:
81c8deff8cbad869e7238842ebf9c94f3220a73d, lld:
81c8deff8cbad869e7238842ebf9c94f3220a73d)
Target: aarch64-none-linux-android21
Thread model: posix
InstalledDir:
/data/users/lanza/fbsource/buck-out/gen/fe3a39b8/xplat/toolchains/android/ndk/linux-llvm-11-asserts-cxx-arm64#link-tree/xplat/toolchains/android/ndk/llvm_toolchain/bin
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/format-635961.cpp
clang++: note: diagnostic msg: /tmp/format-635961.sh
clang++: note: diagnostic msg:
********************
```
Here's `I->getParent()->getParent()->dump()` at the point of the crash
```
# Machine code for function _Z8multiplyv: NoPHIs, TracksLiveness, NoVRegs,
Legalized, RegBankSelected, Selected, TiedOpsRewritten
Frame Objects:
fi#0: size=16, align=16, at location [SP-16]
fi#1: size=8, align=8, at location [SP-24]
bb.1.entry:
successors: %bb.2(0x40000000), %bb.3(0x40000000); %bb.2(50.00%),
%bb.3(50.00%)
$sp = frame-setup SUBXri $sp, 32, 0
$x8 = ORRXrr $xzr, $xzr
renamable $q0 = IMPLICIT_DEF
renamable $q0 = INSvi64gpr renamable $q0(tied-def 0), 0, renamable $x8
renamable $q0 = INSvi64gpr renamable $q0(tied-def 0), 1, killed renamable $x8
STRQui killed renamable $q0, $sp, 1 :: (store 16 into %ir.a)
renamable $q0 = LDRQui $sp, 1 :: (dereferenceable load 16 from %ir.a)
$w0 = FMOVSWr $s0, implicit killed $q0
renamable $x8 = COPY killed renamable $w0
TBZX killed renamable $x8, 63, %bb.3
bb.2.cond.true:
; predecessors: %bb.1
successors: %bb.4(0x80000000); %bb.4(100.00%)
renamable $q0 = LDRQui $sp, 1 :: (dereferenceable load 16 from %ir.a)
renamable $d1 = COPY renamable $d0
renamable $d2 = CPYi64 killed renamable $q0, 1
STRDui killed $d1, $sp, 1 :: (store 8 into %stack.1)
B %bb.4
bb.3.cond.false:
; predecessors: %bb.1
successors: %bb.4(0x80000000); %bb.4(100.00%)
renamable $q0 = LDRQui $sp, 1 :: (dereferenceable load 16 from %ir.a)
renamable $d1 = COPY renamable $d0
renamable $d2 = CPYi64 killed renamable $q0, 1
STRDui killed $d1, $sp, 1 :: (store 8 into %stack.1)
bb.4.cond.end:
; predecessors: %bb.3, %bb.2
$d0 = LDRDui $sp, 1 :: (load 8 from %stack.1)
$x0 = COPY killed renamable $d0
$sp = frame-destroy ADDXri $sp, 32, 0
RET_ReallyLR implicit killed $x0
# End machine code for function _Z8multiplyv.
```
Here's `I->dump()`
```
renamable $x8 = COPY killed renamable $w0
```
--
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/20201203/47b15667/attachment-0001.html>
More information about the llvm-bugs
mailing list