aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-06-17Frontend: Respect -fno-temp-file when creating a PCHZachary Henkel1-7/+4
When creating a PCH file the use of a temp file will be dictated by the presence or absence of the -fno-temp-file flag. Creating a module file will always use a temp file via the new ForceUseTemporary flag. This fixes bug 50033.
2021-06-09Fix to Windows temp file change.Amy Huang1-3/+1
Original change passed wrong parameters to the raw_fd_ostream ctor. Fixes a bug in https://reviews.llvm.org/D102736.
2021-06-08[SystemZ][z/OS] Pass OpenFlags when creating tmp filesAbhina Sreeskantharajan1-1/+3
This patch https://reviews.llvm.org/D102876 caused some lit regressions on z/OS because tmp files were no longer being opened based on binary/text mode. This patch passes OpenFlags when creating tmp files so we can open files in different modes. Reviewed By: amccarth Differential Revision: https://reviews.llvm.org/D103806
2021-06-02Recommit "Fix tmp files being left on Windows builds." with a fix forAmy Huang1-33/+44
incorrect std::string use. (Also remove redundant call to RemoveFileOnSignal.) Clang writes object files by first writing to a .tmp file and then renaming to the final .obj name. On Windows, if a compile is killed partway through the .tmp files don't get deleted. Currently it seems like RemoveFileOnSignal takes care of deleting the tmp files on Linux, but on Windows we need to call setDeleteDisposition on tmp files so that they are deleted when closed. This patch switches to using TempFile to create the .tmp files we write when creating object files, since it uses setDeleteDisposition on Windows. This change applies to both Linux and Windows for consistency. Differential Revision: https://reviews.llvm.org/D102876 This reverts commit 20797b129f844d4b12ffb2b12cf33baa2d42985c.
2021-06-01Revert "Fix tmp files being left on Windows builds." for now;Amy Huang1-46/+29
causing some asan test failures. This reverts commit 7daa18215905c831e130c7542f17619e9d936dfc.
2021-06-01Fix tmp files being left on Windows builds.Amy Huang1-29/+46
Clang writes object files by first writing to a .tmp file and then renaming to the final .obj name. On Windows, if a compile is killed partway through the .tmp files don't get deleted. Currently it seems like RemoveFileOnSignal takes care of deleting the tmp files on Linux, but on Windows we need to call setDeleteDisposition on tmp files so that they are deleted when closed. This patch switches to using TempFile to create the .tmp files we write when creating object files, since it uses setDeleteDisposition on Windows. This change applies to both Linux and Windows for consistency. Differential Revision: https://reviews.llvm.org/D102876
2021-05-21[OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64Anton Zabaznov1-2/+3
There already exists cl_khr_fp64 extension. So OpenCL C 3.0 and higher should use the feature, earlier versions still use the extension. OpenCL C 3.0 API spec states that extension will be not described in the option string if corresponding optional functionality is not supported (see 4.2. Querying Devices). Due to that fact the usage of features for OpenCL C 3.0 must be as follows: ``` $ clang -Xclang -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 ... $ clang -Xclang -cl-ext=-cl_khr_fp64,-__opencl_c_fp64 ... ``` e.g. the feature and the equivalent extension (if exists) must be set to the same values Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D96524
2021-05-13Modules: Simplify how DisableGeneratingGlobalModuleIndex is set, likely NFCDuncan P. N. Exon Smith1-12/+2
DisableGeneratingGlobalModuleIndex was being set by CompilerInstance::findOrCompileModuleAndReadAST most of (but not all of) the times it returned `nullptr` as a "normal" failure. Pull that up to the caller, CompilerInstance::loadModule, to simplify the code. This resolves a number of FIXMEs added during the refactoring in 5cca622310c10fdf6f921b6cce26f91d9f14c762. The extra cases where this is set are all some version of a fatal error, and the only client of the field, shouldBuildGlobalModuleIndex, seems to be unreachable in that case. Even if there is some corner case where this has an effect, it seems like the right/consistent behaviour. Differential Revision: https://reviews.llvm.org/D101672
2021-05-13Modules: Rename ModuleBuildFailed => DisableGeneratingGlobalModuleIndex, NFCDuncan P. N. Exon Smith1-14/+14
Rename CompilerInstance's ModuleBuildFailed field to DisableGeneratingGlobalModuleIndex, which more precisely describes its role. Otherwise, it's hard to suss out how it's different from ModuleLoader::HadFatalFailure, and what sort of code simplifications are safe. Differential Revision: https://reviews.llvm.org/D101670
2021-05-13Modules: Remove ModuleLoader::OtherUncachedFailure, NFCDuncan P. N. Exon Smith1-10/+5
5cca622310c10fdf6f921b6cce26f91d9f14c762 refactored CompilerInstance::loadModule, splitting out findOrCompileModuleAndReadAST, but was careful to avoid making any functional changes. It added ModuleLoader::OtherUncachedFailure to facilitate this and left behind FIXMEs asking why certain failures weren't cached. After a closer look, I think we can just remove this and simplify the code. This changes the behaviour of the following (simplified) code from CompilerInstance::loadModule, causing a failure to be cached more often: ``` if (auto MaybeModule = MM.getCachedModuleLoad(*Path[0].first)) return *MaybeModule; if (ModuleName == getLangOpts().CurrentModule) return MM.cacheModuleLoad(PP.lookupModule(...)); ModuleLoadResult Result = findOrCompileModuleAndReadAST(...); if (Result.isNormal()) // This will be 'true' more often. return MM.cacheModuleLoad(..., Module); return Result; ``` `MM` here is a ModuleMap owned by the Preprocessor. Here are the cases where `findOrCompileModuleAndReadAST` starts returning a "normal" failed result: - Emitted `diag::err_module_not_found`, where there's no module map found. - Emitted `diag::err_module_build_disabled`, where implicitly building modules is disabled. - Emitted `diag::err_module_cycle`, which detects module cycles in the implicit modules build system. - Emitted `diag::err_module_not_built`, which avoids building a module in this CompilerInstance if another one tried and failed already. - `compileModuleAndReadAST()` was called and failed to build. The four errors are all fatal, and last item also reports a fatal error, so it this extra caching has no functionality change... but even if it did, it seems fine to cache these failed results within a ModuleMap instance (note that each CompilerInstance has its own Preprocessor and ModuleMap). Differential Revision: https://reviews.llvm.org/D101667
2021-05-03Modules: Remove an extra early return, NFCDuncan P. N. Exon Smith1-2/+0
Remove an early return from an `else` block that's immediately followed by an equivalent early return after the `else` block. Differential Revision: https://reviews.llvm.org/D101671
2021-04-28[OpenCL] Introduce new method for validating OpenCL targetAnton Zabaznov1-0/+5
Language options are not available when a target is being created, thus, a new method is introduced. Also, some refactoring is done, such as removing OpenCL feature macros setting from TargetInfo. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D101087
2021-04-07[clang] Check AuxTarget exists when creating target in CompilerInstanceoToToT1-2/+4
D97493 separate target creation out to a single function `CompilerInstance::createTarget`. However, it would overwrite AuxTarget even if it has been set. As @kadircet recommended in D98128, this patch check the existence of AuxTarget and not overwrite it when it has been set. Reviewed By: kadircet Differential Revision: https://reviews.llvm.org/D100024
2021-04-06[SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag ↵Abhina Sreeskantharajan1-3/+3
instead of OF_Text Problem: On SystemZ we need to open text files in text mode. On Windows, files opened in text mode adds a CRLF '\r\n' which may not be desirable. Solution: This patch adds two new flags - OF_CRLF which indicates that CRLF translation is used. - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses CRLF translation. Developers should now use either the OF_Text or OF_TextWithCRLF for text files and OF_None for binary files. If the developer doesn't want carriage returns on Windows, they should use OF_Text, if they do want carriage returns on Windows, they should use OF_TextWithCRLF. So this is the behaviour per platform with my patch: z/OS: OF_None: open in binary mode OF_Text : open in text mode OF_TextWithCRLF: open in text mode Windows: OF_None: open file with no carriage return OF_Text: open file with no carriage return OF_TextWithCRLF: open file with carriage return The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode if the OF_CRLF is set. ``` if (Flags & OF_CRLF) CrtOpenFlags |= _O_TEXT; ``` These following files are the ones that still use OF_Text which I left unchanged. I modified all these except raw_ostream.cpp in recent patches so I know these were previously in Binary mode on Windows. ./llvm/lib/Support/raw_ostream.cpp ./llvm/lib/TableGen/Main.cpp ./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp ./llvm/unittests/Support/Path.cpp ./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp ./clang/lib/Frontend/CompilerInstance.cpp ./clang/lib/Driver/Driver.cpp ./clang/lib/Driver/ToolChains/Clang.cpp Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D99426
2021-03-19[SystemZ][z/OS] Distinguish between text and binary files on z/OSAbhina Sreeskantharajan1-3/+6
This patch consists of the initial changes to help distinguish between text and binary content correctly on z/OS. I would like to get feedback from Windows users on setting OF_None for all ToolOutputFiles. This seems to have been done as an optimization to prevent CRLF translation on Windows in the past. Reviewed By: zibi Differential Revision: https://reviews.llvm.org/D97785
2021-02-26[clang][NFC] Extract Target and AuxTarget creation in CompilerInstance to ↵Yu-Hsun Chiang1-43/+49
new function As @sammccall mentioned in [[ https://reviews.llvm.org/D97109 | D97109 ]], I've extract the logic of creating Target and AuxTarget into a new function called `createTargetAndAuxTarget`. Since there are many similar code in clang or other related tools, consolidating them into a single function may help others to maintain the logic handling target related things. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D97493
2021-02-08Make sure a module file with errors produced via ↵Argyrios Kyrtzidis1-2/+6
'-fallow-pcm-with-compiler-errors' can be loaded when using implicit modules A module with errors would be marked as out-of-date, then the `compilerModule` action would produce it, but due to the error it would be treated as failure and the resulting PCM would not get used. rdar://74087062 Differential Revision: https://reviews.llvm.org/D96246
2021-01-26Frontend: Use early returns in CompilerInstance::clearOutputFiles, NFCDuncan P. N. Exon Smith1-17/+22
Use early returns in `CompilerInstance::clearOutputFiles` to clarify the logic, and rename `ec` to `EC` as a drive-by. No functionality change.
2021-01-26Frontend: Fix layering between create{,Default}OutputFile, NFCDuncan P. N. Exon Smith1-62/+51
Fix layering between `CompilerInstance::createDefaultOutputFile` and the two versions of `createOutputFile`. - Add missing configuration flags to `createDefaultOutputFile` so that GeneratePCHAction and GenerateModuleFromModuleMapAction can use it. They previously promised that temporary files were turned on; now `createDefaultOutputFile` handles that logic. - Lift the logic handling `InFile` and `Extension` to `createDefaultOutputFile`, since it's only the callers of that function that are using it. - Rename the deeper of the two `createOutputFile`s to `createOutputFileImpl` and make it private to `CompilerInstance` (to prove that no one else is using it). - Sink the logic for adding to `CompilerInstance::OutputFiles` down to `createOutputFileImpl`, allowing two "optional" (but always used) `std::string*` out parameters to be removed. - Instead of passing a `std::error_code` out parameter into `createOutputFileImpl`, have it return `Expected<>`. - As a drive-by, inline `CompilerInstance::addOutputFile` into its only caller, `createOutputFileImpl`. Clean layering makes it easier for a future commit to extract `createOutputFileImpl` out of `CompilerInstance`. Differential Revision: https://reviews.llvm.org/D93248
2021-01-26Frontend: Simplify handling of non-seeking streams in CompilerInstance, NFCDuncan P. N. Exon Smith1-5/+1
Add a new `raw_pwrite_ostream` variant, `buffer_unique_ostream`, which is like `buffer_ostream` but with unique ownership of the stream it's wrapping. Use this in CompilerInstance to simplify the ownership of non-seeking output streams, avoiding logic sprawled around to deal with them specially. This also simplifies future work to encapsulate output files in a different class. Differential Revision: https://reviews.llvm.org/D93260
2021-01-26Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStreamDuncan P. N. Exon Smith1-1/+1
Found this memory leak in `CompilerInstance::setVerboseOutputStream` by inspection; it looks like this wasn't previously exercised, since it was never called twice. Differential Revision: https://reviews.llvm.org/D93249
2021-01-21[ASTReader] Allow controlling separately whether validation should be ↵Argyrios Kyrtzidis1-6/+9
disabled for a PCH vs a module file This addresses an issue with how the PCH preable works, specifically: 1. When using a PCH/preamble the module hash changes and a different cache directory is used 2. When the preamble is used, PCH & PCM validation is disabled. Due to combination of #1 and #2, reparsing with preamble enabled can end up loading a stale module file before a header change and using it without updating it because validation is disabled and it doesn’t check that the header has changed and the module file is out-of-date. rdar://72611253 Differential Revision: https://reviews.llvm.org/D95159
2020-12-23Basic: Add native support for stdin to SourceManager and FileManagerDuncan P. N. Exon Smith1-23/+12
Add support for stdin to SourceManager and FileManager. Adds FileManager::getSTDIN, which adds a FileEntryRef for `<stdin>` and reads the MemoryBuffer, which is stored as `FileEntry::Content`. Eventually the other buffers in `ContentCache` will sink to here as well -- we probably usually want to load/save a MemoryBuffer eagerly -- but it's happening early for stdin to get rid of CompilerInstance::InitializeSourceManager's final call to `SourceManager::overrideFileContents`. clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp relies on building a module from stdin; supporting that requires setting ContentCache::BufferOverridden. Differential Revision: https://reviews.llvm.org/D93148
2020-12-23Basic: Support named pipes natively in SourceManager and FileManagerDuncan P. N. Exon Smith1-26/+3
Handle named pipes natively in SourceManager and FileManager, removing a call to `SourceManager::overrideFileContents` in `CompilerInstance::InitializeSourceManager` (removing a blocker for sinking the content cache to FileManager (which will incidently sink this new named pipe logic with it)). SourceManager usually checks if the file entry's size matches the eventually loaded buffer, but that's now skipped for named pipes since the `stat` won't reflect the full size. Since we can't trust `ContentsEntry->getSize()`, we also need shift the check for files that are too large until after the buffer is loaded... and load the buffer immediately in `createFileID` so that no client gets a bad value from `ContentCache::getSize`. `FileManager::getBufferForFile` also needs to treat these files as volatile when loading the buffer. Native support in SourceManager / FileManager means that named pipes can also be `#include`d, and clang/test/Misc/dev-fd-fs.c was expanded to check for that. This is a new version of 3b18a594c7717a328c33b9c1eba675e9f4bd367c, which was reverted in b34632201987eed369bb7ef4646f341b901c95b8 since it was missing the `SourceManager` changes. Differential Revision: https://reviews.llvm.org/D92531
2020-12-15Frontend: Fix confusing comment at call to clearOutputFiles, NFCDuncan P. N. Exon Smith1-4/+2
Fix the comment in front of `compileModuleImpl`'s call to `CompilerInstance::clearOutputFiles`. The purpose of this call is to delete any stray temporary files after the module generation thread crashes. The comment is from f545f67de3a1bfdbbfad88acde5b540ce3b82f4f, and was associated with manually deleting a generated module map. Then 13afbf42d830dd43febbeb0855aa359ca9dbfbf9 added this `clearOutputFiles` call between the comment and the code it referenced. Finally, 1f76c4e8101b9beaf8f1b10a57faa80256ab2b05 started sending the generated module map directly to the SourceManager instead of putting it on disk, deleting the call that the comment referenced. No functionality change.
2020-12-09Frontend: Use a getVirtualFileRef for a named pipe main file, NFCDuncan P. N. Exon Smith1-2/+2
2020-12-09Frontend: Migrate to FileEntryRef in ↵Duncan P. N. Exon Smith1-2/+2
CompilerInstance::InitializeSourceManager, NFC Use `FileManager::getVirtualFileRef` to get the virtual file for stdin, and add an overload of `SourceManager::overrideFileContents` that takes a `FileEntryRef`, migrating `CompilerInstance::InitializeSourceManager`. Differential Revision: https://reviews.llvm.org/D92680
2020-12-08[Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control ↵Yuanfang Chen1-1/+1
the pass timing aggregation Currently, -ftime-report + new pass manager emits one line of report for each pass run. This potentially causes huge output text especially with regular LTO or large single file (Obeserved in private tests and was reported in D51276). The behaviour of -ftime-report + legacy pass manager is emitting one line of report for each pass object which has relatively reasonable text output size. This patch adds a flag `-ftime-report=` to control time report aggregation for new pass manager. The flag is for new pass manager only. Using it with legacy pass manager gives an error. It is a driver and cc1 flag. `per-pass` is the new default so `-ftime-report` is aliased to `-ftime-report=per-pass`. Before this patch, functionality-wise `-ftime-report` is aliased to `-ftime-report=per-pass-run`. * Adds an boolean variable TimePassesHandler::PerRun to control per-pass vs per-pass-run. * Adds a new clang CodeGen flag CodeGenOptions::TimePassesPerRun to work with the existing CodeGenOptions::TimePasses. * Remove FrontendOptions::ShowTimers, its uses are replaced by the existing CodeGenOptions::TimePasses. * Remove FrontendTimesIsEnabled (It was introduced in D45619 which was largely reverted.) Differential Revision: https://reviews.llvm.org/D92436
2020-12-02Revert "Frontend: Sink named pipe logic from CompilerInstance down to ↵Duncan P. N. Exon Smith1-2/+24
FileManager" This reverts commit 3b18a594c7717a328c33b9c1eba675e9f4bd367c, since apparently this doesn't work everywhere. E.g., clang-x86_64-debian-fast/3889 (http://lab.llvm.org:8011/#/builders/109/builds/3889) gives me: ``` + : 'RUN: at line 8' + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -x c /dev/fd/0 -E + cat /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Misc/dev-fd-fs.c fatal error: file '/dev/fd/0' modified since it was first processed 1 error generated. ```
2020-12-02Frontend: Sink named pipe logic from CompilerInstance down to FileManagerDuncan P. N. Exon Smith1-24/+2
Remove compilicated logic from CompilerInstance::InitializeSourceManager to deal with named pipes, updating FileManager::getBufferForFile to handle it in a more straightforward way. The existing test at clang/test/Misc/dev-fd-fs.c covers the new behaviour (just like it did the old behaviour). Differential Revision: https://reviews.llvm.org/D90733
2020-11-17[Frontend] Add flag to allow PCM generation despite compiler errorsBen Barham1-1/+3
As with precompiled headers, it's useful for indexers to be able to continue through compiler errors in dependent modules. Resolves rdar://69816264 Reviewed By: akyrtzi Differential Revision: https://reviews.llvm.org/D91580
2020-11-10Allow searching for prebuilt implicit modules.Alexandre Rames1-7/+11
This reverts commit c67656b994c87224e0b33e2c4b09093986a5cfa6, and addresses the build issue.
2020-11-05Revert "Allow searching for prebuilt implicit modules."Stella Stamenova1-11/+7
This reverts commit 71e108cd86e70b06c5fa3a63689dcb3555c3d13f. This change caused a build failure on Windows: http://lab.llvm.org:8011/#/builders/83/builds/570
2020-11-05Allow searching for prebuilt implicit modules.Alexandre Rames1-7/+11
The behavior is controlled by the `-fprebuilt-implicit-modules` option, and allows searching for implicit modules in the prebuilt module cache paths. The current command-line options for prebuilt modules do not allow to easily maintain and use multiple versions of modules. Both the producer and users of prebuilt modules are required to know the relationships between compilation options and module file paths. Using a particular version of a prebuilt module requires passing a particular option on the command line (e.g. `-fmodule-file=[<name>=]<file>` or `-fprebuilt-module-path=<directory>`). However the compiler already knows how to distinguish and automatically locate implicit modules. Hence this proposal to introduce the `-fprebuilt-implicit-modules` option. When set, it enables searching for implicit modules in the prebuilt module paths (specified via `-fprebuilt-module-path`). To not modify existing behavior, this search takes place after the standard search for prebuilt modules. If not Here is a workflow illustrating how both the producer and consumer of prebuilt modules would need to know what versions of prebuilt modules are available and where they are located. clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v1 <config 1 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v2 <config 2 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v3 <config 3 options> clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules_v1 <config 1 options> clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap <non-prebuilt config options> With prebuilt implicit modules, the producer can generate prebuilt modules as usual, all in the same output directory. The same mechanisms as for implicit modules take care of incorporating hashes in the path to distinguish between module versions. Note that we do not specify the output module filename, so `-o` implicit modules are generated in the cache path `prebuilt_modules`. clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 1 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 2 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 3 options> The user can now simply enable prebuilt implicit modules and point to the prebuilt modules cache. No need to "parse" command-line options to decide what prebuilt modules (paths) to use. clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules -fprebuilt-implicit-modules <config 1 options> clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules -fprebuilt-implicit-modules <non-prebuilt config options> This is for example particularly useful in a use-case where compilation is expensive, and the configurations expected to be used are predictable, but not controlled by the producer of prebuilt modules. Modules for the set of predictable configurations can be prebuilt, and using them does not require "parsing" the configuration (command-line options). Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D68997
2020-10-20ContentCache: Simplify by always owning the MemoryBufferDuncan P. N. Exon Smith1-4/+10
This changes `ContentCache::Buffer` to use `std::unique_ptr<MemoryBuffer>` instead of the `PointerIntPair`. It drops the (mostly unused) `DoNotFree` bit, instead creating a (new) non-owning `MemoryBuffer` instance when passed a `MemoryBufferRef`. Differential Revision: https://reviews.llvm.org/D67030
2020-10-20clang/Frontend: Use MemoryBufferRef in FrontendInputFile (and remove ↵Duncan P. N. Exon Smith1-2/+1
SourceManager::getBuffer) In order to drop the final callers to `SourceManager::getBuffer`, change `FrontendInputFile` to use `Optional<MemoryBufferRef>`. Also updated the "unowned" version of `SourceManager::createFileID` to take a `MemoryBufferRef` (it now calls `MemoryBuffer::getMemBuffer`, which creates a `MemoryBuffer` that does not own the buffer data). Differential Revision: https://reviews.llvm.org/D89427
2020-10-19Revert "Reland "[Modules] Add stats to measure performance of building and ↵Volodymyr Sapsai1-5/+0
loading modules."" This reverts commit 4000c9ee18ecebe3ff0f197af8c1fb434ad986e5. Test "LLVM :: Other/statistic.ll" is failing on Windows.
2020-10-19Reland "[Modules] Add stats to measure performance of building and loading ↵Volodymyr Sapsai1-0/+5
modules." Measure amount of high-level or fixed-cost operations performed during building/loading modules and during header search. High-level operations like building a module or processing a .pcm file are motivated by previous issues where clang was re-building modules or re-reading .pcm files unnecessarily. Fixed-cost operations like `stat` calls are tracked because clang cannot change how long each operation takes but it can perform fewer of such operations to improve the compile time. Also tracking such stats over time can help us detect compile-time regressions. Added stats are more stable than the actual measured compilation time, so expect the detected regressions to be less noisy. On relanding drop stats in MemoryBuffer.cpp as their value is pretty low but affects a lot of clients and many of those aren't interested in modules and header search. rdar://problem/55715134 Reviewed By: aprantl, bruno Differential Revision: https://reviews.llvm.org/D86895
2020-09-24Revert "[Modules] Add stats to measure performance of building and loading ↵Volodymyr Sapsai1-5/+0
modules." This reverts commit c4bacc3c9b333bb7032fb96f41d6f5b851623132. Test "LLVM :: ThinLTO/X86/funcimport-stats.ll" is failing. Reverting now and will recommit after making the test not fail with the added stats.
2020-09-24[Modules] Add stats to measure performance of building and loading modules.Volodymyr Sapsai1-0/+5
Measure amount of high-level or fixed-cost operations performed during building/loading modules and during header search. High-level operations like building a module or processing a .pcm file are motivated by previous issues where clang was re-building modules or re-reading .pcm files unnecessarily. Fixed-cost operations like `stat` calls are tracked because clang cannot change how long each operation takes but it can perform fewer of such operations to improve the compile time. Also tracking such stats over time can help us detect compile-time regressions. Added stats are more stable than the actual measured compilation time, so expect the detected regressions to be less noisy. rdar://problem/55715134 Reviewed By: aprantl, bruno Differential Revision: https://reviews.llvm.org/D86895
2020-07-10Reland "[FPEnv][Clang][Driver] Disable constrained floating point on targets ↵Kevin P. Neal1-0/+13
lacking support." We currently have strict floating point/constrained floating point enabled for all targets. Constrained SDAG nodes get converted to the regular ones before reaching the target layer. In theory this should be fine. However, the changes are exposed to users through multiple clang options already in use in the field, and the changes are _completely_ _untested_ on almost all of our targets. Bugs have already been found, like "https://bugs.llvm.org/show_bug.cgi?id=45274". This patch disables constrained floating point options in clang everywhere except X86 and SystemZ. A warning will be printed when this happens. Use the new -fexperimental-strict-floating-point flag to force allowing strict floating point on hosts that aren't already marked as supporting it (X86 and SystemZ). Differential Revision: https://reviews.llvm.org/D80952
2020-07-06Revert "[FPEnv][Clang][Driver] Disable constrained floating point on targets ↵Kevin P. Neal1-13/+0
lacking support." My mistake, I had a blocking reviewer. This reverts commit 39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4. This reverts commit bfdafa32a0fa4b2745627fe57dd253db10ac3fcf. This reverts commit 2b35511350454dd22997f129ee529e3fdb129ac2. Differential Revision: https://reviews.llvm.org/D80952
2020-07-06[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking ↵Kevin P. Neal1-0/+13
support. We currently have strict floating point/constrained floating point enabled for all targets. Constrained SDAG nodes get converted to the regular ones before reaching the target layer. In theory this should be fine. However, the changes are exposed to users through multiple clang options already in use in the field, and the changes are _completely_ _untested_ on almost all of our targets. Bugs have already been found, like "https://bugs.llvm.org/show_bug.cgi?id=45274". This patch disables constrained floating point options in clang everywhere except X86 and SystemZ. A warning will be printed when this happens. Differential Revision: https://reviews.llvm.org/D80952
2020-07-03[clang][NFC] Removed unused parameters in InitializeSourceManagerAndrzej Warzynski1-8/+6
2020-04-17Rename IsMissingRequirement to IsUnimportable and set it for shadowedRichard Smith1-1/+1
modules too. This more accurately reflects the semantics of this flag, as distinct from "IsAvailable", which (in an explicit modules world) only describes whether a module is buildable, not whether it's importable.
2020-03-11Avoid including FileManager.h from SourceManager.hReid Kleckner1-0/+4
Most clients of SourceManager.h need to do things like turning source locations into file & line number pairs, but this doesn't require bringing in FileManager.h and LLVM's FS headers. The main code change here is to sink SM::createFileID into the cpp file. I reason that this is not performance critical because it doesn't happen on the diagnostic path, it happens along the paths of macro expansion (could be hot) and new includes (less hot). Saves some includes: 309 - /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileManager.h 272 - /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileSystemOptions.h 271 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/VirtualFileSystem.h 267 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/FileSystem.h 266 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Chrono.h Differential Revision: https://reviews.llvm.org/D75406
2020-02-21clang/Modules: Finish renaming CompilerInstance::ModuleManager, NFC.Volodymyr Sapsai1-2/+2
Follow-up to 20d51b2f14ac4488f684f8fc57cb0ba718a6b91d, rename the setter to make it consistent with the getter. Also fixed a few comments along the way, didn't try to find all references to a module manager. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D74939
2020-02-08Use heterogenous lookup for std;:map<std::string with a StringRef. NFCI.Benjamin Kramer1-5/+5
2020-02-04[hip] Properly populate macros based on host processor.Michael Liao1-0/+4
Summary: - The device compilation needs to have a consistent source code compared to the corresponding host compilation. If macros based on the host-specific target processor is not properly populated, the device compilation may fail due to the inconsistent source after the preprocessor. So far, only the host triple is used to build the macros. If a detailed host CPU target or certain features are specified, macros derived from them won't be populated properly, e.g. `__SSE3__` won't be added unless `+sse3` feature is present. On Windows compilation compatible with MSVC, that missing macros result in that intrinsics are not included and cause device compilation failure on the host-side source. - This patch addresses this issue by introducing two `cc1` options, i.e., `-aux-target-cpu` and `-aux-target-feature`. If a specific host CPU target or certain features are specified, the compiler driver will append them during the construction of the offline compilation actions. Then, the toolchain in `cc1` phase will populate macros accordingly. - An internal option `--gpu-use-aux-triple-only` is added to fall back the original behavior to help diagnosing potential issues from the new behavior. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73942
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-8/+8
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.