aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig15
-rw-r--r--src/codegen/llvm.zig26
2 files changed, 5 insertions, 36 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 58bf919b1f..3f3147ca80 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -215,7 +215,7 @@ pub const DeclGen = struct {
val: Value,
decl: *Decl,
) error{ OutOfMemory, AnalysisFail }!void {
- markDeclAlive(decl);
+ decl.markAlive();
if (ty.isSlice()) {
try writer.writeByte('(');
@@ -253,19 +253,6 @@ pub const DeclGen = struct {
try dg.renderDeclName(decl, writer);
}
- fn markDeclAlive(decl: *Decl) void {
- if (decl.alive) return;
- decl.alive = true;
-
- // This is the first time we are marking this Decl alive. We must
- // therefore recurse into its value and mark any Decl it references
- // as also alive, so that any Decl referenced does not get garbage collected.
-
- if (decl.val.pointerDecl()) |pointee| {
- return markDeclAlive(pointee);
- }
- }
-
fn renderInt128(
writer: anytype,
int_val: anytype,
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 7858fa76fa..d8c9589213 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -1224,7 +1224,7 @@ pub const DeclGen = struct {
.decl_ref => return lowerDeclRefValue(dg, tv, tv.val.castTag(.decl_ref).?.data),
.variable => {
const decl = tv.val.castTag(.variable).?.data.owner_decl;
- dg.markDeclAlive(decl);
+ decl.markAlive();
const val = try dg.resolveGlobalDecl(decl);
const llvm_var_type = try dg.llvmType(tv.ty);
const llvm_addrspace = dg.llvmAddressSpace(decl.@"addrspace");
@@ -1373,7 +1373,7 @@ pub const DeclGen = struct {
.function => tv.val.castTag(.function).?.data.owner_decl,
else => unreachable,
};
- dg.markDeclAlive(fn_decl);
+ fn_decl.markAlive();
return dg.resolveLlvmFunction(fn_decl);
},
.ErrorSet => {
@@ -1681,7 +1681,7 @@ pub const DeclGen = struct {
ptr_val: Value,
decl: *Module.Decl,
) Error!ParentPtr {
- dg.markDeclAlive(decl);
+ decl.markAlive();
var ptr_ty_payload: Type.Payload.ElemType = .{
.base = .{ .tag = .single_mut_pointer },
.data = decl.ty,
@@ -1763,7 +1763,7 @@ pub const DeclGen = struct {
return self.lowerPtrToVoid(tv.ty);
}
- self.markDeclAlive(decl);
+ decl.markAlive();
const llvm_val = if (decl.ty.zigTypeTag() == .Fn)
try self.resolveLlvmFunction(decl)
@@ -1774,24 +1774,6 @@ pub const DeclGen = struct {
return llvm_val.constBitCast(llvm_type);
}
- fn markDeclAlive(dg: *DeclGen, decl: *Module.Decl) void {
- if (decl.alive) return;
- decl.alive = true;
-
- log.debug("{*} ({s}) marked alive by {*} ({s})", .{
- decl, decl.name,
- dg.decl, dg.decl.name,
- });
-
- // This is the first time we are marking this Decl alive. We must
- // therefore recurse into its value and mark any Decl it references
- // as also alive, so that any Decl referenced does not get garbage collected.
-
- if (decl.val.pointerDecl()) |pointee| {
- return dg.markDeclAlive(pointee);
- }
- }
-
fn lowerPtrToVoid(dg: *DeclGen, ptr_ty: Type) !*const llvm.Value {
const target = dg.module.getTarget();
const alignment = ptr_ty.ptrAlignment(target);