From 9ed599b4e3f5c9f48089a3acd61d0338e27e88f6 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 5 Oct 2021 20:28:29 -0700 Subject: stage2: LLVM backend: miscompilation fixes * work around a stage1 miscompilation leading to the wrong integer comparison predicate being emitted. * fix the bug of not annotating callsites with the calling convention of the callee, leading to undefined behavior. * add the `nobuiltin` attribute when building freestanding libc or compiler_rt libraries to prevent e.g. memcpy from being "optimized" into a call to itself. * compiler-rt: change a call to be comptime to make the generated LLVM IR simpler and easier to study. I still can't enable the widening tests due to the compiler-rt compare function being miscompiled in some not-yet-diagnosed way. --- src/codegen/llvm/bindings.zig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/codegen/llvm') diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index 496579008e..a3ccea0951 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -359,22 +359,14 @@ pub const Builder = opaque { Name: [*:0]const u8, ) *const Value; - pub const buildCall = LLVMBuildCall; - extern fn LLVMBuildCall( + pub const buildCall = ZigLLVMBuildCall; + extern fn ZigLLVMBuildCall( *const Builder, Fn: *const Value, Args: [*]const *const Value, NumArgs: c_uint, - Name: [*:0]const u8, - ) *const Value; - - pub const buildCall2 = LLVMBuildCall2; - extern fn LLVMBuildCall2( - *const Builder, - *const Type, - Fn: *const Value, - Args: [*]*const Value, - NumArgs: c_uint, + CC: CallConv, + attr: CallAttr, Name: [*:0]const u8, ) *const Value; @@ -1184,6 +1176,14 @@ pub const CallConv = enum(c_uint) { AArch64_VectorCall = 97, }; +pub const CallAttr = enum(c_int) { + Auto, + NeverTail, + NeverInline, + AlwaysTail, + AlwaysInline, +}; + pub const address_space = struct { pub const default: c_uint = 0; -- cgit v1.2.3