[llvm] [MachineOutliner] Preserve regmasks in calls to outlined functions (PR #120940)

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 15:45:15 PST 2025


================
@@ -1153,6 +1160,23 @@ bool MachineOutliner::outline(
             MI->getMF()->eraseCallSiteInfo(MI);
         }
 
+        if (!RegMasks.empty()) {
+          if (RegMasks.size() == 1) {
+            CallInst->addOperand(
+                MachineOperand::CreateRegMask(*RegMasks.begin()));
+          } else {
+            uint32_t *RegMask = MF->allocateRegMask();
+            unsigned NumRegs =
+                MF->getSubtarget().getRegisterInfo()->getNumRegs();
+            unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
+            memset(RegMask, UINT32_MAX, Size * sizeof(RegMask[0]));
----------------
MatzeB wrote:

This is also misleading. The 2nd parameter of `memset` is NOT an UINT32_MAX but is an `int` and interpreted as a byte...

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


More information about the llvm-commits mailing list