[PATCH] D111255: [ARC] Add option to ARCOptAddrMode to disable the pass and diagnose errors

Mark Schimmel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 6 12:01:33 PDT 2021


marksl created this revision.
marksl added a reviewer: jdpickens.
Herald added a subscriber: hiraditya.
marksl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This change adds an option that allows you to dump the machine instructions before and after the pass to easily see what change was made by the pass. The option is defined as a set of bits. One of those bits also allows you to disable the pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111255

Files:
  llvm/lib/Target/ARC/ARCOptAddrMode.cpp


Index: llvm/lib/Target/ARC/ARCOptAddrMode.cpp
===================================================================
--- llvm/lib/Target/ARC/ARCOptAddrMode.cpp
+++ llvm/lib/Target/ARC/ARCOptAddrMode.cpp
@@ -23,6 +23,7 @@
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -33,6 +34,16 @@
 #define DEBUG_TYPE "arc-addr-mode"
 
 namespace llvm {
+
+static cl::opt<unsigned> ArcKillAddrMode("arc-kill-addr-mode", cl::init(0),
+                                         cl::ReallyHidden, cl::ZeroOrMore);
+
+#define DUMP_BEFORE() ((ArcKillAddrMode & 0x0001) != 0)
+#define DUMP_AFTER() ((ArcKillAddrMode & 0x0002) != 0)
+#define VIEW_BEFORE() ((ArcKillAddrMode & 0x0004) != 0)
+#define VIEW_AFTER() ((ArcKillAddrMode & 0x0008) != 0)
+#define KILL_PASS() ((ArcKillAddrMode & 0x0010) != 0)
+
 FunctionPass *createARCOptAddrMode();
 void initializeARCOptAddrModePass(PassRegistry &);
 } // end namespace llvm
@@ -485,9 +496,14 @@
 }
 
 bool ARCOptAddrMode::runOnMachineFunction(MachineFunction &MF) {
-  if (skipFunction(MF.getFunction()))
+  if (skipFunction(MF.getFunction()) || KILL_PASS())
     return false;
 
+  if (DUMP_BEFORE())
+    MF.dump();
+  if (VIEW_BEFORE())
+    MF.viewCFG();
+
   AST = &MF.getSubtarget<ARCSubtarget>();
   AII = AST->getInstrInfo();
   MRI = &MF.getRegInfo();
@@ -496,6 +512,11 @@
   bool Changed = false;
   for (auto &MBB : MF)
     Changed |= processBasicBlock(MBB);
+
+  if (DUMP_AFTER())
+    MF.dump();
+  if (VIEW_AFTER())
+    MF.viewCFG();
   return Changed;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111255.377630.patch
Type: text/x-patch
Size: 1676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211006/d398ce5f/attachment.bin>


More information about the llvm-commits mailing list