Commit graph

6227 commits

Author SHA1 Message Date
Johan Engelen
c1b08f1fe6 Order initializations according to how they will happen at runtime. [NFC] 2016-11-08 11:30:22 +01:00
Johan Engelen
53599b4323 Fix mismatched fwd declaration and clang-format. [NFC] 2016-11-08 11:29:36 +01:00
Johan Engelen
44b39895d1 Merge pull request #1865 from JohanEngelen/Dlogging
Add code for logging within D code.
2016-11-08 11:13:46 +01:00
kinke
e154826532 Merge pull request #1845 from LemonBoy/instr
Implement -finstrument-functions.
2016-11-07 20:44:51 +01:00
LemonBoy
596fc82254 Implement -finstrument-functions.
Closes #1839.
2016-11-06 23:17:04 +01:00
Johan Engelen
fe8cf91510 Add code for logging within D code. 2016-11-02 22:50:55 +09:00
Johan Engelen
0833c9b7d6 Merge pull request #1866 from JohanEngelen/travisdmdfix
Does DMD 2.072.0 miscompile LDC?
2016-11-02 00:32:53 +09:00
Johan Engelen
c417d10944 Does DMD 2.072.0 miscompile LDC? 2016-11-02 00:18:46 +09:00
Johan Engelen
7e3979996b Merge pull request #1855 from JohanEngelen/fixused
Only emit llvm.used _once_ in an LLVM module
2016-10-30 18:38:30 +09:00
David Nadlinger
65476809d5 Merge pull request #1863 from JohanEngelen/fixsoftfloat
Set `+soft-float` feature instead of `use-soft-float` attribute.
2016-10-29 16:52:08 +01:00
Johan Engelen
c832735398 Merge pull request #1859 from rainers/fix_llvm40_3
fix build against current LLVM master @ 9b4e8286785f
2016-10-28 17:45:18 +09:00
Johan Engelen
ed3afed77a UseSoftFloat was removed from the TargetOptions in LLVM3.7. It's replacement (I believe) is the "+soft-float" target feature (in the target feature string). Inside LLVM, the "use-soft-float" attribute is upgraded to the "+soft-float" feature, so we can do that ourselves when creating the target machine.
(at the point where we add the attributes to the function, we have no access to whether our TargetMachine was created with FloatABI:SoftFP or not)
2016-10-28 17:19:26 +09:00
Rainer Schuetze
08e1c496dc fix build against current LLVM master @ 9b4e8286785f538e73d2e3eaa96f88c3d98b9960 2016-10-27 08:08:19 +02:00
kinke
04f91f208e Merge pull request #1854 from kinke/abstract
Produce linking errors when calling abstract functions
2016-10-26 18:58:10 +02:00
Johan Engelen
7deae74d89 Only emit llvm.used _once_ when compiling multiple D modules into one LLVM module. 2016-10-26 21:59:18 +09:00
David Nadlinger
a7d530b1da Merge pull request #1846 from kinke/union
Fix union layout and initialization
2016-10-25 21:39:19 +01:00
Martin
1a84b2f148 Produce linking errors when calling abstract functions
Fixes issue #1822.

DtoResolveFunction() explicitly excludes body-less abstract functions from
being automatically declared. If we want to emit linking errors like DMD,
we need a LL function for the call (we previously didn't for abstract
functions, so it was null and LDC crashed). Thus make sure the function is
resolved and declared by invoking DtoDeclareFunction().
2016-10-25 20:46:22 +02:00
Martin
0fda2d271f Fix dynamic initialization of unions
The front-end fills in missing init expressions (except for the nested
context pointer in most cases), so there are no implicitly initialized
fields for dynamically initialized struct literals.

The front-end is also supposed to make sure there are no overlapping
initializers by using null-expressions for overridden fields, but doesn't
in some cases (DMD issue 16471).
Instead of preferring the first one in lexical field order, now use the
lexically last one to mimic DMD.

The previous code iterated over the fields in lexical order and ignored
the initializer for a field if there were earlier declared fields with
greater offset (and an initializer expression), which is wrong for
anonymous structs inside a union:

union {
  struct { int i1;            long l = 123; }
  struct { int i2; int x = 1;               }
}

`x` was previously initialized with 0 (treated as padding).
2016-10-25 01:06:44 +02:00
Martin
10b0261200 Zext i1 constants for scalar Boolean struct fields to i8 2016-10-23 17:31:02 +02:00
Johan Engelen
72bc6b1334 Bump version. 2016-10-23 17:10:32 +09: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
kinke
498cf6df8d Merge pull request #1833 from kinke/reenableRuntimeFunctionsCheck
Re-check existing runtime function declarations for matching type
2016-10-23 02:13:24 +02:00
kinke
9a49790dbf Merge pull request #1849 from klickverbot/throw-noreturn
Mark _d_throw_exception as cold/noreturn
2016-10-23 02:12:50 +02:00
Martin
e6537ba4dc Fix union layout and initialization
By refactoring IrAggr::addFieldInitializers() and making it use an
extended and refactored AggrTypeBuilder::addAggregate().

