hanchenye-llvm-project/clang/lib
Chris Lattner 3dd716c3c3 Change CGCall to handle the "coerce" case where the coerce-to type
is a FCA to pass each of the elements as individual scalars.  This
produces code fast isel is less likely to reject and is easier on
the optimizers.

For example, before we would compile:
struct DeclGroup { long NumDecls; char * Y; };
char * foo(DeclGroup D) {
  return D.NumDecls+D.Y;
}

to:
%struct.DeclGroup = type { i64, i64 }

define i64 @_Z3foo9DeclGroup(%struct.DeclGroup) nounwind {
entry:
  %D = alloca %struct.DeclGroup, align 8          ; <%struct.DeclGroup*> [#uses=3]
  store %struct.DeclGroup %0, %struct.DeclGroup* %D, align 1
  %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1]
  %tmp1 = load i64* %tmp                          ; <i64> [#uses=1]
  %tmp2 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 1 ; <i64*> [#uses=1]
  %tmp3 = load i64* %tmp2                         ; <i64> [#uses=1]
  %add = add nsw i64 %tmp1, %tmp3                 ; <i64> [#uses=1]
  ret i64 %add
}

Now we get:

%0 = type { i64, i64 }
%struct.DeclGroup = type { i64, i8* }

define i8* @_Z3foo9DeclGroup(i64, i64) nounwind {
entry:
  %D = alloca %struct.DeclGroup, align 8          ; <%struct.DeclGroup*> [#uses=3]
  %2 = insertvalue %0 undef, i64 %0, 0            ; <%0> [#uses=1]
  %3 = insertvalue %0 %2, i64 %1, 1               ; <%0> [#uses=1]
  %4 = bitcast %struct.DeclGroup* %D to %0*       ; <%0*> [#uses=1]
  store %0 %3, %0* %4, align 1
  %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1]
  %tmp1 = load i64* %tmp                          ; <i64> [#uses=1]
  %tmp2 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 1 ; <i8**> [#uses=1]
  %tmp3 = load i8** %tmp2                         ; <i8*> [#uses=1]
  %add.ptr = getelementptr inbounds i8* %tmp3, i64 %tmp1 ; <i8*> [#uses=1]
  ret i8* %add.ptr
}

Elimination of the FCA inside the function is still-to-come.

llvm-svn: 107099
2010-06-28 23:44:11 +00:00
..
AST Introduce Expr::Classify and Expr::ClassifyModifiable, which determine the classification of an expression under the C++0x taxology (value category). Reimplement isLvalue and isModifiableLvalue using these functions. No regressions in the test suite from this, and my rough performance check doesn't show any regressions either. 2010-06-28 15:09:07 +00:00
Analysis Type Type::isRealFloatingType() that vectors are not floating-point 2010-06-22 23:07:26 +00:00
Basic Translate numbers properly. 2010-06-25 19:04:52 +00:00
Checker llvm::errs() is non-buffered, so it doesn't need to be flushed. 2010-06-28 15:56:07 +00:00
CodeGen Change CGCall to handle the "coerce" case where the coerce-to type 2010-06-28 23:44:11 +00:00
Driver Set the default arch based on the triple. 2010-06-28 17:18:09 +00:00
Frontend Modify the way sub-statements are stored and retrieved from PCH. 2010-06-28 22:28:35 +00:00
Headers Add a missing dependency to try to fix a buildbot failure. 2010-06-26 00:03:23 +00:00
Index Simplify libIndex Makefile, which doesn't need to worry about altivec support. 2010-06-08 20:57:18 +00:00
Lex Implement support for #pragma message, patch by Michael Spencer! 2010-06-26 17:11:39 +00:00
Parse Partial fix for PR7267 based on comments by John McCall on an earlier patch. 2010-06-28 08:39:25 +00:00
Rewrite introduce a new CharSourceRange class, and enhance the diagnostics routines 2010-06-18 22:45:06 +00:00
Runtime build: Get CLANG_VERSION from Version.inc instead of depending on VER file directly. 2010-06-25 17:33:49 +00:00
Sema Partial fix for PR7267 based on comments by John McCall on an earlier patch. 2010-06-28 08:39:25 +00:00
CMakeLists.txt Split libAnalysis into two libraries: libAnalysis and libChecker. 2010-01-25 04:41:41 +00:00
Makefile Makefile: Switch Clang Makefiles to always include the top-level Clang Makefile. 2010-06-08 20:34:18 +00:00