Skip to content

Conversation

@wsmoses
Copy link
Member

@wsmoses wsmoses commented Nov 17, 2025

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 17, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/compiler.jl b/src/compiler.jl
index 45d9df78..75b1a67a 100644
--- a/src/compiler.jl
+++ b/src/compiler.jl
@@ -3804,59 +3804,59 @@ function move_sret_tofrom_roots!(builder::LLVM.IRBuilder, jltype::LLVM.LLVMType,
 	# aka bfs/etc
         while length(todo) != 0
             path, ty = popfirst!(todo)
-            if !any_jltypes(ty)
-                continue
-            end
+        if !any_jltypes(ty)
+            continue
+        end
 
             if isa(ty, LLVM.PointerType)
 
-        		if direction == SRetPointerToRootPointer || direction == SRetValueToRootPointer || direction == RootPointerToSRetPointer || direction == RootPointerToSRetValue
-                          loc = inbounds_gep!(
-                              builder,
-                              root_ty,
-                              rootRet,
-        		      to_llvm(Cuint[count]),
-        		     )
-        		end
-                        
-        		if direction == SRetPointerToRootPointer
-        		    outloc = inbounds_gep!(builder, jltype, sret, to_llvm(path))
-        		    outloc = load!(builder, ty, outloc)
-                            store!(builder, outloc, loc)
-        		elseif direction == SRetValueToRootPointer
-        		    outloc = Enzyme.API.e_extract_value!(builder, sret, path)
-                            store!(builder, outloc, loc)
-        		elseif direction == RootPointerToSRetValue
-        		    loc = load!(builder, ty, loc)
-        		    val = Enzyme.API.e_insert_value!(builder, val, loc, path)
-                elseif direction == NullifySRetValue
-                    loc = unsafe_to_llvm(builder, nothing)
-                    val = Enzyme.API.e_insert_value!(builder, val, loc, path)
-        		elseif direction == RootPointerToSRetPointer
-        		    outloc = inbounds_gep!(builder, jltype, sret, to_llvm(path))
-        		    loc = load!(builder, ty, loc)
-        		    push!(extracted, loc)
-                            store!(builder, loc, outloc)
-        		else
-        		    @assert false "Unhandled direction"
-        		end
-                        
-        		count += 1
+            if direction == SRetPointerToRootPointer || direction == SRetValueToRootPointer || direction == RootPointerToSRetPointer || direction == RootPointerToSRetValue
+                loc = inbounds_gep!(
+                    builder,
+                    root_ty,
+                    rootRet,
+                    to_llvm(Cuint[count]),
+                )
+            end
+
+            if direction == SRetPointerToRootPointer
+                outloc = inbounds_gep!(builder, jltype, sret, to_llvm(path))
+                outloc = load!(builder, ty, outloc)
+                store!(builder, outloc, loc)
+            elseif direction == SRetValueToRootPointer
+                outloc = Enzyme.API.e_extract_value!(builder, sret, path)
+                store!(builder, outloc, loc)
+            elseif direction == RootPointerToSRetValue
+                loc = load!(builder, ty, loc)
+                val = Enzyme.API.e_insert_value!(builder, val, loc, path)
+            elseif direction == NullifySRetValue
+                loc = unsafe_to_llvm(builder, nothing)
+                val = Enzyme.API.e_insert_value!(builder, val, loc, path)
+            elseif direction == RootPointerToSRetPointer
+                outloc = inbounds_gep!(builder, jltype, sret, to_llvm(path))
+                loc = load!(builder, ty, loc)
+                push!(extracted, loc)
+                store!(builder, loc, outloc)
+            else
+                @assert false "Unhandled direction"
+            end
+
+            count += 1
                 continue
             end
             if isa(ty, LLVM.ArrayType)
-                for i = 1:length(ty)
-                    npath = copy(path)
-		push!(npath, i - 1)
-                    push!(todo, (npath, eltype(ty)))
+            for i in 1:length(ty)
+                npath = copy(path)
+                push!(npath, i - 1)
+                push!(todo, (npath, eltype(ty)))
                 end
                 continue
             end
             if isa(ty, LLVM.VectorType)
-                for i = 1:size(ty)
-                    npath = copy(path)
-		push!(npath, i - 1)
-                    push!(todo, (npath, eltype(ty)))
+            for i in 1:size(ty)
+                npath = copy(path)
+                push!(npath, i - 1)
+                push!(todo, (npath, eltype(ty)))
                 end
                 continue
             end
@@ -6906,7 +6906,7 @@ end
     @nospecialize(strongzero::Val)
 )
     id = deferred_id_codegen(fa, a, tt, mode, width, modifiedbetween, returnprimal, shadowinit, expectedtapetype, erriffuncwritten, runtimeactivity, strongzero)
-    ccall("extern deferred_codegen", llvmcall, Ptr{Cvoid}, (UInt,), id)
+    return ccall("extern deferred_codegen", llvmcall, Ptr{Cvoid}, (UInt,), id)
 end
 
 include("compiler/reflection.jl")
diff --git a/src/compiler/optimize.jl b/src/compiler/optimize.jl
index 6ff32c99..99d89625 100644
--- a/src/compiler/optimize.jl
+++ b/src/compiler/optimize.jl
@@ -188,7 +188,7 @@ function optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
     
     run!(GCInvariantVerifierPass(strong=false), mod)
     
-    removeDeadArgs!(mod, tm, #=post_gc_fixup=#false)
+    removeDeadArgs!(mod, tm, #=post_gc_fixup=# false)
     
     run!(GCInvariantVerifierPass(strong=false), mod)
 
@@ -364,9 +364,9 @@ const DumpPostCallConv = Ref(false)
 
 function post_optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine, machine::Bool = true)
     addr13NoAlias(mod)
-    removeDeadArgs!(mod, tm, #=post_gc_fixup=#false)
+    removeDeadArgs!(mod, tm, #=post_gc_fixup=# false)
     if DumpPreCallConv[]
-	    API.EnzymeDumpModuleRef(mod.ref)
+        API.EnzymeDumpModuleRef(mod.ref)
     end
     for f in collect(functions(mod))
         API.EnzymeFixupJuliaCallingConvention(f)
@@ -375,7 +375,7 @@ function post_optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine, machine::Bool
         API.EnzymeFixupBatchedJuliaCallingConvention(f)
     end
     if DumpPostCallConv[]
-	    API.EnzymeDumpModuleRef(mod.ref)
+        API.EnzymeDumpModuleRef(mod.ref)
     end
     for g in collect(globals(mod))
         if startswith(LLVM.name(g), "ccall")
diff --git a/src/llvm/transforms.jl b/src/llvm/transforms.jl
index 4d43c651..71f26fef 100644
--- a/src/llvm/transforms.jl
+++ b/src/llvm/transforms.jl
@@ -776,11 +776,11 @@ function nodecayed_phis!(mod::LLVM.Module)
                                     end
                                     if addrspace(value_type(v2)) == 0
                                         if addr == 11
-					    PT = if LLVM.is_opaque(value_type(v))
-						LLVM.PointerType(10)
-					    else
-						LLVM.PointerType(eltype(value_type(v)), 10)
-					    end
+                                            PT = if LLVM.is_opaque(value_type(v))
+                                                LLVM.PointerType(10)
+                                            else
+                                                LLVM.PointerType(eltype(value_type(v)), 10)
+                                            end
                                             v2 = const_addrspacecast(
                                                 v2,
                                                 PT
@@ -789,11 +789,11 @@ function nodecayed_phis!(mod::LLVM.Module)
                                         end
                                     end
                                     if LLVM.isnull(v2)
-					PT = if LLVM.is_opaque(value_type(v))
-					   LLVM.PointerType(10)
-				        else
-					   LLVM.PointerType(eltype(value_type(v)), 10)
-				        end
+                                        PT = if LLVM.is_opaque(value_type(v))
+                                            LLVM.PointerType(10)
+                                        else
+                                            LLVM.PointerType(eltype(value_type(v)), 10)
+                                        end
                                         v2 = const_addrspacecast(
                                             v2,
                                             PT
@@ -826,7 +826,7 @@ function nodecayed_phis!(mod::LLVM.Module)
                                         offset,
                                         API.EnzymeComputeByteOffsetOfGEP(b, v, offty),
                                     )
-				    if !LLVM.is_opaque(value_type(v))
+                                    if !LLVM.is_opaque(value_type(v))
                                     v2 = const_bitcast(
                                         v2,
                                         LLVM.PointerType(
@@ -835,7 +835,7 @@ function nodecayed_phis!(mod::LLVM.Module)
                                         ),
                                     )
                                     @assert eltype(value_type(v2)) == eltype(value_type(v))
-				    end
+                                    end
                                     return v2, offset, skipload
                                 end
 
@@ -843,11 +843,11 @@ function nodecayed_phis!(mod::LLVM.Module)
 
                             if isa(v, LLVM.AddrSpaceCastInst)
                                 if addrspace(value_type(operands(v)[1])) == 0
-					PT = if LLVM.is_opaque(value_type(v))
-					   LLVM.PointerType(10)
-				        else
-					   LLVM.PointerType(eltype(value_type(v)), 10)
-				        end
+                                    PT = if LLVM.is_opaque(value_type(v))
+                                        LLVM.PointerType(10)
+                                    else
+                                        LLVM.PointerType(eltype(value_type(v)), 10)
+                                    end
                                     v2 = addrspacecast!(
                                         b,
                                         operands(v)[1],
@@ -895,16 +895,16 @@ function nodecayed_phis!(mod::LLVM.Module)
                             )
                                 v2, offset, skipload =
                                     getparent(b, operands(v)[1], offset, hasload, phicache)
-				    if !LLVM.is_opaque(value_type(v))
-					    v2 = bitcast!(
-					    b,
-					    v2,
-					    LLVM.PointerType(
-						eltype(value_type(v)),
-						addrspace(value_type(v2)),
-					    ),
-					)
-				    end
+                                if !LLVM.is_opaque(value_type(v))
+                                    v2 = bitcast!(
+                                        b,
+                                        v2,
+                                        LLVM.PointerType(
+                                            eltype(value_type(v)),
+                                            addrspace(value_type(v2)),
+                                        ),
+                                    )
+                                end
                                 @assert eltype(value_type(v2)) == eltype(value_type(v))
                                 return v2, offset, skipload
                             end
@@ -1286,7 +1286,7 @@ function fix_decayaddr!(mod::LLVM.Module)
                                 t_sret = true
                             end
                             if kind(a) == kind(StringAttribute("enzymejl_returnRoots"))
-				sret_elty = sret_ty(fop, i)
+                                sret_elty = sret_ty(fop, i)
                                 t_sret = true
                             end
                             # if kind(a) == kind(StringAttribute("enzyme_sret_v"))
diff --git a/src/rules/llvmrules.jl b/src/rules/llvmrules.jl
index 5d8533db..6ec6335e 100644
--- a/src/rules/llvmrules.jl
+++ b/src/rules/llvmrules.jl
@@ -1953,12 +1953,12 @@ end
     API.moveBefore(newo, err, B)
 
     if unsafe_load(shadowR) != C_NULL
-	valTys = API.CValueType[]
-	args = LLVM.Value[]
-	for i in 1:(length(operands(orig))-1)    
-	    push!(valTys, API.VT_Primal)
-	    push!(args, new_from_original(gutils, operands(orig)[i]))
-	end
+        valTys = API.CValueType[]
+        args = LLVM.Value[]
+        for i in 1:(length(operands(orig)) - 1)
+            push!(valTys, API.VT_Primal)
+            push!(args, new_from_original(gutils, operands(orig)[i]))
+        end
         normal = call_samefunc_with_inverted_bundles!(B, gutils, orig, args, valTys, false) #=lookup=#
         width = get_width(gutils)
         if width == 1
@@ -1988,13 +1988,13 @@ end
     newo = new_from_original(gutils, orig)
     API.moveBefore(newo, err, B)
     if unsafe_load(shadowR) != C_NULL
-	valTys = API.CValueType[]
-	args = LLVM.Value[]
-	for i in 1:(length(operands(orig))-1)    
-	    push!(valTys, API.VT_Primal)
-	    push!(args, new_from_original(gutils, operands(orig)[i]))
-	end
-	normal = call_samefunc_with_inverted_bundles!(B, gutils, orig, args, valTys, false) #=lookup=#
+        valTys = API.CValueType[]
+        args = LLVM.Value[]
+        for i in 1:(length(operands(orig)) - 1)
+            push!(valTys, API.VT_Primal)
+            push!(args, new_from_original(gutils, operands(orig)[i]))
+        end
+        normal = call_samefunc_with_inverted_bundles!(B, gutils, orig, args, valTys, false) #=lookup=#
         width = get_width(gutils)
         if width == 1
             shadowres = normal
@@ -2393,9 +2393,10 @@ end
         @fwdfunc(new_structt_fwd),
     )
     register_handler!(
-        ("jl_get_binding_or_error", "ijl_get_binding_or_error",
-	 "jl_get_binding_value_seqcst", "ijl_get_binding_value_seqcst",
-	 ),
+        (
+            "jl_get_binding_or_error", "ijl_get_binding_or_error",
+            "jl_get_binding_value_seqcst", "ijl_get_binding_value_seqcst",
+        ),
         @augfunc(get_binding_or_error_augfwd),
         @revfunc(get_binding_or_error_rev),
         @fwdfunc(get_binding_or_error_fwd),

@github-actions
Copy link
Contributor

github-actions bot commented Nov 17, 2025

Benchmark Results

main 1759479... main / 1759479...
basics/make_zero/namedtuple 0.0536 ± 0.0019 μs 0.0548 ± 0.0025 μs 0.979 ± 0.056
basics/make_zero/struct 0.266 ± 0.0072 μs 0.28 ± 0.0085 μs 0.949 ± 0.039
basics/overhead 4.34 ± 0.01 ns 4.34 ± 0.01 ns 1 ± 0.0033
basics/remake_zero!/namedtuple 0.235 ± 0.0098 μs 0.238 ± 0.0091 μs 0.99 ± 0.056
basics/remake_zero!/struct 0.234 ± 0.0089 μs 0.241 ± 0.0095 μs 0.972 ± 0.053
fold_broadcast/multidim_sum_bcast/1D 10.3 ± 0.36 μs 10.3 ± 0.28 μs 1 ± 0.044
fold_broadcast/multidim_sum_bcast/2D 12.2 ± 0.3 μs 12.2 ± 0.29 μs 1.01 ± 0.034
time_to_load 1.28 ± 0.013 s 1.31 ± 0.012 s 0.978 ± 0.013

Benchmark Plots

A plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/19544687048/artifacts/4630531820.

@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 51.28205% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.06%. Comparing base (a54bfbd) to head (1759479).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/compiler.jl 44.44% 20 Missing ⚠️
src/llvm/transforms.jl 29.41% 12 Missing ⚠️
src/errors.jl 0.00% 3 Missing ⚠️
src/compiler/optimize.jl 71.42% 2 Missing ⚠️
lib/EnzymeCore/src/easyrules.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2793      +/-   ##
==========================================
- Coverage   68.28%   68.06%   -0.22%     
==========================================
  Files          58       58              
  Lines       20521    20495      -26     
==========================================
- Hits        14012    13950      -62     
- Misses       6509     6545      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wsmoses wsmoses merged commit 70eef9d into main Nov 20, 2025
48 of 54 checks passed
@wsmoses wsmoses deleted the rpathing branch November 20, 2025 18:51
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 this pull request may close these issues.

2 participants