Skip to content
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

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

Closed
timkaler opened this issue Sep 14, 2019 · 0 comments · Fixed by #9
Closed

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

timkaler opened this issue Sep 14, 2019 · 0 comments · Fixed by #9

Comments

@timkaler
Copy link
Contributor

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 "}

ZuseZ4 added a commit that referenced this issue Feb 11, 2022
Update releases, allow custom builds
tgymnich pushed a commit that referenced this issue Mar 23, 2023
wsmoses pushed a commit that referenced this issue May 16, 2023
wsmoses pushed a commit that referenced this issue May 18, 2023
wsmoses pushed a commit that referenced this issue May 21, 2023
wsmoses added a commit that referenced this issue May 21, 2023
* compiles with llvm-16 (old PM is gone so I could not run opt) (#1)

* port to llvm-16 (not backward-compatible with older llvms), WIP

* wip, but probably not correct on may places

* rule out old PM on llvm 16 and above

* #if LLVM_VERSION_MAJOR >= 16, WIP

* #if LLVM_VERSION_MAJOR >= 16, WIP

* #if LLVM_VERSION_MAJOR >= 16, WIP

* #if LLVM_VERSION_MAJOR >= 16, WIP

* #if LLVM_VERSION_MAJOR >= 16, WIP

* #if LLVM_VERSION_MAJOR >= 16

* Llvm 16 (#2)

* fix for argmemonly

* disabling old pm tests where new pm tests exist (#3)

* Disable old pm tests fix (#4)

* disabling old pm tests where new pm tests exist: fix typo

* fix build with llvm-16 (#5)

* fix build with llvm < 16 (#6)

* Attribute::Memory fixes (#7)

but still getting zeros instead of derivatives

* curly brace out of macro (#8)

* fix typo (#9)

* fix for llvm-16 (#10)

* fix typo

* fix

* Llvm 16 gha (#11)

* enable build with llvm 16

* enable llvm-16 once this gets to main (on both linux and mac os)

* docker run -it --rm --workdir /Enzyme -v /home/stp/go/src/github.com/stepasite/Enzyme/enzyme/Enzyme:/Enzyme clang-format-lint --clang-format-executable /clang-format/clang-format11 -r --exclude ./Enzyme/SCEV --style llvm --inplace true ./Enzyme

* forward mode vector: new pm tests, wip

* llvm-16: fixing tests, wip (#12)

* llvm-16 tests, WIP

* resolving latest test/ll commits (#13)

* Llvm 16 tests (#14)

* llvm-16 tests, WIP

* fix bug introduced in (FunctionUtils.cpp)

* llvm 16 tests, wip

* llvm tests, WIP (#15)

* continued test fixes

* fixup

* fix build

* fix

* cleanup

* fixes

* fix

* fix attr

* fix format

* fixup

* fix attrs

* fix

* fix

* fix

* fix sret

* fix

* add type analysis

* activity analysis

* fix ta

* fix

* fix

* fixes

* more tests

* more fixes

* 297

* more tests

* fix

* fix

* fix

* fix

* fix

---------

Co-authored-by: Pavel Stepanek <stepasite@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant