Skip to content
  1. Jun 28, 2010
  2. Jun 27, 2010
    • Devang Patel's avatar
      Do not forget last element, function, while creating Subprogram definition... · 81170d23
      Devang Patel authored
      Do not forget last element, function, while creating Subprogram definition MDNode from subprogram declare MDNode.
      
      llvm-svn: 106985
      81170d23
    • Rafael Espindola's avatar
      b1ef8ffb
    • Anders Carlsson's avatar
      Correctly destroy reference temporaries with global storage. Remove... · 3f48c603
      Anders Carlsson authored
      Correctly destroy reference temporaries with global storage. Remove ErrorUnsupported call when binding a global reference to a non-lvalue. Fixes PR7326.
      
      llvm-svn: 106983
      3f48c603
    • Anders Carlsson's avatar
    • Anders Carlsson's avatar
    • Anders Carlsson's avatar
      Reduce indentation. · ca68d357
      Anders Carlsson authored
      llvm-svn: 106980
      ca68d357
    • Chris Lattner's avatar
      minor cleanup to SROA: when lowering type unsafe accesses to · 25a843fc
      Chris Lattner authored
      large integers, the first inserted value would always create
      an 'or X, 0'.  Even though this is trivially zapped by
      instcombine, don't bother creating this pointless instruction.
      
      llvm-svn: 106979
      25a843fc
    • Chris Lattner's avatar
      misc tidying · 818efb64
      Chris Lattner authored
      llvm-svn: 106978
      818efb64
    • Chris Lattner's avatar
      finally get around to doing a significant cleanup to irgen: · 5e016ae9
      Chris Lattner authored
      have CGF create and make accessible standard int32,int64 and 
      intptr types.  This fixes a ton of 80 column violations 
      introduced by LLVMContextification and cleans up stuff a lot.
      
      llvm-svn: 106977
      5e016ae9
    • Chris Lattner's avatar
      tidy up OrderGlobalInits · e000907e
      Chris Lattner authored
      llvm-svn: 106976
      e000907e
    • Chris Lattner's avatar
      If coercing something from int or pointer type to int or pointer type · 055097f0
      Chris Lattner authored
      (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
      055097f0
    • Chris Lattner's avatar
      Same patch as the previous on the store side. Before we compiled this: · 895c52ba
      Chris Lattner authored
      struct DeclGroup {
        unsigned NumDecls;
      };
      
      int foo(DeclGroup D) {
        return D.NumDecls;
      }
      
      to:
      
      %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]
        store i64 %0, i64* %tmp
        %1 = bitcast i64* %tmp to %struct.DeclGroup*    ; <%struct.DeclGroup*> [#uses=1]
        %2 = load %struct.DeclGroup* %1, align 1        ; <%struct.DeclGroup> [#uses=1]
        store %struct.DeclGroup %2, %struct.DeclGroup* %D
        %tmp1 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
        %tmp2 = load i32* %tmp1                         ; <i32> [#uses=1]
        ret i32 %tmp2
      }
      
      which caused fast isel bailouts due to the FCA load/store of %2.  Now
      we generate this just blissful code:
      
      %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
      }
      
      This avoids fastisel bailing out and is groundwork for future patch.
      This reduces bailouts on CGStmt.ll to 911 from 935.
      
      llvm-svn: 106974
      895c52ba
    • Chris Lattner's avatar
      improve CreateCoercedLoad a bit to generate slightly less awful · 1cd6698a
      Chris Lattner authored
      IR when handling X86-64 by-value struct stuff.  For example, we
      use to compile this:
      
      struct DeclGroup {
        unsigned NumDecls;
      };
      
      int foo(DeclGroup D);
      void bar(DeclGroup *D) {
        foo(*D);
      }
      
      into:
      
      define void @_Z3barP9DeclGroup(%struct.DeclGroup* %D) ssp nounwind {
      entry:
        %D.addr = alloca %struct.DeclGroup*, align 8    ; <%struct.DeclGroup**> [#uses=2]
        %agg.tmp = alloca %struct.DeclGroup, align 4    ; <%struct.DeclGroup*> [#uses=2]
        %tmp3 = alloca i64                              ; <i64*> [#uses=2]
        store %struct.DeclGroup* %D, %struct.DeclGroup** %D.addr
        %tmp = load %struct.DeclGroup** %D.addr         ; <%struct.DeclGroup*> [#uses=1]
        %tmp1 = bitcast %struct.DeclGroup* %agg.tmp to i8* ; <i8*> [#uses=1]
        %tmp2 = bitcast %struct.DeclGroup* %tmp to i8*  ; <i8*> [#uses=1]
        call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 4, i32 4, i1 false)
        %0 = bitcast i64* %tmp3 to %struct.DeclGroup*   ; <%struct.DeclGroup*> [#uses=1]
        %1 = load %struct.DeclGroup* %agg.tmp           ; <%struct.DeclGroup> [#uses=1]
        store %struct.DeclGroup %1, %struct.DeclGroup* %0, align 1
        %2 = load i64* %tmp3                            ; <i64> [#uses=1]
        call void @_Z3foo9DeclGroup(i64 %2)
        ret void
      }
      
      which would cause fastisel to bail out due to the first class aggregate load %1.  With
      this patch we now compile it into the (still awful):
      
      define void @_Z3barP9DeclGroup(%struct.DeclGroup* %D) nounwind ssp noredzone {
      entry:
        %D.addr = alloca %struct.DeclGroup*, align 8    ; <%struct.DeclGroup**> [#uses=2]
        %agg.tmp = alloca %struct.DeclGroup, align 4    ; <%struct.DeclGroup*> [#uses=2]
        %tmp3 = alloca i64                              ; <i64*> [#uses=2]
        store %struct.DeclGroup* %D, %struct.DeclGroup** %D.addr
        %tmp = load %struct.DeclGroup** %D.addr         ; <%struct.DeclGroup*> [#uses=1]
        %tmp1 = bitcast %struct.DeclGroup* %agg.tmp to i8* ; <i8*> [#uses=1]
        %tmp2 = bitcast %struct.DeclGroup* %tmp to i8*  ; <i8*> [#uses=1]
        call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 4, i32 4, i1 false)
        %coerce.dive = getelementptr %struct.DeclGroup* %agg.tmp, i32 0, i32 0 ; <i32*> [#uses=1]
        %0 = bitcast i64* %tmp3 to i32*                 ; <i32*> [#uses=1]
        %1 = load i32* %coerce.dive                     ; <i32> [#uses=1]
        store i32 %1, i32* %0, align 1
        %2 = load i64* %tmp3                            ; <i64> [#uses=1]
        %call = call i32 @_Z3foo9DeclGroup(i64 %2) noredzone ; <i32> [#uses=0]
        ret void
      }
      
      which doesn't bail out.  On CGStmt.ll, this reduces fastisel bail outs from 958 to 935,
      and is the precursor of better things to come.
      
      llvm-svn: 106973
      1cd6698a
    • Jordy Rose's avatar
      Implicitly compare symbolic expressions to zero when they're being used as... · 7f8ea4d6
      Jordy Rose authored
      Implicitly compare symbolic expressions to zero when they're being used as constraints. Part of PR7491.
      
      llvm-svn: 106972
      7f8ea4d6
    • Chris Lattner's avatar
      merge two tests. · e01d966c
      Chris Lattner authored
      llvm-svn: 106971
      e01d966c
    • Chris Lattner's avatar
      Change IR generation for return (in the simple case) to avoid doing silly · 3fcc790c
      Chris Lattner authored
      load/store nonsense in the epilog.  For example, for:
      
      int foo(int X) {
        int A[100];
        return A[X];
      }
      
      we used to generate:
      
        %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i64 %idxprom ; <i32*> [#uses=1]
        %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]
        store i32 %tmp1, i32* %retval
        %0 = load i32* %retval                          ; <i32> [#uses=1]
        ret i32 %0
      }
      
      which codegen'd to this code:
      
      _foo:                                   ## @foo
      ## BB#0:                                ## %entry
      	subq	$408, %rsp              ## imm = 0x198
      	movl	%edi, 400(%rsp)
      	movl	400(%rsp), %edi
      	movslq	%edi, %rax
      	movl	(%rsp,%rax,4), %edi
      	movl	%edi, 404(%rsp)
      	movl	404(%rsp), %eax
      	addq	$408, %rsp              ## imm = 0x198
      	ret
      
      Now we generate:
      
        %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i64 %idxprom ; <i32*> [#uses=1]
        %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]
        ret i32 %tmp1
      }
      
      and:
      
      _foo:                                   ## @foo
      ## BB#0:                                ## %entry
      	subq	$408, %rsp              ## imm = 0x198
      	movl	%edi, 404(%rsp)
      	movl	404(%rsp), %edi
      	movslq	%edi, %rax
      	movl	(%rsp,%rax,4), %eax
      	addq	$408, %rsp              ## imm = 0x198
      	ret
      
      This actually does matter, cutting out 2000 lines of IR from CGStmt.ll 
      for example.
      
      Another interesting effect is that altivec.h functions which are dead
      now get dce'd by the inliner.  Hence all the changes to 
      builtins-ppc-altivec.c to ensure the calls aren't dead.
      
      llvm-svn: 106970
      3fcc790c
    • Chris Lattner's avatar
      add some named accessors for StoreInst · 0875802d
      Chris Lattner authored
      llvm-svn: 106969
      0875802d
Loading