[llvm-bugs] [Bug 34952] New: codegen incorrect on windows (because of 4 byval parameters?)
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Oct 14 19:22:43 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34952
Bug ID: 34952
Summary: codegen incorrect on windows (because of 4 byval
parameters?)
Product: new-bugs
Version: 5.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: superjoe30 at gmail.com
CC: llvm-bugs at lists.llvm.org
Created attachment 19277
--> https://bugs.llvm.org/attachment.cgi?id=19277&action=edit
test.ll
This is with LLVM 5.0.0.
The frontend source code is:
const io = @import("std").io;
const std = @import("std");
const builtin = @import("builtin");
const Mode = builtin.Mode;
const TestTarget = struct {
os: builtin.Os,
arch: builtin.Arch,
environ: builtin.Environ,
};
const test_targets = []TestTarget {
TestTarget {
.os = builtin.Os.linux,
.arch = builtin.Arch.x86_64,
.environ = builtin.Environ.gnu,
},
TestTarget {
.os = builtin.Os.darwin,
.arch = builtin.Arch.x86_64,
.environ = builtin.Environ.unknown,
},
TestTarget {
.os = builtin.Os.windows,
.arch = builtin.Arch.x86_64,
.environ = builtin.Environ.msvc,
},
TestTarget {
.os = builtin.Os.windows,
.arch = builtin.Arch.i386,
.environ = builtin.Environ.msvc,
},
};
var name: []const u8 = "hello";
pub fn main() -> %void {
for (test_targets) |test_target| {
for ([]Mode{Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast}) |mode| {
%%io.stdout.printf("{}-{}-{}-{}\n", name,
@enumTagName(test_target.os),
@enumTagName(test_target.arch), @enumTagName(mode));
}
}
}
Expected output:
hello-linux-x86_64-Debug
hello-linux-x86_64-ReleaseSafe
hello-linux-x86_64-ReleaseFast
hello-darwin-x86_64-Debug
hello-darwin-x86_64-ReleaseSafe
hello-darwinx86_64--ReleaseFast
hello-windows-x86_64-Debug
hello-windows-x86_64-ReleaseSafe
hello-windows-x86_64-ReleaseFast
hello-windows-i386-Debug
hello-windows-i386-ReleaseSafe
hello-windows-i386-ReleaseFast
To reproduce, compile test.ll with clang with -O0 and link with LLD. Run
test.exe on windows. You will see:
hello-linux--Debug
hello-linux--ReleaseSafe
hello-linux--ReleaseFast
hello-darwin--Debug
hello-darwin--ReleaseSafe
hello-darwin--ReleaseFast
hello-windows--Debug
hello-windows--ReleaseSafe
hello-windows--ReleaseFast
hello-windows--Debug
hello-windows--ReleaseSafe
hello-windows--ReleaseFast
If you compile with -O3, you get the correct output. But -O0 is broken. It
seems to pass the byval parameters incorrectly.
If you run the code on linux (with the windows WriteFile replaced with the
respective linux syscalls) you get the correct output.
Removing any 1 of the 4 parameters to io.stdout.printf causes the codegen to be
correct.
Cross-compiling the program on linux, targeting windows, and then running the
resulting test.exe with wine64 results in the incorrect output, same as on
Windows natively.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171015/1af3f6b9/attachment.html>
More information about the llvm-bugs
mailing list