Commit Graph

580 Commits

Author SHA1 Message Date
Chris Lattner 7a2607026b make jit jump table emission be based on the EntryKind instead of magic variables.
JITInfo::getPICJumpTableEntry can probably be removed now, but I don't plan to do 
this.

llvm-svn: 94501
2010-01-26 03:47:15 +00:00
Chris Lattner b6db2c6b31 Rearrange handling of jump tables. Highlights:
1. MachineJumpTableInfo is now created lazily for a function the first time
   it actually makes a jump table instead of for every function.
2. The encoding of jump table entries is now described by the
   MachineJumpTableInfo::JTEntryKind enum.  This enum is determined by the
   TLI::getJumpTableEncoding() hook, instead of by lots of code scattered
   throughout the compiler that "knows" that jump table entries are always
   32-bits in pic mode (for example).
3. The size and alignment of jump table entries is now calculated based on
   their kind, instead of at machinefunction creation time.

Future work includes using the EntryKind in more places in the compiler,
eliminating other logic that "knows" the layout of jump tables in various
situations.

llvm-svn: 94470
2010-01-25 23:26:13 +00:00
Chris Lattner 823aed16f9 make -fno-rtti the default unless a directory builds with REQUIRES_RTTI.
llvm-svn: 94378
2010-01-24 20:43:08 +00:00
Jeffrey Yasskin 690818fc27 Make OProfile support compile again after r93630 removed
DebugLocTuple.  Also use an AssertingVH to ensure that MDNodes aren't
destroyed while the FilenameCache is using them.

llvm-svn: 94245
2010-01-22 23:04:39 +00:00
Chris Lattner 7ba0661f27 Stop building RTTI information for *most* llvm libraries. Notable
missing ones are libsupport, libsystem and libvmcore.  libvmcore is
currently blocked on bugpoint, which uses EH.  Once it stops using
EH, we can switch it off.

This #if 0's out 3 unit tests, because gtest requires RTTI information.
Suggestions welcome on how to fix this.

llvm-svn: 94164
2010-01-22 06:49:46 +00:00
Devang Patel 1083b5fc3f Avoid including DebugInfo.h in AsmPrinter.h
llvm-svn: 93864
2010-01-19 06:09:04 +00:00
Devang Patel c0e17df3ce Replace DebugLocTuple with DILocation.
llvm-svn: 93630
2010-01-16 06:09:35 +00:00
Benjamin Kramer d2564e3afb Move remaining stuff to the isInteger predicate.
llvm-svn: 92771
2010-01-05 21:05:54 +00:00
Benjamin Kramer a81a6dff0d Convert a ton of simple integer type equality tests to the new predicate.
llvm-svn: 92760
2010-01-05 20:07:06 +00:00
Benjamin Kramer ccce8bae14 Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer.
llvm-svn: 92726
2010-01-05 13:12:22 +00:00
David Greene 2baba9643c Change errs() to dbgs().
llvm-svn: 92562
2010-01-05 01:23:38 +00:00
David Greene 85814ac1b7 Change errs() to dbgs().
llvm-svn: 92561
2010-01-05 01:23:36 +00:00
David Greene 1c10c25354 Change errs() to dbgs().
llvm-svn: 92560
2010-01-05 01:23:34 +00:00
Bill Wendling 9bea533c8e Remove dead store and simplify code.
llvm-svn: 92191
2009-12-28 01:53:00 +00:00
Jeffrey Yasskin 6523429779 Partially revert r91626. Materializing extra functions to determine whether
they're available_externally broke VMKit, which was relying on the fact that
functions would only be materialized when they were first called.  We'll have
to wait for http://llvm.org/PR5737 to really fix this.

I also added a test for one of the F->isDeclaration() calls which wasn't
covered by anything else in the test suite.

llvm-svn: 91943
2009-12-22 23:47:23 +00:00
Jeffrey Yasskin ad46e4416b Fix a crash in JIT::recompileAndRelinkFunction(). It doesn't pass the MCI
argument to runJITOnFunction(), which caused a null pointer dereference at
every call.

Patch by Gianluca Guida!

llvm-svn: 91939
2009-12-22 23:18:18 +00:00
Jeffrey Yasskin 2b73a4e90f Don't codegen available_externally functions. Fixes http://llvm.org/PR5735.
llvm-svn: 91626
2009-12-17 21:35:29 +00:00
Jeffrey Yasskin e0d8e14e11 Change indirect-globals to use a dedicated allocIndirectGV. This lets us
remove start/finishGVStub and the BufferState helper class from the
MachineCodeEmitter interface.  It has the side-effect of not setting the
indirect global writable and then executable on ARM, but that shouldn't be
necessary.

llvm-svn: 91464
2009-12-15 22:42:46 +00:00
Chris Lattner 45d040bd85 Remove isPod() from DenseMapInfo, splitting it out to its own
isPodLike type trait.  This is a generally useful type trait for
more than just DenseMap, and we really care about whether something
acts like a pod, not whether it really is a pod.

llvm-svn: 91421
2009-12-15 07:26:43 +00:00
Eric Christopher d5218331f7 Formatting.
llvm-svn: 91377
2009-12-15 00:40:55 +00:00
Jeffrey Yasskin 8c17e6de2b Reinstate r91208 to fix available_externally linkage for globals, with
nlewycky's fix to add -rdynamic so the JIT can look symbols up in Linux builds
of the JITTests binary.

llvm-svn: 91250
2009-12-13 20:30:32 +00:00
Jeffrey Yasskin 9ad6ba3766 Revert r91208. Something on Linux prevents the JIT from looking up a symbol
defined in the test, and I don't have time tonight to figure it out.

llvm-svn: 91209
2009-12-12 06:18:46 +00:00
Jeffrey Yasskin 2d2dcdcbf7 Fix available_externally linkage for globals. It's probably still not
supported by emitGlobals, but I don't have a test case for that.

llvm-svn: 91208
2009-12-12 05:58:14 +00:00
Torok Edwin 12b8a63e13 Comparing std::string with NULL is a bad idea, so just check whether its empty.
This code was crashing always with oprofile enabled, since it tried to create a StringRef
out of NULL, which run strlen on NULL.

llvm-svn: 91046
2009-12-10 10:01:47 +00:00
Jeffrey Yasskin fc7384d366 Fix the OProfileJITEventListener for StringRef being returned from debug info.
llvm-svn: 90813
2009-12-07 22:32:38 +00:00
Jeffrey Yasskin f2ad571443 * Move stub allocation inside the JITEmitter, instead of exposing a
way for each TargetJITInfo subclass to allocate its own stubs. This
means stubs aren't as exactly-sized anymore, but it lets us get rid of
TargetJITInfo::emitFunctionStubAtAddr(), which lets ARM and PPC
support the eager JIT, fixing http://llvm.org/PR4816.

* Rename the JITEmitter's stub creation functions to describe the kind
of stub they create. So far, all of them create lazy-compilation
stubs, but they sometimes get used when far-call stubs are needed.
Fixing http://llvm.org/PR5201 will involve fixing this.

llvm-svn: 89715
2009-11-23 23:35:19 +00:00
Jeffrey Yasskin 19b48370fb Allow more than one stub to be being generated at the same time.
It's probably better in the long run to replace the
indirect-GlobalVariable system. That'll be done after a subsequent
patch.

llvm-svn: 89708
2009-11-23 22:49:00 +00:00
Jeffrey Yasskin 34fb6838bc Try to fix JITTest.FarCallToKnownFunction on ARM and PPC.
llvm-svn: 89410
2009-11-19 23:42:58 +00:00
Eric Christopher 700d08e18d Add ability to set code model within the execution engine builders
and creation interfaces.

llvm-svn: 89151
2009-11-17 21:58:16 +00:00
Jeffrey Yasskin 10d3604a9e Make X86-64 in the Large model always emit 64-bit calls.
The large code model is documented at
http://www.x86-64.org/documentation/abi.pdf and says that calls should
assume their target doesn't live within the 32-bit pc-relative offset
that fits in the call instruction.

To do this, we turn off the global-address->target-global-address
conversion in X86TargetLowering::LowerCall(). The first attempt at
this broke the lazy JIT because it can separate the movabs(imm->reg)
from the actual call instruction. The lazy JIT receives the address of
the movabs as a relocation and needs to record the return address from
the call; and then when that call happens, it needs to patch the
movabs with the newly-compiled target. We could thread the call
instruction into the relocation and record the movabs<->call mapping
explicitly, but that seems to require at least as much new
complication in the code generator as this change.

To fix this, we make lazy functions _always_ go through a call
stub. You'd think we'd only have to force lazy calls through a stub on
difficult platforms, but that turns out to break indirect calls
through a function pointer. The right fix for that is to distinguish
between calls and address-of operations on uncompiled functions, but
that's complex enough to leave for someone else to do.

Another attempt at this defined a new CALL64i pseudo-instruction,
which expanded to a 2-instruction sequence in the assembly output and
was special-cased in the X86CodeEmitter's emitInstruction()
function. That broke indirect calls in the same way as above.

This patch also removes a hack forcing Darwin to the small code model.
Without far-call-stubs, the small code model requires things of the
JITMemoryManager that the DefaultJITMemoryManager can't provide.

Thanks to echristo for lots of testing!

llvm-svn: 88984
2009-11-16 22:41:33 +00:00
Benjamin Kramer 8c19a8f17b Implement DISABLE_INLINE for MSVC. This required changing the position in all
forward declaration and patching tblgen to emit it right. Patch by Amine Khaldi!

llvm-svn: 88798
2009-11-14 16:37:18 +00:00
Eric Christopher cb5e227373 Use stubs when we have them, otherwise use code we already have,
otherwise create a stub.

Add a test to make sure we don't create extraneous stubs.

llvm-svn: 86941
2009-11-12 03:12:18 +00:00
Eric Christopher ebbfbeef7d Fix typo, cleanup whitespace.
llvm-svn: 86917
2009-11-12 01:06:08 +00:00
Jeffrey Yasskin 8483f12ac5 Remove dlsym stubs, with Nate Begeman's permission.
llvm-svn: 86606
2009-11-09 22:34:19 +00:00
Jeffrey Yasskin db5f24ce77 Make the need-stub variables accurate and consistent. In the case of
MachineRelocations, "stub" always refers to a far-call stub or a
load-a-faraway-global stub, so this patch adds "Far" to the term. (Other stubs
are used for lazy compilation and dlsym address replacement.) The variable was
also inconsistent between the positive and negative sense, and the positive
sense ("NeedStub") was more demanding than is accurate (since a nearby-enough
function can be called directly even if the platform often requires a stub).
Since the negative sense causes double-negatives, I switched to
"MayNeedFarStub" globally.

llvm-svn: 86363
2009-11-07 08:51:52 +00:00
Jeffrey Yasskin ba78dcd90d Give the JITResolver a direct pointer to its JITEmitter, and use that instead
of going through the global TheJIT variable.  This makes it easier to use
features of JITEmitter that aren't in JITCodeEmitter for fixing PR5201.

llvm-svn: 86305
2009-11-07 00:00:10 +00:00
Benjamin Kramer 5e1db97573 Fix MSVC build.
llvm-svn: 85505
2009-10-29 12:55:32 +00:00
Chris Lattner 0c778f70e9 add interpreter support for indirect goto / blockaddress. The interpreter
now correctly runs clang's test/CodeGen/indirect-goto.c.  The JIT will abort
on it until someone feels compelled to implement this.

llvm-svn: 85488
2009-10-29 05:26:09 +00:00
Jeffrey Yasskin 4567db45b8 Change the JIT to compile eagerly by default as agreed in
http://llvm.org/PR5184, and beef up the comments to describe what both options
do and the risks of lazy compilation in the presence of threads.

llvm-svn: 85295
2009-10-27 20:30:28 +00:00
Jeffrey Yasskin e3e08e0f90 Fix OProfileJITEventListener after r85182.
llvm-svn: 85192
2009-10-27 01:06:51 +00:00
Jeffrey Yasskin bf43f6543d Automatically do the equivalent of freeMachineCodeForFunction(F) when F is
being destroyed. This allows users to run global optimizations like globaldce
even after some functions have been jitted.

This patch also removes the Function* parameter to
JITEventListener::NotifyFreeingMachineCode() since it can cause that to be
called when the Function is partially destroyed. This change will be even more
helpful later when I think we'll want to allow machine code to actually outlive
its Function.

llvm-svn: 85182
2009-10-27 00:03:05 +00:00
Chandler Carruth 56869f22c4 Move DataTypes.h to include/llvm/System, update all users. This breaks the last
direct inclusion edge from System to Support.

llvm-svn: 85086
2009-10-26 01:35:46 +00:00
Chris Lattner f4c2a9f02a fix PR5186: the JIT shouldn't try to codegen available_externally
functions it should just look them up like declarations.

llvm-svn: 85077
2009-10-25 23:06:42 +00:00
Jeffrey Yasskin d0fc8f809a Fix http://llvm.org/PR4822: allow module deletion after a function has been
compiled.

When functions are compiled, they accumulate references in the JITResolver's
stub maps. This patch removes those references when the functions are
destroyed.  It's illegal to destroy a Function when any thread may still try to
call its machine code.

This patch also updates r83987 to use ValueMap instead of explicit CallbackVHs
and fixes a couple "do stuff inside assert()" bugs from r84522.

llvm-svn: 84975
2009-10-23 22:37:43 +00:00
Benjamin Kramer ab304c9237 Random include cleanup.
llvm-svn: 84898
2009-10-22 21:49:41 +00:00
Jeffrey Yasskin 86dfc11cdf Fix OProfileJITEventListener after r84054 renamed CompileUnit to Scope.
llvm-svn: 84895
2009-10-22 20:57:35 +00:00
Nicolas Geoffray 7e8017cce7 Verify that the function and exception table have been allocated
before freeing them.

llvm-svn: 84859
2009-10-22 14:35:57 +00:00
Douglas Gregor 05f77d5006 De-bork CMake build
llvm-svn: 84744
2009-10-21 06:01:54 +00:00
Jeffrey Yasskin 08fa03c740 Delete the MacOSJITEventListener per echristo's request. It was disabled by
default and didn't work anyway.

llvm-svn: 84720
2009-10-21 00:43:48 +00:00
Jeffrey Yasskin 27c669242a Move the Function*->allocated blocks map from the JITMemoryManager to the
JITEmitter.

I'm gradually making Functions auto-remove themselves from the JIT when they're
destroyed. In this case, the Function needs to be removed from the JITEmitter,
but the map recording which Functions need to be removed lived behind the
JITMemoryManager interface, which made things difficult.

This patch replaces the deallocateMemForFunction(Function*) method with a pair
of methods deallocateFunctionBody(void *) and deallocateExceptionTable(void *)
corresponding to the two startFoo/endFoo pairs.

llvm-svn: 84651
2009-10-20 18:13:21 +00:00
Jeffrey Yasskin 7d2edada7f Clean up the JITResolver stub/callsite<->function maps.
The JITResolver maps Functions to their canonical stubs and all callsites for
lazily-compiled functions to their target Functions. To make Function
destruction work, I'm going to need to remove all callsites on destruction, so
this patch also adds the reverse mapping for that.

There was an incorrect assumption in here that the only stub for a function
would be the one caused by needing to lazily compile it, while x86-64 far calls
and dlsym-stubs could also cause such stubs, but I didn't look for a test case
that the assumption broke.

This also adds DenseMapInfo<AssertingVH> so I can use DenseMaps instead of
std::maps.

llvm-svn: 84522
2009-10-19 18:49:59 +00:00
Devang Patel d7ebfe3963 s/DebugLoc.CompileUnit/DebugLoc.Scope/g
s/DebugLoc.InlinedLoc/DebugLoc.InlinedAtLoc/g

llvm-svn: 84054
2009-10-13 23:28:53 +00:00
Jeffrey Yasskin d162dbac7f Keep track of stubs that are created. This fixes PR5162 and probably PR4822 and
4406. Patch by Nick Lewycky!

llvm-svn: 84032
2009-10-13 21:32:57 +00:00
Devang Patel eb43b17074 Update processDebugLoc() to handle requests to process debug info, before and after emitting instructions.
llvm-svn: 83364
2009-10-06 03:04:58 +00:00
Jeffrey Yasskin e97fe329e9 Fix http://llvm.org/PR5116 by rolling back r60822. This passes `make unittests
check-lit` on both x86-64 Linux and x86-32 Darwin.

llvm-svn: 83353
2009-10-06 00:35:55 +00:00
Nick Lewycky 6d59690c3e Fix compile error as debug interface changed.
By the way, this code is buggy. You can't keep a map<MDNode *, something>
because the MDNode may be destroyed and reused for something else.

llvm-svn: 83141
2009-09-30 04:50:26 +00:00
Benjamin Kramer 43355aec61 Fix a struct/class mismatch.
llvm-svn: 82622
2009-09-23 11:48:57 +00:00
Daniel Dunbar 1a0a423b38 Use Compiler.h macro instead of __attribute__.
llvm-svn: 82532
2009-09-22 07:38:23 +00:00
Xerxes Ranby da99be6fae Update cmake.
llvm-svn: 82449
2009-09-21 08:08:29 +00:00
Daniel Dunbar bc528b16c2 Register the MachineModuleInfo for the ARM JIT, and update JITDwarfEmitter to
assert if the setModuleInfo hasn't been called.

llvm-svn: 82441
2009-09-21 05:58:35 +00:00
Reid Kleckner 9a10db8c46 Implement the JIT side of the GDB JIT debugging interface. To enable this
feature, either build the JIT in debug mode to enable it by default or pass
-jit-emit-debug to lli.

Right now, the only debug information that this communicates to GDB is call
frame information, since it's already being generated to support exceptions in
the JIT.  Eventually, when DWARF generation isn't tied so tightly to AsmPrinter,
it will be easy to push that information to GDB through this interface.

Here's a step-by-step breakdown of how the feature works:

- The JIT generates the machine code and DWARF call frame info
  (.eh_frame/.debug_frame) for a function into memory.
- The JIT copies that info into an in-memory ELF file with a symbol for the
  function.
- The JIT creates a code entry pointing to the ELF buffer and adds it to a
  linked list hanging off of a global descriptor at a special symbol that GDB
  knows about.
- The JIT calls a function marked noinline that GDB knows about and has put an
  internal breakpoint in.
- GDB catches the breakpoint and reads the global descriptor to look for new
  code.
- When sees there is new code, it reads the ELF from the inferior's memory and
  adds it to itself as an object file.
- The JIT continues, and the next time we stop the program, we are able to
  produce a proper backtrace.

Consider running the following program through the JIT:

#include <stdio.h>
void baz(short z) {
  long w = z + 1;
  printf("%d, %x\n", w, *((int*)NULL));  // SEGFAULT here
}
void bar(short y) {
  int z = y + 1;
  baz(z);
}
void foo(char x) {
  short y = x + 1;
  bar(y);
}
int main(int argc, char** argv) {
  char x = 1;
  foo(x);
}

Here is a backtrace before this patch:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x2aaaabdfbd10 (LWP 25476)]
0x00002aaaabe7d1a8 in ?? ()
(gdb) bt
#0  0x00002aaaabe7d1a8 in ?? ()
#1  0x0000000000000003 in ?? ()
#2  0x0000000000000004 in ?? ()
#3  0x00032aaaabe7cfd0 in ?? ()
#4  0x00002aaaabe7d12c in ?? ()
#5  0x00022aaa00000003 in ?? ()
#6  0x00002aaaabe7d0aa in ?? ()
#7  0x01000002abe7cff0 in ?? ()
#8  0x00002aaaabe7d02c in ?? ()
#9  0x0100000000000001 in ?? ()
#10 0x00000000014388e0 in ?? ()
#11 0x00007fff00000001 in ?? ()
#12 0x0000000000b870a2 in llvm::JIT::runFunction (this=0x1405b70,
F=0x14024e0, ArgValues=@0x7fffffffe050)
   at /home/rnk/llvm-gdb/lib/ExecutionEngine/JIT/JIT.cpp:395
#13 0x0000000000baa4c5 in llvm::ExecutionEngine::runFunctionAsMain
(this=0x1405b70, Fn=0x14024e0, argv=@0x13f06f8, envp=0x7fffffffe3b0)
   at /home/rnk/llvm-gdb/lib/ExecutionEngine/ExecutionEngine.cpp:377
#14 0x00000000007ebd52 in main (argc=2, argv=0x7fffffffe398,
envp=0x7fffffffe3b0) at /home/rnk/llvm-gdb/tools/lli/lli.cpp:208

And a backtrace after this patch:
Program received signal SIGSEGV, Segmentation fault.
0x00002aaaabe7d1a8 in baz ()
(gdb) bt
#0  0x00002aaaabe7d1a8 in baz ()
#1  0x00002aaaabe7d12c in bar ()
#2  0x00002aaaabe7d0aa in foo ()
#3  0x00002aaaabe7d02c in main ()
#4  0x0000000000b870a2 in llvm::JIT::runFunction (this=0x1405b70,
F=0x14024e0, ArgValues=...)
   at /home/rnk/llvm-gdb/lib/ExecutionEngine/JIT/JIT.cpp:395
#5  0x0000000000baa4c5 in llvm::ExecutionEngine::runFunctionAsMain
(this=0x1405b70, Fn=0x14024e0, argv=..., envp=0x7fffffffe3c0)
   at /home/rnk/llvm-gdb/lib/ExecutionEngine/ExecutionEngine.cpp:377
#6  0x00000000007ebd52 in main (argc=2, argv=0x7fffffffe3a8,
envp=0x7fffffffe3c0) at /home/rnk/llvm-gdb/tools/lli/lli.cpp:208

llvm-svn: 82418
2009-09-20 23:52:43 +00:00
Chris Lattner 0d3f6962a1 remove a dead variable.
llvm-svn: 81985
2009-09-16 01:29:11 +00:00
Bill Wendling ea81960798 Fix PR4865. This syncs up the JIT's DWARF emitter with what's in the
'DwarfException.cpp' file, which changed how CIEs were emitted, the sizes of
some fields, etc.

llvm-svn: 81295
2009-09-09 00:11:02 +00:00
Daniel Dunbar 6119d878bb Improve JIT error message for users crazy enough to use -march with JIT, and
mention -version in messages about missing targets.

llvm-svn: 81272
2009-09-08 23:32:35 +00:00
Evan Cheng 10a5dabfd5 Fix PR4845: r77946 completely broke x86_64 Darwin (or any situation where the
desired triplet is a sub-target, e.g. thumbv7 vs. arm host). Reverting the
patch isn't quite right either since the previous behavior does not allow the
triplet to be overridden with -march.

llvm-svn: 80742
2009-09-02 00:19:03 +00:00
Jeffrey Yasskin 9e955171ca Fix OProfile support after r80406 changed the DebugInfo interface from
GlobalVariables to MDNodes.

llvm-svn: 80411
2009-08-29 00:44:16 +00:00
Dan Gohman fb3d84b524 Initialize the PoisonMemory member before initializing
members that call methods that read the PoisonMemory member.
This fixes potential spurious (though probably otherwise
harmless) poising of unused memory, and fixes the
associated valgrind error.

llvm-svn: 80192
2009-08-27 01:25:57 +00:00
Xerxes Ranby e921f6f927 Fix PR4772 ARM JIT.GlobalInFuction unittest by explicitly initialize MMI
to 0 during JITEmitter constructor.

Modified:
	lib/ExecutionEngine/JIT/JITEmitter.cpp

llvm-svn: 79982
2009-08-25 10:12:55 +00:00
Chris Lattner 471ba48cb9 remove some uses of llvm/Support/Streams.h
llvm-svn: 79842
2009-08-23 08:43:55 +00:00
Chris Lattner 4dc3edde9f remove a few DOUTs here and there.
llvm-svn: 79832
2009-08-23 06:35:02 +00:00
Chris Lattner 7b26fce23e Rename TargetAsmInfo (and its subclasses) to MCAsmInfo.
llvm-svn: 79763
2009-08-22 20:48:53 +00:00
Reid Kleckner 48ca915be9 Fix a bug where the DWARF emitter in the JIT was not initializing alignment
bytes.  libgcc doesn't seem to mind, but if you pass this DWARF to GDB, it
doesn't like it.  

Also make the JIT memory manager to initialize it's memory to garbage in debug
mode, so that it's easier to find bugs like these in the future.

llvm-svn: 79674
2009-08-21 21:03:57 +00:00
Owen Anderson 55f1c09e31 Push LLVMContexts through the IntegerType APIs.
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Dan Gohman 1432ef864e This void is implicit in C++.
llvm-svn: 78848
2009-08-12 22:10:57 +00:00
Jim Grosbach 693e36a3e8 SjLj based exception handling unwinding support. This patch is nasty, brutish
and short. Well, it's kinda short. Definitely nasty and brutish.

The front-end generates the register/unregister calls into the SjLj runtime,
call-site indices and landing pad dispatch. The back end fills in the LSDA
with the call-site information provided by the front end. Catch blocks are
not yet implemented.

Built on Darwin and verified no llvm-core "make check" regressions.

llvm-svn: 78625
2009-08-11 00:09:57 +00:00
Dan Gohman a6d0afcb74 Fix a bunch of namespace pollution.
llvm-svn: 78363
2009-08-07 01:32:21 +00:00
Daniel Dunbar ad9a6c4855 No really, it's unused.
llvm-svn: 78047
2009-08-04 04:08:40 +00:00
Benjamin Kramer c28b306423 llvm_report_error already prints "LLVM ERROR:". So stop reporting errors like "LLVM ERROR: llvm: error:" or "LLVM ERROR: ERROR:".
llvm-svn: 77971
2009-08-03 13:33:33 +00:00
Daniel Dunbar 719d235520 Remove now unused arguments from TargetRegistry::lookupTarget.
llvm-svn: 77950
2009-08-03 04:20:57 +00:00
Daniel Dunbar 0f16ea5c30 Pass target triple string in to TargetMachine constructor.
This is not just a matter of passing in the target triple from the module;
currently backends are making decisions based on the build and host
architecture. The goal is to migrate to making these decisions based off of the
triple (in conjunction with the feature string). Thus most clients pass in the
target triple, or the host triple if that is empty.

This has one important change in the way behavior of the JIT and llc.

For the JIT, it was previously selecting the Target based on the host
(naturally), but it was setting the target machine features based on the triple
from the module. Now it is setting the target machine features based on the
triple of the host.

For LLC, -march was previously only used to select the target, the target
machine features were initialized from the module's triple (which may have been
empty). Now the target triple is taken from the module, or the host's triple is
used if that is empty. Then the triple is adjusted to match -march.

The take away is that -march for llc is now used in conjunction with the host
triple to initialize the subtarget. If users want more deterministic behavior
from llc, they should use -mtriple, or set the triple in the input module.

llvm-svn: 77946
2009-08-03 04:03:51 +00:00
Nick Lewycky 133d9105d3 Fix the build for people with oprofile installed.
llvm-svn: 77914
2009-08-02 20:51:44 +00:00
Nicolas Geoffray 956a86445c In TrimAllocationToSize, if a block is below the minimum allocation size,
there is no new block added to the free list. Therefore on the next
startFunctionBody call, a new slab must be allocated.

llvm-svn: 77520
2009-07-29 22:55:02 +00:00
Owen Anderson 4056ca9568 Move types back to the 2.5 API.
llvm-svn: 77516
2009-07-29 22:17:13 +00:00
Owen Anderson 487375e9a2 Move ConstantExpr to 2.5 API.
llvm-svn: 77494
2009-07-29 18:55:55 +00:00
Owen Anderson 69c464dec4 Move ConstantFP construction back to the 2.5-ish API.
llvm-svn: 77247
2009-07-27 20:59:43 +00:00
Daniel Dunbar 6115b39ffd Remove Value::getName{Start,End}, the last of the old Name APIs.
llvm-svn: 77152
2009-07-26 09:48:23 +00:00
Daniel Dunbar 691a4784db Simplify JIT target selection.
- Instead of requiring targets to define a JIT quality match function, we just
   have them specify if they support a JIT.

 - Target selection for the JIT just gets the host triple and looks for the best
   target which matches the triple and has a JIT.

llvm-svn: 77060
2009-07-25 10:09:50 +00:00
Daniel Dunbar 0dd5e1ed39 More migration to raw_ostream, the water has dried up around the iostream hole.
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
   "magic" DOUT behavior which avoided calling printing functions when the
   statement was disabled. In addition to being unnecessary magic, it had the
   downside of leaving code in -Asserts builds, and of hiding potentially
   unnecessary computations.

llvm-svn: 77019
2009-07-25 00:23:56 +00:00
Owen Anderson edb4a70325 Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
llvm-svn: 77011
2009-07-24 23:12:02 +00:00
Reid Kleckner 4b3a356493 Re-committing r76828 with the JIT memory manager changes now that the build
bots like the BumpPtrAllocator changes.

llvm-svn: 76902
2009-07-23 21:46:56 +00:00
Reid Kleckner 921673225c Reverting r76825 and r76828, since they caused clang runtime errors and some build failure involving memset.
llvm-svn: 76838
2009-07-23 01:40:54 +00:00
Reid Kleckner 1a722d9b73 Make the JIT code emitter properly retry and ask for more memory when it runs
out of memory, and also make the default memory manager allocate more memory
when it runs out.

Also, switch function stubs and global data over to using the BumpPtrAllocator.

This makes it so the JIT no longer mmaps (or the equivalent on Windows) 16 MB
of memory, and instead allocates in 512K slabs.  I suspect this size could go
lower, especially on embedded platforms, now that more slabs can be allocated.

llvm-svn: 76828
2009-07-23 00:49:59 +00:00
Owen Anderson 47db941fd3 Get rid of the Pass+Context magic.
llvm-svn: 76702
2009-07-22 00:24:57 +00:00
Daniel Dunbar 5899e340f3 Simplify / normalize some uses of Value::getName.
llvm-svn: 76553
2009-07-21 08:54:24 +00:00
Reid Kleckner fc8a2d5a83 Add EngineBuilder to ExecutionEngine in favor of the five optional argument EE::create().
Also a test commit.

llvm-svn: 76276
2009-07-18 00:42:18 +00:00
Jeffrey Yasskin efad8e45fe Add line numbers to OProfile. To do this, I added a processDebugLoc()
call to the MachineCodeEmitter interface and made copying the start
line of a function not conditional on whether we're emitting Dwarf
debug information. I'll propagate the processDebugLoc() calls to the
non-X86 targets in a followup patch.

In the long run, it'll probably be better to gather this information
through the DwarfWriter, but the DwarfWriter currently depends on the
AsmPrinter and TargetAsmInfo, and fixing that would be out of the way
for this patch.

There's a bug in OProfile 0.9.4 that makes it ignore line numbers for
addresses above 4G, and a patch fixing it at
http://thread.gmane.org/gmane.linux.oprofile/7634

Sample output:

$ sudo opcontrol --reset; sudo opcontrol --start-daemon; sudo opcontrol --start; `pwd`/Debug/bin/lli fib.bc; sudo opcontrol --stop
Signalling daemon... done
Profiler running.
fib(40) == 165580141
Stopping profiling.

$ opreport -g -d -l `pwd`/Debug/bin/lli|head -60
Overflow stats not available
CPU: Core 2, speed 1998 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (Unhalted core cycles) count 100000
vma      samples  %        linenr info                 image name               symbol name
00007f67a30370b0 25489    61.2554  fib.c:24                    10946.jo                 fib_left
  00007f67a30370b0 1634      6.4106  fib.c:24
  00007f67a30370b1 83        0.3256  fib.c:24
  00007f67a30370b9 1997      7.8348  fib.c:24
  00007f67a30370c6 2080      8.1604  fib.c:27
  00007f67a30370c8 988       3.8762  fib.c:27
  00007f67a30370cd 1315      5.1591  fib.c:27
  00007f67a30370cf 251       0.9847  fib.c:27
  00007f67a30370d3 1191      4.6726  fib.c:27
  00007f67a30370d6 975       3.8252  fib.c:27
  00007f67a30370db 1010      3.9625  fib.c:27
  00007f67a30370dd 242       0.9494  fib.c:27
  00007f67a30370e1 2782     10.9145  fib.c:28
  00007f67a30370e5 3768     14.7828  fib.c:28
  00007f67a30370eb 615       2.4128  (no location information)
  00007f67a30370f3 6558     25.7287  (no location information)
00007f67a3037100 15603    37.4973  fib.c:29                    10946.jo                 fib_right
  00007f67a3037100 1646     10.5493  fib.c:29
  00007f67a3037101 45        0.2884  fib.c:29
  00007f67a3037109 2372     15.2022  fib.c:29
  00007f67a3037116 2234     14.3178  fib.c:32
  00007f67a3037118 612       3.9223  fib.c:32
  00007f67a303711d 622       3.9864  fib.c:32
  00007f67a303711f 385       2.4675  fib.c:32
  00007f67a3037123 404       2.5892  fib.c:32
  00007f67a3037126 634       4.0633  fib.c:32
  00007f67a303712b 870       5.5759  fib.c:32
  00007f67a303712d 62        0.3974  fib.c:32
  00007f67a3037131 1848     11.8439  fib.c:33
  00007f67a3037135 2840     18.2016  fib.c:33
  00007f67a303713a 1         0.0064  fib.c:33
  00007f67a303713b 1023      6.5564  (no location information)
  00007f67a3037143 5         0.0320  (no location information)
000000000080c1e4 15        0.0360  MachineOperand.h:150        lli                      llvm::MachineOperand::isReg() const
  000000000080c1e4 6        40.0000  MachineOperand.h:150
  000000000080c1ec 2        13.3333  MachineOperand.h:150
...

llvm-svn: 76102
2009-07-16 21:07:26 +00:00
Daniel Dunbar b825dd3a31 Remove unused header.
llvm-svn: 75893
2009-07-16 04:01:35 +00:00
Daniel Dunbar d3706458df Switch llc and createJIT to use simpler command line parsing for -march.
llvm-svn: 75890
2009-07-16 02:23:53 +00:00
Daniel Dunbar e833810a5e Reapply TargetRegistry refactoring commits.
--- Reverse-merging r75799 into '.':
 U   test/Analysis/PointerTracking
U    include/llvm/Target/TargetMachineRegistry.h
U    include/llvm/Target/TargetMachine.h
U    include/llvm/Target/TargetRegistry.h
U    include/llvm/Target/TargetSelect.h
U    tools/lto/LTOCodeGenerator.cpp
U    tools/lto/LTOModule.cpp
U    tools/llc/llc.cpp
U    lib/Target/PowerPC/PPCTargetMachine.h
U    lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
U    lib/Target/PowerPC/PPCTargetMachine.cpp
U    lib/Target/PowerPC/PPC.h
U    lib/Target/ARM/ARMTargetMachine.cpp
U    lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
U    lib/Target/ARM/ARMTargetMachine.h
U    lib/Target/ARM/ARM.h
U    lib/Target/XCore/XCoreTargetMachine.cpp
U    lib/Target/XCore/XCoreTargetMachine.h
U    lib/Target/PIC16/PIC16TargetMachine.cpp
U    lib/Target/PIC16/PIC16TargetMachine.h
U    lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
U    lib/Target/Alpha/AlphaTargetMachine.cpp
U    lib/Target/Alpha/AlphaTargetMachine.h
U    lib/Target/X86/X86TargetMachine.h
U    lib/Target/X86/X86.h
U    lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
U    lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
U    lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h
U    lib/Target/X86/X86TargetMachine.cpp
U    lib/Target/MSP430/MSP430TargetMachine.cpp
U    lib/Target/MSP430/MSP430TargetMachine.h
U    lib/Target/CppBackend/CPPTargetMachine.h
U    lib/Target/CppBackend/CPPBackend.cpp
U    lib/Target/CBackend/CTargetMachine.h
U    lib/Target/CBackend/CBackend.cpp
U    lib/Target/TargetMachine.cpp
U    lib/Target/IA64/IA64TargetMachine.cpp
U    lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
U    lib/Target/IA64/IA64TargetMachine.h
U    lib/Target/IA64/IA64.h
U    lib/Target/MSIL/MSILWriter.cpp
U    lib/Target/CellSPU/SPUTargetMachine.h
U    lib/Target/CellSPU/SPU.h
U    lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
U    lib/Target/CellSPU/SPUTargetMachine.cpp
U    lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
U    lib/Target/Mips/MipsTargetMachine.cpp
U    lib/Target/Mips/MipsTargetMachine.h
U    lib/Target/Mips/Mips.h
U    lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
U    lib/Target/Sparc/SparcTargetMachine.cpp
U    lib/Target/Sparc/SparcTargetMachine.h
U    lib/ExecutionEngine/JIT/TargetSelect.cpp
U    lib/Support/TargetRegistry.cpp

llvm-svn: 75820
2009-07-15 20:24:03 +00:00
Stuart Hastings 338191cd67 Revert 75762, 75763, 75766..75769, 75772..75775, 75778, 75780, 75782 to repair broken LLVM-GCC build.
Will revert 75770 in the llvm-gcc trunk.

llvm-svn: 75799
2009-07-15 17:27:11 +00:00