aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2013-06-29PNaCl ABI: Remove use of @llvm.memset.p0i8.i64 (64-bit intrinsic variant)Mark Seaborn
Convert calls to this intrinsic to use the 32-bit variant instead. Do the same for the memcpy and memmove intrinsics too. Change the PNaCl ABI verifier to check this argument. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3530 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/18226003
2013-06-26PNaCl wire format: Use FORWARDTYPEREF consistently for all forward referencesMark Seaborn
Before this change, the writer would only emit FORWARDTYPEREF for some operands, e.g. the first operand of BINOP but not the second, on the grounds that the type of the second operand can be inferred. However, that makes the format complicated. Change the writer so that it always emits FORWARDTYPEREF for a forward ref. This unifies PushValueAndType() and pushValue(). pushValue() gains a call to EmitFnForwardTypeRef() so becomes the same as PushValueAndType(). Change the reader to be stricter, so that it requires a FORWARDTYPEREF to have been emitted in most cases. This is done by ignoring the implied type argument. Tasks still remaining: * Make reader stricter so that multiple FORWARDTYPEREFs are disallowed. * Remove now-unused Type arguments in the reader. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=new llvm-lit test + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17806003
2013-06-26PNaCl wire format: Clean up representation of "alloca" instructionMark Seaborn
For some reason, the size operand of "alloca" was represented using an absolute value ID + type, unlike other instructions where relative value IDs are used. Change the "alloca" representation to be consistent with other instructions, so that we can use PushValueAndType() in the writer and getValue() in the reader. Also take this opportunity to remove the field for alloca's result type, since it's always i8* in PNaCl. This is part of a cleanup to make forward reference handling stricter: it removes a use of getOrCreateFnValueByID(), which isn't strict (that is, it doesn't reject duplicate FORWARDTYPEREF records). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17757004
2013-06-25Support for mem* library functions in stable bitcode via intrinsics.Eli Bendersky
* Don't preserve external linking for mem{cpy,move,cmp} during LTO. * In the RewritePNaClLibraryCalls pass - add rewriting of mem* calls to appropriate intrinsics, similarly to the way it was done for longjmp. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3493 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/17622003
2013-06-25PNaCl wire format: Remove the top-level DATALAYOUT recordMark Seaborn
PNaCl only supports a fixed data layout, so treat this as implicit in the pexe file. Add the data layout field back at read time, to prevent accidentally using any architecture-specific backend data layout when translating, and to ensure that any IR passes that use the data layout work correctly. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3505 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17591014
2013-06-25PNaCl: Fix ExpandStructRegs to handle "select" instructionsMark Seaborn
The code is similar to the case for handling phi nodes. It turns out that "select" on struct values can occur in practice with use of C++ method pointers. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3514 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17706002
2013-06-25Revert "Apply upstream r183551, r183601, r183624 and r183794"Jan Voung
Revert this until we fix i1 sext. Currently, it uses LSL and ASR, which are pseudo-instructions and get dropped on the floor when generating .o files. We'll fix that, but for now revert to green the bots. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3501 R=jfb@chromium.org Review URL: https://codereview.chromium.org/17715002
2013-06-25PNaCl: Fix removal of dead function prototypes in ABI simplificationMark Seaborn
The use of StripDeadPrototypes in PNaClABISimplify.cpp wasn't always having an effect: it doesn't work if there are dead constant references remaining to a function declaration. ReplacePtrsWithInts was leaving some of these references behind, so fix it. BUG=none TEST=llvm-lit tests Review URL: https://codereview.chromium.org/17636006
2013-06-25PNaCl ABI: Disallow various operations on the i1 typeMark Seaborn
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
2013-06-24PNaCl ABI: Strip alignment info from memcpy/memmove/memset intrinsic callsMark Seaborn
Do the same for memcpy/memmove/memset intrinsic calls that we have already done for integer loads and stores: Remove assumptions about pointer alignment by setting the alignment argument to 1. Make the ABI checker require this. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3445 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17563008
2013-06-24PNaCl ABI: Disallow built-in multiplication in "alloca" instructionsMark Seaborn
Simplify the set of "alloca" instructions the ABI verifier allows. Before this change, we used i8 arrays, such as: alloca [8 x i8] After this change, we will just use i8 with an explicit size value, so that becomes: alloca i8, i32 8 Allocation of variable-length arrays will require an explicit multiply instruction. This means that the code generator no longer has to handle an implicit multiplication in "alloca", reducing the burden on fast-and-simple code generators a little. This means the PNaCl ABI doesn't need to specify whether alloca's implicit multiplication checks for overflow. This doesn't affect what the backend generates. See lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp, which handles constant-size AllocaInsts (by filling out StaticAllocaMap) and which is uses for both -O2 (SelectionDAG) and -O0 (FastISel) translation. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17631004
2013-06-24Move i32/i64 cttz, ctlz, and ctpop to whitelisted intrinsics.Jan Voung
Disallow the other input types. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3378 R=jfb@chromium.org Review URL: https://codereview.chromium.org/17613002
2013-06-24Merge r179774: Allow misaligned stores in x86 fast-isel.Mark Seaborn
This change will fix the regression in -O0 translation time caused by putting "align 1" on integer loads and stores, which was causing FastISel to fall back to SelectionDAG more often. > In X86FastISel::X86SelectStore(), improperly aligned stores are > rejected and handled by the DAG-based ISel. However, > X86FastISel::X86SelectLoad() makes no such requirement. There > doesn't appear to be an x86 architectural correctness issue with > allowing potentially unaligned store instructions. This patch > removes this restriction. > > Patch by Jim Stichnot. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3445 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17575003
2013-06-20PNaCl ABI: Reduce the set of allowed "align" attributes on loads/storesMark Seaborn
Change the ABI verifier to require "align 1" on non-atomic integer accesses to prevent non-portable behaviour. Allow larger alignments on floating point accesses as a concession to performance, because ARM might not be able to do unaligned FP loads/stores efficiently. Change StripAttributes to make pexes pass the ABI verifier. Also update comments in StripAttributes to match some recent changes. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3445 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17094009
2013-06-19PNaCl ABI: Disallow the "externally_initialized" attribute of GlobalVariablesMark Seaborn
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3415 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17470005
2013-06-19Rewrite llvm.flt.rounds to "1" for now, and disallow llvm.flt.rounds.Jan Voung
Until there is an intrinsic to *set* the rounding mode, this intrinsic to *get* the rounding mode isn't so useful. Separately we will add a test that for each platform, the initial rounding mode is "1" (round to nearest). That is the case right now for x86, ARM, and MIPS. (see https://codereview.chromium.org/16785003/) BUG=https://code.google.com/p/nativeclient/issues/detail?id=3491 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/17229007
2013-06-16PNaCl ABI: Disallow non-default symbol visibility ("hidden" and "protected")Mark Seaborn
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3495 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16903003
2013-06-14PNaCl ABI: Disallow the "available_externally" linkage typeMark Seaborn
"define available_externally void @foo()" would mean that the definition of foo() can be dropped from the pexe, because a definition of foo() can be found in an external native library. This is not something we support for a PNaCl pexe. Clang generates "available_externally" for non-static inline function definitions at -O1, but not at -O0, and generally not at -O2 either because inlining removes the "available_externally" definition. "available_externally" gets removed at bitcode link time, so we can disallow it in the ABI checker without any further work required. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3495 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17035015
2013-06-14PNaCl ABI: Convert "private" linkage to "internal"Mark Seaborn
This simplifies the ABI by reducing the number of linkage types we have to check for and represent in the wire format. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3495 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17084003
2013-06-13Fix PrologEpilogInserter to save and restore all callee saved registersDerek Schuff
if the function calls _builtin_unwind_init() Also fix the list of callee-saved registers returned by X86RegisterInfo::getCalleeSavedRegisters BUG= https://code.google.com/p/nativeclient/issues/detail?id=3486 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/16987002
2013-06-13PNaCl: Strip more unwanted attributes: "align" on functions and "unnamed_addr"Mark Seaborn
Do this stripping in the StripAttributes pass. Change the pass to be a ModulePass so that it can modify global variables. Change the ABI verifier to check this. Also update a comment about "nuw" and "nsw". BUG=https://code.google.com/p/nativeclient/issues/detail?id=3415 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16991002
2013-06-12Move llvm.expect from dev to blacklist. Convert with -lower-expect.Jan Voung
The backend currently treats llvm.expect as a nop pass-through. Until it becomes more useful, we don't need it in stable bitcode. It sounds like the backend may prefer to use the !prof metadata instead. The -lower-expect pass will convert it into branch weights, which can be consumed by the middle end optimizer's block placement pass. It is already converted to !prof metadata when clang is run with -O2, but not when clang is run at -O0. Also move the llvm.frameaddress from the dev part of the intrinsics test to the disallowed part of the test. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3378 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/16882002
2013-06-12PNaCl ABI: Strip out arithmetic attributes "nsw", "nuw" and "exact"Mark Seaborn
"nsw" and "nuw" -- "no signed wrap" and "no unsigned wrap" -- are not used by the backend, which is not surprising because it makes no difference to the hardware if arithmetic overflows. Although "exact" is used by the backend to convert "sdiv exact" to an "ashr" shift, it appears that "sdiv exact" does not get used in practice, and arguably such a transformation belongs in the user toolchain, not the PNaCl translator. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3483 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16746005
2013-06-11Apply upstream r183551, r183601, r183624 and r183794JF Bastien
Rename countTrailingZeros to the older CountTrailingZeros_32, mark as localmod. These patches fix correctness issues with ARM FastISel, and should make it faster while generating better code. BUG= none TEST= self R=jvoung@chromium.org Review URL: https://codereview.chromium.org/16712002
2013-06-10Change NaCl-specific tests from llc to pnacl-llcEli Bendersky
BUG=None R=dschuff@chromium.org Review URL: https://codereview.chromium.org/16273014
2013-06-10PNaCl: Extend ExpandStructRegs to handle "insertvalue" instructionsMark Seaborn
Previously, the pass could expand out struct_load+extractvalue combinations (via ReplaceUsesOfStructWithFields()). This change makes the pass more general by converting struct_loads to scalar_load+insertvalue combinations and then by expanding out insertvalue+extractvalue combinations. This means the pass can now handle the insertvalue instructions that are sometimes generated by the SROA pass. (Clang compiles ScummVM's use of C++ method pointers to struct loads+stores which SROA generates insertvalue instructions from.) To make the pass more general, we also extend it to be able to handle phi nodes of struct type. These are split into extractvalue+scalar_phi+insertvalue combinations. However, the pass is not yet fully general, because it doesn't handle: * nested struct types * array types Change ExpandArithWithOverflow to rely on ExpandStructRegs' insertvalue handling rather than the less general ReplaceUsesOfStructWithFields() helper function, which can now be removed. SplitUpStore() no longer needs to handle Constants, because this case is handled by ExpandExtractValue(). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3476 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16448006
2013-06-06PNaCl ABI: Strip out calling conventions from functions and callsMark Seaborn
Always use the standard C calling conventions. Disallow "fastcc" etc. BUG=https://code.google.com/p/nativeclient/issues/detail?id=2346 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16529004
2013-06-05PNaCl ABI: Strip out attributes on functions and function callsMark Seaborn
Add a pass, StripAttributes, for doing this, and enable it. Add an ABI check to reject these attributes. BUG=https://code.google.com/p/nativeclient/issues/detail?id=2346 BUG=https://code.google.com/p/nativeclient/issues/detail?id=3415 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16325025
2013-06-04PNaCl ABI checker: Reject functions that are declared but not definedMark Seaborn
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3339 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16270007
2013-06-04PNaCl: Enable RewritePNaClLibraryCalls and fix it to remove unused declsMark Seaborn
Removing the unused declarations of setjmp()/longjmp() will be necessary for future ABI checks which will reject these external function declarations because they are not intrinsics. StripDeadPrototypes is supposed to remove these declarations, but it fails to do so because there are dead ConstantExprs referencing the declarations. I suspect these are left behind by ReplacePtrsWithInts. We could fix this by adding calls to removeDeadConstantUsers() to StripDeadPrototypes or to ReplacePtrsWithInts, but for now it seems cleaner to fix RewritePNaClLibraryCalls. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3429 TEST=*.ll tests + tested along with an ABI check Review URL: https://codereview.chromium.org/15931009
2013-06-04PNaCl ABI checker: Reject the "addrspace" attributeMark Seaborn
It doesn't appear to be possible to set the address space on a Function, but we can still put the check in checkGlobalValueCommon() in case this changes in the future. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests Review URL: https://codereview.chromium.org/15993019
2013-06-04PNaCl ABI checker: Check for normal form introduced by ReplacePtrsWithIntsMark Seaborn
Move most of the per-instruction checking in PNaClABIVerifyFunctions::runOnFunction() to a top-level function so that it can do an early exit to reject the instruction. Reporting just a single error per instruction makes the test expectations easier to understand and update. Remove the check for metadata types. Metadata won't be part of PNaCl's stable ABI, so if the metadata-rejecting check is disabled for debugging purpose, we don't really need to recursively check the metadata's types. This lets us remove the recursive checks of Constants and types. We now only accept a very restricted, non-recursive set of Constants inside functions and global variable initialisers. This means PNaClABITypeChecker doesn't need to be stateful any more, and its methods can become static. This change also fixes a hole where the operands of "switch" instructions weren't fully checked. Add a test to replace-ptrs-with-ints.ll to ensure that "undef" doesn't appear directly in loads and stores. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=PNaCl toolchain trybots + GCC torture tests + LLVM test suite Review URL: https://codereview.chromium.org/15780014
2013-06-04Merging r183035:Bill Wendling
------------------------------------------------------------------------ r183035 | arnolds | 2013-05-31 12:53:50 -0700 (Fri, 31 May 2013) | 7 lines LoopVectorize: PHIs with only outside users should prevent vectorization We check that instructions in the loop don't have outside users (except if they are reduction values). Unfortunately, we skipped this check for if-convertable PHIs. Fixes PR16184. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@183189 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-03PNaCl gep expansion: avoid mul by 1 for i8 arrays.Jan Voung
Makes the bitcode a tiny bit smaller, and avoids generating shift left by 0 code under fast-isel. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/15861029
2013-06-03PNaCl ABI checker: Disallow ExtractValue and InsertValue instructions (2nd try)Mark Seaborn
Uses of these are removed by ExpandMulWithOverflow and ExpandStructRegs. This change was previously committed but reverted because it broke a varargs function call in 255.vortex in Spec2k. This has since been fixed by changing ExpandVarArgs. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=PNaCl toolchain trybots + all the Spec2k tests this time around Review URL: https://codereview.chromium.org/16336012
2013-06-03PNaCl: Fix ReplacePtrsWithInts so that ptrtoint always casts to i32Mark Seaborn
The normal form introduced by ReplacePtrsWithInts (as documented in the comments) is intended to have the property that ptrtoint and inttoptr only convert to/from i32, not other size types. Using IRBuilder's CreateZExtOrTrunc() broke that, though, because it performs some constant folding on global variable references. Fix this by creating CastInsts directly. I found this via the ABI checks I've been writing, which gave this error when building the sandboxed translator: non-i32 ptrtoint: %expanded1 = ptrtoint void ()* @ARMCompilationCallback to i8 LLVM ERROR: PNaCl ABI verification failed BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests + tested full PNaCl build with ABI checks applied too Review URL: https://codereview.chromium.org/15955012
2013-06-03PNaCl: ExpandVarArgs: Use memcpy() instead of struct load+store for struct argsMark Seaborn
Although PNaCl doesn't fully support struct types as varargs arguments, there is a test in Spec2k (255.vortex) that passes a struct as a varargs argument but never reads the argument using va_arg (which is legal, but strange). ExpandVarArgs was handling the struct argument by copying it with a struct load+store. This is undesirable because currently SROA converts that into code that uses extractvalue, which was rejected by the PNaCl ABI checker. Struct load/store will soon be rejected by the ABI checker too. We could fix this by running ExpandStructRegs after ExpandVarArgs, but it's cleaner for ExpandVarArgs to use memcpy() instead of struct load+store. memcpy() is potentially more efficient because it avoids having a temporary copy of the struct, and using memcpy() avoids dependencies between IR passes. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3338 BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests + built 255.vortex from Spec2k Review URL: https://codereview.chromium.org/16232021
2013-06-02Revert "PNaCl ABI checker: Disallow ExtractValue and InsertValue instructions"JF Bastien
This reverts commit 99c2f236a1a09b6c550e91b71dabbbb0e634ea37. It broken 255.vortex. See https://codereview.chromium.org/16257002/ TBR= mseaborn@chromium.org, jvoung@chromium.org Review URL: https://codereview.chromium.org/15888014
2013-06-01Merge 183060: Prevent loop-unroll from making assumptions about undefined ↵Andrew Trick
behavior. Fixes rdar:14036816, PR16130. There is an opportunity to compute precise trip counts for 'or' expressions and multi-exit loops. rdar:14038809: Optimize trip count computation for multi-exit loops. To do this we need to record the fact that ExitLimit assumes NSW. When it does not we can safely assume that the loop trip count is the minimum ExitLimt across all subexpressions and loop exits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183060 91177308-0d34-0410-b5e6-96231b3b80d8 git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@183066 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-31Apply LLVM upstream: r182877 - Enable FastISel on ARM for Linux and NaClJF Bastien
This also pulls in a TargetMachine.h change from r176986 and changes NaCl's intrinsics-bitmanip.ll test to account for register spills at O0. FastISel was only enabled for iOS ARM and Thumb2, this patch enables it for ARM (not Thumb2) on Linux and NaCl. Thumb2 support needs a bit more work, mainly around register class restrictions. The patch punts to SelectionDAG when doing TLS relocation on non-Darwin targets. I will fix this and other FastISel-to-SelectionDAG failures in a separate patch. The patch also forces FastISel to retain frame pointers: iOS always keeps them for backtracking (so emitted code won't change because of this), but Linux was getting much worse code that was incorrect when using big frames (such as test-suite's lencod). I'll also fix this in a later patch, it will probably require a peephole so that FastISel doesn't rematerialize frame pointers back-to-back. The test changes are straightforward, similar to: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130513/174279.html They also add a vararg test that got dropped in that change. I ran all of test-suite on A15 hardware with --optimize-option=-O0 and all the tests pass. R=dschuff@chromium.org, jvoung@chromium.org BUG= https://code.google.com/p/nativeclient/issues/detail?id=3120 Review URL: https://codereview.chromium.org/15671004
2013-05-31PNaCl ABI checker: Require global variable initialisers to be flattenedMark Seaborn
Check for the normal form produced by FlattenGlobals. We also require that all GlobalVariables have initialisers. External globals are not allowed. Note that we don't need to call TC.isValidType() on GlobalVariables any more: the new check is stricter. Update types.ll: * Split some checks into separate files for clarity. Otherwise the ordering of aliases/functions/globals/metadata gets tricky. * Convert a lot of the type-whitelisting tests to test via phi nodes rather than via global variables, since most of these types are now rejected for global variables. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3113 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/15914017
2013-05-31PNaCl: FlattenGlobals: Use ptrtoint+add instead of getelementptr+bitcastMark Seaborn
The constructor for getelementptr ConstantExprs does some constant folding which can add 1 or 2 more indexes to the getelementptr. This complicates checking for FlattenGlobals' normal form in the PNaCl ABI checker. Worse, the GCC torture tests turned up a pathological case where this constant folding adds 4 indexes to the getelementptr and leaves the original struct type behind: @q = global i8* getelementptr inbounds ( %union.u* bitcast ([260 x i8]* @v to %union.u*), i32 0, i32 0, i32 0, i32 0, i32 4) That comes from the following code in gcc/testsuite/gcc.c-torture/execute/pr43784.c: struct s { unsigned char a[256]; }; union u { struct { struct s b; int c; } d; struct { int c; struct s b; } e; }; static union u v; static struct s *q = &v.e.b; We can fix this by using ptrtoint+add instead of getelementptr+bitcast, because ConstantExpr won't automatically convert ptrtoint to something else. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3113 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/15647009
2013-05-31PNaCl: Remove and disallow llvm.invariant.start/end intrinsicsMark Seaborn
These markers work in a similar way to llvm.lifetime.start/end, so we should remove them for similar reasons: it's not very well defined how one marker cancels out the effects of the other. Arguably, invariant.start/end are less useful than lifetime.start/end. They are ignored by the backend. They are generated in fewer places: invariant.start is generated by Clang (at -O1 or higher) when a const global is initialised with a non-POD initialiser. invariant.end is apparently not generated at all. Do the stripping in ReplacePtrsWithInts for consistency with the existing lifetime.start/end stripping. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3443 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/15995004
2013-05-31PNaCl ABI checker: Disallow ExtractValue and InsertValue instructionsMark Seaborn
Uses of these are removed by ExpandMulWithOverflow and ExpandStructRegs. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/15995005
2013-05-30PNaCl ABI checker: Disallow llvm.lifetime.start/end intrinsicsMark Seaborn
Run StripDeadPrototypes as a final pass to ensure that the prototypes for lifetime.start/end are removed. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3443 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16063005
2013-05-30PNaCl: Add a pass to expand out Clang's use of registers of struct typeMark Seaborn
Clang's implementation of C++ method pointers generates IR that uses LLVM registers with struct type -- specifically, loads and stores of struct values, and extractvalue instructions. See lib/CodeGen/ItaniumCXXABI.cpp in Clang. Add a pass, ExpandStructRegs, which expands out those uses. Factor out a function from ExpandArithWithOverflow so that the two passes can share some code. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests + trybots + GCC torture tests Review URL: https://codereview.chromium.org/15692014
2013-05-30Enable integer promotion pass and add ABI check for integer typesDerek Schuff
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
2013-05-30Add switch support to integer promotion passDerek Schuff
Odd-sized switch statements can appear in the sandboxed translator build. R=mseaborn@chromium.org BUG= https://code.google.com/p/nativeclient/issues/detail?id=3360 Review URL: https://codereview.chromium.org/15894006
2013-05-29PNaCl ABI checker: Reject integer arguments smaller than i32Mark Seaborn
We can simplify the varargs checks by doing the checking on the FunctionType rather than having separate checks for the Function and the CallInst. (We couldn't do that prior to enabling ReplacePtrsWithInts because at that point the IR contained bitcasts to and from varargs FunctionTypes.) That simplification means we can also add the check for argument/return types in a single place too. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3342 TEST=*.ll tests + PNaCl toolchain trybots + GCC torture tests + LLVM test suite Review URL: https://codereview.chromium.org/15899011
2013-05-29PNaCl: Add ExpandSmallArguments pass to widen parameters to 32 bitsMark Seaborn
This widens i1, i8 and i16 function arguments and return types. Factor out RecreateFunction() helper function from existing PNaCl passes since this is a reoccurring code fragment. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3342 TEST=*.ll tests + PNaCl toolchain trybots + GCC torture tests + LLVM test suite Review URL: https://codereview.chromium.org/15971007