From: Andrea Di Biagio Date: Tue, 17 Jul 2018 16:11:37 +0000 (+0000) Subject: [Tablegen][PredicateExpander] Fix a bug in `expandCheckImmOperand`. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1885077d4c3ab19074d174be3279f0f1a1d8f469;p=llvm [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337294 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/PredicateExpander.cpp b/utils/TableGen/PredicateExpander.cpp index 62a01dc8854..56ffa77e4ed 100644 --- a/utils/TableGen/PredicateExpander.cpp +++ b/utils/TableGen/PredicateExpander.cpp @@ -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,