-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
incorrect LLVM IR generated for align 1 struct pointer dereferenced and returned #25067
Copy link
Copy link
Closed
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviormiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.
Milestone
Description
const std = @import("std");
pub const panic = std.debug.no_panic;
export fn ok() bool {
var buffer: [5]u8 align(4) = .{ 1, 2, 3, 4, 5 };
const s = gimme(@ptrCast(buffer[1..]));
return s.a == 0x02030405;
}
const S = extern struct {
a: u32,
};
fn gimme(p: *align(1) S) S {
return p.*;
}Generates this LLVM IR:
; Function Attrs: noredzone nounwind uwtable
define internal fastcc void @test.gimme(ptr noalias sret(%test.S) nonnull %0, ptr align 1 nonnull %1) unnamed_addr #0 {
2:
call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %1, i64 4, i1 false)
ret void
}Bad alignment on the memcpy.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviormiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.