summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* Add an AST node for __leave statements, hook it up.Nico Weber2014-07-073-0/+8
| | | | | | | Codegen is still missing (and I won't work on that), but __leave is now as implemented as __try and friends. llvm-svn: 212425
* CodeGen: add support for a few MSVC ARM intrinsicsSaleem Abdulrasool2014-07-051-4/+15
| | | | | | | | This adds support for simple MSVC compatibility mode intrinsics. These intrinsics are simple in that they are either directly passed through to the annotated MSBuiltin intrinsic or they mirror existing GCC builtins. llvm-svn: 212378
* CodeGen: add support for MSBuiltin aliasesSaleem Abdulrasool2014-07-041-1/+7
| | | | | | | | | | | | | | | | | | This completes the infrastructure for the new MSBuiltin aliases in the instruction definitions. These behave similar to the GCCBuiltin in that they can be implicitly constructed without special handling unless needed. With this change it is possible to annotate an LLVM intrinsic in the backend instruction definitions and indicate it as a builtin in the Builtin*.def files in clang via LANGBUILTIN. That will automatically pass through the instruction much as a GCCBuiltin. Note that there is no need for the special handling for ensuring that the compatibility flag is enabled since the filtering on the LANGBUILTIN will automatically prevent the intrinsic from bleeding into non-MS compatible compiler invocations. llvm-svn: 212359
* Move the calling of emitTargetMD() later.Robert Lytton2014-07-032-6/+15
| | | | | | | | | | | | | | | | Summary: Because a global created by GetOrCreateLLVMGlobal() is not finalised until later viz: extern char a[]; char f(){ return a[5];} char a[10]; Change MangledDeclNames to use a MapVector rather than a DenseMap so that the Metadata is output in order of original declaration, so to make deterministic and improve human readablity. Differential Revision: http://reviews.llvm.org/D4176 llvm-svn: 212263
* refactor for-loop as range-loop before making changes.Robert Lytton2014-07-031-10/+6
| | | | | | Differential Revision: http://reviews.llvm.org/D4176 llvm-svn: 212262
* ARMEB: Fix function result return for composite typesChristian Pirker2014-07-031-0/+4
| | | | | | Reviewed at http://reviews.llvm.org/D4364 llvm-svn: 212261
* MS ABI: Get linkage of RTTI data correctDavid Majnemer2014-07-031-2/+17
| | | | | | | | | | | | | | | | | The Itanium rules are not appropriate for the MS ABI. RTTI data is _never_ imported and thus is never available_externally. It is either internal (if the type's linkage is internal) or linkonce_odr. This also means that classes which inherit from dllimport'd bases force their translation unit to duplicate the entirety of the RTTI data of that base. Interestingly, the complete object locator can never be referenced by translation units which import the class. This fixes PR20106. llvm-svn: 212256
* ARM: rename ARM builtins to use __builtin_arm prefixSaleem Abdulrasool2014-07-031-5/+5
| | | | | | | | | This corrects SVN r212196's naming change to use the proper prefix of `__builtin_arm_` instead of `__builtin_`. Thanks to Yi Kong for pointing out the incorrect naming! llvm-svn: 212253
* CodeGen: make target builtins support languagesSaleem Abdulrasool2014-07-021-0/+5
| | | | | | | | | | This extends the target builtin support to allow language specific annotations (i.e. LANGBUILTIN). This is to allow MSVC compatibility whilst retaining the ability to have EABI targets use a __builtin_ prefix. This is merely to allow uniformity in the EABI case where the unprefixed name is provided as an alias in the header. llvm-svn: 212196
* [ASan] Print exact source location of global variables in error reports.Alexey Samsonov2014-07-023-10/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://code.google.com/p/address-sanitizer/issues/detail?id=299 for the original feature request. Introduce llvm.asan.globals metadata, which Clang (or any other frontend) may use to report extra information about global variables to ASan instrumentation pass in the backend. This metadata replaces llvm.asan.dynamically_initialized_globals that was used to detect init-order bugs. llvm.asan.globals contains the following data for each global: 1) source location (file/line/column info); 2) whether it is dynamically initialized; 3) whether it is blacklisted (shouldn't be instrumented). Source location data is then emitted in the binary and can be picked up by ASan runtime in case it needs to print error report involving some global. For example: 0x... is located 4 bytes to the right of global variable 'C::array' defined in '/path/to/file:17:8' (0x...) of size 40 These source locations are printed even if the binary doesn't have any debug info. This is an ABI-breaking change. ASan initialization is renamed to __asan_init_v4(). Pre-built libraries compiled with older Clang will not work with the fresh runtime. llvm-svn: 212188
* ARM: add support for v8 ldaex/stlex builtins.Tim Northover2014-07-021-16/+44
| | | | | | | | | | | | | | ARMv8 adds (to both AArch32 and AArch64) acquiring and releasing variants of the exclusive operations, in line with the C++11 memory model. This adds support for two new intrinsics to expose them to C & C++ developers directly: __builtin_arm_ldaex and __builtin_arm_stlex, in direct analogy with the versions with no implicit barrier. rdar://problem/15885451 llvm-svn: 212175
* [OPENMP, C++11] Improve code of InitVLACaptures function.Alexey Bataev2014-07-021-5/+8
| | | | llvm-svn: 212162
* CodeGen: Add some comments describing VFTable CGDavid Majnemer2014-07-011-0/+20
| | | | | | | No functionality change, just some comments to describe what is going on. llvm-svn: 212142
* Driver: Handle /GR- in a compatible way with MSVCDavid Majnemer2014-07-012-3/+4
| | | | | | | | | | | | | | | | | There are slight differences between /GR- and -fno-rtti which made mapping one to the other inappropriate. -fno-rtti disables dynamic_cast, typeid, and does not emit RTTI related information for the v-table. /GR- does not generate complete object locators and thus will not reference them in vftables. However, constructs like dynamic_cast and typeid are permitted. This should bring our implementation of RTTI up to semantic parity with MSVC modulo bugs. llvm-svn: 212138
* MS ABI: Reference MSVC RTTI from the VFTableDavid Majnemer2014-07-016-53/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pointer for a class's RTTI data comes right before the VFTable but has no name. To be properly compatible with this, we do the following: * Create a single GlobalVariable which holds the contents of the VFTable _and_ the pointer to the RTTI data. * Create a GlobalAlias, with appropriate linkage/visibility, that points just after the RTTI data pointer. This ensures that the VFTable symbol will always refer to VFTable data. * Create a Comdat with a "Largest" SelectionKind and stick the private GlobalVariable in it. By transitivity, the GlobalAlias will be a member of the Comdat group. Using "Largest" ensures that foreign definitions without an RTTI data pointer will _not_ be chosen in the final linked image. Whether or not we emit RTTI data depends on several things: * The -fno-rtti flag implies that we should never not emit a pointer to RTTI data before the VFTable. * __declspec(dllimport) brings in the VFTable from a remote DLL. Use an available_externally GlobalVariable to provide a local definition of the VFTable. This means that we won't have any available_externally definitions of things like complete object locators. This is acceptable because they are never directly referenced. To my knowledge, this completes the implementation of MSVC RTTI code generation. Further semantic work should be done to properly support /GR-. llvm-svn: 212125
* Remove CleanupHackLevel from CGException.Logan Chien2014-07-012-113/+16
| | | | | | | | | | | | | | | | | | | | This patch removes the dead code, and refines the getEHResumeBlock() slightly. The CleanupHackLevel was a hack to the old exception handling intrinsics, which have several issues with function inliner. Since LLVM 3.0, the new landingpad and resume instructions are added to LLVM IR. With the new exception handling mechanism, most of the issues are fixed now. We should always use these instructions to implement the exception handling code nowadays, and we don't need the hack any more. Besides, the `CleanupHackLevel` is a compile-time constant, thus other cases have been considered as dead code for a while. llvm-svn: 212097
* Using of variable length arrays in captured statements and OpenMP constructs.Alexey Bataev2014-06-303-14/+24
| | | | | | Differential Revision: http://reviews.llvm.org/D4067 llvm-svn: 212010
* CodeGenAction::ExecuteAction(): check for invalid LLVM source locationsAlp Toker2014-06-301-5/+11
| | | | | | | | | | | | | Add sign checks to deal with the fact that IR parser line/column pairs are signed integers and sometimes invalid. The crash path is potentially triggered by corrupt '.bc' files in practice, though I don't have a binary input test case that can be checked-in right now. (Unfortunately the backend itself crashes on various ill-formed '.bc' inputs so this bandage isn't as helpful as it appears yet.) llvm-svn: 212007
* Remove llvm:: from uses of ArrayRef.Craig Topper2014-06-287-12/+12
| | | | llvm-svn: 211987
* Remove 'const' from MemoryBuffers used through the SourceManagerDavid Blaikie2014-06-271-4/+2
| | | | | | | | | | | | | | This removes a const_cast added in r211884 that occurred due to an inconsistency in how MemoryBuffers are handled between some parts of clang and LLVM. MemoryBuffers are immutable and the general convention in the LLVM project is to omit const from immutable types as it's simply redundant/verbose (see llvm::Type, for example). While this change doesn't remove "const" from /every/ MemoryBuffer, it at least makes this chain of ownership/usage consistent. llvm-svn: 211915
* CodeGen: Fix a typo in getThreadLocalWrapperLinkageDavid Majnemer2014-06-271-1/+1
| | | | | | The description had a misspelling. No functionality change. llvm-svn: 211908
* [ARM] Fix AAPCS non-compliance caused by very large structsOliver Stannard2014-06-271-3/+6
| | | | | | | | | | | | | | This is a fix to the code in clang which inserts padding arguments to ensure that the ARM backend can emit AAPCS-VFP compliant code. This code needs to track the number of registers which have been allocated in order to do this. When passing a very large struct (>64 bytes) by value, clang emits IR which takes a pointer to the struct, but the backend converts this back to passing the struct in registers and on the stack. The bug was that this was being considered by clang to only use one register, meaning that there were situations in which padding arguments were incorrectly emitted by clang. llvm-svn: 211898
* const_cast the memory MemoryBuffer following LLVM r211883Alp Toker2014-06-271-1/+2
| | | | llvm-svn: 211884
* Add a FIXME for an unfortunate issue in ConvertBackendLocation()Alp Toker2014-06-271-1/+3
| | | | | | | This function is copying the entire file contents into memory repeatedly and allocating new file IDs *each time* a source location is processed. llvm-svn: 211874
* CodeGenAction: don't duplicate entire .ll/.bc files into memoryAlp Toker2014-06-271-6/+1
| | | | | | Requires supporting changes from LLVM r211861. llvm-svn: 211862
* [OPENMP] Initial parsing and sema analysis for 'single' directive.Alexey Bataev2014-06-263-0/+8
| | | | llvm-svn: 211774
* [OPENMP] Initial parsing and sema analysis for 'section' directive.Alexey Bataev2014-06-263-0/+8
| | | | llvm-svn: 211767
* Convert some function arguments to use ArrayRef.Craig Topper2014-06-261-1/+1
| | | | llvm-svn: 211764
* CodeGen: Improve warnings about uninstrumented files when profilingJustin Bogner2014-06-264-12/+51
| | | | | | | | | Improve the warning when building with -fprofile-instr-use and a file appears not to have been profiled at all. This keys on whether a function is defined in the main file or not to avoid false negatives when one includes a header with functions that have been profiled. llvm-svn: 211760
* PR20038: DebugInfo: Call sites without DebugLocs for temporary dtors after a ↵David Blaikie2014-06-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | conditional With && at the top level of an expression, the last thing done when emitting the expression was an unconditional jump to the cleanup block. To reduce the amount of stepping, the DebugLoc is omitted from the unconditional jump. This is done by clearing the IRBuilder's "CurrentDebugLocation"*. If this is not set to some non-empty value before the cleanup block is emitted, the cleanups don't get a location either. If a call without a location is emitted in a function with debug info, and that call is then inlined - bad things happen. (without a location for the call site, the inliner would just leave the inlined DebugLocs as they were - pointing to roots in the original function, not inlined into the current function) Follow up commit to LLVM will ensure that breaking the invariants of the DebugLoc chains by having chains that don't lead to the current function will fail assertions, so we shouldn't accidentally slip any of these cases in anymore. Those assertions may reveal further cases that need to be fixed in clang, though I've tried to test heavily to avoid that. * See r128471, r128513 for the code that clears the CurrentDebugLocation. Simply removing this code or moving the code into IRBuilder to apply to all unconditional branches would regress desired behavior, unfortunately. llvm-svn: 211722
* Rename loop unrolling and loop vectorizer metadata to have a common prefix.Eli Bendersky2014-06-253-13/+13
| | | | | | | | | | | | | | | | | | | [Clang part] These patches rename the loop unrolling and loop vectorizer metadata such that they have a common 'llvm.loop.' prefix. Metadata name changes: llvm.vectorizer.* => llvm.loop.vectorizer.* llvm.loopunroll.* => llvm.loop.unroll.* This was a suggestion from an earlier review (http://reviews.llvm.org/D4090) which added the loop unrolling metadata. Patch by Mark Heffernan. llvm-svn: 211712
* [OPENMP] Initial support for 'sections' directive.Alexey Bataev2014-06-253-1/+10
| | | | llvm-svn: 211685
* Add R600 builtin codegen.Matt Arsenault2014-06-242-0/+38
| | | | llvm-svn: 211631
* Correctly Load Mixed FP-GP Variadic Arguments for x86-64.Rafael Espindola2014-06-241-2/+2
| | | | | | | | | | | | | | | | | | | | According to the x86-64 ABI, structures with both floating point and integer members are split between floating-point and general purpose registers, and consecutive 32-bit floats can be packed into a single floating point register. In the case of variadic functions these are stored to memory and the position recorded in the va_list. This was already correctly implemented in llvm.va_start. The problem is that the code in clang for implementing va_arg was reading floating point registers from the wrong location. Patch by Thomas Jablin. Fixes PR20018. llvm-svn: 211626
* Add new debug kind LocTrackingOnly.Diego Novillo2014-06-242-13/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This new debug emission kind supports emitting line location information in all instructions, but stops code generation from emitting debug info to the final output. This mode is useful when the backend wants to track source locations during code generation, but it does not want to produce debug info. This is currently used by optimization remarks (-Rpass, -Rpass-missed and -Rpass-analysis). When one of the -Rpass flags is used, the front end will enable location tracking, only if no other debug option is enabled. To prevent debug information from being generated, a new debug info kind LocTrackingOnly causes DIBuilder::createCompileUnit() to not emit the llvm.dbg.cu annotation. This blocks final code generation from generating debug info in the back end. Depends on D4234. Reviewers: echristo, dblaikie Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4235 llvm-svn: 211610
* ARM: remove dead CodeGen functions.Tim Northover2014-06-242-33/+0
| | | | | | These two are no longer being used by NEON codegen. llvm-svn: 211586
* Fix spelling. s/overloaed/overloaded/Jim Grosbach2014-06-231-2/+2
| | | | llvm-svn: 211530
* CodeGen: Remove a stray tab character (NFC)Justin Bogner2014-06-231-1/+1
| | | | llvm-svn: 211528
* Revert "Revert r211402 (and r211408,r211410), "CodeGen: Refactor ↵David Majnemer2014-06-224-366/+427
| | | | | | | | | dynamic_cast and typeid" It crashes msvc codegen in clang/test/SemaCXX/undefined-internal.cpp." This reverts commit r211467 which reverted r211408,r211410, it caused crashes in test/SemaCXX/undefined-internal.cpp for i686-win32 targets. llvm-svn: 211473
* Revert r211402 (and r211408,r211410), "CodeGen: Refactor dynamic_cast and ↵NAKAMURA Takumi2014-06-224-430/+366
| | | | | | | | | | typeid" It crashes msvc codegen in clang/test/SemaCXX/undefined-internal.cpp. It is reproducible with: $ clang -cc1 -triple i686-win32 -emit-llvm-only clang/test/SemaCXX/undefined-internal.cpp llvm-svn: 211467
* CodeGen: Refactor dynamic_cast and typeidDavid Majnemer2014-06-204-366/+430
| | | | | | | | | | | This refactors the emission of dynamic_cast and typeid expressions so that ABI specific knowledge lives in appropriate places. There are quite a few benefits for having the two implementations share a common core like sharing logic for optimization opportunities. While we are at it, clean up the tests. llvm-svn: 211402
* Don't crash when emitting a glvalue conditional where one arm is aRichard Smith2014-06-201-10/+32
| | | | | | throw-expression. Based on a patch by Marius Wachtler! llvm-svn: 211388
* [PowerPC] Fix small argument stack slot offset for LEUlrich Weigand2014-06-201-3/+7
| | | | | | | | | | | | | | | | | When small arguments (structures < 8 bytes or "float") are passed in a stack slot in the ppc64 SVR4 ABI, they must reside in the least significant part of that slot. On BE, this means that an offset needs to be added to the stack address of the parameter, but on LE, the least significant part of the slot has the same address as the slot itself. For the most part, this is handled in the LLVM back-end, where I just fixed the LE case in commit r211368. However, there is one piece of the clang front-end that is also aware of these stack-slot offsets: PPC64_SVR4_ABIInfo::EmitVAArg. This patch updates that routine to take endianness into account. llvm-svn: 211370
* Add module flags metadata to record the settings for enum and wchar widthOliver Stannard2014-06-201-0/+17
| | | | | | | Add module flags metadata to record the settings for enum and wchar width, to allow correct ARM build attribute generation llvm-svn: 211354
* [MS-ABI] Implement typeidWarren Hunt2014-06-181-2/+35
| | | | | | | This patch enables clang to generate calls to __RTtypeid when lowering typeid on win32 targets. Test cases are included. llvm-svn: 211223
* CodeGen: improve ms instrincics supportSaleem Abdulrasool2014-06-181-0/+29
| | | | | | | | | Add support for _InterlockedCompareExchangePointer, _InterlockExchangePointer, _InterlockExchange. These are available as a compiler intrinsic on ARM and x86. These are used directly by the Windows SDK headers without use of the intrin header. llvm-svn: 211216
* Inherit dll attributes to static localsHans Wennborg2014-06-182-2/+10
| | | | | | | | This makes us handle static locals in exported/imported functions correctly. Differential Revision: http://reviews.llvm.org/D4136 llvm-svn: 211173
* [OPENMP] Reformatting and code improvement.Alexey Bataev2014-06-183-22/+20
| | | | llvm-svn: 211147
* [OPENMP] Initial support for '#pragma omp for' (fixed incompatibility with ↵Alexey Bataev2014-06-183-0/+7
| | | | | | MSVC). llvm-svn: 211140
* Revert "[OPENMP] Initial support for '#pragma omp for'."Rafael Espindola2014-06-173-7/+0
| | | | | | | | This reverts commit r211096. Looks like it broke the msvc build: SemaOpenMP.cpp(140) : error C4519: default template arguments are only allowed on a class template llvm-svn: 211113
OpenPOWER on IntegriCloud