Commit graph

436 commits

Author SHA1 Message Date
Martin
d01a91f755 Allow multiple occurrences for almost all command-line flags
Except for `-sanitize` and `-cache-prune*`.
2017-05-23 20:53:57 +02:00
Johan Engelen
64df1687a8 Fix LLVM 5.0 compilation. 2017-04-14 12:55:19 +02:00
kinke
94f04216d0 Don't crash when trying to repaint static arrays (#2034)
Fixes issue #2033.
2017-03-18 14:21:25 +01:00
Martin
9d4961ae27 Fix detection of special reference variables
D2.072 apparently doesn't set the STCforeach storage class for each
special reference anymore. So let's consider all references which aren't
parameters, i.e., all locals with STCref, as special references.

By-ref parameters are different as we simply use the LL pointer parameter as
lvalue for the variable, no extra alloca required. Special references are
automatically dereferenced pointers and as such occupy a dedicated alloca for
the address.
2017-02-01 22:52:43 +01:00
Ivan Butygin
a26bfc1223 Refactor code to hide direct IrFunction->func usage and add convenient functions (#1911) 2017-01-17 22:40:32 +01:00
Martin
0de021fe32 Fix check if nested function can access outer function frame
The previous check wouldn't check intermediate aggregates for static-ness,
that was one problem. The other was the assertion that the outer function
can be reached as long as there are no static functions inbetween, which
isn't always the case, as issue #1864 clearly shows, which is resolved by
this.
2016-11-18 18:05:56 +01:00
Martin
67d5fe5624 Map export visibility to LLVM DLL storage classes
Compatible with DMD, but restricted to Windows and functions only.

`export` functions with bodies get the dllexport attribute and will be
exported if the containing object is pulled in when linking.

Body-less `export` functions get the dllimport attribute and will be
accessed via an import table indirection, set up at runtime by the OS.

This is a temporary solution, the proper fix is a pending DMD PR, after
which LDC will need to be adapted.
2016-11-15 21:15:56 +01:00
Rainer Schuetze
08e1c496dc fix build against current LLVM master @ 9b4e8286785f538e73d2e3eaa96f88c3d98b9960 2016-10-27 08:08:19 +02:00
Martin
10b0261200 Zext i1 constants for scalar Boolean struct fields to i8 2016-10-23 17:31:02 +02:00
Martin
ab1432ed06 Use the regular LL type for all init symbols and most globals
There's no <Type>_init type for aggregates (structs and classes) anymore,
effectively eliminating a *lot* of named LLVM types, some bitcasts as well
as replacements of globals etc.

To get there, it was even required to use the regular type for compatible
literals too, otherwise structs embedded as fields in other aggregates had
an anonymous type (well, the LLVM constant for the field initializer had)
and so the container initializer wasn't compatible with the regular type
anymore.

What was also necessary was a fix wrt. static arrays of bools (LLVM
constant of type `[N x i1]` vs. `[N x i8]` for regular type).
I also had to change the initializer for `char[2][3] x = 0xff` from
`[6 x i8]` to `[3 x [2 x i8]]`, i.e., NOT flattening multi-dimensional
inits from a scalar.

So only literals with overlapping (union) fields and an explicit
initializer initializing dominated non-alias union fields should still
have a mismatching anonymous type - i.e., very, very few cases.
2016-10-23 02:52:51 +02:00
Johan Engelen
8d06f23635 Merge pull request #1825 from JohanEngelen/align1
Allow alignment below sizeof(void*).
2016-10-13 21:38:52 +02:00
Rainer Schuetze
0b55bd21d2 fix build against LLVM master: clEnumValEnd removed 2016-10-12 23:55:59 +02:00
Johan Engelen
7e572e6f03 Allow align(1) for global variables.
This reverts a39997d326, and fixes the invalid tests in std.conv.
2016-10-12 12:18:46 +02:00
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