Skip to content

Commit d27c584

Browse files
juanrod2lwesiers
authored andcommitted
Synchronisation between branches
Change-Id: I716f26020732afe3c70c431bb61cec9418947635
1 parent 082d71f commit d27c584

25 files changed

+303
-1038
lines changed

IGC/Compiler/CISACodeGen/DeSSA.cpp

Lines changed: 222 additions & 180 deletions
Large diffs are not rendered by default.

IGC/Compiler/CISACodeGen/DeSSA.hpp

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class DeSSA : public llvm::FunctionPass {
100100
PHISrcArgs.clear();
101101
RegNodeMap.clear();
102102
InsEltMap.clear();
103-
PrefCCMap.clear();
104103
AliasMap.clear();
105104
}
106105

@@ -214,6 +213,7 @@ class DeSSA : public llvm::FunctionPass {
214213
llvm::Function* m_F; // Current Function
215214

216215
llvm::BumpPtrAllocator Allocator;
216+
217217
// Color (label) assigned to each congruent class
218218
// start from 1. Make sure each Node has a different
219219
// color number.
@@ -241,18 +241,6 @@ class DeSSA : public llvm::FunctionPass {
241241
// with a single-node in phi-union. When being isolated, they are isolated together
242242
llvm::MapVector<llvm::Value*, llvm::Value*> InsEltMap;
243243

244-
// Preferred Congruent Class Map
245-
// Assume value v0, v1, v2 are preferred to be in the same congurent class, and
246-
// assume v0 is the root (anyone could be the root), this map will be something like:
247-
// PrefCCMap[v0] = v0 // map-key == map-value: map-value is the root
248-
// PrefCCMap[v1] = v0
249-
// PrefCCMap[v2] = v0
250-
// The purpose of this map is that during value isolation (main algo), if one of the preferred
251-
// value is isolated, all values in the preferred CC shall be isolated as well. In another word,
252-
// the preferred values will be guaranteed to stay in the same congurent class after dessa
253-
// on phi's.
254-
llvm::DenseMap<llvm::Value*, llvm::Value*> PrefCCMap;
255-
256244
// Value Alias map
257245
// This is used for maitaining aliases among values. It maps a value, called 'aliaser',
258246
// to its 'aliasee' (denoted as alias(aliaer, aliasee). This map has the following
@@ -272,6 +260,10 @@ class DeSSA : public llvm::FunctionPass {
272260
// 3. Make sure DeSSA node only use aliasee.
273261
llvm::DenseMap<llvm::Value*, llvm::Value*> AliasMap;
274262

263+
// If an inst is an aliaser and no need to generate code
264+
// due to aliasing, it will be added in this map.
265+
llvm::DenseMap<llvm::Value*, int> NoopAliasMap;
266+
275267
/// If there is no node for Val, create a new one.
276268
void addReg(llvm::Value* Val, e_alignment Align);
277269

@@ -284,10 +276,18 @@ class DeSSA : public llvm::FunctionPass {
284276
unionRegs(RegNodeMap[Val1], RegNodeMap[Val2]);
285277
}
286278

279+
// For a value, return its representative value that is used
280+
// to create dessa node, which is its aliasee's InsElt root.
281+
llvm::Value* getNodeValue(llvm::Value* V) const {
282+
llvm::Value* aliasee = getAliasee(V);
283+
return getInsEltRoot(aliasee);
284+
}
285+
287286
llvm::Value* getInsEltRoot(llvm::Value* Val) const;
288287
llvm::Value* getAliasee(llvm::Value* V) const;
289288
bool isAliasee(llvm::Value* V) const;
290289
bool isAliaser(llvm::Value* V) const;
290+
bool isNoopAliaser(llvm::Value* V) const;
291291
bool interfere(llvm::Value* V0, llvm::Value* V1);
292292
bool alignInterfere(e_alignment a1, e_alignment a2);
293293

@@ -306,33 +306,25 @@ class DeSSA : public llvm::FunctionPass {
306306

307307
void unionRegs(Node* N1, Node* N2);
308308
void CoalesceAliasInstForBasicBlock(llvm::BasicBlock *Blk);
309+
int checkInsertElementAlias(
310+
llvm::InsertElementInst* IEI,
311+
llvm::SmallVector<llvm::Value*, 16>& AllIEIs);
312+
313+
// Add Val into aliasMap if it is not in the map yet.
314+
// Return Val's aliasee.
309315
void AddAlias(llvm::Value *Val) {
310-
if (AliasMap.find(Val) == AliasMap.end()) {
316+
if (AliasMap.find(Val) == AliasMap.end())
311317
AliasMap[Val] = Val;
312-
}
313-
}
314-
void PrefCCMapAddValue(llvm::Value *Val) {
315-
if (PrefCCMap.find(Val) == PrefCCMap.end()) {
316-
PrefCCMap[Val] = Val;
317-
}
318-
}
319-
320-
// Return its root if V is in a preferred CC; nullptr otherwise.
321-
llvm::Value* getPrefCCRoot(llvm::Value* V) {
322-
if (PrefCCMap.find(V) != PrefCCMap.end()) {
323-
return PrefCCMap[V];
324-
}
325-
return nullptr;
326318
}
327319

328-
// If V is an inst and it is not needed (by patternmatch),
329-
// return false; otherwise, return true;
330-
bool isNeededIfInst(llvm::Value *V) {
320+
// If V is an arg or a needed inst (by patternmatch),
321+
// return true; otherwise, return false;
322+
bool isArgOrNeededInst(llvm::Value *V) {
331323
if (llvm::Instruction* I = llvm::dyn_cast<llvm::Instruction>(V))
332324
{
333325
return CG->NeedInstruction(*I);
334326
}
335-
return true;
327+
return llvm::isa<llvm::Argument>(V);
336328
}
337329
};
338330

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8223,7 +8223,7 @@ void EmitPass::EmitNoModifier(llvm::Instruction* inst)
82238223
}
82248224

82258225
if (IGC_IS_FLAG_ENABLED(EnableDeSSAAlias) &&
8226-
m_deSSA && m_deSSA->isAliaser(inst))
8226+
m_deSSA && m_deSSA->isNoopAliaser(inst))
82278227
{
82288228
return;
82298229
}

visa/BinaryEncoding.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -980,11 +980,6 @@ inline void SetSrc0Imm32(BinInst *mybin, uint32_t value, G4_Operand* src)
980980
return;
981981
else
982982
mybin->SetBits(bitsSrcImm32_0,bitsSrcImm32_1,value);
983-
984-
if (src->isRelocImm())
985-
{
986-
((G4_Reloc_Imm*)src)->setNativeOffset((unsigned int)(bitsSrcImm32_1 / 8));
987-
}
988983
}
989984

990985
inline void SetSrc0Imm64(BinInst *mybin, uint64_t value, G4_Operand* src)
@@ -993,11 +988,6 @@ inline void SetSrc0Imm64(BinInst *mybin, uint64_t value, G4_Operand* src)
993988
uint32_t high = value >> 32;
994989
mybin->SetBits( bitsSrcImm64_2, bitsSrcImm64_3, low );
995990
mybin->SetBits( bitsSrcImm64_0, bitsSrcImm64_1, high );
996-
997-
if (src->isRelocImm())
998-
{
999-
((G4_Reloc_Imm*)src)->setNativeOffset((unsigned int)(bitsSrcImm64_3 / 8));
1000-
}
1001991
}
1002992

1003993
inline void EncodeSrc0RegFile(BinInst *mybin, G4_Operand *src0)
@@ -1040,11 +1030,6 @@ inline void SetSrc1Imm32(BinInst *mybin, uint32_t value, G4_Operand* src)
10401030
return;
10411031
else
10421032
mybin->SetBits(bitsSrcImm32_2,bitsSrcImm32_3,value);
1043-
1044-
if (src->isRelocImm())
1045-
{
1046-
((G4_Reloc_Imm*)src)->setNativeOffset((unsigned int)(bitsSrcImm32_3 / 8));
1047-
}
10481033
}
10491034

10501035
inline void EncodeSrcImmData(BinInst *mybin, G4_Operand *src)

visa/BuildCISAIR.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,8 @@ extern int CISAdebug;
4343
#include "VISABuilderAPIDefinition.h"
4444
#include "visa_wa.h"
4545

46-
//#define TIME_vISA_LOADING
47-
//#define TIME_IR_CONSTRUCTION
4846
class Options;
4947

50-
class NativeRelocs
51-
{
52-
public:
53-
void *operator new(size_t sz, vISA::Mem_Manager& m){ return m.alloc(sz); }
54-
void addEntry(uint64_t offset, uint64_t info, int64_t addend, unsigned int nativeOffset);
55-
unsigned int getNativeOffset(unsigned int cisaOffset);
56-
bool isOffsetReloc(uint64_t offset, SuperRelocEntry& info);
57-
58-
unsigned getNumEntries() { return (uint32_t) entries.size(); }
59-
SuperRelocEntry getEntry(unsigned int idx)
60-
{
61-
return entries[idx];
62-
}
63-
private:
64-
std::vector<SuperRelocEntry> entries;
65-
};
66-
6748
class CISA_IR_Builder : public VISABuilder
6849
{
6950
public:
@@ -84,7 +65,6 @@ class CISA_IR_Builder : public VISABuilder
8465
m_cisaBinary = new (m_mem) CisaFramework::CisaBinary(&m_options);
8566
m_currentKernel = NULL;
8667
m_pWaTable = pWaTable;
87-
nativeRelocs = NULL;
8868
}
8969

9070
virtual ~CISA_IR_Builder();
@@ -769,17 +749,6 @@ class CISA_IR_Builder : public VISABuilder
769749
std::stringstream m_ssIsaAsm;
770750
std::stringstream m_ssIsaAsmHeader;
771751

772-
void setupNativeRelocs(unsigned int, const BasicRelocEntry*);
773-
NativeRelocs* getNativeRelocs(bool createIfNULL = true)
774-
{
775-
if (!nativeRelocs &&
776-
createIfNULL)
777-
{
778-
nativeRelocs = new (m_mem)NativeRelocs();
779-
}
780-
return nativeRelocs;
781-
}
782-
783752
void setGtpinInit(void* buf) { gtpin_init = buf; }
784753
void* getGtpinInit() { return gtpin_init; }
785754

@@ -810,8 +779,6 @@ class CISA_IR_Builder : public VISABuilder
810779

811780
PVISA_WA_TABLE m_pWaTable;
812781

813-
NativeRelocs* nativeRelocs;
814-
815782
void* gtpin_init = nullptr;
816783
};
817784
extern _THREAD CISA_IR_Builder * pCisaBuilder;

visa/BuildCISAIRImpl.cpp

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ CISA_IR_Builder::~CISA_IR_Builder()
7474
// don't call delete since vISAKernelImpl is allocated in memory pool
7575
kernel->~VISAKernelImpl();
7676
}
77-
78-
if (nativeRelocs)
79-
{
80-
nativeRelocs->~NativeRelocs();
81-
}
8277
}
8378

8479
void CISA_IR_Builder::InitVisaWaTable(TARGET_PLATFORM platform, Stepping step)
@@ -888,7 +883,6 @@ int CISA_IR_Builder::Compile( const char* nameInput)
888883

889884
compilationUnits.push_back(kernel->getKernel());
890885

891-
kernel->setupRelocTable();
892886
kernel->getIRBuilder()->setIsKernel(kernel->getIsKernel());
893887
kernel->getIRBuilder()->setCUnitId(i);
894888
if( kernel->getIsKernel() == false )
@@ -975,16 +969,6 @@ int CISA_IR_Builder::Compile( const char* nameInput)
975969
kernel->computeAndEmitDebugInfo(functions);
976970
}
977971

978-
#ifndef DLL_MODE
979-
if (m_options.getOptionCstr(vISA_RelocFilename))
980-
{
981-
// Emit gen reloc information to a file only in offline invocation.
982-
// In DLL mode return reloc information of the kernel being
983-
// compiled.
984-
kernel->computeAndEmitGenRelocs();
985-
}
986-
#endif
987-
988972
restoreFCallState( kernel->getKernel(), savedFCallState );
989973

990974

@@ -1155,53 +1139,6 @@ bool CISA_IR_Builder::CISA_file_variable_decl(char * var_name,
11551139
return true;
11561140
}
11571141

