Commit graph

266 commits

Author SHA1 Message Date
Dennis
8dcef66a5f
Revert "Fix #21024 - Optimize x^^c expressions (#21082)" (#21114)
This reverts commit fa1f860e4b.
2025-03-29 12:25:53 +01:00
Fares A. Bakhit
fa1f860e4b
Fix #21024 - Optimize x^^c expressions (#21082)
* Fix #21024 - Optimize x^^c expressions

Reason for the *magic* constraint c<8 on inlining x^^c:

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/fpu/e_powl.S;h=47f129f34d368d7c67b8e5f2462b36b0bebb7621;hb=HEAD#l136

* Fix poor assumption about expression state

* Restrict optimization to floating point expressions

* Generalize optimization to any scalar data type

* Fix segfault on x^^c where x is a single member anonymous enum

DMD segfaulted on compiling the unittests in std/algorithm/sorting.o, the
unittest that caused the segfault can be reduced to:

    enum real Two = 2.0;
    auto _ = Two^^3;

I'm not sure why copying the anonymous enum into a `const` variable causes
the compiler to segfault.

* Add tests to x^^c inlining optimization

* Fix missing type for e1 ^^ -1 to 1 / e1 rewrite

* Move rewrites from constant folding to expression semantic and restrict them to [-1, 2]

* Improve error message for the x^^2 rewrite.

Before:
    ex.d(4): Error: can implicitly convert expression `(const const(double) __powtmp2 = x + 5.0;) , __powtmp2 * ...` of type `double` to `int`
        int y = ( x + 5 ) ^^ 2;
                ^
and after:
    ex.d(4): Error: cannot implicitly convert expression `(x + 5.0) ^^ 2L` of type `double` to `int`
        int y = ( x + 5 ) ^^ 2;
                ^

* Update C++ frontend header to match change in `CommaExp`

* Address code review feedback

Co-authored-by: Dennis Korpel <dkorpel@gmail.com>

---------

Co-authored-by: Dennis Korpel <dkorpel@gmail.com>
2025-03-29 12:13:38 +01:00
Martin Kinkelin
8db14cf846
Fix #21020 - Indexing a *cast* AA yields no lvalue anymore (#21029) 2025-03-19 07:15:23 +08:00
Walter Bright
d1f5972b54
getting first two tests in exe1.c to run (#20968) 2025-03-08 22:49:35 -08:00
Walter Bright
8812065e8b
fix #20960 i = i && 1; fails at runtime (#20961) 2025-03-07 11:42:12 +08:00
Walter Bright
42619075eb
add exe1.c to test suite (#20957) 2025-03-06 12:25:59 -08:00
Dennis Korpel
5375db4f76 Merge branch 'stable' into merge-stable 2025-03-05 11:03:30 +01:00
Walter Bright
73158d8a78 add Placement New 2025-03-03 16:23:02 +10:00
Dennis
3945e81615
Fix #20907 - DMD segfaults with static array length parameter derived from left-shifted template parameter property (#20919) 2025-02-28 21:46:10 +01:00
Rainer
28364abd38 generate full AA typeinfo in InExp 2025-02-18 09:22:39 +01:00
Rainer
7496f54fc4 substitute inout with const in key and value types 2025-02-18 08:09:51 +01:00
Dennis
c0c1b0ab12
Use __FILE__, __LINE__ for templated tracegc hooks (#20882) 2025-02-17 11:53:16 +01:00
Dennis
961862c455
Deprecate typesafe variadic class arguments (#20673) 2025-02-16 21:35:11 +01:00
Dennis
f37cfdf837
Fix #20831 - Mangle conflict after ImportC statement expression gets expanded from macro (#20854) 2025-02-12 20:44:16 +08:00
Dennis
096c9c1528
Make delete an identifier instead of keyword (#20745) 2025-01-21 23:33:50 +01:00
Dennis
fc2b2271a6
Remove D1 operators from the D2 language (#20744) 2025-01-21 06:08:05 +08:00
Dennis
803db11017
Re-enable tests of temporary in condition and throwing callee (#20721) 2025-01-16 23:35:13 +01:00
Dennis
888917669c
Remove debug() / version() integers (#20713) 2025-01-16 15:20:06 +08:00
Dennis
b237d0329c
Fix ambiguous type deduction around hex strings (#20679) 2025-01-10 23:35:51 +01:00
Walter Bright
eb8418a772
build default move constructors (#20634) 2025-01-10 11:19:29 -08:00
Dennis Korpel
37978248a9 Fix "Casting class references to void* should be @safe" 2025-01-08 23:24:36 +01:00
Royal Simpson Pinto
45e4a09a3e
feat(errors): enable verrors=context globally (#20576)
Signed-off-by: royalpinto007 <royalpinto007@gmail.com>
2025-01-03 05:17:59 +08:00
Walter Bright
c57da0cf59
fix #20621 Comparing addresses of rvalue reference parameters not correct (#20622) 2024-12-31 17:00:03 +08:00
Walter Bright
1b9bc74edc
fix #20610 aliasing for fields does not work (#20611) 2024-12-27 21:38:25 -08:00
Walter Bright
2c5638e880
replacing string instructions with MOVs (#20582) 2024-12-24 10:39:26 +08:00
Walter Bright
cdc7334e44
fix issue 20562 returning __rvalue should move-construct the NRVO value (#20585) 2024-12-23 13:08:50 +08:00
Walter Bright
bf3f49ac79 optimize s=s where s is a struct 2024-12-18 16:51:23 -08:00
Walter Bright
b7a3a1942c
fix Issue 20567 returning the result of a constructor should be NRVO (#20568) 2024-12-18 00:48:52 -08:00
Walter Bright
85fe931daa
fix github issue 20754 replace a?b:b with a,b when optimized (#20575) 2024-12-17 23:59:42 -08:00
The Dlang Bot
059b1ab407
Merge pull request #20559 from KitsunebiGames/objc
Objective-C Improvements

Signed-off-by: Dennis <dkorpel@users.noreply.github.com>
Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Dennis <dkorpel@users.noreply.github.com>
2024-12-15 22:48:39 +01:00
Walter Bright
a99a3894be
add __rvalue(expression) builtin (#17050) 2024-12-15 12:13:28 -08:00
LunaTheFoxgirl
0845895659 Objective-C classes do not have invariants, null check directly. 2024-12-14 19:26:08 +01:00
LunaTheFoxgirl
2aa9f23110 Remove super-call in test 2024-12-14 18:35:42 +01:00
LunaTheFoxgirl
8a7108f8c9 Skip selector-gen for templates 2024-12-14 17:30:26 +01:00
LunaTheFoxgirl
8f1803391c Add newline to test 2024-12-14 16:53:25 +01:00
LunaTheFoxgirl
5b9e712f87 Add test for automatic selector generation 2024-12-14 16:42:39 +01:00
Ilya Yanok
c1343f69f3 Make lambda symbols stable post a3abf1187e
Commit a3abf1187e fixes some cases of
lambdas having unstable symbol names between compilation units by
using `generateIdWithLoc` to generate stable lambda names, however since
LOC doesn't uniquely identify a lambda instance (because templates,
mixins, static foreach and foreach unrolling), `generateIdWithLoc`
adds a counter, so there is still some instability going on.

`generateIdWithLoc` makes the name uniq per file+loc, by adding adding a
numeric suffix. But the order of instantiations might be different
across compilation units, so with this counting scheme we are back to
unstable names, so one module might have

`t!0.__lambda_LOC` and
`t!1.__lambda_LOC_1`

while another one has

`t!1.__lambda_LOC`

This is not a critical problem, but at very least the code gets
duplicated for no reason. I also have an example where it leads to
linking error, but since it's not a small one and fails to minimize
further, I suspect it's a result of interaction with some other bug.

The thing is we don't even need uniqueness for those lambdas inside
templates/mixins: their final names will have the instantiation prefix anyway.
But we can't also just disable this uniqueness check completely: `static
foreach` as well as unrollings of the normal `foreach` with lambdas in
the loop body will have several copies of a single lambda with the same
file+loc. So here we do want to keep making them unique. Fortunately, I
don't think a `foreach` could be iterated in different order in
different compilation units, so hopefully if we limit the counting to
this case only, it won't make symbols unstable.

To implement this idea, I've added an extra `parent` argument to
`generateIdWithLoc`: it works like using `parent ~ prefix` prefix, but
without adding `parent` to the final output.

Fixes since last review:
 1. Changed `fromStringz` to `toDString`
 2. Added a test to showcase the problem
2024-12-07 10:48:34 +01:00
Ilya Yanok
451c1596be Make lambda symbols stable post a3abf1187e
Commit a3abf1187e fixes some cases of
lambdas having unstable symbol names between compilation units by
using `generateIdWithLoc` to generate stable lambda names, however since
LOC doesn't uniquely identify a lambda instance (because templates,
mixins, static foreach and foreach unrolling), `generateIdWithLoc`
adds a counter, so there is still some instability going on.

`generateIdWithLoc` makes the name uniq per file+loc, by adding adding a
numeric suffix. But the order of instantiations might be different
across compilation units, so with this counting scheme we are back to
unstable names, so one module might have

`t!0.__lambda_LOC` and
`t!1.__lambda_LOC_1`

while another one has

`t!1.__lambda_LOC`

This is not a critical problem, but at very least the code gets
duplicated for no reason. I also have an example where it leads to
linking error, but since it's not a small one and fails to minimize
further, I suspect it's a result of interaction with some other bug.

The thing is we don't even need uniqueness for those lambdas inside
templates/mixins: their final names will have the instantiation prefix anyway.
But we can't also just disable this uniqueness check completely: `static
foreach` as well as unrollings of the normal `foreach` with lambdas in
the loop body will have several copies of a single lambda with the same
file+loc. So here we do want to keep making them unique. Fortunately, I
don't think a `foreach` could be iterated in different order in
different compilation units, so hopefully if we limit the counting to
this case only, it won't make symbols unstable.

To implement this idea, I've added an extra `parent` argument to
`generateIdWithLoc`: it works like using `parent ~ prefix` prefix, but
without adding `parent` to the final output.

Fixes since last review:
 1. Changed `fromStringz` to `toDString`
 2. Added a test to showcase the problem
2024-12-04 11:04:26 +01:00
Dennis Korpel
74c40e9be0 Merge branch 'stable' into master 2024-11-29 12:46:40 +01:00
Richard (Rikki) Andrew Cattermole
6567f6f4a4 Fix bugzilla issue 24882 - COM class is allocated using GC not malloc 2024-11-29 08:37:07 +01:00
Dennis Korpel
8b1eb80d25 Fix bugzilla 24884 - backend generates wrong 32-bit code after inlining math with double[4] 2024-11-29 08:35:16 +01:00
Dennis
a3abf1187e
Fix 23722 - Lambdas are mangled incorrectly when using multiple compi… (#15343)
* Fix 23722 - Lambdas are mangled incorrectly when using multiple compilation units, resulting in incorrect code

* Update test cases
2024-11-27 12:03:16 +01:00
Walter Bright
735193cc36 fix bugzilla Issue 24819 - Optimizer changes result of float calculations on 32-bit (#17023)
(cherry picked from commit 88d1e8fc37)
2024-10-25 01:47:41 +02:00
Walter Bright
88d1e8fc37
fix bugzilla Issue 24819 - Optimizer changes result of float calculations on 32-bit (#17023) 2024-10-24 13:01:19 +02:00
Nicholas Wilson
57c5b071af
Rebase stable6 (#16967)
* Document template instance duplication status as part of its field documentation. (#16643)

* Fix Bugzilla 24599 - Wrongly elided TypeInfo emission (#15868)

Reverting #14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).

* Reorganize backend build files to match target and make more similar per line (#16672)

* Remove redundant suggestions on linker errors (#16711)

* Fix bugzilla 24337 - Segfault when printing an int[] cast from a string (#16729)

* Add BitFieldStyle.Gcc_Clang_ARM

Required for 32-bit ARM, and non-Apple 64-bit ARM targets.

The only difference to `Gcc_Clang` is that anonymous and 0-length
bit-fields do contribute to the aggregate alignment.

Caught by existing proper C interop tests in
runnable_cxx/testbitfields.d on such targets. The hardcoded bad tests
in runnable/{bitfieldsposix64.c,dbitfieldsposix64.d} however now fail
after the fix, on such targets again.

* [refactor to `TargetC.contributesToAggregateAlignment(BitFieldDeclaration)` hook]

* Fix Bugzilla Issue 24687 - [REG2.110] Cannot cast string-imports to select overload anymore

* Also make deprecationSupplemental adhere to error limit (#16779)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24699 - [REG2.108] No short-circuit evaluation of mixing template bool argument

* Fix bugzilla 24731 - IFTI cannot handle integer expressions (#16822)

* Fix Bugzilla Issue 24760 - ICE on variadic after default argument

* Fix bugzilla 24790 - -vcg-ast ICE on lowered assign exp (#16914)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant (#16917)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in… (#16916)

---------

Co-authored-by: Richard (Rikki) Andrew Cattermole <richard@cattermole.co.nz>
Co-authored-by: Martin Kinkelin <kinke@users.noreply.github.com>
Co-authored-by: Dennis <dkorpel@users.noreply.github.com>
Co-authored-by: Martin Kinkelin <mkinkelin@symmetryinvestments.com>
Co-authored-by: Martin Kinkelin <noone@nowhere.com>
Co-authored-by: RazvanN7 <razvan.nitu1305@gmail.com>
Co-authored-by: Dennis Korpel <dennis@sarc.nl>
Co-authored-by: Dennis Korpel <dkorpel@gmail.com>
2024-10-07 12:00:14 +03:00
Dennis Korpel
64df340150 Fix bugzilla 24748 - DMD can't output object files with fully qualified name, making -od overwirte each other file 2024-09-13 15:38:28 +01:00
Dennis
96d630c644
Fix bugzilla 24731 - IFTI cannot handle integer expressions (#16822) 2024-08-31 21:20:35 +08:00
Nick Treleaven
717e872d37
Fix Bugzilla 21564 - Allow assignment syntax for instantiating mixin templates (#16387)
Following the [alias this change](https://dlang.org/changelog/2.105.0.html#dmd.alias-this-syntax),
I think mixin instantiation was the last place not using assignment
syntax.
2024-08-28 15:02:55 +08:00
The Dlang Bot
d012868974
Merge pull request #16796 from RazvanN7/fix24701
Fix Bugzilla 24701 - No error produced from casted noreturn variable

Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2024-08-21 10:10:14 +02:00
Razvan Nitu
025b072a3e
Update compiler/test/runnable/noreturn2.d
Co-authored-by: Cameron Ross <elpenguino@gmail.com>
2024-08-20 10:44:50 +03:00