<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - A/F: RecNo < RecordedNodes.size() && "Invalid EmitNode", file C:\src\git\merge\llvm\lib\CodeGen\SelectionDAG\SelectionDAGISel.cpp, line 3693 after r354511"
   href="https://bugs.llvm.org/show_bug.cgi?id=40811">40811</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>A/F: RecNo < RecordedNodes.size() && "Invalid EmitNode", file C:\src\git\merge\llvm\lib\CodeGen\SelectionDAG\SelectionDAGISel.cpp, line 3693 after r354511
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>douglas_yung@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> 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: 

********************</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>