-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add support for std::initializer_list in the reverse mode #1018
Conversation
075d682
to
31bd298
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
46fcab0
to
f76201c
Compare
clang-tidy review says "All clean, LGTM! 👍" |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1018 +/- ##
==========================================
+ Coverage 94.12% 94.28% +0.16%
==========================================
Files 55 55
Lines 8266 8293 +27
==========================================
+ Hits 7780 7819 +39
+ Misses 486 474 -12
... and 2 files with indirect coverage changes
|
f76201c
to
d6361cd
Compare
clang-tidy review says "All clean, LGTM! 👍" |
b0ea09e
to
e9e6ed5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
8c98120
to
2d982a5
Compare
clang-tidy review says "All clean, LGTM! 👍" |
2 similar comments
clang-tidy review says "All clean, LGTM! 👍" |
clang-tidy review says "All clean, LGTM! 👍" |
852162e
to
f572746
Compare
clang-tidy review says "All clean, LGTM! 👍" |
1952e6b
to
09402df
Compare
clang-tidy review says "All clean, LGTM! 👍" |
09402df
to
e1e9ac1
Compare
clang-tidy review says "All clean, LGTM! 👍" |
e1e9ac1
to
e2f5ad8
Compare
clang-tidy review says "All clean, LGTM! 👍" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we are heading in a good direction. See some comments inline.
8f7b4aa
to
3a93094
Compare
clang-tidy review says "All clean, LGTM! 👍" |
unsigned numInits = ILE->getNumInits(); | ||
VDDerivedInit = ConstantFolder::synthesizeLiteral( | ||
m_Context.getSizeType(), m_Context, numInits); | ||
VDCloneType = VDDerivedType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not assigning directly to VDCloneType
rather to a temporary VDDerivedType
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VDDerivedType
is not temporary, it represents the type of the adjoint variable, whereas VDCloneType
represents the type of the cloned variable. The same type is used for both the clone and the adjoint, hence the assignment later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I did not realize it was used below. This routine has become quite complicated...
if (promoteToFnScope) { | ||
VDDerivedInit = BuildOp(UO_AddrOf, initDiff.getExpr_dx()); | ||
VDDerivedType = VDDerivedInit->getType(); | ||
} else { | ||
VDDerivedInit = initDiff.getExpr_dx(); | ||
VDDerivedType = | ||
m_Context.getLValueReferenceType(VDDerivedInit->getType()); | ||
} | ||
VDCloneType = VDDerivedType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (promoteToFnScope) { | |
VDDerivedInit = BuildOp(UO_AddrOf, initDiff.getExpr_dx()); | |
VDDerivedType = VDDerivedInit->getType(); | |
} else { | |
VDDerivedInit = initDiff.getExpr_dx(); | |
VDDerivedType = | |
m_Context.getLValueReferenceType(VDDerivedInit->getType()); | |
} | |
VDCloneType = VDDerivedType; | |
if (promoteToFnScope) { | |
VDDerivedInit = BuildOp(UO_AddrOf, initDiff.getExpr_dx()); | |
VDCloneType = VDDerivedInit->getType(); | |
} else { | |
VDDerivedInit = initDiff.getExpr_dx(); | |
VDCloneType = | |
m_Context.getLValueReferenceType(VDDerivedInit->getType()); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way, VDDerivedType
is not modified and the adjoints remain of type std::initializer_list
. This breaks the tests for multiple reasons.
VDCloneType = VDDerivedType; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this block could be further simplified.
3a93094
to
c5ea72a
Compare
clang-tidy review says "All clean, LGTM! 👍" |
unsigned numInits = ILE->getNumInits(); | ||
VDDerivedInit = ConstantFolder::synthesizeLiteral( | ||
m_Context.getSizeType(), m_Context, numInits); | ||
VDCloneType = VDDerivedType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I did not realize it was used below. This routine has become quite complicated...
…ge-based for loops
c5ea72a
to
4cb2d28
Compare
4cb2d28
to
d93e52c
Compare
clang-tidy review says "All clean, LGTM! 👍" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR adds support for
std::initializer_list
in the reverse mode.Also, this PR adds support for non-array type ranges and removes redundant assignments by simplifying the logic for range-based for loops. Apart from that, it adds support for
std::begin
/std::end
, and introducesbegin
/end
functions toclad::array
.Fixes #830.