@@ -41,18 +41,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41
41
42
42
#define DEBUG_TYPE " cmabi"
43
43
44
- #include " llvmWrapper/Analysis/CallGraph.h"
45
44
#include " llvmWrapper/IR/CallSite.h"
45
+ #include " llvmWrapper/Support/Alignment.h"
46
46
#include " llvmWrapper/IR/DerivedTypes.h"
47
47
#include " llvmWrapper/IR/Instructions.h"
48
- #include " llvmWrapper/Support/Alignment.h"
49
-
50
- #include " Probe/Assertion.h"
51
48
52
49
#include " vc/GenXOpts/GenXOpts.h"
53
50
#include " vc/GenXOpts/Utils/GenXSTLExtras.h"
54
- #include " vc/Support/BackendConfig.h"
55
-
56
51
#include " llvm/ADT/DenseMap.h"
57
52
#include " llvm/ADT/PostOrderIterator.h"
58
53
#include " llvm/ADT/SCCIterator.h"
@@ -81,6 +76,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
81
76
#include " llvm/Support/raw_ostream.h"
82
77
#include " llvm/Transforms/Scalar.h"
83
78
79
+ #include " llvmWrapper/Analysis/CallGraph.h"
80
+ #include " Probe/Assertion.h"
81
+
84
82
#include < algorithm>
85
83
#include < iterator>
86
84
#include < numeric>
@@ -91,6 +89,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
91
89
92
90
using namespace llvm ;
93
91
92
+ using LocalizationLimitT = int32_t ;
93
+ static constexpr auto LocalizeAll = std::numeric_limits<LocalizationLimitT>::max();
94
+ static cl::opt<LocalizationLimitT>
95
+ LocalizationLimit (" cm-abi-issues-localization-limit" ,
96
+ cl::desc (" maximum size (in bytes) used to localize global variables" ),
97
+ cl::init(LocalizeAll));
98
+
94
99
STATISTIC (NumArgumentsTransformed, " Number of pointer arguments transformed" );
95
100
96
101
// FIXME: find a propper place for addrspace enum, agree on addrspace politics
@@ -248,7 +253,6 @@ int DiagnosticInfoOverlappingArgs::KindID = 0;
248
253
class CMABIAnalysis : public ModulePass {
249
254
// This map captures all global variables to be localized.
250
255
std::vector<LocalizationInfo *> LocalizationInfoObjs;
251
- GlobalsLocalizationConfig::LimitT GlobalsLocalizationLimit;
252
256
253
257
public:
254
258
static char ID;
@@ -263,7 +267,6 @@ class CMABIAnalysis : public ModulePass {
263
267
264
268
void getAnalysisUsage (AnalysisUsage &AU) const override {
265
269
AU.addRequired <CallGraphWrapperPass>();
266
- AU.addRequired <GenXBackendConfig>();
267
270
AU.setPreservesAll ();
268
271
}
269
272
@@ -356,25 +359,10 @@ char CMABIAnalysis::ID = 0;
356
359
INITIALIZE_PASS_BEGIN (CMABIAnalysis, " cmabi-analysis" ,
357
360
" helper analysis pass to get info for CMABI" , false , true )
358
361
INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass)
359
- INITIALIZE_PASS_DEPENDENCY(GenXBackendConfig)
360
362
INITIALIZE_PASS_END(CMABIAnalysis, " cmabi-analysis" ,
361
363
" Fix ABI issues for the genx backend" , false , true )
362
364
363
- static std::size_t
364
- defineGlobalsLocalizationLimit(const GenXBackendConfig &Config) {
365
- if (Config.isGlobalsLocalizationForced ())
366
- return GlobalsLocalizationConfig::NoLimit;
367
-
368
- // Half of a size of standard GenX register file in bytes.
369
- // 128 * 32 / 2
370
- constexpr std::size_t HalfGRF = 2048 ;
371
- std::size_t Limit = Config.getGlobalsLocalizationLimit ();
372
- return std::min (Limit, HalfGRF);
373
- }
374
-
375
365
bool CMABIAnalysis::runOnModule(Module &M) {
376
- GlobalsLocalizationLimit =
377
- defineGlobalsLocalizationLimit (getAnalysis<GenXBackendConfig>());
378
366
runOnCallGraph (getAnalysis<CallGraphWrapperPass>().getCallGraph ());
379
367
return false ;
380
368
}
@@ -414,7 +402,7 @@ auto selectGlobalsToLocalize(ForwardRange Globals, T Bound,
414
402
Globals, [ExcludePred](GVRef GV) { return !ExcludePred (GV); });
415
403
using GVWithWeightT = std::pair<GVPtr, int >;
416
404
417
- if (Bound == GlobalsLocalizationConfig::NoLimit ) {
405
+ if (Bound == LocalizeAll ) {
418
406
std::vector<GVPtr> ToLocalize;
419
407
transform (Unexcluded, std::back_inserter (ToLocalize),
420
408
[](GVRef GV) { return &GV; });
@@ -1962,7 +1950,7 @@ void CMABIAnalysis::analyzeGlobals(CallGraph &CG) {
1962
1950
};
1963
1951
const auto &DL = M.getDataLayout ();
1964
1952
std::vector<GlobalVariable *> ToLocalize = selectGlobalsToLocalize (
1965
- M.globals (), GlobalsLocalizationLimit ,
1953
+ M.globals (), LocalizationLimit. getValue () ,
1966
1954
[UsesPrintChecker](const GlobalVariable &GV) {
1967
1955
// don't localize global constant format string if it's used by print_index intrinsic
1968
1956
bool UsesPrintIndex = std::any_of (GV.use_begin (), GV.use_end (), UsesPrintChecker);
0 commit comments