Skip to content

WrapGeneric forces output to secret type, leading to crashes later in the pipeline #2553

@AlexanderViand

Description

@AlexanderViand

A program that does not actually return a secret value, e.g.,

//RUN: heir-opt --mlir-to-bgv %s | FileCheck %s
func.func @foo(%x: i32 {secret.secret}) -> i8 {
    %0 = arith.constant 42 : i8
    func.return %0 : i8
}

crashes with the following:

// -----// IR Dump Before ConvertToCiphertextSemantics (convert-to-ciphertext-semantics) //----- //
#layout = #tensor_ext.layout<"{ [] -> [ct, slot] : ct = 0 and 0 <= slot <= 1023 }">
module {
  func.func @foo(%arg0: !secret.secret<i32> {tensor_ext.layout = #layout}) -> (!secret.secret<i8> {tensor_ext.layout = #layout}) {
    %c42_i8 = arith.constant 42 : i8
    %0 = secret.conceal %c42_i8 : i8 -> !secret.secret<i8>
    %1 = tensor_ext.assign_layout %0 {layout = #layout, tensor_ext.layout = #layout} : !secret.secret<i8>
    return %1 : !secret.secret<i8>
  }
}


tmp.mlir:2:1: error: unexpected unrealized conversion cast op found
func.func @foo(%x: i32 {secret.secret}) -> i8 {
^
tmp.mlir:2:1: note: see current operation: %3 = "builtin.unrealized_conversion_cast"(%2) : (tensor<1x1024x!secret.secret<i8>>) -> !secret.secret<tensor<1x1024xi8>>

Obviously a bit of a pathological program, but this bug was encountered "in the wild" in #2525 (but unrelated to that frontend bug)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueIssues suitable for a new contributor's first PR

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions