summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprScalar.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Update for IR: add a second AtomicOrdering to cmpxchg insts.Tim Northover2014-03-111-4/+6
| | | | | | rdar://problem/15996804 llvm-svn: 203560
* [Modules] Update to reflect the move of CFG.h to the IR library in LLVMChandler Carruth2014-03-041-1/+1
| | | | | | r202827. llvm-svn: 202828
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-4/+4
| | | | llvm-svn: 202639
* [C++11] Replace llvm::next and llvm::prior with std::next and std::prev.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202635
* Change PGO instrumentation to compute counts in a separate AST traversal.Bob Wilson2014-02-171-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we made one traversal of the AST prior to codegen to assign counters to the ASTs and then propagated the count values during codegen. This patch now adds a separate AST traversal prior to codegen for the -fprofile-instr-use option to propagate the count values. The counts are then saved in a map from which they can be retrieved during codegen. This new approach has several advantages: 1. It gets rid of a lot of extra PGO-related code that had previously been added to codegen. 2. It fixes a serious bug. My original implementation (which was mailed to the list but never committed) used 3 counters for every loop. Justin improved it to move 2 of those counters into the less-frequently executed breaks and continues, but that turned out to produce wrong count values in some cases. The solution requires visiting a loop body before the condition so that the count for the condition properly includes the break and continue counts. Changing codegen to visit a loop body first would be a fairly invasive change, but with a separate AST traversal, it is easy to control the order of traversal. I've added a testcase (provided by Justin) to make sure this works correctly. 3. It improves the instrumentation overhead, reducing the number of counters for a loop from 3 to 1. We no longer need dedicated counters for breaks and continues, since we can just use the propagated count values when visiting breaks and continues. To make this work, I needed to make a change to the way we count case statements, going back to my original approach of not including the fall-through in the counter values. This was necessary because there isn't always an AST node that can be used to record the fall-through count. Now case statements are handled the same as default statements, with the fall-through paths branching over the counter increments. While I was at it, I also went back to using this approach for do-loops -- omitting the fall-through count into the loop body simplifies some of the calculations and make them behave the same as other loops. Whenever we start using this instrumentation for coverage, we'll need to add the fall-through counts into the counter values. llvm-svn: 201528
* Fix some minor whitespace issues.Bob Wilson2014-02-171-1/+1
| | | | llvm-svn: 201526
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-1/+1
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* CodeGen: Rename adjustFallThroughCount -> adjustForControlFlowJustin Bogner2014-01-131-4/+4
| | | | | | | | adjustFallThroughCount isn't a good name, and the documentation was even worse. This commit attempts to clarify what it's for and when to use it. llvm-svn: 199139
* CodeGen: Initial instrumentation based PGO implementationJustin Bogner2014-01-061-3/+34
| | | | llvm-svn: 198640
* Eliminate UnaryTypeTraitExprAlp Toker2014-01-011-3/+0
| | | | | | | | | | | | | Remove UnaryTypeTraitExpr and switch all remaining type trait related handling over to TypeTraitExpr. The UTT/BTT/TT enum prefix and evaluation code is retained pending further cleanup. This is part of the ongoing work to unify type traits following the removal of BinaryTypeTraitExpr in r197273. llvm-svn: 198271
* Eliminate BinaryTypeTraitExprAlp Toker2013-12-131-1/+1
| | | | | | | | | | | | | | | | | There's nothing special about type traits accepting two arguments. This commit eliminates BinaryTypeTraitExpr and switches all related handling over to TypeTraitExpr. Also fixes a CodeGen failure with variadic type traits appearing in a non-constant expression. The BTT/TT prefix and evaluation code is retained as-is for now but will soon be further cleaned up. This is part of the ongoing work to unify type traits. llvm-svn: 197273
* Add front-end infrastructure now address space casts are in LLVM IR.David Tweed2013-12-111-2/+13
| | | | | | | | | | With the introduction of explicit address space casts into LLVM, there's a need to provide a new cast kind the front-end can create for C/OpenCL/CUDA and code to produce address space casts from those kinds when appropriate. Patch by Michele Scandale! llvm-svn: 197036
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* Remove an incorrect optimization inside Clang's IRGen. Its check to determineNick Lewycky2013-11-081-15/+8
| | | | | | | | | | | whether we can safely lower a conditional operator to select was insufficient. I've left a large comment in place to explaining the sort of problems that this transform can encounter in clang in the hopes of discouraging others from reimplementing it wrongly again in the future. (The test should also help with that, but it's easy to work around any single test I might add and think that your particular implementation doesn't miscompile any code.) llvm-svn: 194289
* Split -fsanitize=bounds to -fsanitize=array-bounds (for the frontend-insertedRichard Smith2013-10-221-2/+2
| | | | | | | | | | | | | | check using the ubsan runtime) and -fsanitize=local-bounds (for the middle-end check which inserts traps). Remove -fsanitize=local-bounds from -fsanitize=undefined. It does not produce useful diagnostics and has false positives (PR17635), and is not a good compromise position between UBSan's checks and ASan's checks. Map -fbounds-checking to -fsanitize=local-bounds to restore Clang's historical behavior for that flag. llvm-svn: 193205
* Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky2013-10-021-18/+23
| | | | | | when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
* Add the intrinsic __builtin_convertvectorHal Finkel2013-09-181-0/+76
| | | | | | | | | | | | | | | | | | LLVM supports applying conversion instructions to vectors of the same number of elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to cause such instructions to be generated when using builtin vector types. C-style casting on vectors is already defined in terms of bitcasts, and so cannot be used for these conversions as well (without leading to a very confusing set of semantics). As a result, this adds a __builtin_convertvector intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is intended to aid the creation of vector intrinsic headers that create generic IR instead of target-dependent intrinsics (in other words, this is a generic _mm_cvtepi32_ps). As noted in the documentation, the action of __builtin_convertvector is defined in terms of the action of a C-style cast on each vector element. llvm-svn: 190915
* UBSan: Fix alignment checks emitted in downcasts.Filipe Cabecinhas2013-08-081-4/+7
| | | | | | | | | | | Summary: UBSan was checking for alignment of the derived class on the pointer to the base class, before converting. With some class hierarchies, this could generate false positives. Added test-case. llvm-svn: 187948
* Add support for passing -1 to __builtin_shufflevector to signify an ↵Craig Topper2013-08-031-2/+6
| | | | | | undefined element value to match IR capabilities. llvm-svn: 187694
* Remove more odd code that tries to account for an off by 1 problem in vec3 ↵Craig Topper2013-08-011-8/+0
| | | | | | shuffles that doesn't really exist. llvm-svn: 187561
* Fix to handle all non-power-of-2 vector sizes in the mask form of ↵Craig Topper2013-08-011-10/+2
| | | | | | | | _builtin_shuffle_vector. Previously a 2-bit mask was used to mask each element of a vec6 mask before doing the extracts instead of 3-bit mask necessary to cover 0-5. vec3 was the only non-power-of-2 that worked correctly because a +1 conditionally added before calculating floor(log2(elements)). llvm-svn: 187560
* Remove broken and unnecessary vec3 handling from VisitShuffleVectorExpr.Craig Topper2013-08-011-5/+1
| | | | llvm-svn: 187558
* Fix formatting. No functional change.Craig Topper2013-07-271-1/+1
| | | | llvm-svn: 187294
* Remove trailing whitespace.Craig Topper2013-07-261-91/+91
| | | | llvm-svn: 187190
* Make IgnoreParens() look through ChooseExprs.Eli Friedman2013-07-201-1/+1
| | | | | | | | | | | | | This is the same way GenericSelectionExpr works, and it's generally a more consistent approach. A large part of this patch is devoted to caching the value of the condition of a ChooseExpr; it's needed to avoid threading an ASTContext into IgnoreParens(). Fixes <rdar://problem/14438917>. llvm-svn: 186738
* Make Expr::isConstantInitializer match IRGen.Eli Friedman2013-07-161-1/+1
| | | | | | | | | | Sema needs to be able to accurately determine what will be emitted as a constant initializer and what will not, so we get accurate errors in C and accurate -Wglobal-constructors warnings in C++. This makes Expr::isConstantInitializer match CGExprConstant as closely as possible. llvm-svn: 186464
* PR16214, PR14467: DebugInfo: use "RequireCompleteType" to decide when to ↵David Blaikie2013-07-131-12/+0
| | | | | | | | | | | | | | | emit the full definition of a type in -flimit-debug-info This simplifies the core benefit of -flimit-debug-info by taking a more systematic approach to avoid emitting debug info definitions for types that only require declarations. The previous ad-hoc approach (3 cases removed in this patch) had many holes. The general approach (adding a bit to TagDecl and callback through ASTConsumer) has been discussed with Richard Smith - though always open to revision. llvm-svn: 186262
* Add support for complex compound assignments where the LHS is a scalar.Eli Friedman2013-06-121-9/+2
| | | | | | Fixes <rdar://problem/11224126> and PR12790. llvm-svn: 183821
* Make sure we don't emit invalid IR for StmtExprs with complex cleanups.Eli Friedman2013-06-101-2/+6
| | | | | | Fixes <rdar://problem/14074868>. llvm-svn: 183699
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-0/+4
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* Standardize accesses to the TargetInfo in IR-gen.John McCall2013-04-161-2/+2
| | | | | | Patch by Stephen Lin! llvm-svn: 179638
* UBSan: Don't diagnose inf/nan conversions between floating-point types. It's ↵Richard Smith2013-03-271-34/+49
| | | | | | far from clear whether these have undefined behavior, and these checks are helping no-one. Keep the double->float overflow warnings, though, since those are useful in practice, even though it's unclear whether such operations have defined behavior. llvm-svn: 178194
* PR15383: When -fsanitize=float-cast-overflow checks a float-to-int conversion,Richard Smith2013-03-191-8/+24
| | | | | | | | it wasn't taking into account that the float should be truncated *before* the range check happens. Thus (unsigned)-0.99 and (unsigned char)255.9 have defined behavior and should not be trapped. llvm-svn: 177362
* Change hasAggregateLLVMType, which conflates complex andJohn McCall2013-03-071-4/+4
| | | | | | | | | | | | | | | aggregate types in a profoundly wrong way that has to be worked around in every call site, to getEvaluationKind, which classifies and distinguishes between all of these cases. Also, normalize the API for loading and storing complexes. I'm working on a larger patch and wanted to pull these changes out, but it would have be annoying to detangle them from each other. llvm-svn: 176656
* Improve C11 atomics support:David Chisnall2013-03-031-7/+89
| | | | | | | | | | | | | | | | | | | | - Generate atomicrmw operations in most of the cases when it's sensible to do so. - Don't crash in several common cases (and hopefully don't crash in more of them). - Add some better tests. We now generate significantly better code for things like: _Atomic(int) x; ... x++; On MIPS, this now generates a 4-instruction ll/sc loop, where previously it generated about 30 instructions in two nested loops. On x86-64, we generate a single lock incl, instead of a lock cmpxchgl loop (one instruction instead of ten). llvm-svn: 176420
* Use the actual ABI-determined C calling convention for runtimeJohn McCall2013-02-281-3/+8
| | | | | | | | | | | | | | | | | | | | | | calls and declarations. LLVM has a default CC determined by the target triple. This is not always the actual default CC for the ABI we've been asked to target, and so we sometimes find ourselves annotating all user functions with an explicit calling convention. Since these calling conventions usually agree for the simple set of argument types passed to most runtime functions, using the LLVM-default CC in principle has no effect. However, the LLVM optimizer goes into histrionics if it sees this kind of formal CC mismatch, since it has no concept of CC compatibility. Therefore, if this module happens to define the "runtime" function, or got LTO'ed with such a definition, we can miscompile; so it's quite important to get this right. Defining runtime functions locally is quite common in embedded applications. llvm-svn: 176286
* [ubsan] Emit single check for left shift.Will Dietz2013-02-251-4/+15
| | | | | | Avoids warning twice on same shift. llvm-svn: 176056
* ubsan: Emit bounds checks for array indexing, vector indexing, and (in ↵Richard Smith2013-02-231-1/+10
| | | | | | really simple cases) pointer arithmetic. This augments the existing bounds checking with language-level array bounds information. llvm-svn: 175949
* Add support to Sema and CodeGen for floating point vector types in OpenCL.Joey Gouly2013-02-211-10/+21
| | | | llvm-svn: 175734
* ubsan: Add checking for invalid downcasts. Per [expr.static.cast]p2 and p11,Richard Smith2013-02-131-1/+9
| | | | | | | base-to-derived casts have undefined behavior if the object is not actually an instance of the derived type. llvm-svn: 175078
* [ubsan] Implement the -fcatch-undefined-behavior flag using a trappingChad Rosier2013-01-291-1/+1
| | | | | | | | | | | implementation; this is much more inline with the original implementation (i.e., pre-ubsan) and does not require run-time library support. The trapping implementation can be invoked using either '-fcatch-undefined-behavior' or '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error', with the latter being preferred. Eventually, the -fcatch-undefined-behavior' flag will be removed. llvm-svn: 173848
* Add a new LangOpt NativeHalfType. This option allows for native half/fp16Joey Gouly2013-01-231-6/+5
| | | | | | | | operations (as opposed to storage only half/fp16). Also add some semantic checks for OpenCL half types. llvm-svn: 173254
* Implement OpenCL event_t as Clang builtin type, including event_t related ↵Guy Benyei2013-01-201-0/+5
| | | | | | OpenCL restrictions (OpenCL 1.2 spec 6.9) llvm-svn: 172973
* [ubsan] Add support for -fsanitize-blacklistWill Dietz2013-01-181-26/+23
| | | | llvm-svn: 172808
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-2/+2
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Testing with a full OpenCL compiler (based on clang) reveals r71734 missedDavid Tweed2013-01-101-2/+6
| | | | | | | difference between type widths of a vector and the width of one of its elements in the case of vector shifts. Use correct witdth in the vector case. llvm-svn: 172047
* [ubsan] Use correct type for compound assignment ops.Will Dietz2013-01-071-2/+2
| | | | llvm-svn: 171801
* Scalar shifts in the OpenCL specification (as of v. 1.2) are defined to beDavid Tweed2013-01-071-11/+20
| | | | | | | | | | with respect to the lower "left-hand-side bitwidth" bits, even when negative); see OpenCL spec 6.3j. This patch both implements this behaviour in the code generator and "constant folding" bits of Sema, and also prevents tests to detect undefinedness in terms of the weaker C99 or C++ specifications from being applied. llvm-svn: 171755
* Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate toChandler Carruth2013-01-021-6/+6
| | | | | | | | reflect the migration in r171366. Re-sort the #include lines to reflect the new paths. llvm-svn: 171369
* Simplify vector splat code. No functionality change.Benjamin Kramer2013-01-011-18/+2
| | | | llvm-svn: 171350
OpenPOWER on IntegriCloud