aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/NaCl/PNaClABISimplify.cpp
AgeCommit message (Collapse)Author
2014-03-05Disable the ResolveAliases and GlobalCleanup passes.Dan Gohman
Also add a test for handling of global aliases.
2014-03-05Disable the LowerExpectIntrinsic pass.Dan Gohman
2014-03-05Don't run a pass to strip dead prototypes; just ignore them.Dan Gohman
Also, fix the code for supressing declarations for no-op intrinsics.
2014-03-05Clean up the handling of inline asm.Dan Gohman
Make inline asm a report_fatal_error instead of an assertion failure so that it's a little friendlier, and add a test to make sure llc -march=js rejects inline asm. Also disable the PNaCl inline asm("":::"memory") lowering pass. If people are using this, it's best that we diagnose it as it likely isn't portable. There are usually better alternatives.
2014-02-28Move ExpandI64 into lib/Target/JSBackend.Dan Gohman
2014-02-28Implement llvm.flt.rounds and disable the createRewriteLLVMIntrinsicsPass pass.Dan Gohman
2014-02-25Disable the RewritePNaClLibraryCalls pass, which isn't needed for Emscripten.Dan Gohman
2014-02-25Re-introduce ConstantExpr expansion for constants containing illegal types.Dan Gohman
2014-02-25Support GEP and ConstantExprs directly in the JSBackend.Dan Gohman
This patch also lays the groundwork for the single-use instruction trick to reduce the number of temporary variables.
2014-02-14typo fixAlon Zakai
2014-02-14Disable two PNaCl passes which the JSBackend no longer needs.Dan Gohman
2014-02-12Disable an unnecessary optimization pass.Dan Gohman
2014-02-12optimize reg/mem stuff around setjmp loweringAlon Zakai
2014-02-12do reg2mem/mem2reg around the setjmp pass, to ensure our cfg changes do not ↵Alon Zakai
break module validation through altering dominances
2014-01-27coordinate exception handling with setjmp - if exception handling code ↵Alon Zakai
generate a pre|postinvoke, use those for setjmp as well
2014-01-21support building projects with both setjmp and c++ exceptions, by avoiding ↵Alon Zakai
modifying setjmp|longjmp in the exceptions lowering code
2014-01-20get first setjmp test passingAlon Zakai
2014-01-20allow only setjmp or c++ exceptions in fastcomp for nowAlon Zakai
2014-01-19initial work on setjmp/longjmp for emscriptenAlon Zakai
2014-01-09exception handling supportAlon Zakai
2013-12-04begin to legalize i64 sextAlon Zakai
2013-11-29do not simplify varargs calls to jsargs emscripten intrinsics, that want ↵Alon Zakai
normal js args to be passed, and disable unneeded createExpandSmallArgumentsPass
2013-11-28do not run nacl atomics passes, we can leave them as-isAlon Zakai
2013-11-21do not expand tlsAlon Zakai
2013-11-21disable pnacl internalization of everything except for _start, as emscripten ↵Alon Zakai
supports arbitrary entry points
2013-10-29PNaCl: Add option to PNaClABISimplify for enabling the PNaClSjLjEH passMark Seaborn
Making this an 'enable' option (rather than using the pass name, "-pnacl-sjlj-eh") will allow us to reorder the passes within PNaClABISimplify.cpp later without having to change pnacl-ld.py (which lives outside the pnacl-llvm repo). It also means that the option can turn off LowerInvoke, which might reduce the link time a little. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3696 TEST=tested with PNaCl-side plumbing in pnacl-ld.py etc. Review URL: https://codereview.chromium.org/33743010
2013-08-14Correct DCE comment.JF Bastien
Follow-up to https://codereview.chromium.org/22710004/ R=eliben@chromium.org Review URL: https://codereview.chromium.org/23085007
2013-08-08Add simple dead code elimination at the end of post-opt.JF Bastien
This should slightly reduce the size of generate pexes without compromising ABI stability since the code in DCE.cpp is so simple. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3613 TEST= tryjobs R= kschimpf@chromium.org, eliben@chromium.org Review URL: https://codereview.chromium.org/22710004
2013-08-07Add the new @llvm.nacl.atomic.fence.all intrinsicJF Bastien
This is a follow-up to: https://codereview.chromium.org/22240002/ And requires the Clang changes from: https://codereview.chromium.org/22294002/ This new intrinsic represents ``asm("":::"~{memory}")`` as well as ``__sync_synchronize()``, and in IR it corresponds to a sequentially-consistent fence surrounded by ``call void asm sideeffect "", "~{memory}"()``. R=jvoung@chromium.org TEST= ninja check-all BUG= https://code.google.com/p/nativeclient/issues/detail?id=3475 Review URL: https://codereview.chromium.org/22474008
2013-07-30Rewrite ``asm("":::"memory")`` to ``fence seq_cst``JF Bastien
This is often used as a compiler barrier and should "just work" in user code. BUG= https://code.google.com/p/nativeclient/issues/detail?id=2345 R=eliben@chromium.org TEST= (cd ./pnacl/build/llvm_x86_64 && ninja check-all) Review URL: https://codereview.chromium.org/21178002
2013-07-13Concurrency support for PNaCl ABIJF Bastien
Add portable support for concurrency in PNaCl's ABI: - Promote volatile to atomic. - Promote all memory ordering to sequential consistency. - Rewrite all atomic operations to frozen NaCl intrinsics for pexe. - Rewrite atomic intrinsics to LLVM instructions for translation. This change also adds documentation to the PNaCl language reference, as well as tests where it makes sense. A future CL could clean up more of our code which mentions atomics, volatiles, memory orderings. Multiple reviewers because this is a big patch: - eliben: LLVM-fu and ResolvePNaClIntrinsics. - dschuff: ABI stability. - mseaborn: ABI stability. - sehr: Tron-duty (fight for the user's programs to work). BUG= https://code.google.com/p/nativeclient/issues/detail?id=3475 R=dschuff@chromium.org, eliben@chromium.org, sehr@google.com TEST= (cd ./pnacl/build/llvm_x86_64; ninja check-all) && ./pnacl/test.sh test-x86-32 && ./pnacl/test.sh test-x86-64 && ./pnacl/test.sh test-arm && ./pnacl/test.sh test-x86-32-sbtc && ./pnacl/test.sh test-x86-64-sbtc && ./pnacl/test.sh test-arm-sbtc Review URL: https://codereview.chromium.org/17777004
2013-07-01Internalize all symbols except _start.Eli Bendersky
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3532 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/18348008
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-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-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-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-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-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: 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-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-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
2013-05-29Revert "Enable integer promotion pass and enable ABI check for integer types."Mark Seaborn
This reverts commit dc58e24a36836fc19c534bdcbef5152717a3c3fc. That change broke the build of the sandboxed PNaCl translator. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3360 TEST=PNaCl toolchain trybots TBR=dschuff@chromium.org Review URL: https://codereview.chromium.org/15845009
2013-05-29Enable integer promotion pass and enable ABI check for integer types.Derek Schuff
R=mseaborn@chromium.org BUG= https://code.google.com/p/nativeclient/issues/detail?id=3360 Review URL: https://codereview.chromium.org/15950006
2013-05-28PNaCl: Extend ExpandMulWithOverflow pass to handle uadd.with.overflow tooMark Seaborn
It turned out that umul.with.overflow wasn't the only *.with.overflow intrinsic usage introduced by Clang. I knew that Clang's CGExprCXX.cpp generates umul.with.overflow for an overflow check for C++'s "new Foo[]". The same code for handling "new Foo[]" also generates uadd.with.overflow in some cases. This happens if class Foo has a destructor or a delete[] operator that takes a size argument. In those cases, the C++ ABI adds a "cookie" to the allocation which contains the array's size. Rename the pass to "ExpandArithWithOverflow" and rename files accordingly. Also enable the pass. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3434 TEST=*.ll tests + trybots + GCC torture tests Review URL: https://codereview.chromium.org/15688011
2013-05-28PNaCl: Enable the ReplacePtrsWithInts passMark Seaborn
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/15767004
2013-05-24PNaCl: Add "-pnacl-abi-simplify-{pre,post}opt" meta-passes to "opt"Mark Seaborn
These meta-passes will be used to replace the pass lists that are currently in the pnacl-ld.py driver script in the NaCl repo. I've moved the comments across from pnacl-ld.py and added a couple more comments for ExpandByVal and StripMetadata. Fix the declaration of createResolveAliasesPass(). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3435 TEST=new *.ll tests + tested with change to pnacl-ld.py Review URL: https://codereview.chromium.org/15669002