1158-
void CISA_IR_Builder::setupNativeRelocs(unsigned int numRelocs, const BasicRelocEntry* relocs)
1159-
{
1160-
for (unsigned int i = 0; i < numRelocs; i++)
1161-
{
1162-
getNativeRelocs()->addEntry(relocs[i].relocOffset, relocs[i].info, relocs[i].addend, 0);
1163-
}
1164-
}
1165-
1166-
void NativeRelocs::addEntry(uint64_t offset, uint64_t info, int64_t addend, unsigned int nativeOffset)
1167-
{
1168-
SuperRelocEntry entry;
1169-
entry.input.relocOffset = offset;
1170-
entry.input.info = info;
1171-
entry.input.addend = addend;
1172-
entry.nativeOffset = nativeOffset;
1173-
entries.push_back(entry);
1174-
}
1175-
1176-
bool NativeRelocs::isOffsetReloc(uint64_t offset, SuperRelocEntry& info)
1177-
{
1178-
for (auto it : entries)
1179-
{
1180-
if (it.input.relocOffset == offset)
1181-
{
1182-
info = it;
1183-
return true;
1184-
}
1185-
}
1186-
1187-
return false;
1188-
}
1189-
1190-
unsigned int NativeRelocs::getNativeOffset(unsigned int cisaOffset)
1191-
{
1192-
for (auto it : entries)
1193-
{
1194-
if (it.input.relocOffset == cisaOffset)
1195-
{
1196-
return it.nativeOffset;
1197-
}
1198-
}
1199-
1200-
#define INVALID_GEN_OFFSET (0xffffffff)
1201-
1202-
return INVALID_GEN_OFFSET;
1203-
}
1204-
12051142
bool CISA_IR_Builder::CISA_addr_variable_decl(char *var_name, unsigned int var_elements, VISA_Type data_type, attr_gen_struct scope, int line_no)
12061143
{
12071144

visa/BuildIR.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ class IR_Builder {
408408

409409
bool isKernel;
410410
int cunit;
411-
reloc_symtab* varRelocTable;
412-
reloc_symtab* funcRelocTable;
413411
const std::vector <char*>* resolvedCalleeNames;
414412

415413
// pre-defined declare that binds to R0 (the entire GRF)
@@ -627,10 +625,6 @@ class IR_Builder {
627625
int getCUnitId() { return cunit; }
628626
void setIsKernel( bool value ) { isKernel = value; }
629627
bool getIsKernel() { return isKernel; }
630-
void setVarRelocTable( reloc_symtab* tab ) { varRelocTable = tab; }
631-
reloc_symtab* getVarRelocTable() { return varRelocTable; }
632-
void setFuncRelocTable( reloc_symtab* tab ) { funcRelocTable = tab; }
633-
reloc_symtab* getFuncRelocTable() { return funcRelocTable; }
634628
void setResolvedCalleeNames(std::vector<char*>* nameList) { resolvedCalleeNames = nameList; }
635629
const std::vector<char*>* getResolvedCalleeNames() { return resolvedCalleeNames; }
636630
void predefinedVarRegAssignment(uint8_t inputSize);
@@ -861,7 +855,7 @@ class IR_Builder {
861855
Mem_Manager &m, Options *options, bool isFESP64Bits,
862856
FINALIZER_INFO *jitInfo = NULL, PVISA_WA_TABLE pWaTable = NULL)
863857
: curFile(NULL), curLine(0), curCISAOffset(-1), func_id(-1), metaData(jitInfo),
864-
isKernel(false), cunit(0), varRelocTable(NULL), funcRelocTable(NULL), resolvedCalleeNames(NULL),
858+
isKernel(false), cunit(0), resolvedCalleeNames(NULL),
865859
usesSampler(false), m_pWaTable(pWaTable), m_options(options), CanonicalRegionStride0(0, 1, 0),
866860
CanonicalRegionStride1(1, 1, 0), CanonicalRegionStride2(2, 1, 0), CanonicalRegionStride4(4, 1, 0),
867861
use64BitFEStackVars(isFESP64Bits), mem(m), phyregpool(pregs), hashtable(m), rgnpool(m), dclpool(m),
@@ -1396,10 +1390,10 @@ class IR_Builder {
13961390
// Create immediate operand without looking up hash table. This operand
13971391
// is a relocatable immediate type.
13981392
//
1399-
G4_Reloc_Imm* createRelocImm(SuperRelocEntry& reloc, G4_Type ty)
1393+
G4_Reloc_Imm* createRelocImm(G4_Type ty)
14001394
{
14011395
G4_Reloc_Imm* newImm;
1402-
newImm = new (mem)G4_Reloc_Imm(reloc, ty);
1396+
newImm = new (mem)G4_Reloc_Imm(ty);
14031397
return newImm;
14041398
}
14051399

0 commit comments

Comments
 (0)