@@ -6606,6 +6606,42 @@ borrowedLLVMArrayForArray lhs rhs =
6606
6606
| otherwise
6607
6607
= bs_skip ++ bs_lhs
6608
6608
6609
+ -- | TODO: hide the bool parameter
6610
+ solveForArray ::
6611
+ (1 <= w , KnownNat w , NuMatchingAny1 r ) =>
6612
+ Bool ->
6613
+ [AtomicPerm (LLVMPointerType w )] ->
6614
+ Mb vars (LLVMArrayPerm w ) ->
6615
+ ImplM vars s r ps ps ()
6616
+ solveForArray should_fail ps mb_ap =
6617
+ getPSubst >>>= \ psubst ->
6618
+ case partialSubst psubst mb_ap of
6619
+ Just _ap -> return ()
6620
+ Nothing
6621
+ | should_fail ->
6622
+ implFailM " goo goo"
6623
+ | otherwise ->
6624
+ solveForArrayH ps psubst mb_ap
6625
+
6626
+ solveForArrayH ::
6627
+ (1 <= w , KnownNat w , NuMatchingAny1 r ) =>
6628
+ [AtomicPerm (LLVMPointerType w )] ->
6629
+ PartialSubst vars ->
6630
+ Mb vars (LLVMArrayPerm w ) ->
6631
+ ImplM vars s r ps ps ()
6632
+ solveForArrayH ps psubst mb_ap
6633
+ | Nothing <- partialSubst psubst $ mbLLVMArrayLifetime mb_ap
6634
+ , Just l: _ <- atomicPermLifetime <$> ps =
6635
+ tryUnifyVars l (mbLLVMArrayLifetime mb_ap) >>>
6636
+ solveForArray False ps mb_ap
6637
+ solveForArrayH ps psubst mb_ap
6638
+ | Nothing <- partialSubst psubst $ mbLLVMArrayRW mb_ap
6639
+ , Just l: _ <- atomicPermModality <$> ps =
6640
+ tryUnifyVars l (mbLLVMArrayRW mb_ap) >>>
6641
+ solveForArray False ps mb_ap
6642
+ solveForArrayH ps _ mb_ap =
6643
+ solveForArray True ps mb_ap
6644
+
6609
6645
6610
6646
-- | Prove an LLVM array permission @ap@ from permissions @x:(p1 * ... *pn)@ on
6611
6647
-- the top of the stack, ensuring that any remaining permissions for @x@ get
@@ -6701,6 +6737,12 @@ proveVarLLVMArrayH x p psubst ps mb_ap
6701
6737
-- Otherwise, try and build a completely borrowed array that references existing
6702
6738
-- permissions that cover the range of mb_ap, and recurse (hitting the special
6703
6739
-- case above).
6740
+ proveVarLLVMArrayH x first_p psubst ps mb_ap
6741
+ | Nothing <- partialSubst psubst mb_ap =
6742
+ solveForArray False ps mb_ap >>>
6743
+ getPSubst >>>= \ psubst' ->
6744
+ proveVarLLVMArrayH x first_p psubst' ps mb_ap
6745
+
6704
6746
proveVarLLVMArrayH x first_p psubst ps mb_ap
6705
6747
| Just ap <- partialSubst psubst mb_ap
6706
6748
-- NOTE: borrowedLLVMArrayForArray only returns a single possible covering, though
0 commit comments