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

LLVM error: broken gc calling conv fix - Julia v1.11 only #2121

Open
mhauru opened this issue Nov 26, 2024 · 5 comments
Open

LLVM error: broken gc calling conv fix - Julia v1.11 only #2121

mhauru opened this issue Nov 26, 2024 · 5 comments

Comments

@mhauru
Copy link
Contributor

mhauru commented Nov 26, 2024

MWE:

module MWE

using Roots: Roots
using Enzyme: Enzyme

function find_zeta(y::T) where {T<:Real}
    lower = -y
    upper = y
    α0 = Roots.find_zero(identity, (lower, upper), Roots.ITP())
    return α0
end

y = 1.0
@show Enzyme.autodiff(Enzyme.Forward, find_zeta, Enzyme.Const(y))

end

Output on Julia v1.11.1:

ERROR: LoadError: LLVM error: broken gc calling conv fix
inlinable function call in a function with debug info must have a !dbg location
  %27 = call double @julia_nextfloat_24153(double %value_phi3)
inlinable function call in a function with debug info must have a !dbg location
  %30 = call double @julia_prevfloat_24254(double %value_phi)

; ModuleID = 'start'
source_filename = "start"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128-ni:10:11:12:13"
target triple = "arm64-apple-darwin22.4.0"

@jl_small_typeof = external local_unnamed_addr constant i8
@_j_const_8 = private unnamed_addr constant [129 x [2 x double]] [[2 x double] zeroinitializer, [2 x double] [double 0x3F7FE02A6B200000, double 0xBD6F30EE07912DF9], [2 x double] [double 0x3F8FC0A8B1000000, double 0xBD5FE0E183092C59], [2 x double] [double 0x3F97B91B07D80000, double 0xBD62772AB6C0559C], [2 x double] [double 0x3F9F829B0E780000, double 0x3D2980267C7E09E4], [2 x double] [double 0x3FA39E87BA000000, double 0xBD642A056FEA4DFD], [2 x double] [double 0x3FA77458F6340000, double 0xBD62303B9CB0D5E1], [2 x double] [double 0x3FAB42DD71180000, double 0x3D671BEC28D14C7E], [2 x double] [double 0x3FAF0A30C0100000, double 0x3D662A6617CC9717], [2 x double] [double 0x3FB16536EEA40000, double 0xBD60A3E2F3B47D18], [2 x double] [double 0x3FB341D7961C0000, double 0xBD4717B6B33E44F8], [2 x double] [double 0x3FB51B073F060000, double 0x3D383F69278E686A], [2 x double] [double 0x3FB6F0D28AE60000, double 0xBD62968C836CC8C2], [2 x double] [double 0x3FB8C345D6320000, double 0xBD5937C294D2F567], [2 x double] [double 0x3FBA926D3A4A0000, double 0x3D6AAC6CA17A4554], [2 x double] [double 0x3FBC5E548F5C0000, double 0xBD4C5E7514F4083F], [2 x double] [double 0x3FBE27076E2A0000, double 0x3D6E5CBD3D50FFFC], [2 x double] [double 0x3FBFEC9131DC0000, double 0xBD354555D1AE6607], [2 x double] [double 0x3FC0D77E7CD10000, double 0xBD6C69A65A23A170], [2 x double] [double 0x3FC1B72AD52F0000, double 0x3D69E80A41811A39], [2 x double] [double 0x3FC29552F8200000, double 0xBD35B967F4471DFC], [2 x double] [double 0x3FC371FC201F0000, double 0xBD6C22F10C9A4EA8], [2 x double] [double 0x3FC44D2B6CCB0000, double 0x3D6F4799F4F6543E], [2 x double] [double 0x3FC526E5E3A20000, double 0xBD62F21746FF8A47], [2 x double] [double 0x3FC5FF3070A80000, double 0xBD6B0B0DE3077D7E], [2 x double] [double 0x3FC6D60FE71A0000, double 0xBD56F1B955C4D1DA], [2 x double] [double 0x3FC7AB8902110000, double 0xBD537B720E4A694B], [2 x double] [double 0x3FC87FA065210000, double 0xBD5B77B7EFFB7F41], [2 x double] [double 0x3FC9525A9CF40000, double 0x3D65AD1D904C1D4E], [2 x double] [double 0x3FCA23BC1FE30000, double 0xBD62A739B23B93E1], [2 x double] [double 0x3FCAF3C94E810000, double 0xBD600349CC67F9B2], [2 x double] [double 0x3FCBC286742E0000, double 0xBD6CCA75818C5DBC], [2 x double] [double 0x3FCC8FF7C79B0000, double 0xBD697794F689F843], [2 x double] [double 0x3FCD5C216B500000, double 0xBD611BA91BBCA682], [2 x double] [double 0x3FCE27076E2B0000, double 0xBD3A342C2AF0003C], [2 x double] [double 0x3FCEF0ADCBDC0000, double 0x3D664D948637950E], [2 x double] [double 0x3FCFB9186D5E0000, double 0x3D5F1546AAA3361C], [2 x double] [double 0x3FD0402594B50000, double 0xBD67DF928EC217A5], [2 x double] [double 0x3FD0A324E2738000, double 0x3D50E35F73F7A018], [2 x double] [double 0x3FD1058BF9AE8000, double 0xBD6A9573B02FAA5A], [2 x double] [double 0x3FD1675CABAB8000, double 0x3D630701CE63EAB9], [2 x double] [double 0x3FD1C898C1698000, double 0x3D59FAFBC68E7540], [2 x double] [double 0x3FD22941FBCF8000, double 0xBD3A6976F5EB0963], [2 x double] [double 0x3FD2895A13DE8000, double 0x3D3A8D7AD24C13F0], [2 x double] [double 0x3FD2E8E2BAE10000, double 0x3D5D309C2CC91A85], [2 x double] [double 0x3FD347DD9A988000, double 0xBD25594DD4C58092], [2 x double] [double 0x3FD3A64C55698000, double 0xBD6D0B1C68651946], [2 x double] [double 0x3FD4043086868000, double 0x3D63F1DE86093EFA], [2 x double] [double 0x3FD4618BC21C8000, double 0xBD609EC17A426426], [2 x double] [double 0x3FD4BE5F95778000, double 0xBD3D7C92CD9AD824], [2 x double] [double 0x3FD51AAD872E0000, double 0xBD3F4BD8DB0A7CC1], [2 x double] [double 0x3FD5767717458000, double 0xBD62C9D5B2A49AF9], [2 x double] [double 0x3FD5D1BDBF580000, double 0x3D4394A11B1C1EE4], [2 x double] [double 0x3FD62C82F2BA0000, double 0xBD6C356848506EAD], [2 x double] [double 0x3FD686C81E9B0000, double 0x3D54AEC442BE1015], [2 x double] [double 0x3FD6E08EAA2B8000, double 0x3D60F1C609C98C6C], [2 x double] [double 0x3FD739D7F6BC0000, double 0xBD67FCB18ED9D603], [2 x double] [double 0x3FD792A55FDD8000, double 0xBD6C2EC1F512DC03], [2 x double] [double 0x3FD7EAF83B828000, double 0x3D67E1B259D2F3DA], [2 x double] [double 0x3FD842D1DA1E8000, double 0x3D462E927628CBC2], [2 x double] [double 0x3FD89A3386C18000, double 0xBD6ED2A52C73BF78], [2 x double] [double 0x3FD8F11E87368000, double 0xBD5D3881E8962A96], [2 x double] [double 0x3FD947941C210000, double 0x3D56FABA4CDD147D], [2 x double] [double 0x3FD99D9581180000, double 0xBD5F753456D113B8], [2 x double] [double 0x3FD9F323ECBF8000, double 0x3D584BF2B68D766F], [2 x double] [double 0x3FDA484090E58000, double 0x3D6D8515FE535B87], [2 x double] [double 0x3FDA9CEC9A9A0000, double 0x3D40931A909FEA5E], [2 x double] [double 0x3FDAF12932478000, double 0xBD3E53BB31EED7A9], [2 x double] [double 0x3FDB44F77BCC8000, double 0x3D4EC5197DDB55D3], [2 x double] [double 0x3FDB985896930000, double 0x3D50FB598FB14F89], [2 x double] [double 0x3FDBEB4D9DA70000, double 0x3D5B7BF7861D37AC], [2 x double] [double 0x3FDC3DD7A7CD8000, double 0x3D66A6B9D9E0A5BD], [2 x double] [double 0x3FDC8FF7C79A8000, double 0x3D5A21AC25D81EF3], [2 x double] [double 0x3FDCE1AF0B860000, double 0xBD48290905A86AA6], [2 x double] [double 0x3FDD32FE7E010000, double 0xBD542A9E21373414], [2 x double] [double 0x3FDD83E7258A0000, double 0x3D679F2828ADD176], [2 x double] [double 0x3FDDD46A04C20000, double 0xBD6DAFA08CECADB1], [2 x double] [double 0x3FDE24881A7C8000, double 0xBD53D9E34270BA6B], [2 x double] [double 0x3FDE744261D68000, double 0x3D3E1F8DF68DBCF3], [2 x double] [double 0x3FDEC399D2468000, double 0x3D49802EB9DCA7E7], [2 x double] [double 0x3FDF128F5FAF0000, double 0x3D3BB2CD720EC44C], [2 x double] [double 0x3FDF6123FA700000, double 0x3D645630A2B61E5B], [2 x double] [double 0x3FDFAF588F790000, double 0xBD49C24CA098362B], [2 x double] [double 0x3FDFFD2E08580000, double 0xBD46CF54D05F9367], [2 x double] [double 0x3FE02552A5A5C000, double 0x3D60FEC69C695D7F], [2 x double] [double 0x3FE04BDF9DA94000, double 0xBD692D9A033EFF75], [2 x double] [double 0x3FE0723E5C1CC000, double 0x3D6F404E57963891], [2 x double] [double 0x3FE0986F4F574000, double 0xBD55BE8DC04AD601], [2 x double] [double 0x3FE0BE72E4254000, double 0xBD657D49676844CC], [2 x double] [double 0x3FE0E44985D1C000, double 0x3D5917EDD5CBBD2D], [2 x double] [double 0x3FE109F39E2D4000, double 0x3D592DFBC7D93617], [2 x double] [double 0x3FE12F7195940000, double 0xBD6043ACFEDCE638], [2 x double] [double 0x3FE154C3D2F4C000, double 0x3D65E9A98F33A396], [2 x double] [double 0x3FE179EABBD88000, double 0x3D69A0BFC60E6FA0], [2 x double] [double 0x3FE19EE6B467C000, double 0x3D52DD98B97BAEF0], [2 x double] [double 0x3FE1C3B81F714000, double 0xBD3EDA1B58389902], [2 x double] [double 0x3FE1E85F5E704000, double 0x3D1A07BD8B34BE7C], [2 x double] [double 0x3FE20CDCD192C000, double 0xBD64926CAFC2F08A], [2 x double] [double 0x3FE23130D7BEC000, double 0xBD17AFA4392F1BA7], [2 x double] [double 0x3FE2555BCE990000, double 0xBD506987F78A4A5E], [2 x double] [double 0x3FE2795E1289C000, double 0xBD5DCA290F81848D], [2 x double] [double 0x3FE29D37FEC2C000, double 0xBD5EEA6F465268B4], [2 x double] [double 0x3FE2C0E9ED448000, double 0x3D5D1772F5386374], [2 x double] [double 0x3FE2E47436E40000, double 0x3D334202A10C3491], [2 x double] [double 0x3FE307D7334F0000, double 0x3D60BE1FB590A1F5], [2 x double] [double 0x3FE32B1339120000, double 0x3D6D71320556B67B], [2 x double] [double 0x3FE34E289D9D0000, double 0xBD6E2CE9146D277A], [2 x double] [double 0x3FE37117B5474000, double 0x3D4ED71774092113], [2 x double] [double 0x3FE393E0D3564000, double 0xBD65E6563BBD9FC9], [2 x double] [double 0x3FE3B6844A000000, double 0xBD3EEA838909F3D3], [2 x double] [double 0x3FE3D9026A714000, double 0x3D66FAA404263D0B], [2 x double] [double 0x3FE3FB5B84D18000, double 0xBD60BDA4B162AFA3], [2 x double] [double 0x3FE41D8FE8468000, double 0xBD5AA33736867A17], [2 x double] [double 0x3FE43F9FE2F9C000, double 0x3D5CCEF4E4F736C2], [2 x double] [double 0x3FE4618BC21C4000, double 0x3D6EC27D0B7B37B3], [2 x double] [double 0x3FE48353D1EA8000, double 0x3D51BEE7ABD17660], [2 x double] [double 0x3FE4A4F85DB04000, double 0xBD244FDD840B8591], [2 x double] [double 0x3FE4C679AFCD0000, double 0xBD61C64E971322CE], [2 x double] [double 0x3FE4E7D811B74000, double 0x3D6BB09CB0985646], [2 x double] [double 0x3FE50913CC018000, double 0xBD6794B434C5A4F5], [2 x double] [double 0x3FE52A2D265BC000, double 0x3D46ABB9DF22BC57], [2 x double] [double 0x3FE54B2467998000, double 0x3D6497A915428B44], [2 x double] [double 0x3FE56BF9D5B40000, double 0xBD58CD7DC73BD194], [2 x double] [double 0x3FE58CADB5CD8000, double 0xBD49DB3DB43689B4], [2 x double] [double 0x3FE5AD404C358000, double 0x3D6F2CFB29AAA5F0], [2 x double] [double 0x3FE5CDB1DC6C0000, double 0x3D67648CF6E3C5D7], [2 x double] [double 0x3FE5EE02A9240000, double 0x3D667570D6095FD2], [2 x double] [double 0x3FE60E32F4478000, double 0x3D51B194F912B417], [2 x double] [double 0x3FE62E42FEFA4000, double 0xBD48432A1B0E2634]], align 8
@_j_const_1 = private unnamed_addr constant { double, i64, i64 } { double 2.000000e-01, i64 2, i64 1 }, align 8
@jl_nothing = external local_unnamed_addr constant {}*, !enzyme_inactive !0
@_j_const_5 = private unnamed_addr constant { double, double, double, double, i64, i8 } { double 0x3630000000000000, double 0x3CB0000000000000, double 0.000000e+00, double 0.000000e+00, i64 60, i8 1 }, align 8
@enz_exception = private unnamed_addr constant [104 x i8] c"Enzyme: The original primal code hits this error condition, thus differentiating it does not make sense\00", align 1
@ejl_enz_runtime_exc = external addrspace(10) global {}, !enzyme_inactive !0, !enzyme_ta_norecur !0
@enz_exception.13 = private unnamed_addr constant [104 x i8] c"Enzyme: The original primal code hits this error condition, thus differentiating it does not make sense\00", align 1
@enz_exception.14 = private unnamed_addr constant [104 x i8] c"Enzyme: The original primal code hits this error condition, thus differentiating it does not make sense\00", align 1

