Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #280 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Array operations in a template in a different module break LLVM with -g

Reported by: Deewiant Assigned to: lindquist
Priority: major Milestone:
Component: backend Version: hg tip
Keywords: Cc:

Description

Same testcase as in #270, but with -g or -gc thrown, causes LLVM to crash when it's trying to write debug info.

a.d:

import b;

void main() { C!().f; }

b.d:

template C() {
	void f() {
		int[1] x;

		x[] += x[];
	}
}

Compiling just ldc -c -g a.d or ldc -c -gc a.d gives:

ldc: /home/deewiant/src/llvm/src/lib/CodeGen/AsmPrinter/DwarfWriter.cpp:2147: void llvm::DwarfDebug::ConstructFunctionDbgScope(llvm::DbgScope*): Assertion `SPDie && "Missing subprogram descriptor"' failed.
0   ldc             0x0000000000d733df
1   ldc             0x0000000000d737d9
2   libpthread.so.0 0x00007f9a6c9ad920
3   libc.so.6       0x00007f9a6b8a60c5 gsignal + 53
4   libc.so.6       0x00007f9a6b8a75e3 abort + 387
5   libc.so.6       0x00007f9a6b89f0e9 __assert_fail + 233
6   ldc             0x000000000099268f
7   ldc             0x0000000000992861 llvm::DwarfDebug::EndFunction(llvm::MachineFunction*) + 465
8   ldc             0x000000000097c1ac llvm::DwarfWriter::EndFunction(llvm::MachineFunction*) + 28
9   ldc             0x0000000000695e1c
10  ldc             0x0000000000d0fbd9 llvm::FPPassManager::runOnFunction(llvm::Function&) + 489
11  ldc             0x0000000000d105be llvm::FunctionPassManagerImpl::run(llvm::Function&) + 142
12  ldc             0x0000000000d107cb llvm::FunctionPassManager::run(llvm::Function&) + 75
13  ldc             0x0000000000630e11 write_asm_to_file(llvm::TargetMachine&, llvm::Module&, llvm::raw_fd_ostream&) + 401
14  ldc             0x000000000063248e writeModule(llvm::Module*, std::string) + 510
15  ldc             0x0000000000601e84 main + 5940
16  libc.so.6       0x00007f9a6b892546 __libc_start_main + 230
17  ldc             0x000000000055cd29
Stack dump:
0.	Running pass 'X86 AT&T-Style Assembly Printer' on function '@_D1b24_arraySliceSliceAddass_iFAiAiZAi'

The error is from the LLVM trunk but the failure happened also on 2.5.

Attachments

a.bc (5.1 kB) - added by Deewiant on 05/08/09 14:34:09.

Change History

05/08/09 14:33:49 changed by Deewiant

Alright, I think I found the error.

On line 66 of the disassembly of the bitcode of a.d (attached) is the subprogram descriptor for one @_D1b24_arraySliceSliceAddass_iFAiAiZAi, namely llvm.dbg.subprogram14. That function is defined in the current module, yet the subprogram descriptor claims that the global is extern: the last element of the structure is i1 false. Flipping it to i1 true makes LLVM accept it just fine.

It seems to me that LDC doesn't take into account the fact that the template instantiation brings it into the current module, and writes the debug info as though it were defined in b.d.

05/08/09 14:34:09 changed by Deewiant

  • attachment a.bc added.

05/09/09 09:28:08 changed by lindquist

  • status changed from new to closed.
  • resolution set to fixed.

fixed in rev [1322] , thanx for investigating

Copyright © 2008, LDC Development Team.