[PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 27 21:34:13 PDT 2016


majnemer added a comment.

In https://reviews.llvm.org/D22900#498793, @Gerolf wrote:

> Nope, I don't see the tail call. Anyway, I'll simplify my test case. Don't worry about it.
>
> clang++ -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.cpp
>
> cat t.ll:
>
> ; ModuleID = 't.cpp'
>  source_filename = "t.cpp"
>  target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
>  target triple = "i386-apple-darwin9"
>
> %struct.C = type { %struct.CBase, %struct.I }
>  %struct.CBase = type { i32 (...)** }
>  %struct.I = type { i32 (...)** }
>  %struct.LARGE = type { %union.anon }
>  %union.anon = type { i32 }
>
> ; Function Attrs: nounwind
>  define void @_ZN1C4SeekE5LARGE(%struct.C* %this, %struct.LARGE* byval align 4) #0 align 2 {
> entry:
>
>   %this.addr = alloca %struct.C*, align 4
>   store %struct.C* %this, %struct.C** %this.addr, align 4
>   %this1 = load %struct.C*, %struct.C** %this.addr, align 4
>   ret void
>
> }
>
> attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }


D'oh, that m_fn1 should have been Seek :/

$ cat t.ii

  struct LARGE {
    union {
      int i;
    };
  };
  struct I {
    virtual void m_fn1(LARGE);
  };
  struct CBase {
    virtual ~CBase();
  };
  struct C : CBase, I {
    void m_fn1(LARGE);
  };
  void C::m_fn1(LARGE) {}

$ ~/llvm/Debug+Asserts/bin/clang -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.ii && grep tail t.ll

  tail call void @_ZN1C5m_fn1E5LARGE(%struct.C* %3, %struct.LARGE* byval align 4 %0)


https://reviews.llvm.org/D22900





More information about the cfe-commits mailing list