summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Use StringRef to simplify code. No functional change.Craig Topper2014-06-121-1/+1
| | | | llvm-svn: 210751
* Use ArrayRef in some function parameters instead of a pointer and count. No ↵Craig Topper2014-06-121-1/+1
| | | | | | functional change. llvm-svn: 210750
* [C++11] Use 'nullptr'.Craig Topper2014-06-091-1/+1
| | | | llvm-svn: 210448
* Mangle predefined string constants names to merge them at link-timeAlexey Samsonov2014-06-051-30/+6
| | | | | | | | | | | | | | | | | | | | | Summary: This change generalizes the code used to create global LLVM variables referencing predefined strings (e.g. __FUNCTION__): now it just calls GetAddrOfConstantStringFromLiteral method. As a result, global variables for these predefined strings may get mangled names and linkonce_odr linkage. Fix the test accordingly. Test Plan: clang regression tests Reviewers: majnemer Reviewed By: majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4023 llvm-svn: 210284
* Add pointer types to global named registerRenato Golin2014-06-051-5/+25
| | | | | | | | | | This patch adds support for pointer types in global named registers variables. It'll be lowered as a pair of read/write_register and inttoptr/ptrtoint calls. Also adds some early checks on types on SemaDecl to avoid the assert. Tests changed accordingly. (PR19837) llvm-svn: 210274
* Formatting cleanup.Richard Smith2014-06-041-10/+9
| | | | llvm-svn: 210219
* [CodeGen] Don't cast and use SizeTy instead of Int32Ty when constructing ↵Michael J. Spencer2014-05-311-3/+2
| | | | | | {extract,insert} vector element instructions. llvm-svn: 209942
* Revert small change to EmitDeclRefLValueRenato Golin2014-05-271-9/+8
| | | | | | | That small change, although it looked harmless, it made emitting the LValue on the PHI node without the proper cast. Reverting it fixes PR19841. llvm-svn: 209663
* [MS-ABI] Implements MS-compatible RTTIWarren Hunt2014-05-231-2/+2
| | | | | | | | | | | | | Enables the emission of MS-compatible RTTI data structures for use with typeid, dynamic_cast and exceptions. Does not implement dynamic_cast or exceptions. As an artiface, typeid works in some cases but proper support an testing will coming in a subsequent patch. majnemer has fuzzed the results. Test cases included. Differential Revision: http://reviews.llvm.org/D3833 llvm-svn: 209523
* [C++11] Use 'nullptr'. CodeGen edition.Craig Topper2014-05-211-17/+17
| | | | llvm-svn: 209272
* Clean up language and grammar.Eric Christopher2014-05-201-1/+1
| | | | | | | Based on a patch by jfcaron3@gmail.com! PR19806 llvm-svn: 209215
* Using SmallString and correct addr varRenato Golin2014-05-191-3/+5
| | | | llvm-svn: 209180
* Fix usage of string when StringRef was neededRenato Golin2014-05-191-1/+3
| | | | | | | | | Also adding a variable to the test, so release bots match %1. This should also calm the gdb buildbot. . llvm-svn: 209171
* Non-allocatable Global Named RegisterRenato Golin2014-05-191-2/+58
| | | | | | | | | | | | | This patch implements global named registers in Clang, lowering to the just created intrinsics in LLVM (@llvm.read/write_register). A new type of LValue had to be created (Register), which just adds support to carry the metadata node containing the name of the register. Two new methods to emit loads and stores interoperate with another to emit the named metadata node. No guarantees are being made and only non-allocatable global variable named registers are being supported. Local named register support is unchanged. llvm-svn: 209149
* Add FIXME describing the limitation of using column info to disambiguate ↵David Blaikie2014-05-101-0/+8
| | | | | | | | | | | | | | | | | | | | inlining. Also tidy up, simplify, and extend the test coverage to demonstrate the limitations. This test should now fail if the bugs are fixed (& hopefully whoever ends up in this situation sees the FIXMEs and realizes that the test needs to be updated to positively test their change that has fixed some or all of these issues). I do wonder whether I could demonstrate breakage without a macro here, but any way I slice it I can't think of a way to get two calls to the same function on the same line/column in non-macro C++ - implicit conversions happen at the same location as an explicit function, but you'd never get an implicit conversion on the result of an explicit call to the same implicit conversion operator (since the value is already converted to the desired result)... llvm-svn: 208468
* Use auto to avoid duplicating the type.Rafael Espindola2014-05-091-64/+58
| | | | llvm-svn: 208374
* Add support for MSVC's __FUNCSIG__Reid Kleckner2014-04-081-21/+13
| | | | | | | | | | | It is very similar to GCC's __PRETTY_FUNCTION__, except it prints the calling convention. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D3311 llvm-svn: 205780
* PR19254: If a thread_local data member of a class is accessed via member accessRichard Smith2014-03-261-7/+8
| | | | | | syntax, don't forget to run its initializer. llvm-svn: 204869
* Sema: Do not assert when dereferencing member pointer using virtual ↵David Majnemer2014-02-201-3/+3
| | | | | | | | | | | | | | inheritance with an incomplete class type The MS ABI requires that we determine the vbptr offset if have a virtual inheritance model. Instead, raise an error pointing to the diagnostic when this happens. This fixes PR18583. Differential Revision: http://llvm-reviews.chandlerc.com/D2842 llvm-svn: 201824
* Change PGO instrumentation to compute counts in a separate AST traversal.Bob Wilson2014-02-171-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-2/+2
| | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | 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: Sentences end with a periodJustin Bogner2014-01-071-1/+1
| | | | llvm-svn: 198649
* CodeGen: Initial instrumentation based PGO implementationJustin Bogner2014-01-061-2/+12
| | | | llvm-svn: 198640
* Add front-end infrastructure now address space casts are in LLVM IR.David Tweed2013-12-111-0/+1
| | | | | | | | | | 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
* Fix a crash in EmitStoreThroughExtVectorComponentLValue for vectors of odd ↵Joey Gouly2013-11-211-0/+6
| | | | | | | | | | | | | | | | | | | sizes. In OpenCL a vector of 3 elements, acts like a vector of four elements. So for a vector of size 3 the '.hi' and '.odd' accessors, would access the elements {2, 3} and {1, 3} respectively. However, in EmitStoreThroughExtVectorComponentLValue we are still operating on a vector of size 3, so we should only access {2} and {1}. We do this by checking the last element to be accessed, and ignore it if it is out-of-bounds. EmitLoadOfExtVectorElementLValue doesn't have a similar problem, because it does a direct shufflevector with undef, so an out-of-bounds access just gives an undef value. Patch by Anastasia Stulova! llvm-svn: 195367
* ubsan: Only emit constants for filenames and type descriptors once.Will Dietz2013-11-081-4/+9
| | | | | | | | Produces neater IR in significantly less time. (~18% faster -O0 compile time for sqlite3 with -fsanitize=undefined) llvm-svn: 194231
* [-fms-extensions] Add support for __FUNCDNAME__David Majnemer2013-11-061-0/+4
| | | | | | | | | | | | | | | | Summary: Similar to __FUNCTION__, MSVC exposes the name of the enclosing mangled function name via __FUNCDNAME__. This implementation is very naive and unoptimized, it is expected that __FUNCDNAME__ would be used rarely in practice. Reviewers: rnk, rsmith, thakis CC: cfe-commits, silvas Differential Revision: http://llvm-reviews.chandlerc.com/D2109 llvm-svn: 194181
* C++1y sized deallocation: if we have a use, but not a definition, of a sizedRichard Smith2013-11-051-2/+2
| | | | | | | | | | | | | deallocation function (and the corresponding unsized deallocation function has been declared), emit a weak discardable definition of the function that forwards to the corresponding unsized deallocation. This allows a C++ standard library implementation to provide both a sized and an unsized deallocation function, where the unsized one does not just call the sized one, for instance by putting both in the same object file within an archive. llvm-svn: 194055
* Split -fsanitize=bounds to -fsanitize=array-bounds (for the frontend-insertedRichard Smith2013-10-221-3/+4
| | | | | | | | | | | | | | 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
* Implement function type checker for the undefined behavior sanitizer.Peter Collingbourne2013-10-201-2/+48
| | | | | | | | | This uses function prefix data to store function type information at the function pointer. Differential Revision: http://llvm-reviews.chandlerc.com/D1338 llvm-svn: 193058
* TBAA: use the same format for scalar TBAA and struct-path aware TBAA.Manman Ren2013-10-081-3/+6
| | | | | | | | | | | | | | | | An updated version of r191586 with bug fix. Struct-path aware TBAA generates tags to specify the access path, while scalar TBAA only generates tags to scalar types. We should not generate a TBAA tag with null being the first field. When a TBAA type node is null, the tag should be null too. Make sure we don't decorate an instruction with a null TBAA tag. Added a testing case for the bug reported by Richard with -relaxed-aliasing and -fsanitizer=thread. llvm-svn: 192145
* Fix objectsize tests after r192117Matt Arsenault2013-10-071-1/+3
| | | | llvm-svn: 192120
* Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky2013-10-021-19/+26
| | | | | | when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
* No functionality change. Reflow lines that could fit on one line. Break linesNick Lewycky2013-10-011-9/+6
| | | | | | that had 80-column violations. Remove spurious emacs mode markers on .cpp files. llvm-svn: 191797
* Fix 2 cases of uninitialized reads of an invalid PresumedLoc.Evgeniy Stepanov2013-09-111-2/+2
| | | | | | | | | The code in CGExpr was added back in 2012 (r165536) but not exercised in tests until recently. Detected on the MemorySanitizer bootstrap bot. llvm-svn: 190521
* Revert r189649 because it was breaking sanitizer bots.Yunzhong Gao2013-08-301-3/+9
| | | | llvm-svn: 189660
* Fixing a bug where debug info for a local variable gets emitted at file scope.Yunzhong Gao2013-08-301-9/+3
| | | | | | | The patch was discussed in Phabricator. See: http://llvm-reviews.chandlerc.com/D1281 llvm-svn: 189649
* Revert "PR14569: Omit debug info for thunks"David Blaikie2013-08-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit r189320. Alexey Samsonov and Dmitry Vyukov presented some arguments for keeping these around - though it still seems like those tasks could be solved by a tool just using the symbol table. In a very small number of cases, thunks may be inlined & debug info might be able to save profilers & similar tools from misclassifying those cases as part of the caller. The extra changes here plumb through the VarDecl for various cases to CodeGenFunction - this provides better fidelity through a few APIs but generally just causes the CGF::StartFunction to fallback to using the name of the IR function as the name in the debug info. The changes to debug-info-global-ctor-dtor.cpp seem like goodness. The two names that go missing (in favor of only emitting those names as linkage names) are names that can be demangled - emitting them only as the linkage name should encourage tools to do just that. Again, thanks to Dinesh Dwivedi for investigation/work on this issue. llvm-svn: 189421
* Handle predefined expression for a captured statementWei Pan2013-08-261-0/+4
| | | | | | | | | | | - __func__ or __FUNCTION__ returns captured statement's parent function name, not the one compiler generated. Differential Revision: http://llvm-reviews.chandlerc.com/D1491 Reviewed by bkramer llvm-svn: 189219
* Sema: Use the right type for PredefinedExpr when it's in a lambda.Benjamin Kramer2013-08-211-8/+15
| | | | | | | | | | | | | 1. We now print the return type of lambdas and return type deduced functions as "auto". Trailing return types with decltype print the underlying type. 2. Use the lambda or block scope for the PredefinedExpr type instead of the parent function. This fixes PR16946, a strange mismatch between type of the expression and the actual result. 3. Verify the type in CodeGen. 4. The type for blocks is still wrong. They are numbered and the name is not known until CodeGen. llvm-svn: 188900
* CodeGen: __uuidof should work even with an incomplete _GUID typeDavid Majnemer2013-08-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We would crash in CodeGen::CodeGenModule::EmitUuidofInitializer because our attempt to enter CodeGen::CodeGenModule::EmitConstantValue will be foiled: the type of the constant value is incomplete. Instead, create an unnamed type with the proper layout on all platforms. Punt the problem of wrongly defined struct _GUID types to the user. (It's impossible because the TU may never get to see the type and thus we can't verify that it is suitable.) This fixes PR16856. Reviewers: rsmith, rnk, thakis Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1375 llvm-svn: 188481
* UBSan: Fix alignment checks emitted in downcasts.Filipe Cabecinhas2013-08-081-6/+6
| | | | | | | | | | | 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
* Debug Info / EmitCallArgs: arguments may modify the debug location.Adrian Prantl2013-07-261-1/+8
| | | | | | | | | | Restore it after each argument is emitted. This fixes the scope info for inlined subroutines inside of function argument expressions. (E.g., anything STL). rdar://problem/12592135 llvm-svn: 187240
* Remove trailing whitespace.Craig Topper2013-07-261-76/+76
| | | | llvm-svn: 187189
* 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
* Simplify atomic load/store IRGen.Eli Friedman2013-07-111-3/+2
| | | | | | Also fixes a couple minor bugs along the way; see testcases. llvm-svn: 186049
* Use SmallVectorImpl& for function arguments instead of SmallVector.Craig Topper2013-07-051-1/+1
| | | | llvm-svn: 185715
* Delete dead code.Eli Friedman2013-06-281-39/+16
| | | | llvm-svn: 185119
OpenPOWER on IntegriCloud