Skip to content

Compiler crash with cannot deal with ptr that isn't arg #8

Closed
@timkaler

Description

Error: opt: /efs/home/tfk/Enzyme-plugin/enzyme/Enzyme/Enzyme.cpp:2700: llvm::Value* GradientUtils::invertPointerM(llvm::Value*, llvm::IRBuilder<>&): Assertion `0 && "cannot find deal with ptr that isnt arg"' failed.

IR

; ModuleID = 'segfault.c'
source_filename = "segfault.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = private unnamed_addr constant [36 x i8] c"hello! %f, res2 %f, da: %f, db: %f\0A\00", align 1

; Function Attrs: noinline nounwind optnone uwtable
define dso_local float @man_max(float* %a, float* %b) #0 {
entry:
  %retval = alloca float, align 4
  %a.addr = alloca float*, align 8
  %b.addr = alloca float*, align 8
  store float* %a, float** %a.addr, align 8
  store float* %b, float** %b.addr, align 8
  %0 = load float*, float** %a.addr, align 8
  %1 = load float, float* %0, align 4
  %2 = load float*, float** %b.addr, align 8
  %3 = load float, float* %2, align 4
  %cmp = fcmp ogt float %1, %3
  br i1 %cmp, label %if.then, label %if.else

if.then:                                          ; preds = %entry
  %4 = load float*, float** %a.addr, align 8
  %5 = load float, float* %4, align 4
  store float %5, float* %retval, align 4
  br label %return

if.else:                                          ; preds = %entry
  %6 = load float*, float** %b.addr, align 8
  %7 = load float, float* %6, align 4
  store float %7, float* %retval, align 4
  br label %return

return:                                           ; preds = %if.else, %if.then
  %8 = load float, float* %retval, align 4
  ret float %8
}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @compute_max(float* %a, float* %b, float* %ret) #0 {
entry:
  %a.addr = alloca float*, align 8
  %b.addr = alloca float*, align 8
  %ret.addr = alloca float*, align 8
  store float* %a, float** %a.addr, align 8
  store float* %b, float** %b.addr, align 8
  store float* %ret, float** %ret.addr, align 8
  %0 = load float*, float** %a.addr, align 8
  %1 = load float*, float** %b.addr, align 8
  %call = call float @man_max(float* %0, float* %1)
  %2 = load float*, float** %ret.addr, align 8
  store float %call, float* %2, align 4
  ret void
}

; Function Attrs: noinline norecurse optnone uwtable
define dso_local i32 @main(i32 %argc, i8** %argv) #1 {
entry:
  %retval = alloca i32, align 4
  %argc.addr = alloca i32, align 4
  %argv.addr = alloca i8**, align 8
  %a = alloca float, align 4
  %b = alloca float, align 4
  %da = alloca float, align 4
  %db = alloca float, align 4
  %ret = alloca float, align 4
  %dret = alloca float, align 4
  store i32 0, i32* %retval, align 4
  store i32 %argc, i32* %argc.addr, align 4
  store i8** %argv, i8*** %argv.addr, align 8
  store float 2.000000e+00, float* %a, align 4
  store float 3.000000e+00, float* %b, align 4
  store float 0.000000e+00, float* %da, align 4
  store float 0.000000e+00, float* %db, align 4
  store float 0.000000e+00, float* %ret, align 4
  store float 1.000000e+00, float* %dret, align 4
  call void @compute_max(float* %a, float* %b, float* %ret)
  %0 = call double (...) @__enzyme_autodiff.f64(void (float*, float*, float*)* @compute_max, float* %a, float* %da, float* %b, float* %db, float* %ret, float* %dret)
  %1 = load float, float* %ret, align 4
  %conv = fpext float %1 to double
  %2 = load float, float* %ret, align 4
  %conv1 = fpext float %2 to double
  %3 = load float, float* %da, align 4
  %conv2 = fpext float %3 to double
  %4 = load float, float* %db, align 4
  %conv3 = fpext float %4 to double
  %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i32 0, i32 0), double %conv, double %conv1, double %conv2, double %conv3)
  ret i32 0
}

declare double @__enzyme_autodiff.f64(...)

declare dso_local i32 @printf(i8*, ...) #2

attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { noinline norecurse optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 7.1.0 "}

Activity

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

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