llvm.org GIT mirror llvm / 8c80b5c
[TableGen] Do not set ReadNone attribute on intrinsics with side effects If an intrinsic is defined without outputs, but having side effects, it still can be removed completely from the program. This patch makes TableGen not set Attribute::ReadNone for intrinsics which are declared with IntrHasSideEffects. Differential Revision: https://reviews.llvm.org/D64414 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366312 91177308-0d34-0410-b5e6-96231b3b80d8 Momchil Velikov a month ago
3 changed file(s) with 43 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 // RUN: llvm-tblgen -gen-intrinsic-impl -I %p/../../include %s | FileCheck %s
1
2 // Get the minimum blurb necessary to process ...
3 include "llvm/CodeGen/ValueTypes.td"
4 include "llvm/CodeGen/SDNodeProperties.td"
5
6 class LLVMType {
7 ValueType VT = vt;
8 int isAny = 0;
9 }
10
11 def llvm_i32_ty : LLVMType;
12
13 class IntrinsicProperty;
14 def IntrNoMem : IntrinsicProperty;
15 def IntrHasSideEffects : IntrinsicProperty;
16
17
18 class Intrinsic ret_types,
19 list param_types = [],
20 list intr_properties = [],
21 string name = "",
22 list sd_properties = []> : SDPatternOperator {
23 string LLVMName = name;
24 string TargetPrefix = "";
25 list RetTypes = ret_types;
26 list ParamTypes = param_types;
27 list IntrProperties = intr_properties;
28 let Properties = sd_properties;
29
30 bit isTarget = 0;
31 }
32
33 // ... this intrinsic.
34 def int_random_gen : Intrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrHasSideEffects]>;
35
36 // CHECK: 1, // llvm.random.gen
37 // CHECK: case 1:
38 // CHECK-NEXT: Atts[] = {Attribute::NoUnwind}
28062806 // chain.
28072807 if (Int.IS.RetVTs.empty())
28082808 Operator = getDAGPatterns().get_intrinsic_void_sdnode();
2809 else if (Int.ModRef != CodeGenIntrinsic::NoMem)
2809 else if (Int.ModRef != CodeGenIntrinsic::NoMem || Int.hasSideEffects)
28102810 // Has side-effects, requires chain.
28112811 Operator = getDAGPatterns().get_intrinsic_w_chain_sdnode();
28122812 else // Otherwise, no chain.
684684 }
685685
686686 if (!intrinsic.canThrow ||
687 intrinsic.ModRef != CodeGenIntrinsic::ReadWriteMem ||
687 (intrinsic.ModRef != CodeGenIntrinsic::ReadWriteMem && !intrinsic.hasSideEffects) ||
688688 intrinsic.isNoReturn || intrinsic.isCold || intrinsic.isNoDuplicate ||
689689 intrinsic.isConvergent || intrinsic.isSpeculatable) {
690690 OS << " const Attribute::AttrKind Atts[] = {";
726726
727727 switch (intrinsic.ModRef) {
728728 case CodeGenIntrinsic::NoMem:
729 if (intrinsic.hasSideEffects)
730 break;
729731 if (addComma)
730732 OS << ",";
731733 OS << "Attribute::ReadNone";