@@ -80,21 +80,11 @@ EnableNoAliasConversion("enable-noalias-to-md-conversion", cl::init(true),
80
80
cl::Hidden,
81
81
cl::desc(" Convert noalias attributes to metadata during inlining." ));
82
82
83
- static cl::opt<bool > UpdateReturnAttributes (
84
- " update-return-attrs" , cl::init(true ), cl::Hidden,
85
- cl::desc(" Update return attributes on calls within inlined body" ));
86
-
87
83
static cl::opt<bool >
88
84
PreserveAlignmentAssumptions (" preserve-alignment-assumptions-during-inlining" ,
89
85
cl::init (true ), cl::Hidden,
90
86
cl::desc(" Convert align attributes to assumptions during inlining." ));
91
87
92
- static cl::opt<unsigned > InlinerAttributeWindow (
93
- " inliner-attribute-window" , cl::Hidden,
94
- cl::desc (" the maximum number of instructions analyzed for may throw during "
95
- " attribute inference in inlined body" ),
96
- cl::init(4 ));
97
-
98
88
llvm::InlineResult llvm::InlineFunction (CallBase *CB, InlineFunctionInfo &IFI,
99
89
AAResults *CalleeAAR,
100
90
bool InsertLifetime) {
@@ -1146,81 +1136,6 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
1146
1136
}
1147
1137
}
1148
1138
1149
- static bool MayContainThrowingOrExitingCall (Instruction *Begin,
1150
- Instruction *End) {
1151
-
1152
- assert (Begin->getParent () == End->getParent () &&
1153
- " Expected to be in same basic block!" );
1154
- unsigned NumInstChecked = 0 ;
1155
- // Check that all instructions in the range [Begin, End) are guaranteed to
1156
- // transfer execution to successor.
1157
- for (auto &I : make_range (Begin->getIterator (), End->getIterator ()))
1158
- if (NumInstChecked++ > InlinerAttributeWindow ||
1159
- !isGuaranteedToTransferExecutionToSuccessor (&I))
1160
- return true ;
1161
- return false ;
1162
- }
1163
-
1164
- static void AddReturnAttributes (CallSite CS, ValueToValueMapTy &VMap) {
1165
- if (!UpdateReturnAttributes)
1166
- return ;
1167
- AttrBuilder AB (CS.getAttributes (), AttributeList::ReturnIndex);
1168
- if (AB.empty ())
1169
- return ;
1170
-
1171
- auto *CalledFunction = CS.getCalledFunction ();
1172
- auto &Context = CalledFunction->getContext ();
1173
-
1174
- for (auto &BB : *CalledFunction) {
1175
- auto *RI = dyn_cast<ReturnInst>(BB.getTerminator ());
1176
- if (!RI || !isa<CallBase>(RI->getOperand (0 )))
1177
- continue ;
1178
- // Sanity check that the cloned return instruction exists and is a return
1179
- // instruction itself.
1180
- auto *NewRI = dyn_cast_or_null<ReturnInst>(VMap.lookup (RI));
1181
- if (!NewRI)
1182
- continue ;
1183
- auto *RetVal = cast<CallBase>(RI->getOperand (0 ));
1184
- // Sanity check that the cloned RetVal exists and is a call.
1185
- // Simplification during inlining could have transformed the cloned
1186
- // instruction.
1187
- auto *NewRetVal = dyn_cast_or_null<CallBase>(VMap.lookup (RetVal));
1188
- if (!NewRetVal)
1189
- continue ;
1190
- // Backward propagation of attributes to the returned value may be incorrect
1191
- // if it is control flow dependent.
1192
- // Consider:
1193
- // @callee {
1194
- // %rv = call @foo()
1195
- // %rv2 = call @bar()
1196
- // if (%rv2 != null)
1197
- // return %rv2
1198
- // if (%rv == null)
1199
- // exit()
1200
- // return %rv
1201
- // }
1202
- // caller() {
1203
- // %val = call nonnull @callee()
1204
- // }
1205
- // Here we cannot add the nonnull attribute on either foo or bar. So, we
1206
- // limit the check to both NewRetVal and NewRI are in the same basic block
1207
- // and there are no throwing/exiting instructions between these
1208
- // instructions.
1209
- if (NewRI->getParent () != NewRetVal->getParent () ||
1210
- MayContainThrowingOrExitingCall (NewRetVal, NewRI))
1211
- continue ;
1212
- // Add to the existing attributes of NewRetVal.
1213
- // NB! When we have the same attribute already existing on NewRetVal, but
1214
- // with a differing value, the AttributeList's merge API honours the already
1215
- // existing attribute value (i.e. attributes such as dereferenceable,
1216
- // dereferenceable_or_null etc). See AttrBuilder::merge for more details.
1217
- AttributeList AL = NewRetVal->getAttributes ();
1218
- AttributeList NewAL =
1219
- AL.addAttributes (Context, AttributeList::ReturnIndex, AB);
1220
- NewRetVal->setAttributes (NewAL);
1221
- }
1222
- }
1223
-
1224
1139
// / If the inlined function has non-byval align arguments, then
1225
1140
// / add @llvm.assume-based alignment assumptions to preserve this information.
1226
1141
static void AddAlignmentAssumptions (CallSite CS, InlineFunctionInfo &IFI) {
@@ -1886,10 +1801,6 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
1886
1801
// Add noalias metadata if necessary.
1887
1802
AddAliasScopeMetadata (CS, VMap, DL, CalleeAAR);
1888
1803
1889
- // Clone return attributes on the callsite into the calls within the inlined
1890
- // function which feed into its return value.
1891
- AddReturnAttributes (CS, VMap);
1892
-
1893
1804
// Propagate llvm.mem.parallel_loop_access if necessary.
1894
1805
PropagateParallelLoopAccessMetadata (CS, VMap);
1895
1806
0 commit comments