Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang failing with "Cannot emit physreg copy instruction" #33804

Open Quuxplusone opened 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR34830
Status NEW
Importance P enhancement
Reported by Hans Wennborg (hans@chromium.org)
Reported on 2017-10-04 10:30:28 -0700
Last modified on 2017-10-05 22:39:07 -0700
Version trunk
Hardware PC Linux
CC babokin@gmail.com, jatin.bhateja@gmail.com, llvm-bugs@lists.llvm.org, nicolasweber@gmx.de
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
From Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=771670

FAILED: obj/third_party/sqlite/chromium_sqlite3/sqlite3.o
export DEVELOPER_DIR=/b/c/builder/ClangToTMac/src/build/mac_files/Xcode.app;
../../third_party/llvm-build/Release+Asserts/bin/clang -MMD -MF
obj/third_party/sqlite/chromium_sqlite3/sqlite3.o.d -DSQLITE_ENABLE_FTS3 -
DSQLITE_DISABLE_FTS3_UNICODE -DSQLITE_DISABLE_FTS4_DEFERRED -DSQLITE_ENABLE_ICU
-DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_SECURE_DELETE -
DSQLITE_SEPARATE_CACHE_POOLS -DSQLITE_THREADSAFE=1 -
DSQLITE_MAX_WORKER_THREADS=0 -DSQLITE_MAX_MMAP_SIZE=268435456 -
DSQLITE_MMAP_READ_ONLY=1 -DSQLITE_DEFAULT_PCACHE_INITSZ=0 -
DSQLITE_API=__attribute__\(\(visibility\(\"default\"\)\)\) -DHAVE_USLEEP=1 -
DUSE_PREAD=1 -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -DFULL_SAFE_BROWSING -
DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -
DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"314905\" -
DCR_XCODE_VERSION=0832 -DCOMPONENT_BUILD -
D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DNDEBUG -DNVALGRIND -
DDYNAMIC_ANNOTATIONS_ENABLED=0 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -
DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DUCHAR_TYPE=uint16_t -
I../../third_party/sqlite/amalgamation -I../.. -Igen -
I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -fno-
strict-aliasing -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -
D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -Xclang -mllvm -Xclang -
instcombine-lower-dbg-declare=1 -arch x86_64 -O2 -fno-omit-frame-pointer -g1 -
isysroot
../../build/mac_files/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-mmacosx-version-min=10.9.0 -fvisibility=hidden -Wheader-hygiene -Wstring-
conversion -Wtautological-overlap-compare -Werror -Wall -Wno-unused-variable -
Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -
Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-
declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-
nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-
capture -Wno-user-defined-warnings -Wno-enum-compare-switch -Wno-tautological-
unsigned-zero-compare -Wno-null-pointer-arithmetic -Wno-tautological-unsigned-
enum-zero-compare -Wno-unused-function -std=c11 -c
../../third_party/sqlite/amalgamation/sqlite3.c -o
obj/third_party/sqlite/chromium_sqlite3/sqlite3.o
Cannot emit physreg copy instruction
UNREACHABLE executed at
/b/c/builder/ClangToTMac/src/third_party/llvm/lib/Target/X86/X86InstrInfo.cpp:6760!
0  clang-6.0                0x0000000108e94fc8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  clang-6.0                0x0000000108e956c6
llvm::sys::PrintStackTraceOnErrorSignal(llvm::StringRef, bool) + 838
2  libsystem_platform.dylib 0x00007fffebb66bba _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff5868b860 _sigtramp + 1823624384
4  libsystem_c.dylib        0x00007fffeb9ed420 abort + 129
5  clang-6.0                0x0000000108e20ad7
llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 471
6  clang-6.0                0x00000001081737d9
llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&,
llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc
const&, unsigned int, unsigned int, bool) const + 6409
7  clang-6.0                0x00000001084d2119
llvm::initializeExpandPostRAPass(llvm::PassRegistry&) + 3737
8  clang-6.0                0x00000001085ae294
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 180
9  clang-6.0                0x000000010889efd3
llvm::FPPassManager::runOnFunction(llvm::Function&) + 547
10 clang-6.0                0x000000010889f233
llvm::FPPassManager::runOnModule(llvm::Module&) + 51
11 clang-6.0                0x000000010889f77e
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 958
12 clang-6.0                0x00000001090ce7c3
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions
const&, clang::CodeGenOptions const&, clang::TargetOptions const&,
clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*,
clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream,
std::__1::default_delete<llvm::raw_pwrite_stream> >) + 15571
13 clang-6.0                0x0000000109329175
clang::EmitObjAction::EmitObjAction(llvm::LLVMContext*) + 2341
14 clang-6.0                0x0000000109dac495 clang::ParseAST(clang::Sema&,
bool, bool) + 469
15 clang-6.0                0x00000001095bcfcc clang::FrontendAction::Execute()
+ 76
16 clang-6.0                0x0000000109575cf1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1217
17 clang-6.0                0x00000001096244ba
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4970
18 clang-6.0                0x0000000107575367 cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 1399
19 clang-6.0                0x00000001075739ef main + 11951
20 libdyld.dylib            0x00007fffeb959255 start + 1
21 libdyld.dylib            0x00000000000000ac start + 342519384
Stack dump:
0.  Program arguments: /b/c/builder/ClangToTMac/src/third_party/llvm-
build/Release+Asserts/bin/clang-6.0 -cc1 -triple x86_64-apple-macosx10.9.0 -
Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -disable-
free -main-file-name sqlite3.c -mrelocation-model pic -pic-level 2 -mthread-
model posix -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -
faligned-alloc-unavailable -target-cpu core2 -dwarf-column-info -debug-info-
kind=line-tables-only -dwarf-version=2 -debugger-tuning=lldb -target-linker-
version 274.1 -coverage-notes-file
/b/c/builder/ClangToTMac/src/out/Release/obj/third_party/sqlite/chromium_sqlite3/sqlite3.gcno
-resource-dir /b/c/builder/ClangToTMac/src/third_party/llvm-
build/Release+Asserts/lib/clang/6.0.0 -dependency-file
obj/third_party/sqlite/chromium_sqlite3/sqlite3.o.d -MT
obj/third_party/sqlite/chromium_sqlite3/sqlite3.o -isysroot
../../build/mac_files/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-D SQLITE_ENABLE_FTS3 -D SQLITE_DISABLE_FTS3_UNICODE -D
SQLITE_DISABLE_FTS4_DEFERRED -D SQLITE_ENABLE_ICU -D
SQLITE_ENABLE_MEMORY_MANAGEMENT -D SQLITE_SECURE_DELETE -D
SQLITE_SEPARATE_CACHE_POOLS -D SQLITE_THREADSAFE=1 -D
SQLITE_MAX_WORKER_THREADS=0 -D SQLITE_MAX_MMAP_SIZE=268435456 -D
SQLITE_MMAP_READ_ONLY=1 -D SQLITE_DEFAULT_PCACHE_INITSZ=0 -D
SQLITE_API=__attribute__((visibility("default"))) -D HAVE_USLEEP=1 -D
USE_PREAD=1 -D V8_DEPRECATION_WARNINGS -D NO_TCMALLOC -D FULL_SAFE_BROWSING -D
SAFE_BROWSING_CSD -D SAFE_BROWSING_DB_LOCAL -D CHROMIUM_BUILD -D
FIELDTRIAL_TESTING_ENABLED -D CR_CLANG_REVISION="314905" -D
CR_XCODE_VERSION=0832 -D COMPONENT_BUILD -D
__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -D NDEBUG -D NVALGRIND -D
DYNAMIC_ANNOTATIONS_ENABLED=0 -D U_USING_ICU_NAMESPACE=0 -D U_ENABLE_DYLOAD=0 -
D ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -D UCHAR_TYPE=uint16_t -I
../../third_party/sqlite/amalgamation -I ../.. -I gen -I
../../third_party/icu/source/common -I ../../third_party/icu/source/i18n -D
__DATE__= -D __TIME__= -D __TIMESTAMP__= -O2 -Wno-builtin-macro-redefined -
Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Werror -
Wall -Wno-unused-variable -Wunguarded-availability -Wno-missing-field-
initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-
default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -
Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-
member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-
switch -Wno-tautological-unsigned-zero-compare -Wno-null-pointer-arithmetic -
Wno-tautological-unsigned-enum-zero-compare -Wno-unused-function -std=c11 -
fdebug-compilation-dir /b/c/builder/ClangToTMac/src/out/Release -ferror-limit
19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fblocks -fencode-
extended-block-signature -fobjc-runtime=macosx-10.9.0 -fmax-type-align=16 -
fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -
mllvm -instcombine-lower-dbg-declare=1 -o
obj/third_party/sqlite/chromium_sqlite3/sqlite3.o -x c
../../third_party/sqlite/amalgamation/sqlite3.c
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module
'../../third_party/sqlite/amalgamation/sqlite3.c'.
4.  Running pass 'Post-RA pseudo instruction expansion pass' on function
'@walIndexWriteHdr'
clang-6.0: error: unable to execute command: Abort trap: 6
clang-6.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0 (trunk 314905)
Target: x86_64-apple-darwin16.3.0
Thread model: posix
InstalledDir: /b/c/builder/ClangToTMac/src/out/Release/../../third_party/llvm-
build/Release+Asserts/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-6.0: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /b/rr/tmpTs51JE/t/sqlite3-74212c.c
clang-6.0: note: diagnostic msg: /b/rr/tmpTs51JE/t/sqlite3-74212c.sh
clang-6.0: note: diagnostic msg: /b/rr/tmpTs51JE/t/sqlite3-74212c.crash
clang-6.0: note: diagnostic msg:
********************
Quuxplusone commented 7 years ago

Repro is here: https://bugs.chromium.org/p/chromium/issues/detail?id=771670#c3

Quuxplusone commented 7 years ago

Bisection points to r314886. Reverted in r314919.

Quuxplusone commented 7 years ago

Currently running creduce, but I expect it will take a while because sqlite is a big file.

Quuxplusone commented 7 years ago

Here's another repro that also started crashing at that revisions: https://bugs.chromium.org/p/chromium/issues/detail?id=771676#c3

Please check that one too before relanding.

Quuxplusone commented 7 years ago

Here's yet another one, this time in 32-bit: https://bugs.chromium.org/p/chromium/issues/detail?id=771673#c3

Quuxplusone commented 7 years ago
Reduced test case for the sqlite failure:

typedef struct WalIndexHdr WalIndexHdr;
struct WalIndexHdr {
  int iVersion;
  char isInit;
  int mxFrame;
  int aSalt[2];
  int aCksum
};
struct Wal {
  short readLock;
  WalIndexHdr hdr
} walChecksumBytes(int nativeCksum, char *a, nByte, aIn, *aOut) {
  int s1, s2, aEnd = &a[nByte];
  int *aData = a;
  s1 = s2 = 0;
  do {
    s1 += *aData++ + s2;
    s2 += *aData++ + s1;
  } while (aData < aEnd);
  aOut[1] = s2;
}

sqlite3WalFrames() {
  struct Wal *pWal = 0;
  int nCksum = __builtin_offsetof(WalIndexHdr, aCksum);
  pWal->hdr.iVersion = 07000;
  walChecksumBytes(1, &pWal->hdr, nCksum, 0, pWal);
}

$ bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -target-cpu x86-64 -
O2 -w /tmp/a.i
Cannot emit physreg copy instruction
UNREACHABLE executed at ../lib/Target/X86/X86InstrInfo.cpp:6750!
#0 0x000000000215ee7a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(bin/clang+0x215ee7a)
#1 0x000000000215ceee llvm::sys::RunSignalHandlers() (bin/clang+0x215ceee)
#2 0x000000000215d052 SignalHandler(int) (bin/clang+0x215d052)
#3 0x00007f4c651e8330 __restore_rt (/lib/x86_64-linux-
gnu/libpthread.so.0+0x10330)
#4 0x00007f4c63fd8c37 gsignal /build/eglibc-SvCtMH/eglibc-
2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f4c63fdc028 abort /build/eglibc-SvCtMH/eglibc-2.19/stdlib/abort.c:91:0
#6 0x000000000210def5 (bin/clang+0x210def5)
#7 0x0000000001695bd8 llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&,
llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc
const&, unsigned int, unsigned int, bool) const (bin/clang+0x1695bd8)
#8 0x0000000001b76b17 (anonymous
namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&)
(bin/clang+0x1b76b17)
#9 0x00000000019ecc05 llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(bin/clang+0x19ecc05)
#10 0x0000000001cfd7a3 llvm::FPPassManager::runOnFunction(llvm::Function&)
(bin/clang+0x1cfd7a3)
#11 0x0000000001cfd84c llvm::FPPassManager::runOnModule(llvm::Module&)
(bin/clang+0x1cfd84c)
#12 0x0000000001cfe5ef llvm::legacy::PassManagerImpl::run(llvm::Module&)
(bin/clang+0x1cfe5ef)
#13 0x00000000022ee5ae (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) (bin/clang+0x22ee5ae)
#14 0x00000000022ef88f 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> >) (bin/clang+0x22ef88f)
#15 0x00000000029e75bb
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(bin/clang+0x29e75bb)
#16 0x0000000002de7a62 clang::ParseAST(clang::Sema&, bool, bool)
(bin/clang+0x2de7a62)
#17 0x00000000029e6bff clang::CodeGenAction::ExecuteAction()
(bin/clang+0x29e6bff)
#18 0x0000000002693996 clang::FrontendAction::Execute() (bin/clang+0x2693996)
#19 0x000000000266b33e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(bin/clang+0x266b33e)
#20 0x000000000272489b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (bin/clang+0x272489b)
#21 0x0000000000bde4f8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (bin/clang+0xbde4f8)
#22 0x0000000000b74384 main (bin/clang+0xb74384)
#23 0x00007f4c63fc3f45 __libc_start_main /build/eglibc-SvCtMH/eglibc-
2.19/csu/libc-start.c:321:0
#24 0x0000000000bd9ae9 _start (bin/clang+0xbd9ae9)
Stack dump:
0.      Program arguments: bin/clang -cc1 -triple x86_64-unknown-linux-gnu -
emit-obj -target-cpu x86-64 -O2 -w /tmp/a.i
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/tmp/a.i'.
4.      Running pass 'Post-RA pseudo instruction expansion pass' on function
'@sqlite3WalFrames'
Aborted (core dumped)
Quuxplusone commented 7 years ago
Two more handy reproducers:

> cat f1.cpp
char a, b;
int c, d, e;
short f;
void g() {
  f = !a &&
      (d - 1) * e + (!(c << 2048 - 2032) == a) - 13906 -
              -(!(c << 2048 - 2032) == 0) >=
          (d - 1) * e + (!(c << 2048 - 2032) == a) - 13906 - b;
}

> cat f2.cpp
bool a;
char b, f, c, d;
int e, g;
void h() {
  if (b * (-(8 - c - (f % 4 && a - b)) + (f % 4 && a - b)))
    d = g;
  e = -(8 - c - (f % 4 && a - b));
}

To compile just run -O2 compilation.