Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: src/IceGlobalContext.h

Issue 1179313004: Fix a bug that would cause subzero to fail when --threads=0. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses code review comments. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index 763a75b487ced3554f3bf53127106f792eabdf31..ccfa927c5b0bb9f041c23855697aca7c750fdafd 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -303,6 +303,8 @@ public:
// Emit file header for output file.
void emitFileHeader();
+ void lowerConstants();
+
void emitQueueBlockingPush(EmitterWorkItem *Item);
EmitterWorkItem *emitQueueBlockingPop();
void emitQueueNotifyEnd() { EmitQ.notifyEnd(); }
@@ -380,6 +382,13 @@ public:
// until the queue is empty.
void emitItems();
+ // Uses DataLowering to lower Globals. As a side effect, clears the Globals
+ // array.
+ void lowerGlobals(const IceString &SectionSuffix);
+
+ // Lowers the profile information.
+ void lowerProfileData();
+
// Utility function to match a symbol name against a match string.
// This is used in a few cases where we want to take some action on
// a particular function or symbol based on a command-line argument,
@@ -435,6 +444,14 @@ private:
std::unique_ptr<ELFObjectWriter> ObjectWriter;
BoundedProducerConsumerQueue<Cfg> OptQ;
BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ;
+ // DataLowering is only ever used by a single thread at a time (either in
+ // emitItems(), or in IceCompiler::run before the compilation is over.)
+ std::unique_ptr<TargetDataLowering> DataLowering;
+ // If !HasEmittedCode, SubZero will accumulate all Globals (which are "true"
+ // program global variables) until the first code WorkItem is seen.
+ bool HasSeenCode;
+ VariableDeclarationList Globals;
+ std::unique_ptr<VariableDeclaration> ProfileBlockInfoVarDecl;
LockedPtr<ArenaAllocator<>> getAllocator() {
return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock);
@@ -449,6 +466,19 @@ private:
return LockedPtr<TimerList>(&Timers, &TimerLock);
}
+ void accumulateGlobals(std::unique_ptr<VariableDeclarationList> Globls) {
+ if (Globls != nullptr)
+ Globals.insert(Globals.end(), Globls->begin(), Globls->end());
+ }
+
+ void lowerGlobalsIfNoCodeHasBeenSeen() {
+ if (HasSeenCode)
+ return;
+ constexpr char NoSuffix[] = "";
+ lowerGlobals(NoSuffix);
+ HasSeenCode = true;
+ }
+
llvm::SmallVector<ThreadContext *, 128> AllThreadContexts;
llvm::SmallVector<std::thread, 128> TranslationThreads;
llvm::SmallVector<std::thread, 128> EmitterThreads;

Powered by Google App Engine
This is Rietveld 408576698