<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 - Dumping PBQP (regalloc) Graphs runs into an assertion due to long file name"
   href="https://bugs.llvm.org/show_bug.cgi?id=37877">37877</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Dumping PBQP (regalloc) Graphs runs into an assertion due to long file name
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Register Allocator
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mail@nicohartmann.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20449" name="attach_20449" title="Input file">attachment 20449</a> <a href="attachment.cgi?id=20449&action=edit" title="Input file">[details]</a></span>
Input file

Running llc with -pbqp-dump-graphs (and -regalloc=pbqp) asserts due to the
generated filename for the dump file exceeding the maximum file length.

The name of each dump file includes the function's mangled name, which can be
longer than maximum file name length for different reasons (first appeared for
me with a function taking a variant<> as an argument, reproduced it in the
attached example with a very long class name though).

Opening/creating the file through the raw_fd_ostream results in open returning
ENAMETOOLONG (openFile in Path.inc). This failure is silently ignored, however.

Attempting to write to the raw_fd_ostream then triggers the assertion in
raw_fd_ostream::preferred_buffer_size() (raw_ostream.cpp) due to FD still being
-1.

See following stack trace and attached minimal complete verifiable example.

Stack dump:
0.      Program arguments: ../bin/llc -O3 -regalloc=pbqp -pbqp-dump-graphs -o
mcve.o mcve.ll 
1.      Running pass 'Function Pass Manager' on module 'mcve.ll'.
2.      Running pass 'PBQP Register Allocator' on function
'@_Z3barP577Lorem_ipsum_dolor_sit_amet_consetetur_sadipscing_elitr_sed_diam_nonumy_eirmod_tempor_invidunt_ut_labore_et_dolore_magna_aliquyam_erat_sed_diam_voluptua_At_vero_eos_et_accusam_et_justo_duo_dolores_et_ea_rebum_Stet_clita_kasd_gubergren_no_sea_takimata_sanctus_est_Lorem_ipsum_dolor_sit_amet_Lorem_ipsum_dolor_sit_amet_consetetur_sadipscing_elitr_sed_diam_nonumy_eirmod_tempor_invidunt_ut_labore_et_dolore_magna_aliquyam_erat_sed_diam_voluptua_At_vero_eos_et_accusam_et_justo_duo_dolores_et_ea_rebum_Stet_clita_kasd_gubergren_no_sea_takimata_sanctus_est_Lorem_ipsum_dolor_sit_amet'
#0 0x00007fde463e493d llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/nico/Projects/llvm/lib/Support/Unix/Signals.inc:488:0
#1 0x00007fde463e49d0 PrintStackTraceSignalHandler(void*)
/home/nico/Projects/llvm/lib/Support/Unix/Signals.inc:552:0
#2 0x00007fde463e2d0e llvm::sys::RunSignalHandlers()
/home/nico/Projects/llvm/lib/Support/Signals.cpp:67:0
#3 0x00007fde463e4360 SignalHandler(int)
/home/nico/Projects/llvm/lib/Support/Unix/Signals.inc:351:0
#4 0x00007fde451def20 (/lib/x86_64-linux-gnu/libc.so.6+0x3ef20)
#5 0x00007fde451dee97 gsignal
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#6 0x00007fde451e0801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
#7 0x00007fde451d039a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
#8 0x00007fde451d0412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
#9 0x00007fde463b2476 llvm::raw_fd_ostream::preferred_buffer_size() const
/home/nico/Projects/llvm/lib/Support/raw_ostream.cpp:703:0
#10 0x00007fde463b03e3 llvm::raw_ostream::SetBuffered()
/home/nico/Projects/llvm/lib/Support/raw_ostream.cpp:85:0
#11 0x00007fde463b0c17 llvm::raw_ostream::write(char const*, unsigned long)
/home/nico/Projects/llvm/lib/Support/raw_ostream.cpp:233:0
#12 0x00007fde4630f55c void write_unsigned_impl<unsigned
int>(llvm::raw_ostream&, unsigned int, unsigned long, llvm::IntegerStyle, bool)
/home/nico/Projects/llvm/lib/Support/NativeFormatting.cpp:75:0
#13 0x00007fde4630f26d void write_unsigned<unsigned long>(llvm::raw_ostream&,
unsigned long, unsigned long, llvm::IntegerStyle, bool)
/home/nico/Projects/llvm/lib/Support/NativeFormatting.cpp:86:0
#14 0x00007fde4630ec0f llvm::write_integer(llvm::raw_ostream&, unsigned long,
unsigned long, llvm::IntegerStyle)
/home/nico/Projects/llvm/lib/Support/NativeFormatting.cpp:117:0
#15 0x00007fde463b0568 llvm::raw_ostream::operator<<(unsigned long)
/home/nico/Projects/llvm/lib/Support/raw_ostream.cpp:113:0
#16 0x00007fde483a4dbd llvm::raw_ostream::operator<<(unsigned int)
/home/nico/Projects/llvm/include/llvm/Support/raw_ostream.h:207:0
#17 0x00007fde487c453c PrintNodeInfo(unsigned int,
llvm::PBQP::RegAlloc::PBQPRAGraph
const&)::'lambda'(llvm::raw_ostream&)::operator()(llvm::raw_ostream&) const
/home/nico/Projects/llvm/lib/CodeGen/RegAllocPBQP.cpp:884:0
#18 0x00007fde487c5721 std::_Function_handler<void (llvm::raw_ostream&),
PrintNodeInfo(unsigned int, llvm::PBQP::RegAlloc::PBQPRAGraph
const&)::'lambda'(llvm::raw_ostream&)>::_M_invoke(std::_Any_data const&,
llvm::raw_ostream&) /usr/include/c++/7/bits/std_function.h:318:0
#19 0x00007fde4a2009f5 std::function<void
(llvm::raw_ostream&)>::operator()(llvm::raw_ostream&) const
/usr/include/c++/7/bits/std_function.h:706:0
#20 0x00007fde483a5280 llvm::operator<<(llvm::raw_ostream&, llvm::Printable
const&) /home/nico/Projects/llvm/include/llvm/Support/Printable.h:47:0
#21 0x00007fde487c4785
llvm::PBQP::RegAlloc::PBQPRAGraph::dump(llvm::raw_ostream&) const
/home/nico/Projects/llvm/lib/CodeGen/RegAllocPBQP.cpp:893:0
#22 0x00007fde487c42ab (anonymous
namespace)::RegAllocPBQP::runOnMachineFunction(llvm::MachineFunction&)
/home/nico/Projects/llvm/lib/CodeGen/RegAllocPBQP.cpp:852:0
#23 0x00007fde486293b1
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
/home/nico/Projects/llvm/lib/CodeGen/MachineFunctionPass.cpp:62:0
#24 0x00007fde47b4543c llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/nico/Projects/llvm/lib/IR/LegacyPassManager.cpp:1581:0
#25 0x00007fde47b455fb llvm::FPPassManager::runOnModule(llvm::Module&)
/home/nico/Projects/llvm/lib/IR/LegacyPassManager.cpp:1603:0
#26 0x00007fde47b459a6 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/home/nico/Projects/llvm/lib/IR/LegacyPassManager.cpp:1660:0
#27 0x00007fde47b460f3 llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/nico/Projects/llvm/lib/IR/LegacyPassManager.cpp:1764:0
#28 0x00007fde47b462eb llvm::legacy::PassManager::run(llvm::Module&)
/home/nico/Projects/llvm/lib/IR/LegacyPassManager.cpp:1796:0
#29 0x000056048385c346 compileModule(char**, llvm::LLVMContext&)
/home/nico/Projects/llvm/tools/llc/llc.cpp:592:0
#30 0x000056048385a963 main /home/nico/Projects/llvm/tools/llc/llc.cpp:349:0
#31 0x00007fde451c1b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#32 0x00005604838586ca _start (../bin/llc+0x276ca)
Aborted (core dumped)</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>