r368323 - Recommit Devirtualize destructor of final class.

2019-08-08 Thread Hiroshi Yamauchi via cfe-commits
Author: yamauchi
Date: Thu Aug  8 11:00:49 2019
New Revision: 368323

URL: http://llvm.org/viewvc/llvm-project?rev=368323&view=rev
Log:
Recommit Devirtualize destructor of final class.

Original patch commited as r364100, reverted as r364359, recommitted as r365509,
reverted as r365850.


Added:
cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=368323&r1=368322&r2=368323&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu Aug  8 11:00:49 2019
@@ -1882,9 +1882,33 @@ static void EmitObjectDelete(CodeGenFunc
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }

Added: cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp?rev=368323&view=auto
==
--- cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp Thu Aug  8 11:00:49 
2019
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void @_ZN5Test11DD1Ev
+delete p;
+  }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364100 - Devirtualize destructor of final class.

2019-06-21 Thread Hiroshi Yamauchi via cfe-commits
Author: yamauchi
Date: Fri Jun 21 13:04:29 2019
New Revision: 364100

URL: http://llvm.org/viewvc/llvm-project?rev=364100&view=rev
Log:
Devirtualize destructor of final class.

Summary:
Take advantage of the final keyword to devirtualize destructor calls.

Fix https://bugs.llvm.org/show_bug.cgi?id=21368

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: davidxl, Prazek, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63161

Added:
cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=364100&r1=364099&r2=364100&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Jun 21 13:04:29 2019
@@ -1865,9 +1865,33 @@ static void EmitObjectDelete(CodeGenFunc
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }

Added: cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp?rev=364100&view=auto
==
--- cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp Fri Jun 21 13:04:29 
2019
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void @_ZN5Test11DD1Ev
+delete p;
+  }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365509 - Revert Revert Devirtualize destructor of final class.

2019-07-09 Thread Hiroshi Yamauchi via cfe-commits
Author: yamauchi
Date: Tue Jul  9 08:57:29 2019
New Revision: 365509

URL: http://llvm.org/viewvc/llvm-project?rev=365509&view=rev
Log:
Revert Revert Devirtualize destructor of final class.

Revert r364359 and recommit r364100.

r364100 was reverted as r364359 due to an internal test failure, but it was a
false alarm.



Added:
cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=365509&r1=365508&r2=365509&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Jul  9 08:57:29 2019
@@ -1865,9 +1865,33 @@ static void EmitObjectDelete(CodeGenFunc
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }

Added: cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp?rev=365509&view=auto
==
--- cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp Tue Jul  9 08:57:29 
2019
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void @_ZN5Test11DD1Ev
+delete p;
+  }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 120e66b - [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-07-29T13:59:40-07:00
New Revision: 120e66b3418b37b95fc1dbbb23e296a602a24fa8

URL: 
https://github.com/llvm/llvm-project/commit/120e66b3418b37b95fc1dbbb23e296a602a24fa8
DIFF: 
https://github.com/llvm/llvm-project/commit/120e66b3418b37b95fc1dbbb23e296a602a24fa8.diff

LOG: [PGO] Include the mem ops into the function hash.

To avoid hash collisions when the only difference is in mem ops.

Differential Revision: https://reviews.llvm.org/D84782

Added: 


Modified: 
clang/test/CodeGen/Inputs/thinlto_expect1.proftext
clang/test/CodeGen/Inputs/thinlto_expect2.proftext
clang/test/CodeGenCXX/Inputs/profile-remap.proftext
clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
compiler-rt/test/profile/Linux/instrprof-value-merge.c
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext

llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Removed: 




diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
index e7ce3a4ee237..0c904e2ea1c8 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
@@ -2,7 +2,7 @@
 :ir
 foo
 # Func Hash:
-25571299074
+784007059655560962
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
index f9de785587ab..c240a442c465 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
@@ -2,7 +2,7 @@
 :csir
 foo
 # Func Hash:
-25571299074
+784007059655560962
 # Num Counters:
 2
 # Counter Values:
@@ -11,7 +11,7 @@ foo
 
 foo
 # Func Hash:
-1152921530178146050
+1936928564262407938
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext 
b/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
index a1f90cfa6e9e..bf57fc696c49 100644
--- a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
+++

[clang] ae7589e - Revert "[PGO] Include the mem ops into the function hash."

2020-07-29 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-07-29T15:04:57-07:00
New Revision: ae7589e1f100b30a4ae13da713c9273733e69fe1

URL: 
https://github.com/llvm/llvm-project/commit/ae7589e1f100b30a4ae13da713c9273733e69fe1
DIFF: 
https://github.com/llvm/llvm-project/commit/ae7589e1f100b30a4ae13da713c9273733e69fe1.diff

LOG: Revert "[PGO] Include the mem ops into the function hash."

This reverts commit 120e66b3418b37b95fc1dbbb23e296a602a24fa8.

Due to a buildbot failure.

Added: 


Modified: 
clang/test/CodeGen/Inputs/thinlto_expect1.proftext
clang/test/CodeGen/Inputs/thinlto_expect2.proftext
clang/test/CodeGenCXX/Inputs/profile-remap.proftext
clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
compiler-rt/test/profile/Linux/instrprof-value-merge.c
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext

llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Removed: 




diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
index 0c904e2ea1c8..e7ce3a4ee237 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
@@ -2,7 +2,7 @@
 :ir
 foo
 # Func Hash:
-784007059655560962
+25571299074
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
index c240a442c465..f9de785587ab 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
@@ -2,7 +2,7 @@
 :csir
 foo
 # Func Hash:
-784007059655560962
+25571299074
 # Num Counters:
 2
 # Counter Values:
@@ -11,7 +11,7 @@ foo
 
 foo
 # Func Hash:
-1936928564262407938
+1152921530178146050
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext 
b/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
index bf57fc696c49..a1f90cfa6e9e 100644
--- a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
+++ b/clang/test/CodeGenC

[clang] 3d6f530 - [PGO] Include the mem ops into the function hash.

2020-07-30 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-07-30T09:26:20-07:00
New Revision: 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d

URL: 
https://github.com/llvm/llvm-project/commit/3d6f53018f845e893ad34f64ff2851a2e5c3ba1d
DIFF: 
https://github.com/llvm/llvm-project/commit/3d6f53018f845e893ad34f64ff2851a2e5c3ba1d.diff

LOG: [PGO] Include the mem ops into the function hash.

To avoid hash collisions when the only difference is in mem ops.

Added: 


Modified: 
clang/test/CodeGen/Inputs/thinlto_expect1.proftext
clang/test/CodeGen/Inputs/thinlto_expect2.proftext
clang/test/CodeGenCXX/Inputs/profile-remap.proftext
clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
compiler-rt/test/profile/Linux/instrprof-value-merge.c
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext

llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Removed: 




diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
index e7ce3a4ee237..0c904e2ea1c8 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
@@ -2,7 +2,7 @@
 :ir
 foo
 # Func Hash:
-25571299074
+784007059655560962
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
index f9de785587ab..c240a442c465 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
@@ -2,7 +2,7 @@
 :csir
 foo
 # Func Hash:
-25571299074
+784007059655560962
 # Num Counters:
 2
 # Counter Values:
@@ -11,7 +11,7 @@ foo
 
 foo
 # Func Hash:
-1152921530178146050
+1936928564262407938
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext 
b/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
index a1f90cfa6e9e..bf57fc696c49 100644
--- a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
+++ b/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
@

[clang] ce82b8e - [HIP] Improve check patterns to avoid test failures in case string "opt",

2020-06-18 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-06-18T10:14:31-07:00
New Revision: ce82b8e8af6d9e95e15624c4fb8af2faac68ff63

URL: 
https://github.com/llvm/llvm-project/commit/ce82b8e8af6d9e95e15624c4fb8af2faac68ff63
DIFF: 
https://github.com/llvm/llvm-project/commit/ce82b8e8af6d9e95e15624c4fb8af2faac68ff63.diff

LOG: [HIP] Improve check patterns to avoid test failures in case string "opt",
etc. happens to be in the InstallDir path in the -### output.

Differential Revision: https://reviews.llvm.org/D82046

Added: 


Modified: 
clang/test/Driver/hip-toolchain-no-rdc.hip

Removed: 




diff  --git a/clang/test/Driver/hip-toolchain-no-rdc.hip 
b/clang/test/Driver/hip-toolchain-no-rdc.hip
index 6bf46a301f99..937da40049e7 100644
--- a/clang/test/Driver/hip-toolchain-no-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9da93f5 - [HIP] Improve check patterns to avoid test failures in case string "opt", etc. happens to be in the command path.

2020-06-25 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-06-25T12:18:43-07:00
New Revision: 9da93f590414ae3b7be20061d8a97695b263482e

URL: 
https://github.com/llvm/llvm-project/commit/9da93f590414ae3b7be20061d8a97695b263482e
DIFF: 
https://github.com/llvm/llvm-project/commit/9da93f590414ae3b7be20061d8a97695b263482e.diff

LOG: [HIP] Improve check patterns to avoid test failures in case string "opt", 
etc. happens to be in the command path.

Similarly to D82046.

Differential Revision: https://reviews.llvm.org/D82586

Added: 


Modified: 
clang/test/Driver/hip-link-save-temps.hip

Removed: 




diff  --git a/clang/test/Driver/hip-link-save-temps.hip 
b/clang/test/Driver/hip-link-save-temps.hip
index 15ab210a84f7..d03cf1e5f4a9 100644
--- a/clang/test/Driver/hip-link-save-temps.hip
+++ b/clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-08-05 Thread Hiroshi Yamauchi via cfe-commits
On Wed, Aug 5, 2020 at 8:30 AM Hans Wennborg via Phabricator <
revi...@reviews.llvm.org> wrote:

> hans added a comment.
>
> In D84782#2191429 , @yamauchi
> wrote:
>
> > In D84782#2191243 , @MaskRay
> wrote:
> >
> >> @yamauchi Do we need cd890944ad344b1b8cac58332ab11c9eec6b61e9 <
> https://reviews.llvm.org/rGcd890944ad344b1b8cac58332ab11c9eec6b61e9> and
> 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d <
> https://reviews.llvm.org/rG3d6f53018f845e893ad34f64ff2851a2e5c3ba1d> in
> https://github.com/llvm/llvm-project/tree/release/11.x ?
> >
> > I think it'd be good to have them, if possible, though it's a latent,
> non-recent bug.
>
> They're hard to apply without 50da55a58534e9207d8d5e31c8b4b5cf0c624175 <
> https://reviews.llvm.org/rG50da55a58534e9207d8d5e31c8b4b5cf0c624175>. Do
> you think we should take that also? Or maybe this can wait since it's not a
> new bug.
>

50da55a58534e9207d8d5e31c8b4b5cf0c624175 isn't a bug fix but it's not
changing the default behavior. So, it is probably safe to take it. That
said, I'd say this can wait unless there's some immediate issue, since it's
not a new bug.


>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D84782/new/
>
> https://reviews.llvm.org/D84782
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 59fb9cd - Devirtualize a call on alloca without waiting for post inline cleanup and next

2020-02-26 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-02-26T09:51:24-08:00
New Revision: 59fb9cde7a4a96fe8485a80d9010e4420ffdca82

URL: 
https://github.com/llvm/llvm-project/commit/59fb9cde7a4a96fe8485a80d9010e4420ffdca82
DIFF: 
https://github.com/llvm/llvm-project/commit/59fb9cde7a4a96fe8485a80d9010e4420ffdca82.diff

LOG: Devirtualize a call on alloca without waiting for post inline cleanup and 
next
DevirtSCCRepeatedPass iteration.  Needs ReviewPublic

This aims to fix a missed inlining case.

If there's a virtual call in the callee on an alloca (stack allocated object) in
the caller, and the callee is inlined into the caller, the post-inline cleanup
would devirtualize the virtual call, but if the next iteration of
DevirtSCCRepeatedPass doesn't happen (under the new pass manager), which is
based on a heuristic to determine whether to reiterate, we may miss inlining the
devirtualized call.

This enables inlining in 
clang/test/CodeGenCXX/member-function-pointer-calls.cpp.

Added: 
llvm/test/Transforms/Inline/devirtualize-4.ll

Modified: 
clang/test/CodeGenCXX/member-function-pointer-calls.cpp
llvm/lib/Transforms/IPO/Inliner.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp 
b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
index 0e98b12e6e9d..232b1f06df89 100644
--- a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
+++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -11,12 +11,8 @@ int f(A* a, int (A::*fp)()) {
 }
 
 // CHECK-LABEL: define i32 @_Z2g1v()
-// CHECK-LEGACY: ret i32 1
-// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
-// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* %a, 
i64 0, i32 0
-// 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
-// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2
-// CHECK-NEWPM: ret i32 [[RET]]
+// CHECK-NOT: }
+// CHECK: ret i32 1
 // MINGW64-LABEL: define dso_local i32 @_Z2g1v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
 int g1() {
@@ -25,6 +21,7 @@ int g1() {
 }
 
 // CHECK-LABEL: define i32 @_Z2g2v()
+// CHECK-NOT: }
 // CHECK: ret i32 2
 // MINGW64-LABEL: define dso_local i32 @_Z2g2v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})

diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp 
b/llvm/lib/Transforms/IPO/Inliner.cpp
index 4f9f4bd1cd04..55753d979b2c 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Transforms/Utils/CallPromotionUtils.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallSite.h"
@@ -1100,10 +1101,20 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC 
&InitialC,
   if (!IFI.InlinedCallSites.empty()) {
 int NewHistoryID = InlineHistory.size();
 InlineHistory.push_back({&Callee, InlineHistoryID});
-for (CallSite &CS : reverse(IFI.InlinedCallSites))
-  if (Function *NewCallee = CS.getCalledFunction())
+for (CallSite &CS : reverse(IFI.InlinedCallSites)) {
+  Function *NewCallee = CS.getCalledFunction();
+  if (!NewCallee) {
+// Try to promote an indirect (virtual) call without waiting for 
the
+// post-inline cleanup and the next DevirtSCCRepeatedPass iteration
+// because the next iteration may not happen and we may miss
+// inlining it.
+if (tryPromoteCall(CS))
+  NewCallee = CS.getCalledFunction();
+  }
+  if (NewCallee)
 if (!NewCallee->isDeclaration())
   Calls.push_back({CS, NewHistoryID});
+}
   }
 
   if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)

diff  --git a/llvm/test/Transforms/Inline/devirtualize-4.ll 
b/llvm/test/Transforms/Inline/devirtualize-4.ll
new file mode 100644
index ..2205dae7aa23
--- /dev/null
+++ b/llvm/test/Transforms/Inline/devirtualize-4.ll
@@ -0,0 +1,214 @@
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S 
| FileCheck %s
+; RUN: opt < %s -passes='default' -S | FileCheck %s
+
+; Check that DoNotOptimize is inlined into Test.
+; CHECK: @_Z4Testv()
+; CHECK-NOT: ret void
+; CHECK: call void asm
+; CHECK: ret void
+
+;template 
+;void DoNotOptimize(const T& var) {
+;  asm volatile("" : "+m"(const_cast(var)));
+;}
+;
+;class Interface {
+; public:
+;  virtual void Run() = 0;
+;};
+;
+;class Impl : public Interface {
+; public:
+;  Impl() : f(3) {}
+;  void Run() { DoNotOptimize(this); }
+;
+; private:
+;  int f;
+;};
+

[clang] f16d2be - Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-28 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-02-28T09:43:32-08:00
New Revision: f16d2bec40691f4050174c99600847d024486bc5

URL: 
https://github.com/llvm/llvm-project/commit/f16d2bec40691f4050174c99600847d024486bc5
DIFF: 
https://github.com/llvm/llvm-project/commit/f16d2bec40691f4050174c99600847d024486bc5.diff

LOG: Devirtualize a call on alloca without waiting for post inline cleanup and 
next DevirtSCCRepeatedPass iteration.

This aims to fix a missed inlining case.

If there's a virtual call in the callee on an alloca (stack allocated object) in
the caller, and the callee is inlined into the caller, the post-inline cleanup
would devirtualize the virtual call, but if the next iteration of
DevirtSCCRepeatedPass doesn't happen (under the new pass manager), which is
based on a heuristic to determine whether to reiterate, we may miss inlining the
devirtualized call.

This enables inlining in 
clang/test/CodeGenCXX/member-function-pointer-calls.cpp.

This is a second commit after a revert
https://reviews.llvm.org/rG4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43 and a fix
https://reviews.llvm.org/rG41e06ae7ba91.

Differential Revision: https://reviews.llvm.org/D69591

Added: 
llvm/test/Transforms/Inline/devirtualize-4.ll

Modified: 
clang/test/CodeGenCXX/member-function-pointer-calls.cpp
llvm/lib/Transforms/IPO/Inliner.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp 
b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
index 0e98b12e6e9d..232b1f06df89 100644
--- a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
+++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -11,12 +11,8 @@ int f(A* a, int (A::*fp)()) {
 }
 
 // CHECK-LABEL: define i32 @_Z2g1v()
-// CHECK-LEGACY: ret i32 1
-// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
-// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* %a, 
i64 0, i32 0
-// 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
-// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2
-// CHECK-NEWPM: ret i32 [[RET]]
+// CHECK-NOT: }
+// CHECK: ret i32 1
 // MINGW64-LABEL: define dso_local i32 @_Z2g1v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
 int g1() {
@@ -25,6 +21,7 @@ int g1() {
 }
 
 // CHECK-LABEL: define i32 @_Z2g2v()
+// CHECK-NOT: }
 // CHECK: ret i32 2
 // MINGW64-LABEL: define dso_local i32 @_Z2g2v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})

diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp 
b/llvm/lib/Transforms/IPO/Inliner.cpp
index d35d8f562b3f..5ce3da340ade 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Transforms/Utils/CallPromotionUtils.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallSite.h"
@@ -1103,10 +1104,20 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC 
&InitialC,
   if (!IFI.InlinedCallSites.empty()) {
 int NewHistoryID = InlineHistory.size();
 InlineHistory.push_back({&Callee, InlineHistoryID});
-for (CallSite &CS : reverse(IFI.InlinedCallSites))
-  if (Function *NewCallee = CS.getCalledFunction())
+for (CallSite &CS : reverse(IFI.InlinedCallSites)) {
+  Function *NewCallee = CS.getCalledFunction();
+  if (!NewCallee) {
+// Try to promote an indirect (virtual) call without waiting for 
the
+// post-inline cleanup and the next DevirtSCCRepeatedPass iteration
+// because the next iteration may not happen and we may miss
+// inlining it.
+if (tryPromoteCall(CS))
+  NewCallee = CS.getCalledFunction();
+  }
+  if (NewCallee)
 if (!NewCallee->isDeclaration())
   Calls.push_back({CS, NewHistoryID});
+}
   }
 
   if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)

diff  --git a/llvm/test/Transforms/Inline/devirtualize-4.ll 
b/llvm/test/Transforms/Inline/devirtualize-4.ll
new file mode 100644
index ..2205dae7aa23
--- /dev/null
+++ b/llvm/test/Transforms/Inline/devirtualize-4.ll
@@ -0,0 +1,214 @@
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S 
| FileCheck %s
+; RUN: opt < %s -passes='default' -S | FileCheck %s
+
+; Check that DoNotOptimize is inlined into Test.
+; CHECK: @_Z4Testv()
+; CHECK-NOT: ret void
+; CHECK: call void asm
+; CHECK: ret void
+
+;template 
+;void DoNotOptimize(const T& var) {
+;  asm volatile("" : "+m"(const_cast(var)));
+;}
+;
+;class In

[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-08 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi created 
https://github.com/llvm/llvm-project/pull/111597

In MSVC, the calling conventions for free functions and C++ instance methods 
could be different, it makes sense to have this variant there.

>From 7be9488cc36596788ea6a1b979cb028e3c28e961 Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Tue, 8 Oct 2024 15:16:06 -0700
Subject: [PATCH] Add arrangeCXXMethodCall to the CodeGenABITypes interface.

In MSVC, the calling conventions for free functions and C++ instance
methods could be different, it makes sense to have this variant there.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h |  6 ++
 clang/lib/CodeGen/CodeGenABITypes.cpp | 11 +++
 2 files changed, 17 insertions(+)

diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..3d29c45cf0cf1b 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,6 +75,12 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
+const CGFunctionInfo &arrangeCXXMethodCall(CodeGenModule &CGM,
+   CanQualType returnType,
+   ArrayRef argTypes,
+   FunctionType::ExtInfo info,
+   RequiredArgs args);
+
 const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
   CanQualType returnType,
   ArrayRef argTypes,
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..283aa8425867ab 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -59,6 +59,17 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
+const CGFunctionInfo &
+CodeGen::arrangeCXXMethodCall(CodeGenModule &CGM,
+  CanQualType returnType,
+  ArrayRef argTypes,
+  FunctionType::ExtInfo info,
+  RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(returnType,
+FnInfoOpts::IsInstanceMethod,
+argTypes, info, {}, args);
+}
+
 const CGFunctionInfo &
 CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
  CanQualType returnType,

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-10 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi updated 
https://github.com/llvm/llvm-project/pull/111597

>From 98f58ce20a610388fd38bac2864b4e8afcf1b463 Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Thu, 10 Oct 2024 13:50:01 -0700
Subject: [PATCH] Add arrangeCXXMethodCall to the CodeGenABITypes interface.

Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h | 24 ++
 clang/lib/CodeGen/CodeGenABITypes.cpp | 25 +--
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..836fdd75477c76 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,11 +75,25 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
-const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
-  CanQualType returnType,
-  ArrayRef argTypes,
-  FunctionType::ExtInfo info,
-  RequiredArgs args);
+const CGFunctionInfo &
+arrangeCXXMethodCall(CodeGenModule &CGM, CanQualType returnType,
+ ArrayRef argTypes, FunctionType::ExtInfo 
info,
+ ArrayRef paramInfos,
+ RequiredArgs args);
+
+const CGFunctionInfo &arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args);
+
+// An overload with an empty `paramInfos`
+inline const CGFunctionInfo &
+arrangeFreeFunctionCall(CodeGenModule &CGM, CanQualType returnType,
+ArrayRef argTypes,
+FunctionType::ExtInfo info, RequiredArgs args) {
+  return arrangeFreeFunctionCall(CGM, returnType, argTypes, info, {}, args);
+}
 
 /// Returns the implicit arguments to add to a complete, non-delegating C++
 /// constructor call.
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..3f10d68f8c5d45 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -59,14 +59,23 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
-const CGFunctionInfo &
-CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
- CanQualType returnType,
- ArrayRef argTypes,
- FunctionType::ExtInfo info,
- RequiredArgs args) {
-  return CGM.getTypes().arrangeLLVMFunctionInfo(returnType, FnInfoOpts::None,
-argTypes, info, {}, args);
+const CGFunctionInfo &CodeGen::arrangeCXXMethodCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::IsInstanceMethod, argTypes, info, paramInfos,
+  args);
+}
+
+const CGFunctionInfo &CodeGen::arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::None, argTypes, info, paramInfos, args);
 }
 
 ImplicitCXXConstructorArgs

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-08 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi updated 
https://github.com/llvm/llvm-project/pull/111597

