@@ -34,7 +34,8 @@ enum PrintVerbosity {
34
34
PV_Uses,
35
35
PV_UnpackAndConst,
36
36
PV_DsaMissing,
37
- PV_DsaVLADimsMissing
37
+ PV_DsaVLADimsMissing,
38
+ PV_VLADimsCaptureMissing
38
39
};
39
40
40
41
static cl::opt<PrintVerbosity>
@@ -46,7 +47,8 @@ PrintVerboseLevel("print-verbosity",
46
47
clEnumValN(PV_Uses, " uses" , " Print task layout with uses" ),
47
48
clEnumValN(PV_UnpackAndConst, " unpack" , " Print task layout with unpack instructions/constexprs needed in dependencies" ),
48
49
clEnumValN(PV_DsaMissing, " dsa_missing" , " Print task layout with uses without DSA" ),
49
- clEnumValN(PV_DsaVLADimsMissing, " dsa_vla_dims_missing" , " Print task layout with DSAs without VLA info or VLA info without DSAs" )));
50
+ clEnumValN(PV_DsaVLADimsMissing, " dsa_vla_dims_missing" , " Print task layout with DSAs without VLA info or VLA info without DSAs" ),
51
+ clEnumValN(PV_VLADimsCaptureMissing, " vla_dims_capture_missing" , " Print task layout with VLA dimensions without capture" )));
50
52
51
53
char OmpSsRegionAnalysisPass::ID = 0 ;
52
54
@@ -77,6 +79,11 @@ static bool valueInVLADimsBundles(const TaskVLADimsInfo& VLADimsInfo,
77
79
return false ;
78
80
}
79
81
82
+ static bool valueInCapturedBundle (const TaskCapturedInfo& CapturedInfo,
83
+ Value *const V) {
84
+ return CapturedInfo.count (V);
85
+ }
86
+
80
87
void OmpSsRegionAnalysisPass::print (raw_ostream &OS, const Module *M) const {
81
88
for (auto it = TaskProgramOrder.begin (); it != TaskProgramOrder.end (); ++it) {
82
89
Instruction *I = it->first ;
@@ -140,14 +147,25 @@ void OmpSsRegionAnalysisPass::print(raw_ostream &OS, const Module *M) const {
140
147
DSAVLADimsFreqMap[VLAWithDimsMap.first ]++;
141
148
}
142
149
for (const auto &Pair : DSAVLADimsFreqMap) {
143
- // It's expected to have only two VLA bundles, the DSA and de dimensions
150
+ // It's expected to have only two VLA bundles, the DSA and dimensions
144
151
if (Pair.second != 2 ) {
145
152
dbgs () << " \n " ;
146
153
dbgs () << std::string ((Depth + 1 ) * PrintSpaceMultiplier, ' ' );
147
154
Pair.first ->printAsOperand (dbgs (), false );
148
155
}
149
156
}
150
157
}
158
+ else if (PrintVerboseLevel == PV_VLADimsCaptureMissing) {
159
+ for (auto &VLAWithDimsMap : Info.VLADimsInfo ) {
160
+ for (Value *const &V : VLAWithDimsMap.second ) {
161
+ if (!valueInCapturedBundle (Info.CapturedInfo , V)) {
162
+ dbgs () << " \n " ;
163
+ dbgs () << std::string ((Depth + 1 ) * PrintSpaceMultiplier, ' ' );
164
+ V->printAsOperand (dbgs (), false );
165
+ }
166
+ }
167
+ }
168
+ }
151
169
152
170
dbgs () << " \n " ;
153
171
}
@@ -245,7 +263,7 @@ static bool insertUniqInstInProgramOrder(SmallVectorImpl<Instruction *> &InstLis
245
263
}
246
264
247
265
static void gatherUnpackInstructions (const TaskDSAInfo &DSAInfo,
248
- const TaskVLADimsInfo &VLADimsInfo ,
266
+ const TaskCapturedInfo &CapturedInfo ,
249
267
const OrderedInstructions &OI,
250
268
DependInfo &DI,
251
269
TaskAnalysisInfo &TAI,
@@ -265,13 +283,12 @@ static void gatherUnpackInstructions(const TaskDSAInfo &DSAInfo,
265
283
Value *Dep = It->second ;
266
284
WorkList.erase (It);
267
285
bool IsDSA = valueInDSABundles (DSAInfo, Cur);
268
- // TODO: this will be get from captured info
269
- bool IsVLADim = valueInVLADimsBundles (VLADimsInfo, Cur);
286
+ bool IsCaptured = valueInCapturedBundle (CapturedInfo, Cur);
270
287
// Go over all uses until:
271
288
// 1. We get a DSA so assign a symbol index
272
- // 2. We get a VLA dimension , so we're done. We don't want to move
273
- // instructions that generate the vla dimension
274
- if (!IsDSA && !IsVLADim ) {
289
+ // 2. We get a Capture value , so we're done. We don't want to move
290
+ // instructions that generate this
291
+ if (!IsDSA && !IsCaptured ) {
275
292
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Cur)) {
276
293
for (Use &U : CE->operands ()) {
277
294
WorkList.emplace_back (U.get (), Dep);
@@ -300,7 +317,7 @@ static void gatherUnpackInstructions(const TaskDSAInfo &DSAInfo,
300
317
static void gatherDependsInfoFromBundles (const SmallVectorImpl<OperandBundleDef> &OpBundles,
301
318
const OrderedInstructions &OI,
302
319
const TaskDSAInfo &DSAInfo,
303
- const TaskVLADimsInfo &VLADimsInfo ,
320
+ const TaskCapturedInfo &CapturedInfo ,
304
321
TaskAnalysisInfo &TAI,
305
322
SmallVectorImpl<DependInfo> &DependsList,
306
323
SmallVectorImpl<Instruction *> &UnpackInsts,
@@ -317,7 +334,7 @@ static void gatherDependsInfoFromBundles(const SmallVectorImpl<OperandBundleDef>
317
334
DI.Dims .push_back (OBArgs[i]);
318
335
}
319
336
320
- gatherUnpackInstructions (DSAInfo, VLADimsInfo , OI, DI, TAI, UnpackInsts, UnpackConsts);
337
+ gatherUnpackInstructions (DSAInfo, CapturedInfo , OI, DI, TAI, UnpackInsts, UnpackConsts);
321
338
322
339
DependsList.push_back (DI);
323
340
}
@@ -327,50 +344,50 @@ static void gatherDependsInfoFromBundles(const SmallVectorImpl<OperandBundleDef>
327
344
static void gatherDependsInfoWithID (const IntrinsicInst *I,
328
345
const OrderedInstructions &OI,
329
346
const TaskDSAInfo &DSAInfo,
330
- const TaskVLADimsInfo &VLADimsInfo ,
347
+ const TaskCapturedInfo &CapturedInfo ,
331
348
TaskAnalysisInfo &TAI,
332
349
SmallVectorImpl<DependInfo> &DependsList,
333
350
SmallVectorImpl<Instruction *> &UnpackInsts,
334
351
SetVector<ConstantExpr *> &UnpackConsts,
335
352
uint64_t Id) {
336
353
SmallVector<OperandBundleDef, 4 > OpBundles;
337
354
getOperandBundlesAsDefsWithID (I, OpBundles, Id);
338
- gatherDependsInfoFromBundles (OpBundles, OI, DSAInfo, VLADimsInfo , TAI, DependsList, UnpackInsts, UnpackConsts);
355
+ gatherDependsInfoFromBundles (OpBundles, OI, DSAInfo, CapturedInfo , TAI, DependsList, UnpackInsts, UnpackConsts);
339
356
}
340
357
341
358
// Gathers all dependencies needed information
342
359
static void gatherDependsInfo (const IntrinsicInst *I, TaskInfo &TI,
343
360
TaskAnalysisInfo &TAI,
344
361
const OrderedInstructions &OI) {
345
- gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.VLADimsInfo , TAI,
362
+ gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.CapturedInfo , TAI,
346
363
TI.DependsInfo .Ins ,
347
364
TI.DependsInfo .UnpackInstructions ,
348
365
TI.DependsInfo .UnpackConstants ,
349
366
LLVMContext::OB_oss_dep_in);
350
- gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.VLADimsInfo , TAI,
367
+ gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.CapturedInfo , TAI,
351
368
TI.DependsInfo .Outs ,
352
369
TI.DependsInfo .UnpackInstructions ,
353
370
TI.DependsInfo .UnpackConstants ,
354
371
LLVMContext::OB_oss_dep_out);
355
- gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.VLADimsInfo , TAI,
372
+ gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.CapturedInfo , TAI,
356
373
TI.DependsInfo .Inouts ,
357
374
TI.DependsInfo .UnpackInstructions ,
358
375
TI.DependsInfo .UnpackConstants ,
359
376
LLVMContext::OB_oss_dep_inout);
360
377
361
- gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.VLADimsInfo , TAI,
378
+ gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.CapturedInfo , TAI,
362
379
TI.DependsInfo .WeakIns ,
363
380
TI.DependsInfo .UnpackInstructions ,
364
381
TI.DependsInfo .UnpackConstants ,
365
382
LLVMContext::OB_oss_dep_weakin);
366
383
367
- gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.VLADimsInfo , TAI,
384
+ gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.CapturedInfo , TAI,
368
385
TI.DependsInfo .WeakOuts ,
369
386
TI.DependsInfo .UnpackInstructions ,
370
387
TI.DependsInfo .UnpackConstants ,
371
388
LLVMContext::OB_oss_dep_weakout);
372
389
373
- gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.VLADimsInfo , TAI,
390
+ gatherDependsInfoWithID (I, OI, TI.DSAInfo , TI.CapturedInfo , TAI,
374
391
TI.DependsInfo .WeakInouts ,
375
392
TI.DependsInfo .UnpackInstructions ,
376
393
TI.DependsInfo .UnpackConstants ,
@@ -383,6 +400,20 @@ static void gatherIfFinalInfo(const IntrinsicInst *I, TaskInfo &TI) {
383
400
getValueFromOperandBundleWithID (I, TI.If , LLVMContext::OB_oss_if);
384
401
}
385
402
403
+ // It's expected to have VLA dims info before calling this
404
+ static void gatherCapturedInfo (const IntrinsicInst *I, TaskInfo &TI) {
405
+ getValueListFromOperandBundlesWithID (I, TI.CapturedInfo , LLVMContext::OB_oss_captured);
406
+ if (!DisableChecks) {
407
+ // VLA Dims that are not Captured is an error
408
+ for (auto &VLAWithDimsMap : TI.VLADimsInfo ) {
409
+ for (Value *const &V : VLAWithDimsMap.second ) {
410
+ if (!valueInCapturedBundle (TI.CapturedInfo , V))
411
+ llvm_unreachable (" VLA dimension has not been captured" );
412
+ }
413
+ }
414
+ }
415
+ }
416
+
386
417
void OmpSsRegionAnalysisPass::getOmpSsFunctionInfo (
387
418
Function &F, DominatorTree &DT, FunctionInfo &FI,
388
419
TaskFunctionAnalysisInfo &TFAI,
@@ -417,6 +448,7 @@ void OmpSsRegionAnalysisPass::getOmpSsFunctionInfo(
417
448
418
449
gatherDSAInfo (II, T.Info );
419
450
gatherVLADimsInfo (II, T.Info );
451
+ gatherCapturedInfo (II, T.Info );
420
452
gatherDependsInfo (II, T.Info , T.AnalysisInfo , OI);
421
453
gatherIfFinalInfo (II, T.Info );
422
454
@@ -448,7 +480,7 @@ void OmpSsRegionAnalysisPass::getOmpSsFunctionInfo(
448
480
T.AnalysisInfo .UsesBeforeEntry .insert (I2);
449
481
if (!DisableChecks
450
482
&& !valueInDSABundles (T.Info .DSAInfo , I2)
451
- && !valueInVLADimsBundles (T.Info .VLADimsInfo , I2)) {
483
+ && !valueInCapturedBundle (T.Info .CapturedInfo , I2)) {
452
484
llvm_unreachable (" Value supposed to be inside task entry "
453
485
" OperandBundle not found." );
454
486
}
@@ -457,7 +489,7 @@ void OmpSsRegionAnalysisPass::getOmpSsFunctionInfo(
457
489
T.AnalysisInfo .UsesBeforeEntry .insert (A);
458
490
if (!DisableChecks
459
491
&& !valueInDSABundles (T.Info .DSAInfo , A)
460
- && !valueInVLADimsBundles (T.Info .VLADimsInfo , A)) {
492
+ && !valueInCapturedBundle (T.Info .CapturedInfo , A)) {
461
493
llvm_unreachable (" Value supposed to be inside task entry "
462
494
" OperandBundle not found." );
463
495
}
0 commit comments