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

Invalid LLVM BuildCondBr call #1468

Closed
tiehuis opened this Issue Sep 4, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@tiehuis
Member

tiehuis commented Sep 4, 2018

Haven't reduced this yet but you can replicate this for now checkout by checking out this branch https://github.com/ziglang/zig/tree/poly1305-x25519 and applying the following patch. (Specific commit: https://github.com/ziglang/zig/tree/763845f95c33140859aa0297c9495d5f08f9afea)

 std/crypto/throughput_test.zig | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/std/crypto/throughput_test.zig b/std/crypto/throughput_test.zig
index 5f25c0b8..8645ca8a 100644
--- a/std/crypto/throughput_test.zig
+++ b/std/crypto/throughput_test.zig
@@ -170,14 +170,14 @@ pub fn main() !void {
     inline for (hashes) |H| {
         // TODO: Inverted early continue case here segfaults compiler. Create reduced test case.
         //
-        // if (filter != null and std.mem.indexOf(u8, H.name, filter.?) == null) {
-        //     continue;
-        // }
-        if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {
+        if (filter != null and std.mem.indexOf(u8, H.name, filter.?) == null) {
+            continue;
+        }
+        //if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {
             const throughput = try benchmarkHash(H.ty, mode(32 * MiB));
             try printPad(stdout, H.name);
             try stdout.print(": {} MiB/s\n", throughput / (1 * MiB));
-        }
+        //}
     }
 
     inline for (macs) |M| {

Running the following command will segfault.

zig build-exe std/crypto/throughput_test.zig
#0  0x0000555558b786d0 in llvm::BasicBlock::getContext() const ()
#1  0x0000555558c083e9 in llvm::BranchInst::BranchInst(llvm::BasicBlock*, llvm::BasicBlock*, llvm::Value*
#2  0x0000555558ba3208 in LLVMBuildCondBr ()
#3  0x0000555555efd84a in ir_render_instruction(CodeGen*, IrExecutable*, IrInstruction*) [clone .isra.182
#4  0x0000555555f03a0e in codegen_build(CodeGen*) ()
#5  0x0000555555e49731 in main ()

@tiehuis tiehuis added the bug label Sep 4, 2018

@andrewrk andrewrk added this to the 0.3.0 milestone Sep 4, 2018

@andrewrk

This comment has been minimized.

Member

andrewrk commented Sep 4, 2018

This might be the same as #834, since filter and the result of indexOf are runtime values.

@andrewrk andrewrk closed this in b000070 Sep 4, 2018

@andrewrk

This comment has been minimized.

Member

andrewrk commented Sep 4, 2018

Confirmed, it was the same as #834 and now if you apply that patch to the code, you get these compile errors:

screenshot_2018-09-04_15-34-54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment