r352740 - Support attribute used in member funcs of class templates

2019-01-31 Thread Rafael Auler via cfe-commits
Author: rafauler
Date: Thu Jan 31 01:38:31 2019
New Revision: 352740

URL: http://llvm.org/viewvc/llvm-project?rev=352740&view=rev
Log:
Support attribute used in member funcs of class templates

Summary:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

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

Added:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=352740&r1=352739&r2=352740&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Jan 31 01:38:31 2019
@@ -2175,6 +2175,20 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }
 
+  // PR17480: Honor the used attribute to instantiate member function
+  // definitions
+  if (Method->hasAttr()) {
+if (const auto *A = dyn_cast(Owner)) {
+  SourceLocation Loc;
+  if (const MemberSpecializationInfo *MSInfo =
+  A->getMemberSpecializationInfo())
+Loc = MSInfo->getPointOfInstantiation();
+  else if (const auto *Spec = dyn_cast(A))
+Loc = Spec->getPointOfInstantiation();
+  SemaRef.MarkFunctionReferenced(Loc, Method);
+}
+  }
+
   return Method;
 }
 

Added: 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp?rev=352740&view=auto
==
--- 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(added)
+++ 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
Thu Jan 31 01:38:31 2019
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
+
+// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
+// classes
+namespace InstantiateUsedMemberDefinition {
+template 
+struct S {
+  int __attribute__((used)) f() {
+return 0;
+  }
+};
+
+void test() {
+  // Check that InstantiateUsedMemberDefinition::S::f() is defined
+  // as a result of the S class template implicit instantiation
+  // CHECK: define linkonce_odr i32 
@_ZN31InstantiateUsedMemberDefinition1SIiE1fEv
+  S inst;
+}
+} // namespace InstantiateUsedMemberDefinition


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


r352748 - Revert "Support attribute used in member funcs of class templates"

2019-01-31 Thread Rafael Auler via cfe-commits
Author: rafauler
Date: Thu Jan 31 05:31:33 2019
New Revision: 352748

URL: http://llvm.org/viewvc/llvm-project?rev=352748&view=rev
Log:
Revert "Support attribute used in member funcs of class templates"

This reverts commit 352740: broke swift build

Removed:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=352748&r1=352747&r2=352748&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Jan 31 05:31:33 2019
@@ -2175,20 +2175,6 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }
 
-  // PR17480: Honor the used attribute to instantiate member function
-  // definitions
-  if (Method->hasAttr()) {
-if (const auto *A = dyn_cast(Owner)) {
-  SourceLocation Loc;
-  if (const MemberSpecializationInfo *MSInfo =
-  A->getMemberSpecializationInfo())
-Loc = MSInfo->getPointOfInstantiation();
-  else if (const auto *Spec = dyn_cast(A))
-Loc = Spec->getPointOfInstantiation();
-  SemaRef.MarkFunctionReferenced(Loc, Method);
-}
-  }
-
   return Method;
 }
 

Removed: 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp?rev=352747&view=auto
==
--- 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(original)
+++ 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(removed)
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
-
-// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
-// classes
-namespace InstantiateUsedMemberDefinition {
-template 
-struct S {
-  int __attribute__((used)) f() {
-return 0;
-  }
-};
-
-void test() {
-  // Check that InstantiateUsedMemberDefinition::S::f() is defined
-  // as a result of the S class template implicit instantiation
-  // CHECK: define linkonce_odr i32 
@_ZN31InstantiateUsedMemberDefinition1SIiE1fEv
-  S inst;
-}
-} // namespace InstantiateUsedMemberDefinition


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


r355627 - Recommit "Support attribute used in member funcs of class templates"

2019-03-07 Thread Rafael Auler via cfe-commits
Author: rafauler
Date: Thu Mar  7 11:14:30 2019
New Revision: 355627

URL: http://llvm.org/viewvc/llvm-project?rev=355627&view=rev
Log:
Recommit "Support attribute used in member funcs of class templates"

The patch originally broke code that was incompatible with GCC, but
we want to follow GCC behavior here according to the discussion in
https://reviews.llvm.org/D58216

Original commit message:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

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

Added:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=355627&r1=355626&r2=355627&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Mar  7 11:14:30 2019
@@ -2232,6 +2232,20 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }
 
+  // PR17480: Honor the used attribute to instantiate member function
+  // definitions
+  if (Method->hasAttr()) {
+if (const auto *A = dyn_cast(Owner)) {
+  SourceLocation Loc;
+  if (const MemberSpecializationInfo *MSInfo =
+  A->getMemberSpecializationInfo())
+Loc = MSInfo->getPointOfInstantiation();
+  else if (const auto *Spec = dyn_cast(A))
+Loc = Spec->getPointOfInstantiation();
+  SemaRef.MarkFunctionReferenced(Loc, Method);
+}
+  }
+
   return Method;
 }
 

Added: 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp?rev=355627&view=auto
==
--- 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(added)
+++ 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
Thu Mar  7 11:14:30 2019
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
+
+// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
+// classes
+namespace InstantiateUsedMemberDefinition {
+template 
+struct S {
+  int __attribute__((used)) f() {
+return 0;
+  }
+};
+
+void test() {
+  // Check that InstantiateUsedMemberDefinition::S::f() is defined
+  // as a result of the S class template implicit instantiation
+  // CHECK: define linkonce_odr i32 
@_ZN31InstantiateUsedMemberDefinition1SIiE1fEv
+  S inst;
+}
+} // namespace InstantiateUsedMemberDefinition


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


r355721 - Revert "Recommit "Support attribute used in member funcs of class templates""

2019-03-08 Thread Rafael Auler via cfe-commits
Author: rafauler
Date: Fri Mar  8 12:23:57 2019
New Revision: 355721

URL: http://llvm.org/viewvc/llvm-project?rev=355721&view=rev
Log:
Revert "Recommit "Support attribute used in member funcs of class templates""

There is nontrivial bug caused in lld that I need to further
investigate. Meanwhile, I'll revert this.

This reverts commit 8297e93480c636dc90fd14653c5a66406193363f.

Removed:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=355721&r1=355720&r2=355721&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Mar  8 12:23:57 2019
@@ -2232,20 +2232,6 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }
 
-  // PR17480: Honor the used attribute to instantiate member function
-  // definitions
-  if (Method->hasAttr()) {
-if (const auto *A = dyn_cast(Owner)) {
-  SourceLocation Loc;
-  if (const MemberSpecializationInfo *MSInfo =
-  A->getMemberSpecializationInfo())
-Loc = MSInfo->getPointOfInstantiation();
-  else if (const auto *Spec = dyn_cast(A))
-Loc = Spec->getPointOfInstantiation();
-  SemaRef.MarkFunctionReferenced(Loc, Method);
-}
-  }
-
   return Method;
 }
 

Removed: 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp?rev=355720&view=auto
==
--- 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(original)
+++ 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(removed)
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
-
-// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
-// classes
-namespace InstantiateUsedMemberDefinition {
-template 
-struct S {
-  int __attribute__((used)) f() {
-return 0;
-  }
-};
-
-void test() {
-  // Check that InstantiateUsedMemberDefinition::S::f() is defined
-  // as a result of the S class template implicit instantiation
-  // CHECK: define linkonce_odr i32 
@_ZN31InstantiateUsedMemberDefinition1SIiE1fEv
-  S inst;
-}
-} // namespace InstantiateUsedMemberDefinition


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


r356598 - Recommit "Support attribute used in member funcs of class templates"

2019-03-20 Thread Rafael Auler via cfe-commits
Author: rafauler
Date: Wed Mar 20 12:22:24 2019
New Revision: 356598

URL: http://llvm.org/viewvc/llvm-project?rev=356598&view=rev
Log:
Recommit "Support attribute used in member funcs of class templates"

This diff previously exposed a bug in LLVM's IRLinker, breaking
buildbots that tried to self-host LLVM with monolithic LTO.
The bug is now in LLVM by D59552

Original commit message:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

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

Added:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=356598&r1=356597&r2=356598&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Mar 20 12:22:24 2019
@@ -2232,6 +2232,20 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }
 
+  // PR17480: Honor the used attribute to instantiate member function
+  // definitions
+  if (Method->hasAttr()) {
+if (const auto *A = dyn_cast(Owner)) {
+  SourceLocation Loc;
+  if (const MemberSpecializationInfo *MSInfo =
+  A->getMemberSpecializationInfo())
+Loc = MSInfo->getPointOfInstantiation();
+  else if (const auto *Spec = dyn_cast(A))
+Loc = Spec->getPointOfInstantiation();
+  SemaRef.MarkFunctionReferenced(Loc, Method);
+}
+  }
+
   return Method;
 }
 

Added: 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp?rev=356598&view=auto
==
--- 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(added)
+++ 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
Wed Mar 20 12:22:24 2019
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
+
+// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
+// classes
+namespace InstantiateUsedMemberDefinition {
+template 
+struct S {
+  int __attribute__((used)) f() {
+return 0;
+  }
+};
+
+void test() {
+  // Check that InstantiateUsedMemberDefinition::S::f() is defined
+  // as a result of the S class template implicit instantiation
+  // CHECK: define linkonce_odr i32 
@_ZN31InstantiateUsedMemberDefinition1SIiE1fEv
+  S inst;
+}
+} // namespace InstantiateUsedMemberDefinition


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


Re: r356598 - Recommit "Support attribute used in member funcs of class templates"

2019-03-26 Thread Rafael Auler via cfe-commits
I’m familiar with this issue as I had to fix a memory bug in LLVM IRLinker that 
was exposed by this commit. That’s why I initially reverted it. However, after 
fixing it, I was able to do the full clang LTO self-hosting with lld on Linux. 
Is there any way I can repro this issue? It’s probably a bad interaction of 
attribute used and an optimization. See https://reviews.llvm.org/D59552


From: Michael Spencer 
Date: Tuesday, March 26, 2019 at 6:59 PM
To: Rafael Auler 
Cc: "cfe-commits@lists.llvm.org" 
Subject: Re: r356598 - Recommit "Support attribute used in member funcs of 
class templates"

On Wed, Mar 20, 2019 at 12:21 PM Rafael Auler via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: rafauler
Date: Wed Mar 20 12:22:24 2019
New Revision: 356598

URL: 
http://llvm.org/viewvc/llvm-project?rev=356598&view=rev<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D356598-26view-3Drev&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=Tp8AU6vZlFhDRTWeUHWkXzTHsspDHfWnErBtktRStLc&s=z5t_fduYusJn1DP4wsOLj9KYsPpKMyUkVXk2JAPRNM8&e=>
Log:
Recommit "Support attribute used in member funcs of class templates"

This diff previously exposed a bug in LLVM's IRLinker, breaking
buildbots that tried to self-host LLVM with monolithic LTO.
The bug is now in LLVM by D59552

Original commit message:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

Differential Revision: 
https://reviews.llvm.org/D56928<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56928&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=Tp8AU6vZlFhDRTWeUHWkXzTHsspDHfWnErBtktRStLc&s=Y54Z_weCYOa7tU_wNo9M6yMwDeLwDQKoNdrnZu_PllE&e=>

Added:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=356598&r1=356597&r2=356598&view=diff<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Sema_SemaTemplateInstantiateDecl.cpp-3Frev-3D356598-26r1-3D356597-26r2-3D356598-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=Tp8AU6vZlFhDRTWeUHWkXzTHsspDHfWnErBtktRStLc&s=Zh4mt8nrN7qZNDUMeoVkSQtZ2ebQTgXi_MOQa87S5fY&e=>
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Mar 20 12:22:24 2019
@@ -2232,6 +2232,20 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }

+  // PR17480: Honor the used attribute to instantiate member function
+  // definitions
+  if (Method->hasAttr()) {
+if (const auto *A = dyn_cast(Owner)) {
+  SourceLocation Loc;
+  if (const MemberSpecializationInfo *MSInfo =
+  A->getMemberSpecializationInfo())
+Loc = MSInfo->getPointOfInstantiation();
+  else if (const auto *Spec = dyn_cast(A))
+Loc = Spec->getPointOfInstantiation();
+  SemaRef.MarkFunctionReferenced(Loc, Method);
+}
+  }
+
   return Method;
 }


Added: 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp?rev=356598&view=auto<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGenCXX_attr-2Dused-2Dmember-2Dfunction-2Dimplicit-2Dinstantiation.cpp-3Frev-3D356598-26view-3Dauto&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=Tp8AU6vZlFhDRTWeUHWkXzTHsspDHfWnErBtktRStLc&s=CMIrOdMDTKRq5dy52CT5B9v2iMMA2dPslSvyhjaCb2o&e=>
==
--- 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(added)
+++ 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
Wed Mar 20 12:22:24 2019
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
+
+// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
+// classes
+namespace InstantiateUsedMemberDefinition {
+template 
+struct S {
+  int __attribute__((used)) f() {
+return 0;

Re: r356598 - Recommit "Support attribute used in member funcs of class templates"

2019-03-28 Thread Rafael Auler via cfe-commits
Full LTO. Oh, so your build bot is using thinLTO. I’ll keep an eye in thinLTO 
builds.

From: Michael Spencer 
Date: Thursday, March 28, 2019 at 1:27 PM
To: Rafael Auler 
Cc: "cfe-commits@lists.llvm.org" 
Subject: Re: r356598 - Recommit "Support attribute used in member funcs of 
class templates"

On Tue, Mar 26, 2019 at 7:40 PM Rafael Auler 
mailto:rafaelau...@fb.com>> wrote:
I’m familiar with this issue as I had to fix a memory bug in LLVM IRLinker that 
was exposed by this commit. That’s why I initially reverted it. However, after 
fixing it, I was able to do the full clang LTO self-hosting with lld on Linux. 
Is there any way I can repro this issue? It’s probably a bad interaction of 
attribute used and an optimization. See 
https://reviews.llvm.org/D59552<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D59552&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=zyfJGH3SN_mqqkedhHgxTKMJD-SKkgBThplLcE0c4bc&s=ZbiPDYSvM_vb8esCc6n0mu7cKL-P4cWlCzbwo7j6Eqo&e=>

Was this with full LTO or thin LTO?  I'm still working on getting a reproducer. 
 This may be related to this issue: 
https://bugs.llvm.org/show_bug.cgi?id=41236<https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D41236&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=zyfJGH3SN_mqqkedhHgxTKMJD-SKkgBThplLcE0c4bc&s=XJ3Li7xxtXeJejLu56BM69HTR1NeZpvM2ibUasdBxVA&e=>

- Michael Spencer



From: Michael Spencer mailto:bigchees...@gmail.com>>
Date: Tuesday, March 26, 2019 at 6:59 PM
To: Rafael Auler mailto:rafaelau...@fb.com>>
Cc: "cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org>" 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r356598 - Recommit "Support attribute used in member funcs of 
class templates"

On Wed, Mar 20, 2019 at 12:21 PM Rafael Auler via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: rafauler
Date: Wed Mar 20 12:22:24 2019
New Revision: 356598

URL: 
http://llvm.org/viewvc/llvm-project?rev=356598&view=rev<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D356598-26view-3Drev&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=Tp8AU6vZlFhDRTWeUHWkXzTHsspDHfWnErBtktRStLc&s=z5t_fduYusJn1DP4wsOLj9KYsPpKMyUkVXk2JAPRNM8&e=>
Log:
Recommit "Support attribute used in member funcs of class templates"

This diff previously exposed a bug in LLVM's IRLinker, breaking
buildbots that tried to self-host LLVM with monolithic LTO.
The bug is now in LLVM by D59552

Original commit message:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

Differential Revision: 
https://reviews.llvm.org/D56928<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56928&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=Tp8AU6vZlFhDRTWeUHWkXzTHsspDHfWnErBtktRStLc&s=Y54Z_weCYOa7tU_wNo9M6yMwDeLwDQKoNdrnZu_PllE&e=>

Added:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=356598&r1=356597&r2=356598&view=diff<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Sema_SemaTemplateInstantiateDecl.cpp-3Frev-3D356598-26r1-3D356597-26r2-3D356598-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kx31RNFp5lAJejEYwuEQ4Zc5A6GakBit07EY08bIAvc&m=Tp8AU6vZlFhDRTWeUHWkXzTHsspDHfWnErBtktRStLc&s=Zh4mt8nrN7qZNDUMeoVkSQtZ2ebQTgXi_MOQa87S5fY&e=>
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Mar 20 12:22:24 2019
@@ -2232,6 +2232,20 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }

+  // PR17480: Honor the used attribute to instantiate member function
+  // definitions
+  if (Method->hasAttr()) {
+if (const auto *A = dyn_cast(Owner)) {
+  SourceLocation Loc;
+  if (const MemberSpecializationInfo *MSInfo =
+  A->getMemberSpecializationInfo())
+Loc = MSInfo->getPointOfInstantiation();
+  else if (const auto *Spec = dyn_cast(A))
+Loc = Spec->getPointOfInstantiation();
+

[flang] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [llvm] [BOLT] Read .rela.dyn in static non-pie binary (PR #71635)

2023-11-09 Thread Rafael Auler via cfe-commits

https://github.com/rafaelauler approved this pull request.

Looks good, thanks.

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


[llvm] [clang] [lldb] [libcxx] [libc] [clang-tools-extra] [mlir] [BOLT][NFC] Print BAT section size (PR #76897)

2024-01-11 Thread Rafael Auler via cfe-commits

https://github.com/rafaelauler approved this pull request.


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


[clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-21 Thread Rafael Auler via cfe-commits

https://github.com/rafaelauler approved this pull request.

Could you elaborate a bit better on why do we need a deleted block to be 
present in the table? My memory fails me, aren't we using the translation table 
just to map samples collected on the bolted binary? Where do the deleted blocks 
become a problem?

Other than the motivation, the implementation itself looks good to me.

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


[clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Rafael Auler via cfe-commits

rafaelauler wrote:

Thanks for the detailed explanation.

So essentially the output offset is not important because these deleted blocks 
are only useful for their input offset, which will be used in 
BoltAddressTranslation::getFallthroughsInTrace() to create traffic in this 
to-be deleted block, is that right?

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


[clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Rafael Auler via cfe-commits

rafaelauler wrote:

Oh I see, thanks!

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