Commit 844211e7 by John Porto

Subzero. Adds symbolic references to RelocInitializer.

BUG= R=kschimpf@google.com, stichnot@chromium.org Review URL: https://codereview.chromium.org/1661193004 .
parent 04bca5a5
...@@ -148,7 +148,8 @@ blockProfilingInfoDeclaration(GlobalContext *Ctx, const IceString &NodeAsmName, ...@@ -148,7 +148,8 @@ blockProfilingInfoDeclaration(GlobalContext *Ctx, const IceString &NodeAsmName,
const RelocOffsetT NodeNameDeclarationOffset = 0; const RelocOffsetT NodeNameDeclarationOffset = 0;
Var->addInitializer(VariableDeclaration::RelocInitializer::create( Var->addInitializer(VariableDeclaration::RelocInitializer::create(
NodeNameDeclaration, NodeNameDeclarationOffset)); NodeNameDeclaration,
{RelocOffset::create(Ctx, NodeNameDeclarationOffset)}));
Var->setAlignment(Int64ByteSize); Var->setAlignment(Int64ByteSize);
return Var; return Var;
} }
......
...@@ -787,8 +787,8 @@ void LLVM2ICEGlobalsConverter::addGlobalInitializer( ...@@ -787,8 +787,8 @@ void LLVM2ICEGlobalsConverter::addGlobalInitializer(
assert(GV); assert(GV);
const Ice::GlobalDeclaration *Addr = const Ice::GlobalDeclaration *Addr =
getConverter().getGlobalDeclaration(GV); getConverter().getGlobalDeclaration(GV);
Global.addInitializer( Global.addInitializer(Ice::VariableDeclaration::RelocInitializer::create(
Ice::VariableDeclaration::RelocInitializer::create(Addr, Offset)); Addr, {Ice::RelocOffset::create(Ctx, Offset)}));
return; return;
} }
default: default:
......
...@@ -357,18 +357,6 @@ void GlobalContext::translateFunctions() { ...@@ -357,18 +357,6 @@ void GlobalContext::translateFunctions() {
namespace { namespace {
void addBlockInfoPtrs(const VariableDeclarationList &Globals,
VariableDeclaration *ProfileBlockInfo) {
for (const VariableDeclaration *Global : Globals) {
if (Cfg::isProfileGlobal(*Global)) {
constexpr RelocOffsetT BlockExecutionCounterOffset = 0;
ProfileBlockInfo->addInitializer(
VariableDeclaration::RelocInitializer::create(
Global, BlockExecutionCounterOffset));
}
}
}
// Ensure Pending is large enough that Pending[Index] is valid. // Ensure Pending is large enough that Pending[Index] is valid.
void resizePending(std::vector<EmitterWorkItem *> &Pending, uint32_t Index) { void resizePending(std::vector<EmitterWorkItem *> &Pending, uint32_t Index) {
if (Index >= Pending.size()) if (Index >= Pending.size())
...@@ -394,6 +382,18 @@ void GlobalContext::lowerConstants() { DataLowering->lowerConstants(); } ...@@ -394,6 +382,18 @@ void GlobalContext::lowerConstants() { DataLowering->lowerConstants(); }
void GlobalContext::lowerJumpTables() { DataLowering->lowerJumpTables(); } void GlobalContext::lowerJumpTables() { DataLowering->lowerJumpTables(); }
void GlobalContext::addBlockInfoPtrs(VariableDeclaration *ProfileBlockInfo) {
for (const VariableDeclaration *Global : Globals) {
if (Cfg::isProfileGlobal(*Global)) {
constexpr RelocOffsetT BlockExecutionCounterOffset = 0;
ProfileBlockInfo->addInitializer(
VariableDeclaration::RelocInitializer::create(
Global,
{RelocOffset::create(this, BlockExecutionCounterOffset)}));
}
}
}
void GlobalContext::lowerGlobals(const IceString &SectionSuffix) { void GlobalContext::lowerGlobals(const IceString &SectionSuffix) {
TimerMarker T(TimerStack::TT_emitGlobalInitializers, this); TimerMarker T(TimerStack::TT_emitGlobalInitializers, this);
const bool DumpGlobalVariables = const bool DumpGlobalVariables =
...@@ -409,7 +409,7 @@ void GlobalContext::lowerGlobals(const IceString &SectionSuffix) { ...@@ -409,7 +409,7 @@ void GlobalContext::lowerGlobals(const IceString &SectionSuffix) {
if (Flags.getDisableTranslation()) if (Flags.getDisableTranslation())
return; return;
addBlockInfoPtrs(Globals, ProfileBlockInfoVarDecl); addBlockInfoPtrs(ProfileBlockInfoVarDecl);
// If we need to shuffle the layout of global variables, shuffle them now. // If we need to shuffle the layout of global variables, shuffle them now.
if (getFlags().shouldReorderGlobalVariables()) { if (getFlags().shouldReorderGlobalVariables()) {
// Create a random number generator for global variable reordering. // Create a random number generator for global variable reordering.
......
...@@ -538,6 +538,8 @@ private: ...@@ -538,6 +538,8 @@ private:
HasSeenCode = true; HasSeenCode = true;
} }
void addBlockInfoPtrs(VariableDeclaration *ProfileBlockInfo);
llvm::SmallVector<ThreadContext *, 128> AllThreadContexts; llvm::SmallVector<ThreadContext *, 128> AllThreadContexts;
llvm::SmallVector<std::thread, 128> TranslationThreads; llvm::SmallVector<std::thread, 128> TranslationThreads;
llvm::SmallVector<std::thread, 128> EmitterThreads; llvm::SmallVector<std::thread, 128> EmitterThreads;
......
...@@ -230,6 +230,7 @@ void VariableDeclaration::RelocInitializer::dump(GlobalContext *Ctx, ...@@ -230,6 +230,7 @@ void VariableDeclaration::RelocInitializer::dump(GlobalContext *Ctx,
Ostream &Stream) const { Ostream &Stream) const {
if (!Ice::BuildDefs::dump()) if (!Ice::BuildDefs::dump())
return; return;
const RelocOffsetT Offset = getOffset();
if (Offset != 0) { if (Offset != 0) {
dumpType(Stream); dumpType(Stream);
Stream << " add ("; Stream << " add (";
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "IceDefs.h" #include "IceDefs.h"
#include "IceGlobalContext.h" #include "IceGlobalContext.h"
#include "IceIntrinsics.h" #include "IceIntrinsics.h"
#include "IceOperand.h"
#include "IceTypes.h" #include "IceTypes.h"
#ifdef __clang__ #ifdef __clang__
...@@ -318,11 +319,19 @@ public: ...@@ -318,11 +319,19 @@ public:
public: public:
static std::unique_ptr<RelocInitializer> static std::unique_ptr<RelocInitializer>
create(const GlobalDeclaration *Declaration, RelocOffsetT Offset) { create(const GlobalDeclaration *Declaration,
return makeUnique<RelocInitializer>(Declaration, Offset); const RelocOffsetArray &OffsetExpr) {
return makeUnique<RelocInitializer>(Declaration, OffsetExpr);
}
RelocOffsetT getOffset() const {
RelocOffsetT Offset = 0;
for (const auto *RelocOffset : OffsetExpr) {
Offset += RelocOffset->getOffset();
}
return Offset;
} }
RelocOffsetT getOffset() const { return Offset; }
const GlobalDeclaration *getDeclaration() const { return Declaration; } const GlobalDeclaration *getDeclaration() const { return Declaration; }
SizeT getNumBytes() const final { return RelocAddrSize; } SizeT getNumBytes() const final { return RelocAddrSize; }
void dump(GlobalContext *Ctx, Ostream &Stream) const final; void dump(GlobalContext *Ctx, Ostream &Stream) const final;
...@@ -334,13 +343,15 @@ public: ...@@ -334,13 +343,15 @@ public:
private: private:
ENABLE_MAKE_UNIQUE; ENABLE_MAKE_UNIQUE;
RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset) RelocInitializer(const GlobalDeclaration *Declaration,
: Initializer(RelocInitializerKind), Declaration(Declaration), const RelocOffsetArray &OffsetExpr)
Offset(Offset) {} // The global declaration used in the relocation. : Initializer(RelocInitializerKind),
Declaration(Declaration), // The global declaration used in the reloc.
OffsetExpr(OffsetExpr) {}
const GlobalDeclaration *Declaration; const GlobalDeclaration *Declaration;
/// The offset to add to the relocation. /// The offset to add to the relocation.
const RelocOffsetT Offset; const RelocOffsetArray OffsetExpr;
}; };
/// Models the list of initializers. /// Models the list of initializers.
......
...@@ -1211,9 +1211,10 @@ void GlobalsParser::ProcessRecord() { ...@@ -1211,9 +1211,10 @@ void GlobalsParser::ProcessRecord() {
Error(StrBuf.str()); Error(StrBuf.str());
} }
} }
Ice::GlobalContext *Ctx = getTranslator().getContext();
CurGlobalVar->addInitializer( CurGlobalVar->addInitializer(
Ice::VariableDeclaration::RelocInitializer::create( Ice::VariableDeclaration::RelocInitializer::create(
getGlobalDeclByID(Index), Offset)); getGlobalDeclByID(Index), {Ice::RelocOffset::create(Ctx, Offset)}));
return; return;
} }
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment