llvm-capstone/clang/lib/CodeGen
Douglas Gregor aae38d6610 Improve our handling of reference binding for subobjects of
temporaries. There are actually several interrelated fixes here:

  - When converting an object to a base class, it's only an lvalue
  cast when the original object was an lvalue and we aren't casting
  pointer-to-derived to pointer-to-base. Previously, we were
  misclassifying derived-to-base casts of class rvalues as lvalues,
  causing various oddities (including problems with reference binding
  not extending the lifetimes of some temporaries).

  - Teach the code for emitting a reference binding how to look
  through no-op casts and parentheses directly, since
  Expr::IgnoreParenNoOpCasts is just plain wrong for this. Also, make
  sure that we properly look through multiple levels of indirection
  from the temporary object, but destroy the actual temporary object;
  this fixes the reference-binding issue mentioned above.

  - Teach Objective-C message sends to bind the result as a temporary
    when needed. This is actually John's change, but it triggered the
    reference-binding problem above, so it's included here. Now John
    can actually test his return-slot improvements.

llvm-svn: 104434
2010-05-22 05:17:18 +00:00
..
ABIInfo.h x86-64 ABI: If a type is a C++ record with either a non-trivial destructor or a non-trivial copy constructor, it should be passed in a pointer. Daniel, plz review. 2009-09-16 15:53:40 +00:00
CGBlocks.cpp Add braces to avoid an ambiguous else, fixing a GCC warning. 2010-05-21 10:29:28 +00:00
CGBlocks.h Allocate space in a block record for implicit references to the Objective C 2010-05-21 04:11:14 +00:00
CGBuilder.h
CGBuiltin.cpp Implement codegen for __builtin_isnormal. 2010-05-19 11:24:26 +00:00
CGCall.cpp Add support for Microsoft's __thiscall, from Steven Watanabe! 2010-05-18 16:57:00 +00:00
CGCall.h Remember the regparm attribute in FunctionType::ExtInfo. 2010-03-30 22:15:11 +00:00
CGClass.cpp Unbreak self-host. 2010-05-21 22:17:48 +00:00
CGCXX.cpp Vtable -> VTable renames across the board. 2010-04-17 20:15:18 +00:00
CGCXX.h Remove tabs, and whitespace cleanups. 2009-09-09 15:08:12 +00:00
CGDebugInfo.cpp Substantially alter the design of the Objective C type AST by introducing 2010-05-15 11:32:37 +00:00
CGDebugInfo.h Substantially alter the design of the Objective C type AST by introducing 2010-05-15 11:32:37 +00:00
CGDecl.cpp Ensure that destructors are called for NRVO'd objects when the 2010-05-17 15:52:46 +00:00
CGDeclCXX.cpp When initializing thread-safe statics, put the call to 2010-05-16 01:24:12 +00:00
CGException.cpp Fix an ambiguous else warning from GCC by adding some much needed curlies. 2010-05-17 20:58:49 +00:00
CGExpr.cpp Improve our handling of reference binding for subobjects of 2010-05-22 05:17:18 +00:00
CGExprAgg.cpp Improve our handling of reference binding for subobjects of 2010-05-22 05:17:18 +00:00
CGExprComplex.cpp Code gen for compound assignment of complex 2010-03-23 18:43:00 +00:00
CGExprConstant.cpp Correctly initialize bases with member pointers. This should fix PR6441 but that test case is a bit weird and I'd like to investigate further before closing that bug. 2010-05-18 16:51:41 +00:00
CGExprCXX.cpp Adds support for generation of objc_memmove_collectable API 2010-05-20 21:38:57 +00:00
CGExprScalar.cpp Unbreak self-host. 2010-05-21 22:17:48 +00:00
CGObjC.cpp Push a return-value slot throughout ObjC message-send codegen. Will be 2010-05-22 01:48:05 +00:00
CGObjCGNU.cpp Push a return-value slot throughout ObjC message-send codegen. Will be 2010-05-22 01:48:05 +00:00
CGObjCMac.cpp Push a return-value slot throughout ObjC message-send codegen. Will be 2010-05-22 01:48:05 +00:00
CGObjCRuntime.h Push a return-value slot throughout ObjC message-send codegen. Will be 2010-05-22 01:48:05 +00:00
CGRecordLayout.h Keep track of the LLVM field numbers for non-virtual bases. 2010-05-18 05:22:06 +00:00
CGRecordLayoutBuilder.cpp Correctly initialize bases with member pointers. This should fix PR6441 but that test case is a bit weird and I'd like to investigate further before closing that bug. 2010-05-18 16:51:41 +00:00
CGRTTI.cpp Fix -fno-rtti -fexceptions by forcing the emission of (non-"builtin") RTTI 2010-04-30 01:15:21 +00:00
CGStmt.cpp Don't remove the break/continue scope of a for loop until after we've 2010-05-21 18:36:48 +00:00
CGTemporaries.cpp Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall. 2010-05-02 23:29:11 +00:00
CGValue.h CodeGen: Shrink RValue. 4 words -> 2 words. 2010-05-02 14:59:10 +00:00
CGVTables.cpp When generating the call arguments in a thunk to call the thunkee, do 2010-05-21 17:55:12 +00:00
CGVTables.h Rework when and how vtables are emitted, by tracking where vtables are 2010-05-13 16:44:06 +00:00
CGVTT.cpp The global variable for the VTT might not have external linkage; allow 2010-05-06 22:18:21 +00:00
CMakeLists.txt Unbreak CMake build. 2010-05-05 05:41:05 +00:00
CodeGenFunction.cpp Unbreak self-host. 2010-05-21 22:17:48 +00:00
CodeGenFunction.h Push a return-value slot throughout ObjC message-send codegen. Will be 2010-05-22 01:48:05 +00:00
CodeGenModule.cpp Disable the available_externally optimization for inline virtual 2010-05-13 21:36:56 +00:00
CodeGenModule.h Rework when and how vtables are emitted, by tracking where vtables are 2010-05-13 16:44:06 +00:00
CodeGenTypes.cpp Add CodeGenTypes::ContainsPointerToDataMember overload that takes a CXXRecordDecl. 2010-05-18 03:47:15 +00:00
CodeGenTypes.h Add CodeGenTypes::ContainsPointerToDataMember overload that takes a CXXRecordDecl. 2010-05-18 03:47:15 +00:00
GlobalDecl.h Use the correct function info for constructors when applying function attributes. Fixes PR6245. 2010-02-06 02:44:09 +00:00
Makefile Allow users to set CPPFLAGS and CXXFLAGS on the make command line. 2010-03-12 22:55:16 +00:00
Mangle.cpp Modify this comment per Doug's suggestion: we don't need to mangle protocols. 2010-05-15 17:06:29 +00:00
Mangle.h Vtable -> VTable renames across the board. 2010-04-17 20:15:18 +00:00
ModuleBuilder.cpp Rework when and how vtables are emitted, by tracking where vtables are 2010-05-13 16:44:06 +00:00
README.txt These IRgen improvements have been done. 2009-07-23 03:03:07 +00:00
TargetInfo.cpp IRgen: Remove dead function. 2010-05-17 16:46:02 +00:00
TargetInfo.h Implement __builtin_dwarf_sp_column for i386 (Darwin and not), x86-64 (all), 2010-03-06 00:35:14 +00:00

