Commit Graph

71523 Commits

Author SHA1 Message Date
Jim Grosbach
f8c1c8465f MCJIT lazy relocation resolution and symbol address re-assignment.
Add handling for tracking the relocations on symbols and resolving them.
Keep track of the relocations even after they are resolved so that if
the RuntimeDyld client moves the object, it can update the address and any
relocations to that object will be updated.

For our trival object file load/run test harness (llvm-rtdyld), this enables
relocations between functions located in the same object module. It should
be trivially extendable to load multiple objects with mutual references.

As a simple example, the following now works (running on x86_64 Darwin 10.6):


$ cat t.c
int bar() {
  return 65;
}

int main() {
  return bar();
}
$ clang t.c -fno-asynchronous-unwind-tables -o t.o -c
$ otool -vt t.o
t.o:
(__TEXT,__text) section
_bar:
0000000000000000  pushq %rbp
0000000000000001  movq  %rsp,%rbp
0000000000000004  movl  $0x00000041,%eax
0000000000000009  popq  %rbp
000000000000000a  ret
000000000000000b  nopl  0x00(%rax,%rax)
_main:
0000000000000010  pushq %rbp
0000000000000011  movq  %rsp,%rbp
0000000000000014  subq  $0x10,%rsp
0000000000000018  movl  $0x00000000,0xfc(%rbp)
000000000000001f  callq 0x00000024
0000000000000024  addq  $0x10,%rsp
0000000000000028  popq  %rbp
0000000000000029  ret
$ llvm-rtdyld t.o -debug-only=dyld ; echo $?
Function sym: '_bar' @ 0
Function sym: '_main' @ 16
Extracting function: _bar from [0, 15]
    allocated to 0x100153000
Extracting function: _main from [16, 41]
    allocated to 0x100154000
Relocation at '_main' + 16 from '_bar(Word1: 0x2d000000)
Resolving relocation at '_main' + 16 (0x100154010) from '_bar (0x100153000)(pcrel, type: 2, Size: 4).
loaded '_main' at: 0x100154000
65
$




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129388 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 21:20:41 +00:00
Johnny Chen
32cefad4b3 Add bad register checks for Thumb2 Ld/St instructions.
rdar://problem/9269047


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129387 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 21:17:51 +00:00
Andrew Trick
c558bf3972 Revert 129383. It causes some targets to hit a scheduler assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129385 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 20:14:07 +00:00
Nick Lewycky
e9e7ffa10d Print our uint64_t with the more portable (C99 and C++0x) %PRIu64 format
specifier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129384 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 20:06:50 +00:00
Andrew Trick
3eb4319313 PreRA scheduler heuristic fixes: VRegCycle, TokenFactor latency.
UnitsSharePred was a source of randomness in the scheduler: node
priority depended on the queue data structure. I rewrote the recent
VRegCycle heuristics to completely replace the old heuristic without
any randomness. To make these heuristic adjustments to node latency work,
I also needed to do something a little more reasonable with TokenFactor. I
gave it zero latency to its consumers and always schedule it as low as
possible.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129383 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 19:54:36 +00:00
Oscar Fuentes
23ba1e4faa Document how to build a LLVM pass with CMake out of source.
Patch by arrowdodger!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129381 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 19:40:35 +00:00
Nick Lewycky
c6d8853dff The counters are unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129380 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 19:35:45 +00:00
Jakob Stoklund Olesen
fd5c51342a Create new intervals for isolated blocks during region splitting.
This merges the behavior of splitSingleBlocks into splitAroundRegion, so the
RS_Region and RS_Block register stages can be coalesced. That means the leftover
intervals after region splitting go directly to spilling instead of a second
pass of per-block splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129379 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 19:32:53 +00:00
Rafael Espindola
5d7dcd3335 Remove LastOffset from the asm parser.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129378 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 18:53:30 +00:00
Johnny Chen
f9ce2cba42 The Thumb2 Ld, St, and Preload instructions with the i12 forms should have its Inst{23}
be specified as '1' (add = TRUE).

Also add a utility function for Thumb2.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129377 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 18:48:00 +00:00
Jakob Stoklund Olesen
e1b43c3b40 Add SplitKit API to query and select the current interval being worked on.
This makes it possible to target multiple registers in one pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129374 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 18:11:31 +00:00
Jakob Stoklund Olesen
dfaf0e2c0e Fix a bug in RegAllocBase::addMBBLiveIns() where a basic block could accidentally be skipped.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129373 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 18:11:28 +00:00
Devang Patel
860cf9693a Remove dead typedef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129368 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 17:43:12 +00:00
Devang Patel
8b9df62d02 Refactor CompileUnit into a separate header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129367 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 17:40:32 +00:00
Johnny Chen
49fdfe3ce5 Print out a debug message when the reglist fails the sanity check for Thumb Ld/St Multiple.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129365 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 17:09:04 +00:00
Rafael Espindola
25f492e778 Fix the case of a .cfi_rel_offset before any .cfi_def_cfa_offset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129362 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 16:12:03 +00:00
Rafael Espindola
c57543964d Implement .cfi_same_value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129361 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 15:31:05 +00:00
Garrison Venn
18bba84d77 Added new FIXME note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129360 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 12:30:10 +00:00
Cameron Zwarich
d0aacbcc2e Split a store of a VMOVDRR into two integer stores to avoid mixing NEON and ARM
stores of arguments in the same cache line. This fixes the second half of
<rdar://problem/8674845>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129345 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 02:24:17 +00:00
NAKAMURA Takumi
39df9b5920 lib/Transforms/Instrumentation/CMakeLists.txt: Add LineProfiling.cpp to fix up r129340.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129343 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 01:54:40 +00:00
Nick Lewycky
93b68b20d4 Add support for line profiling. Very work-in-progress.
Use debug info in the IR to find the directory/file:line:col. Each time that location changes, bump a counter.

Unlike the existing profiling system, we don't try to look at argv[], and thusly don't require main() to be present in the IR. This matches GCC's technique where you specify the profiling flag when producing each .o file.

The runtime library is minimal, currently just calling printf at program shutdown time. The API is designed to make it possible to emit GCOV data later on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129340 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 01:06:09 +00:00
Nick Lewycky
ceb465a8a4 Consider ConstantAggregateZero as well as ConstantArray/Struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129338 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 01:02:45 +00:00
Eric Christopher
bbfc3b3098 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129334 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:48:08 +00:00
Nick Lewycky
cb4e4eae1a Make IRBuilder support StringRef for building strings.
Also document that the global variables produced are mergable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129330 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:29:07 +00:00
Jim Grosbach
7cbf92d1d9 Tidy up a bit now that we're using the MemoryManager interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129328 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:23:32 +00:00
Johnny Chen
163b6eaf25 Add one test case (svc).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129327 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:21:48 +00:00
Eric Christopher
05f9e4e8bd Match case for invalid constant error messages and add a new
test for invalid hexadecimals.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129326 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:18:03 +00:00
Johnny Chen
e77f72d7d2 A8.6.16 B
Encoding T1 (tBcc)
if cond == '1110' then UNDEFINED;

rdar://problem/9268681


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129325 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:14:49 +00:00
Dan Gohman
dac5dbadeb Fix reassociate to use a worklist instead of recursing when new
reassociation opportunities are exposed. This fixes a bug where
the nested reassociation expects to be the IR to be consistent,
but it isn't, because the outer reassociation has disconnected
some of the operands.  rdar://9167457


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129324 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:11:56 +00:00
Eric Christopher
164254d77c Test for invalid constant expr addition - bad octal constant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129323 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:03:38 +00:00
Eric Christopher
f3755b2d0e To avoid printing out multiple error messages for cases like:
.long 80+08

go ahead and assume that if we've got an Error token that we handled it
already. Otherwise if it's a token we can't handle then go ahead and
return the default error.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129322 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-12 00:03:13 +00:00
Jakob Stoklund Olesen
560ab9ebf7 Reuse live interval union between functions. This saves a bit of compile time
when compiling many small functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129321 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 23:57:14 +00:00
Johnny Chen
de16508955 Thumb disassembler was erroneously rejecting "blx sp" instruction.
rdar://problem/9267838


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129320 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 23:33:30 +00:00
Chris Lattner
c8fbc34869 comment cleanup, use moveBefore instead of removeFromParent+insertBefore.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129319 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 23:24:57 +00:00
NAKAMURA Takumi
bd2907356d TableGen: Keep the order of DECL_CONTEXT() for DeclNodes.td. RecordVector may be used instead of RecordSet.
The result of DeclNodes.inc was unstable on msys, Windows 7 x64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129317 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 23:20:28 +00:00
Chris Lattner
b5f18f5df0 remove the StructRetPromotion pass. It is unused, not maintained and
has some bugs.  If this is interesting functionality, it should be 
reimplemented in the argpromotion pass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129314 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 23:09:44 +00:00
Wesley Peck
ef9d9fdde1 Fix an error in the MBlaze delay slot filler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129313 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 22:45:02 +00:00
Daniel Dunbar
58194307c1 build: Add support for a SHOW_DIAGNOSTICS build variable.
If enabled, this will attempt to use the CC_LOG_DIAGNOSTICS feature I dropped
into Clang to print a log of all the diagnostics generated during an individual
build (from the top-level). Not sure if this will actually be useful, but for
now it is handy for testing the option.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129312 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 22:37:39 +00:00
Wesley Peck
3d820baf19 Add scheduling information for the MBlaze backend.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129311 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 22:31:52 +00:00
Eric Christopher
120fd2dd6d Lex, and then fail on invalid constants.
Testcase forthcoming.

rdar://8490596


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129309 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 22:24:56 +00:00
Nick Lewycky
5ea5c61589 Just because a GlobalVariable's initializer is [N x { i32, void ()* }] doesn't
mean that it has to be ConstantArray of ConstantStruct. We might have
ConstantAggregateZero, at either level, so don't crash on that.

Also, semi-deprecate the sentinal value. The linker isn't aware of sentinals so
we end up with the two lists appended, each with their "sentinals" on them.
Different parts of LLVM treated sentinals differently, so make them all just
ignore the single entry and continue on with the rest of the list.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129307 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 22:11:20 +00:00
Rafael Espindola
a61842bf6e Implement cfi_rel_offset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129306 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 21:49:50 +00:00
Jakob Stoklund Olesen
3f5bedf5cb Speed up eviction by stopping collectInterferingVRegs as soon as the spill
weight limit has been exceeded.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129305 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 21:47:01 +00:00
Rafael Espindola
787d41aaa0 Add test for previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129304 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 21:41:34 +00:00
Wesley Peck
e53060fdf4 Don't crash on invalid instructions when disassembling MBlaze code.
This fixes http://llvm.org/bugs/show_bug.cgi?id=9653


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129303 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 21:35:21 +00:00
Bill Wendling
cc88595bce The default of the dispatch switch statement was to branch to a BB that executed
the 'unwind' instruction. However, later on that instruction was converted into
a jump to the basic block it was located in, causing an infinite loop when we
get there.

It turns out, we get there if the _Unwind_Resume_or_Rethrow call returns (which
it's not supposed to do). It returns if it cannot find a place to unwind
to. Thus we would get what appears to be a "hang" when in reality it's just that
the EH couldn't be propagated further along.

Instead of infinitely looping (or calling `unwind', which none of our back-ends
support (it's lowered into nothing...)), call the @llvm.trap() intrinsic
instead. This may not conform to specific rules of a particular language, but
it's rather better than infinitely looping.

<rdar://problem/9175843&9233582>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129302 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 21:32:34 +00:00
Johnny Chen
35563fee7b Fix the bug where the immediate shift amount for Thumb logical shift instructions are incorrectly disassembled.
rdar://problem/9266265


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129298 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 21:14:35 +00:00
Evan Cheng
d67705faaa Look pass copies when determining whether hoisting would end up inserting more copies. rdar://9266679
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129297 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 21:09:18 +00:00
Rafael Espindola
53abbe5064 implement .cfi_adjust_cfa_offset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129296 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 20:29:16 +00:00
Eli Friedman
2227f154eb Get rid of useless comment; if a file uses functions from a given header,
it is obvious that it should be included.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129295 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-11 20:16:05 +00:00