Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

codegen crashes with debug info from clang 3.4 #20508

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR20509
Status NEW
Importance P release blocker
Reported by Thomas Pöchtrager (t.poechtrager@gmail.com)
Reported on 2014-08-01 12:33:57 -0700
Last modified on 2014-11-18 15:01:08 -0800
Version trunk
Hardware Macintosh MacOS X
CC aprantl@apple.com, dblaikie@gmail.com, echristo@gmail.com, greened@obbligato.org, llvm-bugs@lists.llvm.org, mren@apple.com, rafael@espindo.la
Fixed by commit(s)
Attachments file_20509.txt (5414 bytes, text/plain)
test.ll (2030 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 12844
backtrace

$ cat test.c
int main() {return 0;}

# Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
$ clang test.c -g -c -flto

# Adjust DYLD_LIBRARY_PATH, so ld64 uses the correct libLTO
$ export DYLD_LIBRARY_PATH=/Users/thomas/llvm-trunk/lib

$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-236.3
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m
armv7em
LTO support using: LLVM version 3.6.0svn

$ ld -arch x86_64 -macosx_version_min 10.9 test.o
Segmentation fault: 11

LLVM rev: 214519. Backtrace is attached.
Quuxplusone commented 10 years ago

Attached file_20509.txt (5414 bytes, text/plain): backtrace

Quuxplusone commented 10 years ago

Any chance to have this fixed before the 3.5 release?

Quuxplusone commented 10 years ago

Attached test.ll (2030 bytes, application/octet-stream): ir testcase

Quuxplusone commented 10 years ago

This is not LTO specific. The attached IR testcase crashes llc:

llc: /home/espindola/llvm/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1598: void llvm::DwarfCompileUnit::createGlobalVariableDIE(llvm::DIGlobalVariable): Assertion `GV.isGlobalVariable()' failed.

It was created with

Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)

Quuxplusone commented 10 years ago

Should probably fail verification and be ignored rather than assert.

Quuxplusone commented 9 years ago

I just hit this with another code. Any progress?

Quuxplusone commented 9 years ago
Reproduced on the 3.5 branch.

In Rafael's testcase the CU's list of global variables is defined as
!2 = metadata !{i32 0}
which fails in createGlobalVariableDIE with
  assert(GV.isGlobalVariable());

on trunk the list is just 2 = !{}.

I think this can be worked around on 3.5 by doing (as Eric suggested):

Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfUnit.cpp    (revision 215556)
+++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp    (working copy)
@@ -1558,7 +1558,8 @@
   if (getDIE(GV))
     return;

-  assert(GV.isGlobalVariable());
+  if (!GV.isGlobalVariable())
+    return;

   DIScope GVContext = GV.getContext();
   DIType GTy = DD->resolve(GV.getType());