Skip to content

Commit 4d211ca

Browse files
committed
[NFCI] Ensure TargetOpcode::* are compatible with guessInstructionProperties=0
rL162640 introduced CodeGenTarget::guessInstructionProperties. If a target sets guessInstructionProperties=0 in its FooInstrInfo, tablegen will error if it has to guess properties from patterns. Unfortunately, guessInstructionProperties=0 can't be used with current upstream LLVM as instructions in the TargetOpcode namespace are always included and sometimes have inferred properties for mayLoad, mayStore, and hasSideEffects. This patch provides the simplest possible fix to this problem, setting default values for these fields in the TargetOpcode scope. There is no intended functional change, as the explicitly set properties should match what was previously inferred. A number of the instructions had hasSideEffects=1 inferred unintentionally. This patch makes it explicit, while future patches (such as D37097) correct the property. Differential Revision: https://reviews.llvm.org/D37065 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317674 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 19b50e8 commit 4d211ca

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

include/llvm/Target/Target.td

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,16 @@ class InstrInfo {
884884
// Standard Pseudo Instructions.
885885
// This list must match TargetOpcodes.h and CodeGenTarget.cpp.
886886
// Only these instructions are allowed in the TargetOpcode namespace.
887-
let isCodeGenOnly = 1, isPseudo = 1, hasNoSchedulingInfo = 1,
888-
Namespace = "TargetOpcode" in {
887+
// Ensure mayLoad and mayStore have a default value, so as not to break
888+
// targets that set guessInstructionProperties=0. Any local definition of
889+
// mayLoad/mayStore takes precedence over these default values.
890+
let mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, isPseudo = 1,
891+
hasNoSchedulingInfo = 1, Namespace = "TargetOpcode" in {
889892
def PHI : Instruction {
890893
let OutOperandList = (outs unknown:$dst);
891894
let InOperandList = (ins variable_ops);
892895
let AsmString = "PHINODE";
896+
let hasSideEffects = 1;
893897
}
894898
def INLINEASM : Instruction {
895899
let OutOperandList = (outs);
@@ -902,27 +906,31 @@ def CFI_INSTRUCTION : Instruction {
902906
let InOperandList = (ins i32imm:$id);
903907
let AsmString = "";
904908
let hasCtrlDep = 1;
909+
let hasSideEffects = 1;
905910
let isNotDuplicable = 0;
906911
}
907912
def EH_LABEL : Instruction {
908913
let OutOperandList = (outs);
909914
let InOperandList = (ins i32imm:$id);
910915
let AsmString = "";
911916
let hasCtrlDep = 1;
917+
let hasSideEffects = 1;
912918
let isNotDuplicable = 1;
913919
}
914920
def GC_LABEL : Instruction {
915921
let OutOperandList = (outs);
916922
let InOperandList = (ins i32imm:$id);
917923
let AsmString = "";
918924
let hasCtrlDep = 1;
925+
let hasSideEffects = 1;
919926
let isNotDuplicable = 1;
920927
}
921928
def ANNOTATION_LABEL : Instruction {
922929
let OutOperandList = (outs);
923930
let InOperandList = (ins i32imm:$id);
924931
let AsmString = "";
925932
let hasCtrlDep = 1;
933+
let hasSideEffects = 1;
926934
let isNotDuplicable = 1;
927935
}
928936
def KILL : Instruction {
@@ -990,6 +998,7 @@ def BUNDLE : Instruction {
990998
let OutOperandList = (outs);
991999
let InOperandList = (ins variable_ops);
9921000
let AsmString = "BUNDLE";
1001+
let hasSideEffects = 1;
9931002
}
9941003
def LIFETIME_START : Instruction {
9951004
let OutOperandList = (outs);
@@ -1006,6 +1015,7 @@ def LIFETIME_END : Instruction {
10061015
def STACKMAP : Instruction {
10071016
let OutOperandList = (outs);
10081017
let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops);
1018+
let hasSideEffects = 1;
10091019
let isCall = 1;
10101020
let mayLoad = 1;
10111021
let usesCustomInserter = 1;
@@ -1014,6 +1024,7 @@ def PATCHPOINT : Instruction {
10141024
let OutOperandList = (outs unknown:$dst);
10151025
let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee,
10161026
i32imm:$nargs, i32imm:$cc, variable_ops);
1027+
let hasSideEffects = 1;
10171028
let isCall = 1;
10181029
let mayLoad = 1;
10191030
let usesCustomInserter = 1;
@@ -1048,6 +1059,7 @@ def FAULTING_OP : Instruction {
10481059
let OutOperandList = (outs unknown:$dst);
10491060
let InOperandList = (ins variable_ops);
10501061
let usesCustomInserter = 1;
1062+
let hasSideEffects = 1;
10511063
let mayLoad = 1;
10521064
let mayStore = 1;
10531065
let isTerminator = 1;

lib/Target/RISCV/RISCV.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>;
4040
//===----------------------------------------------------------------------===//
4141

4242
def RISCVInstrInfo : InstrInfo {
43-
// TODO: disable guessInstructionProperties when
44-
// https://reviews.llvm.org/D37065 lands.
45-
let guessInstructionProperties = 1;
43+
let guessInstructionProperties = 0;
4644
}
4745

4846
def RISCVAsmParser : AsmParser {

0 commit comments

Comments
 (0)