IRgen optimization opportunities.

//===---------------------------------------------------------------------===//

The common pattern of
--
short x; // or char, etc
(x == 10)
--
generates an zext/sext of x which can easily be avoided.

//===---------------------------------------------------------------------===//

Bitfields accesses can be shifted to simplify masking and sign
extension. For example, if the bitfield width is 8 and it is
appropriately aligned then is is a lot shorter to just load the char
directly.

//===---------------------------------------------------------------------===//

It may be worth avoiding creation of alloca's for formal arguments
for the common situation where the argument is never written to or has
its address taken. The idea would be to begin generating code by using
the argument directly and if its address is taken or it is stored to
then generate the alloca and patch up the existing code.

In theory, the same optimization could be a win for block local
variables as long as the declaration dominates all statements in the
block.

NOTE: The main case we care about this for is for -O0 -g compile time
performance, and in that scenario we will need to emit the alloca
anyway currently to emit proper debug info. So this is blocked by
being able to emit debug information which refers to an LLVM
temporary, not an alloca.

//===---------------------------------------------------------------------===//

We should try and avoid generating basic blocks which only contain
jumps. At -O0, this penalizes us all the way from IRgen (malloc &
instruction overhead), all the way down through code generation and
assembly time.

On 176.gcc:expr.ll, it looks like over 12% of basic blocks are just
direct branches!

//===---------------------------------------------------------------------===//