diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-17 16:24:42 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-17 16:24:42 -0700 |
commit | 139165f35e841945b94685bdd91243f5b14d0a7a (patch) | |
tree | a3ebc050a54bee854a0e8170bc2abc8fc3511873 /lib/Analysis | |
parent | b1f3b6883c3b106c76088ae4d09e31c765a7667a (diff) |
PNaCl: Turn on ABI verifier by default in sandboxed translator
Change pnacl-llc.cpp to enable the verifier. This causes two problems
which we fix:
* The ABI check for declared-but-not-defined functions fails in
streaming mode. Fixing this would involve changing the bitcode
reader. For now, disable this check when in streaming mode. Add a
flag to PNaClABIVerifyModule.
* ARM's GlobalMerge pass modifies functions' global variable
references to use ConstantExprs that the ABI checker rejects.
Address this by disabling GlobalMerge for now.
GlobalMerge does not provide much benefit at the moment anyway,
because, with the FlattenGlobals pass applied, GlobalMerge doesn't
merge variables with alignment >1.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3465
TEST=PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/17190002
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index 675b62a974..3a422288d8 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -50,10 +50,12 @@ class PNaClABIVerifyModule : public ModulePass { ReporterIsOwned(true) { initializePNaClABIVerifyModulePass(*PassRegistry::getPassRegistry()); } - explicit PNaClABIVerifyModule(PNaClABIErrorReporter *Reporter_) : + explicit PNaClABIVerifyModule(PNaClABIErrorReporter *Reporter_, + bool StreamingMode) : ModulePass(ID), Reporter(Reporter_), - ReporterIsOwned(false) { + ReporterIsOwned(false), + StreamingMode(StreamingMode) { initializePNaClABIVerifyModulePass(*PassRegistry::getPassRegistry()); } ~PNaClABIVerifyModule() { @@ -69,6 +71,7 @@ class PNaClABIVerifyModule : public ModulePass { void checkGlobalIsFlattened(const GlobalVariable *GV); PNaClABIErrorReporter *Reporter; bool ReporterIsOwned; + bool StreamingMode; }; static const char *linkageName(GlobalValue::LinkageTypes LT) { @@ -392,7 +395,12 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { << PNaClABITypeChecker::getTypeName(MI->getFunctionType()) << "\n"; } - if (MI->isDeclaration()) { + // This check is disabled in streaming mode because it would + // reject a function that is defined but not read in yet. + // Unfortunately this means we simply don't check this property + // when translating a pexe in the browser. + // TODO(mseaborn): Enforce this property in the bitcode reader. + if (!StreamingMode && MI->isDeclaration()) { Reporter->addError() << "Function " << MI->getName() << " is declared but not defined (disallowed)\n"; } @@ -451,6 +459,6 @@ INITIALIZE_PASS(PNaClABIVerifyModule, "verify-pnaclabi-module", "Verify module for PNaCl", false, true) ModulePass *llvm::createPNaClABIVerifyModulePass( - PNaClABIErrorReporter *Reporter) { - return new PNaClABIVerifyModule(Reporter); + PNaClABIErrorReporter *Reporter, bool StreamingMode) { + return new PNaClABIVerifyModule(Reporter, StreamingMode); } |