+
    -i,=                     |   ^ RI t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
u Ht R t ! R R4      t ! R	 R
]4      t]P                   ! ^4      P#                  4       t ! R R]]4      t ! R R]]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t]R8X  d   ] P4                  ! 4        R# R# )    N)defaultdict)ir)binding)TestCasec              #      a "   V 3R  lp\         P                  P                  4        F-  w  r#VP                  R4      '       g   K  RV 2V! V4      3x  K/  	  R# 5i)c                 Z   <a  V V3R  lpRS P                    RS P                   2Vn        V# )c                    < S! V S4      # N )selffngenerate_tests   &Z/var/www/html/photoedit/myenv/lib/python3.14/site-packages/llvmlite/tests/test_refprune.pywrapped-_iterate_cases.<locals>.wrap.<locals>.wrapped   s     r**    zgenerated test for .)
__module____name____doc__)r   r   r   s   f r   wrap_iterate_cases.<locals>.wrap   s)    	+/a}Mr   casetest_N)proto__dict__items
startswith)r   r   kcase_fns   f   r   _iterate_casesr!   
   sJ      nn**,
<<!+tG},, -s   >AAc                   &   a  ] tR t^t o R tRtV tR# )PassManagerMixinc                    \         P                  ! 4        \         P                  P                  4       P	                  4       p\         P
                  ! ^ ^ R7      p\         P                  ! W4      # )r   )speed_level
size_level)llvminitialize_native_targetTargetfrom_default_triplecreate_target_machinecreate_pipeline_tuning_optionscreate_pass_builder)r   tmptos   &  r   pbPassManagerMixin.pb   sL    %%'[[,,.DDF11aAN''00r   r   N)r   r   __qualname____firstlineno__r0   __static_attributes____classdictcell____classdict__s   @r   r#   r#      s     1 1r   r#   c                   b   a  ] tR t^t o RtR t]! ]4       F  w  tt]]	! 4       ]&   K  	  Rt
V tR# )TestRefPrunePrototypez%
Test that the prototype is working.
c                    V! 4       w  r#p\         P                  ! W#4      P                  4       pV P                  WE4       R # r
   )r   FanoutAlgorithmrunassertEqual)r   case_gennodesedgesexpectedgots   &&    r   r   #TestRefPrunePrototype.generate_test#   s5    !)h##E1557'r   r   N)r   r   r2   r3   r   r   r!   namer   localsr4   r5   r6   s   @r   r9   r9      s/     ( %]3
d 4r   r9   c                      a  ] tR t^0t o RtR tR tR tR tR t	R t
R tR	 t]! ]4       F  w  tt]]! 4       ]&   K  	  R
tV tR# )TestRefPrunePassz
Test that the C++ implementation matches the expected behavior as for
the prototype.

