r301178 - [Devirtualization] Emit invariant.group loads with empty group md
Piotr Padlewski via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 24 05:58:43 PDT 2017
Author: prazek
Date: Mon Apr 24 07:58:43 2017
New Revision: 301178
URL: http://llvm.org/viewvc/llvm-project?rev=301178&view=rev
Log:
[Devirtualization] Emit invariant.group loads with empty group md
Summary:
As discussed here
http://lists.llvm.org/pipermail/llvm-dev/2017-January/109332.html
having different groups doesn't solve the problem entirly.
Reviewers: rjmccall, rsmith
Subscribers: amharc, cfe-commits
Differential Revision: https://reviews.llvm.org/D32110
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=301178&r1=301177&r2=301178&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Apr 24 07:58:43 2017
@@ -565,12 +565,8 @@ void CodeGenModule::DecorateInstructionW
void CodeGenModule::DecorateInstructionWithInvariantGroup(
llvm::Instruction *I, const CXXRecordDecl *RD) {
- llvm::Metadata *MD = CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
- auto *MetaDataNode = dyn_cast<llvm::MDNode>(MD);
- // Check if we have to wrap MDString in MDNode.
- if (!MetaDataNode)
- MetaDataNode = llvm::MDNode::get(getLLVMContext(), MD);
- I->setMetadata(llvm::LLVMContext::MD_invariant_group, MetaDataNode);
+ I->setMetadata(llvm::LLVMContext::MD_invariant_group,
+ llvm::MDNode::get(getLLVMContext(), {}));
}
void CodeGenModule::Error(SourceLocation loc, StringRef message) {
Modified: cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp?rev=301178&r1=301177&r2=301178&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp Mon Apr 24 07:58:43 2017
@@ -12,15 +12,15 @@ struct D : A {
void testExternallyVisible() {
A *a = new A;
- // CHECK: load {{.*}} !invariant.group ![[A_MD:[0-9]+]]
+ // CHECK: load {{.*}} !invariant.group ![[MD:[0-9]+]]
a->foo();
D *d = new D;
// CHECK: call void @_ZN1DC1Ev(
- // CHECK: load {{.*}} !invariant.group ![[D_MD:[0-9]+]]
+ // CHECK: load {{.*}} !invariant.group ![[MD]]
d->foo();
A *a2 = d;
- // CHECK: load {{.*}} !invariant.group ![[A_MD]]
+ // CHECK: load {{.*}} !invariant.group ![[MD]]
a2->foo();
}
// CHECK-LABEL: {{^}}}
@@ -40,35 +40,32 @@ struct C : B {
// CHECK-LABEL: define void @_Z21testInternallyVisibleb(
void testInternallyVisible(bool p) {
B *b = new B;
- // CHECK: = load {{.*}}, !invariant.group ![[B_MD:[0-9]+]]
+ // CHECK: = load {{.*}}, !invariant.group ![[MD]]
b->bar();
// CHECK: call void @_ZN12_GLOBAL__N_11CC1Ev(
C *c = new C;
- // CHECK: = load {{.*}}, !invariant.group ![[C_MD:[0-9]+]]
+ // CHECK: = load {{.*}}, !invariant.group ![[MD]]
c->bar();
}
// Checking A::A()
// CHECK-LABEL: define linkonce_odr void @_ZN1AC2Ev(
-// CHECK: store {{.*}}, !invariant.group ![[A_MD]]
+// CHECK: store {{.*}}, !invariant.group ![[MD]]
// CHECK-LABEL: {{^}}}
// Checking D::D()
// CHECK-LABEL: define linkonce_odr void @_ZN1DC2Ev(
// CHECK: = call i8* @llvm.invariant.group.barrier(i8*
// CHECK: call void @_ZN1AC2Ev(%struct.A*
-// CHECK: store {{.*}} !invariant.group ![[D_MD]]
+// CHECK: store {{.*}} !invariant.group ![[MD]]
// Checking B::B()
// CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11BC2Ev(
-// CHECK: store {{.*}}, !invariant.group ![[B_MD]]
+// CHECK: store {{.*}}, !invariant.group ![[MD]]
// Checking C::C()
// CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11CC2Ev(
-// CHECK: store {{.*}}, !invariant.group ![[C_MD]]
+// CHECK: store {{.*}}, !invariant.group ![[MD]]
-// CHECK: ![[A_MD]] = !{!"_ZTS1A"}
-// CHECK: ![[D_MD]] = !{!"_ZTS1D"}
-// CHECK: ![[B_MD]] = distinct !{}
-// CHECK: ![[C_MD]] = distinct !{}
+// CHECK: ![[MD]] = !{}
More information about the cfe-commits
mailing list