Detect PaX and fallback to intepreter if needed (bb #2092).
Recent PaX versions deny the RWX mapping, but older versions silently change it
to RW, which causes the program to die as soon as it tries to execute JITed
code.
Add selfcheck on startup (bb #2092).
This will run a very simple bytecode on startup in both JIT and interpreter
mode. The bytecode only calls 1 libclamav API and returns.
Bounds checks were too strict, causing the bytecode to abort when it shouldn't.
This happened when trying to access the last byte of an array, the verifier
was too conservative and considered to be out of bounds, when in fact it wasn't.
This is an update of the runtime verifier from the bytecode compiler.
This is LLVM SVN r102604:
Limit alignment in SmallVector 8, otherwise GCC assumes 16 byte alignment.
opetaror new, and malloc only return 8-byte aligned memory on 32-bit Linux,
which cause a crash if code is compiled with -O3 (or -ftree-vectorize) and some
SmallVector code is vectorized.
RedHat's version (3.4.6 20060404 (Red Hat 3.4.6-11) is buggy, see http://farm.0xacab.net/build/show/6292
FreeBSD's version appears to work, they can pass --enable-llvm, and if make
check passes use it.
All bytecode functions are loaded in a single module, the bounds verifier is
run, and then stack protectors are inserted.
The problem is that when the next bytecode function is loaded, all functions get
run through the verifier again (including those which got the stack protector
applied), and the bounds verifier rejects it (it doesn't know about stack
protectors).
The fix is to skip running the bounds verifier when a function already has the
stack protector applied, when run in libclamav.
This affects only loading of multiple unsigned bytecodes, or an unsigned
bytecode + bytecode.cvd.
Load of a single unsigned bytecode works, and load of multiple signed bytecodes
is not affected (since the verifier is skipped there).
Solaris has 2 greps, one archaic that doesn't know -E and -F,
and one that does. Configure finds the correct one, but
'make check' was using the wrong one.
This patch makes 'lit' substitute 'grep ' with the path to the
correct grep.
Introduce another Reset() method in BumpPtrAllocator that calls a destructor
on all objects it has allocated, if they are all of the same size and alignment.
Use this to destruct all VNInfos allocated in LiveIntervalAnalysis (PR6653).
valnos is not reliable for this purpose, as seen in r99400
(which still leaked, and sometimes caused double frees).
Port LLVM commit r98349:
Author: d0k
Date: Fri Mar 12 07:54:59 2010
New Revision: 98349
Log:
Use StringRef::substr instead of std::string::substr to avoid using a free'd
string temporary. This should fix PR6590.
commit 15467f5ca4d080ee9e5c28c881433d6ec6af33d8
Author: Tanya Lattner <tonic@nondot.org>
Date: Tue Mar 23 17:16:35 2010 +0000
Merge 99032 from mainline.
If call result is in ST0 and it is not being passed to the caller's
caller, then it is not safe to optimize the call into a sibcall since
the call result has to be popped off the x87 stack.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_27@99293 91177308-0d34-0410-b5e6-96231b3b80d8
commit d9fe4c59bba5baba38ba7bcf5282d72b72bccda4
Author: Tanya Lattner <tonic@nondot.org>
Date: Tue Mar 23 17:15:19 2010 +0000
Merge 98977 from mainline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_27@99292 91177308-0d34-0410-b5e6-96231b3b80d8
commit 6d9848f18a63a1d7a9dbccfe74020af569c62eb2
Author: Tanya Lattner <tonic@nondot.org>
Date: Tue Mar 23 17:11:51 2010 +0000
Merge r98845 from mainline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_27@99291 91177308-0d34-0410-b5e6-96231b3b80d8
commit 8c577d8dd275154fdd07bd048f200ab74cefd028
Author: Tanya Lattner <tonic@nondot.org>
Date: Tue Mar 23 17:06:56 2010 +0000
Merge 98561 from mainline.
Avoid sibcall optimization if either caller or callee is using sret semantics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_27@99290 91177308-0d34-0410-b5e6-96231b3b80d8
commit 00d819742f6b1b80bcffccd94802788166ea1eef
Author: Tanya Lattner <tonic@nondot.org>
Date: Tue Mar 23 16:58:02 2010 +0000
Merge r98416 from mainline.
Fix a typo in ValueTracking that's causing instcombine to delete needed shift instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_27@99289 91177308-0d34-0410-b5e6-96231b3b80d8
commit 63a535b8c10001cc189647804f311f413d0d9f29
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Sun Mar 21 20:37:19 2010 +0000
Memoize InlineAsms into the LLVMContext and delete them on shutdown.
Fixes PR803.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99143 91177308-0d34-0410-b5e6-96231b3b80d8
commit 700524ca0d62f3c952aaa6834c6a9792076e2dd6
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Sat Mar 13 01:26:15 2010 +0000
Delete MDNodes when LLVMContext is destroyed. Previous attempts: r97918, r97788.
Tested: clang debug bootstrap, llvm-gcc bootstrap, `make check-lit`
after configuring with --with-llvmgccdir (and this did run the
FrontendC* tests this time)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98410 91177308-0d34-0410-b5e6-96231b3b80d8
commit 8460da1b03c5138a9d5d4185e005e9da6de2bd47
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Sun Mar 21 21:17:34 2010 +0000
Move the LLVMContextImpl implementation into a .cpp file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99146 91177308-0d34-0410-b5e6-96231b3b80d8
commit 0b20bf7e5e79ec124f03ef11eb88be14b1b69162
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Sun Mar 21 22:08:41 2010 +0000
Re-add the Metadata.h include to LLVMContextImpl.h so that MDNode is complete
where FoldingSet<MDNode> is instantiated. Clang and MSVC complain; gcc
doesn't.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99147 91177308-0d34-0410-b5e6-96231b3b80d8
commit 77e427769a0c1dce88e3cc147aa00b2c0dd7f8dd
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Mon Mar 22 05:23:37 2010 +0000
Free all Constants in ~LLVMConstantImpl. We avoid assertion failures
by dropping all references from all constants that can use other
constants before trying to destroy any of them.
I also had to free bugpoint's Module in ~BugDriver().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99160 91177308-0d34-0410-b5e6-96231b3b80d8
commit 6dd22e9c0e8ba4e34a4a21574d66c03c004831bb
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Sat Mar 13 20:09:55 2010 +0000
Allow types that have been forwarded to to be freed.
Tested: make check-lit && valgrind --dsymutil=yes --leak-check=full unittests/ExecutionEngine/JIT/Debug/JITTests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98447 91177308-0d34-0410-b5e6-96231b3b80d8
pthread_cancel is broken on Mac OS X (it only works if the thread
you want to kill calls pthread_testcancel, which is never the situation
when you need async cancelation).
Anyway async cancelation is risky, it may leave bc_ctx in an inconsistent state.
So rather than doing using pthread_cancel (or pthread_kill+siglongjmp)
just insert the timeout checks into the JITed code directly.
These are inserted in each loop, if the loop's tripcount is unknown, or
higher than a threshold. They are also inserted after a certain amount
of APIcalls are made (even in absence of loops).
Note that 'loop' in this sense is not LLVM's notion of a natural loop,
it is simply a BB which is reachable both directly and via a backedge.
For example this doesn't contain natural loops but contains backedges (and a
potential infinite loop):
int foo(int a)
{
int x=4;
if (a == 42)
goto head2;
head:
x++;
head2:
if (a >= 2) {
x += 3;
goto head;
} else if (a >= 0) {
x += 9;
goto head;
}
return x;
}