Commit graph

660 commits

Author SHA1 Message Date
Johan Engelen
cb15d21996 Fix evaluation order of bitwise operators 2016-07-12 23:01:34 +02:00
Johan Engelen
cec61a4432 clang-format [NFC] 2016-07-12 23:01:10 +02:00
Johan Engelen
57b21d10d4 Fix github issue 1611 2016-07-10 00:42:00 +02:00
Martin
ed70c12b06 Enable in-place construction for static array literals 2016-07-03 00:23:08 +02:00
Martin
08fa2f093c Enable in-place construction for struct literals 2016-07-03 00:23:03 +02:00
Martin
364d1e9acd Be less restrictive in toDirectSretConstruction() 2016-07-02 12:52:29 +02:00
Martin
50b89a47fe Extract helper toDirectSretConstruction() 2016-07-02 12:52:28 +02:00
Martin
879fb97d56 Rename retvar to sretPointer 2016-07-02 12:52:21 +02:00
Martin
07cad0f20a Fix the actual issue 2016-06-29 22:41:08 +02:00
Martin
26d0c715d2 Resolve virtual base functions (super.foo()) correctly
Don't perform a vtable lookup for those, resolve them directly instead.
Fixes issue #1450, where calling the base method in the overwritten
method resulted in an infinite loop and corresponding stack overflow.
2016-06-29 20:35:11 +02:00
Martin
82005009e7 Refactor and fix intrinsics for variadic functions
I.e., va_start(), va_copy() and va_arg().
2016-06-28 22:40:14 +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
Martin
a3adb403de Fix evaluation/load order of binary operators
Fixes issue #1327 by loading immediately from lvalues resulting from
left- and right-hand sides.
2016-06-26 21:19:06 +02:00
Martin
1c14efffde AssignExp: Refactor direct construction by rhs call via sret 2016-06-26 19:51:57 +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
Johan Engelen
0f22a88238 Remove unused variables. 2016-06-20 17:28:32 +02:00
Johan Engelen
e0d9c58443 [PGO] Add PGO to LDC. Supported for LLVM >= 3.7
Add the commandline options -fprofile-instr-generate[=filename] and -profile-instr-use=filename
-fprofile-instr-generate
-- Add instrumentation on branches, switches, and function entry; uses LLVM's InstrProf pass.
-- Link to profile runtime that writes instrumentation counters to a file.
-fprofile-instr-use
-- Read profile data from a file and apply branch weights to branches and switches, and annotate functions with entrycount in LLVM IR.
-- Functions with low or high entrycount are marked with 'cold' or 'inlinehint'.

The only statement type without PGO yet is "try-finally".

A new pragma, `pragma(LDC_profile_instr, [ true | false ])`, is added to selectively disable/enable instrumentation of functions (granularity = whole functions).

The runtime library ldc-profile-rt is a copy of LLVM compiler-rt lib/profile. It has to be exactly in-sync with the LLVM version, and thus we need a copy for each PGO-supported LLVM (>=3.7).
import ldc.profile for a D interface to ldc-profile-rt (for example to reset execution counts after a program startup phase).

The instrumentation data is mainly passed on to LLVM: function-entry counts and branch counts/probabilities. LDC marks functions as hot when "execution count is 30% of the maximum function execution count", and marks functions as cold if their count is 1% of maximum function execution count.

The source of LLVM's llvm-profdata tool is hereby included in LDCs repository (different source for each LLVM version), and the binary is included in the install bin folder.
The executable is named "ldc-profdata" to avoid clashing with llvm-profdata on the same machine. This is needed because profdata executable has to be in-sync with the LLVM version used to build LDC.

Maintenance burden: for trunk LLVM, we have to keep ldc-profile-rt and llvm-profdata in sync. There is no diff with upstream; but because of active development there are the occasional API changes.
2016-06-20 17:28:22 +02:00
kinke
a81ac7d790 Merge pull request #1565 from rainers/fix_build_llvm_master2
fix build against LLVM trunk svn rev 273030
2016-06-18 16:53:55 +02:00
Rainer Schuetze
f9995b1883 fix build against LLVM trunk svn rev 273030 2016-06-18 10:54:23 +02:00
Martin
f432275686 object.classinfo: Return a TypeInfo_Class instead of a TypeInfo_Interface 2016-06-17 00:13:36 +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
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
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
72d20ce21c Fix LDC ICE for https://issues.dlang.org/show_bug.cgi?id=16022.
Added additional test case with enum structs.
2016-06-02 10:30:27 +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
David Nadlinger
622a38eec2 toir/ThisExp: Straighten out control flow [nfci] 2016-05-08 22:00:14 +01:00
David Nadlinger
baf40cf631 toir: clang-formatify again [nfci] 2016-05-08 22:00:11 +01:00
David Nadlinger
219758756c Merge branch 'merge-2.071' 2016-05-06 19:24:48 +01: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
c74d4c2231 Merge remote-tracking branch 'remotes/origin/master' into merge-2.071
# Conflicts:
#	runtime/druntime
#	tests/d2/dmd-testsuite
2016-04-17 21:24:56 +02:00
Rainer Schuetze
1f2699e91c function literals also have to be generated from VarExp 2016-04-14 08:33:44 +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
9f998a398d Initial merge of upstream v2.071.0-b2
Notably, the glue layer side of the changed multiple interface
inheritance layout (DMD a54e89d) has not been implemented yet.

This corresponds to DMD commit 3f6a763c0589dd03c1c206eafd434b593702564e.
2016-04-03 15:15:14 +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
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
6c15b4bc8e Random comment cleanup [nfc] 2016-03-29 09:08:55 +01:00
David Nadlinger
e3e2a2a1e0 Use special ref var machinery for CondExp temporary
The semantics (hidden pointer to values) are the same, so it makes
sense to reuse the associated code. Delaying the load to wherever
the variable is actually used might make for somewhat more efficient
codegen.

Incidentally, this fixes GitHub #1294, but that is more a case
of the underlying bug not being triggered anymore by that
particular test case.
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
David Nadlinger
32859d7a56 gen: Remove unused DFieldValue [nfc]
The class was actually never instantiated.
2016-03-29 09:08:55 +01:00
David Nadlinger
68568695fa gen: Make DVarValue::var private [nfc]
This is in preparation of removing it entirely. In the contexts
where it was used, the information about the variable declaration
was directly available anyway. Instead, we now use the AST directly
like the DMD glue code does.
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
f42273cbe1 Merge branch 'ltsmaster' 2016-03-24 21:50:15 +01:00