; Function Attrs: nofree memory(none)
declare {}*** @julia.get_pgcstack() local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(1) memory(inaccessiblemem: readwrite)
declare noalias nonnull {} addrspace(10)* @julia.gc_alloc_obj({}*, i64, {} addrspace(10)*) local_unnamed_addr #1

; Function Attrs: nofree memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @julia.safepoint(i64*) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minimum.f64(double, double) #3

; Function Attrs: nofree speculatable memory(none)
define private "enzyme_type"="{[-1]:Float@double}" double @julia_nextfloat_24156(double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="4720220464" "enzymejl_parmtype_ref"="0" %0, i64 noundef signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="4720221264" "enzymejl_parmtype_ref"="0" %1) local_unnamed_addr #4 !dbg !26 {
top:
  %2 = call {}*** @julia.get_pgcstack()
  %ptls_field7 = getelementptr inbounds {}**, {}*** %2, i64 2
  %3 = bitcast {}*** %ptls_field7 to i64***
  %ptls_load89 = load i64**, i64*** %3, align 8, !tbaa !29
  %4 = getelementptr inbounds i64*, i64** %ptls_load89, i64 2
  %safepoint = load i64*, i64** %4, align 8, !tbaa !33
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint) #26, !dbg !35
  fence syncscope("singlethread") seq_cst
  %5 = fcmp ord double %0, 0.000000e+00, !dbg !36
  br i1 %5, label %L4, label %common.ret, !dbg !40

