From 7ebea86a443a078a9b6ed733a4954b772817a38b Mon Sep 17 00:00:00 2001 From: Ilia Filippov Date: Wed, 2 Apr 2014 15:49:57 +0400 Subject: [PATCH] These changes fix problem with debug info in LLVM 3.4 with structs and enums. The reason of problem is that ISPC generates debugInfo type of struct (or enum) in the scope, where the variable of this type appears. Ctx.cpp:1586 llvm::DIScope scope = GetDIScope(); llvm::DIType diType = sym->type->GetDIType(scope); It is always Lexical_Block in some function. It is not right because type can be declared global or in some function or in some namespace. Struct and enums are failing because they don't reduce to atomic types. The "Big" fix is to save declaration place in Type class. But now ISPC doesn't know about it, for example this doesn't emit an error: void function_1() { struct Foo {float x;}; uniform Foo myFoo;} void function_2() { uniform Foo myFoo;} So now all type declarations are global and we can simply change scope parameter to the current file. The "Big" fix will be after integration with clang. --- type.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/type.cpp b/type.cpp index b6d504f2..082f8910 100644 --- a/type.cpp +++ b/type.cpp @@ -826,7 +826,7 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIFile diFile = pos.GetDIFile(); llvm::DIType diType = - m->diBuilder->createEnumerationType(scope, name, diFile, pos.first_line, + m->diBuilder->createEnumerationType(diFile, name, diFile, pos.first_line, 32 /* size in bits */, 32 /* align in bits */, elementArray @@ -2179,7 +2179,7 @@ StructType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes); llvm::DIFile diFile = pos.GetDIFile(); return m->diBuilder->createStructType( - scope, + diFile, name, diFile, pos.first_line, // Line number @@ -2422,7 +2422,7 @@ UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIFile diFile = pos.GetDIFile(); llvm::DIArray elements; return m->diBuilder->createStructType( - scope, + diFile, name, diFile, pos.first_line, // Line number