stage2: add debug info for globals in the LLVM backend

LLVM backend: generate DIGlobalVariable's for non-function globals and
rename linkage names when exporting functions and globals.

zig_llvm.cpp: add some wrappers to convert a handful of DI classes
into DINode's since DIGlobalVariable is not a DIScope like the others.

zig_llvm.cpp: add some wrappers to allow replacing the LinkageName of
DISubprogram and DIGlobalVariable.

zig_llvm.cpp: fix DI class mixup causing nonsense reinterpret_cast.

The end result is that GDB is now usable since you now no longer need
to manually cast every global nor fully qualify every export.
This commit is contained in:
William Sengir
2022-03-13 00:28:34 -07:00
committed by Andrew Kelley
parent f36bf8506c
commit c757f19790
5 changed files with 150 additions and 8 deletions

View File

@@ -663,7 +663,7 @@ pub const Decl = struct {
return (try decl.typedValue()).val;
}
pub fn isFunction(decl: *Decl) !bool {
pub fn isFunction(decl: Decl) !bool {
const tv = try decl.typedValue();
return tv.ty.zigTypeTag() == .Fn;
}