summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* Refactor call emission to package the function pointer together withJohn McCall2016-10-2623-327/+620
| | | | | | | | | | | abstract information about the callee. NFC. The goal here is to make it easier to recognize indirect calls and trigger additional logic in certain cases. That logic will come in a later patch; in the meantime, I felt that this was a significant improvement to the code. llvm-svn: 285258
* [CodeGen] Don't emit lifetime intrinsics for some local variablesVitaly Buka2016-10-266-6/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Current generation of lifetime intrinsics does not handle cases like: ``` { char x; l1: bar(&x, 1); } goto l1; ``` We will get code like this: ``` %x = alloca i8, align 1 call void @llvm.lifetime.start(i64 1, i8* nonnull %x) br label %l1 l1: %call = call i32 @bar(i8* nonnull %x, i32 1) call void @llvm.lifetime.end(i64 1, i8* nonnull %x) br label %l1 ``` So the second time bar was called for x which is marked as dead. Lifetime markers here are misleading so it's better to remove them at all. This type of bypasses are rare, e.g. code detects just 8 functions building clang (2329 targets). PR28267 Reviewers: eugenis Subscribers: beanz, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D24693 llvm-svn: 285176
* [CodeGen] Move shouldEmitLifetimeMarkers into more convenient placeVitaly Buka2016-10-263-28/+31
| | | | | | | | | | | | Summary: D24693 will need access to it from other places Reviewers: eugenis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24695 llvm-svn: 285158
* [codeview] emit debug info for indirect virtual base classesBob Haarman2016-10-252-9/+40
| | | | | | | | | | | | | | | Summary: Fixes PR28281. MSVC lists indirect virtual base classes in the field list of a class. This change makes Clang emit the information necessary for LLVM to emit such records. Reviewers: rnk, ruiu, zturner Differential Revision: https://reviews.llvm.org/D25579 llvm-svn: 285132
* CodeGen: be more conservative about setting sectionSaleem Abdulrasool2016-10-251-29/+44
| | | | | | | The section names currently are MachO specific. Only set the section on the variables if the file format is MachO. llvm-svn: 285126
* CodeGen: mark protocols as common dataSaleem Abdulrasool2016-10-251-12/+30
| | | | | | | | This allows for the coalescing of the protocol declarations. When the protocols are declared in headers, multiple definitions of the protocol would be emitted. Marking them as common data indicates that any one can be selected. llvm-svn: 285073
* Re-apply patch r279045.Kelvin Li2016-10-253-0/+19
| | | | llvm-svn: 285066
* Add dependency from clangCodeGen to clangAnalysisMehdi Amini2016-10-241-0/+1
| | | | | | This is unbreaking the build with shared library after r285019. llvm-svn: 285042
* Link clangCodeGen with clangAnalysis required after r284990.Artem Belevich2016-10-241-0/+1
| | | | | | Fixes build break for configurations that use shared libraries. llvm-svn: 285037
* CodeGen: remove incorrect temporary TwineSaleem Abdulrasool2016-10-241-2/+2
| | | | | | Twines should not be stack allocated. This somehow managed to get past me. llvm-svn: 285028
* CodeGen: centralise label construction for method listsSaleem Abdulrasool2016-10-241-59/+107
| | | | | | | | | | | Move all the label construction for the various method list emission into EmitMethodList. Rather than have all the names be constructed in pieces in all of the callers of EmitMethodList, have this occur in one site. This also makes the calls much easier to understand as we simplify identify the type of the method list being emitted and the interface name for which it is being emitted. NFC. llvm-svn: 285023
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-1/+84
| | | | | | | | | | | | | | | | | This reverts commit r285007 and reapply r284990, with a fix for the opencl test that I broke. Original commit message follows: These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 285019
* Revert "Add support for __builtin_os_log_format[_buffer_size]"Mehdi Amini2016-10-241-84/+1
| | | | | | This reverts commit r284990, two opencl test are broken llvm-svn: 285007
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-1/+84
| | | | | | | | | | | | | | These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 284990
* [AVX-512] Replace 64-bit element and 512-bit vector pmin/pmax builtins with ↵Craig Topper2016-10-241-17/+44
| | | | | | native IR like we do for 128/256-bit, but with the addition of masking. llvm-svn: 284956
* [AVX-512] Remove masked 128/256-bit palignr builtins. We can just use a ↵Craig Topper2016-10-221-2/+0
| | | | | | select in the header file with the older unmasked versions instead. llvm-svn: 284920
* Switch SmallSetVector to use DenseSet when it overflows its inline space.Justin Lebar2016-10-211-3/+4
| | | | | | | | | | | | | | | | | | | | Summary: SetVector already used DenseSet, but SmallSetVector used std::set. This leads to surprising performance differences. Moreover, it means that the set of key types accepted by SetVector and SmallSetVector are quite different! In order to make this change, we had to convert some callsites that used SmallSetVector<std::string, N> to use SmallSetVector<CachedHashString, N> instead. Reviewers: timshen Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25648 llvm-svn: 284887
* [CodeGen] Devirtualize calls to methods marked final in a derived classVedant Kumar2016-10-201-7/+15
| | | | | | | | | | If we see a virtual method call to Base::foo() but can infer that the object is an instance of Derived, and that 'foo' is marked 'final' in Derived, we can devirtualize the call to Derived::foo(). Differential Revision: https://reviews.llvm.org/D25813 llvm-svn: 284766
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-204-7/+6
| | | | | | No functionality change intended. llvm-svn: 284730
* DebugInfo: pass alignment value only if it was forcedVictor Leschuk2016-10-202-51/+85
| | | | | | | | | | Preparation to implement DW_AT_alignment support: - We pass non-zero align value to DIBuilder only when alignment was forced - Modify tests to match this change Differential Revision: https://reviews.llvm.org/D24426 llvm-svn: 284679
* Don't crash generating debug info for VLA in function prototype.Eli Friedman2016-10-191-3/+5
| | | | | | | | Fixes regression from r279445. Differential Revision: https://reviews.llvm.org/D25793 llvm-svn: 284652
* DebugInfo: use uint32_t for alignment variables.Victor Leschuk2016-10-191-17/+17
| | | | | | | | | LLVM now uses uint32_t for DebugInfo alignment for space efficiency, in this patch we change frontend DebugInfo-related variables to uint32_t too. Differential Revision: https://reviews.llvm.org/D25621 llvm-svn: 284651
* New clang option -mpie-copy-relocations to use copy relocations for PIE builds.Sriraman Tallam2016-10-191-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D19996 llvm-svn: 284638
* [ubsan] Use the object pointer's type info for devirtualized callsVedant Kumar2016-10-191-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ubsan reports a false positive 'invalid member call' diagnostic on the following example (PR30478): struct Base1 { virtual int f1() { return 1; } }; struct Base2 { virtual int f1() { return 2; } }; struct Derived2 final : Base1, Base2 { int f1() override { return 3; } }; int t1() { Derived2 d; return static_cast<Base2 *>(&d)->f1(); } Adding the "final" attribute to a most-derived class allows clang to devirtualize member calls into an instance of that class. We should pass along the type info of the object pointer to avoid the FP. In this case, that means passing along the type info for 'Derived2' instead of 'Base2' when checking the dynamic type of static_cast<Base2 *>(&d2). Differential Revision: https://reviews.llvm.org/D25448 llvm-svn: 284636
* MS ABI: Fix assert when generating virtual function call with virtual bases ↵Hans Wennborg2016-10-191-9/+2
| | | | | | | | | | | | and -flto (PR30731) getClassAtVTableLocation() was calling ASTRecordLayout::getBaseClassOffset() on a virtual base, causing an assert. Differential Revision: https://reviews.llvm.org/D25779 llvm-svn: 284624
* [CodeGen][ObjC] Do not call objc_storeStrong when initializing aAkira Hatanaka2016-10-185-36/+13
| | | | | | | | | | | | | | | | | | constexpr variable. When compiling a constexpr NSString initialized with an objective-c string literal, CodeGen emits objc_storeStrong on an uninitialized alloca, which causes a crash. This patch folds the code in EmitScalarInit into EmitStoreThroughLValue and fixes the crash by calling objc_retain on the string instead of using objc_storeStrong. rdar://problem/28562009 Differential Revision: https://reviews.llvm.org/D25547 llvm-svn: 284516
* [Coverage] Support for C++17 if initializersVedant Kumar2016-10-142-0/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D25572 llvm-svn: 284293
* [Coverage] Support for C++17 switch initializersVedant Kumar2016-10-142-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D25539 llvm-svn: 284292
* Implement no_sanitize_address for global varsDouglas Katzman2016-10-141-1/+7
| | | | llvm-svn: 284272
* Module: emit initializers in submodules when importing the parent module.Manman Ren2016-10-142-3/+31
| | | | | | | | | When importing the parent module, module initializers in submodules should be emitted. rdar://28740482 llvm-svn: 284263
* Implement __stosb intrinsic as a volatile memsetAlbert Gutowski2016-10-141-0/+5
| | | | | | | | | | | | Summary: We need `__stosb` to be an intrinsic, because SecureZeroMemory function uses it without including intrin.h. Implementing it as a volatile memset is not consistent with MSDN specification, but it gives us target-independent IR while keeping the most important properties of `__stosb`. Reviewers: rnk, hans, thakis, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25334 llvm-svn: 284253
* Add 64-bit MS _Interlocked functions as builtins againAlbert Gutowski2016-10-131-86/+151
| | | | | | | | | | | | Summary: Previously global 64-bit versions of _Interlocked functions broke buildbots on i386, so now I'm adding them as builtins for x86-64 and ARM only (should they be also on AArch64? I had problems with testing it for AArch64, so I left it) Reviewers: hans, majnemer, mstorsjo, rnk Subscribers: cfe-commits, aemerson Differential Revision: https://reviews.llvm.org/D25576 llvm-svn: 284172
* [CUDA] Emit deferred diagnostics during Sema rather than during codegen.Justin Lebar2016-10-132-48/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Emitting deferred diagnostics during codegen was a hack. It did work, but usability was poor, both for us as compiler devs and for users. We don't codegen if there are any sema errors, so for users this meant that they wouldn't see deferred errors if there were any non-deferred errors. For devs, this meant that we had to carefully split up our tests so that when we tested deferred errors, we didn't emit any non-deferred errors. This change moves checking for deferred errors into Sema. See the big comment in SemaCUDA.cpp for an overview of the idea. This checking adds overhead to compilation, because we have to maintain a partial call graph. As a result, this change makes deferred errors a CUDA-only concept (whereas before they were a general concept). If anyone else wants to use this framework for something other than CUDA, we can generalize at that time. This patch makes the minimal set of test changes -- after this lands, I'll go back through and do a cleanup of the tests that we no longer have to split up. Reviewers: rnk Subscribers: cfe-commits, rsmith, tra Differential Revision: https://reviews.llvm.org/D25541 llvm-svn: 284158
* CodeGen: ensure that the runtime calling convention matchesSaleem Abdulrasool2016-10-131-12/+8
| | | | | | | | Incorrect specification of the calling convention results in UB which can cause the code path to be eliminated. Simplify the existing code by using the RuntimeCall constructor in `CodeGenFunction`. llvm-svn: 284154
* Swift Calling Convention: Fix out of bounds accessArnold Schwaighofer2016-10-131-1/+1
| | | | | | | | | | Use iterator instead of address of element in vector It is not valid to access one after the last element. rdar://28759508 llvm-svn: 284150
* Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsicsAlbert Gutowski2016-10-131-0/+8
| | | | | | | | | | Reviewers: rnk, thakis, majnemer, hans Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25540 llvm-svn: 284131
* Fix for PR30639: CGDebugInfo Null dereference with OpenMP arrayAlexey Bataev2016-10-131-4/+17
| | | | | | | | | | | | | access, by Erich Keane OpenMP creates a variable array type with a a null size-expr. The Debug generation failed to due to this. This patch corrects the openmp implementation, updates the tests, and adds a new one for this condition. Differential Revision: https://reviews.llvm.org/D25373 llvm-svn: 284110
* Implement MS _BitScan intrinsicsAlbert Gutowski2016-10-122-0/+80
| | | | | | | | | | | | Summary: _BitScan intrinsics (and some others, for example _Interlocked and _bittest) are supposed to work on both ARM and x86. This is an attempt to isolate them, avoiding repeating their code or writing separate function for each builtin. Reviewers: hans, thakis, rnk, majnemer Subscribers: RKSimon, cfe-commits, aemerson Differential Revision: https://reviews.llvm.org/D25264 llvm-svn: 284060
* Declare WinX86_64ABIInfo to satisfy SwiftABI infoArnold Schwaighofer2016-10-121-2/+8
| | | | | | | | | This is minimal support that allows swift's test cases on non windows platforms to pass. rdar://28738985 llvm-svn: 284032
* Pass the end of a component to SwiftAggLowering's enumerateComponents callbackArnold Schwaighofer2016-10-111-1/+1
| | | | | | This is usefull for determining whether components overlap. llvm-svn: 283932
* Revert "Change Builtins name to be stored as StringRef instead of raw ↵Mehdi Amini2016-10-111-2/+2
| | | | | | | | | | | | | | pointers (NFC)" This reverts commit r283802. It introduces temporarily static initializers, because StringRef ctor isn't (yet) constexpr for string literals. I plan to get there this week, but apparently GCC is so terrible with these static initializer right now (10 min+ extra codegen time was reported) that I'll hold on to this patch till the constexpr one is ready, and land these at the same time. llvm-svn: 283920
* Add an option to save the backend-produced YAML optimization record to a fileHal Finkel2016-10-111-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | The backend now has the capability to save information from optimizations, the same information that can be used to generate optimization diagnostics but in machine-consumable form, into an output file. This can be enabled when using opt (see r282539), and this change enables it when using clang. The idea is that other tools will be able to consume these files, and perhaps in combination with the original source code, produce various kinds of optimization reports for users (and for compiler developers). We now have at-least two tools that can consume these files: * tools/llvm-opt-report * utils/opt-viewer Using the flag -fsave-optimization-record will cause the YAML file to be generated; the file name will be based on the output file name (if we're using -c or -S and have an output name), or the input file name. When we're using CUDA, or some other offloading mechanism, separate files are generated for each backend target. The output file name can be specified by the user using -foptimization-record-file=filename. Differential Revision: https://reviews.llvm.org/D25225 llvm-svn: 283834
* Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)Mehdi Amini2016-10-101-1/+1
| | | | llvm-svn: 283815
* Change Builtins name to be stored as StringRef instead of raw pointers (NFC)Mehdi Amini2016-10-101-2/+2
| | | | llvm-svn: 283802
* Make the LValue created in EmitValueForIvarAtOffset have the same Qualifiers ↵Nick Lewycky2016-10-101-5/+2
| | | | | | in the LValue as the QualType in the LValue. No functionality change intended. llvm-svn: 283795
* Implement MS read/write barriers and __faststorefence intrinsicAlbert Gutowski2016-10-101-0/+11
| | | | | | | | | | Reviewers: hans, rnk, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25442 llvm-svn: 283793
* Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use ofRichard Smith2016-10-102-169/+221
| | | | | | | | | | | past-the-end iterator. Original commit message: P0035R4: Semantic analysis and code generation for C++17 overaligned allocation. llvm-svn: 283789
* Implement __emul, __emulu, _mul128 and _umul128 MS intrinsicsAlbert Gutowski2016-10-101-8/+21
| | | | | | | | | | Reviewers: rnk, thakis, majnemer, hans Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25353 llvm-svn: 283785
* Use unique_ptr for VPtrLocationsMap and VPtrInfoVector.Justin Lebar2016-10-101-29/+29
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25422 llvm-svn: 283770
* Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned ↵Daniel Jasper2016-10-102-221/+169
| | | | | | | | | | | | allocation." This reverts commit r283722. Breaks: Clang.SemaCUDA.device-var-init.cu Clang.CodeGenCUDA.device-var-init.cu http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/884/ llvm-svn: 283750
OpenPOWER on IntegriCloud