Commit Graph

1510 Commits

Author SHA1 Message Date
Christian Kamm
d7b00783d3 Automated merge with http://hg.dsource.org/projects/ldc 2009-06-20 19:12:04 +02:00
Christian Kamm
42b3da8ac7 Move function codegen data from IrFunction to new FuncGen.
This change reduces memory consumption significantly by releasing the
memory held by the STL containers that are now inside FuncGen.
2009-06-20 19:11:44 +02:00
Frits van Bommel
5ecdf1a70a Eliminate comparisons between GC allocations and constants. This removes some
`assert(this !is null)`s when member functions get inlined.

Also tweak pass order a bit.
2009-06-20 14:28:59 +02:00
Frits van Bommel
465f15eda0 Return void* from _d_allocclass so LLVM doesn't do weird things with it...
This allows `-instcombine` followed by `-gvn` to do devirtualization, so add
`-gvn` in strategic places in the default pass order.
2009-06-20 11:39:13 +02:00
Robert Clipsham
34fbdb6271 Automated merge with http://hg.dsource.org/projects/ldc 2009-06-18 15:44:18 +01:00
Robert Clipsham
f13c5e82f5 Added a stripModifiers() function to remove shared|const|immutable storage classes in D2 (should eventually be moved to a dhelpers file rather than llvm helpers).
Replaced a few occurances of STCinvariant with STCimmutable.
2009-06-18 15:44:04 +01:00
Christian Kamm
7dbe9baa37 Made is and !is use the same numeric comparison as == and !=, fixes #328
Factored out common code from EqualExp and IdentityExp into
DtoBinNumericEquals in binexp.cpp.
2009-06-16 23:00:27 +02:00
Frits van Bommel
4158fb474a Add an llvm::OStream workalike class for use with Logger::cout(), with the
crucial difference being special handling of `llvm::Type`s so they get printed
by name rather than printing their full representation (which can be positively
*huge*).

This allows re-enabling some logger calls that were disabled due to extreme
verbosity.
2009-06-16 19:31:10 +02:00
Benjamin Kramer
348192e7e7 Build fix for LLVM >= r73431 2009-06-16 15:37:40 +02:00
Kelly Wilson
0c1b6e27d9 fix problem reported in ticket 327 - thanks d0k 2009-06-16 08:57:20 -06:00
Christian Kamm
723cfef519 Another shot at fixing the issues with (constant) struct literals and their addresses. See DMD2682, #218, #324.
The idea is to separate the notion of const from 'this variable can always be
replaced with its initializer' in the frontend. To do that, I introduced
Declaration::isSameAsInitializer, which is overridden in VarDeclaration to
return false for constants that have a struct literal initializer.

So
{{{
const S s = S(5);
void foo() { auto ps = &s; }
// is no longer replaced by
void foo() { auto ps = &(S(5)); }
}}}

To make taking the address of a struct constant with a struct-initializer
outside of function scope possible, I made sure that AddrExp::optimize doesn't
try to run the argument's optimization with WANTinterpret - that'd again
replace the constant with a struct literal temporary.
2009-06-14 19:49:58 +02:00
Christian Kamm
8357777440 Set the default RUNTIME_DIR to be side-by-side of the ldc source dir. 2009-06-14 14:28:11 +02:00
Christian Kamm
e54d75354c Cannot take the address of a slice or struct literal as a constant expression. 2009-06-14 12:27:51 +02:00
Christian Kamm
dbe949ede6 More DtoType -> DtoTypeNotVoid for getting the array element llvm type. 2009-06-12 21:34:35 +02:00
Christian Kamm
1563c14e7a The llvm element type of void arrays should be i8 and not void.
This caused DtoArrayCopyToSlice to fail when trying to get the size of
llvm-void for something like void[3] s = "abc"; inside a function.
2009-06-12 20:39:01 +02:00
Frits van Bommel
25ebb3dbcd Generate less dead code by deleting unreachable blocks at the end of functions
(which would otherwise appear if a function ends with a return, for example).
2009-06-12 16:41:38 +02:00
Christian Kamm
8bcc2d9b3f Increment the iterator before deleting redundant functions or globals in the StripExternals pass. 2009-06-11 21:48:10 +02:00
Frits van Bommel
bc7737a03b Add some passes that opt runs to the default pass list. 2009-06-11 16:57:45 +02:00
Frits van Bommel
1f7a2a7884 Teach stack promotion to walk the CFG when a potential reuse of an allocation
is found to see if it can actually happen instead of just assuming it will.

This allows it to catch cases like
{{{
int i;
Foo f;
while (cond(i))
    f = new Foo(i++);
return f.value;
}}}
where it previously wouldn't because a phi using the allocation would appear in
the condition block to propagate it to the use after the loop.
2009-06-11 02:04:44 +02:00
Frits van Bommel
bf89205f7d Look for configuration file in /etc and /etc/ldc too (absolute paths)
except on Windows. Also disabled the `$PREFIX/etc/ldc` case for Windows, since
the "/etc/ldc" part was #if'ed out anyway.
2009-06-09 12:19:52 +02:00
Christian Kamm
f8840f66c4 Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322. 2009-06-08 19:48:20 +02:00
Frits van Bommel
9ba306a42f Oops, I accidentally pushed r1486 before the last touches were committed. 2009-06-08 13:52:45 +02:00
Frits van Bommel
8044a67720 Apply changes from r1482 to D2 frontend too. Completely untested, but ldc2
compiles again.
2009-06-08 13:45:26 +02:00
Frits van Bommel
b999f679a7 Teach -dgc2stack to promote GC allocations in simple loops to stack
allocations too. (A "simple" loop is one where the allocation isn't used in a
subsequent iteration)

