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

Unified Diff: src/llvm2ice.cpp

Issue 291213003: Subzero: Fix x86 floating-point constant emission (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: "Fix" static casting Created 6 years, 7 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
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | tests_lit/llvm2ice_tests/fpconst.pnacl.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/llvm2ice.cpp
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index 08f90f8132727f84c8f9b271275da01f04b62f39..e29637dea85e5aa54449088e57985a57263627d8 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -19,6 +19,7 @@
#include "IceGlobalContext.h"
#include "IceInst.h"
#include "IceOperand.h"
+#include "IceTargetLowering.h"
#include "IceTypes.h"
#include "llvm/IR/Constant.h"
@@ -63,6 +64,7 @@ public:
SubzeroPointerType = Ice::IceType_i32;
}
+ // Caller is expected to delete the returned Ice::Cfg object.
Ice::Cfg *convertFunction(const Function *F) {
VarMap.clear();
NodeMap.clear();
@@ -618,14 +620,11 @@ DisableTranslation("notranslate", cl::desc("Disable Subzero translation"));
static cl::opt<bool> SubzeroTimingEnabled(
"timing", cl::desc("Enable breakdown timing of Subzero translation"));
-static cl::opt<NaClFileFormat>
-InputFileFormat(
- "bitcode-format",
- cl::desc("Define format of input file:"),
- cl::values(
- clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"),
- clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
- clEnumValEnd),
+static cl::opt<NaClFileFormat> InputFileFormat(
+ "bitcode-format", cl::desc("Define format of input file:"),
+ cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"),
+ clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
+ clEnumValEnd),
cl::init(LLVMFormat));
int main(int argc, char **argv) {
@@ -670,6 +669,15 @@ int main(int argc, char **argv) {
raw_os_ostream *Ls = new raw_os_ostream(LogFilename == "-" ? std::cout : Lfs);
Ls->SetUnbuffered();
+ // Ideally, Func would be declared inside the loop and its object
+ // would be automatically deleted at the end of the loop iteration.
+ // However, emitting the constant pool requires a valid Cfg object,
+ // so we need to defer deleting the last non-empty Cfg object until
+ // outside the loop and after emitting the constant pool. TODO:
+ // Since all constants are globally pooled in the Ice::GlobalContext
+ // object, change all Ice::Constant related functions to use
+ // GlobalContext instead of Cfg, and then clean up this loop.
+ OwningPtr<Ice::Cfg> Func;
Ice::GlobalContext Ctx(Ls, Os, VMask, TargetArch, OptLevel, TestPrefix);
for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
@@ -678,7 +686,7 @@ int main(int argc, char **argv) {
LLVM2ICEConverter FunctionConverter(&Ctx);
Ice::Timer TConvert;
- Ice::Cfg *Func = FunctionConverter.convertFunction(I);
+ Func.reset(FunctionConverter.convertFunction(I));
if (DisableInternal)
Func->setInternal(false);
@@ -713,5 +721,8 @@ int main(int argc, char **argv) {
}
}
+ if (!DisableTranslation && Func)
+ Func->getTarget()->emitConstants();
+
return ExitStatus;
}
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | tests_lit/llvm2ice_tests/fpconst.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698