summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* Parsing/Sema of directive omp for simdAlexander Musman2014-09-183-0/+8
| | | | llvm-svn: 218029
* Don't try to use C5/D5 comdats in COFF.Rafael Espindola2014-09-161-2/+6
| | | | | | This should fix the mingw bootstrap. llvm-svn: 217897
* Add support for putting constructors and destructos in explicit comdats.Rafael Espindola2014-09-165-45/+126
| | | | | | | | | | | | | | | | | | There are situations when clang knows that the C1 and C2 constructors or the D1 and D2 destructors are identical. We already optimize some of these cases, but cannot optimize it when the GlobalValue is weak_odr. The problem with weak_odr is that an old TU seeing the same code will have a C1 and a C2 comdat with the corresponding symbols. We cannot suddenly start putting the C2 symbol in the C1 comdat as we cannot guarantee that the linker will not pick a .o with only C1 in it. The solution implemented by GCC is to expand the ABI to have a comdat whose name uses a C5/D5 suffix and always has both symbols. That is what this patch implements. llvm-svn: 217874
* Reduce code duplication a bit more. NFC.Rafael Espindola2014-09-152-24/+2
| | | | llvm-svn: 217813
* Reduce code duplication a bit more. NFC.Rafael Espindola2014-09-154-24/+30
| | | | llvm-svn: 217811
* Simplify the code a bit, NFC.Rafael Espindola2014-09-152-21/+4
| | | | | | hasConstructorVariants is always true for MS and false for Itanium. llvm-svn: 217809
* Move emitCXXStructor to CGCXXABI.Rafael Espindola2014-09-156-83/+164
| | | | | | A followup patch will address the code duplication. llvm-svn: 217807
* Create a emitCXXStructor function and make the existing emitCXXConstructor andRafael Espindola2014-09-153-49/+58
| | | | | | | | emitCXXDestructor static helpers. A next patch will make it a helper in CGCXXABI. llvm-svn: 217804
* Add -fseh-exceptions for MinGW-w64Reid Kleckner2014-09-151-0/+10
| | | | | | | | | | | | | | This adds a flag called -fseh-exceptions that uses the native Windows .pdata and .xdata unwind mechanism to throw exceptions. The other EH possibilities are DWARF and SJLJ exceptions. Patch by Martell Malone! Reviewed By: asl, rnk Differential Revision: http://reviews.llvm.org/D3419 llvm-svn: 217790
* Allow protocols to be just declared.Rafael Espindola2014-09-121-3/+3
| | | | llvm-svn: 217704
* MS ABI: The latest VC "14" CTP implements deleted virtual functionsDavid Majnemer2014-09-121-2/+0
| | | | | | | | | | | | Deleted virtual functions get _purecall inserted into the vftable. Earlier CTPs would simply stick nullptr in there. N.B. MSVC can't handle deleted virtual functions which require return adjusting thunks, they give an error that a deleted function couldn't be called inside of a compiler generated function. We get this correct by making the thunk have a __purecall entry as well. llvm-svn: 217654
* MS ABI: Use the correct this arg when generating implict copy ctorDavid Majnemer2014-09-114-4/+26
| | | | | | | | | | We assumed that the incoming this argument would be the last argument. However, this is not true under the MS ABI. This fixes PR20897. llvm-svn: 217642
* Merge GetAddrOfCXXConstructor and GetAddrOfCXXDonstructor. NFC.Rafael Espindola2014-09-119-50/+21
| | | | llvm-svn: 217598
* Avoid some unnecessary SmallVector copies.Benjamin Kramer2014-09-111-1/+1
| | | | | | No functionality change. llvm-svn: 217586
* NULL->nullptrAlexander Musman2014-09-111-1/+1
| | | | llvm-svn: 217573
* Update for llvm api change.Rafael Espindola2014-09-101-3/+3
| | | | llvm-svn: 217547
* MS ABI: Emit dynamic initializers for selectany globals in ↵Hans Wennborg2014-09-101-0/+5
| | | | | | | | | | comdat-associative sections (PR20889) This prevents initializers for comdat-folded globals from running multiple times. Differential Revision: http://reviews.llvm.org/D5281 llvm-svn: 217534
* typoSanjay Patel2014-09-101-1/+1
| | | | llvm-svn: 217517
* CodeGen: Use a fixed alignment for vtables.Benjamin Kramer2014-09-101-0/+6
| | | | | | | | | | | | | | | Pointer-sized alignment is sufficient as we only ever read single values from the table. Otherwise we'd bump the alignment to 16 bytes in the backend if the vtable is larger than 16 bytes. This is great for structures that are accessed with vector instructions or copied around, but that's simply not the case for vtables. Shrinks the data segment of a Release x86_64 clang by 0.3%. The wins are larger for i386 and code bases that use vtables more often than we do. This matches the behavior of GCC 5. llvm-svn: 217495
* Unique_ptrify PPCallbacks ownership.Craig Topper2014-09-101-1/+2
| | | | | | Unique_ptr creation stil needs to be moved earlier at some of the call sites. llvm-svn: 217474
* Report source location of returns_nonnull attribute in UBSan reports.Alexey Samsonov2014-09-081-9/+11
| | | | llvm-svn: 217400
* Implement nonnull-attribute sanitizerAlexey Samsonov2014-09-085-28/+67
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements a new UBSan check, which verifies that function arguments declared to be nonnull with __attribute__((nonnull)) are actually nonnull in runtime. To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs (where applicable) and if function declaration has nonnull attribute specified for a certain formal parameter, we compare the corresponding RValue to null as soon as it's calculated. Test Plan: regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, rnk Differential Revision: http://reviews.llvm.org/D5082 llvm-svn: 217389
* Remove a parameter that has been unused since r188481. No behavior change.Nico Weber2014-09-082-4/+3
| | | | llvm-svn: 217386
* Add a comment for something that confused me.Nico Weber2014-09-081-0/+1
| | | | llvm-svn: 217384
* Handle constructors and destructors a bit more uniformly in CodeGen.Rafael Espindola2014-09-089-173/+161
| | | | | | | | | There were code paths that are duplicated for constructors and destructors just because we have both CXXCtorType and CXXDtorsTypes. This patch introduces an unified enum and reduces code deplication a bit. llvm-svn: 217383
* Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.Hal Finkel2014-09-073-3/+53
| | | | | | | | | | | This makes use of the recently-added @llvm.assume intrinsic to implement a __builtin_assume(bool) intrinsic (to provide additional information to the optimizer). This hooks up __assume in MS-compatibility mode to mirror __builtin_assume (the semantics have been intentionally kept compatible), and implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM now contains special logic to deal with assumptions of this form. llvm-svn: 217349
* [ARMv8] Add support for 32-bit MIN/MAXNM and directed rounding.James Molloy2014-09-051-0/+16
| | | | | | | | This patch adds support for the 32bit numeric max/min and directed round-to-integral NEON intrinsics that were added as part of v8, along with unit tests. Patch by Graham Hunter! llvm-svn: 217242
* Don't emit prologues or epilogues for naked functions (PR18791, PR20028)Hans Wennborg2014-09-041-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | For naked functions with parameters, Clang would still emit stores in the prologue that would clobber the stack, because LLVM doesn't set up a stack frame. (This shows up in -O0 compiles, because the stores are optimized away otherwise.) For example: __attribute__((naked)) int f(int x) { asm("movl $42, %eax"); asm("retl"); } Would result in: _Z1fi: movl 12(%esp), %eax movl %eax, (%esp) <--- Oops. movl $42, %eax retl Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217198
* MS inline asm: Allow __asm blocks to set a return valueReid Kleckner2014-09-045-5/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | If control falls off the end of a function after an __asm block, MSVC assumes that the inline assembly filled the EAX and possibly EDX registers with an appropriate return value. This functionality is used in inline functions returning 64-bit integers in system headers, so we need some amount of compatibility. This is implemented in Clang by adding extra output constraints to every inline asm block, and storing the resulting output registers into the return value slot. If we see an asm block somewhere in the function body, we emit a normal epilogue instead of marking the end of the function with a return type unreachable. Normal returns in functions not using this functionality will overwrite the return value slot, and in most cases LLVM should be able to eliminate the dead stores. Fixes PR17201. Reviewed By: majnemer Differential Revision: http://reviews.llvm.org/D5177 llvm-svn: 217187
* Fix double full-stop that was accidentally added in r217160.Daniel Sanders2014-09-041-1/+1
| | | | llvm-svn: 217161
* [mips] Mark aggregates returned in registers with the 'inreg' attribute.Daniel Sanders2014-09-041-6/+9
| | | | | | | | | | | | | | | | | | Summary: This allows us to easily find them in the backend after the aggregates have been lowered to other types. This is important on big-endian targets using the N32/N64 ABI's since these ABI's must shift small structures into the upper bits of the register. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5005 llvm-svn: 217160
* [mips] Zero-sized structs cannot be ignored in ↵Daniel Sanders2014-09-041-1/+6
| | | | | | | | | | | | | | | | | | | | | | | MipsABIInfo::classifyReturnType() for O32 Summary: They are returned indirectly which causes the other arguments to move to the next argument slot. With this, utils/ABITest does not discover any failing cases in the first 500 attempts on big/little endian for O32. Previously some of these failed. Also tested N32/N64 little endian (big endian has other known issues) with no issues. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: atanasyan, cfe-commits Differential Revision: http://reviews.llvm.org/D4811 llvm-svn: 217147
* Update for LLVM api change.Rafael Espindola2014-09-031-1/+1
| | | | llvm-svn: 217050
* CGBuiltin: Use @llvm.fabs rather than fabs libcall when emitting builtinsTom Stellard2014-09-031-19/+5
| | | | | | | | | | | Using the intrinsic allows the SelectionDAGBuilder to turn this call into the FABS Node and also the intrinsic is something the vectorizer knows how to vectorize. This patch also sets the readnone attribute on this call, which should enable additional optmizations. llvm-svn: 217042
* Don't indent inside a namespace.Rafael Espindola2014-09-021-28/+28
| | | | llvm-svn: 216937
* Fix for LLVM API change to SpecialCaseList::createDavid Blaikie2014-09-021-1/+2
| | | | llvm-svn: 216926
* MS ABI: Reindent MicrosoftCXXABI::GetVirtualBaseClassOffsetDavid Majnemer2014-09-011-8/+6
| | | | | | No functional change intended. llvm-svn: 216887
* Fix some cases where StringRef was being passed by const reference. Remove ↵Craig Topper2014-08-303-10/+10
| | | | | | const from some other StringRefs since its implicitly const already. llvm-svn: 216825
* Debug info: Only emit C++ accessibility specifiers when they are divergingAdrian Prantl2014-08-292-41/+54
| | | | | | | | from the default for the containing type. rdar://problem/18154959 llvm-svn: 216800
* Make all virtual member pointers use variadic musttail callsReid Kleckner2014-08-293-12/+40
| | | | | | | | | This avoids encoding information about the function prototype into the thunk at the cost of some function prototype bitcast gymnastics. Fixes PR20653. llvm-svn: 216782
* Provide a BuryPointer for unique_ptrs.David Blaikie2014-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In theory, it'd be nice if we could move to a case where all buried pointers were buried via unique_ptr to demonstrate that the program had finished with the value (that we could really have cleanly deallocated it) but instead chose to bury it. I think the main reason that's not possible right now is the various IntrusiveRefCntPtrs in the Frontend, sharing ownership for a variety of compiler bits (see the various similar "CompilerInstance::releaseAndLeak*" functions). I have yet to figure out their correct ownership semantics - but perhaps, even if the intrusiveness can be removed, the shared ownership may yet remain and that would lead to a non-unique burying as is there today. (though we could model that a little better - by passing in a shared_ptr, etc - rather than needing the two step that's currently used in those other releaseAndLeak* functions) This might be a bit more robust if BuryPointer took the boolean: BuryPointer(bool, unique_ptr<T>) and the choice to bury was made internally - that way, even when DisableFree was not set, the unique_ptr would still be null in the caller and there'd be no chance of accidentally having a different codepath where the value is used after burial in !DisableFree, but it becomes null only in DisableFree, etc... llvm-svn: 216742
* Use store size instead of alloc size when coercing.James Molloy2014-08-291-3/+5
| | | | | | | | | | Previously, EnterStructPointerForCoercedAccess used Alloc size when determining how to convert. This was problematic, because there were situations were the alloc size was larger than the store size. For example, if the first element of a structure were i24 and the destination type were i32, the old code would generate a GEP and a load i24. The code should compare store sizes to ensure the whole object is loaded. I have attached a test case. This patch modifies the output of arm64-be-bitfield.c test case, but the new IR seems to be equivalent, and after -O3, the compiler generates identical ARM assembly. (asr x0, x0, #54) Patch by Thomas Jablin! llvm-svn: 216722
* unique_ptrify SourceManager::createFileIDDavid Blaikie2014-08-291-1/+1
| | | | llvm-svn: 216715
* CodeGen: Don't completely mess-up optimized atomic libcallsDavid Majnemer2014-08-291-13/+31
| | | | | | | | | | | | | | | | | | | | | | | Summary: We did a great job getting this wrong: - We messed up which LLVM IR types to use for arguments and return values. The optimized libcalls use integer types for values. Clang attempted to use the IR type which corresponds to the value passed in instead of using an appropriately sized integer type. This would result in violations of the ABI for, as an example, floating point types. - We didn't bother recording the result of the atomic libcall in the destination memory. Instead, call the functions with arguments matching the type of the libcall prototype's parameters. This fixes PR20780. Differential Revision: http://reviews.llvm.org/D5098 llvm-svn: 216714
* unique_ptrify clang::BackendConsumer::takeModuleDavid Blaikie2014-08-291-2/+2
| | | | llvm-svn: 216707
* call __asan_load_cxx_array_cookie when loading array cookie in asan mode.Kostya Serebryany2014-08-291-5/+14
| | | | | | | | | | | | | | | | | | Summary: The current implementation of asan cookie is incorrect: we add nosanitize metadata to the cookie load, but the metadata may be lost and we will instrument the load from poisoned memory. This change replaces the load with a call to __asan_load_cxx_array_cookie (r216692) Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5111 llvm-svn: 216702
* Better codegen support for DLL attributes being dropped after the first ↵Hans Wennborg2014-08-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | declaration (PR20792) For the following code: __declspec(dllimport) int f(int x); int user(int x) { return f(x); } int f(int x) { return 1; } Clang will drop the dllimport attribute in the AST, but CodeGen would have already put it on the LLVM::Function, and that would never get updated. (The same thing happens for global variables.) This makes Clang check dropped DLL attribute case each time the LLVM object is referenced. This isn't perfect, because we will still get it wrong if the function is never referenced by codegen after the attribute is dropped, but this handles the common cases and makes us not fail in the verifier. llvm-svn: 216699
* Reverting r216675. This breaks some bots. Before this can be committed ↵Aaron Ballman2014-08-284-58/+7
| | | | | | again, I have to explore runtime ABI requirements with libc++abi. llvm-svn: 216677
* Objective-C IRGen. Fixes an assertion crash caused by inconsistentFariborz Jahanian2014-08-281-2/+1
| | | | | | | | linkage related to generation of OBJC_SELECTOR_REFERENCES symbol needed in generation of call to 'super' in a class method. // rdar://18150301 llvm-svn: 216676
* Throw a std::bad_array_new_length exception when the expression (or ↵Aaron Ballman2014-08-284-7/+58
| | | | | | constant-expression) passed to operator new[] results in overflow in conformance with [expr.new]p7. Fixes PR11644. llvm-svn: 216675
OpenPOWER on IntegriCloud