This generates a LLVM module for each test case, runs the pruner and checks
that the expected results are achieved.
c                    \         P                  ! \         P                  ! 4       \        .4      p\         P                  ! WR R7      # )
NRT_increfrD   r   FunctionTypeVoidTypeptr_tyFunctionr   mfntys   && r   make_increfTestRefPrunePass.make_incref9   +    r{{}vh7{{166r   c                    \         P                  ! \         P                  ! 4       \        .4      p\         P                  ! WR R7      # )
NRT_decrefrJ   rK   rP   s   && r   make_decrefTestRefPrunePass.make_decref=   rU   r   c                    \         P                  ! \         P                  ! ^ 4      R4      p\         P                  ! WRR7      # )    switcherrJ   r   r   rL   IntTyperO   rP   s   && r   make_switcherTestRefPrunePass.make_switcherA   s+    rzz"~r2{{144r   c                    \         P                  ! \         P                  ! ^4      R4      p\         P                  ! WRR7      # )   brancherrJ   r   r]   rP   s   && r   make_brancherTestRefPrunePass.make_brancherE   s+    rzz!}b1{{144r   c                   \         P                  ! 4       pV P                  V4      pV P                  V4      pV P	                  V4      pV P                  V4      p\         P                  ! \         P                  ! 4       \        .4      p\         P                  ! W8R R7      p	V	P                  w  p
RV
n        / pV F  pV	P                  V4      W&   K  	  \         P                  ! 4       pVP                  4        EFt  w  rVP                  W,          4       W,           FB  pVR8X  d   VP!                  WJ.4       K  VR8X  d   VP!                  WZ.4       K9  \#        R4      h	  \%        V4      pV^ 8X  d   VP'                  4        K  V^8X  d   Vw  pVP)                  VV,          4       K  V^8X  d;   Vw  ppVP!                  VR4      pVP+                  VVV,          VV,          4       K  V^8  dq   VP!                  VR4      pVvppVP-                  VVV,          R7      p\/        V4       F.  w  ppVP1                  VP3                  V4      VV,          4       K0  	  EKl  \#        R4      h	  V# )mainrJ   memincrefdecrefunreachable)defaultr   )r   ModulerS   rX   r_   rd   rL   rM   rN   rO   argsrD   append_basic_block	IRBuilderr   position_at_endcallAssertionErrorlenret_voidbranchcbranchswitch	enumerateadd_casetype)r   r?   r@   rQ   	incref_fn	decref_fnswitcher_fnbrancher_fnrR   r   ptrbbmapbbbuilderjump_targetsaction	n_targetsdstleftrightselheadtailswis   &&&                      r   generate_irTestRefPrunePass.generate_irI   s	   IIK$$Q'	$$Q'	((+((+r{{}vh7[[v.B--b1EI  ,,. %B##EI.))X%LLE2x'LLE2(77 $ L)IA~  "a$uSz*a ,ull;3U4[%,?Qll;3 ,^^Ct^='oFAsKKU3Z8 . %]33? !.B r   c                    \         P                  ! \        V4      4      pV P                  4       pVP	                  4       pVP                  4        VP                  W#4       V# r
   )r'   parse_assemblystrr0   getModulePassManageradd_refprune_passr<   )r   irmodmodr0   pms   &&   r   apply_refpruneTestRefPrunePass.apply_refprune   sK    !!#e*-WWY$$&

s
r   c                   \        R  4      pVP                  4        F/  w  rVVP                  R4      pVP                  R4      pRVRV/WE&   K1  	  VP                  4        F]  w  rYVP                  V4      '       g   K  V	R;;,          ^,          uu&   W%,           F  p
WJ,          R;;,          ^,          uu&   K   	  K_  	  VP                   F  pVP
                  R8X  g   K   M	  XP                   F~  pWLP
                  ,          p	\        V4      pVP                  R4      pVP                  R4      pV P                  V	R,          VRV 2R7       V P                  V	R,          VRV 2R7       K  	  R# )	c                       \        \        4      # r
   )r   intr   r   r   <lambda>(TestRefPrunePass.check.<locals>.<lambda>   s	    C 0r   ri   rj   rg   rI   rW   zBB )msgN)	r   r   countget	functionsrD   blocksr   r=   )r   r   rA   r?   dr   vsn_increfn_decrefstatsdec_bbfr   texts   &&&&          r   checkTestRefPrunePass.check   s9   
 01[[]EAxx)Hxx)Hh(;AD # 	HA||Ah1$&kkFIh'1,' * " Avv 
 ((BggJEr7Dzz,/Hzz,/HU8_hc"JGU8_hc"JG r   c                    V! 4       w  r#pV P                  W#4      pV P                  V4      pV P                  WdV4       R # r
   )r   r   r   )r   r>   r?   r@   rA   r   outmods   &&     r   r   TestRefPrunePass.generate_test   s<    !)h  .$$U+

6U+r   r   N)r   r   r2   r3   r   rS   rX   r_   rd   r   r   r   r   r!   rD   r   rE   r4   r5   r6   s   @r   rG   rG   0   sT     77554lH>, %]3
d 4r   rG   c                   2   a  ] tR t^t o ^ tRtRR ltRtV tR# )BaseTestByIRzG
declare void @NRT_incref(i8* %ptr)
declare void @NRT_decref(i8* %ptr)
Nc                   \         P                  ! V P                   R V 24      pV P                  4       pVP	                  4       pVf   VP                  V P                  4       MVP                  V P                  VR7       \         P                  ! 4       pVP                  W44       \         P                  ! 4       pW7V,
          3# )
subgraph_limit)	r'   r   prologuer0   r   r   refprune_bitmaskdump_refprune_statsr<   )r   r   r   r   r0   r   beforeafters   &&&     r   r   BaseTestByIR.check   s    !!T]]O2eW"=>WWY$$&!  !6!67  !6!60> ! @))+
s((*FN""r   r   r
   )	r   r   r2   r3   r   r   r   r4   r5   r6   s   @r   r   r      s     H
# #r   r   c                   t   a  ] tR t^t o ]P
                  P                  tRtR t	Rt
R tRtR tRtR tR	tV tR
# )	TestPerBBzv
define void @main(i8* %ptr) {
    call void @NRT_incref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R#    N)r   per_bb_ir_1r=   
basicblockr   r   r   s   &  r   test_per_bb_1TestPerBB.test_per_bb_1   s.    ZZ 0 01
))1-r   z
define void @main(i8* %ptr) {
    call void @NRT_incref(i8* %ptr)
    call void @NRT_incref(i8* %ptr)
    call void @NRT_incref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                    V P                  V P                  4      w  rV P                  VP                  ^4       V P	                  R\        V4      4       R# )   zcall void @NRT_incref(ptr %ptr)N)r   per_bb_ir_2r=   r   assertInr   r   s   &  r   test_per_bb_2TestPerBB.test_per_bb_2   sA    ZZ 0 01
))1-7SBr   z
define void @main(ptr %ptr, ptr %other) {
    call void @NRT_incref(ptr %ptr)
    call void @NRT_incref(ptr %ptr)
    call void @NRT_decref(ptr %ptr)
    call void @NRT_decref(ptr %other)
    ret void
}
c                    V P                  V P                  4      w  rV P                  VP                  ^4       V P	                  R\        V4      4       R# )r   !call void @NRT_decref(ptr %other)N)r   per_bb_ir_3r=   r   r   r   r   s   &  r   test_per_bb_3TestPerBB.test_per_bb_3   A    ZZ 0 01
))1-93s8Dr   z
; reordered
define void @main(ptr %ptr, ptr %other) {
    call void @NRT_incref(ptr %ptr)
    call void @NRT_decref(ptr %ptr)
    call void @NRT_decref(ptr %ptr)
    call void @NRT_decref(ptr %other)
    call void @NRT_incref(ptr %ptr)
    ret void
}
c                    V P                  V P                  4      w  rV P                  VP                  ^4       V P	                  R\        V4      4       R# )r   r   N)r   per_bb_ir_4r=   r   r   r   r   s   &  r   test_per_bb_4TestPerBB.test_per_bb_4  r   r   r   N)r   r   r2   r3   r'   RefPruneSubpassesPER_BBr   r   r   r   r   r   r   r   r   r4   r5   r6   s   @r   r   r      sP     --44K.	KCKE
KE Er   r   c                   ~   a  ] tR tRt o ]P
                  P                  tRtR t	Rt
R tRtR tRtR	 tR
tR tRtV tR# )TestDiamondi  z
define void @main(i8* %ptr) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br label %bb_B
bb_B:
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# r   )r   per_diamond_1r=   diamondr   s   &  r   test_per_diamond_1TestDiamond.test_per_diamond_1  ,    ZZ 2 23
*r   z
define void @main(i8* %ptr, i1 %cond) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    br label %bb_D
bb_C:
    br label %bb_D
bb_D:
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# r   )r   per_diamond_2r=   r   r   s   &  r   test_per_diamond_2TestDiamond.test_per_diamond_2,  r   r   a3  
define void @main(i8* %ptr, i1 %cond) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    br label %bb_D
bb_C:
    call void @NRT_decref(i8* %ptr)  ; reject because of decref in diamond
    br label %bb_D
bb_D:
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^ 4       R# r   N)r   per_diamond_3r=   r   r   s   &  r   test_per_diamond_3TestDiamond.test_per_diamond_3@  r   r   a5  
define void @main(i8* %ptr, i1 %cond) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_incref(i8* %ptr)     ; extra incref will not affect prune
    br label %bb_D
bb_C:
    br label %bb_D
bb_D:
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# r   )r   per_diamond_4r=   r   r   s   &  r   test_per_diamond_4TestDiamond.test_per_diamond_4T  r   r   a0  
define void @main(i8* %ptr, i1 %cond) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    br label %bb_D
bb_C:
    br label %bb_D
bb_D:
    call void @NRT_decref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# )r   N)r   per_diamond_5r=   r   r   s   &  r   test_per_diamond_5TestDiamond.test_per_diamond_5i  r   r   r   N)r   r   r2   r3   r'   r   DIAMONDr   r   r   r   r   r   r   r   r   r   r   r4   r5   r6   s   @r   r   r     sX     --55	M+M+M +M +M"+ +r   r   c                   t   a  ] tR tRt o Rt]P                  P                  tRt	R t
RtR tRtR tR	 tR
tV tR# )
TestFanoutin  z6More complex cases are tested in TestRefPrunePass
    z
define void @main(i8* %ptr, i1 %cond) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    ret void
bb_C:
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# )   N)r   fanout_1r=   fanoutr   s   &  r   test_fanout_1TestFanout.test_fanout_1  *    ZZ.
q)r   a6  
define void @main(i8* %ptr, i1 %cond, i8** %excinfo) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    ret void
bb_C:
    call void @NRT_decref(i8* %ptr)
    br label %bb_B                      ; illegal jump to other decref
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^ 4       R# r   )r   fanout_2r=   r   r   s   &  r   test_fanout_2TestFanout.test_fanout_2  r   r   a}  
define void @main(i8* %ptr, i1 %cond) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    ret void
bb_C:
    call void @NRT_decref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    ret void
}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# )   Nr   fanout_3r=   r   r   s   &  r   test_fanout_3TestFanout.test_fanout_3  r   r   c                |    V P                  V P                  ^R7      w  rV P                  VP                  ^ 4       R# )rb   r   Nr  r   s   &  r   test_fanout_3_limited TestFanout.test_fanout_3_limited  s0     ZZaZ@
q)r   r   N)r   r   r2   r3   r   r'   r   FANOUTr   r   r   r   r   r  r  r  r4   r5   r6   s   @r   r   r   n  sL      --44H*H*H$** *r   r   c                      a  ] tR tRt o ]P
                  P                  tRtR t	Rt
