Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: valgrind client request support for aarch64 #13292

Merged
merged 2 commits into from
Nov 22, 2022

Conversation

mitchellh
Copy link
Contributor

Tested locally on my aarch64 machine.

Copy link
Contributor

@daurnimator daurnimator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches what I see in valgrind.h.

@andrewrk
Copy link
Member

andrewrk commented Oct 25, 2022

Nice!

I'd like to do the corresponding improvements to src/target.zig and src/codegen/llvm.zig (valgrindClientRequest) along with merging this. If you're up for doing that here, be my guest, otherwise sit tight and I'll take care of it.

@mitchellh
Copy link
Contributor Author

I'd like to do the corresponding improvements to src/target.zig and src/codegen/llvm.zig (valgriendClientRequest) along with merging this. If you're up for doing that here, be my guest, otherwise sit tight and I'll take care of it.

Ah, sorry for not seeing that. Target is easy but I'm not comfortable with the llvm side. I'll sit tight... no rush this is obviously not critical.

mitchellh and others added 2 commits November 19, 2022 18:54
This also modifies the inline assembly to be more optimizable - instead of
doing explicit movs, we instead communicate to LLVM which registers we
would like to, somehow, have the correct values. This is how the x86_64
code already worked and thus allows the code to be unified across the
two architectures.

As a bonus, I threw in x86 support.
@andrewrk
Copy link
Member

This is now done, but I was unable to test it on aarch64 due to #10086 (which I will be looking into shortly) or x86 due to not having an x86 machine lying around.

@andrewrk
Copy link
Member

Tested on aarch64-linux Debian-bullseye:

$ cat test.zig
const std = @import("std");

pub fn main() !void {
foo();
}

fn foo() void {
    var data: bool = true;
    data = undefined;
    if (data) {
        std.debug.print("true\n", .{});
    }
}

$ valgrind ./test
==425462== Memcheck, a memory error detector
==425462== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==425462== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==425462== Command: ./test
==425462== 
==425462== Conditional jump or move depends on uninitialised value(s)
==425462==    at 0x21E14C: ??? (in /home/andy/zig/build-release/test)
==425462== 
==425462== 
==425462== HEAP SUMMARY:
==425462==     in use at exit: 0 bytes in 0 blocks
==425462==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==425462== 
==425462== All heap blocks were freed -- no leaks are possible
==425462== 
==425462== Use --track-origins=yes to see where uninitialised values come from
==425462== For lists of detected and suppressed errors, rerun with: -s
==425462== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Looks like the code here works, although I'm not sure why the debug info is missing.

@andrewrk andrewrk merged commit 670b4c5 into ziglang:master Nov 22, 2022
@mitchellh mitchellh deleted the valgrind-arm64 branch November 22, 2022 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants