aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Transforms
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-06-25 07:57:02 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-06-25 07:57:02 -0700
commitd32f2f27e9bed303ce454ec48608204fba1e1194 (patch)
treebbcf1b66bea25bb80bebe741a3f5111ec92b4899 /include/llvm/Transforms
parent29faec27f780be4336e0f210e8dd96582c989d3a (diff)
PNaCl ABI: Disallow various operations on the i1 type
Disallow i1 on loads/stores and require the conversions to i8 to be explicit. Add a pass, PromoteI1Ops, that adds the conversions. (Load/store on i1 occur in practice in small_tests for some boolean globals.) Disallow i1 for most arithmetic/comparison operations since these aren't very useful and it's a nuisance for a code generator to have to support these. I haven't seen these occur in practice, but PromoteI1Ops nevertheless expands them. We still allow and/or/xor on i1 because these do occur in practice, and they're less of a nuisance to handle because they never overflow: no truncation to 1 bit is required, unlike with adds. Restrict the type of alloca's argument. Clang always uses i32 here. Disallow i1 in switch instructions. Clang doesn't generate i1 switches for booleans. Move CopyLoadOrStoreAttrs() helper into a header to reuse. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3490 TEST=PNaCl toolchain trybots + GCC torture tests + Spec2k Review URL: https://codereview.chromium.org/17356011
Diffstat (limited to 'include/llvm/Transforms')
-rw-r--r--include/llvm/Transforms/NaCl.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/llvm/Transforms/NaCl.h b/include/llvm/Transforms/NaCl.h
index 6924320cfe..2e2a7bc69d 100644
--- a/include/llvm/Transforms/NaCl.h
+++ b/include/llvm/Transforms/NaCl.h
@@ -35,6 +35,7 @@ ModulePass *createExpandTlsConstantExprPass();
ModulePass *createExpandVarArgsPass();
ModulePass *createFlattenGlobalsPass();
ModulePass *createGlobalCleanupPass();
+BasicBlockPass *createPromoteI1OpsPass();
FunctionPass *createPromoteIntegersPass();
ModulePass *createReplacePtrsWithIntsPass();
ModulePass *createResolveAliasesPass();
@@ -54,6 +55,14 @@ void PhiSafeReplaceUses(Use *U, Value *NewVal);
// Copy debug information from Original to NewInst, and return NewInst.
Instruction *CopyDebug(Instruction *NewInst, Instruction *Original);
+template <class InstType>
+static void CopyLoadOrStoreAttrs(InstType *Dest, InstType *Src) {
+ Dest->setVolatile(Src->isVolatile());
+ Dest->setAlignment(Src->getAlignment());
+ Dest->setOrdering(Src->getOrdering());
+ Dest->setSynchScope(Src->getSynchScope());
+}
+
// In order to change a function's type, the function must be
// recreated. RecreateFunction() recreates Func with type NewType.
// It copies or moves across everything except the argument values,