-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
LDC-specific _d_array_slice_copy (betterC) #2425
Comments
|
As the name of the function suggests, this isn't directly related to array bounds checks, but with |
|
See https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/arrayinit.d#L142. According to the comment, it's only used for enabled assertions (also checking that the slices don't overlap); so an additional |
It related to This issue about difference between behavior of ldc and dmd. |
This divergence between LDC and DMD has absolutely nothing to do with
Well, there's not a single
|
|
[Inlineability seems not to be a real issue as Enabling that pass generally for |
|
@kinke what's the interaction between IMO, |
|
No interaction at all, as it handles no arrayops, see https://github.com/ldc-developers/ldc/blob/master/gen/passes/SimplifyDRuntimeCalls.cpp#L344-L369. |
I work in company that develop devices for industrial mainly for uninterruptible power source (monitoring, measurement etc). Some devices we develop on RPI, some on other ARM-boards, some devices fully develop by my colleagues and based on STM32, MSP430 etc. Last one use C for firmware. I try use D on ARM-board devices (with linux on the board) but have this problem. This is main blocker for using D on future projects on ARM-boards (impossible to determine place there throwing exception will lead to this error). Now I try eliminate druntime to get more predictable behavior. If |
|
You do realize there is no exception support whatsoever with So if you don't need them, you won't run into the EH issue anyway. |
Yes, I know.
Druntime can throws. For minimize probability of throwing I must check all data before any druntime call. And as a result, in any case I must put all druntime call in try-catch block. Or rewrite interested functions by myself as nothrow. In the end than it differs from |
|
Well, avoiding druntime is what needs to be done for If you're so worried about hitting the EH issue, why don't you try disabling inlining as Joakim suggested in your issue? Or is your code performance-critical as well and that's really not an option? |
|
Even if performance might be an issue, he should still try disabling inlining to see if that's causing the problem. |
|
At this moment I don't know where I can get EH problem, because compile-to-compile place changes. I include |
|
If you can't figure out the problem, my advice is to get one of the ldc devs under an NDA and let them get their hands on it, for a consulting fee. My understanding is that some of them do this for Weka. It sounds like you will save a lot of your time and money rather than trying to do everything yourself. |
|
What's the progress on this? it's been 4 years already, and i got hit by this issue |
original problem not solved in ldc 1.24.0 (with |
|
@deviator ok thanks That is the only issue that prevents me from using -betterC, it works fine with DMD, but not with LDC |
|
See https://forum.dlang.org/post/heksucpdamkgwnztyitr@forum.dlang.org for the workaround. |
@kinke Thanks, the workaround works! Do you have an idea about this one? it works with DMD, so i guess it is a similar issue as the copy one char[] ext = extbuf[0..extlen];
switch (ext[0]) {
case 't': if (ext == "tga") return IF_TGA; else return -1;
case 'b': if (ext == "bmp") return IF_BMP; else return -1;
case 'p': if (ext == "png") return IF_PNG; else return -1;
case 'j': if (ext == "jpg" || ext == "jpeg") return IF_JPG; return -1;
default: return -1;
}
|
|
This looks template-culling related; try with |
|
@kinke it works! thanks!! Is this a bug? should it be reported somewhere? |
|
Nope, this is all to be expected with current Making |
|
Oh i see, i wish there was an easier solution I will try to document all the issues i had and their solution, so at least it'll be easier for people in similar situation as me EDIT: here is a first draft: https://gist.github.com/ryuukk/e0b40012dcde9f071bf414ecec9c9ccf |
|
I got hit by the issue again and i didn't remember about the workaround.. I think the template hack you mentioned is worth it if users gets a cleaner experience as a result I don't see myself carying that function with me whenever i create a project
feels bad |
|
Any news on this? I'm tired of having to include that file for all my projects If someone could indicate me where in the code base the problem lies, i could try to come up with a PR If the issue is known and a fix is possible but is not desirable, then i'd love a patch so i can maintain a private fork |
|
This should 'work', skipping the bounds and overlap checks for diff --git a/gen/arrays.cpp b/gen/arrays.cpp
index 14b1b26614..bbc24062c2 100644
--- a/gen/arrays.cpp
+++ b/gen/arrays.cpp
@@ -164,7 +164,8 @@ static void copySlice(const Loc &loc, LLValue *dstarr, LLValue *dstlen,
LLValue *srcarr, LLValue *srclen, size_t elementSize,
bool knownInBounds) {
const bool checksEnabled =
- global.params.useAssert == CHECKENABLEon || gIR->emitArrayBoundsChecks();
+ !global.params.betterC && (global.params.useAssert == CHECKENABLEon ||
+ gIR->emitArrayBoundsChecks());
if (checksEnabled && !knownInBounds) {
LLFunction *fn = getRuntimeFunction(loc, gIR->module, "_d_array_slice_copy");
gIR->CreateCallOrInvoke( |
|
I will give this a try, thanks a lot |
|
Wait, i missed an important detail You said: "skipping the bounds and overlap checks" Why would someone want to skip that? i want that in debug build, did i misunderstand the feature? |
|
These checks are the only reason why a druntime function is called - asserting that the array lengths match and the arrays don't overlap, constructing a nice assertion msg (incl. the array lengths etc.) with the GC if violated. If similar checks are desired for betterC - well, then some external implementation not depending on the GC is required. |

Hello. I try build this simple example:
ldc2 -betterC bettercarray2.dAnd I get error:
On dmd 2.076.1 I have same problem, but it solves by
-noboundscheckflag.If I try
-boundscheck=offon ldc2 I have no effect.ldc2 version is
1.6.0-beta1(prebuild for linux x86_64)The text was updated successfully, but these errors were encountered: