[PATCH] D25500: AMDGPU: Workaround for instruction size with literals

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 22:51:43 PDT 2016


arsenm created this revision.
arsenm added a subscriber: llvm-commits.
Herald added a reviewer: tstellarAMD.
Herald added subscribers: tony-tye, yaxunl, wdng, kzhuravl.

Instructions with a 32-bit base encoding with an optional
32-bit literal encoded after them report their size as 4
for the disassembler. Consider these when computing the
MachineInstr size. This fixes problems caused by size estimate
consistency in BranchRelaxation.


https://reviews.llvm.org/D25500

Files:
  lib/CodeGen/BranchRelaxation.cpp


Index: lib/CodeGen/BranchRelaxation.cpp
===================================================================
--- lib/CodeGen/BranchRelaxation.cpp
+++ lib/CodeGen/BranchRelaxation.cpp
@@ -116,6 +116,7 @@
     unsigned Num = MBB.getNumber();
     assert(BlockInfo[Num].Offset % (1u << Align) == 0);
     assert(!Num || BlockInfo[PrevNum].postOffset(MBB) <= BlockInfo[Num].Offset);
+    assert(BlockInfo[Num].Size == computeBlockSize(MBB));
     PrevNum = Num;
   }
 #endif
@@ -385,12 +386,9 @@
 
   DebugLoc DL = MI.getDebugLoc();
   MI.eraseFromParent();
-
-  // insertUnconditonalBranch may have inserted a new block.
-  BlockInfo[MBB->getNumber()].Size += TII->insertIndirectBranch(
+  BlockInfo[BranchBB->getNumber()].Size += TII->insertIndirectBranch(
     *BranchBB, *DestBB, DL, DestOffset - SrcOffset, RS.get());
 
-  computeBlockSize(*BranchBB);
   adjustBlockOffsets(*MBB);
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25500.74326.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161012/9fa7bd1c/attachment.bin>


More information about the llvm-commits mailing list