<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 - Using -fsanitize-coverage=trace-pc-guards on AArch64: inlinable function call in a function with debug info must have a !dbg location"
   href="https://bugs.llvm.org/show_bug.cgi?id=47876">47876</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Using -fsanitize-coverage=trace-pc-guards on AArch64: inlinable function call in a function with debug info must have a !dbg location
          </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>pierre.langlois@arm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24074" name="attach_24074" title="Tarbal with original repro.cc file, and repro-1cce41.{sh,cpp} files from clang.">attachment 24074</a> <a href="attachment.cgi?id=24074&action=edit" title="Tarbal with original repro.cc file, and repro-1cce41.{sh,cpp} files from clang.">[details]</a></span>
Tarbal with original repro.cc file, and repro-1cce41.{sh,cpp} files from clang.

Clang fails to compile with `-g -O2 -fsanitize-coverage=trace-pc-guard` with a
native AArch64 toolchain. It's interesting that, according to a quick test
using gcc.godbolt.org, the error doesn't appear when using a cross-compiler.

I've reproduced it on trunk, by building it from source on an AArch64 machine.

I get the following backtrace:

~~~
$ ./llvm-project/build//bin/clang++ -g -fsanitize-coverage=trace-pc-guard -O2
-c repro.cc
inlinable function call in a function with debug info must have a !dbg location
  call void @__sanitizer_cov_trace_pc_guard(i32* inttoptr (i64 add (i64
ptrtoint ([8 x i32]* @__sancov_gen_ to i64), i64 12) to i32*)) #3
inlinable function call in a function with debug info must have a !dbg location
  call void @__sanitizer_cov_trace_pc_guard(i32* inttoptr (i64 add (i64
ptrtoint ([8 x i32]* @__sancov_gen_ to i64), i64 12) to i32*)) #3
fatal error: error in backend: Broken module found, compilation aborted!
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.
Stack dump:
0.      Program arguments: ./llvm-project/build//bin/clang++ -g
-fsanitize-coverage=trace-pc-guard -O2 -c repro.cc
1.      <eof> parser at end of file
2.      Code generation
 #0 0x0000aaaacdae0e58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:22
 #1 0x0000aaaacdae0f28 PrintStackTraceSignalHandler(void*)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:630:1
 #2 0x0000aaaacdadee04 llvm::sys::RunSignalHandlers()
/home/pielan01/llvm/llvm-project/llvm/lib/Support/Signals.cpp:71:20
 #3 0x0000aaaacdae05f8 llvm::sys::CleanupOnSignal(unsigned long)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:361:31
 #4 0x0000aaaacda22b2c (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:75:5 
 #5 0x0000aaaacda2335c llvm::CrashRecoveryContext::HandleExit(int)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:442:3
 #6 0x0000aaaacdada5f0 llvm::sys::Process::Exit(int)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/Process.cpp:97:9
 #7 0x0000aaaacae58108 ensureStackAddressSpace()
/home/pielan01/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:132:40
 #8 0x0000aaaacda2b27c llvm::report_fatal_error(llvm::Twine const&, bool)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/ErrorHandling.cpp:108:36
 #9 0x0000aaaacda2b164
llvm::report_fatal_error(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, bool)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/ErrorHandling.cpp:86:77       
#10 0x0000aaaacd147f0c (anonymous
namespace)::VerifierLegacyPass::doFinalization(llvm::Module&)
/home/pielan01/llvm/llvm-project/llvm/lib/IR/Verifier.cpp:5532:12               
#11 0x0000aaaacd084bf8 llvm::FPPassManager::doFinalization(llvm::Module&)
/home/pielan01/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1583:55
#12 0x0000aaaacd085058 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/home/pielan01/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1670:55      
#13 0x0000aaaacd08068c llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/pielan01/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:615:55
#14 0x0000aaaacd085678 llvm::legacy::PassManager::run(llvm::Module&)
/home/pielan01/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1761:17
#15 0x0000aaaacde919f0 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/home/pielan01/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:987:51       
#16 0x0000aaaacde95594 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/pielan01/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1672:27
#17 0x0000aaaacef59e9c
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/pielan01/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:341:24     
#18 0x0000aaaad0a40d30 clang::ParseAST(clang::Sema&, bool, bool)
/home/pielan01/llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:178:14
#19 0x0000aaaace678e5c clang::ASTFrontendAction::ExecuteAction()
/home/pielan01/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1057:11
#20 0x0000aaaacef5740c clang::CodeGenAction::ExecuteAction()
/home/pielan01/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1187:1
#21 0x0000aaaace678844 clang::FrontendAction::Execute()
/home/pielan01/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:954:38
#22 0x0000aaaace615d04
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/pielan01/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984:42 
#23 0x0000aaaace80158c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/pielan01/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38 
#24 0x0000aaaacae58774 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/pielan01/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:240:40
#25 0x0000aaaacae4d920 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/pielan01/llvm/llvm-project/clang/tools/driver/driver.cpp:330:20
#26 0x0000aaaace533fcc
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()::operator()() const
/home/pielan01/llvm/llvm-project/clang/lib/Driver/Job.cpp:404:32                
#27 0x0000aaaace5347d8 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()>(long)
/home/pielan01/llvm/llvm-project/llvm/include/llvm/ADT/STLExtras.h:186:40
#28 0x0000aaaacda167c0 llvm::function_ref<void ()>::operator()() const
/home/pielan01/llvm/llvm-project/llvm/include/llvm/ADT/STLExtras.h:209:62
#29 0x0000aaaacda232f4
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
/home/pielan01/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:425:10 
#30 0x0000aaaace53412c
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const
/home/pielan01/llvm/llvm-project/clang/lib/Driver/Job.cpp:404:21                
#31 0x0000aaaace4ea030
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
/home/pielan01/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:195:22        
#32 0x0000aaaace4ea3ac
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
/home/pielan01/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:246:53        
#33 0x0000aaaace4f7ce0
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
/home/pielan01/llvm/llvm-project/clang/lib/Driver/Driver.cpp:1513:28            
#34 0x0000aaaacae4e524 main
/home/pielan01/llvm/llvm-project/clang/tools/driver/driver.cpp:502:39
#35 0x0000ffff9728d2a4 __libc_start_main
/build/glibc-rOnGPq/glibc-2.29/csu/../csu/libc-start.c:342:3
#36 0x0000aaaacae4c454 _start (./llvm-project/build//bin/clang+++0x2abb454)
clang-12: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
51ff04567b2f8d06b2062bd3ed72eab2e93e4466)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/pielan01/llvm/./llvm-project/build//bin
clang-12: note: diagnostic msg:
********************

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

********************
~~~

I've attached my original reproducer, which I manually reduced from
<a href="https://source.chromium.org/chromium/chromium/src/+/master:v8/src/d8/cov.cc;drc=923375a43504ca7b1db0ab571502e6801ef29d74">https://source.chromium.org/chromium/chromium/src/+/master:v8/src/d8/cov.cc;drc=923375a43504ca7b1db0ab571502e6801ef29d74</a>
which is where I originally noticed the problem.</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>