[llvm-bugs] [Bug 38672] New: LTO results in crash in whole-module-devirtualization with Assertion `hasInitializer() && "GV doesn't have initializer!"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 22 17:28:16 PDT 2018


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

            Bug ID: 38672
           Summary: LTO results in crash in whole-module-devirtualization
                    with Assertion `hasInitializer() && "GV doesn't have
                    initializer!"' failed.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Linker
          Assignee: unassignedbugs at nondot.org
          Reporter: trent.xin.tong at gmail.com
                CC: llvm-bugs at lists.llvm.org

I have a small test case that fails to compile on latest LLVM LTO.

~/llvmtot/build-debug/bin/clang++ main.cpp -c
~/llvmtot/build-debug/bin/clang++ -flto -O3 unknown.cpp -c
~/llvmtot/build-debug/bin/clang++  -flto main.o  unknown.o -o ab -O3

ld: /home/trentxintong/llvmfb/llvm/include/llvm/IR/GlobalVariable.h:142:
llvm::Constant* llvm::GlobalVariable::getInitializer(): Assertion
`hasInitializer() && "GV doesn't have initializer!"' failed.

[~/linkerbug/reduced]$ cat B.hpp 
#include <iostream> 

using namespace std;

template <typename T>
class B {
public:
    B() {}
    virtual void func1() {
      std::cout << "func1 called in class B\n";
    }
};
[~/linkerbug/reduced]$ cat main.cpp 
#include "B.hpp"

void unknown(B<int> *);

int main(int argc, char** argv) {
  B<int> a;
  unknown(&a);
  return 0;
}
[~/linkerbug/reduced]$ cat unknown.cpp 
#include "B.hpp"

__attribute__((optnone))
void unknown2(B<int> *y) {}

void unknown(B<int> *x) {
  B<int> y;
  unknown2(&y);
}

-- 
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/20180823/ef275970/attachment.html>


More information about the llvm-bugs mailing list