OSDN Git Service

[Tablegen][PredicateExpander] Fix a bug in `expandCheckImmOperand`.
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Tue, 17 Jul 2018 16:11:37 +0000 (16:11 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Tue, 17 Jul 2018 16:11:37 +0000 (16:11 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337294 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/PredicateExpander.cpp

index 62a01dc..56ffa77 100644 (file)
@@ -22,14 +22,14 @@ void PredicateExpander::expandFalse(formatted_raw_ostream &OS) {
 
 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,