Commit graph

164 commits

Author SHA1 Message Date
Johan Engelen
950d2aabcf Additional -vv logging in DtoCreateNestedContext. (#2191) 2017-07-06 18:55:16 +02:00
kinke
89e5d27415 Put debuginfo on GEP instead of on the alloca with an offset. (#1984)
For nested variables. Resolves issue #1933 at the expense of a debuginfo
regression wrt. captured this pointer, see PR #1963.

Also add DWARF deref for non-ref/out variables captured by reference.
2017-01-25 00:36:00 +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
8be1e3e719 Adapt emission of debuginfos for parameters
Emit all parameters (except for captured ones) as DI parameters.
2016-10-09 20:17:39 +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
Johan Engelen
197b63a04f Fix debuginfo generation for the local variable frame for a function with nested functions.
Declare debuginfo directly on the GEP instead of on the frame alloca+offset, . An explicit DW_OP_deref is necessary (tested in LLDB).

Resolves an ICE introduced by PR #1598.
2016-07-27 16:57:47 +02:00
Elie Morisse
7ac1216292 Nested variables debug info fixes.
- Fix the value of closure variables in the parent function. Previously the passed value was the GEP instruction into .frame, and that instruction corresponds to a register  so resulted in "DWARF-2 expression error: DW_OP_reg operations must be used either alone(...)" (also the address was incorrect anyway because the offset would get doubled by 'addr')

 - When emitting debug info for a parent function parameter that is accessed from a nested function, call DIBuilder.createAutoVariable instead of createParameterVariable. Two different variables for the same parameter index was triggering an assert in llvm::DbgVariable::addMMIEntry. This fixes the compilation of druntime and phobos when building against LLVM 3.8.
2016-06-30 14:13:51 -03:00
Martin
0c0c1ecaf5 Rename DVarValue to DLValue 2016-06-13 22:30:15 +02:00
Martin
a6a6786d8d Try to boil down special cases in nested.cpp 2016-05-28 03:03:56 +02:00
David Nadlinger
bf432d92f3 DtoNestedVariable: Make debug log more useful [nfci] 2016-05-08 22:00:14 +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
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
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
33704577f3 Merge branch 'ltsmaster' 2016-02-25 20:09:19 +01:00
David Nadlinger
e127150cda Always use null for unneeded context pointers
This fixes the 'object' unit tests in 2.070.
2016-02-25 20:08:10 +01:00
David Nadlinger
0c7660a98b nested: Use early exit instead of giant if in DtoCreateNestedContextType [nfc] 2016-02-06 21:16:05 +01:00
Martin
ddfaac10b3 Rename DtoAggrCopy/ZeroInit() to DtoMemCpy/SetZero() overloads
And replace some obvious load->store combos by a memcpy.
2015-12-04 22:23:09 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01:00
Martin
b63a5e3cf8 Merge branch 'master' into merge-2.068 2015-10-22 22:39:46 +02:00
Martin
93158caca8 Respect alignments of captured variables when building nested context LL struct 2015-10-18 23:25:37 +02:00
Kai Nacke
012a9ee05c Merge branch 'master' into merge-2.068 2015-10-10 17:49:03 +02:00
Kai Nacke
0040b01675 Fix warning because of signed/unsigned comparison 2015-10-09 23:39:28 +02:00
Martin
46421dbd5f Proper (?) fix in getParentFunc() 2015-10-08 19:41:16 +02:00
Martin
b0649397c0 Nested static functions and function literals do not inherit the parent context 2015-10-08 19:40:54 +02:00
Martin
0d7c0aeedc Proper (?) fix in getParentFunc() 2015-10-08 03:23:02 +02:00
Martin
a2fe91d5e3 Nested static functions and function literals do not inherit the parent context 2015-10-08 02:17:58 +02:00
Martin
cda8a12112 Merge branch 'master' into merge-2.068
Conflicts:
	dmd2/root/man.c
	tests/d2/dmd-testsuite
2015-10-05 22:56:36 +02:00
Martin
b13565c17e Refactor common i1ToI8(voidToI8(DtoType(...))) code occurrences 2015-10-03 22:58:00 +02:00
Martin
8ee0e250c7 Merge branch 'master' into merge-2.068 2015-10-02 15:38:02 +02:00
Martin
aec8208c00 Fix debug infos of nested variables 2015-10-01 00:14:38 +02:00
David Nadlinger
4cc492b1df nested: Fix over-zealous invalid frame access check for calling context "root" functions 2015-09-26 15:24:36 +02:00
David Nadlinger
ce66fa4866 Emit error on invalid nested function call instead of crashing
For fail_compilation/fail39.d, the frontend furthermore passes a
FuncExp with a TOKdelegate declaration, but a function pointer type
to the glue layer. Just add that to the special case list.
2015-09-26 15:24:36 +02:00
David Nadlinger
ee50259dfd C ABI: Do not pass empty structs as parameters at all
This is most visible on x86 (32-bit), where the stack
alignment is off otherwise.

This change is quite messy because many places assumed
that there was always exactly one LLVM parameter per
TypeFunction::parameters entry.
2015-08-22 23:41:56 +02:00
David Nadlinger
4bcae9731a The big catch/finally rework, part 2
Now with *almost* working EH codegen. Does not compile Phobos yet
because we run into the "instruction does not dominate all uses"
issue when an r-value result of toElemDtor is used and we need to
run cleanups in between. Should easily be fixed by promoting those
values to allocas.

Most of the changes outside of ir/irfunction.{h, cpp} are just
because CreateCallOrInvoke moved locations. I took the
opportunity to also make use of the different arg count
overloads where possible.
2015-08-19 19:56:39 +02:00
Kai Nacke
15b1ee1576 DebugInfo: Output the underlying delegate for lazy parameters.
This fixes issue #959.
2015-06-04 15:09:29 +02:00
kai
b3e239a527 Fix generation of DWARF debug information in LLVM 3.6.
The creation of complex expressions (e.g. address calculations) was extended in LLVM 3.6.
2014-10-12 12:40:31 +02:00
David Nadlinger
bff766b379 Track member field index in IrTypeAggr, not IrField.
This fixes a regression introduced in caa2f15c8a. The IrDsymbol
metadata is obviously reset in between modules, while IrTypes
are not. Thus, we can never set symbol metadata when resolving
types, as the symbol data will be wrong in all modules following
the one where the type was first resolved.

GitHub: Fixes #739.
2014-10-11 03:28:49 +02:00
Alexey Prokhin
18f33b1815 Make IrDsymbol to be a typesafe union to reduce memory usage 2014-09-12 14:43:49 +04:00
kai
45fca1f3b5 Add line number to error message of -nogc switch.
This was suggested by bearophile in the news group.
It also changes all Loc objects to be passed by reference.
2014-07-04 07:15:05 +02:00
kai
2b6dbb03f4 Add IF_LOG to more logging statements.
Evaluating arguments which call toChars() or toPrettyChars() are much more expensive then checking Logger::enabled().
2014-06-26 06:54:38 +02:00
David Nadlinger
b40969b660 Re-introduce glue layer closure building error.
This reverts part of b15ffe2ef0,
and fixes 'fail_compilation/fail10666'.
2014-06-04 14:34:28 +02:00
kai
b15ffe2ef0 Merge branch 'master' into merge-2.064
Conflicts:
	gen/nested.cpp
2014-06-02 06:41:23 +02:00
Christian Kamm
522585aa6d Fix dmd test template2962 by removing nestedVars.
nestedVars was always a copy of closureVars. There was no point to it
existing.
2014-05-29 16:49:43 +02:00
Alexey Prokhin
a6973a39b7 Temporary variables cannot be referenced inside a closure 2014-01-12 15:44:17 +04:00
kai
6287a4d422 Replace ArrayIter<> with Array<>::iterator.
Just use the new iterator instead of the old Java-like class.
Also removes a dead iterator and replaces an iterator with a
pointer in some place.
2014-01-11 14:48:41 +01:00
Kai Nacke
bdc1f44088 Merge remote-tracking branch 'origin/master' into merge-2.064
Conflicts:
	gen/runtime.cpp
	runtime/CMakeLists.txt
2013-12-08 19:29:10 +01:00
Kai Nacke
aeba90b9f9 Fix a clang warning 2013-12-08 18:59:17 +01:00