aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-02-02[Driver] Move -fsemantic-interposition decision from cc1 to driverFangrui Song1-3/+1
And add test/Driver/fsemantic-interposition.c
2020-02-01[Frontend] Delete a redundant check of -pg for setFramePointer()Fangrui Song1-5/+0
Driver errors if -fomit-frame-pointer is used together with -pg. useFramePointerForTargetByDefault() returns true if -pg is specified. => (!OmitFP && useFramePointerForTargetByDefault(Args, Triple)) is true => We cannot get FramePointerKind::None
2020-01-31Implement -fsemantic-interpositionserge-sans-paille1-0/+4
First attempt at implementing -fsemantic-interposition. Rely on GlobalValue::isInterposable that already captures most of the expected behavior. Rely on a ModuleFlag to state whether we should respect SemanticInterposition or not. The default remains no. So this should be a no-op if -fsemantic-interposition isn't used, and if it is, isInterposable being already used in most optimisation, they should honor it properly. Note that it only impacts architecture compiled with -fPIC and no pie. Differential Revision: https://reviews.llvm.org/D72829
2020-01-29Fix conversions in clang and examplesBenjamin Kramer1-1/+2
2020-01-29Fix a couple more implicit conversions that Clang doesn't diagnose.Benjamin Kramer1-6/+15
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-69/+93
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.
2020-01-27Make AST reading work better with LLVM_APPEND_VC_REV=NONico Weber1-0/+6
With LLVM_APPEND_VC_REV=NO, Modules/merge-lifetime-extended-temporary.cpp would fail if it ran before a0f50d731639350c7a7 (which changed the serialization format) and then after, for these reasons: 1. With LLVM_APPEND_VC_REV=NO, the module hash before and after the change was the same. 2. Modules/merge-lifetime-extended-temporary.cpp is the only test we have that uses -fmodule-cache-path=%t that a) actually writes to the cache path b) doesn't do `rm -rf %t` at the top of the test So the old run would write a module file, and then the new run would try to load it, but the serialized format changed. Do several things to fix this: 1. Include clang::serialization::VERSION_MAJOR/VERSION_MINOR in the module hash, so that when the AST format changes (...and we remember to bump these), we use a different module cache dir. 2. Bump VERSION_MAJOR, since a0f50d731639350c7a7 changed the on-disk format in a way that a gch file written before that change can't be read after that change. 3. Add `rm -rf %t` to all tests that pass -fmodule-cache-path=%t. This is unnecessary from a correctness PoV after 1 and 2, but makes it so that we don't amass many cache dirs over time. (Arguably, it also makes it so that the test suite doesn't catch when we change the serialization format but don't bump clang::serialization::VERSION_MAJOR/VERSION_MINOR; oh well.) Differential Revision: https://reviews.llvm.org/D73202
2020-01-27Add a warning, flags and pragmas to limit the number of pre-processor tokens ↵Hans Wennborg1-0/+2
in a translation unit See https://docs.google.com/document/d/1xMkTZMKx9llnMPgso0jrx3ankI4cv60xeZ0y4ksf4wc/preview for background discussion. This adds a warning, flags and pragmas to limit the number of pre-processor tokens either at a certain point in a translation unit, or overall. The idea is that this would allow projects to limit the size of certain widely included headers, or for translation units overall, as a way to insert backstops for header bloat and prevent compile-time regressions. Differential revision: https://reviews.llvm.org/D72703
2020-01-23[Frontend] Delete some unneeded CC1 optionsFangrui Song1-21/+8
2020-01-23[Driver][CodeGen] Support -fpatchable-function-entry=N,M and ↵Fangrui Song1-0/+2
__attribute__((patchable_function_entry(N,M))) where M>0 Reviewed By: nickdesaulniers Differential Revision: https://reviews.llvm.org/D73072
2020-01-24[Concepts] Deprecate -fconcepts-ts, enable Concepts under -std=c++2aSaar Raz1-1/+2
Now with concepts support merged and mostly complete, we do not need -fconcepts-ts (which was also misleading as we were not implementing the TS) and can enable concepts features under C++2a. A warning will be generated if users still attempt to use -fconcepts-ts.
2020-01-22[Concepts] Constraint Satisfaction CachingSaar Raz1-0/+2
Add a simple cache for constraint satisfaction results. Whether or not this simple caching would be permitted in final C++2a is currently being discussed but it is required for acceptable performance so we use it in the meantime, with the possibility of adding some cache invalidation mechanisms later. Differential Revision: https://reviews.llvm.org/D72552
2020-01-17Consolidate internal denormal flushing controlsMatt Arsenault1-3/+7
Currently there are 4 different mechanisms for controlling denormal flushing behavior, and about as many equivalent frontend controls. - AMDGPU uses the fp32-denormals and fp64-f16-denormals subtarget features - NVPTX uses the nvptx-f32ftz attribute - ARM directly uses the denormal-fp-math attribute - Other targets indirectly use denormal-fp-math in one DAGCombine - cl-denorms-are-zero has a corresponding denorms-are-zero attribute AMDGPU wants a distinct control for f32 flushing from f16/f64, and as far as I can tell the same is true for NVPTX (based on the attribute name). Work on consolidating these into the denormal-fp-math attribute, and a new type specific denormal-fp-math-f32 variant. Only ARM seems to support the two different flush modes, so this is overkill for the other use cases. Ideally we would error on the unsupported positive-zero mode on other targets from somewhere. Move the logic for selecting the flush mode into the compiler driver, instead of handling it in cc1. denormal-fp-math/denormal-fp-math-f32 are now both cc1 flags, but denormal-fp-math-f32 is not yet exposed as a user flag. -cl-denorms-are-zero, -fcuda-flush-denormals-to-zero and -fno-cuda-flush-denormals-to-zero will be mapped to -fp-denormal-math-f32=ieee or preserve-sign rather than the old attributes. Stop emitting the denorms-are-zero attribute for the OpenCL flag. It has no in-tree users. The meaning would also be target dependent, such as the AMDGPU choice to treat this as only meaning allow flushing of f32 and not f16 or f64. The naming is also potentially confusing, since DAZ in other contexts refers to instructions implicitly treating input denormals as zero, not necessarily flushing output denormals to zero. This also does not attempt to change the behavior for the current attribute. The LangRef now states that the default is ieee behavior, but this is inaccurate for the current implementation. The clang handling is slightly hacky to avoid touching the existing denormal-fp-math uses. Fixing this will be left for a future patch. AMDGPU is still using the subtarget feature to control the denormal mode, but the new attribute are now emitted. A future change will switch this and remove the subtarget features.
2020-01-17[clang][xray] Add -fxray-ignore-loops optionIan Levesque1-0/+2
XRay allows tuning by minimum function size, but also always instruments functions with loops in them. If the minimum function size is set to a large value the loop instrumention ends up causing most functions to be instrumented anyway. This adds a new flag, -fxray-ignore-loops, to disable the loop detection logic. Differential Revision: https://reviews.llvm.org/D72873
2020-01-13[DebugInfo] Add another level to DebugInfoKind called ConstructorAmy Huang1-2/+2
The option will limit debug info by only emitting complete class type information when its constructor is emitted. This patch changes comparisons with LimitedDebugInfo to use the new level instead. Differential Revision: https://reviews.llvm.org/D72427
2020-01-13This option allows selecting the TLS size in the local exec TLS model,KAWASHIMA Takahiro1-0/+2
which is the default TLS model for non-PIC objects. This allows large/ many thread local variables or a compact/fast code in an executable. Specification is same as that of GCC. For example, the code model option precedes the TLS size option. TLS access models other than local-exec are not changed. It means supoort of the large code model is only in the local exec TLS model. Patch By KAWASHIMA Takahiro (kawashima-fj <t-kawashima@fujitsu.com>) Reviewers: dmgreen, mstorsjo, t.p.northover, peter.smith, ostannard Reviewd By: peter.smith Committed by: peter.smith Differential Revision: https://reviews.llvm.org/D71688
2020-01-10[Driver][CodeGen] Add -fpatchable-function-entry=N[,0]Fangrui Song1-0/+2
In the backend, this feature is implemented with the function attribute "patchable-function-entry". Both the attribute and XRay use TargetOpcode::PATCHABLE_FUNCTION_ENTER, so the two features are incompatible. Reviewed By: ostannard, MaskRay Differential Revision: https://reviews.llvm.org/D72222
2020-01-07[HIP] Add option --gpu-max-threads-per-block=nYaxun (Sam) Liu1-0/+6
Add this option to change the default launch bounds. Differential Revision: https://reviews.llvm.org/D71221
2020-01-06Add Triple::isX86()Fangrui Song1-1/+1
Reviewed By: craig.topper, skan Differential Revision: https://reviews.llvm.org/D72247
2019-12-21[NFC] Separate getLastArgIntValue to BasicYaxun (Sam) Liu1-27/+0
getLastArgIntValue is a useful utility function to get command line argument as an integer. Currently it is in Frontend so that it can only be used by clang -cc1. Move it to basic so that it can also be used by clang driver. Differential Revision: https://reviews.llvm.org/D71080
2019-12-19[Clang FE, SystemZ] Recognize -mrecord-mcount CL option.Jonas Paulsson1-0/+1
Recognize -mrecord-mcount from the command line and add a function attribute "mrecord-mcount" when passed. Only valid on SystemZ (when used with -mfentry). Review: Ulrich Weigand https://reviews.llvm.org/D71627
2019-12-19Re-land "Add an -fno-temp-file flag for compilation"Hans Wennborg1-0/+1
This time making sure to initialize FrontendOptions::UseTemporary. Patch by Zachary Henkel! Differential revision: https://reviews.llvm.org/D70615
2019-12-18Revert "Add an -fno-temp-file flag for compilation"Mitch Phillips1-1/+0
This reverts commit d129aa1d5369781deff6c6b854cb612e160d3fb2. This broke the MSan buildbots. More information available in the original PR: https://reviews.llvm.org/D70615
2019-12-18Add an -fno-temp-file flag for compilationHans Wennborg1-0/+1
Our build system does not handle randomly named files created during the build well. We'd prefer to write compilation output directly without creating a temporary file. Function parameters already existed to control this behavior but were not exposed all the way out to the command line. Patch by Zachary Henkel! Differential revision: https://reviews.llvm.org/D70615
2019-12-17[Frontend] Fixes -Wrange-loop-analysis warningsMark de Wever1-3/+3
This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71530
2019-12-17[Clang FE, SystemZ] Recognize -mpacked-stack CL optionJonas Paulsson1-0/+1
Recognize -mpacked-stack from the command line and add a function attribute "mpacked-stack" when passed. This is needed for building the Linux kernel. If this option is passed for any other target than SystemZ, an error is generated. Review: Ulrich Weigand https://reviews.llvm.org/D71441
2019-12-12Default to -fuse-init-arrayFangrui Song1-1/+1
Very few ELF platforms still use .ctors/.dtors now. Linux (glibc: 1999-07), DragonFlyBSD, FreeBSD (2012-03) and Solaris have supported .init_array for many years. Some architectures like AArch64/RISC-V default to .init_array . GNU ld and gold can even convert .ctors to .init_array . It makes more sense to flip the CC1 default, and only uses -fno-use-init-array on platforms that don't support .init_array . For example, OpenBSD did not support DT_INIT_ARRAY before Aug 2016 (https://github.com/openbsd/src/commit/86fa57a2792c6374b0849dd7b818a11e676e60ba) I may miss some ELF platforms that still use .ctors, but their maintainers can easily diagnose such problems. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D71393
2019-12-11[OpenMP] Use the OpenMP-IR-BuilderJohannes Doerfert1-0/+2
This is a follow up patch to use the OpenMP-IR-Builder, as discussed on the mailing list ([1] and later) and at the US Dev Meeting'19. [1] http://lists.flang-compiler.org/pipermail/flang-dev_lists.flang-compiler.org/2019-May/000197.html Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim Subscribers: ppenzin, penzn, llvm-commits, cfe-commits, jfb, guansong, bollu, hiraditya, mgorny Tags: #clang Differential Revision: https://reviews.llvm.org/D69922
2019-12-08[Frontend] Allow OpenMP offloading to aarch64Bryan Chan1-1/+2
Summary: D30644 added OpenMP offloading to AArch64 targets, then D32035 changed the frontend to throw an error when offloading is requested for an unsupported target architecture. However the latter did not include AArch64 in the list of supported architectures, causing the following unit tests to fail: libomptarget :: api/omp_get_num_devices.c libomptarget :: mapping/pr38704.c libomptarget :: offloading/offloading_success.c libomptarget :: offloading/offloading_success.cpp Reviewers: pawosm01, gtbercea, jdoerfert, ABataev Subscribers: kristof.beyls, guansong, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70804
2019-12-05 Reapply af57dbf12e54 "Add support for options -frounding-math, ↵Melanie Blower1-0/+28
ftrapping-math, -ffp-model=, and -ffp-exception-behavior=" Patch was reverted because https://bugs.llvm.org/show_bug.cgi?id=44048 The original patch is modified to set the strictfp IR attribute explicitly in CodeGen instead of as a side effect of IRBuilder. In the 2nd attempt to reapply there was a windows lit test fail, the tests were fixed to use wildcard matching. Differential Revision: https://reviews.llvm.org/D62731
2019-12-04Revert " Reapply af57dbf12e54 "Add support for options ↵Melanie Blower1-28/+0
-frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior="" This reverts commit cdbed2dd856c14687efd741c2d8321686102acb8. Build break on Windows (lit fail)
2019-12-04 Reapply af57dbf12e54 "Add support for options -frounding-math, ↵Melanie Blower1-0/+28
ftrapping-math, -ffp-model=, and -ffp-exception-behavior=" Patch was reverted because https://bugs.llvm.org/show_bug.cgi?id=44048 The original patch is modified to set the strictfp IR attribute explicitly in CodeGen instead of as a side effect of IRBuilder Differential Revision: https://reviews.llvm.org/D62731
2019-11-27[ConstExprPreter] Removed the flag forcing the use of the interpreterNandor Licker1-2/+0
Summary: Removed the ```-fforce-experimental-new-constant-interpreter flag```, leaving only the ```-fexperimental-new-constant-interpreter``` one. The interpreter now always emits an error on an unsupported feature. Allowing the interpreter to bail out would require a mapping from APValue to interpreter memory, which will not be necessary in the final version. It is more sensible to always emit an error if the interpreter fails. Reviewers: jfb, Bigcheese, rsmith, dexonsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70071
2019-11-26Initial implementation of -fmacro-prefix-map and -ffile-prefix-mapDan McGregor1-0/+3
GCC 8 implements -fmacro-prefix-map. Like -fdebug-prefix-map, it replaces a string prefix for the __FILE__ macro. -ffile-prefix-map is the union of -fdebug-prefix-map and -fmacro-prefix-map Reviewed By: rnk, Lekensteyn, maskray Differential Revision: https://reviews.llvm.org/D49466
2019-11-22Move vtordisp mode from Attr class to LangOptions.h, NFCReid Kleckner1-1/+2
This removes one of the two uses of Attr.h in DeclCXX.h, reducing the need to include Attr.h as widely. LangOptions is already very popular.
2019-11-19clang: Add -fconvergent-functions flagMatt Arsenault1-0/+3
The CUDA builtin library is apparently compiled in C++ mode, so the assumption of convergent needs to be made in a typically non-SPMD language. The functions in the library should still be assumed convergent. Currently they are not, which is potentially incorrect and this happens to work after the library is linked.
2019-11-19Work on cleaning up denormal mode handlingMatt Arsenault1-7/+2
Cleanup handling of the denormal-fp-math attribute. Consolidate places checking the allowed names in one place. This is in preparation for introducing FP type specific variants of the denormal-fp-mode attribute. AMDGPU will switch to using this in place of the current hacky use of subtarget features for the denormal mode. Introduce a new header for dealing with FP modes. The constrained intrinsic classes define related enums that should also be moved into this header for uses in other contexts. The verifier could use a check to make sure the denorm-fp-mode attribute is sane, but there currently isn't one. Currently, DAGCombiner incorrectly asssumes non-IEEE behavior by default in the one current user. Clang must be taught to start emitting this attribute by default to avoid regressions when this is switched to assume ieee behavior if the attribute isn't present.
2019-11-18Temporarily Revert "Add support for options -frounding-math, ftrapping-math, ↵Eric Christopher1-30/+0
-ffp-model=, and -ffp-exception-behavior=" and a follow-up NFC rearrangement as it's causing a crash on valid. Testcase is on the original review thread. This reverts commits af57dbf12e54f3a8ff48534bf1078f4de104c1cd and e6584b2b7b2de06f1e59aac41971760cac1e1b79
2019-11-08Revert "Reland "[clang] Report sanitizer blacklist as a dependency in cc1""Jan Korous1-1/+20
This reverts commit cae4a28864f4e8a55920e2b94e2cd43617902dec.
2019-11-08[clang] Fix -fsanitize-system-blacklist processing in cc1Jan Korous1-0/+5
2019-11-08Reland "[clang] Report sanitizer blacklist as a dependency in cc1"Jan Korous1-20/+1
This reverts commit 3182027282c59c51d5080d83365917fccd695854.
2019-11-08Reland "[clang] Report sanitizer blacklist as a dependency in cc1"Jan Korous1-1/+20
This reverts commit 9b8413ac6e56e7a6e0ba884773d13bcf9414bd43.
2019-11-08Revert "Revert "Revert "[clang] Report sanitizer blacklist as a dependency ↵Abel Kocsis1-20/+1
in cc1""" This reverts commit 3182027282c59c51d5080d83365917fccd695854.
2019-11-08Revert "Revert "[clang] Report sanitizer blacklist as a dependency in cc1""Abel Kocsis1-1/+20
This reverts commit 6b45e1bc11e91ea7b57a6ab1c19461a86dba33f8.
2019-11-08Revert "[clang] Report sanitizer blacklist as a dependency in cc1"Jeremy Morse1-20/+1
This reverts commit 03b84e4f6d0e1c04f22d69cc445f36e1f713beb4. This breaks dfsan tests with a linking failure, in for example this build: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24312 Reverting this patch locally makes those tests succeed.
2019-11-07[clang] Report sanitizer blacklist as a dependency in cc1Jan Korous1-1/+20
Previously these were reported from the driver which blocked clang-scan-deps from getting the full set of dependencies from cc1 commands. Also the default sanitizer blacklist that is added in driver was never reported as a dependency. I introduced -fsanitize-system-blacklist cc1 option to keep track of which blacklists were user-specified and which were added by driver and clang -MD now also reports system blacklists as dependencies. Differential Revision: https://reviews.llvm.org/D69290
2019-11-07Add support for options -frounding-math, ftrapping-math, -ffp-model=, and ↵Melanie Blower1-0/+30
-ffp-exception-behavior= Add options to control floating point behavior: trapping and exception behavior, rounding, and control of optimizations that affect floating point calculations. More details in UsersManual.rst. Reviewers: rjmccall Differential Revision: https://reviews.llvm.org/D62731
2019-11-05[Clang FE] Recognize -mnop-mcount CL option (SystemZ only).Jonas Paulsson1-0/+1
Recognize -mnop-mcount from the command line and add a function attribute "mnop-mcount"="true" when passed. When this option is used, a nop is added instead of a call to fentry. This is used when building the Linux Kernel. If this option is passed for any other target than SystemZ, an error is generated. Review: Ulrich Weigand https://reviews.llvm.org/D67763
2019-11-04Recommit "[CodeView] Add option to disable inline line tables."Amy Huang1-0/+1
This reverts commit 004ed2b0d1b86d424643ffc88fce20ad8bab6804. Original commit hash 6d03890384517919a3ba7fe4c35535425f278f89 Summary: This adds a clang option to disable inline line tables. When it is used, the inliner uses the call site as the location of the inlined function instead of marking it as an inline location with the function location. https://reviews.llvm.org/D67723
2019-10-31[cfi] Add flag to always generate .debug_frameDavid Candler1-0/+3
This adds a flag to LLVM and clang to always generate a .debug_frame section, even if other debug information is not being generated. In situations where .eh_frame would normally be emitted, both .debug_frame and .eh_frame will be used. Differential Revision: https://reviews.llvm.org/D67216