Skip to content

Commit 2f38c75

Browse files
committed
Revert "[IR] Intrinsics default attributes and opt-out flag"
This commit introduced a non-trivial compile time regression that needs to be addressed: https://reviews.llvm.org/D70365#2227627 Given that it is unclear how long that will take, I'll revert it for now. This reverts commit eedf18f.
1 parent 1de70a7 commit 2f38c75

File tree

9 files changed

+70
-128
lines changed

9 files changed

+70
-128
lines changed

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ include "llvm/CodeGen/SDNodeProperties.td"
1717
// Properties we keep track of for intrinsics.
1818
//===----------------------------------------------------------------------===//
1919

20-
class IntrinsicProperty<bit is_default = 0> {
21-
bit IsDefault = is_default;
22-
}
20+
class IntrinsicProperty;
2321

2422
// Intr*Mem - Memory properties. If no property is set, the worst case
2523
// is assumed (it may read and write any memory it can get access to and it may
@@ -333,19 +331,14 @@ class Intrinsic<list<LLVMType> ret_types,
333331
list<LLVMType> param_types = [],
334332
list<IntrinsicProperty> intr_properties = [],
335333
string name = "",
336-
list<SDNodeProperty> sd_properties = [],
337-
bit disable_default_attributes = 0> : SDPatternOperator {
334+
list<SDNodeProperty> sd_properties = []> : SDPatternOperator {
338335
string LLVMName = name;
339336
string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics.
340337
list<LLVMType> RetTypes = ret_types;
341338
list<LLVMType> ParamTypes = param_types;
342339
list<IntrinsicProperty> IntrProperties = intr_properties;
343340
let Properties = sd_properties;
344341

345-
// Disable applying IntrinsicProperties that are marked default with
346-
// IntrinsicProperty<1>
347-
bit DisableDefaultAttributes = disable_default_attributes;
348-
349342
bit isTarget = 0;
350343
}
351344

llvm/test/TableGen/intrin-side-effects.td

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ class LLVMType<ValueType vt> {
1111

1212
def llvm_i32_ty : LLVMType<i32>;
1313

14-
class IntrinsicProperty<bit is_default = 0> {
15-
bit IsDefault = is_default;
16-
}
17-
14+
class IntrinsicProperty;
1815
def IntrNoMem : IntrinsicProperty;
1916
def IntrHasSideEffects : IntrinsicProperty;
2017

@@ -30,8 +27,6 @@ class Intrinsic<list<LLVMType> ret_types,
3027
list<LLVMType> ParamTypes = param_types;
3128
list<IntrinsicProperty> IntrProperties = intr_properties;
3229
let Properties = sd_properties;
33-
bit DisableDefaultAttributes = 1;
34-
3530

3631
bit isTarget = 0;
3732
}

llvm/test/TableGen/intrinsic-long-name.td

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// RUN: llvm-tblgen -gen-intrinsic-enums %s | FileCheck %s
22
// XFAIL: vg_leak
33

4-
class IntrinsicProperty<bit is_default = 0> {
5-
bit IsDefault = is_default;
6-
}
7-
4+
class IntrinsicProperty;
85
class SDNodeProperty;
96

107
class ValueType<int size, int value> {
@@ -25,7 +22,6 @@ class Intrinsic<string name, list<LLVMType> param_types = []> {
2522
list<LLVMType> ParamTypes = param_types;
2623
list<IntrinsicProperty> IntrProperties = [];
2724
list<SDNodeProperty> Properties = [];
28-
bit DisableDefaultAttributes = 1;
2925
}
3026

3127
def iAny : ValueType<0, 253>;

llvm/test/TableGen/intrinsic-pointer-to-any.td

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
// case, so TableGen would hit an assertion in EncodeFixedType that was checking
77
// to ensure that the substitution being processed was correctly replaced.
88

9-
class IntrinsicProperty<bit is_default = 0> {
10-
bit IsDefault = is_default;
11-
}
12-
9+
class IntrinsicProperty;
1310
class SDNodeProperty;
1411

1512
class ValueType<int size, int value> {
@@ -35,7 +32,6 @@ class Intrinsic<list<LLVMType> ret_types> {
3532
list<IntrinsicProperty> IntrProperties = [];
3633
list<SDNodeProperty> Properties = [];
3734
bit isTarget = 0;
38-
bit DisableDefaultAttributes = 1;
3935
}
4036

4137
class LLVMQualPointerType<LLVMType elty>

llvm/test/TableGen/intrinsic-struct.td

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// RUN: llvm-tblgen -gen-intrinsic-enums %s | FileCheck %s
22
// XFAIL: vg_leak
33

4-
class IntrinsicProperty<bit is_default = 0> {
5-
bit IsDefault = is_default;
6-
}
7-
4+
class IntrinsicProperty;
85
class SDNodeProperty;
96

107
class ValueType<int size, int value> {
@@ -25,7 +22,6 @@ class Intrinsic<string name, list<LLVMType> ret_types = []> {
2522
list<LLVMType> ParamTypes = [];
2623
list<IntrinsicProperty> IntrProperties = [];
2724
list<SDNodeProperty> Properties = [];
28-
bit DisableDefaultAttributes = 1;
2925
}
3026

3127
def iAny : ValueType<0, 253>;

llvm/test/TableGen/intrinsic-varargs.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
include "llvm/CodeGen/ValueTypes.td"
55

6-
class IntrinsicProperty<bit is_default = 0> {
7-
bit IsDefault = is_default;
8-
}
6+
class IntrinsicProperty;
97
class SDNodeProperty;
108

119
class LLVMType<ValueType vt> {
@@ -20,7 +18,6 @@ class Intrinsic<string name, list<LLVMType> param_types = []> {
2018
list<LLVMType> ParamTypes = param_types;
2119
list<IntrinsicProperty> IntrProperties = [];
2220
list<SDNodeProperty> Properties = [];
23-
bit DisableDefaultAttributes = 1;
2421
}
2522

2623
def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here

llvm/test/TableGen/searchabletables-intrinsic.td

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
include "llvm/TableGen/SearchableTable.td"
55

6-
class IntrinsicProperty<bit is_default = 0> {
7-
bit IsDefault = is_default;
8-
}
9-
6+
class IntrinsicProperty;
107
class SDNodeProperty;
118

129
class ValueType<int size, int value> {
@@ -27,7 +24,6 @@ class Intrinsic<list<LLVMType> param_types = []> {
2724
list<LLVMType> ParamTypes = param_types;
2825
list<IntrinsicProperty> IntrProperties = [];
2926
list<SDNodeProperty> Properties = [];
30-
bit DisableDefaultAttributes = 1;
3127
}
3228

3329
def iAny : ValueType<0, 253>;

llvm/utils/TableGen/CodeGenIntrinsics.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,6 @@ struct CodeGenIntrinsic {
176176
return Properties & (1 << Prop);
177177
}
178178

179-
/// Goes through all IntrProperties and sets to true ones that have IsDefault
180-
/// value set to true.
181-
void setDefaultProperties(Record *R);
182-
183-
/// Helper function to set property \p Name to true;
184-
void setProperty(Record *R);
185-
186179
/// Returns true if the parameter at \p ParamIdx is a pointer type. Returns
187180
/// false if the parameter is not a pointer, or \p ParamIdx is greater than
188181
/// the size of \p IS.ParamVTs.

llvm/utils/TableGen/CodeGenTarget.cpp

Lines changed: 62 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -766,17 +766,75 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
766766
IS.ParamTypeDefs.push_back(TyEl);
767767
}
768768

769-
// Set default properties to true.
770-
setDefaultProperties(R);
771-
772769
// Parse the intrinsic properties.
773770
ListInit *PropList = R->getValueAsListInit("IntrProperties");
774771
for (unsigned i = 0, e = PropList->size(); i != e; ++i) {
775772
Record *Property = PropList->getElementAsRecord(i);
776773
assert(Property->isSubClassOf("IntrinsicProperty") &&
777774
"Expected a property!");
778775

779-
setProperty(Property);
776+
if (Property->getName() == "IntrNoMem")
777+
ModRef = NoMem;
778+
else if (Property->getName() == "IntrReadMem")
779+
ModRef = ModRefBehavior(ModRef & ~MR_Mod);
780+
else if (Property->getName() == "IntrWriteMem")
781+
ModRef = ModRefBehavior(ModRef & ~MR_Ref);
782+
else if (Property->getName() == "IntrArgMemOnly")
783+
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_ArgMem);
784+
else if (Property->getName() == "IntrInaccessibleMemOnly")
785+
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_InaccessibleMem);
786+
else if (Property->getName() == "IntrInaccessibleMemOrArgMemOnly")
787+
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_ArgMem |
788+
MR_InaccessibleMem);
789+
else if (Property->getName() == "Commutative")
790+
isCommutative = true;
791+
else if (Property->getName() == "Throws")
792+
canThrow = true;
793+
else if (Property->getName() == "IntrNoDuplicate")
794+
isNoDuplicate = true;
795+
else if (Property->getName() == "IntrConvergent")
796+
isConvergent = true;
797+
else if (Property->getName() == "IntrNoReturn")
798+
isNoReturn = true;
799+
else if (Property->getName() == "IntrNoSync")
800+
isNoSync = true;
801+
else if (Property->getName() == "IntrNoFree")
802+
isNoFree = true;
803+
else if (Property->getName() == "IntrWillReturn")
804+
isWillReturn = true;
805+
else if (Property->getName() == "IntrCold")
806+
isCold = true;
807+
else if (Property->getName() == "IntrSpeculatable")
808+
isSpeculatable = true;
809+
else if (Property->getName() == "IntrHasSideEffects")
810+
hasSideEffects = true;
811+
else if (Property->isSubClassOf("NoCapture")) {
812+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
813+
ArgumentAttributes.emplace_back(ArgNo, NoCapture, 0);
814+
} else if (Property->isSubClassOf("NoAlias")) {
815+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
816+
ArgumentAttributes.emplace_back(ArgNo, NoAlias, 0);
817+
} else if (Property->isSubClassOf("Returned")) {
818+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
819+
ArgumentAttributes.emplace_back(ArgNo, Returned, 0);
820+
} else if (Property->isSubClassOf("ReadOnly")) {
821+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
822+
ArgumentAttributes.emplace_back(ArgNo, ReadOnly, 0);
823+
} else if (Property->isSubClassOf("WriteOnly")) {
824+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
825+
ArgumentAttributes.emplace_back(ArgNo, WriteOnly, 0);
826+
} else if (Property->isSubClassOf("ReadNone")) {
827+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
828+
ArgumentAttributes.emplace_back(ArgNo, ReadNone, 0);
829+
} else if (Property->isSubClassOf("ImmArg")) {
830+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
831+
ArgumentAttributes.emplace_back(ArgNo, ImmArg, 0);
832+
} else if (Property->isSubClassOf("Align")) {
833+
unsigned ArgNo = Property->getValueAsInt("ArgNo");
834+
uint64_t Align = Property->getValueAsInt("Align");
835+
ArgumentAttributes.emplace_back(ArgNo, Alignment, Align);
836+
} else
837+
llvm_unreachable("Unknown property!");
780838
}
781839

782840
// Also record the SDPatternOperator Properties.
@@ -786,84 +844,6 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
786844
llvm::sort(ArgumentAttributes);
787845
}
788846

789-
void CodeGenIntrinsic::setDefaultProperties(Record *R) {
790-
// opt-out of using default attributes.
791-
if (R->getValueAsBit("DisableDefaultAttributes"))
792-
return;
793-
794-
std::vector<Record *> Defs =
795-
R->getRecords().getAllDerivedDefinitions("IntrinsicProperty");
796-
797-
for (Record *Rec : Defs)
798-
if (Rec->getValueAsBit("IsDefault"))
799-
setProperty(Rec);
800-
}
801-
802-
void CodeGenIntrinsic::setProperty(Record *R) {
803-
if (R->getName() == "IntrNoMem")
804-
ModRef = NoMem;
805-
else if (R->getName() == "IntrReadMem")
806-
ModRef = ModRefBehavior(ModRef & ~MR_Mod);
807-
else if (R->getName() == "IntrWriteMem")
808-
ModRef = ModRefBehavior(ModRef & ~MR_Ref);
809-
else if (R->getName() == "IntrArgMemOnly")
810-
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_ArgMem);
811-
else if (R->getName() == "IntrInaccessibleMemOnly")
812-
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_InaccessibleMem);
813-
else if (R->getName() == "IntrInaccessibleMemOrArgMemOnly")
814-
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_ArgMem |
815-
MR_InaccessibleMem);
816-
else if (R->getName() == "Commutative")
817-
isCommutative = true;
818-
else if (R->getName() == "Throws")
819-
canThrow = true;
820-
else if (R->getName() == "IntrNoDuplicate")
821-
isNoDuplicate = true;
822-
else if (R->getName() == "IntrConvergent")
823-
isConvergent = true;
824-
else if (R->getName() == "IntrNoReturn")
825-
isNoReturn = true;
826-
else if (R->getName() == "IntrNoSync")
827-
isNoSync = true;
828-
else if (R->getName() == "IntrNoFree")
829-
isNoFree = true;
830-
else if (R->getName() == "IntrWillReturn")
831-
isWillReturn = true;
832-
else if (R->getName() == "IntrCold")
833-
isCold = true;
834-
else if (R->getName() == "IntrSpeculatable")
835-
isSpeculatable = true;
836-
else if (R->getName() == "IntrHasSideEffects")
837-
hasSideEffects = true;
838-
else if (R->isSubClassOf("NoCapture")) {
839-
unsigned ArgNo = R->getValueAsInt("ArgNo");
840-
ArgumentAttributes.emplace_back(ArgNo, NoCapture, 0);
841-
} else if (R->isSubClassOf("NoAlias")) {
842-
unsigned ArgNo = R->getValueAsInt("ArgNo");
843-
ArgumentAttributes.emplace_back(ArgNo, NoAlias, 0);
844-
} else if (R->isSubClassOf("Returned")) {
845-
unsigned ArgNo = R->getValueAsInt("ArgNo");
846-
ArgumentAttributes.emplace_back(ArgNo, Returned, 0);
847-
} else if (R->isSubClassOf("ReadOnly")) {
848-
unsigned ArgNo = R->getValueAsInt("ArgNo");
849-
ArgumentAttributes.emplace_back(ArgNo, ReadOnly, 0);
850-
} else if (R->isSubClassOf("WriteOnly")) {
851-
unsigned ArgNo = R->getValueAsInt("ArgNo");
852-
ArgumentAttributes.emplace_back(ArgNo, WriteOnly, 0);
853-
} else if (R->isSubClassOf("ReadNone")) {
854-
unsigned ArgNo = R->getValueAsInt("ArgNo");
855-
ArgumentAttributes.emplace_back(ArgNo, ReadNone, 0);
856-
} else if (R->isSubClassOf("ImmArg")) {
857-
unsigned ArgNo = R->getValueAsInt("ArgNo");
858-
ArgumentAttributes.emplace_back(ArgNo, ImmArg, 0);
859-
} else if (R->isSubClassOf("Align")) {
860-
unsigned ArgNo = R->getValueAsInt("ArgNo");
861-
uint64_t Align = R->getValueAsInt("Align");
862-
ArgumentAttributes.emplace_back(ArgNo, Alignment, Align);
863-
} else
864-
llvm_unreachable("Unknown property!");
865-
}
866-
867847
bool CodeGenIntrinsic::isParamAPointer(unsigned ParamIdx) const {
868848
if (ParamIdx >= IS.ParamVTs.size())
869849
return false;

0 commit comments

Comments
 (0)