>From 47449911273a69b5a2aa89789aeb7e35b66ff0e2 Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Tue, 8 Oct 2024 15:16:06 -0700
Subject: [PATCH] Add arrangeCXXMethodCall to the CodeGenABITypes interface.

In MSVC, the calling conventions for free functions and C++ instance
methods could be different, it makes sense to have this variant there.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h | 6 ++
 clang/lib/CodeGen/CodeGenABITypes.cpp | 8 
 2 files changed, 14 insertions(+)

diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..3d29c45cf0cf1b 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,6 +75,12 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
+const CGFunctionInfo &arrangeCXXMethodCall(CodeGenModule &CGM,
+   CanQualType returnType,
+   ArrayRef argTypes,
+   FunctionType::ExtInfo info,
+   RequiredArgs args);
+
 const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
   CanQualType returnType,
   ArrayRef argTypes,
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..972bc4137c6053 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -59,6 +59,14 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
+const CGFunctionInfo &
+CodeGen::arrangeCXXMethodCall(CodeGenModule &CGM, CanQualType returnType,
+  ArrayRef argTypes,
+  FunctionType::ExtInfo info, RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::IsInstanceMethod, argTypes, info, {}, args);
+}
+
 const CGFunctionInfo &
 CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
  CanQualType returnType,

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-08 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi ready_for_review 
https://github.com/llvm/llvm-project/pull/111597
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-11 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi updated 
https://github.com/llvm/llvm-project/pull/111597

