aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2013-05-30 12:27:02 -0700
committerDerek Schuff <dschuff@chromium.org>2013-05-30 12:27:02 -0700
commit663c1c948321264aceb07b86cfadcd06b3386e1e (patch)
treebfb6b164a026dbcc39e493ac9558038ec4f26cbd /lib
parent5f406495406e92cddd44d3f9aa477e72dca5f37e (diff)
Enable integer promotion pass and add ABI check for integer types
This is a reapply of dc58e24a with one cleanup of a commented-out line in PromoteIntegers.cpp R=mseaborn@chromium.org BUG= https://code.google.com/p/nativeclient/issues/detail?id=3360 Review URL: https://codereview.chromium.org/16015003
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/NaCl/PNaClABITypeChecker.cpp14
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp3
-rw-r--r--lib/Transforms/NaCl/PromoteIntegers.cpp11
3 files changed, 15 insertions, 13 deletions
diff --git a/lib/Analysis/NaCl/PNaClABITypeChecker.cpp b/lib/Analysis/NaCl/PNaClABITypeChecker.cpp
index 064f7862b1..7e8c269717 100644
--- a/lib/Analysis/NaCl/PNaClABITypeChecker.cpp
+++ b/lib/Analysis/NaCl/PNaClABITypeChecker.cpp
@@ -51,7 +51,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
@@ -75,15 +75,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:
Valid = isValidFunctionType(cast<FunctionType>(Ty));
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index 3c59546275..848d340e22 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -66,6 +66,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 8749cdf2e5..017e4976f2 100644
--- a/lib/Transforms/NaCl/PromoteIntegers.cpp
+++ b/lib/Transforms/NaCl/PromoteIntegers.cpp
@@ -36,6 +36,7 @@
#include "llvm/Support/IntegersSubset.h"
#include "llvm/Support/IntegersSubsetMapping.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/NaCl.h"
using namespace llvm;
@@ -55,11 +56,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;
}
@@ -607,7 +609,6 @@ static void convertInstruction(Instruction *Inst, ConversionState &State) {
NewInst->addCase(Case, I.getCaseSuccessor());
}
Switch->eraseFromParent();
- //State.recordConverted(Switch, NewInst);
} else {
errs() << *Inst<<"\n";
llvm_unreachable("unhandled instruction");
@@ -646,3 +647,7 @@ bool PromoteIntegers::runOnFunction(Function &F) {
State.eraseReplacedInstructions();
return Modified;
}
+
+FunctionPass *llvm::createPromoteIntegersPass() {
+ return new PromoteIntegers();
+}