Skip to content

select of pointer operands can occur for valid code #886

@zero9178

Description

@zero9178

Given the following C code:

#include <stdint.h>
uint8_t test58(int8_t var0, uint8_t var1[4]) {
  return 0 == (var0 ? var1[1] : var1[0]);
}

Dynamatic will crash on a scalar type being unhandled. The problem can be seen in the LLVM IR:

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @test58(i8 noundef signext %var0, ptr noundef %var1) #0 {
entry:
  %tobool.not = icmp eq i8 %var0, 0
  %arrayidx = getelementptr inbounds i8, ptr %var1, i64 1
  %cond.in.in = select i1 %tobool.not, ptr %var1, ptr %arrayidx
  %cond.in = load i8, ptr %cond.in.in, align 1, !handshake.name !6
  %cmp = icmp eq i8 %cond.in, 0
  %conv5 = zext i1 %cmp to i8
  ret i8 %conv5
}

While the C code is a select between two loaded values, LLVM compiles it to a select between two pointer operands, something that dynamatic does not support.
This is an instance where despite the C code adhering to the HLS coding conventions it still fails to compile due to LLVM adhering to the rules of LLVM IR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfuzzer-foundBugs found using an automated fuzzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions