<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - [ThinLTO] Assertion "Local has more than one summary" fails when two source files have the same name"
   href="https://llvm.org/bugs/show_bug.cgi?id=31561">31561</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ThinLTO] Assertion "Local has more than one summary" fails when two source files have the same name
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>russell_gallop@sn.scee.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>ThinLTO hits an assertion in some cases where two source files have the same
name. Seen at r290351. The same examples work with full LTO and without LTO.

To reproduce (test.cpp and testb.cpp both exhibit this issue):
$ cat test.cpp
struct S {
  S();
};
template <class> struct A { static S GO; };
template <class C> S A<C>::GO;
void fn1() { A<int>::GO; }

$ cat testb.cpp
#include <iostream>

$ cat test.sh
#!/bin/bash -e

CFLAGS="-flto=thin"

# Create two files with the same base name
mkdir -p a
cp $1 a/test.cpp
mkdir -p b
cp $1 b/test.cpp
# Files don't need to be identical
echo "void bar() {}" >> b/test.cpp

cd a
clang++ $CFLAGS -c test.cpp -o test.o
cd ..
cd b
clang++ $CFLAGS -c test.cpp -o testh.o
cd ..

if ! llvm-lto -thinlto-action=run a/test.o b/testh.o 2>&1 > /dev/null | grep
"Local has more than one summary"; then
    exit 0
fi
exit 1

$ ./test.sh test.cpp
test.cpp:6:14: warning: expression result unused [-Wunused-value]
void fn1() { A<int>::GO; }
             ^~~~~~~~~~
1 warning generated.
test.cpp:6:14: warning: expression result unused [-Wunused-value]
void fn1() { A<int>::GO; }
             ^~~~~~~~~~
1 warning generated.
llvm-lto: <snip>/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp:77: bool
llvm::FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(const
llvm::GlobalValue*): Assertion `Summaries->second.size() == 1 && "Local has
more than one summary"' failed.
llvm-lto: <snip>/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp:77: bool
llvm::FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(const
llvm::GlobalValue*): Assertion `Summaries->second.size() == 1 && "Local has
more than one summary"' failed.

$ ./test.sh testb.cpp
llvm-lto: <snip>/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp:77: bool
llvm::FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(const
llvm::GlobalValue*): Assertion `Summaries->second.size() == 1 && "Local has
more than one summary"' failed.
llvm-lto: <snip>/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp:77: bool
llvm::FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(const
llvm::GlobalValue*): Assertion `Summaries->second.size() == 1 && "Local has
more than one summary"' failed.

Failure introduced by this commit, which introduced the assertion which is
firing here.

commit 6e15e36dae54361e9f21b7711ad9bca48923f64a
Author: Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>>
Date:   Thu Nov 3 01:07:16 2016 +0000

    [ThinLTO] Handle distributed backend case when doing renaming

    Summary:
    The recent change I made to consult the summary when deciding whether to
    rename (to handle inline asm) in r285513 broke the distributed build
    case. In a distributed backend we will only have a portion of the
    combined index, specifically for imported modules we only have the
    summaries for any imported definitions. When renaming on import we were
    asserting because no summary entry was found for a local reference being
    linked in (def wasn't imported).

    We only need to consult the summary for a renaming decision for the
    exporting module. For imports, we would have prevented importing any
    references to NoRename values already.

    Reviewers: mehdi_amini

    Subscribers: llvm-commits

    Differential Revision: <a href="https://reviews.llvm.org/D26250">https://reviews.llvm.org/D26250</a>

    git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/trunk@285871">https://llvm.org/svn/llvm-project/llvm/trunk@285871</a></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>