llvm-project/clang/lib
Chris Lattner 055097f024 If coercing something from int or pointer type to int or pointer type
(potentially after unwrapping it from a struct) do it without going through
memory.  We now compile:

struct DeclGroup {
  unsigned NumDecls;
};

int foo(DeclGroup D) {
  return D.NumDecls;
}

into:

%struct.DeclGroup = type { i32 }

define i32 @_Z3foo9DeclGroup(i64) nounwind ssp noredzone {
entry:
  %D = alloca %struct.DeclGroup, align 4          ; <%struct.DeclGroup*> [#uses=2]
  %coerce.dive = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %coerce.val.ii = trunc i64 %0 to i32            ; <i32> [#uses=1]
  store i32 %coerce.val.ii, i32* %coerce.dive
  %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %tmp1 = load i32* %tmp                          ; <i32> [#uses=1]
  ret i32 %tmp1
}

instead of:

%struct.DeclGroup = type { i32 }

define i32 @_Z3foo9DeclGroup(i64) nounwind ssp noredzone {
entry:
  %D = alloca %struct.DeclGroup, align 4          ; <%struct.DeclGroup*> [#uses=2]
  %tmp = alloca i64                               ; <i64*> [#uses=2]
  %coerce.dive = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  store i64 %0, i64* %tmp
  %1 = bitcast i64* %tmp to i32*                  ; <i32*> [#uses=1]
  %2 = load i32* %1, align 1                      ; <i32> [#uses=1]
  store i32 %2, i32* %coerce.dive
  %tmp1 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %tmp2 = load i32* %tmp1                         ; <i32> [#uses=1]
  ret i32 %tmp2
}

... which is quite a bit less terrifying.

llvm-svn: 106975
2010-06-27 06:26:04 +00:00
..
AST Support UnresolvedLookupExpr for PCH. 2010-06-25 09:03:34 +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 Implicitly compare symbolic expressions to zero when they're being used as constraints. Part of PR7491. 2010-06-27 01:20:56 +00:00
CodeGen If coercing something from int or pointer type to int or pointer type 2010-06-27 06:26:04 +00:00
Driver Implement support for -fwrapv, rdar://7221421 2010-06-26 21:25:03 +00:00
Frontend Implement support for -fwrapv, rdar://7221421 2010-06-26 21:25:03 +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 Add parentheses suggested by gcc. 2010-06-23 19:34:52 +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 Use TypeSourceInfo to help determine the SourceRange of a CXXNewExpr. This fixes several 2010-06-25 22:48:49 +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