Commit graph

114 commits

Author SHA1 Message Date
liushuyu
fc4d884d2d
Multiple changes ...
* Use getVoidPtrType helper
* Replace #define with constexpr
2024-03-26 14:48:36 -06:00
liushuyu
b8a96faf92 tree-wide: port LDC to LLVM 18 2024-03-26 14:45:35 -06:00
Andrei Horodniceanu
d7f87811f6
support CC envvar to be in the form "command args..." (#4582)
In case CC is set try to split it by spaces into a command and
arguments. This is the same behaviour as in dmd.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-02-24 16:46:35 +01:00
the-horo
f192187bdf
driver/toobj.cpp: writeModule: don't use StringRef::data to get a c_str (#4554)
The .data() method on a StringRef, returns a const char* to the first
character but there is no guarantee that the string is null
terminated.

In order to get a proper null terminated string it is
necessary to use .str() which will return a C++ std::string which
provided the .c_str() method to get the null terminated C string.

The invalid behavior can be seen by running (where the user doesn't
have acces to the inaccessible folder):
$ ldc2 <<< '' - -od=inaccessible/impossible
Error: failed to create output directory: inaccessible/impossible/__stdin_4416.o

The error message should only include inaccessible/impossible.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-01-07 20:45:10 +01:00
Johan Engelen
91d306894e
Add support for LLVM 17. (#4533) 2023-12-03 19:07:31 +01:00
Martin Kinkelin
a053480010 Misc. merge fixes (C++) 2023-11-06 00:33:57 +01:00
Martin Kinkelin
9ce57807c0 Drop support for LLVM 9 and LLVM 10 2023-07-29 01:12:43 +02:00
Johan Engelen
3e2156fa68
Don't output files on LLVM errors. (#4425)
Fix issue where an LLVM error or warning during IR passes (e.g. --fwarn-stack-size) does not abort outputting files. The object file would be added to the cache, and subsequent repeated LDC
execution would fetch the object file from the cache, effectively swallowing the error.
2023-06-16 00:26:07 +02:00
Martin Kinkelin
5b137768a0 Run C preprocessor 2023-06-07 12:06:25 +02:00
Martin Kinkelin
3f5f3662d1 Run dllimport relocation pass separately
In its own tiny legacy pass manager, right after the optimization
passes, for correct -output-{bc,ll} output (tested by Windows CI).
2023-05-12 23:58:32 +02:00
Martin Kinkelin
3197a523cd Run LLVM codegen passes once in toobj.cpp 2023-05-09 20:58:13 +02:00
Martin Kinkelin
0b40412c29
Fix #4354 - Huge compile slowdown with -g and the new LLVM pass manager (#4393)
Tested manually with the Symmetry project, and LLVM 14. The `-g`
compile times with both legacy and new pass managers are on par
again.
2023-05-09 12:30:10 +00:00
Nicholas Wilson
f08fef7e99
Use LLVM's SPIRV backend for LLVM 16 (#4187) 2022-09-21 10:13:51 +08:00
Nicholas Wilson
a3eae7a815
Fix compilation with LLVM16 (#4176) 2022-09-16 11:09:41 +08:00
Nicholas Wilson
d528554535
Remove getContainedType from driver/toobj.cpp (#4149) 2022-09-13 18:44:14 +08:00
Martin Kinkelin
bdef01e7cc Raise min LLVM version to 9.0 2022-04-25 23:11:48 +02:00
Johan Engelen
c517ce9d12
Improve ftime-trace implementation. (#3797)
* Improve ftime-trace implementation.
- Rewrite ftime-trace to our own implementatation instead of using LLVM's time trace code. The disadvantage is that this removes LLVM's work from the trace (optimization), but has the large benefit of being able to tailor the tracing output to our needs.
- Add memory tracing to ftime-trace (not possible with LLVM's implementation)
- Do not output the sum for each "category"/named string. This causes the LLVM output to be _very_ long, because we put more information in each time segment name. Tooling that processes the time trace output can do this summing itself (i.e. Tracy), and makes the time trace much more pleasant to view in trace viewers.
- Use MonoTime, move timescale calculation to output stage, 'measurement' stage uses ticks as unit
- Fix crash on `ldc2 -ftime-trace` without files passed.
2021-08-14 14:11:22 +02:00
Martin Kinkelin
bfa3cead08 Upgrade frontend & libs to early v2.097.0 (dlang/dmd@cb0457daf3) 2021-05-29 00:19:22 +02:00
Hiroki Noda
a8d98fc054
Use new OpenFlags enumeration (#3710)
[This](https://reviews.llvm.org/D101506) drops old deprecated
OpenFlags support.
OF_{Append,None,Text} has been available since LLVM 9.

- https://reviews.llvm.org/rG1f67a3cba9b09636c56e2109d8a35ae96dc15782
2021-05-01 00:43:45 +00:00
Johan Engelen
29245c8255
Add --ftime-trace functionality. (#3624)
This uses LLVM's TimeProfiler functionality, such that LLVM's work is traced in the same profile (optimization and machine code gen).
Functionality is meant to be identical to Clang and LLD's --ftime-trace.
2020-12-28 17:05:04 +01:00
Hiroki Noda
3268e4668a
[Trivial] refactor doLTO in writeModule (#3506) 2020-07-15 10:36:01 +02:00
Martin Kinkelin
834f666ce5
Raise min LLVM version to 6.0 (#3493) 2020-07-13 20:42:50 +02:00
Roberto Rosmaninho
6274217c39
Add -output-mlir and prepare for MLIR emission (#3313) 2020-05-22 12:31:24 +02:00
Martin Kinkelin
2d86e49fba
Finalize support for LLVM 10 (#3323) 2020-02-14 17:53:40 +01:00
Fangrui Song
0a007a55f8
Fix StringRef conversion for LLVM 11 (777180a32b61070a10dd330b4f038bf24e916af1) (#3305) 2020-02-01 02:52:35 +01:00
Nicholas Lindsay Wilson
5b7d706ea6 Fix future versions of LLVM9 2019-12-09 09:49:27 +08:00
Nicholas Lindsay Wilson
f5b81cd731 Fix CGFT 2019-12-09 09:48:55 +08:00
Martin Kinkelin
030123410a Add support for LLVM 9.0.0
Including some of Nicholas' fixes in #3144.
2019-09-25 03:42:18 +02:00
Martin Kinkelin
e52199469f Upgrade front-end & libs to v2.087.0-beta.1 2019-06-21 15:39:45 +02:00
Nicholas Wilson
f5ae8311cd
Adapt to using SPIR-V support as an external library (#2935)
Adapt to using SPIR-V support as an external library.
2019-01-18 14:51:48 +08:00
Martin Kinkelin
5c24f60cf9
Raise min LLVM version to 3.9 (#2872) 2018-10-15 22:31:59 +02:00
Ivan Butygin
21972bbc49
Clone module if we are writing both assembly and object (#2847) 2018-09-09 18:47:47 +03:00
Johan Engelen
95b454d2bd Fix compilation with current LLVM trunk. (#2722) 2018-06-03 01:30:27 +02:00
Martin
2faf46962f Emit both object file and LTO bitcode file via -output-o -output-bc -flto=... 2018-04-16 22:13:21 +02:00
Johan Engelen
aa979e6e90 fix LLVM7.0 build (#2578) 2018-02-19 00:07:01 +03:00
Johan Engelen
9ff79e556a
Small fix to fix compiler warning (gcc bug?) (#2564)
On the ARM scaleway buildbot, I saw this warning:
```
/var/lib/buildbot/slaves/scaleway/armv7_builder/build/driver/toobj.cpp: In constructor ‘{anonymous}::AssemblyAnnotator::AssemblyAnnotator(const llvm::DataLayout&)’:
/var/lib/buildbot/slaves/scaleway/armv7_builder/build/driver/toobj.cpp:152:56: warning: a temporary bound to ‘{anonymous}::AssemblyAnnotator::DL’ only persists until the constructor exits [-Wextra]
   AssemblyAnnotator(const llvm::DataLayout &dl) : DL{dl} {}
```
http://buildbot.ldc-developers.org/builders/armv7_builder/builds/3087/steps/make/logs/stdio

Looks like this gcc bug: https://stackoverflow.com/questions/25561387/spurious-warning-about-binding-temporary-to-reference-member-in-constructor

So let's just use old-style initialization, and we should be good.
2018-02-08 22:30:36 +01:00
Johan Engelen
e2a5fba876
Remove one use of gDataLayout. (#2525) 2018-01-22 21:34:41 +01:00
Martin
27deb2ff8c Get rid of obsolete gen/llvmcompat.h
Not needed anymore since C++11.
2018-01-12 20:20:47 +01:00
Nicholas Wilson
baf3654868
Fix compilation with most recent LLVM (#2428)
Fix LDC compilation with latest LLVM (Mostly renaming and moving headers).
2017-12-03 18:25:43 +08:00
Martin Kinkelin
b67232a886
IR annotations: Let LLVM print debug locations (#2377)
Which also includes the file.
2017-11-28 21:14:19 +01:00
kinke
3b2f6bccdb Don't use -m32/-m64 for external ARM assembler (#2264)
And merge the two out-of-sync copies for adding gcc target flags. The flag
was omitted for gcc as linker already, but not for gcc as external assembler.
2017-08-12 18:17:03 +02:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Nicholas Wilson
40de53d095 Fix LTO for LLVM 5.0 (#2158)
Remove micro-optimization that breaks LTO on LLVM 5.0.
2017-06-06 08:34:35 +02:00
David Nadlinger
747f7a3dfa clang-format files touched in d01a91f7 [nfc]
Some housekeeping on files that recently saw large changes anyway.
2017-05-24 21:35:40 +01: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
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
Rainer Schuetze
ae7f1a7f2c fix buildinng against LLVM master (#2111) 2017-05-16 20:43:29 +02:00
Martin
95c1d38e2e Integrate module gen/programs into driver/tool 2017-03-13 23:31:32 +01:00
Martin
cab165f3d8 Set up the MSVC environment in a more flexible way
For invoking MS tools such as link.exe and lib.exe, which require
compatible PATH, LIB, LIBPATH etc.

We previously wrapped the invokation of the tool with a batch file taking
care of setting up the environment and then calling the actual tool.

I changed this to first invoke another batch file setting up its
environment and then dumping all environment variables to a file. LDC then
parses this file and updates its own environment variables. Later spawned
child processes then inherit the updated environment, and the tools will
be located by LLVM in updated PATH.

This allows LDC to keep track of the used Visual C++ installation (and
could so set up additional runtime libs required since VS 2015, something
we would have needed some time back when we still supported VS 2013). It's
also required as a prerequisite for integrating LLD as in-process linker
on Windows.

I quickly looked into the option of setting up the environment manually,
but the MS batch files are full of quirks, mixtures of registry and
file-system lookups, checking for existence of misc. headers to filter out
bogus installations etc. With VS 2017, there's nothing in the registry at
all anymore (at least for the Build Tools); MS expose a COM interface for
querying the VS installer... But at least they still provide the batch
files.
2017-03-13 00:36:45 +01:00
Johan Engelen
c1c1fcb027 Add PGO data to the ThinLTO module summary (LLVM >= 4.0). (#1892) 2016-11-23 12:53:55 +01:00