This also means it's no longer necessary to run this pass multiple times.
Running it once after inlining should now catch all cases.
2009-06-08 12:35:55 +02:00
Frits van Bommel
f7ab031c7e Delete some code I forgot about in [1480]. 2009-06-07 23:00:53 +02:00
Frits van Bommel
f76870f255 Print the path to the configuration file being used if -v is passed. 2009-06-07 17:20:55 +02:00
Frits van Bommel
96650855ed Add a pass to strip the bodies of available_externally functions so string
literals and `TypeInfo`s only referenced by them can be deleted by `-globaldce`.
2009-06-07 16:00:13 +02:00
Frits van Bommel
96fdcd6347 Run semantic3 on imported modules, and emit new symbols with
`available_externally` linkage. This allows the inliner to inline functions from
other modules while telling the code generator to ignore those functions (treat
them as declarations)
Still generates a few extra `TypeInfo`s and strings...
Disabled when generating debug info because I don't really understand it, and it
doesn't like this.
2009-06-07 16:00:13 +02:00
Frits van Bommel
b972dcb92d Add -memcpyopt to the optimization pass list. 2009-06-07 15:07:29 +02:00
Frits van Bommel
f79e40a491 Use llvm.memset instead of _d_array_init_i1 and _d_array_init_i8.
This exposes what's happening to LLVM, and memset is probably faster than the
runtime functions we were using anyway.
2009-06-07 13:57:59 +02:00
Frits van Bommel
1958e17734 Rewrite StructLiteralExp::toElem to store individual fields instead of
generating a constant to fill the entire struct with a single `store`.
This is much more efficient at compile time (fixing #320) and vastly reduces
the size of the emitted code. Since LLVM no longer needs to keep the data for
all fields in "registers" until the store happens, it should also be more
efficient at run time in cases where the fields aren't assigned with constants.

There's also some code clean-up by removing duplicated logic.
2009-06-06 20:16:13 +02:00
Christian Kamm
b4f8bd6e52 Fix #318 by making a list of all seen template instances in a module for
singleobj compilation and then making sure they get emitted in their entirety.
2009-06-06 09:47:32 +02:00
Frits van Bommel
c6946d4072 Fix indentation, removing tabs. 2009-06-05 02:54:34 +02:00
Kelly Wilson
243a9bc4a6 There was another fix needed here for reading %%ldcbinarypath%% 2009-06-04 18:36:07 -06:00
Kelly Wilson
690ca32c0c Fix memory leak in configfile.cpp...probably the only one in ldc! 2009-06-04 16:46:05 -06:00
Kelly Wilson
d21e61b8b8 merging 2009-06-04 16:06:35 -06:00
Kelly Wilson
7bf64922f5 Fix for finding ldc.conf file with mingw 2009-06-04 16:04:26 -06:00
Frits van Bommel
5edb7545f2 Move -tailcallelim to a place in the optimization sequence where it seems to
be more useful.
2009-06-04 15:59:51 +02:00
Frits van Bommel
5a6e2f1c8f Emit nicer error messages when the user didn't set LLVM_REV and autodetection
didn't find a suitable revision or when the LLVM revision in use is too old.
2009-06-03 16:09:48 +02:00
Frits van Bommel
6c3afda318 Remove \r\n newlines from bash script. 2009-06-03 15:26:58 +02:00
Frits van Bommel
1ca21d089c Remove premake.lua and update the readme. 2009-06-03 15:09:30 +02:00
Tomas Lindquist Olsen
e31957dcd8 Change the frontend generated assert(this) or assert(&this) in D2 to set the ThisExp::var field. 2009-06-03 13:11:01 +02:00
Frits van Bommel
060d18b91e Fix a bug in DtoNestedInit and update an unrelated comment. 2009-06-03 12:32:35 +02:00
Tomas Lindquist Olsen
062b6d93c4 Make sure typeinfo output are mutable types, this is a temporary workaround to get druntime genobj.d to compile until we figure out what typeinfos are actually needed here and there ... 2009-06-03 04:12:28 +02:00
Tomas Lindquist Olsen
b218bfc828 Added missing initializer of (LDC introduced) Expression::cachedLvalue in D2 frontend. 2009-06-03 03:49:24 +02:00
Tomas Lindquist Olsen
092381577f Some minor changes to handling of variables referenced from nested functions in D2 .
Added generation of new 'void*[4] reserved;' !ModuleInfo member .
2009-06-03 03:04:47 +02:00
Tomas Lindquist Olsen
f6997cb604 D2:
Applied function type from D1 frontend that got removed in D2, it's critical for member function type to be correct.

Fixed a bunch of type discrepancies in druntime object.di vs. genobj.d .

Disabled (#if 0) some potentally very large type dumps for -vv .

Updated classinfo and typeinfo generation for D2, almost complete now.

Added finer grained checks for vtbl type mismatching, aids debugging.
2009-06-03 02:28:48 +02:00
Frits van Bommel
2cd4d15be1 Merge a fix from the D1 frontend to the D2 frontend. 2009-06-02 20:28:53 +02:00
Frits van Bommel
0c6a40485d Fix a segfault in ldc2 (use of an uninitialized variable). 2009-06-02 19:54:02 +02:00
Frits van Bommel
59f5636391 * Fix some gcc warnings in the D2 frontend code.
* Remove binaries from `dmd2/`
2009-06-02 19:18:48 +02:00