summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [CodeGen][ObjC] Block captures should inherit the type of the capturedAkira Hatanaka2016-09-162-11/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | field in the enclosing lambda or block. This patch fixes a bug in code-gen where it uses the type of the declared variable rather than the type of the capture of the enclosing lambda or block for the block capture. For example, in the following function, code-gen currently uses i32* for the block capture "a" because "a" is passed to foo1 as a reference, but it should use i32 since the enclosing lambda captures "a" by value. void foo1(int &a) { auto lambda = [a]{ auto block1 = ^{ i = a; }; block1(); }; lambda(); } rdar://problem/18586386 Differential Revision: https://reviews.llvm.org/D21104 llvm-svn: 281682
* Add some MS aliases for existing intrinsicsAlbert Gutowski2016-09-141-0/+24
| | | | | | | | | | Reviewers: thakis, compnerd, majnemer, rsmith, rnk Subscribers: alexshap, cfe-commits Differential Revision: https://reviews.llvm.org/D24330 llvm-svn: 281540
* Convert finite to builtinDehao Chen2016-09-141-0/+6
| | | | | | | | | | | | Summary: This patch converts finite/__finite to builtin functions so that it will be inlined by compiler. Reviewers: hfinkel, davidxl, efriedma Subscribers: efriedma, llvm-commits Differential Revision: https://reviews.llvm.org/D24483 llvm-svn: 281509
* CodeGen: simplify the logic a slight bitSaleem Abdulrasool2016-09-143-14/+8
| | | | | | | | | Move the definition of `getTriple()` into the header. It would just call `getTarget().getTriple()`. Inline the definition to allow the compiler to see the same amount of the layout as previously. Remove the more verbose `getTarget().getTriple()` in favour of `getTriple()`. llvm-svn: 281487
* [sanitizer-coverage] add yet another flavour of coverage instrumentation: ↵Kostya Serebryany2016-09-141-0/+1
| | | | | | trace-pc-guard. The intent is to eventually replace all of {bool coverage, 8bit-counters, trace-pc} with just this one. Clang part llvm-svn: 281432
* Also don't inline dllimport functions referring to non-dllimport constructors.Hans Wennborg2016-09-131-0/+6
| | | | | | | | The AST walker wasn't visiting CXXConstructExprs before. This is a follow-up to r281395. llvm-svn: 281413
* [CodeGen] Fix an assert in EmitNullConstant.Akira Hatanaka2016-09-131-1/+2
| | | | | | | | | | | | | | | r235815 changed CGRecordLowering::accumulateBases to ignore non-virtual bases of size 0, which prevented adding those non-virtual bases to CGRecordLayout's NonVirtualBases. This caused clang to assert when CGRecordLayout::getNonVirtualBaseLLVMFieldNo was called in EmitNullConstant. This commit fixes the bug by ignoring zero-sized non-virtual bases in EmitNullConstant. rdar://problem/28100139 Differential Revision: https://reviews.llvm.org/D24312 llvm-svn: 281405
* Temporary fix for MS _Interlocked intrinsicsAlbert Gutowski2016-09-131-10/+2
| | | | llvm-svn: 281401
* Reverse commit 281375 (breaks building Chromium)Albert Gutowski2016-09-131-24/+0
| | | | llvm-svn: 281399
* Try harder to not inline dllimport functions referencing non-dllimport functionsHans Wennborg2016-09-131-2/+23
| | | | | | | | In r246338, code was added to check for this, but it failed to take into account implicit destructor invocations because those are not reflected in the AST. This adds a separate check for them. llvm-svn: 281395
* Add bunch of _Interlocked builtinsAlbert Gutowski2016-09-131-14/+38
| | | | | | | | | | Reviewers: compnerd, thakis, Prazek, majnemer, rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24153 llvm-svn: 281378
* Add some MS aliases for existing intrinsicsAlbert Gutowski2016-09-131-0/+24
| | | | | | | | | | Reviewers: thakis, compnerd, majnemer, rsmith, rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24330 llvm-svn: 281375
* ObjectiveC generics: Add ObjCTypeParamType in the type system.Manman Ren2016-09-133-0/+17
| | | | | | | | | | | | | | | | | We also need to add ObjCTypeParamTypeLoc. ObjCTypeParamType supports the representation of "T <protocol>" where T is a type parameter. Before this, we use TypedefType to represent the type parameter for ObjC. ObjCTypeParamType has "ObjCTypeParamDecl *OTPDecl" and it extends from ObjCProtocolQualifiers. It is a non-canonical type and is canonicalized to the underlying type with the protocol qualifiers. rdar://24619481 rdar://25060179 Differential Revision: http://reviews.llvm.org/D23079 llvm-svn: 281355
* Reapply r281276 with passing -emit-llvm in one of the testsAdam Nemet2016-09-131-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original commit message: Add -fdiagnostics-show-hotness Summary: I've recently added the ability for optimization remarks to include the hotness of the corresponding code region. This uses PGO and allows filtering of the optimization remarks by relevance. The idea was first discussed here: http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334 The general goal is to produce a YAML file with the remarks. Then, an external tool could dynamically filter these by hotness and perhaps by other things. That said it makes sense to also expose this at the more basic level where we just include the hotness info with each optimization remark. For example, in D22694, the clang flag was pretty useful to measure the overhead of the additional analyses required to include hotness. (Without the flag we don't even run the analyses.) For the record, Hal has already expressed support for the idea of this patch on IRC. Differential Revision: https://reviews.llvm.org/D23284 llvm-svn: 281293
* Update Clang for D20147 ("DebugInfo: New metadata representation for global ↵Peter Collingbourne2016-09-135-13/+17
| | | | | | | | variables.") Differential Revision: http://reviews.llvm.org/D20415 llvm-svn: 281285
* Revert "Add -fdiagnostics-show-hotness"Adam Nemet2016-09-131-9/+1
| | | | | | | | This reverts commit r281276. Many bots are failing. llvm-svn: 281279
* [DebugInfo] Deduplicate debug info limiting logicReid Kleckner2016-09-131-21/+10
| | | | | | | | | | | | | We should be doing the same checks when a type is completed as we do when a complete type is used during emission. Previously, we duplicated the logic, and it got out of sync. This could be observed with dllimported classes. Also reduce a test case for this slightly. Implementing review feedback from David Blaikie on r281057. llvm-svn: 281278
* Add -fdiagnostics-show-hotnessAdam Nemet2016-09-121-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I've recently added the ability for optimization remarks to include the hotness of the corresponding code region. This uses PGO and allows filtering of the optimization remarks by relevance. The idea was first discussed here: http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334 The general goal is to produce a YAML file with the remarks. Then, an external tool could dynamically filter these by hotness and perhaps by other things. That said it makes sense to also expose this at the more basic level where we just include the hotness info with each optimization remark. For example, in D22694, the clang flag was pretty useful to measure the overhead of the additional analyses required to include hotness. (Without the flag we don't even run the analyses.) For the record, Hal has already expressed support for the idea of this patch on IRC. Differential Revision: https://reviews.llvm.org/D23284 llvm-svn: 281276
* CodeGen: use some range-based for loopsSaleem Abdulrasool2016-09-121-14/+10
| | | | | | | Use range-based for loops to simplify the logic. Add an explicit check for MachO as the inline asm uses MachO specific directives. llvm-svn: 281261
* [MS ABI] Add /include directives for dynamic TLSDavid Majnemer2016-09-121-0/+8
| | | | | | | | | MSVC emits /include directives in the .drective section for the __dyn_tls_init function (decorated as ___dyn_tls_init@12 for 32-bit). This fixes PR30347. llvm-svn: 281189
* CodeGen: remove unnecessary else caseSaleem Abdulrasool2016-09-111-6/+3
| | | | | | | Refactor the assignment so that its much more clear that the if-clause contains the lookup, and once cached is directly used. NFC. llvm-svn: 281150
* [DebugInfo] Ensure complete type is emitted with -fstandalone-debugReid Kleckner2016-09-091-3/+7
| | | | | | | | | | | The logic for upgrading a class from a forward decl to a complete type was not checking the debug info emission level before applying the vtable optimization. This meant we ended up without debug info for a class which was required to be complete. I noticed it because it triggered an assertion during CodeView emission, but that's a separate issue. llvm-svn: 281057
* [codeview] Extend the heuristic for detecting classes imported from DLLsReid Kleckner2016-09-091-3/+15
| | | | | | | | | | | | | | If a dynamic class contains a dllimport method, then assume the class may not be constructed in this DLL, and therefore the vtable will live in a different PDB. This heuristic is still incomplete, and will miss things like abstract base classes that are only constructed on one side of the DLL interface. That said, this heuristic does detect some cases that are currently problematic, and may be useful to other projects that don't use many DLLs. llvm-svn: 281053
* Update clang for D21514. NFCAmaury Sechet2016-09-091-4/+5
| | | | | | | | | | | | Summary: As per title. Reviewers: ahatanak, bkramer, whitequark, mehdi_amini, void Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21515 llvm-svn: 281018
* C++ Modules TS: Add parsing and some semantic analysis support forRichard Smith2016-09-083-16/+18
| | | | | | | export-declarations. These don't yet have an effect on name visibility; we still export everything by default. llvm-svn: 280999
* Implement MS _rot intrinsicsAlbert Gutowski2016-09-081-0/+52
| | | | | | | | | | Reviewers: thakis, Prazek, compnerd, rnk Subscribers: majnemer, cfe-commits Differential Revision: https://reviews.llvm.org/D24311 llvm-svn: 280997
* Moved unreachable to appease msvc, gcc and clangSimon Pilgrim2016-09-081-3/+2
| | | | llvm-svn: 280921
* Fixed a 'not all control paths return a value' warning on MSVC buildsSimon Pilgrim2016-09-081-19/+22
| | | | llvm-svn: 280917
* CodeGen: Clean up implementation of vtable initializer builder. NFC.Peter Collingbourne2016-09-085-139/+121
| | | | | | | | | | | | | - Simplify signature of CreateVTableInitializer function. - Move vtable component builder to a separate function. - Remove unnecessary accessors from VTableLayout class. This is in preparation for a future change that will alter the type of the vtable initializer. Differential Revision: https://reviews.llvm.org/D22642 llvm-svn: 280897
* [MS] Fix prologue this adjustment when 'this' is passed indirectlyReid Kleckner2016-09-072-7/+19
| | | | | | | | | | | | Move the logic for doing this from the ABI argument lowering into EmitParmDecl, which runs for all parameters. Our codegen is slightly suboptimal in this case, as we may leave behind a dead store after optimization, but it's 32-bit inalloca, and this fixes the bug in a robust way. Fixes PR30293 llvm-svn: 280836
* [MS] Fix 'this' type when calling virtual methods with inallocaReid Kleckner2016-09-071-5/+9
| | | | | | | | | | | | | | If the virtual method comes from a secondary vtable, then the type of the 'this' parameter should be i8*, and not a pointer to the complete class. In the MS ABI, the 'this' parameter on entry points to the vptr containing the virtual method that was called, so we use i8* instead of the normal type. We had a mismatch where the CGFunctionInfo of the call didn't match the CGFunctionInfo of the declaration, and this resulted in some assertions, but now both sides agree the type of 'this' is i8*. Fixes one issue raised in PR30293 llvm-svn: 280815
* Fix whitespace issuesMatt Arsenault2016-09-071-2/+1
| | | | | | ^M and extra space llvm-svn: 280786
* Formatting with clang-format patch r280701Leny Kholodov2016-09-061-23/+24
| | | | llvm-svn: 280718
* DebugInfo: use llvm::DINode::DIFlags type for debug info flagsLeny Kholodov2016-09-062-34/+40
| | | | | | | | | | Use llvm::DINode::DIFlags type (strongly typed enum) for debug flags instead of unsigned int to avoid problems on platforms with sizeof(int) < 4: we already have flags with values > (1 << 16). Patch by: Victor Leschuk <vleschuk@gmail.com> Differential Revision: https://reviews.llvm.org/D23767 llvm-svn: 280701
* [OpenCL] Remove access qualifiers on images in arg info metadata.Alexey Bader2016-09-061-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Remove access qualifiers on images in arg info metadata: * kernel_arg_type * kernel_arg_base_type Image access qualifiers are inseparable from type in clang implementation, but OpenCL spec provides a special query to get access qualifier via clGetKernelArgInfo with CL_KERNEL_ARG_ACCESS_QUALIFIER. Besides that OpenCL conformance test_api get_kernel_arg_info expects image types without access qualifier. Patch by Evgeniy Tyurin. Reviewers: bader, yaxunl, Anastasia Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23915 llvm-svn: 280699
* [Frontend] Fix mcount inlining bugHonggyu Kim2016-09-011-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Since some profiling tools, such as gprof, ftrace, and uftrace, use -pg option to generate a mcount function call at the entry of each function. Function invocation can be detected by this hook function. But mcount insertion is done before function inlining phase in clang, sometime a function that already has a mcount call can be inlined in the middle of another function. This patch adds an attribute "counting-function" to each function rather than emitting the mcount call directly in frontend so that this attribute can be processed in backend. Then the mcount calls can be properly inserted in backend after all the other optimizations are completed. Link: https://llvm.org/bugs/show_bug.cgi?id=28660 Reviewers: hans, rjmccall, hfinkel, rengolin, compnerd Subscribers: shenhan, cfe-commits Differential Revision: https://reviews.llvm.org/D22666 llvm-svn: 280355
* Remove whitespace to test commit accessHonggyu Kim2016-09-011-1/+1
| | | | llvm-svn: 280337
* Add -fprofile-dir= to clang.Nick Lewycky2016-08-311-12/+18
| | | | | | | | | | | | | | | | | | | | | -fprofile-dir=path allows the user to specify where .gcda files should be emitted when the program is run. In particular, this is the first flag that causes the .gcno and .o files to have different paths, LLVM is extended to support this. -fprofile-dir= does not change the file name in the .gcno (and thus where lcov looks for the source) but it does change the name in the .gcda (and thus where the runtime library writes the .gcda file). It's different from a GCOV_PREFIX because a user can observe that the GCOV_PREFIX_STRIP will strip paths off of -fprofile-dir= but not off of a supplied GCOV_PREFIX. To implement this we split -coverage-file into -coverage-data-file and -coverage-notes-file to specify the two different names. The !llvm.gcov metadata node grows from a 2-element form {string coverage-file, node dbg.cu} to 3-elements, {string coverage-notes-file, string coverage-data-file, node dbg.cu}. In the 3-element form, the file name is already "mangled" with .gcno/.gcda suffixes, while the 2-element form left that to the middle end pass. llvm-svn: 280306
* [codeview] Don't emit vshape info for classes without vfptrsReid Kleckner2016-08-311-1/+8
| | | | | | | | | | | | Classes with no virtual methods or whose virtual methods were all inherited from virtual bases don't have a vfptr at offset zero. We were crashing attempting to get the layout of that non-existent vftable. We don't need any vshape info in this case because the debugger can infer it from the base class information. The current class may not introduce any virtual methods if we are in this situation. llvm-svn: 280287
* [codeview] Pass through vftable shape informationReid Kleckner2016-08-312-11/+39
| | | | | | | | | | | | | | | The shape is really just the number of methods in the vftable, since we don't support 16 bit far calls. All calls are near. Encode this number in the size of the artificial __vtbl_ptr_type DIDerivedType that we generate. For DWARF, this will be a normal pointer, but for codeview this will be a wide pointer that gets pattern matched into a VFTableShape record. Insert this type into the element list of all dynamic classes when emitting CodeView, so that the backend can emit the shape even if the vptr lives in a primary base class. Fixes PR28150 llvm-svn: 280255
* [Coverage] Suppress creating a code region if the same area is covered by an ↵Igor Kudrin2016-08-311-5/+23
| | | | | | | | | | | | expansion region. In most cases these code regions are just redundant, but sometimes they could be assigned to the counter of the parent code region instead of the counter of the nested block. Differential Revision: https://reviews.llvm.org/D23987 llvm-svn: 280199
* This adds new options -fdenormal-fp-math and passes through option -ffast-mathSjoerd Meijer2016-08-301-0/+7
| | | | | | | | | | to CC1, which are translated to function attributes and can e.g. be mapped on build attributes FP_exceptions and FP_denormal. Setting these build attributes allows better selection of floating point libraries. Differential Revision: https://reviews.llvm.org/D23840 llvm-svn: 280064
* [PowerPC] Update the DWARF register-size tableHal Finkel2016-08-301-3/+9
| | | | | | | | | The PPC64 DWARF register-size table did not match the ABI specification (or GCC, for that matter). Fix that, and add a regression test. Fixes PR27931. llvm-svn: 280053
* [sanitizer-coverage] add two more modes of instrumentation: trace-div and ↵Kostya Serebryany2016-08-301-0/+2
| | | | | | trace-gep, mostly usaful for value-profile-based fuzzing; clang part llvm-svn: 280044
* [Coverage] Prevent creating a redundant counter if a nested body ends with a ↵Igor Kudrin2016-08-291-1/+2
| | | | | | | | | | | | | | | | | macro. If there were several nested statements arranged in a way that all of them end up with the same macro, then the expansion of this macro was assigned with all the corresponding counters of these statements. As a result, the wrong counter value was shown for the macro in llvm-cov. This patch fixes the issue by preventing adding a counter for an expanded source range if it already has an assigned counter, which is expected to come from the most specific statement. Differential Revision: https://reviews.llvm.org/D23160 llvm-svn: 279962
* Widen type of __offset_flags in RTTI on Mingw64Reid Kleckner2016-08-251-4/+14
| | | | | | | | | | | | Otherwise we can't handle secondary base classes at offsets greater than 2**24. This agrees with libstdc++abi. We could extend this change to other LLP64 platforms, but then we would want to update libc++abi and it would require additional review. Fixes PR29116 llvm-svn: 279786
* [MS] Win64 va_arg should expect large arguments to be passed indirectlyReid Kleckner2016-08-251-1/+11
| | | | | | Fixes PR20569 llvm-svn: 279774
* [MS] Pass non-trivially-copyable objects indirectly on Windows ARMReid Kleckner2016-08-251-0/+6
| | | | | | | | | | This isn't exactly what MSVC does, unfortunately. MSVC does not pass objects with destructors but no copy constructors by address. More ARM expertise is required to really understand what should be done here. Fixes PR29136. llvm-svn: 279764
* DebugInfo: Add flag to CU to disable emission of inline debug info into the ↵David Blaikie2016-08-241-1/+2
| | | | | | | | | | skeleton CU In cases where .dwo/.dwp files are guaranteed to be available, skipping the extra online (in the .o file) inline info can save a substantial amount of space - see the original r221306 for more details there. llvm-svn: 279651
* [Pragma] Clear loop distribution attribute between loopsAdam Nemet2016-08-241-0/+1
| | | | llvm-svn: 279608
OpenPOWER on IntegriCloud