aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
AgeCommit message (Collapse)AuthorFilesLines
2017-07-06This reverts r305820 (ARMv.2-A FP16 vector intrinsics) because it showsSjoerd Meijer3-179/+7
problems in testing, see comments in D34161 for some more details. A fix is in progres in D35011, but a revert seems better now as the fix will probably take some more time to land. llvm-svn: 307277
2017-07-04[CodeGen] Check key function for typeinfo importShoaib Meenai1-3/+7
If the imported class does not have a key function, we should emit its typeinfo locally instead of attempting to import it. llvm-svn: 307052
2017-07-03fix trivial typos in comments; NFCHiroshi Inoue2-2/+2
llvm-svn: 307007
2017-07-01Changed Opts.EABIVersion type string to llvm::EABI enum classYuka Takahashi1-5/+1
Summary: Changed EABIVersion type from string to llvm::EABI. It seems it was just a typo and this is intended implementation. Differential Revision: https://reviews.llvm.org/D34595 llvm-svn: 306953
2017-07-01Un-revert "[Driver] Add -fdiagnostics-hotness-threshold"Brian Gesiak1-0/+3
Summary: Un-revert https://reviews.llvm.org/D34868, but with a slight tweak to the documentation to fix an error -- I had used the wrong syntax for a link. llvm-svn: 306948
2017-07-01Revert "[Driver] Add -fdiagnostics-hotness-threshold"Brian Gesiak1-3/+0
Summary: The commit caused a documentation breakage. llvm-svn: 306946
2017-07-01[Driver] Add -fdiagnostics-hotness-thresholdBrian Gesiak1-0/+3
Summary: Depends on https://reviews.llvm.org/D34867. Add a Clang frontend option to enable optimization remark hotness thresholds, which were added to LLVM in https://reviews.llvm.org/D34867. This prevents diagnostics that do not meet a minimum hotness threshold from being output. When generating optimization remarks for large codebases with a ton of cold code paths, this option can be used to limit the optimization remark output at a reasonable size. Discussion of this change can be read here: http://lists.llvm.org/pipermail/llvm-dev/2017-June/114377.html Reviewers: anemet, davidxl, hfinkel Reviewed By: anemet Subscribers: fhahn, cfe-commits Differential Revision: https://reviews.llvm.org/D34868 llvm-svn: 306945
2017-06-30[Profile] Do not assign counters to functions without bodiesVedant Kumar1-0/+3
The root cause of the issues reported in D32406 and D34680 is that clang instruments functions without bodies. Make it stop doing that, and also teach it how to use old (incorrectly generated) profiles without crashing. llvm-svn: 306883
2017-06-30[ORE] Use LLVM's "diagnostics hotness" spellingBrian Gesiak1-2/+2
Summary: Depends on https://reviews.llvm.org/D34864. To unify Clang and LLVM's spelling of "diagnostic[s] hotness", use the new "diagnostics hotness" spelling in LLVM, which was added in https://reviews.llvm.org/D34864. Reviewers: anemet, davidxl Reviewed By: anemet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34865 llvm-svn: 306862
2017-06-30[objc] Don't require null-check and don't emit memset when result is ignored ↵Kuba Mracek1-11/+22
for struct-returning method calls [clang part] This fixes an issue with the emission of lifetime markers for struct-returning Obj-C msgSend calls. When the result of a struct-returning call is ignored, the temporary storage is only marked with lifetime markers in one of the two branches of the nil-receiver-check. The check is, however, not required when the result is unused. If we still need to emit the check (due to consumer arguments), let's not emit the memset to zero out the result if it's unused. This fixes a use-after-scope false positive with AddressSanitizer. Differential Revision: https://reviews.llvm.org/D34834 llvm-svn: 306837
2017-06-30Revert "[CodeGen] Propagate dllexport to thunks"Reid Kleckner1-4/+0
This reverts r306770, it causes LNK4102 warnings in MSVC builds. llvm-svn: 306835
2017-06-30Remove Clang support for '-fvectorize-slp-aggressive' which used LLVM'sChandler Carruth1-1/+0
basic block vectorizer. This vectorizer has had no known users for many, many years and is completely surpassed by the normal '-fvectorize-slp'-controlled SLP vectorizer in LLVM. Hal proposed this back in 2014 to no objections: http://lists.llvm.org/pipermail/llvm-dev/2014-November/079091.html While this patch completely removes the flag, Joerg is working on a patch that will add it back in a way that warns users and ignores the flag in a clear and well factored way (so that we can keep doing this going forward). Differential Revision: https://reviews.llvm.org/D34846 llvm-svn: 306786
2017-06-30[WebAssembly] Add throw/rethrow builtins for exception handlingHeejin Ahn1-0/+10
Summary: Add new builtins for throw/rethrow instructions. This follows exception handling handling proposal in https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md Reviewers: sunfish, dschuff Reviewed By: dschuff Subscribers: jfb, dschuff, sbc100, jgravelle-google Differential Revision: https://reviews.llvm.org/D34783 llvm-svn: 306775
2017-06-30[CodeGen] Propagate dllexport to thunksShoaib Meenai1-0/+4
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. Differential Revision: https://reviews.llvm.org/D34850 llvm-svn: 306770
2017-06-29[PM] Add support for sample PGO in the new pass manager (clang-side)Dehao Chen1-1/+5
Summary: This implements the clang bits of https://reviews.llvm.org/D34720, and add corresponding test to verify if it worked. Reviewers: chandlerc, davidxl, davide, tejohnson Reviewed By: chandlerc, tejohnson Subscribers: tejohnson, sanjoy, mehdi_amini, eraman, cfe-commits Differential Revision: https://reviews.llvm.org/D34721 llvm-svn: 306764
2017-06-29[NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.Tim Shen1-4/+7
Differential Revision: https://reviews.llvm.org/D34790 llvm-svn: 306757
2017-06-29[ThinkLTO] Invoke build(Thin)?LTOPreLinkDefaultPipeline.Tim Shen1-4/+16
Previously it doesn't actually invoke the designated new PM builder functions. This patch moves NameAnonGlobalPass out from PassBuilder, as Chandler points out that PassBuilder is used for non-O0 builds, and for optimizations only. Differential Revision: https://reviews.llvm.org/D34728 llvm-svn: 306756
2017-06-29CodeGen: Fix invalid bitcast for coerced function argumentYaxun Liu1-3/+2
Clang assumes coerced function argument is in address space 0, which is not always true and results in invalid bitcasts. This patch fixes failure in OpenCL conformance test api/get_kernel_arg_info with amdgcn---amdgizcl triple, where non-zero alloca address space is used. Differential Revision: https://reviews.llvm.org/D34777 llvm-svn: 306721
2017-06-29[OPENMP][DEBUG] Generate second function with correct arg types.Alexey Bataev2-64/+157
Currently, if the some of the parameters are captured by value, this argument is converted to uintptr_t type and thus we loosing the debug info about real type of the argument (captured variable): ``` void @.outlined_function.(uintptr %par); ... %a = alloca i32 %a.casted = alloca uintptr %cast = bitcast uintptr* %a.casted to i32* %a.val = load i32, i32 *%a store i32 %a.val, i32 *%cast %a.casted.val = load uintptr, uintptr* %a.casted call void @.outlined_function.(uintptr %a.casted.val) ... ``` To resolve this problem, in debug mode a speciall external wrapper function is generated, that calls the outlined function with the correct parameters types: ``` void @.wrapper.(uintptr %par) { %a = alloca i32 %cast = bitcast i32* %a to uintptr* store uintptr %par, uintptr *%cast %a.val = load i32, i32* %a call void @.outlined_function.(i32 %a) ret void } void @.outlined_function.(i32 %par); ... %a = alloca i32 %a.casted = alloca uintptr %cast = bitcast uintptr* %a.casted to i32* %a.val = load i32, i32 *%a store i32 %a.val, i32 *%cast %a.casted.val = load uintptr, uintptr* %a.casted call void @.wrapper.(uintptr %a.casted.val) ... ``` llvm-svn: 306697
2017-06-29CodeGen: handle missed case of COMDAT handlingSaleem Abdulrasool1-6/+5
When Protocol references are constructed, we need to add the reference symbol to a COMDAT group on non-MachO object file formats (MachO handles this by having a coalesced attribute). This adds the missing case. llvm-svn: 306622
2017-06-28[CodeGen] Fix assertion failure in EmitCallArg.Akira Hatanaka1-1/+8
The assertion was failing when a method of a parameterized class was called and the types of the argument and parameter didn't match. To fix the failure, move the assertion in EmitCallArg to its only caller EmitCallArgs and require the argument and parameter types match only when the method is not parameterized. rdar://problem/32874473 Differential Revision: https://reviews.llvm.org/D34665 llvm-svn: 306494
2017-06-27CodeGen: load indirect ObjC ARC arguments in prologueSaleem Abdulrasool1-0/+4
When generating a prologue, add loads for ARC arguments passed indirectly. Patch by Dave Lee! llvm-svn: 306444
2017-06-27[OPENMP] Use MapVector instead of DenseMap for stable codegen, NFC.Alexey Bataev1-1/+1
llvm-svn: 306419
2017-06-27[CodeGen][ObjC] Fix GNU's encoding of bit-field ivars.Akira Hatanaka1-42/+9
According to the documentation, when encoding a bit-field, GNU runtime needs its starting position in addition to its type and size. https://gcc.gnu.org/onlinedocs/gcc/Type-encoding.html Prior to r297702, the starting position information was not being encoded, which is incorrect, and after r297702, an assertion started to fail because an ObjCIvarDecl was being passed to a function expecting a FieldDecl. This commit moves LookupFieldBitOffset to ASTContext and uses the function to encode the starting position of bit-fields. llvm-svn: 306364
2017-06-23[ubsan] Improve diagnostics for return value checks (clang)Vedant Kumar4-24/+56
This patch makes ubsan's nonnull return value diagnostics more precise, which makes the diagnostics more useful when there are multiple return statements in a function. Example: 1 |__attribute__((returns_nonnull)) char *foo() { 2 | if (...) { 3 | return expr_which_might_evaluate_to_null(); 4 | } else { 5 | return another_expr_which_might_evaluate_to_null(); 6 | } 7 |} // <- The current diagnostic always points here! runtime error: Null returned from Line 7, Column 2! With this patch, the diagnostic would point to either Line 3, Column 5 or Line 5, Column 5. This is done by emitting source location metadata for each return statement in a sanitized function. The runtime is passed a pointer to the appropriate metadata so that it can prepare and deduplicate reports. Compiler-rt patch (with more tests): https://reviews.llvm.org/D34298 Differential Revision: https://reviews.llvm.org/D34299 llvm-svn: 306163
2017-06-21SwiftCC: Perform physical layout when computing coercion typesArnold Schwaighofer1-1/+7
We need to take type alignment padding into account whe computing physical layouts. The layout must be compatible with the input layout, offsets are defined in terms of offsets within a packed struct which are computed in terms of the alloc size of a type. Usingthe store size we would insert padding for the following type for example: struct { int3 v; long long l; } __attribute((packed)) On x86-64 int3 is padded to int4 alignment. The swiftcc type would be <{ <3 x float>, [4 x i8], i64 }> which is not compatible with <{ <3 x float>, i64 }>. The latter has i64 at offset 16 and the former at offset 20. rdar://32618125 llvm-svn: 305956
2017-06-21Correct VectorCall x86 (32 bit) behavior for SSE Register AssignmentErich Keane1-72/+56
In running some internal vectorcall tests in 32 bit mode, we discovered that the behavior I'd previously implemented for x64 (and applied to x32) regarding the assignment of SSE registers was incorrect. See spec here: https://msdn.microsoft.com/en-us/library/dn375768.aspx My previous implementation applied register argument position from the x64 version to both. This isn't correct for x86, so this removes and refactors that section. Additionally, it corrects the integer/int-pointer assignments. Unlike x64, x86 permits integers to be assigned independent of position. Finally, the code for 32 bit was cleaned up a little to clarify the intent, as well as given a descriptive comment. Differential Revision: https://reviews.llvm.org/D34455 llvm-svn: 305928
2017-06-20Prevent devirtualization of calls to un-instantiated functions.Sunil Srivastava1-2/+11
PR 27895 Differential Revision: https://reviews.llvm.org/D22057 llvm-svn: 305862
2017-06-20[AArch64] ADD ARMv.2-A FP16 vector intrinsicsAbderrazek Zaafrani3-7/+179
Differential Revision: https://reviews.llvm.org/D34161 llvm-svn: 305820
2017-06-20[OpenCL] Fix OpenCL and SPIR version metadata generation.Alexey Bader3-41/+37
Summary: OpenCL and SPIR version metadata must be generated once per module instead of once per mangled global value. Reviewers: Anastasia, yaxunl Reviewed By: Anastasia Subscribers: ahatanak, cfe-commits Differential Revision: https://reviews.llvm.org/D34235 llvm-svn: 305796
2017-06-19[Clang] Handle interaction of -pg and no_instrument_function attribute.Manoj Gupta1-2/+4
Summary: Disable generation of counting-function attribute if no_instrument_function attribute is present in function. Interaction between -pg and no_instrument_function is the desired behavior and matches gcc as well. This is required for fixing a crash in Linux kernel when function tracing is enabled. Fixes PR33515. Reviewers: hfinkel, rengolin, srhines, hans Reviewed By: hfinkel Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34357 llvm-svn: 305728
2017-06-19CodeGen: Cast temporary variable to proper address spaceYaxun Liu4-42/+74
In C++ all variables are in default address space. Previously change has been made to cast automatic variables to default address space. However that is not sufficient since all temporary variables need to be casted to default address space. This patch casts all temporary variables to default address space except those for passing indirect arguments since they are only used for load/store. This patch only affects target having non-zero alloca address space. Differential Revision: https://reviews.llvm.org/D33706 llvm-svn: 305711
2017-06-17CodeGen: make the type match the comment for a libcallSaleem Abdulrasool1-1/+1
Fix the type for a (runtime) library call to match both the comment and the runtime implementation. As it happens, the type being used matched, this just makes it more precise. llvm-svn: 305638
2017-06-16Expand vector oparation to as IR constants, PR28129.Dinar Temirbulatov1-0/+21
llvm-svn: 305551
2017-06-16[ubsan] PR33081: Skip the standard type checks for volatileVedant Kumar1-0/+5
Skip checks for null dereference, alignment violation, object size violation, and dynamic type violation if the pointer points to volatile data. Differential Revision: https://reviews.llvm.org/D34262 llvm-svn: 305546
2017-06-15[coroutines] Remove pass-through operator co_await; Replace it with the ↵Eric Fiselier1-13/+0
input expression Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Differential Revision: https://reviews.llvm.org/D34216 llvm-svn: 305498
2017-06-15[coroutines] Allow co_await and co_yield expressions that return an lvalue ↵Eric Fiselier3-5/+55
to compile Summary: The title says it all. Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: rjmccall, cfe-commits Differential Revision: https://reviews.llvm.org/D34194 llvm-svn: 305496
2017-06-15Apply summary-based dead stripping to regular LTO modules with summaries.Peter Collingbourne1-4/+4
If a regular LTO module has a summary index, then instead of linking it into the combined regular LTO module right away, add it to the combined summary index and associate it with a special module that represents the combined regular LTO module. Any such modules are linked during LTO::run(), at which time we use the results of summary-based dead stripping to control whether to link prevailing symbols. Differential Revision: https://reviews.llvm.org/D33922 llvm-svn: 305482
2017-06-13Preserve cold attribute for function declsXinliang David Li1-0/+2
Differential Revision: http://reviews.llvm.org/D34133 llvm-svn: 305325
2017-06-13Align definition of DW_OP_plus with DWARF spec [2/3]Florian Hahn1-5/+5
Summary: This patch is part of 3 patches that together form a single patch, but must be introduced in stages in order not to break things.   The way that LLVM interprets DW_OP_plus in DIExpression nodes is basically that of the DW_OP_plus_uconst operator since LLVM expects an unsigned constant operand. This unnecessarily restricts the DW_OP_plus operator, preventing it from being used to describe the evaluation of runtime values on the expression stack. These patches try to align the semantics of DW_OP_plus and DW_OP_minus with that of the DWARF definition, which pops two elements off the expression stack, performs the operation and pushes the result back on the stack.   This is done in three stages: • The first patch (LLVM) adds support for DW_OP_plus_uconst and changes all uses (and tests) of DW_OP_plus to use DW_OP_plus_uconst.   • The second patch (Clang) contains changes to use DW_OP_plus_uconst instead of DW_OP_plus.   • The third patch (LLVM) changes the semantics of DW_OP_plus to be in line with it’s DWARF meaning. It also does this for DW_OP_minus. Patch by Sander de Smalen. Reviewers: echristo, pcc, aprantl Reviewed By: aprantl Subscribers: aprantl, cfe-commits Differential Revision: https://reviews.llvm.org/D33893 llvm-svn: 305312
2017-06-13Add comma to comment.Gheorghe-Teodor Bercea1-1/+1
llvm-svn: 305294
2017-06-12IR: Replace the "Linker Options" module flag with "llvm.linker.options" ↵Peter Collingbourne2-8/+9
named metadata. The new metadata is easier to manipulate than module flags. Differential Revision: https://reviews.llvm.org/D31349 llvm-svn: 305227
2017-06-12Correct debug info bit offset calculation for big-endian targetsReid Kleckner1-1/+7
Summary: The change "[CodeView] Implement support for bit fields in Clang" (r274201, https://reviews.llvm.org/rL274201) broke the calculation of bit offsets for the debug info describing bitfields on big-endian targets. Prior to commit r274201 the debug info for bitfields got their offsets from the ASTRecordLayout in CGDebugInfo::CollectRecordFields(), the current field offset was then passed on to CGDebugInfo::CollectRecordNormalField() and used directly in the DIDerivedType. Since commit r274201, the bit offset ending up in the DIDerivedType no longer comes directly from the ASTRecordLayout. Instead CGDebugInfo::CollectRecordNormalField() calls the new method CGDebugInfo::createBitFieldType(), which in turn calls CodeGenTypes::getCGRecordLayout().getBitFieldInfo() to fetch a CGBitFieldInfo describing the field. The 'Offset' member of CGBitFieldInfo is then used to calculate the bit offset of the DIDerivedType. Unfortunately the previous and current method of calculating the bit offset are only equivalent for little endian targets, as CGRecordLowering::setBitFieldInfo() reverses the bit offsets for big endian targets as the last thing it does. A simple reproducer for this error is the following module: struct fields { unsigned a : 4; unsigned b : 4; } flags = {0x0f, 0x1}; Compiled for Mips, with commit r274200 both the DIDerivedType bit offsets on the IR-level and the DWARF information on the ELF-level will have the expected values: the offsets of 'a' and 'b' are 0 and 4 respectively. With r274201 the offsets are switched to 4 and 0. By noting that the static initialization of 'flags' in both cases is the same, we can eliminate a change in record layout as the cause of the change in the debug info. Also compiling this example with gcc, produces the same record layout and debug info as commit r274200. In order to restore the previous function we extend CGDebugInfo::createBitFieldType() to compensate for the reversal done in CGRecordLowering::setBitFieldInfo(). Patch by Frej Drejhammar! Reviewers: cfe-commits, majnemer, rnk, aaboud, echristo, aprantl Reviewed By: rnk, aprantl Subscribers: aprantl, arichardson, frej Differential Revision: https://reviews.llvm.org/D32745 llvm-svn: 305224
2017-06-12[ubsan] Detect invalid unsigned pointer index expression (clang)Vedant Kumar3-37/+53
Adding an unsigned offset to a base pointer has undefined behavior if the result of the expression would precede the base. An example from @regehr: int foo(char *p, unsigned offset) { return p + offset >= p; // This may be optimized to '1'. } foo(p, -1); // UB. This patch extends the pointer overflow check in ubsan to detect invalid unsigned pointer index expressions. It changes the instrumentation to only permit non-negative offsets in pointer index expressions when all of the GEP indices are unsigned. Testing: check-llvm, check-clang run on a stage2, ubsan-instrumented build. Differential Revision: https://reviews.llvm.org/D33910 llvm-svn: 305216
2017-06-09[DebugInfo] Fix comment, NFC.Alexey Bataev1-2/+2
llvm-svn: 305076
2017-06-09[DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.Alexey Bataev13-166/+163
Summary: If the first parameter of the function is the ImplicitParamDecl, codegen automatically marks it as an implicit argument with `this` or `self` pointer. Added internal kind of the ImplicitParamDecl to separate 'this', 'self', 'vtt' and other implicit parameters from other kind of parameters. Reviewers: rjmccall, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33735 llvm-svn: 305075
2017-06-09Represent debug information compression type fullySaleem Abdulrasool1-1/+1
This is tied with the LLVM side of the change to expose the debug information compression types to clang. We now track the compression type as an enumeration rather than a boolean. We still use the same value (GNU) that we did previously. This is in preparation to support passing down the compression type and switch it based on the command line. llvm-svn: 305039
2017-06-08[sanitizer-coverage] one more flavor of coverage: ↵Kostya Serebryany1-0/+1
-fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. Reapplying revisions 304630, 304631, 304632, 304673, see PR33308 llvm-svn: 305026
2017-06-05Add support for #pragma clang sectionJaved Absar2-1/+36
This patch provides a means to specify section-names for global variables, functions and static variables, using #pragma directives. This feature is only defined to work sensibly for ELF targets. One can specify section names as: #pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText" One can "unspecify" a section name with empty string e.g. #pragma clang section bss="" data="" text="" rodata="" Reviewers: Roger Ferrer, Jonathan Roelofs, Reid Kleckner Differential Revision: https://reviews.llvm.org/D33412 llvm-svn: 304705
2017-06-05Revert "[sanitizer-coverage] one more flavor of coverage: ↵Renato Golin1-1/+0
-fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. (clang part)" This reverts commit r304631, as it broke ARM/AArch64 bots for 2 days. llvm-svn: 304697