Fix mixed-size memcpy_s#1002
Merged
hernanponcedeleon merged 17 commits intodevelopmentfrom Mar 13, 2026
Merged
Conversation
This enables more dead code elimination.
Will later enable dynamic-sized memcpy.
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
Comment on lines
+1744
to
+1745
| final IntegerType resultType = returnReg.getType() instanceof IntegerType t ? t : null; | ||
| final Expression zero = expressions.makeZero(resultType); |
There was a problem hiding this comment.
I do not like this kind of code. If we expect the result register to be of type integer (otherwise we will get some exception somewhere else when trying to create the zero value with null type), we should have a proper precondition to the method
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
ThomasHaas
reviewed
Mar 10, 2026
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
Support arbitrary fill values for `memset`. Re-implement deterministic return values for `memcmp`. Fix span size for `--mixedSize=false`.
This enables more dead code elimination.
Will later enable dynamic-sized memcpy.
Support arbitrary fill values for `memset`. Re-implement deterministic return values for `memcmp`. Fix span size for `--mixedSize=false`.
bb80657 to
952eec6
Compare
ThomasHaas
reviewed
Mar 12, 2026
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java
Outdated
Show resolved
Hide resolved
Adjust comments in `inlineMemCpyS`.
Collaborator
|
I think the code looks a lot better now, especially with the clarification what a |
Comment on lines
+1665
to
+1666
| final Expression errorCodeFail = expressions.makeOne((IntegerType)resultRegister.getType()); | ||
| final Expression errorCodeSuccess = expressions.makeZero((IntegerType)resultRegister.getType()); |
There was a problem hiding this comment.
errorCodeSuccess -> having error/success together is weird. I would call it returnCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modifies the intrinsics for the
string.hstandard library functions to be compatible with mixed-size accesses. With the current default settings, dynamic memory accesses are torn into units ofarchType. E.g.memcpy(dest, src, 16)translates toWith the option
--mixedSize=true, more informed tearing is applied later. So that call translates toWIth this PR, that scheme also applies to
memcpy_s,memcmpandmemset. This should fix at least #977.