R tRtR tRtR	 tR
tR tRtR tRtV tR# )TestFanoutRaisei  a'  
define i32 @main(i8* %ptr, i1 %cond, i8** %excinfo) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    ret i32 0
bb_C:
    store i8* null, i8** %excinfo, !numba_exception_output !0
    ret i32 1
}
!0 = !{i1 true}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# r   )r   fanout_raise_1r=   fanout_raiser   s   &  r   test_fanout_raise_1#TestFanoutRaise.test_fanout_raise_1  .    ZZ 3 34
++Q/r   a:  
define i32 @main(i8* %ptr, i1 %cond, i8** %excinfo) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    ret i32 0
bb_C:
    store i8* null, i8** %excinfo, !numba_exception_typo !0      ; bad metadata
    ret i32 1
}

!0 = !{i1 true}
c                x    V P                  V P                  4      w  rV P                  VP                  ^ 4       R# r   )r   fanout_raise_2r=   r  r   s   &  r   test_fanout_raise_2#TestFanoutRaise.test_fanout_raise_2  s0     ZZ 3 34
++Q/r   a:  
define i32 @main(i8* %ptr, i1 %cond, i8** %excinfo) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    ret i32 0
bb_C:
    store i8* null, i8** %excinfo, !numba_exception_output !0
    ret i32 1
}

!0 = !{i32 1}       ; ok; use i32
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# r   )r   fanout_raise_3r=   r  r   s   &  r   test_fanout_raise_3#TestFanoutRaise.test_fanout_raise_3  r  r   a!  
define i32 @main(i8* %ptr, i1 %cond, i8** %excinfo) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    ret i32 1    ; BAD; all tails are raising without decref
bb_C:
    ret i32 1    ; BAD; all tails are raising without decref
}

!0 = !{i1 1}
c                x    V P                  V P                  4      w  rV P                  VP                  ^ 4       R# r   )r   fanout_raise_4r=   r  r   s   &  r   test_fanout_raise_4#TestFanoutRaise.test_fanout_raise_4  r  r   a  
define i32 @main(i8* %ptr, i1 %cond, i8** %excinfo) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    br label %common.ret
bb_C:
    store i8* null, i8** %excinfo, !numba_exception_output !0
    br label %common.ret
common.ret:
    %common.ret.op = phi i32 [ 0, %bb_B ], [ 1, %bb_C ]
    ret i32 %common.ret.op
}
!0 = !{i1 1}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# r   )r   fanout_raise_5r=   r  r   s   &  r   test_fanout_raise_5#TestFanoutRaise.test_fanout_raise_5  r  r   af  
define i32 @main(i8* %ptr, i1 %cond1, i1 %cond2, i1 %cond3, i8** %excinfo) {
bb_A:
    call void @NRT_incref(i8* %ptr)
    call void @NRT_incref(i8* %ptr)
    br i1 %cond1, label %bb_B, label %bb_C
bb_B:
    call void @NRT_decref(i8* %ptr)
    br i1 %cond2, label %bb_D, label %bb_E
bb_C:
    store i8* null, i8** %excinfo, !numba_exception_output !0
    ret i32 1
bb_D:
    call void @NRT_decref(i8* %ptr)
    ret i32 0
bb_E:
    call void @NRT_incref(i8* %ptr)
    br i1 %cond3, label %bb_F, label %bb_C
bb_F:
    call void @NRT_decref(i8* %ptr)
    call void @NRT_decref(i8* %ptr)
    ret i32 0
}
!0 = !{i1 1}
c                x    V P                  V P                  4      w  rV P                  VP                  ^4       R# )   N)r   fanout_raise_6r=   r  r   s   &  r   test_fanout_raise_6#TestFanoutRaise.test_fanout_raise_68  r  r   r   N)r   r   r2   r3   r'   r   FANOUT_RAISEr   r  r  r  r  r  r  r  r  r   r!  r%  r&  r4   r5   r6   s   @r   r  r    sd     --::N0N 0N 0N0N$0
N40 0r   r  __main__)unittestcollectionsr   llvmliter   r   r'   llvmlite.testsr   llvmlite.tests.refprune_prototestsrefprune_protor   r!   r#   r9   r^   
as_pointerrN   rG   r   r   r   r   r  r   rg   r   r   r   <module>r2     s     #  $ # - -	-1 1H  
A	!	!	#~x!1 ~B#8- #.@E @EF`+, `+FD* D*NE0l E0P zMMO r   