Skip to content
  1. May 03, 2012
  2. Jul 13, 2011
  3. Jun 29, 2011
    • Eli Friedman's avatar
      We don't pass classes with a copy-constructor or destructor byval, so the... · 4774b7e4
      Eli Friedman authored
      We don't pass classes with a copy-constructor or destructor byval, so the address takes up an integer register (if one is available).  Make sure the x86-64 ABI implementation takes that into account properly.
      
      The fixed implementation is compatible with the implementation both gcc and llvm-gcc use.
      
      rdar://9686430 . (This is the issue that was reported in the thread "[LLVMdev] Segfault calling LLVM libs from a clang-compiled executable".)
      
      llvm-svn: 134059
      4774b7e4
  4. Apr 17, 2011
    • Anders Carlsson's avatar
      When laying out bases in, always try the "base subobject" LLVM type. If it · fcaaa697
      Anders Carlsson authored
      turns out that a field or base needs to be laid out in the tail padding of
      the base, CGRecordLayoutBuilder::ResizeLastBaseFieldIfNecessary will convert
      it to an array of i8.
      
      I've audited the new test results to make sure that they are still valid. I've
      also verified that we pass a self-host with this change.
      
      This (finally) fixes PR5589!
      
      llvm-svn: 129673
      fcaaa697
  5. Sep 01, 2010
  6. Aug 23, 2010
    • Chris Lattner's avatar
      fix rdar://8340348, a miscompile of boost that was exposed by r109848. · 65526f01
      Chris Lattner authored
      That revision started classifying truly empty structs like "Y" and "X"
      as being NoClass/NoClass and turning them into 'ignore'.  The call code
      turns around and allocates space for the ignored argument with 
      GetUndefRValue.  The bug is that GetUndefRValue would return the address
      as undef, instead of returning an object with a defined address but 
      undefined contents.
      
      llvm-svn: 111794
      65526f01
  7. Jul 30, 2010
    • Chris Lattner's avatar
      fix PR5179 and correctly fix PR5831 to not miscompile. · 8a2f3c77
      Chris Lattner authored
      The X86-64 ABI code didn't handle the case when a struct
      would get classified and turn up as "NoClass INTEGER" for
      example.  This is perfectly possible when the first slot
      is all padding (e.g. due to empty base classes).  In this
      situation, the first 8-byte doesn't take a register at all,
      only the second 8-byte does.
      
      This fixes this by enhancing the x86-64 abi stuff to allow
      and handle this case, reverts the broken fix for PR5831,
      and enhances the target independent stuff to be able to 
      handle an argument value in registers being accessed at an
      offset from the memory value.
      
      This is the last x86-64 calling convention related miscompile
      that I'm aware of.
      
      llvm-svn: 109848
      8a2f3c77
  8. Jul 29, 2010
    • Chris Lattner's avatar
      fix PR7742 / rdar://8250764, a miscompilation of struct · cd84084f
      Chris Lattner authored
      return where the struct has a base but no fields.  This
      was because the x86-64 abi logic was checking the wrong
      predicate in one place.
      
      This was introduced in r91874, which was a fix for PR5831,
      which lacked a CHECK line, so I verified and added it.
      
      llvm-svn: 109759
      cd84084f
    • Chris Lattner's avatar
      Kill off the 'coerce' ABI passing form. Now 'direct' and 'extend' always · fe34c1d5
      Chris Lattner authored
      have a "coerce to" type which often matches the default lowering of Clang
      type to LLVM IR type, but the coerce case can be handled by making them
      not be the same.
      
      This simplifies things and fixes issues where X86-64 abi lowering would 
      return coerce after making preferred types exactly match up.  This caused
      us to compile:
      
      typedef float v4f32 __attribute__((__vector_size__(16)));
      v4f32 foo(v4f32 X) {
        return X+X;
      }
      
      into this code at -O0:
      
      define <4 x float> @foo(<4 x float> %X.coerce) nounwind {
      entry:
        %retval = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=2]
        %coerce = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=2]
        %X.addr = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=3]
        store <4 x float> %X.coerce, <4 x float>* %coerce
        %X = load <4 x float>* %coerce                  ; <<4 x float>> [#uses=1]
        store <4 x float> %X, <4 x float>* %X.addr
        %tmp = load <4 x float>* %X.addr                ; <<4 x float>> [#uses=1]
        %tmp1 = load <4 x float>* %X.addr               ; <<4 x float>> [#uses=1]
        %add = fadd <4 x float> %tmp, %tmp1             ; <<4 x float>> [#uses=1]
        store <4 x float> %add, <4 x float>* %retval
        %0 = load <4 x float>* %retval                  ; <<4 x float>> [#uses=1]
        ret <4 x float> %0
      }
      
      Now we get:
      
      define <4 x float> @foo(<4 x float> %X) nounwind {
      entry:
        %X.addr = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=3]
        store <4 x float> %X, <4 x float>* %X.addr
        %tmp = load <4 x float>* %X.addr                ; <<4 x float>> [#uses=1]
        %tmp1 = load <4 x float>* %X.addr               ; <<4 x float>> [#uses=1]
        %add = fadd <4 x float> %tmp, %tmp1             ; <<4 x float>> [#uses=1]
        ret <4 x float> %add
      }
      
      This implements rdar://8248065
      
      llvm-svn: 109733
      fe34c1d5
  9. Jun 30, 2010
  10. Jun 29, 2010
    • Chris Lattner's avatar
      Change X86_64ABIInfo to have ASTContext and TargetData ivars to · 22a931e3
      Chris Lattner authored
      avoid passing ASTContext down through all the methods it has.
      
      When classifying an argument, or argument piece, as INTEGER, check
      to see if we have a pointer at exactly the same offset in the 
      preferred type.  If so, use that pointer type instead of i64.  This
      allows us to compile A function taking a stringref into something
      like this:
      
      define i8* @foo(i64 %D.coerce0, i8* %D.coerce1) nounwind ssp {
      entry:
        %D = alloca %struct.DeclGroup, align 8          ; <%struct.DeclGroup*> [#uses=4]
        %0 = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1]
        store i64 %D.coerce0, i64* %0
        %1 = getelementptr %struct.DeclGroup* %D, i32 0, i32 1 ; <i8**> [#uses=1]
        store i8* %D.coerce1, i8** %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
      }
      
      instead of this:
      
      define i8* @foo(i64 %D.coerce0, i64 %D.coerce1) nounwind ssp {
      entry:
        %D = alloca %struct.DeclGroup, align 8          ; <%struct.DeclGroup*> [#uses=3]
        %0 = insertvalue %0 undef, i64 %D.coerce0, 0    ; <%0> [#uses=1]
        %1 = insertvalue %0 %0, i64 %D.coerce1, 1       ; <%0> [#uses=1]
        %2 = bitcast %struct.DeclGroup* %D to %0*       ; <%0*> [#uses=1]
        store %0 %1, %0* %2, 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
      }
      
      This implements rdar://7375902 - [codegen quality] clang x86-64 ABI lowering code punishing StringRef
      
      llvm-svn: 107123
      22a931e3
    • Chris Lattner's avatar
      add IR names to coerced arguments. · 9e748e9d
      Chris Lattner authored
      llvm-svn: 107105
      9e748e9d
    • Chris Lattner's avatar
      Change CGCall to handle the "coerce" case where the coerce-to type · 3dd716c3
      Chris Lattner authored
      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
      3dd716c3
  11. May 15, 2010
  12. Dec 22, 2009
  13. Dec 15, 2009
  14. Nov 23, 2009
  15. Nov 08, 2009
  16. Sep 16, 2009
Loading