Created attachment 17610 [details] Reduced testcase with stackstrace and run script When compiling the attached reduced test case, current clang segfaults with 1. <eof> parser at end of file 2. Per-module optimization passes 3. Running pass 'Global Variable Optimizer' on module 'report.ii'. Segmentation fault (core dumped) Full diagnostics in attached test case It seems that the creation of a static variable after the assert() triggers this.
$ ./clang blah.cpp -O0 -emit-llvm -c -std=c++1y produces a module which doesn't pass the verifier. ``` Global is referenced by parentless instruction! i64* @_ZGVZNK3Baz3fooERKNSt3__110shared_ptrI3FooEEE5stFoo ; ModuleID = 'blah.cpp' <badref> = load atomic i8, i8* bitcast (i64* @_ZGVZNK3Baz3fooERKNSt3__110shared_ptrI3FooEEE5stFoo to i8*) acquire, align 8 fatal error: error in backend: Broken module found, compilation aborted! ``` so it could be a bug in the frontend. CC:ing Richard Smith.
We only run `Add DWARF path discriminators` before the verifier runs. I wasn't able to reproduce with `opt` standalone.
This is even easier and seems to trigger the same problem: struct A { ~A(); }; void f(){ return; static A k; }
Seemed easy enough to fix: https://reviews.llvm.org/D28505
Fix landed in clang r291576