aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-02-06Re-apply r259977 - [OpenMP] Reorganize code to allow specialized code ↵Samuel Antao1-1/+15
generation for different devices. This was reverted due to a failure in a buildbot, but it turned out the failure was unrelated. llvm-svn: 259985
2016-02-06Revert r259977 - [OpenMP] Reorganize code to allow specialized code ↵Samuel Antao1-15/+1
generation for different devices. It triggered some problem in the configuration related with zlib and exposed in the driver. llvm-svn: 259984
2016-02-06[OpenMP] Reorganize code to allow specialized code generation for different ↵Samuel Antao1-1/+15
devices. Summary: Different devices may in some cases require different code generation schemes in order to implement OpenMP. This is required not only for performance reasons, but also because it may not be possible to have the current (default) implementation working for these devices. E.g. GPU's cannot implement the same scheme a target such as powerpc or x86b would use, in the sense that it does not have the ability to fork threads, instead all the threads are always executing and need to be managed by the implementation. This patch proposes a reorganization of the code in the OpenMP code generation to pave the way to have specialized implementation of OpenMP support. More than a "real" patch this is more a request for comments in order to understand if what is proposed is acceptable or if there are better/easier ways to do it. In this patch part of the common OpenMP codegen infrastructure is moved to a new file under a new namespace (CGOpenMPCommon) so it can be shared between the default implementation and the specialized one. When CGOpenMPRuntime is created, an attempt to select a specialized implementation is done. In the patch a specialization for nvptx targets is done which currently checks if the target is an OpenMP device and trap if it is not. Let me know comments suggestions you may have. Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev Subscribers: Hahnfeld, cfe-commits, fraggamuffin, caomhin, jholewinski Differential Revision: http://reviews.llvm.org/D16784 llvm-svn: 259977
2016-02-03[cfi] Safe handling of unaddressable vtable pointers (clang).Evgeniy Stepanov1-0/+25
Avoid crashing when printing diagnostics for vtable-related CFI errors. In diagnostic mode, the frontend does an additional check of the vtable pointer against the set of all known vtable addresses and lets the runtime handler know if it is safe to inspect the vtable. http://reviews.llvm.org/D16823 llvm-svn: 259716
2016-02-02[CUDA] Do not allow dynamic initialization of global device side variables.Artem Belevich1-11/+6
In general CUDA does not allow dynamic initialization of global device-side variables. One exception is that CUDA allows records with empty constructors as described in section E2.2.1 of CUDA 7.5 Programming guide. This patch applies initializer checks for all device-side variables. Empty constructors are accepted, but no code is generated for them. Differential Revision: http://reviews.llvm.org/D15305 llvm-svn: 259592
2016-02-02Move DebugInfoKind into its own header to cut the cyclic dependency edge ↵Benjamin Kramer1-6/+5
from Driver to Frontend. llvm-svn: 259489
2016-01-29Use a consistent spelling for vtables.Eric Christopher1-3/+3
llvm-svn: 259137
2016-01-26[MS ABI] Allow a member pointers' converted type to changeDavid Majnemer1-0/+5
Member pointers in the MS ABI are tricky for a variety of reasons. The size of a member pointer is indeterminate until the program reaches a point where the representation is required to be known. However, *pointers* to member pointers may exist without knowing the pointee type's representation. In these cases, we synthesize an opaque LLVM type for the pointee type. However, we can be in a situation where the underlying member pointer's representation became known mid-way through the program. To account for this, we attempted to manicure CodeGen's type-cache so that we can replace the opaque member pointer type with the real deal while leaving the pointer types unperturbed. This, unfortunately, is a problematic approach to take as we will violate CodeGen's invariants. These violations are mostly harmless but let's do the right thing instead: invalidate the type-cache if a member pointer's LLVM representation changes. This fixes PR26313. llvm-svn: 258839
2016-01-25[cfi] Cross-DSO CFI diagnostic mode (clang part)Evgeniy Stepanov1-0/+2
* Runtime diagnostic data for cfi-icall changed to match the rest of cfi checks * Layout of all CFI diagnostic data changed to put Kind at the beginning. There is no ABI stability promise yet. * Call cfi_slowpath_diag instead of cfi_slowpath when needed. * Emit __cfi_check_fail function, which dispatches a CFI check faliure according to trap/recover settings of the current module. * A tiny driver change to match the way the new handlers are done in compiler-rt. llvm-svn: 258745
2016-01-25[CUDA] Don't generate aliases for static extern "C" functions.Justin Lebar1-0/+4
Summary: These aliases are done to support inline asm, but there's nothing we can do: NVPTX doesn't support aliases. Reviewers: tra Subscribers: cfe-commits, jhen, echristo Differential Revision: http://reviews.llvm.org/D16501 llvm-svn: 258734
2016-01-16Introduce -fsanitize-stats flag.Peter Collingbourne1-0/+9
This is part of a new statistics gathering feature for the sanitizers. See clang/docs/SanitizerStats.rst for further info and docs. Differential Revision: http://reviews.llvm.org/D16175 llvm-svn: 257971
2016-01-14PR25910: clang allows two var definitions with the same mangled nameAndrey Bokhanko1-27/+86
Proper diagnostic and resolution of mangled names' conflicts in variables. When there is a declaration and a definition using the same name but different types, we emit what is in the definition. When there are two conflicting definitions, we issue an error. Differential Revision: http://reviews.llvm.org/D15686 llvm-svn: 257754
2016-01-08[MS ABI] Complete and base constructor GlobalDecls must have the same nameDavid Majnemer1-1/+14
Clang got itself into the situation where we mangled the same constructor twice with two different constructor types. After one of the constructors were utilized, the tag used for one of the types changed from class to struct because a class template became complete. This resulted in one of the constructor types varying from the other constructor. Instead, force "base" constructor types to "complete" if the ABI doesn't have constructor variants. This will ensure that GlobalDecls for both variants will get the same mangled name. This fixes PR26029. llvm-svn: 257205
2016-01-06[Driver] Add support for -fno-builtin-foo options.Chad Rosier1-1/+2
Addresses PR4941 and rdar://6756912. http://reviews.llvm.org/D15195 llvm-svn: 256937
2016-01-06[OpenMP] Reapply rL256842: [OpenMP] Offloading descriptor registration and ↵Samuel Antao1-0/+12
device codegen. This patch attempts to fix the regressions identified when the patch was committed initially. Thanks to Michael Liao for identifying the fix in the offloading metadata generation related with side effects in evaluation of function arguments. llvm-svn: 256933
2016-01-05[OpenMP] Revert rL256842: [OpenMP] Offloading descriptor registration and ↵Samuel Antao1-12/+0
device codegen. It was causing two regression, so I'm reverting until the cause is found. llvm-svn: 256858
2016-01-05[OpenMP] Offloading descriptor registration and device codegen.Samuel Antao1-0/+12
Summary: In order to offloading work properly two things need to be in place: - a descriptor with all the offloading information (device entry functions, and global variable) has to be created by the host and registered in the OpenMP offloading runtime library. - all the device functions need to be emitted for the device and a convention has to be in place so that the runtime library can easily map the host ID of an entry point with the actual function in the device. This patch adds support for these two things. However, only entry functions are being registered given that 'declare target' directive is not yet implemented. About offloading descriptor: The details of the descriptor are explained with more detail in http://goo.gl/L1rnKJ. Basically the descriptor will have fields that specify the number of devices, the pointers to where the device images begin and end (that will be defined by the linker), and also pointers to a the begin and end of table whose entries contain information about a specific entry point. Each entry has the type: ``` struct __tgt_offload_entry{ void *addr; char *name; int64_t size; }; ``` and will be implemented in a pre determined (ELF) section `.omp_offloading.entries` with 1-byte alignment, so that when all the objects are linked, the table is in that section with no padding in between entries (will be like a C array). The code generation ensures that all `__tgt_offload_entry` entries are emitted in the same order for both host and device so that the runtime can have the corresponding entries in both host and device in same index of the table, and efficiently implement the mapping. The resulting descriptor is registered/unregistered with the runtime library using the calls `__tgt_register_lib` and `__tgt_unregister_lib`. The registration is implemented in a high priority global initializer so that the registration happens always before any initializer (that can potentially include target regions) is run. The driver flag -omptargets= was created to specify a comma separated list of devices the user wants to support so that the new functionality can be exercised. Each device is specified with its triple. About target codegen: The target codegen is pretty much straightforward as it reuses completely the logic of the host version for the same target region. The tricky part is to identify the meaningful target regions in the device side. Unlike other programming models, like CUDA, there are no already outlined functions with attributes that mark what should be emitted or not. So, the information on what to emit is passed in the form of metadata in host bc file. This requires a new option to pass the host bc to the device frontend. Then everything is similar to what happens in CUDA: the global declarations emission is intercepted to check to see if it is an "interesting" declaration. The difference is that instead of checking an attribute, the metadata information in checked. Right now, there is only a form of metadata to pass information about the device entry points (target regions). A class `OffloadEntriesInfoManagerTy` was created to manage all the information and queries related with the metadata. The metadata looks like this: ``` !omp_offload.info = !{!0, !1, !2, !3, !4, !5, !6} !0 = !{i32 0, i32 52, i32 77426347, !"_ZN2S12r1Ei", i32 479, i32 13, i32 4} !1 = !{i32 0, i32 52, i32 77426347, !"_ZL7fstatici", i32 461, i32 11, i32 5} !2 = !{i32 0, i32 52, i32 77426347, !"_Z9ftemplateIiET_i", i32 444, i32 11, i32 6} !3 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 99, i32 11, i32 0} !4 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 272, i32 11, i32 3} !5 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 127, i32 11, i32 1} !6 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 159, i32 11, i32 2} ``` The fields in each metadata entry are (in sequence): Entry 1) an ID of the type of metadata - right now only zero is used meaning "OpenMP target region". Entry 2) a unique ID of the device where the input source file that contain the target region lives. Entry 3) a unique ID of the file where the input source file that contain the target region lives. Entry 4) a mangled name of the function that encloses the target region. Entries 5) and 6) line and column number where the target region was found. Entry 7) is the order the entry was emitted. Entry 2) and 3) are required to distinguish files that have the same function name. Entry 4) is required to distinguish different instances of the same declaration (usually templated ones) Entries 5) and 6) are required to distinguish the particular target region in body of the function (it is possible that a given target region is not an entry point - if clause can evaluate always to zero - and therefore we need to identify the "interesting" target regions. ) This patch replaces http://reviews.llvm.org/D12306. Reviewers: ABataev, hfinkel, tra, rjmccall, sfantao Subscribers: FBrygidyn, piotr.rak, Hahnfeld, cfe-commits Differential Revision: http://reviews.llvm.org/D12614 llvm-svn: 256842
2015-12-17Attach maximum function count to Module when using PGO mode.Easwaran Raman1-2/+5
This sets the maximum entry count among all functions in the program to the module using module flags. This allows the optimizer to use this information. Differential Revision: http://reviews.llvm.org/D15163 llvm-svn: 255918
2015-12-15Cross-DSO control flow integrity (Clang part).Evgeniy Stepanov1-18/+84
Clang-side cross-DSO CFI. * Adds a command line flag -f[no-]sanitize-cfi-cross-dso. * Links a runtime library when enabled. * Emits __cfi_slowpath calls is bitset test fails. * Emits extra hash-based bitsets for external CFI checks. * Sets a module flag to enable __cfi_check generation during LTO. This mode does not yet support diagnostics. llvm-svn: 255694
2015-12-15[WinEH] Update clang to use operand bundles on call sitesDavid Majnemer1-2/+7
This updates clang to use bundle operands to associate an invoke with the funclet which it is contained within. Depends on D15517. Differential Revision: http://reviews.llvm.org/D15518 llvm-svn: 255675
2015-12-12Revert r254647.Easwaran Raman1-3/+0
Reason: The testcase fails in many architectures. Differential Revision: http://reviews.llvm.org/D15163 llvm-svn: 255416
2015-12-12Attach maximum function count to Module when using PGO modeEaswaran Raman1-0/+3
This sets the maximum entry count among all functions in the program to the module using module flags. This allows the optimizer to use this information. Differential Revision: http://reviews.llvm.org/D15163 llvm-svn: 255397
2015-12-05Revert "[x86] Exclusion of incorrect include headers paths for MCU target"Reid Kleckner1-52/+17
This reverts commit r254195. From the description, I suspect that the wrong patch was committed here, and this is causing assertion failures in EmitDeferred() when the global value ends up being a bitcast of a global. llvm-svn: 254823
2015-12-02Add the `pass_object_size` attribute to clang.George Burgess IV1-2/+5
`pass_object_size` is our way of enabling `__builtin_object_size` to produce high quality results without requiring inlining to happen everywhere. A link to the design doc for this attribute is available at the Differential review link below. Differential Revision: http://reviews.llvm.org/D13263 llvm-svn: 254554
2015-12-01Fix use-after-free when a C++ thread_local variable gets replaced (because itsRichard Smith1-2/+2
type changes when the initializer is attached). Don't hold onto the GlobalVariable*; recompute it from the VarDecl* instead. llvm-svn: 254359
2015-11-27[x86] Exclusion of incorrect include headers paths for MCU targetAndrey Bokhanko1-17/+52
Exclusion of /usr/include and /usr/local/include headers paths for MCU target. Differential Revision: http://reviews.llvm.org/D14954 llvm-svn: 254195
2015-11-11[TLS on Darwin] treat all Darwin platforms in the same way.Manman Ren1-1/+1
rdar://problem/9001553 llvm-svn: 252820
2015-11-11Extract out a function onto CodeGenModule for getting the map ofEric Christopher1-0/+29
features for a particular function, then use it to clean up some code. llvm-svn: 252819
2015-11-11[TLS on Darwin] change how we handle globals with linkonce or weak linkage.Manman Ren1-4/+9
This is about how we handle static member of a template. Before this commit, we use internal linkage for the IR thread-local variable, which is inefficient. With this commit, we will start to follow Itanium C++ ABI. rdar://problem/23415206 Reviewed by John McCall. llvm-svn: 252814
2015-11-06CodeGen: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith1-1/+2
Make ilist iterator conversions explicit in clangCodeGen. Eventually I'll remove them everywhere. llvm-svn: 252358
2015-11-05Fix crash in EmitDeclMetadata modeKeno Fischer1-2/+4
Summary: This fixes a bug that's easily encountered in LLDB (https://llvm.org/bugs/show_bug.cgi?id=22875). The problem here is that we mangle a name during debug info emission, but never actually emit the actual Decl, so we run into problems in EmitDeclMetadata (which assumes such a Decl exists). Fix that by just skipping metadata emissions for mangled names that don't have associated Decls. Reviewers: rjmccall Subscribers: labath, cfe-commits Differential Revision: http://reviews.llvm.org/D13959 llvm-svn: 252229
2015-10-30Watch and TV OS: wire up basic ABI choicesTim Northover1-0/+2
This sets the mostly expected Darwin default ABI options for these two platforms. Active changes from these defaults for watchOS are in a later patch. llvm-svn: 251708
2015-10-21Unify the ObjC entrypoint caches.John McCall1-7/+5
llvm-svn: 250918
2015-10-15[CodeGen] Remove dead code. NFC.Benjamin Kramer1-6/+0
llvm-svn: 250418
2015-10-08[CodeGen] [CodeGen] Attach function attributes to functions created inAkira Hatanaka1-4/+5
CGBlocks.cpp. This commit fixes a bug in clang's code-gen where it creates the following functions but doesn't attach function attributes to them: __copy_helper_block_ __destroy_helper_block_ __Block_byref_object_copy_ __Block_byref_object_dispose_ rdar://problem/20828324 Differential Revision: http://reviews.llvm.org/D13525 llvm-svn: 249735
2015-10-08[CodeGen] Check if the Decl pointer passed is null, and if so, returnAkira Hatanaka1-7/+15
early. This is needed in a patch I plan to commit later, in which a null Decl pointer is passed to SetLLVMFunctionAttributesForDefinition. Relevant discussion is in http://reviews.llvm.org/D13525. llvm-svn: 249722
2015-10-08[MSVC Compat] Enable ABI impacting non-conforming behavior independently of ↵David Majnemer1-1/+1
-fms-compatibility No ABI for C++ currently makes it possible to implement the standard 100% perfectly. We wrongly hid some of our compatible behavior behind -fms-compatibility instead of tying it to the compiler ABI. llvm-svn: 249656
2015-10-03Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren1-1/+1
SourceLocation.isValid(). llvm-svn: 249228
2015-09-27Use llvm::makeArrayRef. NFC.Craig Topper1-1/+1
llvm-svn: 248678
2015-09-21Remove attributes minsize and optsize, which conflict with optnone.Akira Hatanaka1-4/+2
This commit fixes an assert that is triggered when optnone is being added to an IR function that is already marked with minsize and optsize. rdar://problem/22723716 Differential Revision: http://reviews.llvm.org/D13004 llvm-svn: 248191
2015-09-17Using MD_invariant_groupPiotr Padlewski1-1/+1
http://reviews.llvm.org/D12927 llvm-svn: 247933
2015-09-16[WinEH] Pass the catch adjectives to catchpad directlyReid Kleckner1-6/+0
This avoids building a fake LLVM IR global variable just to ferry an i32 down into LLVM codegen. It also puts a nail in the coffin of using MS ABI C++ EH with landingpads, since now we'll assert in the lpad code when flags are present. llvm-svn: 247843
2015-09-15Decorating vptr load & stores with !invariant.groupPiotr Padlewski1-3/+13
Adding !invariant.group to vptr load/stores for devirtualization purposes. For more goto: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html http://reviews.llvm.org/D12026 llvm-svn: 247725
2015-09-15Added llvm.module flag for strict vtable pointersPiotr Padlewski1-0/+16
It is dangerous to do LTO on code with strict-vtable-pointers, because one module has invariant.group.barriers, and the other one not. In the future I want to just strip all invariant.group metadata from vptrs loads/stores and get rid of invariant.group.barrier calls. http://reviews.llvm.org/D12580 llvm-svn: 247724
2015-09-14Revert "Always_inline codegen rewrite" and 2 follow-ups.Evgeniy Stepanov1-108/+1
Revert "Update cxx-irgen.cpp test to allow signext in alwaysinline functions." Revert "[CodeGen] Remove wrapper-free always_inline functions from COMDATs" Revert "Always_inline codegen rewrite." Reason for revert: PR24793. llvm-svn: 247620
2015-09-14[opaque pointer type] Fix a few uses of PointerType::getElementType in favor ↵David Blaikie1-2/+1
of uses of types already available elsewhere These are a few cleanups I happened to have from trying to go in a different direction recently, so just flushing them out while I have them. llvm-svn: 247593
2015-09-14Revert "[opaque pointer type] update for LLVM API change"David Blaikie1-1/+1
This was the wrong direction to take anyway (because ultimately the GlobalValue needed the pointee type again and /it/ used PointerType::getElementType eventually anyway)... let's go a different way. This reverts commit r236161. llvm-svn: 247586
2015-09-12[CodeGen] Remove wrapper-free always_inline functions from COMDATsDavid Majnemer1-1/+5
always_inline functions without a wrapper don't need to be in a COMDAT. llvm-svn: 247500
2015-09-12Always_inline codegen rewrite.Evgeniy Stepanov1-1/+104
Current implementation may end up emitting an undefined reference for an "inline __attribute__((always_inline))" function by generating an "available_externally alwaysinline" IR function for it and then failing to inline all the calls. This happens when a call to such function is in dead code. As the inliner is an SCC pass, it does not process dead code. Libc++ relies on the compiler never emitting such undefined reference. With this patch, we emit a pair of 1. internal alwaysinline definition (called F.alwaysinline) 2a. A stub F() { musttail call F.alwaysinline } -- or, depending on the linkage -- 2b. A declaration of F. The frontend ensures that F.inlinefunction is only used for direct calls, and the stub is used for everything else (taking the address of the function, really). Declaration (2b) is emitted in the case when "inline" is meant for inlining only (like __gnu_inline__ and some other cases). This approach, among other nice properties, ensures that alwaysinline functions are always internal, making it impossible for a direct call to such function to produce an undefined symbol reference. This patch is based on ideas by Chandler Carruth and Richard Smith. llvm-svn: 247494
2015-09-11Revert "Specify target triple in alwaysinline tests."Evgeniy Stepanov1-98/+1
Revert "Always_inline codegen rewrite." Breaks gdb & lldb tests. Breaks on Fedora 22 x86_64. llvm-svn: 247491