hanchenye-llvm-project/clang
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
..
INPUTS
bindings/python Rename 'CIndex' to 'libclang', since it has basically become our stable public 2010-04-30 21:51:10 +00:00
clang.xcodeproj Update Xcode project. 2010-06-08 20:02:04 +00:00
docs build: Get CLANG_VERSION from Version.inc instead of depending on VER file directly. 2010-06-25 17:33:49 +00:00
examples Frontend: Allow passing -cc1 level arguments to plugins. Patch by Troy Straszheim! 2010-06-16 16:59:23 +00:00
include Fix up ClassTemplateSpecializationDecl: For implicit instantiations 2010-06-28 23:42:10 +00:00
lib Change CGCall to handle the "coerce" case where the coerce-to type 2010-06-28 23:44:11 +00:00
test Change CGCall to handle the "coerce" case where the coerce-to type 2010-06-28 23:44:11 +00:00
tools Silence warning about C++-style comments. 2010-06-22 09:29:44 +00:00
utils FuzzTest: Add support for reading list of replacements from a file. 2010-05-30 22:27:55 +00:00
www Update checker build. 2010-06-21 22:25:24 +00:00
CMakeLists.txt clang: Derive version name from LLVM unless specified explicitly. This means 2010-06-25 23:34:47 +00:00
INSTALL.txt
LICENSE.TXT 2010 is here. 2010-01-09 18:40:42 +00:00
Makefile Remove cruft that I didn't intend to commit. 2010-06-26 00:31:14 +00:00
ModuleInfo.txt
NOTES.txt Remove clang-cc tool, it has joined in unholy union with clang. 2009-12-12 00:56:47 +00:00
README.txt Fix typo (test commit) 2010-06-17 12:39:05 +00:00
TODO.txt switch -Werror/-Wfatal-errors error conditions to use diagnostics instead 2009-12-23 18:53:37 +00:00

README.txt

//===----------------------------------------------------------------------===//
// C Language Family Front-end
//===----------------------------------------------------------------------===//

Welcome to Clang.  This is a compiler front-end for the C family of languages
(C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM
compiler infrastructure project.

Unlike many other compiler frontends, Clang is useful for a number of things
beyond just compiling code: we intend for Clang to be host to a number of
different source level tools.  One example of this is the Clang Static Analyzer.

If you're interested in more (including how to build Clang) it is best to read
the relevant web sites.  Here are some pointers:

Information on Clang:              http://clang.llvm.org/
Building and using Clang:          http://clang.llvm.org/get_started.html
Clang Static Analyzer:             http://clang-analyzer.llvm.org/
Information on the LLVM project:   http://llvm.org/

If you have questions or comments about Clang, a great place to discuss them is
on the Clang development mailing list:
  http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

If you find a bug in Clang, please file it in the LLVM bug tracker:
  http://llvm.org/bugs/