Delete copy-ctor of MachineFrameInfo.
authorAmara Emerson <amara@apple.com>
Fri, 6 Aug 2021 06:21:08 +0000 (23:21 -0700)
committerAmara Emerson <amara@apple.com>
Fri, 6 Aug 2021 06:24:37 +0000 (23:24 -0700)
I just hit a nasty bug when writing a unit test after calling MF->getFrameInfo()
without declaring the variable as a reference.

Deleting the copy-constructor also showed a place in the ARM backend which was
doing the same thing, albeit it didn't impact correctness there from the looks of it.

llvm/include/llvm/CodeGen/MachineFrameInfo.h
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp

index 28a5970..5df4681 100644 (file)
@@ -342,6 +342,8 @@ public:
       : StackAlignment(assumeAligned(StackAlignment)),
         StackRealignable(StackRealignable), ForcedRealign(ForcedRealign) {}
 
+  MachineFrameInfo(const MachineFrameInfo &) = delete;
+
   /// Return true if there are any stack objects in this function.
   bool hasStackObjects() const { return !Objects.empty(); }
 
index ea41442..9f2aec6 100644 (file)
@@ -1121,7 +1121,7 @@ static bool ValidateMVEStore(MachineInstr *MI, MachineLoop *ML) {
     return false;
   int FI = GetFrameIndex(MI->memoperands().front());
 
-  MachineFrameInfo FrameInfo = MI->getParent()->getParent()->getFrameInfo();
+  auto &FrameInfo = MI->getParent()->getParent()->getFrameInfo();
   if (FI == -1 || !FrameInfo.isSpillSlotObjectIndex(FI))
     return false;