[llvm] r337294 - [Tablegen][PredicateExpander] Fix a bug in `expandCheckImmOperand`.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 17 09:11:37 PDT 2018


Author: adibiagio
Date: Tue Jul 17 09:11:37 2018
New Revision: 337294

URL: http://llvm.org/viewvc/llvm-project?rev=337294&view=rev
Log:
[Tablegen][PredicateExpander] Fix a bug in `expandCheckImmOperand`.

Function `expandCheckImmOperand` should always check if the input machine
instruction is passed by reference before calling method `getOperand()` on it.

Found while working on a patch that relies on `expandCheckImmOperand` to expand
a scheduling predicate.

Modified:
    llvm/trunk/utils/TableGen/PredicateExpander.cpp

Modified: llvm/trunk/utils/TableGen/PredicateExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PredicateExpander.cpp?rev=337294&r1=337293&r2=337294&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/PredicateExpander.cpp (original)
+++ llvm/trunk/utils/TableGen/PredicateExpander.cpp Tue Jul 17 09:11:37 2018
@@ -22,14 +22,14 @@ void PredicateExpander::expandFalse(form
 
 void PredicateExpander::expandCheckImmOperand(formatted_raw_ostream &OS,
                                               int OpIndex, int ImmVal) {
-  OS << "MI.getOperand(" << OpIndex << ").getImm() "
-     << (shouldNegate() ? "!= " : "== ") << ImmVal;
+  OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex
+     << ").getImm() " << (shouldNegate() ? "!= " : "== ") << ImmVal;
 }
 
 void PredicateExpander::expandCheckImmOperand(formatted_raw_ostream &OS,
                                               int OpIndex, StringRef ImmVal) {
-  OS << "MI.getOperand(" << OpIndex << ").getImm() "
-     << (shouldNegate() ? "!= " : "== ") << ImmVal;
+  OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex
+     << ").getImm() " << (shouldNegate() ? "!= " : "== ") << ImmVal;
 }
 
 void PredicateExpander::expandCheckRegOperand(formatted_raw_ostream &OS,




More information about the llvm-commits mailing list