<div dir="ltr">I've messaged the author internally and pointed to the failing targets.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 27, 2020 at 4:04 PM Roman Lebedev <<a href="mailto:lebedev.ri@gmail.com">lebedev.ri@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Is there a reproducer in progress?<br>
<br>
On Thu, Feb 27, 2020 at 5:59 PM Kirill Bobyrev via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
><br>
> Author: Kirill Bobyrev<br>
> Date: 2020-02-27T15:58:39+01:00<br>
> New Revision: 4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43<br>
><br>
> URL: <a href="https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43</a><br>
> DIFF: <a href="https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43.diff</a><br>
><br>
> LOG: Revert "Devirtualize a call on alloca without waiting for post inline cleanup and next"<br>
><br>
> This reverts commit 59fb9cde7a4a96fe8485a80d9010e4420ffdca82.<br>
><br>
> The patch caused internal miscompilations.<br>
><br>
> Added:<br>
><br>
><br>
> Modified:<br>
>     clang/test/CodeGenCXX/member-function-pointer-calls.cpp<br>
>     llvm/lib/Transforms/IPO/Inliner.cpp<br>
><br>
> Removed:<br>
>     llvm/test/Transforms/Inline/devirtualize-4.ll<br>
><br>
><br>
> ################################################################################<br>
> diff  --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp<br>
> index 232b1f06df89..0e98b12e6e9d 100644<br>
> --- a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp<br>
> +++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp<br>
> @@ -11,8 +11,12 @@ int f(A* a, int (A::*fp)()) {<br>
>  }<br>
><br>
>  // CHECK-LABEL: define i32 @_Z2g1v()<br>
> -// CHECK-NOT: }<br>
> -// CHECK: ret i32 1<br>
> +// CHECK-LEGACY: ret i32 1<br>
> +// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8<br>
> +// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 0<br>
> +// CHECK-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** [[TMP]], align 8<br>
> +// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2<br>
> +// CHECK-NEWPM: ret i32 [[RET]]<br>
>  // MINGW64-LABEL: define dso_local i32 @_Z2g1v()<br>
>  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})<br>
>  int g1() {<br>
> @@ -21,7 +25,6 @@ int g1() {<br>
>  }<br>
><br>
>  // CHECK-LABEL: define i32 @_Z2g2v()<br>
> -// CHECK-NOT: }<br>
>  // CHECK: ret i32 2<br>
>  // MINGW64-LABEL: define dso_local i32 @_Z2g2v()<br>
>  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})<br>
><br>
> diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp<br>
> index 55753d979b2c..4f9f4bd1cd04 100644<br>
> --- a/llvm/lib/Transforms/IPO/Inliner.cpp<br>
> +++ b/llvm/lib/Transforms/IPO/Inliner.cpp<br>
> @@ -35,7 +35,6 @@<br>
>  #include "llvm/Analysis/TargetLibraryInfo.h"<br>
>  #include "llvm/Analysis/TargetTransformInfo.h"<br>
>  #include "llvm/Transforms/Utils/Local.h"<br>
> -#include "llvm/Transforms/Utils/CallPromotionUtils.h"<br>
>  #include "llvm/IR/Attributes.h"<br>
>  #include "llvm/IR/BasicBlock.h"<br>
>  #include "llvm/IR/CallSite.h"<br>
> @@ -1101,20 +1100,10 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,<br>
>        if (!IFI.InlinedCallSites.empty()) {<br>
>          int NewHistoryID = InlineHistory.size();<br>
>          InlineHistory.push_back({&Callee, InlineHistoryID});<br>
> -        for (CallSite &CS : reverse(IFI.InlinedCallSites)) {<br>
> -          Function *NewCallee = CS.getCalledFunction();<br>
> -          if (!NewCallee) {<br>
> -            // Try to promote an indirect (virtual) call without waiting for the<br>
> -            // post-inline cleanup and the next DevirtSCCRepeatedPass iteration<br>
> -            // because the next iteration may not happen and we may miss<br>
> -            // inlining it.<br>
> -            if (tryPromoteCall(CS))<br>
> -              NewCallee = CS.getCalledFunction();<br>
> -          }<br>
> -          if (NewCallee)<br>
> +        for (CallSite &CS : reverse(IFI.InlinedCallSites))<br>
> +          if (Function *NewCallee = CS.getCalledFunction())<br>
>              if (!NewCallee->isDeclaration())<br>
>                Calls.push_back({CS, NewHistoryID});<br>
> -        }<br>
>        }<br>
><br>
>        if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)<br>
><br>
> diff  --git a/llvm/test/Transforms/Inline/devirtualize-4.ll b/llvm/test/Transforms/Inline/devirtualize-4.ll<br>
> deleted file mode 100644<br>
> index 2205dae7aa23..000000000000<br>
> --- a/llvm/test/Transforms/Inline/devirtualize-4.ll<br>
> +++ /dev/null<br>
> @@ -1,214 +0,0 @@<br>
> -; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S | FileCheck %s<br>
> -; RUN: opt < %s -passes='default<O3>' -S | FileCheck %s<br>
> -<br>
> -; Check that DoNotOptimize is inlined into Test.<br>
> -; CHECK: @_Z4Testv()<br>
> -; CHECK-NOT: ret void<br>
> -; CHECK: call void asm<br>
> -; CHECK: ret void<br>
> -<br>
> -;template <class T><br>
> -;void DoNotOptimize(const T& var) {<br>
> -;  asm volatile("" : "+m"(const_cast<T&>(var)));<br>
> -;}<br>
> -;<br>
> -;class Interface {<br>
> -; public:<br>
> -;  virtual void Run() = 0;<br>
> -;};<br>
> -;<br>
> -;class Impl : public Interface {<br>
> -; public:<br>
> -;  Impl() : f(3) {}<br>
> -;  void Run() { DoNotOptimize(this); }<br>
> -;<br>
> -; private:<br>
> -;  int f;<br>
> -;};<br>
> -;<br>
> -;static void IndirectRun(Interface& o) { o.Run(); }<br>
> -;<br>
> -;void Test() {<br>
> -;  Impl o;<br>
> -;  IndirectRun(o);<br>
> -;}<br>
> -<br>
> -%class.Impl = type <{ %class.Interface, i32, [4 x i8] }><br>
> -%class.Interface = type { i32 (...)** }<br>
> -<br>
> -@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI4Impl to i8*), i8* bitcast (void (%class.Impl*)* @_ZN4Impl3RunEv to i8*)] }, align 8<br>
> -@_ZTVN10__cxxabiv120__si_class_type_infoE = external dso_local global i8*<br>
> -@_ZTS4Impl = linkonce_odr dso_local constant [6 x i8] c"4Impl\00", align 1<br>
> -@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*<br>
> -@_ZTS9Interface = linkonce_odr dso_local constant [11 x i8] c"9Interface\00", align 1<br>
> -@_ZTI9Interface = linkonce_odr dso_local constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTS9Interface, i32 0, i32 0) }, align 8<br>
> -@_ZTI4Impl = linkonce_odr dso_local constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Impl, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*) }, align 8<br>
> -@_ZTV9Interface = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*)] }, align 8<br>
> -<br>
> -define dso_local void @_Z4Testv() local_unnamed_addr {<br>
> -entry:<br>
> -  %o = alloca %class.Impl, align 8<br>
> -  %0 = bitcast %class.Impl* %o to i8*<br>
> -  call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0)<br>
> -  call void @_ZN4ImplC2Ev(%class.Impl* nonnull %o)<br>
> -  %1 = getelementptr inbounds %class.Impl, %class.Impl* %o, i64 0, i32 0<br>
> -  call fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* nonnull dereferenceable(8) %1)<br>
> -  call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0)<br>
> -  ret void<br>
> -}<br>
> -<br>
> -declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)<br>
> -<br>
> -define linkonce_odr dso_local void @_ZN4ImplC2Ev(%class.Impl* %this) unnamed_addr align 2 {<br>
> -entry:<br>
> -  %0 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0<br>
> -  call void @_ZN9InterfaceC2Ev(%class.Interface* %0)<br>
> -  %1 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0, i32 0<br>
> -  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Impl, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8<br>
> -  %f = getelementptr inbounds %class.Impl, %class.Impl* %this, i64 0, i32 1<br>
> -  store i32 3, i32* %f, align 8<br>
> -  ret void<br>
> -}<br>
> -<br>
> -define internal fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* dereferenceable(8) %o) unnamed_addr {<br>
> -entry:<br>
> -  %0 = bitcast %class.Interface* %o to void (%class.Interface*)***<br>
> -  %vtable = load void (%class.Interface*)**, void (%class.Interface*)*** %0, align 8<br>
> -  %1 = load void (%class.Interface*)*, void (%class.Interface*)** %vtable, align 8<br>
> -  call void %1(%class.Interface* nonnull %o)<br>
> -  ret void<br>
> -}<br>
> -<br>
> -declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)<br>
> -<br>
> -define linkonce_odr dso_local void @_ZN9InterfaceC2Ev(%class.Interface* %this) unnamed_addr align 2 {<br>
> -entry:<br>
> -  %0 = getelementptr %class.Interface, %class.Interface* %this, i64 0, i32 0<br>
> -  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV9Interface, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8<br>
> -  ret void<br>
> -}<br>
> -<br>
> -define linkonce_odr dso_local void @_ZN4Impl3RunEv(%class.Impl* %this) unnamed_addr align 2 {<br>
> -entry:<br>
> -  %ref.tmp = alloca %class.Impl*, align 8<br>
> -  %0 = bitcast %class.Impl** %ref.tmp to i8*<br>
> -  call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)<br>
> -  store %class.Impl* %this, %class.Impl** %ref.tmp, align 8<br>
> -  call void @_Z13DoNotOptimizeIP4ImplEvRKT_(%class.Impl** nonnull dereferenceable(8) %ref.tmp)<br>
> -  call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0)<br>
> -  ret void<br>
> -}<br>
> -<br>
> -declare dso_local void @__cxa_pure_virtual() unnamed_addr<br>
> -<br>
> -define linkonce_odr dso_local void @_Z13DoNotOptimizeIP4ImplEvRKT_(%class.Impl** dereferenceable(8) %var) local_unnamed_addr {<br>
> -entry:<br>
> -  call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(%class.Impl** nonnull %var, %class.Impl** nonnull %var)<br>
> -  ret void<br>
> -}<br>
> -<br>
> -<br>
> -; Based on clang/test/CodeGenCXX/member-function-pointer-calls.cpp.<br>
> -; Check that vf1 and vf2 are inlined into g1 and g2.<br>
> -; CHECK: @_Z2g1v()<br>
> -; CHECK-NOT: }<br>
> -; CHECK: ret i32 1<br>
> -; CHECK: @_Z2g2v()<br>
> -; CHECK-NOT: }<br>
> -; CHECK: ret i32 2<br>
> -;<br>
> -;struct A {<br>
> -;  virtual int vf1() { return 1; }<br>
> -;  virtual int vf2() { return 2; }<br>
> -;};<br>
> -;<br>
> -;int f(A* a, int (A::*fp)()) {<br>
> -;  return (a->*fp)();<br>
> -;}<br>
> -;int g1() {<br>
> -;  A a;<br>
> -;  return f(&a, &A::vf1);<br>
> -;}<br>
> -;int g2() {<br>
> -;  A a;<br>
> -;  return f(&a, &A::vf2);<br>
> -;}<br>
> -<br>
> -%struct.A = type { i32 (...)** }<br>
> -<br>
> -@_ZTV1A = linkonce_odr unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A3vf1Ev to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A3vf2Ev to i8*)] }, align 8<br>
> -@_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", align 1<br>
> -@_ZTI1A = linkonce_odr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1A, i32 0, i32 0) }, align 8<br>
> -<br>
> -define i32 @_Z1fP1AMS_FivE(%struct.A* %a, i64 %fp.coerce0, i64 %fp.coerce1) {<br>
> -entry:<br>
> -  %0 = bitcast %struct.A* %a to i8*<br>
> -  %1 = getelementptr inbounds i8, i8* %0, i64 %fp.coerce1<br>
> -  %this.adjusted = bitcast i8* %1 to %struct.A*<br>
> -  %2 = and i64 %fp.coerce0, 1<br>
> -  %memptr.isvirtual = icmp eq i64 %2, 0<br>
> -  br i1 %memptr.isvirtual, label %memptr.nonvirtual, label %memptr.virtual<br>
> -<br>
> -memptr.virtual:                                   ; preds = %entry<br>
> -  %3 = bitcast i8* %1 to i8**<br>
> -  %vtable = load i8*, i8** %3, align 8<br>
> -  %4 = add i64 %fp.coerce0, -1<br>
> -  %5 = getelementptr i8, i8* %vtable, i64 %4<br>
> -  %6 = bitcast i8* %5 to i32 (%struct.A*)**<br>
> -  %memptr.virtualfn = load i32 (%struct.A*)*, i32 (%struct.A*)** %6, align 8<br>
> -  br label %memptr.end<br>
> -<br>
> -memptr.nonvirtual:                                ; preds = %entry<br>
> -  %memptr.nonvirtualfn = inttoptr i64 %fp.coerce0 to i32 (%struct.A*)*<br>
> -  br label %memptr.end<br>
> -<br>
> -memptr.end:                                       ; preds = %memptr.nonvirtual, %memptr.virtual<br>
> -  %7 = phi i32 (%struct.A*)* [ %memptr.virtualfn, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ]<br>
> -  %call = call i32 %7(%struct.A* %this.adjusted)<br>
> -  ret i32 %call<br>
> -}<br>
> -<br>
> -define i32 @_Z2g1v() {<br>
> -entry:<br>
> -  %a = alloca %struct.A, align 8<br>
> -  %0 = bitcast %struct.A* %a to i8*<br>
> -  call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)<br>
> -  call void @_ZN1AC1Ev(%struct.A* nonnull %a)<br>
> -  %call = call i32 @_Z1fP1AMS_FivE(%struct.A* nonnull %a, i64 1, i64 0)<br>
> -  call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0)<br>
> -  ret i32 %call<br>
> -}<br>
> -<br>
> -define linkonce_odr void @_ZN1AC1Ev(%struct.A* %this) align 2 {<br>
> -entry:<br>
> -  call void @_ZN1AC2Ev(%struct.A* %this)<br>
> -  ret void<br>
> -}<br>
> -<br>
> -define i32 @_Z2g2v() {<br>
> -entry:<br>
> -  %a = alloca %struct.A, align 8<br>
> -  %0 = bitcast %struct.A* %a to i8*<br>
> -  call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)<br>
> -  call void @_ZN1AC1Ev(%struct.A* nonnull %a)<br>
> -  %call = call i32 @_Z1fP1AMS_FivE(%struct.A* nonnull %a, i64 9, i64 0)<br>
> -  call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0)<br>
> -  ret i32 %call<br>
> -}<br>
> -<br>
> -define linkonce_odr void @_ZN1AC2Ev(%struct.A* %this) align 2 {<br>
> -entry:<br>
> -  %0 = getelementptr %struct.A, %struct.A* %this, i64 0, i32 0<br>
> -  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8<br>
> -  ret void<br>
> -}<br>
> -<br>
> -define linkonce_odr i32 @_ZN1A3vf1Ev(%struct.A* %this) align 2 {<br>
> -entry:<br>
> -  ret i32 1<br>
> -}<br>
> -<br>
> -define linkonce_odr i32 @_ZN1A3vf2Ev(%struct.A* %this) align 2 {<br>
> -entry:<br>
> -  ret i32 2<br>
> -}<br>
><br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>