summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Fix for pacify buildbots, NFC.Alexey Bataev2017-08-041-18/+12
| | | | llvm-svn: 310120
* Reland "CFI: blacklist STL allocate() from unrelated-casts"Vlad Tsyrklevich2017-08-041-0/+27
| | | | | | | | Reland r310097 with a unit test fix for MS ABI build bots. Differential Revision: https://reviews.llvm.org/D36294 llvm-svn: 310105
* [OPENMP][DEBUG] Set proper address space info if required by target.Alexey Bataev2017-08-044-13/+174
| | | | | | | | | | | Arguments, passed to the outlined function, must have correct address space info for proper Debug info support. Patch sets global address space for arguments that are mapped and passed by reference. Also, cuda-gdb does not handle reference types correctly, so reference arguments are represented as pointers. llvm-svn: 310104
* Revert "CFI: blacklist STL allocate() from unrelated-casts"Vlad Tsyrklevich2017-08-041-27/+0
| | | | | | This reverts commit r310097. llvm-svn: 310099
* [OPENMP] Unify generation of outlined function calls.Alexey Bataev2017-08-044-12/+31
| | | | llvm-svn: 310098
* CFI: blacklist STL allocate() from unrelated-castsVlad Tsyrklevich2017-08-041-0/+27
| | | | | | | | | | | | | | | | | | | | | | Summary: Previously, STL allocators were blacklisted in compiler_rt's cfi_blacklist.txt because they mandated a cast from void* to T* before object initialization completed. This change moves that logic into the front end because C++ name mangling supports a substitution compression mechanism for symbols that makes it difficult to blacklist the mangled symbol for allocate() using a regular expression. Motivated by crbug.com/751385. Reviewers: pcc, kcc Reviewed By: pcc Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36294 llvm-svn: 310097
* Add OpenCL 2.0 atomic builtin functions as Clang builtinYaxun Liu2017-08-044-37/+183
| | | | | | | | | | | | | | | | | | | | | OpenCL 2.0 atomic builtin functions have a scope argument which is ideally represented as synchronization scope argument in LLVM atomic instructions. Clang supports translating Clang atomic builtin functions to LLVM atomic instructions. However it currently does not support synchronization scope of LLVM atomic instructions. Without this, users have to use LLVM assembly code to implement OpenCL atomic builtin functions. This patch adds OpenCL 2.0 atomic builtin functions as Clang builtin functions, which supports generating LLVM atomic instructions with synchronization scope operand. Currently only constant memory scope argument is supported. Support of non-constant memory scope argument will be added later. Differential Revision: https://reviews.llvm.org/D28691 llvm-svn: 310082
* Revert "[coverage] Special-case calls to noreturn functions."Vedant Kumar2017-08-041-12/+0
| | | | | | | | | | | This reverts commit r309995. It looks like it's responsible for breaking the stage2 coverage build: http://green.lab.llvm.org/green/job/clang-stage2-coverage-R_build/1402 The cfe-commits discussion re: r309995 has more context. llvm-svn: 310019
* [Coverage] Precise region termination with deferred regionsVedant Kumar2017-08-041-5/+86
| | | | | | | | | | | | | | | | | | | | | | | | The current coverage implementation doesn't handle region termination very precisely. Take for example an `if' statement with a `return': void f() { if (true) { return; // The `if' body's region is terminated here. } // This line gets the same coverage as the `if' condition. } If the function `f' is called, the line containing the comment will be marked as having executed once, which is not correct. The solution here is to create a deferred region after terminating a region. The deferred region is completed once the start location of the next statement is known, and is then pushed onto the region stack. In the cases where it's not possible to complete a deferred region, it can safely be dropped. Testing: lit test updates, a stage2 coverage-enabled build of clang llvm-svn: 310010
* [coverage] Special-case calls to noreturn functions.Eli Friedman2017-08-031-0/+12
| | | | | | | | | | | The code after a noreturn call doesn't execute. The pattern in the testcase is pretty common in LLVM (a switch with a default case that calls llvm_unreachable). Differential Revision: https://reviews.llvm.org/D36250 llvm-svn: 309995
* [mips] Revert r309942 & r309940Simon Dardis2017-08-031-14/+0
| | | | | | | | This reverts commit r309942 & commit r309940. A revert was requested following post commit review. llvm-svn: 309978
* [mips] Implement -muninit-const-in-rodataSimon Dardis2017-08-031-0/+14
| | | | | | | | | | | This option when combined with -mgpopt and -membedded-data places all uninitialized constant variables in the read-only section. Reviewers: atanasyan, nitesh.jain Differential Revision: https://reviews.llvm.org/D35917 llvm-svn: 309940
* Update for llvm change.Rafael Espindola2017-08-031-10/+12
| | | | llvm-svn: 309912
* [coverage] Make smaller regions for the first case of a switch.Eli Friedman2017-08-021-6/+13
| | | | | | | | | | | | | We never overwrite the end location of a region, so we would end up with an overly large region when we reused the switch's region. It's possible this code will be substantially rewritten in the near future to deal with fallthrough more accurately, but this seems like an improvement on its own for now. Differential Revision: https://reviews.llvm.org/D34801 llvm-svn: 309901
* [ubsan] Have -fsanitize=vptr emit a null check if -fsanitize=null isn't ↵Vedant Kumar2017-08-021-4/+4
| | | | | | | | | | | | | | | | | | available In r309007, I made -fsanitize=null a hard prerequisite for -fsanitize=vptr. I did not see the need for the two checks to have separate null checking logic for the same pointer. I expected the two checks to either always be enabled together, or to be mutually compatible. In the mailing list discussion re: r309007 it became clear that that isn't the case. If a codebase is -fsanitize=vptr clean but not -fsanitize=null clean, it's useful to have -fsanitize=vptr emit its own null check. That's what this patch does: with it, -fsanitize=vptr can be used without -fsanitize=null. Differential Revision: https://reviews.llvm.org/D36112 llvm-svn: 309846
* Fix creating bitcasts with wrong address spaceMatt Arsenault2017-08-011-2/+4
| | | | | | | | In a future commit AMDGPU will start passing aggregates directly to more functions, triggering asserts in test/CodeGenOpenCL/addr-space-struct-arg.cl llvm-svn: 309741
* [OpenCL] Add missing subgroup builtinsJoey Gouly2017-08-011-0/+19
| | | | | | | This adds get_kernel_max_sub_group_size_for_ndrange and get_kernel_sub_group_count_for_ndrange. llvm-svn: 309678
* Re-apply r309622 with a fix for MSVC.Peter Collingbourne2017-07-311-5/+4
| | | | | | Patch by Vlad Tsyrklevich! llvm-svn: 309635
* Revert r309622, "Fix logic for generating llvm.type.test()s"Peter Collingbourne2017-07-311-4/+5
| | | | | | | Caused a bot test failure: http://bb.pgr.jp/builders/test-clang-msc-x64-on-i686-linux-RA/builds/5325 llvm-svn: 309624
* Fix logic for generating llvm.type.test()sPeter Collingbourne2017-07-311-5/+4
| | | | | | | | | | | | | | CodeGenFunction::EmitTypeMetadataCodeForVCall() could output an llvm.assume(llvm.type.test())when CFI was enabled, optimizing out the vcall check. This case was only reached when: 1) CFI-vcall was enabled, 2) -fwhole-program-tables was specified, and 3) -fno-sanitize-trap=cfi-vcall was specified. Patch by Vlad Tsyrklevich! Differential Revision: https://reviews.llvm.org/D36013 llvm-svn: 309622
* [OPENMP] Change the name of outer non-debug function in debug mode, NFC.Alexey Bataev2017-07-311-2/+4
| | | | llvm-svn: 309575
* [coroutines] Evaluate the operand of void `co_return` expressions.Eric Fiselier2017-07-311-0/+7
| | | | | | | | | | | | | | | | | Summary: Previously Clang incorrectly ignored the expression of a void `co_return`. This patch addresses that bug. I'm not quite sure if I got the code-gen right, but this patch is at least a start. Reviewers: rsmith, GorNishanov Reviewed By: rsmith, GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36070 llvm-svn: 309545
* CodeGenModule.cpp: [PR33810][Modules] Remove an assertion that confirms ↵NAKAMURA Takumi2017-07-301-2/+0
| | | | | | | MangledDeclNames[CanonicalGD] might be still empty. FIXME: It is accepted that MangledDeclNames[CanonicalGD] is overwritten here? llvm-svn: 309504
* CodeGenModule.cpp: [PR33810][Modules] Avoid reusing FoundStr to try to fix ↵NAKAMURA Takumi2017-07-301-6/+6
| | | | | | | | crash. MangledDeclNames might grow up and be reallocated when it were reused by reentering CodeGenModule::getMangledName(). llvm-svn: 309501
* CodeGenModule.cpp: [PR33810][Modules] Make sure actual memory corruption ↵NAKAMURA Takumi2017-07-301-0/+2
| | | | | | before random crash with -fmodules. llvm-svn: 309499
* Fix incorrect assertion condition.Victor Leschuk2017-07-291-2/+2
| | | | llvm-svn: 309484
* [ubsan] Diagnose invalid uses of builtins (clang)Vedant Kumar2017-07-292-2/+34
| | | | | | | | | | | | | | | On some targets, passing zero to the clz() or ctz() builtins has undefined behavior. I ran into this issue while debugging UB in __hash_table from libcxx: the bug I was seeing manifested itself differently under -O0 vs -Os, due to a UB call to clz() (see: libcxx/r304617). This patch introduces a check which can detect UB calls to builtins. llvm.org/PR26979 Differential Revision: https://reviews.llvm.org/D34590 llvm-svn: 309459
* Adopt to LLVM API change (llvm.dbg.value no longer has an offset)Adrian Prantl2017-07-281-1/+1
| | | | llvm-svn: 309427
* [sanitizer-coverage] clang flags pumbing for -fsanitize-coverage=pc-tableKostya Serebryany2017-07-281-0/+1
| | | | llvm-svn: 309338
* Revert r264998 and r265035.Akira Hatanaka2017-07-271-2/+10
| | | | | | | | | | r303175 made changes to have __cxa_allocate_exception return a 16-byte aligned pointer, so it's no longer necessary to specify a lower alignment (8-bytes) for exception objects on Darwin. rdar://problem/32363695 llvm-svn: 309308
* Fix double destruction of objects when OpenMP construct is canceledErich Keane2017-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an omp for loop is canceled the constructed objects are being destructed twice. It looks like the desired code is: { Obj o; If (cancelled) branch-through-cleanups to cancel.exit. } [cleanups] cancel.exit: __kmpc_for_static_fini br cancel.cont (*) cancel.cont: __kmpc_barrier return The problem seems to be the branch to cancel.cont is currently also going through the cleanups calling them again. This change just does a direct branch instead. Patch By: michael.p.rice@intel.com Differential Revision: https://reviews.llvm.org/D35854 llvm-svn: 309288
* Make new PM honor -fdebug-info-for-profiling (clang side)Dehao Chen2017-07-271-22/+21
| | | | | | | | | | | | | | Summary: The new PM needs to invoke add-discriminator pass when building with -fdebug-info-for-profiling. Reviewers: chandlerc, davidxl Reviewed By: chandlerc Subscribers: sanjoy, cfe-commits Differential Revision: https://reviews.llvm.org/D35746 llvm-svn: 309282
* [OPENMP] Codegen for 'in_reduction' clause.Alexey Bataev2017-07-271-0/+50
| | | | | | | | | | | | | | | | | | Added codegen for task-based directive with in_reduction clause. ``` <body> ``` The next code is emitted: ``` void *td; ... td = call i8* @__kmpc_task_reduction_init(); ... <type> *priv = (<type> *)call i8* @__kmpc_task_reduction_get_th_data(i32 GTID, i8* td, i8* <orig>) ``` llvm-svn: 309270
* [CodeGen][ARM] ARM runtime helper functions are not always soft-fpPeter Smith2017-07-271-10/+7
| | | | | | | Re-commit r309257 with less precise register checks in arm-float-helpers.c test. llvm-svn: 309263
* [CodeGen][ARM] Revert r309257Peter Smith2017-07-271-7/+10
| | | | | | | The test arm-float-helpers.c appears to be failing on some builders and needs some work to make it more robust. llvm-svn: 309259
* [CodeGen][ARM] ARM runtime helper functions are not always soft-fpPeter Smith2017-07-271-10/+7
| | | | | | | | | | | | | | | | | | | The ARM Runtime ABI document (IHI0043) defines the AEABI floating point helper functions in 4.1.2 The floating-point helper functions. These functions always use the base PCS (soft-fp). However helper functions defined outside of this document such as the complex-number multiply and divide helpers are not covered by this requirement and should use hard-float PCS if the target is hard-float as both compiler-rt and libgcc for a hard-float sysroot implement these functions with a hard-float PCS. All of the floating point helper functions that are explicitly soft float are expanded in the llvm ARM backend. This change makes clang not force the BuiltinCC to AAPCS for AAPCS_VFP. With this change the ARM compiler-rt tests involving _Complex pass with both hard-fp and soft-fp targets. Differential Revision: https://reviews.llvm.org/D35538 llvm-svn: 309257
* [Coverage] NFC: Simplify sanity checks with a SpellingRange utilityVedant Kumar2017-07-271-21/+41
| | | | | | This should simplify D35925. llvm-svn: 309245
* [Coverage] NFC: Save a pair of calls to get{Start,End}Vedant Kumar2017-07-271-3/+5
| | | | llvm-svn: 309244
* Add branch weights to branches for static initializers.Richard Smith2017-07-264-7/+57
| | | | | | | | | | | | | | | | | | | The initializer for a static local variable cannot be hot, because it runs at most once per program. That's not quite the same thing as having a low branch probability, but under the assumption that the function is invoked many times, modeling this as a branch probability seems reasonable. For TLS variables, the situation is less clear, since the initialization side of the branch can run multiple times in a program execution, but we still expect initialization to be rare relative to non-initialization uses. It would seem worthwhile to add a PGO counter along this path to make this estimation more accurate in future. For globals with guarded initialization, we don't yet apply any branch weights. Due to our use of COMDATs, the guard will be reached exactly once per DSO, but we have no idea how many DSOs will define the variable. llvm-svn: 309195
* [OpenCL] Fix access qualifiers metadata for kernel arguments with typedefAlexey Sotkin2017-07-261-1/+4
| | | | | | | | Subscribers: cfe-commits, yaxunl, Anastasia Differential Revision: https://reviews.llvm.org/D35420 llvm-svn: 309155
* [CodeGen] Correctly model std::byte's aliasing propertiesDavid Majnemer2017-07-251-0/+6
| | | | | | | | | | | | std::byte, when defined as an enum, needs to be given special treatment with regards to its aliasing properties. An array of std::byte is allowed to be used as storage for other types. This fixes PR33916. Differential Revision: https://reviews.llvm.org/D35824 llvm-svn: 309058
* [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)Vedant Kumar2017-07-251-5/+20
| | | | | | | | | | | | | | | | | | | The instrumentation generated by -fsanitize=vptr does not null check a user pointer before loading from it. This causes crashes in the face of UB member calls (this=nullptr), i.e it's causing user programs to crash only after UBSan is turned on. The fix is to make run-time null checking a prerequisite for enabling -fsanitize=vptr, and to then teach UBSan to reuse these run-time null checks to make -fsanitize=vptr safe. Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build Differential Revision: https://reviews.llvm.org/D35735 https://bugs.llvm.org/show_bug.cgi?id=33881 llvm-svn: 309007
* [OPENMP] Codegen for 'task_reduction' clause.Alexey Bataev2017-07-251-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added codegen for taskgroup directive with task_reduction clause. ``` <body> ``` The next code is emitted: ``` %struct.kmp_task_red_input_t red_init[n]; void *td; call void @__kmpc_taskgroup(%ident_t id, i32 gtid) ... red_init[i].shar = &<item>; red_init[i].size = sizeof(<item>); red_init[i].init = (void*)initializer_function; red_init[i].fini = (void*)destructor_function; red_init[i].comb = (void*)combiner_function; red_init[i].flags = flags; ... td = call i8* @__kmpc_task_reduction_init(i32 gtid, i32 n, i8* (void*)red_init); call void @__kmpc_end_taskgroup(%ident_t id, i32 gtid) void initializer_function(i8* priv) { *(<type>*)priv = <red_init>; ret void; } void destructor_function(i8* priv) { (<type>*)priv->~(); ret void; } void combiner_function(i8* inout, i8* in) { *(<type>*)inout = *(<type>*)inout <red_id> *(<type>*)in; ret void; } ``` llvm-svn: 308979
* [PM] Setup TargetLibraryInfo correctly for the new pass manager.Chandler Carruth2017-07-251-0/+8
| | | | | | | Without this, -fno-builtin and friends doesn't work. Added the obvious RUN lines to the test for -fno-builtin and they pass now. llvm-svn: 308967
* Debug Info: Avoid completing class types when a definition is in a module.Adrian Prantl2017-07-241-23/+27
| | | | | | | | | | This patch adds an early exit to CGDebugInfo::completeClassData() when compiling with -gmodules and the to-be-completed type is available in a clang module. rdar://problem/23599990 llvm-svn: 308938
* [CodeGen] Propagate dllexport to thunksShoaib Meenai2017-07-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under Windows Itanium, we need to export virtual and non-virtual thunks if the functions being thunked are exported. These thunks would previously inherit their dllexport attribute from the declaration, but r298330 changed declarations to not have dllexport attributes. We therefore need to add the dllexport attribute to the definition ourselves now. This is consistent with MinGW GCC's behavior. This redoes r306770 but limits the logic to Itanium. MicrosoftCXXABI's setThunkLinkage ensures that thunks aren't exported under that ABI, so I'm handling this in ItaniumCXXABI's setThunkLinkage for symmetry. We need to export these thunks because they can be referenced outside the library they're defined in. For example, if a child class without a key function inherits from a parent class with a key function, the parent's thunks will only be defined in the library with the key function, but the construction vtable for the parent in the child might be emitted outside the library (since the child doesn't have a key function), and it needs to reference the parent's thunks. We don't need to mark these thunks as imported since any references to them will occur in data, so the compiler can't generate the IAT load sequence anyway. Instead, we rely on the linker generating import thunks for the thunks. Differential Revision: https://reviews.llvm.org/D34972 llvm-svn: 308899
* Remove Bitrig: Clang ChangesErich Keane2017-07-211-1/+0
| | | | | | | | Bitrig code has been merged back to OpenBSD, thus the OS has been abandoned. Differential Revision: https://reviews.llvm.org/D35708 llvm-svn: 308797
* Complex Long Double classification In RegCall calling conventionErich Keane2017-07-211-13/+28
| | | | | | | | | | | | | This change is part of the RegCall calling convention support for LLVM. Existing RegCall implementation was extended to include correct handling of Complex Long Double type. Complex long double types should be returned/passed in memory and not register stack. This patch implements this behavior. Patch by: eandrews Differential Revision: https://reviews.llvm.org/D35259 llvm-svn: 308769
* [OPENMP] Initial support for 'in_reduction' clause.Alexey Bataev2017-07-211-0/+1
| | | | | | | Parsing/sema analysis for 'in_reduction' clause for task-based directives. llvm-svn: 308768
* [CodeGen][mips] Support `long_call/far/near` attributesSimon Atanasyan2017-07-204-44/+98
| | | | | | | | | | | This patch adds support for the `long_call`, `far`, and `near` attributes for MIPS targets. The `long_call` and `far` attributes are synonyms. All these attributes override `-mlong-calls` / `-mno-long-calls` command line options for particular function. Differential revision: https://reviews.llvm.org/D35479 llvm-svn: 308667
OpenPOWER on IntegriCloud