summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove unused Args parameter from EmitFunctionBody, NFCReid Kleckner2018-12-132-4/+3
| | | | llvm-svn: 349001
* Emit a proper diagnostic when attempting to forward inalloca argumentsReid Kleckner2018-12-121-2/+3
| | | | | | | | | | The previous assertion was relatively easy to trigger, and likely will be easy to trigger going forward. EmitDelegateCallArg is relatively popular. This cleanly diagnoses PR28299 while I work on a proper solution. llvm-svn: 348991
* Revert "Declares __cpu_model as dso local"Haibo Huang2018-12-121-5/+0
| | | | | | This reverts r348978 llvm-svn: 348982
* Declares __cpu_model as dso localHaibo Huang2018-12-121-0/+5
| | | | | | | | __builtin_cpu_supports and __builtin_cpu_is use information in __cpu_model to decide cpu features. Before this change, __cpu_model was not declared as dso local. The generated code looks up the address in GOT when reading __cpu_model. This makes it impossible to use these functions in ifunc, because at that time GOT entries have not been relocated. This change makes it dso local. Differential Revision: https://reviews.llvm.org/D53850 llvm-svn: 348978
* Teach __builtin_unpredictable to work through implicit casts.Erich Keane2018-12-121-1/+1
| | | | | | | | | The __builtin_unpredictable implementation is confused by any implicit casts, which happen in C++. This patch strips those off so that if/switch statements now work with it in C++. Change-Id: I73c3bf4f1775cd906703880944f4fcdc29fffb0a llvm-svn: 348969
* Revert "[OpenCL] Add generic AS to 'this' pointer"Mikael Nilsson2018-12-126-34/+14
| | | | | | Reverting because the patch broke lldb. llvm-svn: 348931
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-126-14/+34
| | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 348927
* [OpenCL] Fix for TBAA information of pointer after addresspacecastAndrew Savonichev2018-12-121-2/+3
| | | | | | | | | | | | | | Summary: When addresspacecast is generated resulting pointer should preserve TBAA information from original value. Reviewers: rjmccall, yaxunl, Anastasia Reviewed By: rjmccall Subscribers: asavonic, kosarev, cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D55262 llvm-svn: 348919
* [CodeGen] Fix -DBUILD_SHARED_LIBS=on build after rC348907Fangrui Song2018-12-121-0/+1
| | | | llvm-svn: 348911
* Remove CGDebugInfo::getOrCreateFile() and use TheCU->getFile() directly.Adrian Prantl2018-12-112-26/+16
| | | | llvm-svn: 348866
* Reuse code from CGDebugInfo::getOrCreateFile() when creating the fileAdrian Prantl2018-12-112-9/+17
| | | | | | | | | | | | | for the DICompileUnit. This addresses post-commit feedback for D55085. Without this patch, a main source file with an absolute paths may appear in different DIFiles, once with the absolute path and once with the common prefix between the absolute path and the current working directory. Differential Revision: https://reviews.llvm.org/D55519 llvm-svn: 348865
* Move CodeGenOptions from Frontend to BasicRichard Trieu2018-12-1124-24/+21
| | | | | | Basic uses CodeGenOptions and should not depend on Frontend. llvm-svn: 348827
* Misc typos fixes in ./lib folderRaphael Isemann2018-12-108-15/+15
| | | | | | | | | | | | | | Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned` Reviewers: teemperor Reviewed By: teemperor Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D55475 llvm-svn: 348755
* [OpenCL][CodeGen] Fix replacing memcpy with addrspacecastAndrew Savonichev2018-12-101-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If a function argument is byval and RV is located in default or alloca address space an optimization of creating addrspacecast instead of memcpy is performed. That is not correct for OpenCL, where that can lead to a situation of address space casting from __private * to __global *. See an example below: ``` typedef struct { int x; } MyStruct; void foo(MyStruct val) {} kernel void KernelOneMember(__global MyStruct* x) { foo (*x); } ``` for this code clang generated following IR: ... %0 = load %struct.MyStruct addrspace(1)*, %struct.MyStruct addrspace(1)** %x.addr, align 4 %1 = addrspacecast %struct.MyStruct addrspace(1)* %0 to %struct.MyStruct* ... So the optimization was disallowed for OpenCL if RV is located in an address space different than that of the argument (0). Reviewers: yaxunl, Anastasia Reviewed By: Anastasia Subscribers: cfe-commits, asavonic Differential Revision: https://reviews.llvm.org/D54947 llvm-svn: 348752
* [X86] Remove the addcarry builtins. Leaving only the addcarryx builtins ↵Craig Topper2018-12-101-12/+4
| | | | | | | | | | since that matches gcc. The addcarry and addcarryx builtins do the same thing. The only difference is that addcarryx previously required adx feature. This commit removes the adx feature check from addcarryx and removes the addcarry builtin. This matches the builtins that gcc has. We don't guarantee compatibility in builtins, but we generally try to be consistent if its not a burden. llvm-svn: 348738
* Convert some ObjC msgSends to runtime calls.Pete Cooper2018-12-083-14/+99
| | | | | | | | | | | | | | It is faster to directly call the ObjC runtime for methods such as alloc/allocWithZone instead of sending a message to those functions. This patch adds support for converting messages to alloc/allocWithZone to their equivalent runtime calls. Tests included for the positive case of applying this transformation, negative tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and also a driver test to ensure we enable this only for supported runtime versions. Reviewed By: rjmccall https://reviews.llvm.org/D55349 llvm-svn: 348687
* Make CPUDispatch resolver emit dependent functions.Erich Keane2018-12-071-2/+13
| | | | | | | | | | Inline cpu_specific versions referenced before the cpu_dispatch function weren't properly emitted, since they hadn't been referred to. This patch ensures that during resolver generation that all appropriate versions are emitted. Change-Id: I94c3766aaf9c75ca07a0ad8258efdbb834654ff8 llvm-svn: 348600
* Fix thunks returning memptrs via sret by emitting also scalar return values ↵Hans Wennborg2018-12-072-5/+3
| | | | | | | | | | | | | | | | | | | directly in sret slot (PR39901) Thunks that return member pointers via sret are broken due to using temporary storage for the return value on the stack and then passing that pointer to a tail call, violating the rule that a tail call can't access allocas in the caller (see bug). Since r90526, we put aggregate return values directly in the sret slot, but this doesn't apply to member pointers which are considered scalar. Unless I'm missing something subtle, we should be able to always use the sret slot directly for indirect return values. Differential revision: https://reviews.llvm.org/D55371 llvm-svn: 348569
* Reapply "Avoid emitting redundant or unusable directories in DIFile metadata ↵Adrian Prantl2018-12-062-15/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | entries."" This reverts commit r348280 and reapplies D55085 without modifications. Original commit message: Avoid emitting redundant or unusable directories in DIFile metadata entries. As discussed on llvm-dev recently, Clang currently emits redundant directories in DIFile entries, such as .file 1 "/Volumes/Data/llvm" "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c" This patch looks at any common prefix between the compilation directory and the (absolute) file path and strips the redundant part. More importantly it leaves the compilation directory empty if the two paths have no common prefix. After this patch the above entry is (assuming a compilation dir of "/Volumes/Data/llvm/_build"): .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c" When building the FileCheck binary with debug info, this patch makes the build artifacts ~1kb smaller. Differential Revision: https://reviews.llvm.org/D55085 llvm-svn: 348513
* [OPENMP][NVPTX] Fix globalization of the mapped array sections.Alexey Bataev2018-12-061-3/+5
| | | | | | | | | If the array section is based on pointer and this sections is mapped in target region + then it is used in the inner parallel region, it also must be globalized as the pointer itself is passed by value, not by reference. llvm-svn: 348492
* Remove unnecessary include.Richard Trieu2018-12-061-1/+0
| | | | llvm-svn: 348459
* Remove CodeGen dependencies on Sema.Richard Trieu2018-12-064-4/+3
| | | | | | | Move diagnostics from Sema to Frontend (or Common) so that CodeGen no longer needs to include the Sema diagnostic IDs. llvm-svn: 348458
* Honor -fdebug-prefix-map when creating function names for the debug info.Adrian Prantl2018-12-052-3/+6
| | | | | | | | | | | | | This adds a callback to PrintingPolicy to allow CGDebugInfo to remap file paths according to -fdebug-prefix-map. Otherwise the debug info (particularly function names for C++ lambdas) may contain paths that should have been remapped in the debug info. <rdar://problem/46128056> Differential Revision: https://reviews.llvm.org/D55137 llvm-svn: 348397
* Revert: Honor -fdebug-prefix-map when creating function names for the debug ↵Renato Golin2018-12-052-6/+3
| | | | | | | | | info. This commit reverts r348060 and r348062 due to it breaking the AArch64 Full buildbot: https://bugs.llvm.org/show_bug.cgi?id=39892 llvm-svn: 348364
* [asan] Add clang flag -fsanitize-address-use-odr-indicatorVitaly Buka2018-12-051-2/+4
| | | | | | | | | | Reviewers: eugenis, m.ostapenko, ygribov Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D55157 llvm-svn: 348327
* Revert "Avoid emitting redundant or unusable directories in DIFile metadata ↵Ilya Biryukov2018-12-042-48/+15
| | | | | | | | | | entries." This reverts commit r348154 and follow-up commits r348211 and r3248213. Reason: the original commit broke compiler-rt tests and a follow-up fix (r348203) broke our integrate and was reverted. llvm-svn: 348280
* [OPENMP][NVPTX]Fixed emission of the critical region.Alexey Bataev2018-12-041-2/+4
| | | | | | | | | | | | | Critical regions in NVPTX are the constructs, which, generally speaking, are not supported by the NVPTX target. Instead we're using special technique to handle the critical regions. Currently they are supported only within the loop and all the threads in the loop must execute the same critical region. Inside of this special regions the regions still must be emitted as critical, to avoid possible data races between the teams + synchronization must use __kmpc_barrier functions. llvm-svn: 348272
* [OPENMP][NVPTX]Mark __kmpc_barrier functions as convergent.Alexey Bataev2018-12-044-7/+53
| | | | | | | | __kmpc_barrier runtime functions must be marked as convergent to prevent some dangerous optimizations. Also, for NVPTX target all barriers must be emitted as simple barriers. llvm-svn: 348271
* Remove unnecessary include.Richard Trieu2018-12-041-1/+0
| | | | llvm-svn: 348238
* Avoid emitting redundant or unusable directories in DIFile metadata entries.Adrian Prantl2018-12-032-15/+48
| | | | | | | | | | | | | | | | | | | | | | | As discussed on llvm-dev recently, Clang currently emits redundant directories in DIFile entries, such as .file 1 "/Volumes/Data/llvm" "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c" This patch looks at any common prefix between the compilation directory and the (absolute) file path and strips the redundant part. More importantly it leaves the compilation directory empty if the two paths have no common prefix. After this patch the above entry is (assuming a compilation dir of "/Volumes/Data/llvm/_build"): .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c" When building the FileCheck binary with debug info, this patch makes the build artifacts ~1kb smaller. Differential Revision: https://reviews.llvm.org/D55085 llvm-svn: 348154
* Correct indentation.Bill Wendling2018-12-011-1/+1
| | | | llvm-svn: 348071
* Specify constant context in constant emitterBill Wendling2018-12-012-1/+5
| | | | | | | The constant emitter may need to evaluate the expression in a constant context. For exasmple, global initializer lists. llvm-svn: 348070
* Honor -fdebug-prefix-map when creating function names for the debug info.Adrian Prantl2018-12-012-3/+6
| | | | | | | | | | | | | This adds a callback to PrintingPolicy to allow CGDebugInfo to remap file paths according to -fdebug-prefix-map. Otherwise the debug info (particularly function names for C++ lambdas) may contain paths that should have been remapped in the debug info. <rdar://problem/46128056> Differential Revision: https://reviews.llvm.org/D55137 llvm-svn: 348060
* Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures.""Fangrui Song2018-11-307-30/+67
| | | | | | | | | It seems the two failing tests can be simply fixed after r348037 Fix 3 cases in Analysis/builtin-functions.cpp Delete the bad CodeGen/builtin-constant-p.c for now llvm-svn: 348053
* Revert r347417 "Re-Reinstate 347294 with a fix for the failures."Fangrui Song2018-11-307-67/+30
| | | | | | | | | | Kept the "indirect_builtin_constant_p" test case in test/SemaCXX/constant-expression-cxx1y.cpp while we are investigating why the following snippet fails: extern char extern_var; struct { int a; } a = {__builtin_constant_p(extern_var)}; llvm-svn: 348039
* Revert r348029. I was git-ing and jumped the gun.Bill Wendling2018-11-301-2/+1
| | | | llvm-svn: 348032
* We're in a constant context in the ConstantEmitter.Bill Wendling2018-11-301-1/+2
| | | | llvm-svn: 348029
* [-gmodules] Honor -fdebug-prefix-map in the debug info inside PCMs.Adrian Prantl2018-11-291-0/+2
| | | | | | | | | | | | This patch passes -fdebug-prefix-map (a feature for renaming source paths in the debug info) through to the per-module codegen options and adds the debug prefix map to the module hash. <rdar://problem/46045865> Differential Revision: https://reviews.llvm.org/D55037 llvm-svn: 347926
* [OPENMP][NVPTX]Call get __kmpc_global_thread_num in worker afterAlexey Bataev2018-11-291-0/+4
| | | | | | | | | initialization. Function __kmpc_global_thread_num should be called only after initialization, not earlier. llvm-svn: 347919
* [OpenMP] Add a new version of the SPMD deinit kernel functionGheorghe-Teodor Bercea2018-11-291-7/+11
| | | | | | | | | | | | | | Summary: This patch adds a new runtime for the SPMD deinit kernel function which replaces the previous function. The new function takes as argument the flag which signals whether the runtime is required or not. This enables the compiler to optimize out the part of the deinit function which are not needed. Reviewers: ABataev, caomhin Reviewed By: ABataev Subscribers: jholewinski, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D54970 llvm-svn: 347915
* [ThinLTO] Allow importing of multiple symbols with same GUIDTeresa Johnson2018-11-291-9/+8
| | | | | | | | | | | | | | | | | | | Summary: The is the clang side of the fix in D55047, to handle the case where two different modules have local variables with the same GUID because they had the same source file name at compilation time. Allow multiple symbols with the same GUID to be imported, and test that this case works with the distributed backend path. Depends on D55047. Reviewers: evgeny777 Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D55048 llvm-svn: 347887
* Ensure sanitizer check function calls have a !dbg locationAdrian Prantl2018-11-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | Function calls without a !dbg location inside a function that has a DISubprogram make it impossible to construct inline information and are rejected by the verifier. This patch ensures that sanitizer check function calls have a !dbg location, by carrying forward the location of the preceding instruction or by inserting an artificial location if necessary. This fixes a crash when compiling the attached testcase with -Os. rdar://problem/45311226 Differential Revision: https://reviews.llvm.org/D53459 Note: This reapllies r344915, modified to reuse the IRBuilder's DebugLoc if one exists instead of picking the one from CGDebugInfo since the latter may get reset when emitting thunks such as block helpers in the middle of emitting another function. llvm-svn: 347810
* Correct 'target' default behavior on redecl, allow forward declaration.Erich Keane2018-11-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | Declarations without the attribute were disallowed because it would be ambiguous which 'target' it was supposed to be on. For example: void ___attribute__((target("v1"))) foo(); void foo(); // Redecl of above, or fwd decl of below? void ___attribute__((target("v2"))) foo(); However, a first declaration doesn't have that problem, and erroring prevents it from working in cases where the forward declaration is useful. Additionally, a forward declaration of target==default wouldn't properly cause multiversioning, so this patch fixes that. The patch was not split since the 'default' fix would require implementing the same check for that case, followed by undoing the same change for the fwd-decl implementation. Change-Id: I66f2c5bc2477bcd3f7544b9c16c83ece257077b0 llvm-svn: 347805
* [Coverage] Do not visit artificial stmts in defaulted methods (PR39822)Vedant Kumar2018-11-281-4/+16
| | | | | | | | | | | | | | | | | | | | | | There is no reason to emit coverage mappings for artificial statements contained within defaulted methods, as these statements are not visible to users. Only emit a mapping for the body of the defaulted method (clang treats the text of the "default" keyword as the body when reporting locations). This allows users to see how often the default method is called, but trims down the coverage mapping by skipping visitation of the children of the method. The immediate motivation for this change is that the lexer's getPreciseTokenLocEnd API cannot return the correct location when given an artificial statement (with a somewhat made-up location) as an input. Test by Orivej Desh! Fixes llvm.org/PR39822. llvm-svn: 347803
* [NFC] Move MultIversioning::Type into Decl so that it can be used inErich Keane2018-11-281-2/+9
| | | | | | | CodeGen Change-Id: I32b14edca3501277e0e65672eafe3eea38c6f9ae llvm-svn: 347791
* Re-commit r347417 "Re-Reinstate 347294 with a fix for the failures."Hans Wennborg2018-11-287-30/+67
| | | | | | | This was reverted in r347656 due to me thinking it caused a miscompile of Chromium. Turns out it was the Chromium code that was broken. llvm-svn: 347756
* Move LoopHint.h from Sema to ParseRichard Trieu2018-11-282-2/+0
| | | | | | | | struct LoopHint was only used within Parse and not in any of the Sema or Codegen files. In the non-Parse files where it was included, it either wasn't used or LoopHintAttr was used, so its inclusion did nothing. llvm-svn: 347728
* [CodeGen] Fix included headers.Richard Trieu2018-11-281-1/+2
| | | | | | | Remove the included Parse header because CodeGen should not depend on Parse. Instead, include the Lex headers that it needs instead. llvm-svn: 347727
* [OPENMP][NVPTX]Basic support for reductions across the teams.Alexey Bataev2018-11-272-379/+118
| | | | | | Added basic codegen support for the reductions across the teams. llvm-svn: 347715
* [clang][slh] add attribute for speculative load hardeningZola Bridges2018-11-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Resubmit this with no changes because I think the build was broken by a different diff. ----- The prior diff had to be reverted because there were two tests that failed. I updated the two tests in this diff clang/test/Misc/pragma-attribute-supported-attributes-list.test clang/test/SemaCXX/attr-speculative-load-hardening.cpp ----- Summary from Previous Diff (Still Accurate) ----- LLVM IR already has an attribute for speculative_load_hardening. Before this commit, when a user passed the -mspeculative-load-hardening flag to Clang, every function would have this attribute added to it. This Clang attribute will allow users to opt into SLH on a function by function basis. This can be applied to functions and Objective C methods. Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54915 llvm-svn: 347701
OpenPOWER on IntegriCloud