Translate _d_arraycatnTX to a template#14550
Conversation
|
Thanks for your pull request, @teodutu! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#14550" |
|
This is currently blocked by https://issues.dlang.org/show_bug.cgi?id=23408. This causes |
6d77157 to
b544112
Compare
I suggest changing the test case from runnable to compilable, since the original bug report was about a compiler crash. |
53909d1 to
39bb37a
Compare
| { | ||
| //printf("[%s] CallExp.toElem('%s') %p, %s\n", ce.loc.toChars(), ce.toChars(), ce, ce.type.toChars()); | ||
| /* Do this check during code gen rather than semantic() because concatenation is | ||
| * allowed in CTFE, and cannot distinguish that in semantic(). |
There was a problem hiding this comment.
Two major issues with this:
- GDC and LDC have to implement this error check themselves (is there a testcase for it?)
-o-will not trigger this error
There was a problem hiding this comment.
GDC and LDC have to implement this error check themselves (is there a testcase for it?)
This check was previously in visitCat(), so this PR isn't making things worse. And the reason it's here is explained in the comment. Do you know of a better place where to verify this?
-o-will not trigger this error
Why would it? AFICT -o- simply skips the generation of the .o file. How is this connected to string concatenation with -betterC? This check is triggered by test/fail_compilation/test18312.d.
There was a problem hiding this comment.
-o- skips codegen, thus skips e2ir ?
There was a problem hiding this comment.
looks like you are right that this PR does not make the situation worse.
There was a problem hiding this comment.
-o-skips codegen, thus skipse2ir
And doing so also skips the rest of the backend. Therefore, the CatExp that would otherwise be leaked to the glue layer is ignored. Because code generation is omitted, the leak is silent as it doesn't cause any trouble.
eafbf95 to
98442f1
Compare
|
@teodutu any updates on this PR? |
|
@RazvanN7 The buildkite failures come from building DMD. This tells me that the failures are likely coming from string concatenations that then call string res = str1 ~ str2;
foo(res.ptr);For some reason, they didn't trigger errors before, but now they cause issues because |
98442f1 to
4642c29
Compare
bff1692 to
eb525aa
Compare
RazvanN7
left a comment
There was a problem hiding this comment.
Looks good to me, although I don't understand why now we have more allocations for the profilegc tests.
|
@JohanEngelen @ibuclaw @dkorpel could you please take a look at this? |
4db8529 to
f04d44b
Compare
2f651be to
29cd668
Compare
|
@JohanEngelen @ibuclaw @dkorpel I've fixed the bugs created by moving the lowering to its own field inside |
| @@ -1725,50 +1725,10 @@ elem* toElem(Expression e, IRState *irs) | |||
| return el_long(TYint, 0); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
The above betterC check could be probably moved to the frontend. You could check sc.func.needsCodegen, however, that is a topic for a different PR.
29cd668 to
66b4d9c
Compare
66b4d9c to
c525392
Compare
|
@RazvanN7 @JohanEngelen, I have addressed your comments about |
|
I have also enclosed |
RazvanN7
left a comment
There was a problem hiding this comment.
LGTM. cc @JohanEngelen any more comments?
c525392 to
9601ea8
Compare
|
@dkorpel @JohanEngelen are there any other concerns? |
This brings the following changes: - Improves the existing template `_d_arraycatnTX`, to now concatenates both arrays and single elements - Changes the lowerings to `_d_arraycatT` to use the new template - Moves the lowering logic to `_d_arraycatnTX` to expressionsem.d - Adds a new field to `CatExp` called `lowering` to store the template lowering - Removes the old non-template `_d_arraycatnTX` and `_d_arraycatT` hooks - Moves `test19688.d` from `runnable/` to `compilable/` until https://issues.dlang.org/show_bug.cgi?id=23408 is fixed Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
9601ea8 to
3c9bea4
Compare
|
I lack the knowledge to review in a lot of detail. Overall I am worried about template bloat due to these templatizations, so I'd appreciate if you can add an open issue about trying to implement it in such a way that reduces this bloat (e.g. have the template forward to a function that is the same for POD structs of the same size, etc.) |
|
@JohanEngelen The follow-up project for @teodutu after he has finished templating the existing hooks is to implement optimizations for them. |
|
This PR broke frontend.h: #15141 |
|
This PR caused a regression: #24018 |
|
And unfortunately #24078 |
|
There are two other regressions related to this: |
…RAYCATT, TRACEARRAYCATNTX and TRACEARRAYCATT
* Remove RTLSYM for Translation PR #15819: Removed NEWARRAYMITX, NEWARRAYMITX, TRACENEWARRAYMTX and TRACENEWARRAYMITX * Remove RTLSYM for Translation PR #15299: Removed NEWARRAYT, NEWARRAYIT, TRACENEWARRAYT and TRACENEWARRAYIT * Remove RTLSYM for Translation PR #14837: Removed NEWCLASS, TRACENEWCLASS * Remove RTLSYM for Translation PR #14664: Removed NEWITEMT, NEWITEMIT, TRACENEWITEMT and TRACENEWITEMIT * Remove RTLSYM for Translation PR #14550: Removed ARRAYCATNTX, ARRAYCATT, TRACEARRAYCATNTX and TRACEARRAYCATT * Remove RTLSYM for Translation PR #14382: Removed ARRAYSETASSIGN * Remove RTLSYM for Translation PR #14310: Removed ARRAYASSIGN * Remove RTLSYM for Translation PR #13495: Removed ARRAYAPPENDT, ARRAYAPPENDCTX, TRACEARRAYAPPENDT and TRACEARRAYAPPENDCTX
This brings the following changes:
_d_arraycatnTX, to now concatenates both arrays and single elements_d_arraycatTto use the new template_d_arraycatnTXto expressionsem.d_d_arraycatnTXand_d_arraycatThooksisRuntimeHookandremoveHookTraceImplto expression.d` so they can be called from both expressionsem.d and dinterpret.dThis continues #10064.
Signed-off-by: Teodor Dutu teodor.dutu@gmail.com