>From 1ccc7c1e107cc4a1b8a0bb65a87f2ed019a72d4b Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Thu, 10 Oct 2024 13:50:01 -0700
Subject: [PATCH] Add arrangeCXXMethodCall to the CodeGenABITypes interface.

Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h | 24 ++
 clang/lib/CodeGen/CodeGenABITypes.cpp | 25 +--
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..836fdd75477c76 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,11 +75,25 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
-const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
-  CanQualType returnType,
-  ArrayRef argTypes,
-  FunctionType::ExtInfo info,
-  RequiredArgs args);
+const CGFunctionInfo &
+arrangeCXXMethodCall(CodeGenModule &CGM, CanQualType returnType,
+ ArrayRef argTypes, FunctionType::ExtInfo 
info,
+ ArrayRef paramInfos,
+ RequiredArgs args);
+
+const CGFunctionInfo &arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args);
+
+// An overload with an empty `paramInfos`
+inline const CGFunctionInfo &
+arrangeFreeFunctionCall(CodeGenModule &CGM, CanQualType returnType,
+ArrayRef argTypes,
+FunctionType::ExtInfo info, RequiredArgs args) {
+  return arrangeFreeFunctionCall(CGM, returnType, argTypes, info, {}, args);
+}
 
 /// Returns the implicit arguments to add to a complete, non-delegating C++
 /// constructor call.
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..3f10d68f8c5d45 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -59,14 +59,23 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
-const CGFunctionInfo &
-CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
- CanQualType returnType,
- ArrayRef argTypes,
- FunctionType::ExtInfo info,
- RequiredArgs args) {
-  return CGM.getTypes().arrangeLLVMFunctionInfo(returnType, FnInfoOpts::None,
-argTypes, info, {}, args);
+const CGFunctionInfo &CodeGen::arrangeCXXMethodCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::IsInstanceMethod, argTypes, info, paramInfos,
+  args);
+}
+
+const CGFunctionInfo &CodeGen::arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::None, argTypes, info, paramInfos, args);
 }
 
 ImplicitCXXConstructorArgs

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-16 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi closed 
https://github.com/llvm/llvm-project/pull/111597
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-10 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi updated 
https://github.com/llvm/llvm-project/pull/111597

