Skip to content

Commit 79928b2

Browse files
dmitryryinteligcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: c7334a7
avoid localization of large data for oclbin, use relocation instead
1 parent f85f5e1 commit 79928b2

File tree

5 files changed

+14
-91
lines changed

5 files changed

+14
-91
lines changed

IGC/VectorCompiler/include/vc/Support/BackendConfig.h

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -51,48 +51,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5151
#include <llvm/Pass.h>
5252
#include <llvm/PassRegistry.h>
5353

54-
#include <limits>
55-
5654
namespace llvm {
5755

5856
void initializeGenXBackendConfigPass(PassRegistry &PR);
5957

60-
struct GlobalsLocalizationConfig {
61-
using LimitT = std::size_t;
62-
static constexpr auto NoLimit = std::numeric_limits<LimitT>::max();
63-
64-
private:
65-
// Whether every global variable must be localized.
66-
bool IsForced = true;
67-
// How many GRF memory is allowed to be used for localization.
68-
LimitT Limit = NoLimit;
69-
70-
public:
71-
GlobalsLocalizationConfig(bool IsForcedIn, LimitT LimitIn)
72-
: IsForced{IsForcedIn}, Limit{LimitIn} {
73-
if (IsForced)
74-
IGC_ASSERT_MESSAGE(
75-
Limit == NoLimit,
76-
"there can be no localization limit when localization is forced");
77-
}
78-
79-
GlobalsLocalizationConfig() {}
80-
81-
// Every global variable must be localized.
82-
static GlobalsLocalizationConfig CreateForcedLocalization() { return {}; }
83-
84-
// GlobalsLocalization is allowed to localize globals but it can use only
85-
// GlobalsLocalizationLimit bytes of GRF.
86-
static GlobalsLocalizationConfig
87-
CreateLocalizationWithLimit(LimitT GlobalsLocalizationLimitIn = NoLimit) {
88-
return {false, GlobalsLocalizationLimitIn};
89-
}
90-
91-
bool isForced() const { return IsForced; }
92-
93-
LimitT getLimit() const { return Limit; }
94-
};
95-
9658
// Plain structure to be filled by users who want to create backend
9759
// configuration. Some values are default-initialized from cl options.
9860
struct GenXBackendOptions {
@@ -112,10 +74,6 @@ struct GenXBackendOptions {
11274
bool EnableDebugInfoDumps;
11375
std::string DebugInfoDumpsNameOverride;
11476

115-
// Configuration for GlobalsLocalization pass
116-
// (part of CMABI pass by historical reasons).
117-
GlobalsLocalizationConfig GlobalsLocalization;
118-
11977
GenXBackendOptions();
12078
};
12179

@@ -174,13 +132,6 @@ class GenXBackendConfig : public ImmutablePass {
174132
const std::string &dbgInfoDumpsNameOverride() const {
175133
return Options.DebugInfoDumpsNameOverride;
176134
}
177-
178-
bool isGlobalsLocalizationForced() const {
179-
return Options.GlobalsLocalization.isForced();
180-
}
181-
GlobalsLocalizationConfig::LimitT getGlobalsLocalizationLimit() const {
182-
return Options.GlobalsLocalization.getLimit();
183-
}
184135
};
185136
} // namespace llvm
186137

IGC/VectorCompiler/lib/GenXCodeGen/GenXWrapper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,6 @@ static GenXBackendOptions createBackendOptions(const vc::CompileOptions &Opts) {
454454
BackendOpts.EnableAsmDumps = Opts.DumpAsm;
455455
BackendOpts.EnableDebugInfoDumps = Opts.DumpDebugInfo;
456456
BackendOpts.Dumper = Opts.Dumper.get();
457-
BackendOpts.GlobalsLocalization =
458-
(Opts.Binary == vc::BinaryKind::OpenCL)
459-
? GlobalsLocalizationConfig::CreateLocalizationWithLimit()
460-
: GlobalsLocalizationConfig::CreateForcedLocalization();
461457
return BackendOpts;
462458
}
463459

IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMABI.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4141

4242
#define DEBUG_TYPE "cmabi"
4343

44-
#include "llvmWrapper/Analysis/CallGraph.h"
4544
#include "llvmWrapper/IR/CallSite.h"
45+
#include "llvmWrapper/Support/Alignment.h"
4646
#include "llvmWrapper/IR/DerivedTypes.h"
4747
#include "llvmWrapper/IR/Instructions.h"
48-
#include "llvmWrapper/Support/Alignment.h"
49-
50-
#include "Probe/Assertion.h"
5148

5249
#include "vc/GenXOpts/GenXOpts.h"
5350
#include "vc/GenXOpts/Utils/GenXSTLExtras.h"
54-
#include "vc/Support/BackendConfig.h"
55-
5651
#include "llvm/ADT/DenseMap.h"
5752
#include "llvm/ADT/PostOrderIterator.h"
5853
#include "llvm/ADT/SCCIterator.h"
@@ -81,6 +76,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8176
#include "llvm/Support/raw_ostream.h"
8277
#include "llvm/Transforms/Scalar.h"
8378

79+
#include "llvmWrapper/Analysis/CallGraph.h"
80+
#include "Probe/Assertion.h"
81+
8482
#include <algorithm>
8583
#include <iterator>
8684
#include <numeric>
@@ -91,6 +89,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9189

9290
using namespace llvm;
9391

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+
9499
STATISTIC(NumArgumentsTransformed, "Number of pointer arguments transformed");
95100

96101
// FIXME: find a propper place for addrspace enum, agree on addrspace politics
@@ -248,7 +253,6 @@ int DiagnosticInfoOverlappingArgs::KindID = 0;
248253
class CMABIAnalysis : public ModulePass {
249254
// This map captures all global variables to be localized.
250255
std::vector<LocalizationInfo *> LocalizationInfoObjs;
251-
GlobalsLocalizationConfig::LimitT GlobalsLocalizationLimit;
252256

253257
public:
254258
static char ID;
@@ -263,7 +267,6 @@ class CMABIAnalysis : public ModulePass {
263267

264268
void getAnalysisUsage(AnalysisUsage &AU) const override {
265269
AU.addRequired<CallGraphWrapperPass>();
266-
AU.addRequired<GenXBackendConfig>();
267270
AU.setPreservesAll();
268271
}
269272

@@ -356,25 +359,10 @@ char CMABIAnalysis::ID = 0;
356359
INITIALIZE_PASS_BEGIN(CMABIAnalysis, "cmabi-analysis",
357360
"helper analysis pass to get info for CMABI", false, true)
358361
INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass)
359-
INITIALIZE_PASS_DEPENDENCY(GenXBackendConfig)
360362
INITIALIZE_PASS_END(CMABIAnalysis, "cmabi-analysis",
361363
"Fix ABI issues for the genx backend", false, true)
362364

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-
375365
bool CMABIAnalysis::runOnModule(Module &M) {
376-
GlobalsLocalizationLimit =
377-
defineGlobalsLocalizationLimit(getAnalysis<GenXBackendConfig>());
378366
runOnCallGraph(getAnalysis<CallGraphWrapperPass>().getCallGraph());
379367
return false;
380368
}
@@ -414,7 +402,7 @@ auto selectGlobalsToLocalize(ForwardRange Globals, T Bound,
414402
Globals, [ExcludePred](GVRef GV) { return !ExcludePred(GV); });
415403
using GVWithWeightT = std::pair<GVPtr, int>;
416404

417-
if (Bound == GlobalsLocalizationConfig::NoLimit) {
405+
if (Bound == LocalizeAll) {
418406
std::vector<GVPtr> ToLocalize;
419407
transform(Unexcluded, std::back_inserter(ToLocalize),
420408
[](GVRef GV) { return &GV; });
@@ -1962,7 +1950,7 @@ void CMABIAnalysis::analyzeGlobals(CallGraph &CG) {
19621950
};
19631951
const auto &DL = M.getDataLayout();
19641952
std::vector<GlobalVariable *> ToLocalize = selectGlobalsToLocalize(
1965-
M.globals(), GlobalsLocalizationLimit,
1953+
M.globals(), LocalizationLimit.getValue(),
19661954
[UsesPrintChecker](const GlobalVariable &GV) {
19671955
// don't localize global constant format string if it's used by print_index intrinsic
19681956
bool UsesPrintIndex = std::any_of(GV.use_begin(), GV.use_end(), UsesPrintChecker);

IGC/VectorCompiler/lib/GenXOpts/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ set(OPT_SOURCES
1616
add_library(VCTransforms ${OPT_SOURCES})
1717
target_link_libraries(VCTransforms
1818
VCHeaders
19-
VCSupport
2019
LLVMGenXIntrinsics
2120
)

IGC/VectorCompiler/lib/Support/BackendConfig.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ static cl::opt<std::string>
7171
"precompiled OpenCL generic builtins"),
7272
cl::init(""));
7373

74-
static cl::opt<bool> ForceGlobalsLocalizationOpt(
75-
"vc-force-globals-localization",
76-
cl::desc("all global variables must be localized"), cl::init(true));
77-
78-
static cl::opt<GlobalsLocalizationConfig::LimitT> GlobalsLocalizationLimitOpt(
79-
"vc-globals-localization-limit",
80-
cl::desc("maximum size (in bytes) used to localize global variables"),
81-
cl::init(GlobalsLocalizationConfig::NoLimit));
82-
8374
//===----------------------------------------------------------------------===//
8475
//
8576
// Backend config related stuff.
@@ -91,9 +82,7 @@ GenXBackendOptions::GenXBackendOptions()
9182
: EnableKernelDebug(GenerateDebugInfoOpt), DumpRegAlloc(DumpRegAllocOpt),
9283
StackSurfaceMaxSize(StackMemSizeOpt), EnableAsmDumps(EnableAsmDumpsOpt),
9384
EnableDebugInfoDumps(EnableDebugInfoDumpOpt),
94-
DebugInfoDumpsNameOverride(DebugInfoDumpNameOverride),
95-
GlobalsLocalization{ForceGlobalsLocalizationOpt.getValue(),
96-
GlobalsLocalizationLimitOpt.getValue()} {}
85+
DebugInfoDumpsNameOverride(DebugInfoDumpNameOverride) {}
9786

9887
GenXBackendData::GenXBackendData() {
9988
if (OCLGenericBiFPath.getNumOccurrences() == 0)

0 commit comments

Comments
 (0)