Commit graph

444 commits

Author SHA1 Message Date
Martin
0b28925e9a Win32: Remove extra leading underscore from D symbol mangling
This is compatible with DMD.
2017-10-07 14:06:17 +02:00
Martin
d7f68dbeb3 Merge branch 'master' into merge-2.075
Conflicts:
	runtime/druntime
2017-10-01 18:28:44 +02:00
Martin
610a1c37e4 Handle multiple function definitions with same mangled name
By discarding (and warning about) all but the first definition.
compilable/test17352.d tests that the compiler accepts 2 distinct but
equivalent templated function instantiations (with an alias to a
different local of the same type and name) ending up with a common
mangled name.
See https://issues.dlang.org/show_bug.cgi?id=17352.
2017-09-23 22:11:34 +02:00
Martin
1fa90a0381 Fix parameter-less out contracts of virtual methods with auto return type
These out contracts can still access the return value via __result.

LDC always passes the return value by reference to the out contract -
as long as there is a result (non-void). As the return type may still
need to be inferred in the first semantic pass, reserve a parameter
there and remove it later in semantic3() in case it is void (or finalize
its type).

Fixes compilable/test17502.
2017-09-23 21:50:34 +02:00
kinke
ae9d43c167 Use LLVM headers for shared codegen command-line options (#2148)
I.e., llvm/CodeGen/CommandFlags.h which in turn includes
llvm/MC/MCTargetOptionsCommandFlags.h.

This gets rid of a few duplicates on our side and includes about 35
(depending on LLVM version) new command-line options. LLVM provides a
helper function to set up the TargetOptions according to (most of) these
options.
Newer LLVM versions may add new options and we'll automatically inherit
them, including setting up the TargetOptions accordingly.

I did my best (TM) to remove a few unused/undesirable options and hide all
remaining new ones except for `-fp-contract`. The lists will need to be
tweaked from time to time.
2017-09-20 01:04:43 +02:00
Martin
41aae46b91 Merge branch 'master' into merge-2.075
Conflicts:
	runtime/druntime
2017-09-12 19:44:53 +02:00
Martin
8cc5ff6e79 Fix debuginfos for nested ref/out parameters (use llvm.dbg.declare)
llvm.dbg.value() apparently doesn't like GEP + deref, so use
llvm.dbg.declare() & GEP.
2017-09-09 22:02:14 +02:00
Martin
8a5984b7d3 Use llvm.dbg.value for all non-special refs & fix nested refs DI 2017-09-09 22:01:22 +02:00
Martin
7d4e9622a5 Fix DI storage for captured function parameters 2017-09-09 22:01:22 +02:00
Martin
b085be1404 Merge branch 'master' into merge-2.075
Conflicts:
	runtime/druntime
	runtime/phobos
2017-08-12 18:21:21 +02:00
kinke
b01c3be575 Replace hacky disabling of fp-elimination for functions with inline asm (#2266)
... by proper function attributes. Clang sets these 2 attributes if frame
pointer elimination is to be fully disabled.
2017-08-12 14:14:13 +02:00
Johan Engelen
ec9ffe29f1 Add the -fsanitize-blacklist option for the sanitizers. (#2261)
Blacklisting is necessary for some druntime functions, and LLVM/Clang already provides just the right functionality.
2017-08-09 23:21:33 +02:00
Martin
2616261fd2 Revise all LDC-specific errors/warnings/deprecs and insert backticks
For DMD's new syntax highlighting. I grepped in all .{h,cpp} files only.
2017-08-03 22:53:49 +02:00
Martin
c51c2c0d55 Merge 2.075.0 front-end and stdlibs 2017-07-30 03:03:28 +02:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Nicholas Wilson
c041205fe0 Dcompute fixes (#2195)
* Disable debug info for now Until I get it working.

* Don't recurse into uninstansiated templates

* Remove device only modules from objfiles.

* Remove typeid generation for dcompute.

* Dont generate typeinfo member functions

* Whitelist `__dcompute_reflect`
2017-07-13 11:28:09 +08:00
Johan Engelen
22b1accb59 Replace -sanitize with -fsanitize and add -fsanitize-coverage. (#2149)
This reworks the sanitizer interface to be identical with Clang's.
What's left to do is pass the correct runtime libraries to the linker.
2017-06-15 17:19:21 +02:00
Nicholas Wilson
69ad69e872 [dcomptue] semantic analysis & lit tests (#2143)
* CI & semantic analysis

* semantic and codegen tests
2017-05-29 16:02:17 +08:00
kinke
151e83dc6b Fix C++ warnings (#2140) 2017-05-26 13:45:15 +02:00
Nicholas Wilson
ae6ff33fc1 [dcomptue] codegen (#2126)
* code generation

* simplify logic

* apply clang-format

* Undo completely inane choice by clang-format

* Guard the use of the command line args.
2017-05-24 08:55:32 +08:00
David Nadlinger
c9112f3daf Only non-typesafe variadics need to take LLVM varargs (#2127)
* gen/functions: Re-clang-format, minor style cleanup [nfc]

* Only non-typesafe variadics need to take LLVM varargs

GitHub: Fixes #2121.
2017-05-22 15:37:05 +08:00
Johan Engelen
64df1687a8 Fix LLVM 5.0 compilation. 2017-04-14 12:55:19 +02:00
Martin
82395def98 Re-add uwtable function attribute on Win64
Apparently needed for x86_64 in general and NetBSD (possibly other BSD
flavours too) based on `clang::ToolChain::IsUnwindTablesDefault()`.

Resolves issue #2048.
2017-03-25 22:28:23 +01:00
Johan Engelen
e21634e19d Fix LLVM 5.0 build and update profile-rt (#2039)
* Update profile-rt (LLVM 5.0)

* Fix LLVM 5.0 compile.

"less-precise-fpmad" is now always set to "false".
2017-03-18 20:58:10 +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
Ivan
def709c59b Renamed helpers.h to scope_exit.h 2017-01-06 12:17:50 +03:00
Ivan
6c4f421ead Use SCOPE_EXIT in DtoDefineFunction 2016-12-19 00:51:07 +03: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
b7c2a30950 Win64: Don't enforce uwtable function attribute 2016-11-15 21:15: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
LemonBoy
596fc82254 Implement -finstrument-functions.
Closes #1839.
2016-11-06 23:17:04 +01: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
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
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
Johan Engelen
63fba4efdb Add a matching call to llvm.va_end when llvm.va_start was called.
Resolves #1744
2016-10-07 14:48:46 +02:00
Johan Engelen
00dfb4d138 Apply TargetMachine options as function attributes in IR. Needed for LTO. 2016-10-06 19:06:30 +02:00
Rainer Schuetze
2dec29b825 CodeView: fix display of dynamic array arguments (#1761) 2016-09-24 21:06:58 +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
c6ba2dc29b Fix a few clang warnings. [NFC] 2016-07-27 20:21:02 +02:00
Johan Engelen
463e53b9ac Apply DDMD PR #5885 (f5f9150ea57cce5fabb43c79ff1b187d34d37044).
This fixes incorrect overriding of class methods and gets rid of many C++ warnings.
2016-07-25 15:25:01 +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
David Nadlinger
75e1573cb2 Merge pull request #1577 from JohanEngelen/inlining
Implement cross-module inlining
2016-07-04 21:32:28 +01:00
Johan Engelen
f2c3ed4cce Separate inlining-heuristic code into its own file. Implement a simple statement-counting inlining heuristic. 2016-07-02 17:08:48 +02:00
Johan Engelen
7919805eb4 Disable cross-module inlining for LLVM < 3.7. 2016-07-02 17:08:48 +02:00
Johan Engelen
7ed5a09dc3 Fixes and improvements to cross-module inlining code. 2016-07-02 17:08:48 +02:00
Johan Engelen
a3f0678283 Fix inlining problem: reverse order in which module array is codegenned. 2016-07-02 17:08:48 +02:00
Johan Engelen
0eb8689006 Implement cross-module inlining (with and without pragma). 2016-07-02 17:08:47 +02:00
Johan Engelen
b8048be6e4 Implement same-module pragma(inline, {true|false}). 2016-07-02 17:08:47 +02:00
Martin
cdb817633e Rename IrFunction::retArg to sretArg 2016-07-02 12:52:28 +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