>From 1c7101f579c4eb65773d8af7bdd7a3b37247f554 Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Thu, 10 Oct 2024 13:50:01 -0700
Subject: [PATCH] Add arrangeCXXMethodCall to the CodeGenABITypes interface.

Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h | 24 ++
 clang/lib/CodeGen/CodeGenABITypes.cpp | 25 +--
 2 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..e275f5c944c707 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,11 +75,25 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
-const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
-  CanQualType returnType,
-  ArrayRef argTypes,
-  FunctionType::ExtInfo info,
-  RequiredArgs args);
+const CGFunctionInfo &arrangeCXXMethodCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args);
+
+const CGFunctionInfo &arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args);
+
+// An overload with an empty `paramInfos`
+inline const CGFunctionInfo &arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+RequiredArgs args) {
+  return arrangeFreeFunctionCall(CGM, returnType, argTypes, info, {}, args);
+}
 
 /// Returns the implicit arguments to add to a complete, non-delegating C++
 /// constructor call.
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..b3c16288d3422a 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -60,13 +60,24 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
 }
 
 const CGFunctionInfo &
-CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
- CanQualType returnType,
- ArrayRef argTypes,
- FunctionType::ExtInfo info,
- RequiredArgs args) {
-  return CGM.getTypes().arrangeLLVMFunctionInfo(returnType, FnInfoOpts::None,
-argTypes, info, {}, args);
+CodeGen::arrangeCXXMethodCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::IsInstanceMethod, argTypes, info, paramInfos,
+  args);
+}
+
+const CGFunctionInfo &
+CodeGen::arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::None, argTypes, info, paramInfos, args);
 }
 
 ImplicitCXXConstructorArgs

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-10 Thread Hiroshi Yamauchi via cfe-commits


@@ -75,6 +75,12 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
+const CGFunctionInfo &arrangeCXXMethodCall(CodeGenModule &CGM,
+   CanQualType returnType,
+   ArrayRef argTypes,
+   FunctionType::ExtInfo info,
+   RequiredArgs args);

hjyamauchi wrote:

@rjmccall Updated. Do you mean like the latest revision?

https://github.com/llvm/llvm-project/pull/111597
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-15 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi updated 
https://github.com/llvm/llvm-project/pull/111597

>From ae4cdf4458b84b5fe5ab22f1ef4b5ceaf439a4f0 Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Thu, 10 Oct 2024 13:50:01 -0700
Subject: [PATCH] Add arrangeCXXMethodCall to the CodeGenABITypes interface.

Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h | 24 ++
 clang/lib/CodeGen/CodeGenABITypes.cpp | 25 +--
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..836fdd75477c76 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,11 +75,25 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
-const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
-  CanQualType returnType,
-  ArrayRef argTypes,
-  FunctionType::ExtInfo info,
-  RequiredArgs args);
+const CGFunctionInfo &
+arrangeCXXMethodCall(CodeGenModule &CGM, CanQualType returnType,
+ ArrayRef argTypes, FunctionType::ExtInfo 
info,
+ ArrayRef paramInfos,
+ RequiredArgs args);
+
+const CGFunctionInfo &arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args);
+
+// An overload with an empty `paramInfos`
+inline const CGFunctionInfo &
+arrangeFreeFunctionCall(CodeGenModule &CGM, CanQualType returnType,
+ArrayRef argTypes,
+FunctionType::ExtInfo info, RequiredArgs args) {
+  return arrangeFreeFunctionCall(CGM, returnType, argTypes, info, {}, args);
+}
 
 /// Returns the implicit arguments to add to a complete, non-delegating C++
 /// constructor call.
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..3f10d68f8c5d45 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -59,14 +59,23 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
-const CGFunctionInfo &
-CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
- CanQualType returnType,
- ArrayRef argTypes,
- FunctionType::ExtInfo info,
- RequiredArgs args) {
-  return CGM.getTypes().arrangeLLVMFunctionInfo(returnType, FnInfoOpts::None,
-argTypes, info, {}, args);
+const CGFunctionInfo &CodeGen::arrangeCXXMethodCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::IsInstanceMethod, argTypes, info, paramInfos,
+  args);
+}
+
+const CGFunctionInfo &CodeGen::arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::None, argTypes, info, paramInfos, args);
 }
 
 ImplicitCXXConstructorArgs

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-21 Thread Hiroshi Yamauchi via cfe-commits

hjyamauchi wrote:

An assertion failure like the above was encountered in the swift toolchain in 
the context of this PR https://github.com/swiftlang/swift/pull/78184 which uses 
a module map VFS overlay on top of the read-only Windows MSVC/ucrt include 
paths.

https://github.com/llvm/llvm-project/pull/128267
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-21 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi created 
https://github.com/llvm/llvm-project/pull/128267

This is to avoid assertion failures like the following when 
RedirectingFileSystem's are created and used outside createVFSFromOverlayFiles.

```
Assertion failed: VFSUsage.size() == 
getHeaderSearchOpts().VFSOverlayFiles.size() && "A different number of 
RedirectingFileSystem's were present than " "-ivfsoverlay options passed to 
Clang!", file S:\SourceCache\llvm-project\clang\lib\Lex\HeaderSearch.cpp, line 
162
```

>From c23ba6d0195f727955e7f777ebb339124719104e Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Fri, 21 Feb 2025 17:43:30 -0800
Subject: [PATCH] Exclude RedirectingFileSystem with null OverlayFileDir in
 VFSUsage

This is to avoid assertion failures like the following when
RedirectingFileSystem's are created and used outside
createVFSFromOverlayFiles.

```
Assertion failed: VFSUsage.size() == 
getHeaderSearchOpts().VFSOverlayFiles.size() && "A different number of 
RedirectingFileSystem's were present than " "-ivfsoverlay options passed to 
Clang!", file S:\SourceCache\llvm-project\clang\lib\Lex\HeaderSearch.cpp, line 
162
```
---
 clang/lib/Lex/HeaderSearch.cpp | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index bf8fe44e4ca9c..f1e011627d499 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -149,11 +149,16 @@ std::vector HeaderSearch::collectVFSUsageAndClear() 
