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: unassignedb...@nondot.org
          Reporter: trent.xin.t...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to