summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExpr.cpp
AgeCommit message (Collapse)Author
2014-07-18Make sure globals created by UBSan are not instrumented by ASan.Alexey Samsonov
Summary: This change adds description of globals created by UBSan instrumentation (UBSan handlers, type descriptors, filenames) to llvm.asan.globals metadata, effectively "blacklisting" them. This can dramatically decrease the data section in binaries built with UBSan+ASan, as UBSan tends to create a lot of handlers, and ASan instrumentation increases the global size to at least 64 bytes. Test Plan: clang regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, byoungyoung, kcc Differential Revision: http://reviews.llvm.org/D4575 llvm-svn: 213392
2014-07-18Revert "Emit lifetime.start / lifetime.end markers for unnamed temporary ↵Arnaud A. de Grandmaison
objects." This reverts commit dbf785a6432f78a8ec229665876647c4cc610d3d, while I qm investigating a buildbot failure. llvm-svn: 213380
2014-07-18Emit lifetime.start / lifetime.end markers for unnamed temporary objects.Arnaud A. de Grandmaison
This will give more information to the optimizers so that they can reuse stack slots. llvm-svn: 213379
2014-07-17[UBSan] Add !nosanitize metadata to the code generated by UBSan.Alexey Samsonov
This is used to mark the instructions emitted by Clang to implement variety of UBSan checks. Generally, we don't want to instrument these instructions with another sanitizers (like ASan). Reviewed in http://reviews.llvm.org/D4544 llvm-svn: 213291
2014-07-10[UBSan] Introduce type-based blacklisting.Alexey Samsonov
Teach UBSan vptr checker to ignore technically invalud down-casts on blacklisted types. Based on http://reviews.llvm.org/D4407 by Byoungyoung Lee! llvm-svn: 212770
2014-07-07[Sanitizer] Remove brittle cache variable and slightly simplify blacklisting ↵Alexey Samsonov
code. Now CodeGenFunction is responsible for looking at sanitizer blacklist (in CodeGenFunction::StartFunction) and turning off instrumentation, if necessary. No functionality change. llvm-svn: 212501
2014-06-20Don't crash when emitting a glvalue conditional where one arm is aRichard Smith
throw-expression. Based on a patch by Marius Wachtler! llvm-svn: 211388
2014-06-12Use StringRef to simplify code. No functional change.Craig Topper
llvm-svn: 210751
2014-06-12Use ArrayRef in some function parameters instead of a pointer and count. No ↵Craig Topper
functional change. llvm-svn: 210750
2014-06-09[C++11] Use 'nullptr'.Craig Topper
llvm-svn: 210448
2014-06-05Mangle predefined string constants names to merge them at link-timeAlexey Samsonov
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
2014-06-05Add pointer types to global named registerRenato Golin
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
2014-06-04Formatting cleanup.Richard Smith
llvm-svn: 210219
2014-05-31[CodeGen] Don't cast and use SizeTy instead of Int32Ty when constructing ↵Michael J. Spencer
{extract,insert} vector element instructions. llvm-svn: 209942
2014-05-27Revert small change to EmitDeclRefLValueRenato Golin
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
2014-05-23[MS-ABI] Implements MS-compatible RTTIWarren Hunt
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
2014-05-21[C++11] Use 'nullptr'. CodeGen edition.Craig Topper
llvm-svn: 209272
2014-05-20Clean up language and grammar.Eric Christopher
Based on a patch by jfcaron3@gmail.com! PR19806 llvm-svn: 209215
2014-05-19Using SmallString and correct addr varRenato Golin
llvm-svn: 209180
2014-05-19Fix usage of string when StringRef was neededRenato Golin
Also adding a variable to the test, so release bots match %1. This should also calm the gdb buildbot. . llvm-svn: 209171
2014-05-19Non-allocatable Global Named RegisterRenato Golin
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
2014-05-10Add FIXME describing the limitation of using column info to disambiguate ↵David Blaikie
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
2014-05-09Use auto to avoid duplicating the type.Rafael Espindola
llvm-svn: 208374
2014-04-08Add support for MSVC's __FUNCSIG__Reid Kleckner
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
2014-03-26PR19254: If a thread_local data member of a class is accessed via member accessRichard Smith
syntax, don't forget to run its initializer. llvm-svn: 204869
2014-02-20Sema: Do not assert when dereferencing member pointer using virtual ↵David Majnemer
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
2014-02-17Change PGO instrumentation to compute counts in a separate AST traversal.Bob Wilson
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
2014-01-25Rename getResultType() on function and method declarations to getReturnType()Alp Toker
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
2014-01-13CodeGen: Rename adjustFallThroughCount -> adjustForControlFlowJustin Bogner
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
2014-01-07CodeGen: Sentences end with a periodJustin Bogner
llvm-svn: 198649
2014-01-06CodeGen: Initial instrumentation based PGO implementationJustin Bogner
llvm-svn: 198640
2013-12-11Add front-end infrastructure now address space casts are in LLVM IR.David Tweed
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
2013-11-21Fix a crash in EmitStoreThroughExtVectorComponentLValue for vectors of odd ↵Joey Gouly
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
2013-11-08ubsan: Only emit constants for filenames and type descriptors once.Will Dietz
Produces neater IR in significantly less time. (~18% faster -O0 compile time for sqlite3 with -fsanitize=undefined) llvm-svn: 194231
2013-11-06[-fms-extensions] Add support for __FUNCDNAME__David Majnemer
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
2013-11-05C++1y sized deallocation: if we have a use, but not a definition, of a sizedRichard Smith
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
2013-10-22Split -fsanitize=bounds to -fsanitize=array-bounds (for the frontend-insertedRichard Smith
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
2013-10-20Implement function type checker for the undefined behavior sanitizer.Peter Collingbourne
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
2013-10-08TBAA: use the same format for scalar TBAA and struct-path aware TBAA.Manman Ren
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
2013-10-07Fix objectsize tests after r192117Matt Arsenault
llvm-svn: 192120
2013-10-02Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky
when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
2013-10-01No functionality change. Reflow lines that could fit on one line. Break linesNick Lewycky
that had 80-column violations. Remove spurious emacs mode markers on .cpp files. llvm-svn: 191797
2013-09-11Fix 2 cases of uninitialized reads of an invalid PresumedLoc.Evgeniy Stepanov
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
2013-08-30Revert r189649 because it was breaking sanitizer bots.Yunzhong Gao
llvm-svn: 189660
2013-08-30Fixing a bug where debug info for a local variable gets emitted at file scope.Yunzhong Gao
The patch was discussed in Phabricator. See: http://llvm-reviews.chandlerc.com/D1281 llvm-svn: 189649
2013-08-27Revert "PR14569: Omit debug info for thunks"David Blaikie
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
2013-08-26Handle predefined expression for a captured statementWei Pan
- __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
2013-08-21Sema: Use the right type for PredefinedExpr when it's in a lambda.Benjamin Kramer
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
2013-08-15CodeGen: __uuidof should work even with an incomplete _GUID typeDavid Majnemer
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
2013-08-08UBSan: Fix alignment checks emitted in downcasts.Filipe Cabecinhas
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