From: Sanjoy Das Date: Fri, 16 Dec 2016 18:52:33 +0000 (+0000) Subject: Fix CodeGenPrepare::stripInvariantGroupMetadata X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=089c699743614cc99340c694454b4333c44d0198;p=platform%2Fupstream%2Fllvm.git 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`. llvm-svn: 289973 --- diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 0ae57ce..bc333b9 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -5735,6 +5735,5 @@ bool CodeGenPrepare::splitBranchCondition(Function &F) { } 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); } diff --git a/llvm/test/Transforms/CodeGenPrepare/invariant.group.ll b/llvm/test/Transforms/CodeGenPrepare/invariant.group.ll index e8f1e42..bde04a5 100644 --- a/llvm/test/Transforms/CodeGenPrepare/invariant.group.ll +++ b/llvm/test/Transforms/CodeGenPrepare/invariant.group.ll @@ -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}