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,
const RelocOffsetT NodeNameDeclarationOffset = 0;
Var->addInitializer(VariableDeclaration::RelocInitializer::create(
NodeNameDeclaration, NodeNameDeclarationOffset));
NodeNameDeclaration,
{RelocOffset::create(Ctx, NodeNameDeclarationOffset)}));
Var->setAlignment(Int64ByteSize);
return Var;
}
......
......@@ -787,8 +787,8 @@ void LLVM2ICEGlobalsConverter::addGlobalInitializer(
assert(GV);
const Ice::GlobalDeclaration *Addr =
getConverter().getGlobalDeclaration(GV);
Global.addInitializer(
Ice::VariableDeclaration::RelocInitializer::create(Addr, Offset));
Global.addInitializer(Ice::VariableDeclaration::RelocInitializer::create(
Addr, {Ice::RelocOffset::create(Ctx, Offset)}));
return;
}
default:
......
......@@ -357,18 +357,6 @@ void GlobalContext::translateFunctions() {
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.
void resizePending(std::vector<EmitterWorkItem *> &Pending, uint32_t Index) {
if (Index >= Pending.size())
......@@ -394,6 +382,18 @@ void GlobalContext::lowerConstants() { DataLowering->lowerConstants(); }
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) {
TimerMarker T(TimerStack::TT_emitGlobalInitializers, this);
const bool DumpGlobalVariables =
......@@ -409,7 +409,7 @@ void GlobalContext::lowerGlobals(const IceString &SectionSuffix) {
if (Flags.getDisableTranslation())
return;
addBlockInfoPtrs(Globals, ProfileBlockInfoVarDecl);
addBlockInfoPtrs(ProfileBlockInfoVarDecl);
// If we need to shuffle the layout of global variables, shuffle them now.
if (getFlags().shouldReorderGlobalVariables()) {
// Create a random number generator for global variable reordering.
......
......@@ -538,6 +538,8 @@ private:
HasSeenCode = true;
}
void addBlockInfoPtrs(VariableDeclaration *ProfileBlockInfo);
llvm::SmallVector<ThreadContext *, 128> AllThreadContexts;
llvm::SmallVector<std::thread, 128> TranslationThreads;
llvm::SmallVector<std::thread, 128> EmitterThreads;
......
......@@ -230,6 +230,7 @@ void VariableDeclaration::RelocInitializer::dump(GlobalContext *Ctx,
Ostream &Stream) const {
if (!Ice::BuildDefs::dump())
return;
const RelocOffsetT Offset = getOffset();
if (Offset != 0) {
dumpType(Stream);
Stream << " add (";
......
......@@ -22,6 +22,7 @@
#include "IceDefs.h"
#include "IceGlobalContext.h"
#include "IceIntrinsics.h"
#include "IceOperand.h"
#include "IceTypes.h"
#ifdef __clang__
......@@ -318,11 +319,19 @@ public:
public:
static std::unique_ptr<RelocInitializer>
create(const GlobalDeclaration *Declaration, RelocOffsetT Offset) {
return makeUnique<RelocInitializer>(Declaration, Offset);
create(const GlobalDeclaration *Declaration,
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; }
SizeT getNumBytes() const final { return RelocAddrSize; }
void dump(GlobalContext *Ctx, Ostream &Stream) const final;
......@@ -334,13 +343,15 @@ public:
private:
ENABLE_MAKE_UNIQUE;
RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset)
: Initializer(RelocInitializerKind), Declaration(Declaration),
Offset(Offset) {} // The global declaration used in the relocation.
RelocInitializer(const GlobalDeclaration *Declaration,
const RelocOffsetArray &OffsetExpr)
: Initializer(RelocInitializerKind),
Declaration(Declaration), // The global declaration used in the reloc.
OffsetExpr(OffsetExpr) {}
const GlobalDeclaration *Declaration;
/// The offset to add to the relocation.
const RelocOffsetT Offset;
const RelocOffsetArray OffsetExpr;
};
/// Models the list of initializers.
......
......@@ -1211,9 +1211,10 @@ void GlobalsParser::ProcessRecord() {
Error(StrBuf.str());
}
}
Ice::GlobalContext *Ctx = getTranslator().getContext();
CurGlobalVar->addInitializer(
Ice::VariableDeclaration::RelocInitializer::create(
getGlobalDeclByID(Index), Offset));
getGlobalDeclByID(Index), {Ice::RelocOffset::create(Ctx, Offset)}));
return;
}
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