diff options
| author | riChar <wxsychi@163.com> | 2022-09-04 23:44:45 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-04 18:44:45 +0300 |
| commit | 349cf54b3293bc4177253e96a4f84fea0251fa08 (patch) | |
| tree | 5d10e1ca26ee49a5121a18aa5dffc269bd729277 /src/codegen/llvm.zig | |
| parent | b7d5582dede8f4cae341365ac9c47c840bd80eff (diff) | |
| download | zig-349cf54b3293bc4177253e96a4f84fea0251fa08.tar.gz zig-349cf54b3293bc4177253e96a4f84fea0251fa08.zip | |
llvm: fix the `type` parameter of `GlobalAlias`
Closes 12680
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 004d152e1f..3da66acc18 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -287,6 +287,15 @@ pub fn supportsTailCall(target: std.Target) bool { } } +/// TODO can this be done with simpler logic / different API binding? +fn deleteLlvmGlobal(llvm_global: *const llvm.Value) void { + if (llvm_global.globalGetValueType().getTypeKind() == .Function) { + llvm_global.deleteFunction(); + return; + } + return llvm_global.deleteGlobal(); +} + pub const Object = struct { gpa: Allocator, module: *Module, @@ -640,7 +649,7 @@ pub const Object = struct { const new_global_ptr = other_global.constBitCast(llvm_global.typeOf()); llvm_global.replaceAllUsesWith(new_global_ptr); - object.deleteLlvmGlobal(llvm_global); + deleteLlvmGlobal(llvm_global); entry.value_ptr.* = new_global_ptr; } object.extern_collisions.clearRetainingCapacity(); @@ -666,7 +675,7 @@ pub const Object = struct { const new_global_ptr = llvm_global.constBitCast(other_global.typeOf()); other_global.replaceAllUsesWith(new_global_ptr); llvm_global.takeName(other_global); - other_global.deleteGlobal(); + deleteLlvmGlobal(other_global); // Problem: now we need to replace in the decl_map that // the extern decl index points to this new global. However we don't // know the decl index. @@ -1184,15 +1193,6 @@ pub const Object = struct { return null; } - /// TODO can this be done with simpler logic / different API binding? - fn deleteLlvmGlobal(o: Object, llvm_global: *const llvm.Value) void { - if (o.llvm_module.getNamedFunction(llvm_global.getValueName()) != null) { - llvm_global.deleteFunction(); - return; - } - return llvm_global.deleteGlobal(); - } - pub fn updateDeclExports( self: *Object, module: *Module, @@ -1287,7 +1287,7 @@ pub const Object = struct { alias.setAliasee(llvm_global); } else { _ = self.llvm_module.addAlias( - llvm_global.typeOf(), + llvm_global.globalGetValueType(), 0, llvm_global, exp_name_z, |
