Commit Graph

3471 Commits

Author SHA1 Message Date
Chris Lattner 0ab5e2cded Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Jim Grosbach 7cb41d787d Load multiple object files and link them via RuntimeDyld in llvm-rtdyld.
Relocations between the object modules are properly resolved, as in the
following trivial example:

$ cat t.c
int foo();
int main() {
    return foo();
}
$ cat foo.c
int foo() {
    return 65;
}
$ clang -c t.c -fno-asynchronous-unwind-tables
$ clang -c foo.c -fno-asynchronous-unwind-tables
$ llvm-rtdyld t.o foo.o ; echo $?
loaded '_main' at: 0x10015c000
65

llvm-svn: 129448
2011-04-13 15:49:40 +00:00
Jim Grosbach d35159a177 Allow user-specified program entry point for llvm-rtdyld.
llvm-svn: 129446
2011-04-13 15:38:30 +00:00
Jim Grosbach 733d305fee 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
$

llvm-svn: 129388
2011-04-12 21:20:41 +00:00
Jim Grosbach 3ed03f18d1 Tidy up a bit now that we're using the MemoryManager interface.
llvm-svn: 129328
2011-04-12 00:23:32 +00:00
Jay Foad 7c14a558fe Don't include Operator.h from InstrTypes.h.
llvm-svn: 129271
2011-04-11 09:35:34 +00:00
Sean Callanan 7ccf375622 Moved an access to an object past a NULL check,
making the MC disassembler tester more robust.

llvm-svn: 129175
2011-04-09 00:21:04 +00:00
Jim Grosbach 18b81c52bb Refactor MCJIT 32-bit section loading.
Teach 32-bit section loading to use the Memory Manager interface, just like
the 64-bit loading does. Tidy up a few other things here and there.

llvm-svn: 129138
2011-04-08 17:31:24 +00:00
Rafael Espindola ece7c9c282 If present, use gold's support for getting a file view. This prevents having
to map the file both in the linker and in the plugin.

llvm-svn: 129109
2011-04-07 21:11:00 +00:00
Jim Grosbach 23de2437bd RuntimeDyld should use the memory manager API.
Start teaching the runtime Dyld interface to use the memory manager API
for allocating space. Rather than mapping directly into the MachO object,
we extract the payload for each object and copy it into a dedicated buffer
allocated via the memory manager. For now, just do Segment64, so this works
on x86_64, but not yet on ARM.

llvm-svn: 128973
2011-04-06 01:11:05 +00:00
Chris Lattner 706754c1f2 remove graphprinter support for domfrontier.
llvm-svn: 128938
2011-04-05 21:43:56 +00:00
Andrew Trick 12004013ef Added *hidden* flags -print-options and -print-all-options so
developers can see if their driver changed any cl::Option's. The
current implementation isn't perfect but handles most kinds of
options. This is nice to have when decomposing the stages of
compilation and moving between different drivers. It's also a good
sanity check when comparing results produced by different command line
invocations that are expected to produce the comparable results.

Note: This is not an attempt to prolong the life of cl::Option. On the
contrary, it's a placeholder for a feature that must exist when
cl::Option is replaced by a more appropriate framework. A new
framework needs: a central option registry, dynamic name lookup,
non-global containers of option values (e.g. per-module,
per-function), *and* the ability to print options values and their defaults at
any point during compilation.

llvm-svn: 128910
2011-04-05 18:54:36 +00:00
Andrew Trick b826ae8310 whitespace
llvm-svn: 128905
2011-04-05 18:41:31 +00:00
Oscar Fuentes d8a6dd6c99 Rename LLVMConfig.cmake to LLVM-Config.cmake. The *Config.cmake naming
scheme is used by the functionality related to find_package.

llvm-svn: 128889
2011-04-05 17:02:48 +00:00
Jim Grosbach 2dcef0505f Layer the memory manager between the JIT and the runtime Dyld.
The JITMemory manager references LLVM IR constructs directly, while the
runtime Dyld works at a lower level and can handle objects which may not
originate from LLVM IR. Introduce a new layer for the memory manager to
handle the interface between them. For the MCJIT, this layer will be almost
entirely simply a call-through w/ translation between the IR objects and
symbol names.

llvm-svn: 128851
2011-04-04 23:04:39 +00:00
Devang Patel 0abc463f5b Update BreakpointPrinter to emit original function names only.
llvm-svn: 128839
2011-04-04 19:51:17 +00:00
Eric Christopher 66c1c59bdb Remove unused function.
llvm-svn: 128834
2011-04-04 17:36:11 +00:00
Chris Lattner 2c6cefc9c3 silence an unused function warning.
llvm-svn: 128831
2011-04-04 17:17:57 +00:00
Eric Christopher 19ea5ae81a Start migrating mach-o dumping facilities to the object file out of a
separate executable.

llvm-svn: 128801
2011-04-03 23:51:47 +00:00
Oscar Fuentes 25ec0d38e1 CMake: remove debug code from previous commit.
llvm-svn: 128740
2011-04-01 21:39:38 +00:00
Oscar Fuentes cde00a55c8 Fix assignment of -fPIC to CMAKE_C_FLAGS. Configure llvm-config.in.in
with the contents of CMAKE_C(XX)_FLAGS too, else `llvm-config
--c(xx)flags' doesn't tell the absolute truth.

This comes from PR9603 and is based on a patch by Ryuta Suzuki!

llvm-svn: 128727
2011-04-01 19:36:06 +00:00
Devang Patel 22430f4141 Update CMakeLists.txt
Patch by arrowdoger.

llvm-svn: 128719
2011-04-01 18:03:58 +00:00
Michael J. Spencer 3df5c04fe4 Fix whitespace.
llvm-svn: 128631
2011-03-31 13:06:39 +00:00
Michael J. Spencer c60223ef6c Switch FileRemover from PathV1 to V2.
llvm-svn: 128630
2011-03-31 13:04:19 +00:00
Jay Foad 52131344a2 Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
PHINode::Create() giving the (known or expected) number of operands.

llvm-svn: 128537
2011-03-30 11:28:46 +00:00
Jay Foad e0938d8a87 (Almost) always call reserveOperandSpace() on newly created PHINodes.
llvm-svn: 128535
2011-03-30 11:19:20 +00:00
Francois Pichet c68476480e Update CMake link dependency.
llvm-svn: 128503
2011-03-29 23:18:51 +00:00
Jim Grosbach 6cfbcc8954 Instantiate a JITMemoryManager for MCJIT Dyld
llvm-svn: 128485
2011-03-29 21:03:05 +00:00
Devang Patel 4a2737aa26 Expoert c interface for disassembler.
llvm-svn: 128440
2011-03-29 00:01:39 +00:00
Daniel Dunbar 4ee0d03274 MC: Add support for disabling "temporary label" behavior. Useful for debugging
on Darwin.

llvm-svn: 128430
2011-03-28 22:49:15 +00:00
NAKAMURA Takumi 3854bad4a1 llvm-stub.cpp: mingw-w64 tweak.
llvm-svn: 128205
2011-03-24 07:06:45 +00:00
Rafael Espindola 26b57ffa27 Add a lto_codegen_compile_to_file to avoid producing a file, reading it to
memory and writing it back to disk.

llvm-svn: 128108
2011-03-22 20:57:13 +00:00
Rafael Espindola 2475adce37 We don't need a null terminator for the output file.
llvm-svn: 128098
2011-03-22 19:20:47 +00:00
Jim Grosbach 40411cc409 Propogate the error message, not just the error state.
llvm-svn: 128094
2011-03-22 18:19:42 +00:00
Oscar Fuentes 27cfcbac82 Updated library dependencies.
Now we can remove RuntimeDyld from the LLVM_LINK_COMPONENTS of
tools/lli. CMakeLists.txt LLVM_LINK_COMPONENTS shall not differ from
its companion Makefile LINK_COMPONENTS.

llvm-svn: 128069
2011-03-22 03:58:55 +00:00
Jim Grosbach 7bf595348e Update link components.
Also perform the required dark rituals and sacrifices to placate the buildbot
spirits. We shall see if they are appeased...

llvm-svn: 128067
2011-03-22 03:10:14 +00:00
Oscar Fuentes e4840e2918 Build the new RuntimeDyld library.
llvm-svn: 128035
2011-03-21 23:07:53 +00:00
Jim Grosbach f016b0a359 Library-ize the dyld components of llvm-rtdyld.
Move the dynamic linking functionality of the llvm-rtdyld program into an
ExecutionEngine support library. Update llvm-rtdyld to just load an object
file into memory, use the library to process it, then run the _main()
function, if one is found.

llvm-svn: 128031
2011-03-21 22:15:52 +00:00
Bill Wendling 00f0cddfd4 We need to pass the TargetMachine object to the InstPrinter if we are printing
the alias of an InstAlias instead of the thing being aliased. Because we need to
know the features that are valid for an InstAlias.

This is part of a work-in-progress.

llvm-svn: 127986
2011-03-21 04:13:46 +00:00
Oscar Fuentes cae1b90915 Make llvm-config.in configuration more MSYS-friendly.
Some of those POSIX <-> Windows command line conversions ended on
failure.

llvm-svn: 127958
2011-03-19 22:52:33 +00:00
Oscar Fuentes 916fb1a62b CMake: store TARGET_TRIPLE on llvm-config.in.
llvm-svn: 127957
2011-03-19 22:52:25 +00:00
Jim Grosbach 7b162490fd Beginnings of MC-JIT code generation.
Proof-of-concept code that code-gens a module to an in-memory MachO object.
This will be hooked up to a run-time dynamic linker library (see: llvm-rtdyld
for similarly conceptual work for that part) which will take the compiled
object and link it together with the rest of the system, providing back to the
JIT a table of available symbols which will be used to respond to the
getPointerTo*() queries.

llvm-svn: 127916
2011-03-18 22:48:41 +00:00
Rafael Espindola 5b778b2e60 Use lazy parsing in LTO. Unfortunately this is only a 3% time saving for
'ar'. Have to figure out how to make libLTO even lazier.

llvm-svn: 127901
2011-03-18 19:51:00 +00:00
Jim Grosbach 486e57f694 Add llvm-rtdyld support for loading 32-bit code.
Factor out the 64-bit specific bits into a helper function and add an
equivalent that loads the 32-bit sections. This allows using llvm-rtdyld on ARM.

llvm-svn: 127892
2011-03-18 18:54:32 +00:00
Oscar Fuentes 9d8ffa9dba Update list of link components for llvm-rtdyld.
llvm-svn: 127887
2011-03-18 17:27:04 +00:00
Jim Grosbach 4d5284b44b Naming conventional tidy up.
llvm-svn: 127886
2011-03-18 17:24:21 +00:00
Jim Grosbach 0072cdbc50 MachO file loader and execution utility.
Add a bone-simple utility to load a MachO object into memory, look for
a function (main) in it, and run that function directly. This will be used
as a test and development platform for MC-JIT work regarding symbol resolution,
dynamic lookup, etc..

Code by Daniel Dunbar.

llvm-svn: 127885
2011-03-18 17:11:39 +00:00
Rafael Espindola c78f65775a Simplify the computation of undefined symbols. Instead of walking
functions and initializers, just report the declarations present in
the module.

The motivation is to open the way for using the lazy module parsing,
which should speed up clients that just want a symbol list (nm, ar).

This is slightly less precise, but since both -strip-dead-prototypes
and -globaldce are part of the standard pipeline, this shouldn't
change the result for clang/dragonegg produced binaries.

Any decl in an IL file was also put there because a FE expected it
to be necessary, so this should not be a problem for "-O0 -emit-llvm".

As a sanity check, I have bootstrapped clang on linux and built
firefox on both linux and darwin. A clang bootstrap on darwin
with LTO fails with or without this patch because, ironically,
the linker doesn't like the combination of dead_strip and LTO
when building libLTO.so :-)

llvm-svn: 127870
2011-03-18 05:12:38 +00:00
NAKAMURA Takumi f4d5346fb4 tools/lto/LTOModule.cpp: Eliminate an unused variable.
llvm-svn: 127859
2011-03-18 03:21:11 +00:00
NAKAMURA Takumi ce60d4cd4d llvm-bcanalyzer.cpp: Tweak format string to suppress warnings on mingw32-g++.
llvm-svn: 127858
2011-03-18 03:21:04 +00:00
Rafael Espindola ab959a2e68 Use RequiresNullTerminator to create buffers without a null terminator
instead of copying.

llvm-svn: 127835
2011-03-17 22:18:42 +00:00
Stuart Hastings ec54bd755f Reapply: Add type output to llvm-dis annotations. Patch by Yuri!
llvm-svn: 127824
2011-03-17 19:50:04 +00:00
Stuart Hastings ead01c40e1 Revert 127813 while fixing broken test.
llvm-svn: 127814
2011-03-17 16:54:27 +00:00
Stuart Hastings 8e08a786bf Add type output to llvm-dis. Patch by Yuri!
llvm-svn: 127813
2011-03-17 16:30:14 +00:00
Rafael Espindola b39c7c7b17 Add support in the LTO library for loading an object from the middle
of an file.

llvm-svn: 127781
2011-03-17 00:36:11 +00:00
Francois Pichet dfeda09345 Make llvm::Consumer a class (to remove a MSVC warning since Consumer is later forward declared as a struct)
llvm-svn: 127632
2011-03-14 23:07:21 +00:00
Renato Golin 4b6ae939ca This patch is a big refactoring of llvm-diff. It doesn't add new features, but it re-organizes the old features, so I can insert the MetadataEngine to use the same infrastructure.
llvm-svn: 127627
2011-03-14 22:22:46 +00:00
Oscar Fuentes ac824ee462 LTO is not ready for Windows.
llvm-svn: 127562
2011-03-13 03:06:59 +00:00
Oscar Fuentes 3685f2762b Build EnhancedDisassembly as a shared library too.
llvm-svn: 127555
2011-03-12 22:01:47 +00:00
Oscar Fuentes 02c446a73a Build LTO as a static library too.
llvm-svn: 127553
2011-03-12 22:01:36 +00:00
Oscar Fuentes 68c1f55fdc Build LTO as a static library too.
llvm-svn: 127549
2011-03-12 17:32:30 +00:00
Oscar Fuentes 1fc0c8ab78 Update link components for llvm-dis and LTO.
llvm-svn: 127545
2011-03-12 16:48:49 +00:00
Oscar Fuentes 0122841626 Force re-linking of LLVMgold.so when its exports file changes.
llvm-svn: 127473
2011-03-11 18:27:13 +00:00
Oscar Fuentes 87e4a4da0d Fix processing of gold.exports.
llvm-svn: 127471
2011-03-11 18:07:46 +00:00
Devang Patel 982efb5c89 While printing annotations, print line number and variable name if debug info is present.
llvm-svn: 127470
2011-03-11 18:07:33 +00:00
Oscar Fuentes 64d05bc281 Add LTO and gold plugin to the CMake build. Linux-only, support for
other systems pending.

PR9456.

llvm-svn: 127466
2011-03-11 15:44:24 +00:00
Rafael Espindola 1e49a6d9bc Add a special streamer to libLTO that just records symbols definitions and
uses.

The result produced by the streamer is used to give the linker more accurate
information and to add to llvm.compiler.used. The second improvement removes
the need for the user to add __attribute__((used)) to functions only used in
inline asm. The first one lets us build firefox with LTO on Darwin :-)

llvm-svn: 126830
2011-03-02 04:14:42 +00:00
Rafael Espindola 7e5fe6ce1c Gold now rescans archives as needed, so the pass-through options are not
necessary anymore.

llvm-svn: 126580
2011-02-27 20:30:22 +00:00
Rafael Espindola 92c06ba158 bfd was fixed, remove the work around.
llvm-svn: 126579
2011-02-27 20:15:37 +00:00
Rafael Espindola 908d391bd2 LTO uses MC now.
llvm-svn: 126546
2011-02-26 16:44:13 +00:00
Rafael Espindola fac373cacb Switch LTO to use MC. This takes the linking of libxul.so from about 7m to
6m30.

llvm-svn: 126426
2011-02-24 21:04:06 +00:00
Chris Lattner 7c3230d348 fit in 80 cols.
llvm-svn: 126399
2011-02-24 18:59:38 +00:00
Benjamin Kramer c053644217 Plug some leaks in edis.
- Don't leak parsed operands during tokenization.
- Don't leak printed insts in llvm-mc.

llvm-svn: 126381
2011-02-24 11:03:19 +00:00
Sean Callanan be81988c99 Fixed a bug in the enhanced disassembly tester that
caused it to only parse one line of input.

llvm-svn: 126301
2011-02-23 03:29:41 +00:00
Oscar Fuentes ab0465020b CMake: remove unnecessary variable.
llvm-svn: 126224
2011-02-22 15:40:20 +00:00
Sean Callanan 5b23294799 Fixed llvm-mc in edis mode to use the result of
operand.evaluate as an error code, not as the
contents of the operand.

llvm-svn: 126181
2011-02-22 02:09:15 +00:00
Rafael Espindola 9ef90d5b35 Dispose modules early and only create codegen when the plugin is being
used by the linker and not by nm or ar.

llvm-svn: 126089
2011-02-20 18:28:29 +00:00
Rafael Espindola 477d11f9a0 Fix some memory leaks and avoid looking in the hash tables twice.
libxul links in 7m0.403s.

llvm-svn: 126085
2011-02-20 16:27:25 +00:00
Stephen Wilson a32b8d7801 This patch lets LLDB build as an LLVM subproject. LLDB is not built in
parallel with the rest of the tools directory as it depends on Clang.

This patch was first applied in r125956 and subsequently reverted in
r125964 as it broke in-tree builds.  Makefile.rules was fixed up in 
r126070 to handle missing optional directories for the in-tree case,
so it should be safe now to bring this patch back in.
 

llvm-svn: 126071
2011-02-20 04:17:15 +00:00
Rafael Espindola d4f34d840e Add modules to codegen as soon as possible. This reduces the link time
of libxul from 12m31.084s to 7m1.359s.

llvm-svn: 126052
2011-02-19 21:49:57 +00:00
Mikhail Glushenkov 82e559837a Make "-opt [-emit-llvm]" work for .ll files.
Patch by Kaelyn Uhrain!

llvm-svn: 126000
2011-02-19 00:33:27 +00:00
Chris Lattner 1341df93f7 add a way to disable all builtins, wire it up to opt's -disable-simplifylibcalls flag.
llvm-svn: 125978
2011-02-18 22:34:03 +00:00
Chris Lattner 15c8b5ef8b Have opt set up a specific TargetLibraryInfo for modules
with a triple.

llvm-svn: 125970
2011-02-18 22:13:01 +00:00
Oscar Fuentes 5ed962656c Move library stuff out of the toplevel CMakeLists.txt file.
llvm-svn: 125968
2011-02-18 22:06:14 +00:00
Owen Anderson d2f7431fa8 Revert r125956, which broke the build if you _don't_ have lldb checked out.
llvm-svn: 125964
2011-02-18 21:33:23 +00:00
Stephen Wilson 880a6129e2 This patch lets LLDB build as an LLVM subproject. LLDB is not built in
parallel with the rest of the tools directory as it depends on Clang.

llvm-svn: 125956
2011-02-18 20:50:33 +00:00
Peter Collingbourne 53049153cf Make -disable-simplify-libcalls work with -std-compile-opts
llvm-svn: 125824
2011-02-18 02:59:21 +00:00
Rafael Espindola 6b6ed5d1f9 Add a debug obj-path option to make it easy to keep the .o produce by LTO.
llvm-svn: 125663
2011-02-16 11:19:44 +00:00
Rafael Espindola 70d8015063 Switch llvm to using comdats. For now always use groups with a single
section.

llvm-svn: 125526
2011-02-14 22:23:49 +00:00
Chris Lattner 20541a6da6 improve solaris support, from PR9109, patch by Yuri!
llvm-svn: 125456
2011-02-13 08:38:44 +00:00
Rafael Espindola 8cc5910dbc Preserve aliases if needed.
llvm-svn: 125439
2011-02-12 18:03:13 +00:00
Rafael Espindola 3937ded624 Fix a silly bug I introduced when dropping std::string.
llvm-svn: 125420
2011-02-12 00:19:56 +00:00
Chris Lattner cee9db2b6f fix dumping of METADATA_ATTACHMENT2 names, patch by Peter Housel!
llvm-svn: 125367
2011-02-11 05:50:01 +00:00
Rafael Espindola 34b59389ea Remove std::string version of getNameWithPrefix.
llvm-svn: 125363
2011-02-11 05:23:09 +00:00
NAKAMURA Takumi 3de6c8607e CMake: LLVM_NO_RTTI must be obsolete now!
llvm-svn: 125274
2011-02-10 09:13:39 +00:00
NAKAMURA Takumi cec7e6828e tools/llvm-ld/CMakeLists.txt: llvm-ld depends on llvm-stub at runtime.
llvm-svn: 125166
2011-02-09 04:17:47 +00:00
NAKAMURA Takumi db06756c9c tools/llvm-ld: Cygwin can handle #!shbang.
llvm-svn: 125165
2011-02-09 04:17:39 +00:00
Rafael Espindola 56e41f7f0b Don't open the file again in the gold plugin. To be able to do this, update
MemoryBuffer::getOpenFile to not close the file descriptor.

llvm-svn: 125128
2011-02-08 22:40:47 +00:00
Andrew Trick 8665d59f46 Added bugpoint options: -compile-custom and -compile-command=...
I've been using this mode to narrow down llc unit tests. Example
custom compile script:
llc "$@"
not pygrep.py 'mul\s+r([0-9]), r\1,' < bugpoint-test-program.s

llvm-svn: 125096
2011-02-08 18:20:48 +00:00
Andrew Trick 69a963e377 whitespace
llvm-svn: 125095
2011-02-08 18:07:10 +00:00