[llvm-bugs] [Bug 40811] New: A/F: RecNo < RecordedNodes.size() && "Invalid EmitNode", file C:\src\git\merge\llvm\lib\CodeGen\SelectionDAG\SelectionDAGISel.cpp, line 3693 after r354511

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 21 15:27:20 PST 2019


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

            Bug ID: 40811
           Summary: A/F: RecNo < RecordedNodes.size() && "Invalid
                    EmitNode", file
                    C:\src\git\merge\llvm\lib\CodeGen\SelectionDAG\Selecti
                    onDAGISel.cpp, line 3693 after r354511
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: douglas_yung at playstation.sony.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

We started seeing this assertion failure in several of our internal tests which
I bisected down to commit r354511.

Here is a cut down testcase from one of our internal tests that shows the
problem:

/* repro.cpp */
typedef unsigned char uchar;

typedef short __attribute__((ext_vector_type(16))) short16;
typedef int __attribute__((ext_vector_type(8))) int8;
typedef int __attribute__((ext_vector_type(4))) int4;
typedef uchar __attribute__((ext_vector_type(16))) uchar16;

typedef union { short16 a; int8 b; } union_short16_int8;
#define union_short16_int8_b(__A) ((__A.b))
#define int8_wyxx(__A) (__A.wyxx)
typedef union { int4 a; uchar16 b; } union_int4_uchar16;
#define union_int4_uchar16_a(__A) ((__A.a))
#define int8_shr24(__A) (__A >> 24)

//
================================================================================
int8 test70() {
  volatile union_short16_int8 id14795;
  id14795.a =
      (short16){(short)-1470484603, (short)-158280945,  (short)1297854847,
                (short)1159565671,  (short)1805195162,  (short)-1359141492,
                (short)1118726523,  (short)-81078992,   (short)-779406984,
                (short)-1686948886, (short)1582452283,  (short)-335683020,
                (short)544821235,   (short)-1629066267, (short)-195530409,
                (short)1975011310}; // vec_type
  volatile int8 id14794 = union_short16_int8_b(id14795);
  volatile int4 id14793 = int8_wyxx(id14794);
  union_int4_uchar16 id14797;
  id14797.a = (int4){(int)271624746, (int)-1052558824, (int)2076715566,
                     (int)1402199831}; // vec_type
  int4 id14796 = union_int4_uchar16_a(id14797);
  int8 id14792 =
      __builtin_shufflevector(id14793, id14796, 0, 2, 5, 0, 1, 3, 1, 0);
  int8 id14791 = int8_shr24(id14792);
  return id14791;
}


If you build this with optimizations enabled (-O2) and targeting btver2
(-march=btver2), you get an assertion failure:

Command line: clang -c -O2 -march=btver2

Output:
clang-9:
/home/dyung/src/upstream/llvm_clean/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:3613:
void llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, const unsigned
char*, unsigned int): Assertion `RecNo < RecordedNodes.size() && "Invalid
EmitNode"' failed.
Stack dump:
0.      Program arguments: /home/dyung/src/upstream/354517-linux/bin/clang-9
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name
test_1472632898.cpp -mrelocation-model static -mthread-model posix -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu btver2 -dwarf-column-info -debugger-tuning=gdb
-momit-leaf-frame-pointer -coverage-notes-file
/home/dyung/sandbox/random_intrinsics/test_1472632898.gcno -resource-dir
/home/dyung/src/upstream/354517-linux/lib/clang/9.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
-internal-isystem /usr/local/include -internal-isystem
/home/dyung/src/upstream/354517-linux/lib/clang/9.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdeprecated-macro -fdebug-compilation-dir
/home/dyung/sandbox/random_intrinsics -ferror-limit 19 -fmessage-length 0
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-vectorize-loops -vectorize-slp -o test_1472632898.o -x c++
/home/dyung/src/patches/test_1472632898.cpp -faddrsig 
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module
'/home/dyung/src/patches/test_1472632898.cpp'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function
'@_Z6test70v'
 #0 0x000055bb7cae567a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x289f67a)
 #1 0x000055bb7cae3534 llvm::sys::RunSignalHandlers()
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x289d534)
 #2 0x000055bb7cae3672 SignalHandler(int)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x289d672)
 #3 0x00007fab5bf53890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007fab5ae21e97 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x3ee97)
 #5 0x00007fab5ae23801 abort (/lib/x86_64-linux-gnu/libc.so.6+0x40801)
 #6 0x00007fab5ae1339a (/lib/x86_64-linux-gnu/libc.so.6+0x3039a)
 #7 0x00007fab5ae13412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x000055bb7d591de1 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*,
unsigned char const*, unsigned int)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x334bde1)
 #9 0x000055bb7bc4dbe7 (anonymous
namespace)::X86DAGToDAGISel::Select(llvm::SDNode*)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x1a07be7)
#10 0x000055bb7d58c3d2 llvm::SelectionDAGISel::DoInstructionSelection()
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x33463d2)
#11 0x000055bb7d5934a6 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x334d4a6)
#12 0x000055bb7d599053
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x3353053)
#13 0x000055bb7d59b2b7
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(.part.910) (/home/dyung/src/upstream/354517-linux/bin/clang-9+0x33552b7)
#14 0x000055bb7bc54770 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x1a0e770)
#15 0x000055bb7c18879e
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x1f4279e)
#16 0x000055bb7c52f7a9 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x22e97a9)
#17 0x000055bb7c52f859 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x22e9859)
#18 0x000055bb7c52eaf2 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x22e8af2)
#19 0x000055bb7cce98f7 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x2aa38f7)
#20 0x000055bb7cceb2dd 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> >)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x2aa52dd)
#21 0x000055bb7d676075
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x3430075)
#22 0x000055bb7dd56689 clang::ParseAST(clang::Sema&, bool, bool)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x3b10689)
#23 0x000055bb7d674d58 clang::CodeGenAction::ExecuteAction()
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x342ed58)
#24 0x000055bb7d18165e clang::FrontendAction::Execute()
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x2f3b65e)
#25 0x000055bb7d1439f6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x2efd9f6)
#26 0x000055bb7d2259ff
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0x2fdf9ff)
#27 0x000055bb7afd74d8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/dyung/src/upstream/354517-linux/bin/clang-9+0xd914d8)
#28 0x000055bb7af3f4b9 main
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0xcf94b9)
#29 0x00007fab5ae04b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#30 0x000055bb7afd300a _start
(/home/dyung/src/upstream/354517-linux/bin/clang-9+0xd8d00a)
clang-9: error: unable to execute command: Aborted (core dumped)
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0 (trunk 354517)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dyung/src/upstream/354517-linux/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-9: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-9: note: diagnostic msg: /tmp/test_1472632898-c45ef0.cpp
clang-9: note: diagnostic msg: /tmp/test_1472632898-c45ef0.sh
clang-9: note: diagnostic msg: 

********************

-- 
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/20190221/1994a840/attachment-0001.html>


More information about the llvm-bugs mailing list