summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* [clang] Version support for UBSan handlersFilipe Cabecinhas2016-12-127-36/+84
| | | | | | | | | | | | | | | | | | | | | | This adds a way for us to version any UBSan handler by itself. The patch overrides D21289 for a better implementation (we're able to rev up a single handler). After this, then we can land a slight modification of D19667+D19668. We probably don't want to keep all the versions in compiler-rt (maybe we want to deprecate on one release and remove the old handler on the next one?), but with this patch we will loudly fail to compile when mixing incompatible handler calls, instead of silently compiling and then providing bad error messages. Reviewers: kcc, samsonov, rsmith, vsk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21695 llvm-svn: 289444
* Add two new AST nodes to represent initialization of an array in terms ofRichard Smith2016-12-123-0/+121
| | | | | | | | | | | | | | | | | | | | initialization of each array element: * ArrayInitLoopExpr is a prvalue of array type with two subexpressions: a common expression (an OpaqueValueExpr) that represents the up-front computation of the source of the initialization, and a subexpression representing a per-element initializer * ArrayInitIndexExpr is a prvalue of type size_t representing the current position in the loop This will be used to replace the creation of explicit index variables in lambda capture of arrays and copy/move construction of classes with array elements, and also C++17 structured bindings of arrays by value (which inexplicably allow copying an array by value, unlike all of C++'s other array declarations). No uses of these nodes are introduced by this change, however. llvm-svn: 289413
* [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}Vedant Kumar2016-12-091-7/+8
| | | | | | | | | | | | | | On some Apple platforms, the ObjC BOOL type is defined as a signed char. When performing instrumentation for -fsanitize=bool, we'd like to treat the range of BOOL like it's always {0, 1}. While we can't change clang's IRGen for char-backed BOOL's due to ABI compatibility concerns, we can teach ubsan to catch potential abuses of this type. rdar://problem/29502773 Differential Revision: https://reviews.llvm.org/D27607 llvm-svn: 289290
* Fix unused variable warnings. NFCI.Simon Pilgrim2016-12-092-4/+4
| | | | llvm-svn: 289285
* Add support for non-zero null pointer for C and OpenCLYaxun Liu2016-12-0910-42/+140
| | | | | | | | | | | | | | | | | | In amdgcn target, null pointers in global, constant, and generic address space take value 0 but null pointers in private and local address space take value -1. Currently LLVM assumes all null pointers take value 0, which results in incorrectly translated IR. To workaround this issue, instead of emit null pointers in local and private address space, a null pointer in generic address space is emitted and casted to local and private address space. Tentative definition of global variables with non-zero initializer will have weak linkage instead of common linkage since common linkage requires zero initializer and does not have explicit section to hold the non-zero value. Virtual member functions getNullPointer and performAddrSpaceCast are added to TargetCodeGenInfo which by default returns ConstantPointerNull and emitting addrspacecast instruction. A virtual member function getNullPointerValue is added to TargetInfo which by default returns 0. Each target can override these virtual functions to get target specific null pointer and the null pointer value for specific address space, and perform specific translations for addrspacecast. Wrapper functions getNullPointer is added to CodegenModule and getTargetNullPointerValue is added to ASTContext to facilitate getting the target specific null pointers and their values. This change has no effect on other targets except amdgcn target. Other targets can provide support of non-zero null pointer in a similar way. This change only provides support for non-zero null pointer for C and OpenCL. Supporting for other languages will be added later incrementally. Differential Revision: https://reviews.llvm.org/D26196 llvm-svn: 289252
* [OpenMP] Sema and parsing for 'teams distribute parallel for' pragmaKelvin Li2016-12-093-0/+18
| | | | | | | | This patch is to implement sema and parsing for 'teams distribute parallel for' pragma. Differential Revision: https://reviews.llvm.org/D27345 llvm-svn: 289179
* [DebugInfo] Add support for __fp16, float, and double constants.David Gross2016-12-081-0/+3
| | | | | | | | | | | | | | | | | | | Summary: Partial fix for PR26619. Prior to this change, a DIGlobalVariable corresponding to a static const was marked with an expression corresponding to its constant value only if it is of integral type. With this change, we now do the same if it is of __fp16, float, or double type (that is, floating-point types that do not exceed 64 bits in size, and hence are supported easily by the existing LLVM machinery for creating constant expressions in debug info). Reviewers: llvm-commits Differential Revision: https://reviews.llvm.org/D27549 llvm-svn: 289094
* [OpenCL] Fix SPIR version generation.Alexey Bader2016-12-071-2/+4
| | | | | | | | | | | | Patch by Egor Churaev (echuraev). Reviewers: Anastasia Subscribers: bader, yaxunl, cfe-commits Differential Revision: https://reviews.llvm.org/D27300 llvm-svn: 288890
* [MS-ABI]V-base dtor called more than needed when throw happens in v-base ↵Erich Keane2016-12-071-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ctor in window. Need add "complete object flag" check in eh cleanup code. The problem only happen on window ( A MS-ABI issuer ) The nature of the problem is virtual base dtor called more than it is needed after exception throw in inheriting base class(with virtual bases) ctor. The root problem is when throw happen, not all virtual base classes have been contructed, so not all virtual base dtors are need to call for ehcleanup. clang has code to handle vbase initialization: basically add check for "complete object flag" before call to v-base ctor. But that part is missing for cleanup code. To fix this add similar code as v-base init to cleanup code, same algorithm. 1> Add new routine: EmitDtorCompleteObjectHandler With corresponding to EmitCtorCompleteObjectHandler 2> In the EmitDestructorCal Call EmitDtorCompleteObjectHandler when generate ehcleanup inside ctor. Just add check for "complete object flag" before call to v-base dtor. Without my change: ehcleanup: ; preds = %ctor.skip_vbases %13 = cleanuppad within none [], !dbg !66 %14 = bitcast %struct.class_0* %this1 to i8*, !dbg !66 %15 = getelementptr inbounds i8, i8* %14, i64 8, !dbg !66 %16 = bitcast i8* %15 to %struct.class_2*, !dbg !66 call void @"\01??1class_2@@UEAA@XZ"(%struct.class_2* %16) #6 [ "funclet"(token %13) ], !dbg !66 cleanupret from %13 unwind to caller, !dbg !66 with my change: ehcleanup: ; preds = %ctor.skip_vbases %13 = cleanuppad within none [], !dbg !66 %14 = bitcast %struct.class_0* %this1 to i8*, !dbg !66 %15 = getelementptr inbounds i8, i8* %14, i64 8, !dbg !66 %16 = bitcast i8* %15 to %struct.class_2*, !dbg !66 %is_complete_object4 = icmp ne i32 %is_most_derived2, 0, !dbg !66 br i1 %is_complete_object4, label %Dtor.dtor_vbase, label %Dtor.skip_vbase, !d bg !66 Dtor.dtor_vbase: ; preds = %ehcleanup call void @"\01??1class_2@@UEAA@XZ"(%struct.class_2* %16) #6 [ "funclet"(token %13) ], !dbg !66 br label %Dtor.skip_vbase, !dbg !66 Dtor.skip_vbase: ; preds = %Dtor.dtor_vbase, %ehcleanup cleanupret from %13 unwind to caller, !dbg !66 Please let me know you need more info. Patch by Jennifer Yu. Differential Revision: https://reviews.llvm.org/D27358 llvm-svn: 288869
* [c++17] P0135R1: Guaranteed copy elision.Richard Smith2016-12-063-17/+7
| | | | | | | | When an object of class type is initialized from a prvalue of the same type (ignoring cv qualifications), use the prvalue to initialize the object directly instead of inserting a redundant elidable call to a copy constructor. llvm-svn: 288866
* Fix two clang-tidy misc-move-forwarding-reference warningsMalcolm Parsons2016-12-061-1/+1
| | | | | | Patch by Michael Sharpe. llvm-svn: 288813
* CodeGen: fix windows itanium RTTI in EH modeSaleem Abdulrasool2016-12-051-1/+1
| | | | | | | | | When emitting RTTI for EH only, we would mark the locally defined (LinkOnceODR) RTTI definition as dllimport, which is incorrect. Ensure that if we are generating the type information for EH only, it is marked as LinkOnceODR and we do not make it dllimport. llvm-svn: 288721
* IRGen: Remove an unused overload of CreateAlignedLoad.Peter Collingbourne2016-12-051-5/+0
| | | | llvm-svn: 288629
* CodeGen: export typeinfo and typeinfo name on itaniumSaleem Abdulrasool2016-12-021-6/+24
| | | | | | | | When a C++ record is marked with dllexport mark both the typeinfo and the typeinfo name as being exported. Handle dllimport as the inverse. This applies to the itanium environment and not the MinGW environment. llvm-svn: 288546
* Struct GEPs must use i32, not whatever size_t is. It should be safeJohn McCall2016-12-011-2/+4
| | | | | | | to do this unconditionally, given that the indices will always be small constant integers anyway. llvm-svn: 288440
* [CodeGen][ARM] Make sure the value and type used to create a bitcastAkira Hatanaka2016-12-011-10/+20
| | | | | | | | | | | have the same size. This fixes an asset that is triggered when an address of a boolean variable is passed to __builtin_arm_ldrex or __builtin_arm_strex. rdar://problem/29269006 llvm-svn: 288404
* swiftcc: Add an api to query whether a target ABI stores swifterror in a ↵Arnold Schwaighofer2016-12-013-0/+28
| | | | | | register llvm-svn: 288394
* Teach ConstantBuilder how to emit a reference to the current positionJohn McCall2016-12-011-0/+40
| | | | | | that will be filled in when the initializer is set. llvm-svn: 288313
* P0012R1: add Itanium ABI support for throwing non-noexcept function pointers ↵Richard Smith2016-12-011-41/+42
| | | | | | and catching as noexcept. llvm-svn: 288305
* Revert r285664, cxx-abi-dev chose to go in a different direction for the ABI ↵Richard Smith2016-12-011-109/+4
| | | | | | here. llvm-svn: 288304
* Clean up CGObjCMac's APIs for deriving class references. NFC.John McCall2016-11-303-115/+89
| | | | llvm-svn: 288295
* [OpenMP] Sema and parsing for 'teams distribute parallel for simd' pragmaKelvin Li2016-11-303-0/+17
| | | | | | | | This patch is to implement sema and parsing for 'teams distribute parallel for simd' pragma. Differential Revision: https://reviews.llvm.org/D27084 llvm-svn: 288294
* Introduce a type-safe enum for ForDefinition.John McCall2016-11-304-18/+30
| | | | llvm-svn: 288289
* Fix some layering violations where CGObjCMac's NSString emission wasJohn McCall2016-11-303-135/+127
| | | | | | | | | | performed at the CodeGenModule level. Would be NFC except we now also use a different uniquing structure so that we don't get spurious conflicts if you ask for both an NSString and a CFString for the same content (which is possible with builtins). llvm-svn: 288287
* Prospective MSVC workaround.John McCall2016-11-301-1/+2
| | | | llvm-svn: 288272
* Finish adopting ConstantInitBuilder in CGObjCGNU. NFC.John McCall2016-11-302-180/+187
| | | | llvm-svn: 288269
* Prospective GCC build fix: the unelaborated form of this friendJohn McCall2016-11-301-2/+2
| | | | | | | declaration should find the right type, assuming it's supported evenly across all our hosts. llvm-svn: 288231
* Switch CGObjCMac to use ConstantInitBuilder. Whew.John McCall2016-11-302-778/+862
| | | | | | | Not strictly NFC because I did change the order of emission of some global constants, but it shouldn't make any difference. llvm-svn: 288229
* Fix -Winconsistent-missing-override in CodeGenAction.cppReid Kleckner2016-11-301-1/+1
| | | | llvm-svn: 288227
* Stop handling interesting deserialized decls after HandleTranslationUnitReid Kleckner2016-11-301-0/+13
| | | | | | | | Other AST consumers can deserialize interesting decls that we might codegen, but they won't make it to the final object file and can trigger assertions in debug information generation after finalization. llvm-svn: 288221
* getObjCEncodingForMethodDecl cannot fail. Simplify. NFC.John McCall2016-11-292-41/+17
| | | | llvm-svn: 288203
* [OpenCL] Prevent generation of globals in non-constant AS for OpenCL.Anastasia Stulova2016-11-291-2/+6
| | | | | | | | | | Avoid using shortcut for const qualified non-constant address space aggregate variables while generating them on the stack such that the alloca object is used instead of a global variable containing initializer. Review: https://reviews.llvm.org/D27109 llvm-svn: 288163
* IRGen: Remove all uses of CreateDefaultAlignedLoad.Peter Collingbourne2016-11-285-33/+37
| | | | | | Differential Revision: https://reviews.llvm.org/D27157 llvm-svn: 288083
* Make CGVTables use ConstantInitBuilder. NFC.John McCall2016-11-284-78/+89
| | | | llvm-svn: 288081
* Hide the result of building a constant initializer. NFC.John McCall2016-11-284-48/+91
| | | | llvm-svn: 288080
* ConstantBuilder -> ConstantInitBuilder for clarity, andJohn McCall2016-11-286-124/+141
| | | | | | | move the member classes up to top level to allow forward declarations to name them. NFC. llvm-svn: 288079
* [MS] Mangle a unique ID into all MS inline asm labelsReid Kleckner2016-11-281-9/+0
| | | | | | | | | | | | This solves PR23715 in a way that is compatible with LTO. MSVC supports jumping to source-level labels and between inline asm blocks, but we don't. Also revert the old solution, r255201, which was to mark these calls as noduplicate. llvm-svn: 288059
* [CodeGen] Pass objects that are expensive to copy by const ref.Benjamin Kramer2016-11-244-16/+18
| | | | | | | No functionality change. Found by clang-tidy's performance-unnecessary-value-param. llvm-svn: 287894
* Remove C++ default arg side table for MS ABI ctor closuresReid Kleckner2016-11-231-5/+5
| | | | | | | | | | | | | | | | | | | Summary: We don't need a side table in ASTContext to hold CXXDefaultArgExprs. The important part of building the CXXDefaultArgExprs was to ODR use the default argument expressions, not to make AST nodes. Refactor the code to only check the default argument, and remove the side table in ASTContext which wasn't being serialized. Fixes PR31121 Reviewers: thakis, rsmith, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27007 llvm-svn: 287774
* [CodeGen] Simplify code. No functionality change intended.Benjamin Kramer2016-11-231-8/+1
| | | | llvm-svn: 287754
* Remove variable only used in an assertion.John McCall2016-11-221-5/+0
| | | | llvm-svn: 287691
* [CodeGen] Insert TargetLibraryInfoWrapperPass before anything else.Marcin Koscielnicki2016-11-221-2/+9
| | | | | | | | | | | | Currently, TargetLibraryInfoWrapperPass is inserted by PMBuilder. However, some passes are inserted manually before the PMBuilder ones - if any of them happens to use TargetLibraryInfoWrapperPass, it'll get a default-constructed one, with an unknown target triple. This happens to InstrProfiling in D21736, breaking it. Differential Revision: http://reviews.llvm.org/D21737 llvm-svn: 287688
* Sema, CodeGen: Ensure that an implicit copy ctor is available more often ↵Peter Collingbourne2016-11-221-9/+16
| | | | | | | | | | | | | | | | under the Microsoft C++ ABI. This is needed because whether the constructor is deleted can control whether we pass structs by value directly. To fix this properly we probably want a more direct way for CodeGen to ask whether the constructor was deleted. Fixes PR31049. Differential Revision: https://reviews.llvm.org/D26822 llvm-svn: 287600
* Remove alignment from ctors/dtors lists in an attempt to placate LTO.John McCall2016-11-191-3/+9
| | | | llvm-svn: 287458
* Change setDiagnosticsOutputFile to take a unique_ptr from a raw pointer (NFC)Mehdi Amini2016-11-191-1/+2
| | | | | | | | | | | | | | Summary: This makes it explicit that ownership is taken. Also replace all `new` with make_unique<> at call sites. Reviewers: anemet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26884 llvm-svn: 287449
* Introduce a helper class for building complex constant initializers. NFC.John McCall2016-11-196-508/+767
| | | | | | | I've adopted this in most of the places it makes sense, but v-tables and CGObjCMac will need a second pass. llvm-svn: 287437
* [AMDGPU] Change frexp.exp builtin to return i16 for f16 inputKonstantin Zhuravlyov2016-11-181-3/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D26863 llvm-svn: 287390
* Adapt to llvm NamedRegionTimer changesMatthias Braun2016-11-182-2/+2
| | | | | | We have to specify a name and description for the timers and groups now. llvm-svn: 287371
* Forward ns_consumed delegate arguments with a move.John McCall2016-11-181-3/+21
| | | | | | | | | | | | | | | | StartFunction enters a release cleanup for ns_consumed arguments in ARC, so we need to balance that somehow. We could teach StartFunction that it's emitting a delegating function, so that the cleanup is unnecessary, but that would be invasive and somewhat fraught. We could balance the consumed argument with an extra retain, but clearing the original variable should be easier to optimize and avoid some extra work at -O0. And there shouldn't be any difference as long as nothing else uses the argument, which should always be true for the places we emit delegate arguments. Fixes PR 27887. llvm-svn: 287291
* [CUDA] Use the right section and constant names for fatbins when compiling ↵Justin Lebar2016-11-181-3/+8
| | | | | | | | | | | | for macos. Reviewers: tra Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26777 llvm-svn: 287287
OpenPOWER on IntegriCloud