common.ret:                                       ; preds = %top, %L33
  %common.ret.op = phi double [ %19, %L33 ], [ %0, %top ]
  ret double %common.ret.op, !dbg !41

L4:                                               ; preds = %top
  %6 = bitcast double %0 to i64, !dbg !42
  %7 = icmp sgt i64 %6, -1, !dbg !48
  %8 = and i64 %6, 9223372036854775807, !dbg !52
  %9 = call i64 @llvm.abs.i64(i64 noundef %1, i1 noundef false), !dbg !55
  %.lobit = lshr i64 %6, 63, !dbg !62
  %10 = trunc i64 %.lobit to i8, !dbg !62
  %.lobit10 = lshr i64 %1, 63, !dbg !62
  %11 = trunc i64 %.lobit10 to i8, !dbg !62
  %12 = icmp eq i8 %10, %11, !dbg !62
  br i1 %12, label %L28, label %L17, !dbg !71

.
.
.
[Maaaaaaaany more lines of some LLVM stuff]
.
.
.

!833 = distinct !{!833, !834, !"na_addr13"}
!834 = distinct !{!834, !"addr13"}
!835 = distinct !DISubprogram(name: "fwddiffejulia_find_zeta_24057wrap", linkageName: "fwddiffejulia_find_zeta_24057wrap", scope: null, file: !836, type: !28, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!836 = !DIFile(filename: "/Users/mhauru/projects/Enzyme-mwes/bijectors_julia11/mwe3.jl", directory: ".")
!837 = !{!838}
!838 = distinct !{!838, !839, !"primal"}
!839 = distinct !{!839, !" diff: %pgcstack"}
!840 = !{!841}
!841 = distinct !{!841, !839, !"shadow_0"}
!842 = !{!843}
!843 = distinct !{!843, !844, !"primal"}
!844 = distinct !{!844, !" diff: %ptls_load56"}
!845 = !{!846}
!846 = distinct !{!846, !844, !"shadow_0"}
!847 = !DILocation(line: 6, scope: !848, inlinedAt: !849)
!848 = distinct !DISubprogram(name: "find_zeta", linkageName: "julia_find_zeta_24057", scope: null, file: !836, line: 6, type: !28, scopeLine: 6, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!849 = distinct !DILocation(line: 0, scope: !835)
!850 = !DILocation(line: 489, scope: !851, inlinedAt: !852)
!851 = distinct !DISubprogram(name: "-;", linkageName: "-", scope: !27, file: !27, type: !28, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!852 = distinct !DILocation(line: 7, scope: !848, inlinedAt: !849)
!853 = !DILocation(line: 9, scope: !848, inlinedAt: !849)
!854 = !{!195, !855, !124, !126, !127, !121}
!855 = distinct !{!855, !856, !"na_addr13"}
!856 = distinct !{!856, !"addr13"}
!857 = !DILocation(line: 484, scope: !858, inlinedAt: !859)
!858 = distinct !DISubprogram(name: "solve;", linkageName: "solve", scope: !588, file: !588, type: !28, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!859 = distinct !DILocation(line: 220, scope: !860, inlinedAt: !861)
!860 = distinct !DISubprogram(name: "#find_zero#40;", linkageName: "#find_zero#40", scope: !588, file: !588, type: !28, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!861 = distinct !DILocation(line: 210, scope: !862, inlinedAt: !863)
!862 = distinct !DISubprogram(name: "find_zero;", linkageName: "find_zero", scope: !588, file: !588, type: !28, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!863 = distinct !DILocation(line: 210, scope: !862, inlinedAt: !864)
!864 = distinct !DILocation(line: 9, scope: !848, inlinedAt: !849)
!865 = !DILocation(line: 617, scope: !866, inlinedAt: !867)
!866 = distinct !DISubprogram(name: "!=;", linkageName: "!=", scope: !27, file: !27, type: !28, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!867 = distinct !DILocation(line: 702, scope: !868, inlinedAt: !869)
!868 = distinct !DISubprogram(name: "isnan;", linkageName: "isnan", scope: !27, file: !27, type: !28, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!869 = distinct !DILocation(line: 229, scope: !860, inlinedAt: !861)
!870 = !DILocation(line: 229, scope: !860, inlinedAt: !861)
!871 = !DILocation(line: 10, scope: !872, inlinedAt: !869)
!872 = distinct !DISubprogram(name: "ConvergenceFailed;", linkageName: "ConvergenceFailed", scope: !670, file: !670, type: !28, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !12, retainedNodes: !0)
!873 = !{!195, !855, !124, !125, !127, !121}

Stacktrace:
  [1] post_optimze!(mod::LLVM.Module, tm::LLVM.TargetMachine, machine::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/RTS5U/src/compiler/optimize.jl:2856
  [2] post_optimze!(mod::LLVM.Module, tm::LLVM.TargetMachine)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/RTS5U/src/compiler/optimize.jl:2834
  [3] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/RTS5U/src/compiler.jl:8487
  [4] _thunk
    @ ~/.julia/packages/Enzyme/RTS5U/src/compiler.jl:8468 [inlined]
  [5] cached_compilation
    @ ~/.julia/packages/Enzyme/RTS5U/src/compiler.jl:8509 [inlined]
  [6] thunkbase(ctx::LLVM.Context, mi::Core.MethodInstance, ::Val{…}, ::Type{…}, ::Type{…}, tt::Type{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Type{…}, ::Val{…}, ::Val{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/RTS5U/src/compiler.jl:8641
  [7] #s2105#19135
    @ ~/.julia/packages/Enzyme/RTS5U/src/compiler.jl:8778 [inlined]
  [8]
    @ Enzyme.Compiler ./none:0
  [9] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:707
 [10] autodiff
    @ ~/.julia/packages/Enzyme/RTS5U/src/Enzyme.jl:633 [inlined]
 [11] autodiff
    @ ~/.julia/packages/Enzyme/RTS5U/src/Enzyme.jl:537 [inlined]
 [12] autodiff(mode::EnzymeCore.ForwardMode{…}, f::typeof(Main.MWE.find_zeta), args::EnzymeCore.Const{…})
    @ Enzyme ~/.julia/packages/Enzyme/RTS5U/src/Enzyme.jl:504
 [13] macro expansion
    @ show.jl:1229 [inlined]
 [14] top-level scope
    @ ~/projects/Enzyme-mwes/bijectors_julia11/mwe3.jl:14
 [15] include(fname::String)
    @ Main ./sysimg.jl:38
 [16] top-level scope
    @ REPL[1]:1
in expression starting at /Users/mhauru/projects/Enzyme-mwes/bijectors_julia11/mwe3.jl:1
Some type information was truncated. Use `show(err)` to see complete types.

The full error is 2238 lines. In addition to fixing the problem, just printing a simpler and less intimidating error would be good.

On Julia v1.10 this passes. The above is for Enzyme v0.13.16, Julia v.11.1. If I change the argument activity from Const to Duplicated then we hit #2035 on v1.10 too.

@wsmoses
Copy link
Member

wsmoses commented Nov 27, 2024

Can you paste the whole log.

@mhauru
Copy link
Contributor Author

mhauru commented Nov 27, 2024

@wsmoses
Copy link
Member

wsmoses commented Nov 27, 2024

Looking more closely at the log, this looks like a bug in julia itself.

In particular,

debug info is not attached to the function before any Enzyme shenanigans:


define private fastcc void @julia_init_state_28603({ double, double, double, double, i64, double, double }* noalias nocapture nofree noundef nonnull writeonly sret({ double, double, double, double, i64, double, double }) align 8 dereferenceable(56) "enzyme_type"="{[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Float@double, [-1,16]:Float@double, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double, [-1,48]:Float@double}" %sret_return, [2 x double] addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(16) "enzyme_type"="{[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Float@double}" "enzymejl_parmtype"="5421396000" "enzymejl_parmtype_ref"="1" %0) unnamed_addr #20 !dbg !587 {
top:
  %1 = call {}*** @julia.get_pgcstack()
  %current_task125 = getelementptr inbounds {}**, {}*** %1, i64 -14
  %2 = bitcast {}*** %current_task125 to {}*
  %ptls_field26 = getelementptr inbounds {}**, {}*** %1, i64 2
  %3 = bitcast {}*** %ptls_field26 to i64***
  %ptls_load2728 = load i64**, i64*** %3, align 8, !tbaa !29
  %4 = getelementptr inbounds i64*, i64** %ptls_load2728, i64 2
  %safepoint = load i64*, i64** %4, align 8, !tbaa !33
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint) #26, !dbg !589
  fence syncscope("singlethread") seq_cst
  %5 = getelementptr inbounds [2 x double], [2 x double] addrspace(11)* %0, i64 0, i64 0, !dbg !590
  %6 = getelementptr inbounds [2 x double], [2 x double] addrspace(11)* %0, i64 0, i64 1, !dbg !592
  %7 = load double, double addrspace(11)* %5, align 8, !dbg !599, !tbaa !33, !alias.scope !218, !noalias !221, !enzyme_type !226, !enzymejl_source_type_Float64 !0, !enzymejl_byref_BITS_VALUE !0
  %8 = load double, double addrspace(11)* %6, align 8, !dbg !599, !tbaa !33, !alias.scope !218, !noalias !221, !enzyme_type !226, !enzymejl_source_type_Float64 !0, !enzymejl_byref_BITS_VALUE !0
  %9 = fcmp une double %7, %8, !dbg !599
  br i1 %9, label %L8, label %L5, !dbg !601

L5:                                               ; preds = %top
  %10 = call fastcc [1 x {} addrspace(10)*] @julia_ArgumentError_28618({} addrspace(10)* nofree noundef nonnull readonly align 32 addrspacecast ({}* inttoptr (i64 6033208416 to {}*) to {} addrspace(10)*)), !dbg !601
  %11 = call noalias nonnull align 8 dereferenceable(8) "enzyme_inactive" "enzyme_type"="{[-1]:Pointer, [-1,-1]:Pointer}" {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 noundef 8, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 5448471936 to {}*) to {} addrspace(10)*)) #28, !dbg !601
  %12 = bitcast {} addrspace(10)* %11 to [1 x {} addrspace(10)*] addrspace(10)*, !dbg !601, !enzyme_inactive !0
  %13 = extractvalue [1 x {} addrspace(10)*] %10, 0, !dbg !601
  %14 = getelementptr [1 x {} addrspace(10)*], [1 x {} addrspace(10)*] addrspace(10)* %12, i64 0, i64 0, !dbg !601
  store {} addrspace(10)* %13, {} addrspace(10)* addrspace(10)* %14, align 8, !dbg !601, !tbaa !286, !alias.scope !290, !noalias !602
  %15 = addrspacecast {} addrspace(10)* %11 to {} addrspace(12)*, !dbg !601, !enzyme_inactive !0
  call void @ijl_throw({} addrspace(12)* %15) #29, !dbg !601
  unreachable, !dbg !601

L8:                                               ; preds = %top
  %16 = fcmp ord double %7, %8, !dbg !605
  %17 = fsub double %7, %8, !dbg !637
  %18 = bitcast double %17 to i64, !dbg !640
  %19 = icmp sgt i64 %18, -1, !dbg !642
  %20 = select i1 %19, double %8, double %7, !dbg !646
  %21 = select i1 %16, double %20, double %17, !dbg !646
  %22 = select i1 %19, double %7, double %8, !dbg !648
  %23 = select i1 %16, double %22, double %17, !dbg !648
  %24 = fcmp uge double %23, %21, !dbg !650
  %value_phi = select i1 %24, double %23, double %21, !dbg !654
  %value_phi3 = select i1 %24, double %21, double %23, !dbg !654
  %25 = call double @llvm.fabs.f64(double %value_phi3), !dbg !655
  %26 = bitcast double %25 to i64, !dbg !657
  %.not = icmp eq i64 %26, 9218868437227405312, !dbg !657
  %27 = call double @julia_nextfloat_28514(double %value_phi3)
  %spec.select21 = select i1 %.not, double %27, double %value_phi3, !dbg !659
  %28 = call double @llvm.fabs.f64(double %value_phi), !dbg !660

@wsmoses
Copy link
Member

wsmoses commented Nov 27, 2024

file an issue with julia?

@mhauru
Copy link
Contributor Author

mhauru commented Nov 29, 2024

Could you file the Julia issue please? I have very little understanding of what's going on here, and it would take me a long time to write a good bug report about this.

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

No branches or pull requests

2 participants