@@ -327,16 +327,18 @@ class AMDGPULowerModuleLDS {
327
327
return convertUsersOfConstantsToInstructions (LDSGlobals);
328
328
}
329
329
330
+ std::optional<bool > HasAbsoluteGVs;
331
+
330
332
public:
331
333
AMDGPULowerModuleLDS (const AMDGPUTargetMachine &TM_) : TM(TM_) {}
332
334
333
335
using FunctionVariableMap = DenseMap<Function *, DenseSet<GlobalVariable *>>;
334
336
335
337
using VariableFunctionMap = DenseMap<GlobalVariable *, DenseSet<Function *>>;
336
338
337
- static void getUsesOfLDSByFunction (CallGraph const &CG, Module &M,
338
- FunctionVariableMap &kernels,
339
- FunctionVariableMap &functions) {
339
+ void getUsesOfLDSByFunction (CallGraph const &CG, Module &M,
340
+ FunctionVariableMap &kernels,
341
+ FunctionVariableMap &functions) {
340
342
341
343
// Get uses from the current function, excluding uses by called functions
342
344
// Two output variables to avoid walking the globals list twice
@@ -345,10 +347,18 @@ class AMDGPULowerModuleLDS {
345
347
continue ;
346
348
}
347
349
348
- if (GV.isAbsoluteSymbolRef ()) {
349
- report_fatal_error (
350
- " LDS variables with absolute addresses are unimplemented." );
351
- }
350
+ // Check if the module is consistent: either all GVs are absolute (happens
351
+ // when we run the pass more than once), or none are.
352
+ if (HasAbsoluteGVs.has_value ()) {
353
+ if (*HasAbsoluteGVs != GV.isAbsoluteSymbolRef ()) {
354
+ report_fatal_error (
355
+ " Module cannot mix absolute and non-absolute LDS GVs" );
356
+ }
357
+ } else
358
+ HasAbsoluteGVs = GV.isAbsoluteSymbolRef ();
359
+
360
+ if (GV.isAbsoluteSymbolRef ())
361
+ continue ;
352
362
353
363
for (User *V : GV.users ()) {
354
364
if (auto *I = dyn_cast<Instruction>(V)) {
@@ -368,7 +378,7 @@ class AMDGPULowerModuleLDS {
368
378
FunctionVariableMap indirect_access;
369
379
};
370
380
371
- static LDSUsesInfoTy getTransitiveUsesOfLDS (CallGraph const &CG, Module &M) {
381
+ LDSUsesInfoTy getTransitiveUsesOfLDS (CallGraph const &CG, Module &M) {
372
382
373
383
FunctionVariableMap direct_map_kernel;
374
384
FunctionVariableMap direct_map_function;
0 commit comments