Skip to content

Enzyme Bug - Phi Nodes #2492

@jpmedinagl

Description

@jpmedinagl

I had a bug when compiling an enzyme project. I followed the instructions and created a minimal reproducer. Here is the link below:

https://fwd.gymni.ch/SpoXL2

Error Message: PHI nodes not grouped at top of basic block!

Here is the minimal reproducer as well:

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i32 @foo(ptr %0) {
  %2 = call i32 @baz(ptr %0, ptr null)
  ret i32 %2
}

define i32 @baz(ptr %0, ptr %1) {
  %3 = load i32, ptr %0, align 4
  %4 = tail call i32 @llvm.abs.i32(i32 %3, i1 false)
  %5 = or i32 0, %4
  %6 = sitofp i32 %5 to double
  store double %6, ptr %1, align 8
  ret i32 0
}

define {} @_ZN8overhead4main17h25736e915a18b782E() {
  %1 = tail call {} (...) @__enzyme_fwddiff_foo(ptr @bar)
  ret {} %1
}

define i32 @bar() {
  %1 = alloca [120 x i8], align 8
  %2 = call i32 @foo(ptr %1)
  ret i32 %2
}

declare {} @__enzyme_fwddiff_foo(...)

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #0

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions