[llvm] r289973 - Fix CodeGenPrepare::stripInvariantGroupMetadata
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 10:52:33 PST 2016
Author: sanjoy
Date: Fri Dec 16 12:52:33 2016
New Revision: 289973
URL: http://llvm.org/viewvc/llvm-project?rev=289973&view=rev
Log:
Fix CodeGenPrepare::stripInvariantGroupMetadata
`dropUnknownNonDebugMetadata` takes a list of "known" metadata IDs. The
only reason it worked at all is that `getMetadataID` returns something
unrelated -- it returns the subclass ID of the receiver (which is used
in `dyn_cast` etc.). That does not numerically match
`LLVMContext::MD_invariant_group` and ends up dropping `invariant_group`
along with every other metadata that does not numerically match
`LLVMContext::MD_invariant_group`.
Modified:
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
llvm/trunk/test/Transforms/CodeGenPrepare/invariant.group.ll
Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=289973&r1=289972&r2=289973&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Fri Dec 16 12:52:33 2016
@@ -5735,6 +5735,5 @@ bool CodeGenPrepare::splitBranchConditio
}
void CodeGenPrepare::stripInvariantGroupMetadata(Instruction &I) {
- if (auto *InvariantMD = I.getMetadata(LLVMContext::MD_invariant_group))
- I.dropUnknownNonDebugMetadata(InvariantMD->getMetadataID());
+ I.setMetadata(LLVMContext::MD_invariant_group, nullptr);
}
Modified: llvm/trunk/test/Transforms/CodeGenPrepare/invariant.group.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CodeGenPrepare/invariant.group.ll?rev=289973&r1=289972&r2=289973&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CodeGenPrepare/invariant.group.ll (original)
+++ llvm/trunk/test/Transforms/CodeGenPrepare/invariant.group.ll Fri Dec 16 12:52:33 2016
@@ -7,8 +7,8 @@ define void @foo() {
enter:
; CHECK-NOT: !invariant.group
; CHECK-NOT: @llvm.invariant.group.barrier(
- ; CHECK: %val = load i8, i8* @tmp
- %val = load i8, i8* @tmp, !invariant.group !0
+ ; CHECK: %val = load i8, i8* @tmp, !tbaa
+ %val = load i8, i8* @tmp, !invariant.group !0, !tbaa !{!1, !1, i64 0}
%ptr = call i8* @llvm.invariant.group.barrier(i8* @tmp)
; CHECK: store i8 42, i8* @tmp
@@ -20,4 +20,5 @@ enter:
declare i8* @llvm.invariant.group.barrier(i8*)
-!0 = !{!"something"}
\ No newline at end of file
+!0 = !{!"something"}
+!1 = !{!"x", !0}
More information about the llvm-commits
mailing list