[llvm] Copy missing metadata to new inst created from existing inst (PR #84357)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 10:27:54 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-function-specialization

@llvm/pr-subscribers-llvm-transforms

Author: None (EnidXiong)

<details>
<summary>Changes</summary>

Previously in replaceSignedInst of SCCPSolver.cpp, the new usigned instructions created from the signed instructions are missing debug messages as the metadata are not being propagated over.
Added a line to copy the metadata of the old inst to the new one.

---
Full diff: https://github.com/llvm/llvm-project/pull/84357.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Utils/SCCPSolver.cpp (+1) 


``````````diff
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index a185e8cd371c60..233c097f591805 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -210,6 +210,7 @@ static bool replaceSignedInst(SCCPSolver &Solver,
 
   // Wire up the new instruction and update state.
   assert(NewInst && "Expected replacement instruction");
+  NewInst->copyMetadata(Inst);
   NewInst->takeName(&Inst);
   InsertedValues.insert(NewInst);
   Inst.replaceAllUsesWith(NewInst);

``````````

</details>


https://github.com/llvm/llvm-project/pull/84357


More information about the llvm-commits mailing list