aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-22 17:12:12 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-10-22 17:12:12 -0700
commit01c1f415209f5085e09430cc6df182d7eb2245ee (patch)
tree9f93de2769afd58bf1a88db0b9b266aa24bb4b66 /src/codegen/llvm.zig
parentb24e9b6347afc66aa94f61b3ed4c2d02cdb0d0ee (diff)
downloadzig-01c1f415209f5085e09430cc6df182d7eb2245ee.tar.gz
zig-01c1f415209f5085e09430cc6df182d7eb2245ee.zip
stage2: slice and alignment fixes
* Fix backend using wrong union field of the slice instruction. * LLVM backend properly sets alignment on global variables. * Sema: add coercion for *T to *[1]T * Sema: pointers to Decls with explicit alignment now have alignment metadata in them.
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index d6b41208f2..3f24bb535d 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -581,7 +581,9 @@ pub const DeclGen = struct {
} else if (decl.val.castTag(.extern_fn)) |extern_fn| {
_ = try self.resolveLlvmFunction(extern_fn.data);
} else {
+ const target = self.module.getTarget();
const global = try self.resolveGlobalDecl(decl);
+ global.setAlignment(decl.getAlignment(target));
assert(decl.has_tv);
const init_val = if (decl.val.castTag(.variable)) |payload| init_val: {
const variable = payload.data;
@@ -2713,7 +2715,8 @@ pub const FuncGen = struct {
fn airSlice(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
if (self.liveness.isUnused(inst)) return null;
- const bin_op = self.air.instructions.items(.data)[inst].bin_op;
+ const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
+ const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
const ptr = try self.resolveInst(bin_op.lhs);
const len = try self.resolveInst(bin_op.rhs);
const inst_ty = self.air.typeOfIndex(inst);