llvm-project/clang/test
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
..
ASTMerge Hack in some really terrible C++ record PCH support that I need right now. 2010-06-03 19:28:45 +00:00
Analysis Implicitly compare symbolic expressions to zero when they're being used as constraints. Part of PR7491. 2010-06-27 01:20:56 +00:00
CXX A bug I've introduced in STDIN handling surfaced a few broken tests, fix them. 2010-06-25 12:48:07 +00:00
CodeCompletion Make -code-completion-patterns only cover multi-line code 2010-05-28 00:22:41 +00:00
CodeGen If coercing something from int or pointer type to int or pointer type 2010-06-27 06:26:04 +00:00
CodeGenCXX Change IR generation for return (in the simple case) to avoid doing silly 2010-06-27 01:06:27 +00:00
CodeGenObjC Trying to make BuildBot happy again (related to PR7431). 2010-06-22 17:08:32 +00:00
CodeGenObjCXX Renamed selactor-expr-lvalue.mm to selector-expr-lvalue.mm. 2010-06-24 16:40:16 +00:00
Coverage "this patch properly addresses escaping < and > which might appear 2010-05-12 23:27:11 +00:00
Driver Fix typo. 2010-06-15 08:21:35 +00:00
FixIt Tweak test for non-64-bit Darwin 2010-05-31 14:58:57 +00:00
Frontend tests: Update Frontend config to actually run ir-support tests. 2010-06-16 20:04:36 +00:00
Headers Make sure we don't include mm_malloc.h in this test, it includes errno.h which 2010-03-26 20:17:23 +00:00
Index Add USR tests for ObjC class extensions. 2010-06-23 18:10:30 +00:00
Lexer A bug I've introduced in STDIN handling surfaced a few broken tests, fix them. 2010-06-25 12:48:07 +00:00
Misc Testcase for r103712. 2010-05-13 12:04:17 +00:00
PCH Support NonTypeTemplateParmDecl for PCH. 2010-06-25 16:25:09 +00:00
Parser improve altivec vector bool/pixel support, patch by Anton Yartsev 2010-06-23 06:00:24 +00:00
Preprocessor clang: Derive version name from LLVM unless specified explicitly. This means 2010-06-25 23:34:47 +00:00
Rewriter Patch to rewrite block pointers as arguments to 2010-05-25 15:56:08 +00:00
Sema Fixes a regression when redeclaration of a global satic 2010-06-24 18:50:41 +00:00
SemaCXX String literals enclosed in parentheses are still string 2010-06-22 23:47:37 +00:00
SemaObjC Patch to provide separate ASTs for multiple ObjC class extension 2010-06-22 23:20:40 +00:00
SemaObjCXX Fix the recently-added warning about 'typename' and 'template' 2010-06-16 22:31:08 +00:00
SemaTemplate Implement dependent alignment attribute support. This is a bit gross given the 2010-06-25 03:22:07 +00:00
CMakeLists.txt Add test cases for r98003 and r98006. 2010-03-08 23:38:27 +00:00
Makefile I don't know when I committed this, but it's probably a "bad thing". 2010-06-25 05:00:29 +00:00
TestRunner.sh Switch TestRunner.sh to just use 'lit'. 2009-09-20 22:00:23 +00:00
cxx-sections.data Update C++ section data and directory structure to reflect N2914 2009-06-30 16:45:27 +00:00
lit.cfg tests: Mangle '-vg' onto the end of the triple when running under valgrind, so 2010-03-20 21:13:08 +00:00
lit.site.cfg.in Rework site config for cmake to be generated at configure time, and only pass 2009-11-07 23:53:32 +00:00
make_test_dirs.pl Add the structure for a C++ test suite that mimics the structure of the C++ standard 2009-06-13 06:06:53 +00:00