diff options
author | Derek Schuff <dschuff@chromium.org> | 2013-05-29 10:27:19 -0700 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2013-05-29 10:27:19 -0700 |
commit | dc58e24a36836fc19c534bdcbef5152717a3c3fc (patch) | |
tree | 343a9c7047b58bcffb5466acb7dc3f52a481f547 | |
parent | 8d01804c97533ed9006a65c11cade3c6b23d1c75 (diff) |
Enable integer promotion pass and enable ABI check for integer types.
R=mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3360
Review URL: https://codereview.chromium.org/15950006
-rw-r--r-- | lib/Analysis/NaCl/PNaClABITypeChecker.cpp | 14 | ||||
-rw-r--r-- | lib/Transforms/NaCl/PNaClABISimplify.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/NaCl/PromoteIntegers.cpp | 10 |
3 files changed, 15 insertions, 12 deletions
diff --git a/lib/Analysis/NaCl/PNaClABITypeChecker.cpp b/lib/Analysis/NaCl/PNaClABITypeChecker.cpp index 8501a4f9e2..5157747f2b 100644 --- a/lib/Analysis/NaCl/PNaClABITypeChecker.cpp +++ b/lib/Analysis/NaCl/PNaClABITypeChecker.cpp @@ -24,7 +24,7 @@ bool PNaClABITypeChecker::isValidType(const Type *Ty) { if (VisitedTypes.count(Ty)) return VisitedTypes[Ty]; - // unsigned Width; + unsigned Width; bool Valid = false; switch (Ty->getTypeID()) { // Allowed primitive types @@ -48,15 +48,9 @@ bool PNaClABITypeChecker::isValidType(const Type *Ty) { Valid = false; break; case Type::IntegerTyID: - // The check for integer sizes below currently does not pass on - // all NaCl tests because some LLVM passes introduce unusual - // integer sizes. - // TODO(mseaborn): Re-enable the check when it passes. - // See https://code.google.com/p/nativeclient/issues/detail?id=3360 - Valid = true; - // Width = cast<const IntegerType>(Ty)->getBitWidth(); - // Valid = (Width == 1 || Width == 8 || Width == 16 || - // Width == 32 || Width == 64); + Width = cast<const IntegerType>(Ty)->getBitWidth(); + Valid = (Width == 1 || Width == 8 || Width == 16 || + Width == 32 || Width == 64); break; case Type::FunctionTyID: case Type::StructTyID: diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp index 47e5fb67e6..71f0f23000 100644 --- a/lib/Transforms/NaCl/PNaClABISimplify.cpp +++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp @@ -60,6 +60,9 @@ void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) { // We should not place arbitrary passes after ExpandConstantExpr // because they might reintroduce ConstantExprs. PM.add(createExpandConstantExprPass()); + // PromoteIntegersPass does not handle constexprs and creates GEPs, + // so it goes between those passes. + PM.add(createPromoteIntegersPass()); // ExpandGetElementPtr must follow ExpandConstantExpr to expand the // getelementptr instructions it creates. PM.add(createExpandGetElementPtrPass()); diff --git a/lib/Transforms/NaCl/PromoteIntegers.cpp b/lib/Transforms/NaCl/PromoteIntegers.cpp index fcb9b2e607..37805f8d30 100644 --- a/lib/Transforms/NaCl/PromoteIntegers.cpp +++ b/lib/Transforms/NaCl/PromoteIntegers.cpp @@ -34,6 +34,7 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/Pass.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Transforms/NaCl.h" using namespace llvm; @@ -53,11 +54,12 @@ INITIALIZE_PASS(PromoteIntegers, "nacl-promote-ints", "Promote integer types which are illegal in PNaCl", false, false) - // Legal sizes are currently 1, 8, 16, 32, and 64. // We can't yet expand types above 64 bit, so don't try to touch them for now. +// TODO(dschuff): expand >64bit types or disallow >64bit packed bitfields. +// There are currently none in our tests that use the ABI checker. +// See https://code.google.com/p/nativeclient/issues/detail?id=3360 static bool isLegalSize(unsigned Size) { - // TODO(dschuff): expand >64bit types or disallow >64bit packed bitfields if (Size > 64) return true; return Size == 1 || Size == 8 || Size == 16 || Size == 32 || Size == 64; } @@ -612,3 +614,7 @@ bool PromoteIntegers::runOnFunction(Function &F) { State.eraseReplacedInstructions(); return Modified; } + +FunctionPass* llvm::createPromoteIntegersPass() { + return new PromoteIntegers(); +} |