Commit graph

55 commits

Author SHA1 Message Date
Martin Kinkelin
866be1e8cb
Fix bit field IR storage from weird integer to i8 array (#4708)
Fixes #4646.
2024-07-19 17:53:32 +02:00
Martin Kinkelin
d140f2a283 Skip superfluous IR pointer bitcasts, now that they are always opaque 2024-05-20 16:45:09 +02:00
Martin Kinkelin
3067b7b115 Enforce opaque IR pointers 2024-05-12 18:47:13 +02:00
Johan Engelen
bc00d4b775
Add memory invariant assumptions for virtual calls to improve devirtualization (#4596)
Assumptions:
- class methods do not change the object's vtable pointer
- loads through vtable pointer are invariant (vtables are immutable throughout program life)
2024-04-05 16:14:38 +02:00
Johan Engelen
91d306894e
Add support for LLVM 17. (#4533) 2023-12-03 19:07:31 +01:00
Martin Kinkelin
5d3ded9eeb Remove legacy LL[Maybe]Align 2023-07-29 02:09:35 +02:00
Nicholas Wilson
b5bc517249
Remove final use of getPointerElementType (#4143) 2022-09-13 15:16:46 +08:00
Martin Kinkelin
78fdc135e4 Merge remote-tracking branch 'origin/master' into bitfields
Conflicts:
	gen/dvalue.cpp
	gen/llvmhelpers.cpp
	gen/structs.cpp
	gen/toir.cpp
	ir/irtypeaggr.cpp
2022-09-10 16:25:59 +02:00
Nicholas Wilson
0829b40abe
Remove deprecated getPointeeType and DtoLoad (#4109) 2022-09-04 11:39:21 +08:00
Nicholas Wilson
b8b1a5c10c
Use typed DtoLoad in dvalue.cpp (#4048) 2022-08-28 01:30:04 +00:00
Martin Kinkelin
37894dd3d0 Refactor via new DBitFieldLValue type
This enables BinAssignExp with bit fields as left-hand-sides and
should generally be more robust.
2022-08-05 15:15:44 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Martin Kinkelin
4b101baed9
DSliceValue: Don't cache *extracted* length & ptr (#2997)
As they may be extracted earlier in an unrelated basic block.
Fixes #2996.
2019-02-12 20:38:35 +01:00
Martin Kinkelin
68fa7b0167 Enforce slice IR rvalues to be represented by DSliceValue, disallow DImValue 2019-01-10 00:53:24 +01:00
Martin Kinkelin
2fb5098f48 Optimize some slice copies
Cache length & ptr in DSliceValue, so that e.g. a pair constructed from
a constant length and some ptr keeps returning a constant length instead
of an extractvalue instruction every time the length is needed.

This enables checking for matching constant lengths when copying slices
and makes `test1()` in runnable/betterc.d work (memcpy instead of
_d_array_slice_copy call):

```
int[10] a1 = void;
int[10] a2 = void;
a1[] = a2[];
```

(more or less equivalent to `a1 = a2`, which is already optimized)
2019-01-09 23:50:44 +01:00
Martin Kinkelin
4a23399236 Aim for consistent #includes (order + dir prefix)
I surely missed a few.
2018-10-20 16:19:46 +02:00
Martin
c908ebabe4 Add range metadata when loading bools
When optimizing the code, analogous to clang, fixing one aspect of
issue #2131.
2017-05-25 04:09:48 +02:00
Nicholas Wilson
6c7f1b616e [NFC] [dcompute] Make LDC somewhat aware of addrspaces. (#2122)
* [NFC] Make LDC somewhat aware of addrspaces.

Required so that we don't generate invalid code when dealing with pointer to addrspaces other than zero.
2017-05-21 08:43:04 +08:00
Martin
ca8c932d75 Safe some allocas+loads when creating LL slices
Create the LL pair directly instead.
2016-07-21 19:49:33 +02:00
Martin
d6dcc7a4db Enforce type consistency for most DValues
At the cost of some more bitcasts.
2016-07-17 06:22:22 +02:00
Martin
7fec36b51f Continue with DValue refactoring
* Introduce a DRValue base class to be able to discriminate between
  DLValues and DRValues (e.g., function parameters).
* Let DValue::getRVal() return each DValue's value as DRValue.
  This allows to convert a DLValue to a DRValue, a snapshot of the
  lvalue's current state, while retaining the D type, something we've
  previously lost when returning the low-level rvalue directly.
* Let the DtoR/LVal() helpers be the only way to convert a DValue to a
  low-level value.
2016-06-25 15:33:57 +02:00
Martin
f70f11fac5 Handle internal ref variables in class DSpecialRefValue 2016-06-13 22:30:16 +02:00
Martin
0c0c1ecaf5 Rename DVarValue to DLValue 2016-06-13 22:30:15 +02:00
Martin
963a10b225 Let DValue types handle memory-only types consistently
I.e., disallow memory-only values from being represented as DImValues
and disallow getRVal() for such types instead of returning the address.
2016-06-13 22:30:14 +02:00
Martin
c1c285782d Streamline DSliceValue
All DValues are now required to have a (main) LL value, which allows
to conveniently refactor the DValue hierarchy.

DSliceValue now represents a LL struct instead of separate values for
length and pointer.
2016-06-13 22:30:14 +02:00
Martin
f9afcee17f DValue: Add public val field
DSliceValue is still a special case and contains pointer and length
separately, which are packed to a LL struct in getRVal().

It'd probably pay off to do it the other way around and store the LL
struct as single value and allowing for access to the components.
2016-06-13 22:30:13 +02:00
David Nadlinger
79df07d3f5 gen: Properly implement result instruction scope check in ToElemVisitor
This should put an end to the "instruction does not dominate all uses"
ICEs triggered by the new cleanup code, such as GitHub #1294 and other
reports before that.

The root cause was that the code assumed that DVarValues were always
either globals or pointed to allocas in the function entry basic block,
whereas DVarValue is really just a generic lvalue.
2016-03-29 09:08:55 +01:00
David Nadlinger
b47aee1750 refactor: Remove last bits of direct connection between DVarValue and VarDeclaration
The relationship between them is at best tenuous; DVarValue should
probably be renamed to DLValue and is used right now to describe
a general lvalue, of which variables are just one example.
2016-03-29 09:08:55 +01:00
Martin
740a21eb8f Rename DtoIsPassedByRef() to DtoIsInMemoryOnly()
Motivation: issue #937
2015-12-04 22:23:09 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04:00
David Nadlinger
848dee32d4 Store bools as i8.
I really hope we can refactor this to use a less leaky
abstraction later – it should at least be possible to merge
voidToI8 and i1ToI8.
2013-06-07 03:20:54 +02:00
David Nadlinger
4369776b27 Minor DVarValue refactoring. 2013-06-07 03:20:39 +02:00
David Nadlinger
0a96aea868 Sort includes according to style guidelines:
1. Main include corresponding to .cpp file, if any.
 2. DMD and LDC includes.
 3. LLVM includes.
 4. System includes.

Also updated a few include guards to match the default format.
2013-02-07 21:20:55 +01:00
David Nadlinger
c3d517e17f Correctly handle ref variables in an outer frame.
Fixes DMD testcase 'testcontracts'.
2013-01-04 07:31:18 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
David Nadlinger
ee4285f934 Properly handle DMD-internal "reference variables".
Previously, we just had a hack to make ref foreach statements work.
This commit enables them to work in other cases as well, like the
implicit __result variable for functions with out-contracts (which
is such a magic ref variable for ref-returning functions).

Fixes DMD testcase 'testcontracts'.
2012-09-07 03:51:33 +02:00
Alexey Prokhin
629f13929e WIP: port to llvm 3.0 2011-10-25 15:43:39 +04:00
Alexey Prokhin
eccd26ac93 Fixed crashes when compiling interpret test. 2010-12-17 12:55:28 +03:00
Frits van Bommel
df8547a40f Remove some redundancy from the DValue hierarchy: all subclasses had a 'type'
field and identical implementations of virtual function getType().
Move these to DValue itself, and make getType() non-virtual.
2009-03-31 01:18:35 +02:00
Tomas Lindquist Olsen
36f6ebc77f - Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
- Eliminated the DLRValue DValue.

- Implemented proactive handling of l-value CastExpS.

- Minor tweak in runtime memory.d .
2009-03-28 05:00:43 +01:00
Tomas Lindquist Olsen
f7ea1da010 Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
2008-10-22 14:55:33 +02:00
Tomas Lindquist Olsen
c9242e3fbe Fixed DLRValue::getLType did not handle the lvalue being a LRValue itself properly. 2008-09-15 15:17:41 +02:00
Tomas Lindquist Olsen
8e9b957bce Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change. 2008-09-09 16:49:47 -07:00
Tomas Lindquist Olsen
daad516579 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
in this regard. Code for accessing nested variables and contexts rewritten. Probably more. Fairly well tested.
2008-08-04 02:59:34 +02:00
Tomas Lindquist Olsen
905ca019dd Added type param to DVarValue as DMD sometimes overrides the type of the VarDeclaration.
Added support for align(1)/packed structs, other alignments are still ignored.
Fixed some problems with accessing lazy arguments.
2008-07-30 10:12:55 +02:00
Tomas Lindquist Olsen
dbd640a3dc [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
Removed some dead code.
Started on a more generalised approach to call misc. D functions.
2008-07-13 20:49:10 +02:00
Tomas Lindquist Olsen
832504e5d7 [svn r357] Merged DMD 1.033 2008-07-12 19:38:31 +02:00