From e8d697d15ef097871a12b0e37bca87b81674bede Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Thu, 11 Apr 2019 17:55:06 +0200 Subject: [PATCH] Don't modify existing MDNodes in SIMDloop pass. (cherry picked from commit 0afa9a3acc0c57d71d719d204d19478fc885d5ea) --- src/llvm-simdloop.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/llvm-simdloop.cpp b/src/llvm-simdloop.cpp index 683d41d57cc68..d64a6a8ddf921 100644 --- a/src/llvm-simdloop.cpp +++ b/src/llvm-simdloop.cpp @@ -207,8 +207,9 @@ bool LowerSIMDLoop::markSIMDLoop(Module &M, Function *marker, bool ivdep) MDNode *n = L->getLoopID(); if (!n) { // Loop does not have a LoopID yet, so give it one. - n = MDNode::get(Lh->getContext(), ArrayRef(NULL)); - n->replaceOperandWith(0, n); + auto temp_n = MDNode::getTemporary(Lh->getContext(), ArrayRef(NULL)); + temp_n->replaceOperandWith(0, temp_n.get()); + n = MDNode::replaceWithPermanent(std::move(temp_n)); L->setLoopID(n); }