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

Fix ternary value copying #713

Merged
merged 2 commits into from
Jan 17, 2025
Merged

Fix ternary value copying #713

merged 2 commits into from
Jan 17, 2025

Conversation

marcauberer
Copy link
Member

  • Fix ternary value copying
  • Add more lifetime object tests

We have four different possibilities of operand combinations (temporary/non-temporary):

true is tmp, false is tmp:

    true_block:
        trueVal = getValue(trueExpr)
        jmp end_block
    false_block:
        falseVal = getValue(falseExpr)
        jmp end_block:
    end_block:
        resultVal = phi [true_block trueVal, false_block falseVal]

true is tmp, false is not:

        falsePtr = alloca
    true_block:
        truePtr = getAddress(trueExpr)
        jmp end_block
    false_block:
        originalPtr = getAddress(falseExpr)
        callCopyCtor(falsePtr, originalPtr)
        jmp end_block
    end_block:
        resultPtr = phi [true_block truePtr, false_block falsePtr]

true is not, false is tmp:
    
        truePtr = alloca
    true_block:
        originalPtr = getAddress(trueExpr)
        callCopyCtor(truePtr, originalPtr)
        jmp end_block
    false_block:
        falsePtr = getAddress(falseExpr)
        jmp end_block
    end_block:
        resultPtr = phi [true_block truePtr, false_block falsePtr]

true is not, false is not:

        resultPtr = alloca
    true_block:
        truePtr = getAddress(trueExpr)
        jmp end_block
    false_block:
        falsePtr = getAddress(falseExpr)
        jmp end_block
    end_block:
        originalPtr = phi [true_block truePtr, false_block falsePtr]
        callCopyCtor(originalPtr, resultPtr)

@marcauberer marcauberer added bug Something isn't working improvement Improvement of an existing feature labels Jan 17, 2025
@marcauberer marcauberer added this to the 0.21.0 milestone Jan 17, 2025
@marcauberer marcauberer self-assigned this Jan 17, 2025
@marcauberer marcauberer requested a review from a team as a code owner January 17, 2025 21:13
@marcauberer marcauberer enabled auto-merge (squash) January 17, 2025 21:18
@marcauberer marcauberer merged commit c739d58 into main Jan 17, 2025
5 checks passed
@marcauberer marcauberer deleted the fix/ternary-value-copies branch January 17, 2025 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler improvement Improvement of an existing feature size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant