Commit graph

423 commits

Author SHA1 Message Date
Rainer Schuetze
8f0f29c239 fix building against recent LLVM 4.0 2016-10-03 10:58:21 +02:00
David Nadlinger
8a9c7cf463 gen: Remove some redundant elses [nfc] 2016-09-03 14:38:10 +01:00
David Nadlinger
53cdc9a68e gen: Const-ify a loc parameter [nfc] 2016-08-18 16:27:34 +02:00
Martin
7d15ab9ffc Reduce ScopeStack to JumpTargets
Add some comments after this more or less clean separation, and move
callOrInvoke() to FuncGenState.
2016-08-07 21:29:47 +02:00
David Nadlinger
6cc93bc8ba gen/ir: Move function body codegen state into separate class
Previously, the transitory state only needed and valid during
generation of the LLVM IR for the function body was conflated
with the general codegen metadata for the function declaration
in IrFunction.

There is further potential for cleanup regarding the use of
gIR->func() and so on all over the code base, but this is out
of scope of this commit, which is only concerned with those
IrFunction members moved to FuncGenState.

GitHub: Fixes #1661.
2016-08-03 21:07:18 +01:00
David Nadlinger
566923b407 Merge pull request #1609 from kinke/sliceAssign
Fix issue #1608
2016-07-29 17:07:50 +01:00
Martin
54cab47890 Revise DtoAssign() 2016-07-28 01:03:53 +02:00
Johan Engelen
c6ba2dc29b Fix a few clang warnings. [NFC] 2016-07-27 20:21:02 +02:00
Johan Engelen
0b59181936 Implement codegen of function literals passed as default argument.
Fixes issue #1634
2016-07-24 15:44:51 +02:00
Martin
126184a8b6 More in-place construction
Also for struct literal fields, array literal elements and associative array
literal elements as well as basic types allocated on the heap.
2016-07-21 19:49:28 +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
12ff7ef803 Let special __result variable be an alias for sret
So for functions using sret and featuring an out contract, we save an
additional alloca + memcpy by using the sret pointer as storage.
2016-07-04 19:47:55 +02:00
Martin
cdb817633e Rename IrFunction::retArg to sretArg 2016-07-02 12:52:28 +02:00
kinke
13f522a164 Merge pull request #1588 from kinke/assignSret
AssignExp: Refactor direct construction by rhs call via sret
2016-06-26 21:26:14 +02:00
kinke
a2fdffaf0d Merge pull request #1562 from kinke/dvalue
Continue with DValue refactoring and fix issue #1327
2016-06-26 21:24:43 +02:00
Martin
1c14efffde AssignExp: Refactor direct construction by rhs call via sret 2016-06-26 19:51:57 +02:00
Martin
99384dde9b Tighten NRVO detection for VarDeclarations
The D types of the variable and the right-hand-side of the init AssignExp
must match; this fixes issue #1548.
Don't restrict it to memory-only types anymore though; the sret-check
performed by DtoIsReturnInArg() should suffice and makes more sense to me.
2016-06-25 23:40:58 +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
de9149f1b6 Remove getLVal() from DValue and add DtoL/RVal() overloads 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
e3e2f4b2e9 DValue: Remove method getType()
Use the existing public field directly instead.

It's shorter and different than LLValue's getType() (making it easier
to discriminate DValues and LLValues for experienced LDC devs imho).
2016-06-13 22:30:13 +02:00
Martin
039560bd83 Introduce DtoRVal/DtoLVal convenience functions
No functional changes intended.
2016-06-13 22:30:13 +02:00
Johan Engelen
1b4b9a07c9 Fix typo: typeinf.h --> typinf.h [NFC] 2016-06-08 10:40:00 +02:00
Johan Engelen
04b89e642c Windows: Move the prepending of 0x1 to C++ mangled functions from frontend to the backend.
Windows x64 ABI: remove unnecessary \01 from mangled symbol name.

This removes the 0x1 byte from `.mangleof` accessible from user code.
Resolves issue #1519

Also let mangleForLLVM take a std::string, to enable C++11's moves.
2016-05-30 10:18:39 +02:00
Martin
7778db00a8 Simplify generation of a call's return value 2016-05-29 14:01:02 +02:00
Martin
fc6c340661 Optimize ABIRewrite system for lvalues
Allow ABIRewrites to return the D parameter's LL value directly.
Most rewrites store to memory anyway, so let the D parameter point
directly to that memory instead of a dedicated alloca bitcopy.
2016-05-28 21:03:56 +02:00
Johan Engelen
c77c16ef59 C++11 a few loops [NFC] 2016-04-24 14:45:06 +02:00
Kai Nacke
ee8c6b106b Fix merge errors 2016-04-23 14:58:39 +02:00
Kai Nacke
e55823fd09 Merge remote-tracking branch 'origin/ltsmaster' 2016-04-23 11:19:20 +02:00
Rainer Schuetze
eaa9e8130c create our own global context, it's been removed from LLVM
(cherry picked from commit 26a4e2bd13)
2016-04-21 22:34:08 +02:00
Johan Engelen
9955d8e4e4 For LDC_inline_ir functions: instantiate a new "alwaysinline" function for each call, which is the current behavior for inline ASM too.
When certain attributes are applied to the calling function, like "unsafe-fp-math", the inlined inlineIR function has to have the same attributes otherwise the calling function attribute will be reset to the safe merge of the two: "false". Because the same inlineIR function can be called in different functions using an alias definition, a new function (with possibly different attributes) has to be instantiated upon every call.

Related GH issue #1438
2016-04-21 10:16:33 +02:00
Rainer Schuetze
26a4e2bd13 create our own global context, it's been removed from LLVM 2016-04-16 10:02:13 +02:00
David Nadlinger
209b6fc2b0 Merge pull request #1393 from kinke/nullArray
Optimize array comparisons against null
2016-04-09 23:22:53 +01:00
David Nadlinger
d89419445d gen: Fix buildStringLiteralConstant() for zeroTerm enabled
Apparently, this has not been triggered on the 2.070 branch
so far by chance, but Phobos 2.071 hits it.
2016-04-02 19:22:29 +01:00
Johan Engelen
15aebef5be Merge branch 'master' into merge-2.070 2016-03-29 11:48:14 +02:00
Johan Engelen
823a9efe26 Merge branch 'ltsmaster'
Solved merge conflicts in:
	gen/abi.cpp
	gen/toir.cpp
	runtime/druntime
	tests/d2/dmd-testsuite
	tests/lit.site.cfg.in
2016-03-29 11:40:20 +02:00
David Nadlinger
6c15b4bc8e Random comment cleanup [nfc] 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
David Nadlinger
32864c47a5 Re-clang-format some files [nfc] 2016-03-29 09:08:55 +01:00
Martin
0440bd20db Optimize array comparisons against null
This fixes issue #894 and includes some refactorings.
2016-03-28 15:30:55 +02:00
Kai Nacke
763b196a72 Merge remote-tracking branch 'origin/master' into merge-2.070 2016-03-24 22:40:31 +01:00
Kai Nacke
782dd77110 Fix merge error 2016-03-22 19:31:29 +01:00
Kai Nacke
88f3de8bea Merge branch 'ltsmaster' 2016-03-22 19:05:07 +01:00
Martin
88dcb4349a Refactor setting linkage type and COMDAT 2016-03-20 16:37:44 +01:00
David Nadlinger
90c213b52e Adapt to changed StringExp API
Not tested yet. There is also quite a bit of potential for
further cleanup of the glue layer string manipulation code.
2016-02-14 19:35:40 +01:00
Johan Engelen
acdcc4a8c1 Merge branch 'master' into merge-2.069 2016-02-13 20:12:17 +01:00
David Nadlinger
994da2e98f DtoCast: Implement struct repainting casts
The assoiative array case seems to be mostly triggered by some
remaining parts of the old shared/immutable AA type canonicalization
issue.
2016-01-31 00:57:34 +01:00