AggrTypeBuilder::addAggregate() can now optionally detect alias fields
in unions (same offset and LL type as a dominant union field) and add
those to the variable-to-GEP-index mapping.
These alias fields can then be indexed directly with a GEP instead of
resorting to casting the pointer and applying the byte offset.
2016-10-22 01:40:54 +02:00
David Nadlinger
c083a67e3e Mark _d_throw_exception as cold/noreturn
`noreturn` have been inferred already by the `unreachable` following
the call, but being explicit can't hurt.
2016-10-21 23:04:00 +01:00
kinke
86d11c8ace Merge pull request #1830 from kinke/dub
Create static libs in -od directory for LDMD only
2016-10-20 00:04:52 +02:00
Johan Engelen
2fa64b9662 Merge pull request #1835 from JohanEngelen/minfolinkermagic
ELF: Use magic linker symbol names for begin/end of .minfo.
2016-10-19 11:08:06 +02:00
LemonBoy
eab33ea726 Implement single-thread fences via the LDC_fence pragma. (#1837)
* Implement single-thread fences.

* Add a test for PR#1837
2016-10-18 19:20:44 +01:00
kinke
ec6483f67e Merge pull request #1821 from LemonBoy/slit
Check StructLiteralExp elements in isConstLiteral.
2016-10-18 10:21:21 +02:00
LemonBoy
517f9095a4 Check StructLiteralExp elements in isConstLiteral. 2016-10-17 23:37:04 +02:00
Johan Engelen
eb0f97aaf1 ELF: Use magic linker symbol names for begin/end of .minfo. 2016-10-17 09:52:33 +02:00
Johan Engelen
b9ec85c7f6 Merge pull request #1836 from JohanEngelen/ldc0172
[Travis] Bump the LDC LTS version.
2016-10-17 00:45:04 +02:00
Johan Engelen
87e79ff9af [Travis] Bump the LDC LTS version. 2016-10-17 00:07:11 +02:00
Johan Engelen
9dad1609db Merge pull request #1812 from JohanEngelen/rename-ir2obj
Rename "ir2obj-cache" to "cache"
2016-10-16 16:27:06 +02:00
Johan Engelen
10b85feba4 Merge pull request #1824 from kinke/inplaceIR
Fix in-place construction of structs returned by inline assembly
2016-10-16 12:40:49 +02:00
Martin
44e7511e46 LDMD: Prevent object file collisions when creating static libs
Approximate DMD behavior by naming the temporary object files uniquely
and, if successful, removing all generated object files.

Executables and shared libs imply -singleobj => no collisions.
2016-10-15 23:54:22 +02:00
Martin
141310c77c Introduce (hidden) command-line option -cleanup-obj
Removing all generated object files on success.
2016-10-15 23:53:30 +02:00
Martin
d7b45f7c7d Revert "Revert "Check existing runtime function declarations for matching type""
This reverts commit 2de6538241.
2016-10-15 23:30:07 +02:00
David Nadlinger
bb2b648d8e Shared library support for OS X (#1705) 2016-10-15 16:17:39 +01:00
Martin
8276269ab1 Create static libs in -od directory for LDMD only
Let LDC treat relative output paths as relative to the current working
directory again (as it always used to until a few weeks ago). It's more
intuitive and avoids breaking build systems/scripts using LDC directly.

Only LDMD continues to prepend the -od directory to the relative output
path, for DMD compatibility.

Fixes issue #1819.
2016-10-14 21:47:27 +02:00
Johan Engelen
cf1a48870e Merge pull request #1811 from JohanEngelen/funcattributes
Apply TargetMachine options as function attributes in IR.
2016-10-14 00:07:46 +02:00
Johan Engelen
5077453629 Merge pull request #1826 from LemonBoy/asm-cvalid
Validate the __asm constraints.
2016-10-13 21:42:13 +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
LemonBoy
399962aa63 Validate the __asm constraints.
Fixes #802.
2016-10-13 15:53:08 +02:00
LemonBoy
549422f300 Add a test for #802. 2016-10-13 15:53:08 +02:00
Rainer Schuetze
f77d3fa6ff Merge pull request #1818 from rainers/fix_llvm40_2
fix build against LLVM master: clEnumValEnd removed
2016-10-13 01:35:09 +02:00
Rainer Schuetze
0b55bd21d2 fix build against LLVM master: clEnumValEnd removed 2016-10-12 23:55:59 +02:00
Johan Engelen
61e99e82d7 Rename "ir2obj-cache" to "cache" (source and filenames) 2016-10-12 18:58:01 +02:00
Johan Engelen
e0c78fa198 Rename -ir2obj-cache-* cmdline flags to -cache-*, because the cache can be used for more things than just ir2obj caching.
Rename "ir2obj" namespace to "cache".
2016-10-12 18:58:01 +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