const {
 
   llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
   // TODO: This only works if the `RedirectingFileSystem`s were all created by
-  //   `createVFSFromOverlayFiles`.
+  //   `createVFSFromOverlayFiles`. But at least exclude the ones with null
+  //   OverlayFileDir.
   RootFS.visit([&](llvm::vfs::FileSystem &FS) {
 if (auto *RFS = dyn_cast(&FS)) {
-  VFSUsage.push_back(RFS->hasBeenUsed());
-  RFS->clearHasBeenUsed();
+  // Skip a `RedirectingFileSystem` with null OverlayFileDir which 
indicates
+  // that they aren't created by `createVFSFromOverlayFiles`.
+  if (!RFS->getOverlayFileDir().empty()) {
+VFSUsage.push_back(RFS->hasBeenUsed());
+RFS->clearHasBeenUsed();
+  }
 }
   });
   assert(VFSUsage.size() == getHeaderSearchOpts().VFSOverlayFiles.size() &&

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-21 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi edited 
https://github.com/llvm/llvm-project/pull/128267
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-21 Thread Hiroshi Yamauchi via cfe-commits


@@ -149,11 +149,16 @@ std::vector HeaderSearch::collectVFSUsageAndClear() 
const {
 
   llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
   // TODO: This only works if the `RedirectingFileSystem`s were all created by

hjyamauchi wrote:

This PR partially addresses the limitation described by this comment.

https://github.com/llvm/llvm-project/pull/128267
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-21 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi ready_for_review 
https://github.com/llvm/llvm-project/pull/128267
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-24 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi closed 
https://github.com/llvm/llvm-project/pull/128267
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-24 Thread Hiroshi Yamauchi via cfe-commits


@@ -149,11 +149,16 @@ std::vector HeaderSearch::collectVFSUsageAndClear() 
const {
 
   llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
   // TODO: This only works if the `RedirectingFileSystem`s were all created by
-  //   `createVFSFromOverlayFiles`.
+  //   `createVFSFromOverlayFiles`. But at least exclude the ones with null
+  //   OverlayFileDir.
   RootFS.visit([&](llvm::vfs::FileSystem &FS) {
 if (auto *RFS = dyn_cast(&FS)) {
-  VFSUsage.push_back(RFS->hasBeenUsed());
-  RFS->clearHasBeenUsed();
+  // Skip a `RedirectingFileSystem` with null OverlayFileDir which 
indicates
+  // that they aren't created by `createVFSFromOverlayFiles`.

hjyamauchi wrote:

Done

https://github.com/llvm/llvm-project/pull/128267
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)

2025-02-24 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi updated 
https://github.com/llvm/llvm-project/pull/128267

>From a36305e0feb4558045e2168d96ef6d941f48a427 Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Fri, 21 Feb 2025 17:43:30 -0800
Subject: [PATCH] Exclude RedirectingFileSystem with null OverlayFileDir in
 VFSUsage

This is to avoid assertion failures like the following when
RedirectingFileSystem's are created and used outside
createVFSFromOverlayFiles.

```
Assertion failed: VFSUsage.size() == 
getHeaderSearchOpts().VFSOverlayFiles.size() && "A different number of 
RedirectingFileSystem's were present than " "-ivfsoverlay options passed to 
Clang!", file S:\SourceCache\llvm-project\clang\lib\Lex\HeaderSearch.cpp, line 
162
```
---
 clang/lib/Lex/HeaderSearch.cpp | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index bf8fe44e4ca9c..6fc477dff43ad 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -149,11 +149,17 @@ std::vector HeaderSearch::collectVFSUsageAndClear() 
const {
 
   llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
   // TODO: This only works if the `RedirectingFileSystem`s were all created by
-  //   `createVFSFromOverlayFiles`.
+  //   `createVFSFromOverlayFiles`. But at least exclude the ones with null
+  //   OverlayFileDir.
   RootFS.visit([&](llvm::vfs::FileSystem &FS) {
 if (auto *RFS = dyn_cast(&FS)) {
-  VFSUsage.push_back(RFS->hasBeenUsed());
-  RFS->clearHasBeenUsed();
+  // Skip a `RedirectingFileSystem` with null OverlayFileDir which 
indicates
+  // that they aren't created by createVFSFromOverlayFiles from the 
overlays
+  // in HeaderSearchOption::VFSOverlayFiles.
+  if (!RFS->getOverlayFileDir().empty()) {
+VFSUsage.push_back(RFS->hasBeenUsed());
+RFS->clearHasBeenUsed();
+  }
 }
   });
   assert(VFSUsage.size() == getHeaderSearchOpts().VFSOverlayFiles.size() &&

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits