summaryrefslogtreecommitdiff
path: root/test/CodeGen/WebAssembly
AgeCommit message (Collapse)Author
2017-12-15[WebAssembly] Implement @llvm.global_ctors and @llvm.global_dtorsSam Clegg
Summary: - lowers @llvm.global_dtors by adding @llvm.global_ctors functions which register the destructors with `__cxa_atexit`. - impements @llvm.global_ctors with wasm start functions and linker metadata See [here](https://github.com/WebAssembly/tool-conventions/issues/25) for more background. Subscribers: jfb, dschuff, mgorny, jgravelle-google, aheejin, sunfish Differential Revision: https://reviews.llvm.org/D41211 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320774 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08[WebAssembly] Reapply r319186: "Support bitcasted function addresses with ↵Dan Gohman
varargs." This puts the functionality under control of a command-line option which is off by default to avoid breaking existing setups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320197 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08[WebAssemby] Re-apply r320041: "Support main functions with alternate ↵Dan Gohman
signatures." This includes a fix so that it doesn't transform declarations, and it puts the functionality under control of a command-line option which is off by default to avoid breaking existing setups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320196 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08Revert "[WebAssemby] Support main functions with alternate signatures."Derek Schuff
This reverts commit 959e37e669b0c3cfad4cb9f1f7c9261ce9f5e9ae. That commit doesn't handle the case where main is declared rather than defined, in particular the even-more special case where main is a prototypeless declaration (which is of course the one actually used by musl currently). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320121 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-07[WebAssemby] Support main functions with alternate signatures.Dan Gohman
WebAssembly requires caller and callee signatures to match, so the usual C runtime trick of calling main and having it just work regardless of whether main is defined as '()' or '(int argc, char *argv[])' doesn't work. Extend the FixFunctionBitcasts pass to rewrite main to use the latter form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320041 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-07[WebAssembly] Don't try to emit size information for unsized typesDan Gohman
Patch by John Sully! Fixes PR35164. Differential Revision: https://reviews.llvm.org/D39519 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319991 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-06[WebAssembly] Remove WASM_STACK_POINTER.Dan Gohman
WASM_STACK_POINTER and the .stack_pointer directive are no longer needed now that the stack pointer global is an import. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319956 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05[WebAssembly] Implement WASM_STACK_POINTER.Dan Gohman
Use the .stack_pointer directive to implement WASM_STACK_POINTER for specifying a global variable to be the stack pointer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319797 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05[WebAssembly] Don't emit .import_global for the wasm target.Dan Gohman
.import_global is used by the ELF-based target and not needed by the wasm target. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319796 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-04[CodeGen] Unify MBB reference format in both MIR and debug outputFrancis Visoiu Mistrih
As part of the unification of the debug format and the MIR format, print MBB references as '%bb.5'. The MIR printer prints the IR name of a MBB only for block definitions. * find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#" << ([a-zA-Z0-9_]+)->getNumber\(\)/" << printMBBReference(*\1)/g' * find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#" << ([a-zA-Z0-9_]+)\.getNumber\(\)/" << printMBBReference(\1)/g' * find . \( -name "*.txt" -o -name "*.s" -o -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#([0-9]+)/%bb.\1/g' * grep -nr 'BB#' and fix Differential Revision: https://reviews.llvm.org/D40422 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319665 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-30[WebAssembly] Revert r319186 "Support bitcasted function addresses with ↵Dan Gohman
varargs." The patch broke Emscripten's EM_ASM macros, which utiltize unprototyped functions. See https://bugs.llvm.org/show_bug.cgi?id=35385 for details. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319452 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-30[CodeGen] Print "%vreg0" as "%0" in both MIR and debug outputFrancis Visoiu Mistrih
As part of the unification of the debug format and the MIR format, avoid printing "vreg" for virtual registers (which is one of the current MIR possibilities). Basically: * find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E "s/%vreg([0-9]+)/%\1/g" * grep -nr '%vreg' . and fix if needed * find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E "s/ vreg([0-9]+)/ %\1/g" * grep -nr 'vreg[0-9]\+' . and fix if needed Differential Revision: https://reviews.llvm.org/D40420 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319427 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29[WebAssembly] Fix fptoui lowering boundsDan Gohman
To fully avoid trapping on wasm, fptoui needs a second check to ensure that the operand isn't below the supported range. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319354 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-28[WebAssembly] Support bitcasted function addresses with varargs.Dan Gohman
Generalize FixFunctionBitcasts to handle varargs functions. This in particular fixes the case where clang bitcasts away a varargs when calling a K&R-style function. This avoids interacting with tricky ABI details because it operates at the LLVM IR level before varargs ABI details are exposed. This fixes PR35385. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319186 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-28[WebAssembly] Handle errors better in fast-isel.Dan Gohman
Fast-isel routines need to bail out in the case that fast-isel fails on the operands. This fixes https://bugs.llvm.org/show_bug.cgi?id=35064 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319144 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-28[WebAssembly] Fix trapping behavior in fptosi/fptoui.Dan Gohman
This adds code to protect WebAssembly's `trunc_s` family of opcodes from values outside their domain. Even though such conversions have full undefined behavior in C/C++, LLVM IR's `fptosi` and `fptoui` do not, and only return undef. This also implements the proposed non-trapping float-to-int conversion feature and uses that instead when available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319128 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15[WebAssembly] Update cfg-stackify.ll to remove the workaround added in r318288.Dan Gohman
Remove -switch-peel-threshold=100 and update the expected results in test10 in cfg-stackify.ll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318338 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15Workaround CodeGen/WebAssembly/cfg-stackify.ll failure after r318202Ilya Biryukov
By disabling the introduced optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318288 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-14Use input redirection in WebAssembly/comdat.ll test.Ilya Biryukov
To match how the other tests do it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318153 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-14[WebAssembly] Explicily disable comdat support for wasm outputSam Clegg
For now at least. We clearly need some kind of comdat or linkonce_odr support for wasm but currently COMDAT is not supported. Disable COMDAT support in the same way we do the Mach-O. This also causes clang not to generated COMDATs. Differential Revision: https://reviews.llvm.org/D39873 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318123 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[WebAssembly] Fix stack offsets of return values from call lowering.Jatin Bhateja
Summary: Fixes PR35220 Reviewers: vadimcn, alexcrichton Reviewed By: alexcrichton Subscribers: pepyakin, alexcrichton, jfb, dschuff, sbc100, jgravelle-google, llvm-commits, aheejin Differential Revision: https://reviews.llvm.org/D39866 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317895 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08[WebAssembly] Add a test for inline-asm "m" constraints.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317711 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08[WebAssembly] Call signExtend to get sign extended registerDan Gohman
Patch by Jatin Bhateja! Differential Revision: https://reviews.llvm.org/D39529 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317710 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08[WebAssembly] Revise the strategy for inline asm.Dan Gohman
Previously, an "r" constraint would mean the compiler provides a value on WebAssembly's operand stack. This was tricky to use properly, particularly since it isn't possible to declare a new local from within an inline asm string. With this patch, "r" provides the value in a WebAssembly local, and the local index is provided to the inline asm string. This requires inline asm to use get_local and set_local to read the register. This does potentially result in larger code size, however inline asm should hopefully be quite rare in WebAssembly. This also means that the "m" constraint can no longer be supported, as WebAssembly has nothing like a "memory operand" that includes an implicit get_local. This fixes PR34599 for the wasm32-unknown-unknown-wasm target (though not for the ELF target). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317707 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-10[WebAssembly] Narrow the scope of WebAssemblyFixFunctionBitcastsJacob Gravelle
Summary: The pass to fix function bitcasts generates thunks for functions that are called directly with a mismatching signature. It was also generating thunks in cases where the function was address-taken, causing aliasing problems in otherwise valid cases. This patch tightens the restrictions for when the pass runs. Reviewers: sunfish, dschuff Subscribers: jfb, sbc100, llvm-commits, aheejin Differential Revision: https://reviews.llvm.org/D38640 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315326 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[WebAssembly] Add the rest of the atomic loadsDerek Schuff
Add extending loads and constant offset patterns A bit more refactoring of the tablegen to make the patterns fairly nice and uniform between the regular and atomic loads. Differential Revision: https://reviews.llvm.org/D38523 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315022 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-13[WebAssembly] Add sign extend instructions from atomics proposalDerek Schuff
Select them from ISD::SIGN_EXTEND_INREG Differential Revision: https://reviews.llvm.org/D37603 remove spurious change git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313101 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-31[WebAssembly] Refactor load ISel tablegen patterns into classesDerek Schuff
Not all of these will be able to be used by atomics because tablegen, but it still seems like a good change by itself. Differential Revision: https://reviews.llvm.org/D37345 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312287 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-30[WebAssembly] Add target feature for atomicsDerek Schuff
Summary: This tracks the WebAssembly threads feature proposal at https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md Differential Revision: https://reviews.llvm.org/D37300 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312145 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-30Canonicalize the representation of empty an expression in ↵Adrian Prantl
DIGlobalVariableExpression This change simplifies code that has to deal with DIGlobalVariableExpression and mirrors how we treat DIExpressions in debug info intrinsics. Before this change there were two ways of representing empty expressions on globals, a nullptr and an empty !DIExpression(). If someone needs to upgrade out-of-tree testcases: perl -pi -e 's/(!DIGlobalVariableExpression\(var: ![0-9]*)\)/\1, expr: !DIExpression())/g' <MYTEST.ll> will catch 95%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312144 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-24[WebAssembly] FastISel : Bail to SelectionDAG for constexpr callsJacob Gravelle
Summary: Currently FastISel lowers constexpr calls as indirect calls. We'd like those to direct calls, and falling back to SelectionDAGISel handles that. Reviewers: dschuff, sunfish Subscribers: jfb, sbc100, llvm-commits, aheejin Differential Revision: https://reviews.llvm.org/D37073 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311693 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-16[WebAssembly] Remove infinite loop from reg-stackify testDerek Schuff
r310940 exposed reverse-unreachable code to some optimizers, which caused some of the code in this test to be sunk, changing the input to the pass and breaking the exptectations. Since that change is irrelevant to this particular test, this change just adds an exit node to work around the problem; the test should really be more robust (or be an MIR test?) but this preserves the existing test intent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310981 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19Revert r308273 to reinstate part of r308100.Chandler Carruth
That part was reverted because the underlying change necessitating it (r308025) was reverted in r308271. Nirav re-landed r308025 again in r308350, so re-landing this fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308418 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18Revert part of r308100 since the cause (r308025) was also reverted.Chandler Carruth
The commit r308100 updated WebAssembly tests for r308025. In one case it merely made the test more resilient but in another case it made a substantive update. Because r308025 was reverted in r308271, these changes to the test also need to be reverted. They should be folded into the recommit of r308025 when it is ready. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308273 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-15[wasm] Update two tests for r308025 which causes scheduling changes dueChandler Carruth
to the newly improved AA information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308100 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05Fix libcall expansion creating DAG nodes with invalid type post type ↵Vadim Chugunov
legalization. If we are lowering a libcall after legalization, we'll split the return type into a pair of legal values. Patch by Jatin Bhateja and Eli Friedman. Differential Revision: https://reviews.llvm.org/D34240 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307207 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-30[WebAssembly] Add support for exception handling instructionsHeejin Ahn
Summary: This adds backend support for throw, rethrow, try, and try_end instructions. This needs the corresponding clang builtin support: https://reviews.llvm.org/D34783 This follows the Wasm exception handling proposal in https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md Reviewers: sunfish, dschuff Reviewed By: dschuff Subscribers: jfb, sbc100, jgravelle-google Differential Revision: https://reviews.llvm.org/D34826 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306774 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-22[WebAssembly] WebAssemblyFastISel getelementptr variable index supportJacob Gravelle
Summary: Previously -fast-isel getelementptr would constant-fold non-constant i8 load/stores. Reviewers: sunfish Subscribers: jfb, dschuff, sbc100, llvm-commits Differential Revision: https://reviews.llvm.org/D34044 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306060 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16[WebAssembly] Use __stack_pointer global when writing wasm binarySam Clegg
This ensures that symbolic relocations are generated for stack pointer manipulations. These relocations are of type R_WEBASSEMBLY_GLOBAL_INDEX_LEB. This change also adds support for reading relocations of this type in WasmObjectFile.cpp. Since its a globally imported symbol this does mean that the get_global/set_global instruction won't be valid until the objects are linked that global used in no longer an imported global. Differential Revision: https://reviews.llvm.org/D34172 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305616 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-29[wasm] Fix test after r304117.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304164 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17[WebAssembly] Fix WebAssemblyOptimizeReturned after r300367Jacob Gravelle
Summary: Refactoring changed paramHasAttr(1 + i) to paramHasAttr(0), fix that to paramHasAttr(i). Add more tests to WebAssemblyOptimizeReturned that catch that regression. Reviewers: dschuff Subscribers: jfb, sbc100, llvm-commits Differential Revision: https://reviews.llvm.org/D32136 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300502 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28[WebAssembly] Convert the remaining unit tests to the new wasm-object-file ↵Dan Gohman
target. To facilitate this, add a new hidden command-line option to disable the explicit-locals pass. That causes llc to emit invalid code that doesn't have all locals converted to get_local/set_local, however it simplifies testwriting in many cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296540 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24[WebAssembly] Add support for using a wasm global for the stack pointer.Dan Gohman
This replaces the __stack_pointer variable which was allocated in linear memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296201 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24[WebAssembly] Basic support for Wasm object file encoding.Dan Gohman
With the "wasm32-unknown-unknown-wasm" triple, this allows writing out simple wasm object files, and is another step in a larger series toward migrating from ELF to general wasm object support. Note that this code and the binary format itself is still experimental. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296190 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24[WebAssembly] Handle f16 in fast-isel.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296172 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22[WebAssembly] Configure codegen to legalize f16 values.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295850 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15Codegen: Make chains from trellis-shaped CFGsKyle Butt
Lay out trellis-shaped CFGs optimally. A trellis of the shape below: A B |\ /| | \ / | | X | | / \ | |/ \| C D would be laid out A; B->C ; D by the current layout algorithm. Now we identify trellises and lay them out either A->C; B->D or A->D; B->C. This scales with an increasing number of predecessors. A trellis is a a group of 2 or more predecessor blocks that all have the same successors. because of this we can tail duplicate to extend existing trellises. As an example consider the following CFG: B D F H / \ / \ / \ / \ A---C---E---G---Ret Where A,C,E,G are all small (Currently 2 instructions). The CFG preserving layout is then A,B,C,D,E,F,G,H,Ret. The current code will copy C into B, E into D and G into F and yield the layout A,C,B(C),E,D(E),F(G),G,H,ret define void @straight_test(i32 %tag) { entry: br label %test1 test1: ; A %tagbit1 = and i32 %tag, 1 %tagbit1eq0 = icmp eq i32 %tagbit1, 0 br i1 %tagbit1eq0, label %test2, label %optional1 optional1: ; B call void @a() br label %test2 test2: ; C %tagbit2 = and i32 %tag, 2 %tagbit2eq0 = icmp eq i32 %tagbit2, 0 br i1 %tagbit2eq0, label %test3, label %optional2 optional2: ; D call void @b() br label %test3 test3: ; E %tagbit3 = and i32 %tag, 4 %tagbit3eq0 = icmp eq i32 %tagbit3, 0 br i1 %tagbit3eq0, label %test4, label %optional3 optional3: ; F call void @c() br label %test4 test4: ; G %tagbit4 = and i32 %tag, 8 %tagbit4eq0 = icmp eq i32 %tagbit4, 0 br i1 %tagbit4eq0, label %exit, label %optional4 optional4: ; H call void @d() br label %exit exit: ret void } here is the layout after D27742: straight_test: # @straight_test ; ... Prologue elided ; BB#0: # %entry ; A (merged with test1) ; ... More prologue elided mr 30, 3 andi. 3, 30, 1 bc 12, 1, .LBB0_2 ; BB#1: # %test2 ; C rlwinm. 3, 30, 0, 30, 30 beq 0, .LBB0_3 b .LBB0_4 .LBB0_2: # %optional1 ; B (copy of C) bl a nop rlwinm. 3, 30, 0, 30, 30 bne 0, .LBB0_4 .LBB0_3: # %test3 ; E rlwinm. 3, 30, 0, 29, 29 beq 0, .LBB0_5 b .LBB0_6 .LBB0_4: # %optional2 ; D (copy of E) bl b nop rlwinm. 3, 30, 0, 29, 29 bne 0, .LBB0_6 .LBB0_5: # %test4 ; G rlwinm. 3, 30, 0, 28, 28 beq 0, .LBB0_8 b .LBB0_7 .LBB0_6: # %optional3 ; F (copy of G) bl c nop rlwinm. 3, 30, 0, 28, 28 beq 0, .LBB0_8 .LBB0_7: # %optional4 ; H bl d nop .LBB0_8: # %exit ; Ret ld 30, 96(1) # 8-byte Folded Reload addi 1, 1, 112 ld 0, 16(1) mtlr 0 blr The tail-duplication has produced some benefit, but it has also produced a trellis which is not laid out optimally. With this patch, we improve the layouts of such trellises, and decrease the cost calculation for tail-duplication accordingly. This patch produces the layout A,C,E,G,B,D,F,H,Ret. This layout does have back edges, which is a negative, but it has a bigger compensating positive, which is that it handles the case where there are long strings of skipped blocks much better than the original layout. Both layouts handle runs of executed blocks equally well. Branch prediction also improves if there is any correlation between subsequent optional blocks. Here is the resulting concrete layout: straight_test: # @straight_test ; BB#0: # %entry ; A (merged with test1) mr 30, 3 andi. 3, 30, 1 bc 12, 1, .LBB0_4 ; BB#1: # %test2 ; C rlwinm. 3, 30, 0, 30, 30 bne 0, .LBB0_5 .LBB0_2: # %test3 ; E rlwinm. 3, 30, 0, 29, 29 bne 0, .LBB0_6 .LBB0_3: # %test4 ; G rlwinm. 3, 30, 0, 28, 28 bne 0, .LBB0_7 b .LBB0_8 .LBB0_4: # %optional1 ; B (Copy of C) bl a nop rlwinm. 3, 30, 0, 30, 30 beq 0, .LBB0_2 .LBB0_5: # %optional2 ; D (Copy of E) bl b nop rlwinm. 3, 30, 0, 29, 29 beq 0, .LBB0_3 .LBB0_6: # %optional3 ; F (Copy of G) bl c nop rlwinm. 3, 30, 0, 28, 28 beq 0, .LBB0_8 .LBB0_7: # %optional4 ; H bl d nop .LBB0_8: # %exit Differential Revision: https://reviews.llvm.org/D28522 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295223 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31CodeGen: Allow small copyable blocks to "break" the CFG.Kyle Butt
When choosing the best successor for a block, ordinarily we would have preferred a block that preserves the CFG unless there is a strong probability the other direction. For small blocks that can be duplicated we now skip that requirement as well, subject to some simple frequency calculations. Differential Revision: https://reviews.llvm.org/D28583 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293716 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20[WebAssembly] Don't create bitcast-wrappers for varargs.Dan Gohman
WebAssembly varargs functions use a significantly different ABI than non-varargs functions, and the current code in WebAssemblyFixFunctionBitcasts doesn't handle that difference. For now, just avoid creating wrapper functions in the presence of varargs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292645 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18[WebAssembly] Update grow_memory's return type.Dan Gohman
The grow_memory instruction now returns the previous memory size. Add the return type to the LLVM intrinsic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292322 91177308-0d34-0410-b5e6-96231b3b80d8