Commit Graph

1160 Commits

Author SHA1 Message Date
Bill Wendling a52aa3c18f Add checks for the landingpad instruction's clause values to make sure that
they're the correct type.

llvm-svn: 137511
2011-08-12 20:52:25 +00:00
Bill Wendling fae1475823 Initial commit of the 'landingpad' instruction.
This implements the 'landingpad' instruction. It's used to indicate that a basic
block is a landing pad. There are several restrictions on its use (see
LangRef.html for more detail). These restrictions allow the exception handling
code to gather the information it needs in a much more sane way.

This patch has the definition, implementation, C interface, parsing, and bitcode
support in it.

llvm-svn: 137501
2011-08-12 20:24:12 +00:00
Chris Lattner 335d399a0e switch to use the new api for structtypes.
llvm-svn: 137480
2011-08-12 18:06:37 +00:00
Eli Friedman 59b66883ea Representation of 'atomic load' and 'atomic store' in IR.
llvm-svn: 137170
2011-08-09 23:02:53 +00:00
Benjamin Kramer 103e2ec2df Remove unused variables.
llvm-svn: 136803
2011-08-03 19:53:48 +00:00
Bill Wendling f891bf8b30 Add the 'resume' instruction for the new EH rewrite.
This adds the 'resume' instruction class, IR parsing, and bitcode reading and
writing. The 'resume' instruction resumes propagation of an existing (in-flight)
exception whose unwinding was interrupted with a 'landingpad' instruction (to be
added later).

llvm-svn: 136589
2011-07-31 06:30:59 +00:00
Bill Wendling ad088e6724 Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,
r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444,
r136445, r136446, r136253 pending review.

llvm-svn: 136556
2011-07-30 05:42:50 +00:00
Chandler Carruth 9d7feab3e0 Rewrite the CMake build to use explicit dependencies between libraries,
specified in the same file that the library itself is created. This is
more idiomatic for CMake builds, and also allows us to correctly specify
dependencies that are missed due to bugs in the GenLibDeps perl script,
or change from compiler to compiler. On Linux, this returns CMake to
a place where it can relably rebuild several targets of LLVM.

I have tried not to change the dependencies from the ones in the current
auto-generated file. The only places I've really diverged are in places
where I was seeing link failures, and added a dependency. The goal of
this patch is not to start changing the dependencies, merely to move
them into the correct location, and an explicit form that we can control
and change when necessary.

This also removes a serialization point in the build because we don't
have to scan all the libraries before we begin building various tools.
We no longer have a step of the build that regenerates a file inside the
source tree. A few other associated cleanups fall out of this.

This isn't really finished yet though. After talking to dgregor he urged
switching to a single CMake macro to construct libraries with both
sources and dependencies in the arguments. Migrating from the two macros
to that style will be a follow-up patch.

Also, llvm-config is still generated with GenLibDeps.pl, which means it
still has slightly buggy dependencies. The internal CMake
'llvm-config-like' macro uses the correct explicitly specified
dependencies however. A future patch will switch llvm-config generation
(when using CMake) to be based on these deps as well.

This may well break Windows. I'm getting a machine set up now to dig
into any failures there. If anyone can chime in with problems they see
or ideas of how to solve them for Windows, much appreciated.

llvm-svn: 136433
2011-07-29 00:14:25 +00:00
Eli Friedman c9a551ebed LangRef and basic memory-representation/reading/writing for 'cmpxchg' and
'atomicrmw' instructions, which allow representing all the current atomic
rmw intrinsics.

The allowed operands for these instructions are heavily restricted at the
moment; we can probably loosen it a bit, but supporting general
first-class types (where it makes sense) might get a bit complicated,
given how SelectionDAG works.

As an initial cut, these operations do not support specifying an alignment,
but it would be possible to add if we think it's useful. Specifying an
alignment lower than the natural alignment would be essentially
impossible to support on anything other than x86, but specifying a greater
alignment would be possible.  I can't think of any useful optimizations which
would use that information, but maybe someone else has ideas.

Optimizer/codegen support coming soon.

llvm-svn: 136404
2011-07-28 21:48:00 +00:00
Bill Wendling 4f027233d2 The personality function should be a Function* and not just a Value*.
llvm-svn: 136392
2011-07-28 21:14:13 +00:00
Bill Wendling 4c93488999 Make sure that the landingpad instruction takes a Constant* as the clause's value.
llvm-svn: 136326
2011-07-28 02:27:12 +00:00
Bill Wendling 6c923bb8d9 Merge the contents from exception-handling-rewrite to the mainline.
This adds the new instructions 'landingpad' and 'resume'.

llvm-svn: 136253
2011-07-27 20:18:04 +00:00
Eli Friedman fee02c6c13 Initial implementation of 'fence' instruction, the new C++0x-style replacement for llvm.memory.barrier.
This is just a LangRef entry and reading/writing/memory representation; optimizer+codegen support coming soon.

llvm-svn: 136009
2011-07-25 23:16:38 +00:00
Jay Foad d1b7849d49 Convert GetElementPtrInst to use ArrayRef.
llvm-svn: 135904
2011-07-25 09:48:08 +00:00
Jay Foad 2f5fc8c67d Make better use of ConstantExpr::getGetElementPtr's InBounds parameter.
llvm-svn: 135676
2011-07-21 15:15:37 +00:00
Jay Foad ed8db7d9df Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.

llvm-svn: 135673
2011-07-21 14:31:17 +00:00
Jeffrey Yasskin 7a16288157 Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ambiguity
errors like the one corrected by r135261.  Migrate all LLVM callers of the old
constructor to the new one.

llvm-svn: 135431
2011-07-18 21:45:40 +00:00
Frits van Bommel 717d7edd3e Migrate LLVM and Clang to use the new makeArrayRef(...) functions where previously explicit non-default constructors were used.
Mostly mechanical with some manual reformatting.

llvm-svn: 135390
2011-07-18 12:00:32 +00:00
Chris Lattner 229907cd11 land David Blaikie's patch to de-constify Type, with a few tweaks.
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Jay Foad 5bd375a6cc Convert CallInst and InvokeInst APIs to use ArrayRef.
llvm-svn: 135265
2011-07-15 08:37:34 +00:00
Jay Foad 57aa636794 Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.
llvm-svn: 135040
2011-07-13 10:26:04 +00:00
Jay Foad b804a2b751 Second attempt at de-constifying LLVM Types in FunctionType::get(),
StructType::get() and TargetData::getIntPtrType().

llvm-svn: 134982
2011-07-12 14:06:48 +00:00
Bill Wendling a78cd228c2 Revert r134893 and r134888 (and related patches in other trees). It was causing
an assert on Darwin llvm-gcc builds.

Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, li\
ne 2067.
etc.

http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354

--- Reverse-merging r134893 into '.':
U    include/llvm/Target/TargetData.h
U    include/llvm/DerivedTypes.h
U    tools/bugpoint/ExtractFunction.cpp
U    unittests/Support/TypeBuilderTest.cpp
U    lib/Target/ARM/ARMGlobalMerge.cpp
U    lib/Target/TargetData.cpp
U    lib/VMCore/Constants.cpp
U    lib/VMCore/Type.cpp
U    lib/VMCore/Core.cpp
U    lib/Transforms/Utils/CodeExtractor.cpp
U    lib/Transforms/Instrumentation/ProfilingUtils.cpp
U    lib/Transforms/IPO/DeadArgumentElimination.cpp
U    lib/CodeGen/SjLjEHPrepare.cpp
--- Reverse-merging r134888 into '.':
G    include/llvm/DerivedTypes.h
U    include/llvm/Support/TypeBuilder.h
U    include/llvm/Intrinsics.h
U    unittests/Analysis/ScalarEvolutionTest.cpp
U    unittests/ExecutionEngine/JIT/JITTest.cpp
U    unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
U    unittests/VMCore/PassManagerTest.cpp
G    unittests/Support/TypeBuilderTest.cpp
U    lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp
U    lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp
U    lib/VMCore/IRBuilder.cpp
G    lib/VMCore/Type.cpp
U    lib/VMCore/Function.cpp
G    lib/VMCore/Core.cpp
U    lib/VMCore/Module.cpp
U    lib/AsmParser/LLParser.cpp
U    lib/Transforms/Utils/CloneFunction.cpp
G    lib/Transforms/Utils/CodeExtractor.cpp
U    lib/Transforms/Utils/InlineFunction.cpp
U    lib/Transforms/Instrumentation/GCOVProfiling.cpp
U    lib/Transforms/Scalar/ObjCARC.cpp
U    lib/Transforms/Scalar/SimplifyLibCalls.cpp
U    lib/Transforms/Scalar/MemCpyOptimizer.cpp
G    lib/Transforms/IPO/DeadArgumentElimination.cpp
U    lib/Transforms/IPO/ArgumentPromotion.cpp
U    lib/Transforms/InstCombine/InstCombineCompares.cpp
U    lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
U    lib/Transforms/InstCombine/InstCombineCalls.cpp
U    lib/CodeGen/DwarfEHPrepare.cpp
U    lib/CodeGen/IntrinsicLowering.cpp
U    lib/Bitcode/Reader/BitcodeReader.cpp

llvm-svn: 134949
2011-07-12 01:15:52 +00:00
Jay Foad 56cc1530ee De-constify Types in FunctionType::get().
llvm-svn: 134888
2011-07-11 07:56:41 +00:00
Chris Lattner b1ed91f397 Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM.  One way to look at it
is through diffstat:
 109 files changed, 3005 insertions(+), 5906 deletions(-)

Removing almost 3K lines of code is a good thing.  Other advantages
include:

1. Value::getType() is a simple load that can be CSE'd, not a mutating
   union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
   uniques them.  This means that the compiler doesn't merge them structurally
   which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
   struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
   in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead 
   "const Type *" everywhere.

Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.  
"LLVM 3.0" is the right time to do this.

There are still some cleanups pending after this, this patch is large enough
as-is.

llvm-svn: 134829
2011-07-09 17:41:24 +00:00
Jay Foad 83be361b8a Replace the existing forms of ConstantArray::get() with a single form
that takes an ArrayRef.

llvm-svn: 133615
2011-06-22 09:24:39 +00:00
Chris Lattner cc19efaa97 Revamp the "ConstantStruct::get" methods. Previously, these were scattered
all over the place in different styles and variants.  Standardize on two
preferred entrypoints: one that takes a StructType and ArrayRef, and one that
takes StructType and varargs.

In cases where there isn't a struct type convenient, we now add a
ConstantStruct::getAnon method (whose name will make more sense after a few
more patches land).  

It would be "really really nice" if the ConstantStruct::get and 
ConstantVector::get methods didn't make temporary std::vectors.

llvm-svn: 133412
2011-06-20 04:01:31 +00:00
Chris Lattner 8936d2bfbc Remove support for parsing the "type i32" syntax for defining a numbered
top level type without a specified number.  This syntax isn't documented
and blocks forward progress.

llvm-svn: 133371
2011-06-19 00:03:46 +00:00
Chris Lattner 07037364cd revert r133368, apparently I missed the tests to be updated.
llvm-svn: 133369
2011-06-18 23:51:31 +00:00
Chris Lattner a7f74ad10e Remove support for parsing the "type i32" syntax for defining a numbered
top level type without a specified number.  This asmprinter has never
generated this, as you can tell by no tests being updated.  It also isn't
documented.

llvm-svn: 133368
2011-06-18 23:38:57 +00:00
Chris Lattner 0f214ebe5a eliminate the Type::getDescription() method, using "<<" instead. This
removes some gunk from LLVMContext.

llvm-svn: 133360
2011-06-18 21:18:23 +00:00
Matt Beaumont-Gay c3dfb5fa89 Fix -Asserts build
llvm-svn: 133305
2011-06-17 22:21:12 +00:00
Chris Lattner 9505356e3f remove another old and dead hunk of code.
llvm-svn: 133267
2011-06-17 17:40:18 +00:00
Chris Lattner 6bc5c89093 Stop accepting and ignoring attributes in function types. Attributes are applied
to functions and call/invokes, not to types.

llvm-svn: 133266
2011-06-17 17:37:13 +00:00
Chris Lattner 5756c16cdf make the asmparser reject function and type redefinitions. 'Merging' hasn't been
needed since llvm-gcc 3.4 days.

llvm-svn: 133248
2011-06-17 07:06:44 +00:00
Chris Lattner 59345c8b65 remove asmparser support for the old getresult instruction, which has been subsumed by extractvalue.
llvm-svn: 133247
2011-06-17 06:57:15 +00:00
Chris Lattner 33de427cd6 remove parser support for the obsolete "multiple return values" syntax, which
was replaced with return of a "first class aggregate".

llvm-svn: 133245
2011-06-17 06:49:41 +00:00
Chris Lattner 4649a73cc3 stop accepting begin/end around function bodies in the .ll parser, this isn't pascal anymore.
llvm-svn: 133244
2011-06-17 06:42:57 +00:00
Chris Lattner def1949c00 Remove support for using "foo" as symbols instead of %"foo". This is ancient
syntax and has been long obsolete.  As usual, updating the tests is the nasty
part of this.

llvm-svn: 133242
2011-06-17 06:36:20 +00:00
Chris Lattner 7810372577 Remove old backwards compatibility support from the parser for autoupgrading
the old malloc/free instructions, and for 'sext' and 'zext' as function 
attributes (they are spelled signext/zeroext now), and support for result
value attributes being specified after a function.

Additionally, diagnose invalid attributes on functions with an error message
instead of an abort in the verifier.

llvm-svn: 133229
2011-06-17 03:16:47 +00:00
John McCall 4b7a8d68ae Add a new function attribute, nonlazybind, which inhibits lazy-loading
optimizations when emitting calls to the function;  instead those calls may
use faster relocations which require the function to be immediately resolved
upon loading the dynamic object featuring the call.  This is useful when it
is known that the function will be called frequently and pervasively and
therefore there is no merit in delaying binding of the function.

Currently only implemented for x86-64, where it turns into a call through
the global offset table.

Patch by Dan Gohman, who assures me that he's going to add LangRef documentation
for this once it's committed.

llvm-svn: 133080
2011-06-15 20:36:13 +00:00
Nick Lewycky 5bcbd73c38 Teach the .ll parser to handle named metadata with non-simple names.
Unfortunately we can't follow what the rest of the language does (wrapping it
in double-quotes) because that would cause an ambiguity with metadata strings,
so instead we escape any unusual characters with \xx escaping.

llvm-svn: 133050
2011-06-15 06:37:58 +00:00
Nick Lewycky 2176cdc98c Refactor parsing of variable names (ie., %foo and @foo) since they have the same
rules. Also refactor "read string until quote" into its own function. No
functionality change!

llvm-svn: 132645
2011-06-04 18:16:26 +00:00
Rafael Espindola fc9bae6f8b Replace the -unwind-tables option with a per function flag. This is more
LTO friendly as we can now correctly merge files compiled with or without
-fasynchronous-unwind-tables.

llvm-svn: 132033
2011-05-25 03:44:17 +00:00
Benjamin Kramer 9c373c1c7a Remove unused variables caught by GCC's -Wunused-but-set-variable.
llvm-svn: 130755
2011-05-03 16:00:27 +00:00
Jay Foad 5514afe6b2 PR9214: Convert Metadata API to use ArrayRef.
llvm-svn: 129932
2011-04-21 19:59:31 +00:00
Bill Wendling 35a9c3cd72 Revert r129235 pending a vetting of the EH rewrite.
--- Reverse-merging r129235 into '.':
D    test/Feature/bb_attrs.ll
U    include/llvm/BasicBlock.h
U    include/llvm/Bitcode/LLVMBitCodes.h
U    lib/VMCore/AsmWriter.cpp
U    lib/VMCore/BasicBlock.cpp
U    lib/AsmParser/LLParser.cpp
U    lib/AsmParser/LLLexer.cpp
U    lib/AsmParser/LLToken.h
U    lib/Bitcode/Reader/BitcodeReader.cpp
U    lib/Bitcode/Writer/BitcodeWriter.cpp

llvm-svn: 129259
2011-04-10 23:18:04 +00:00
Bill Wendling 3d5450d809 Beginning of the Great Exception Handling Rewrite.
* Add a "landing pad" attribute to the BasicBlock.
* Modify the bitcode reader and writer to handle said attribute.

Later: The verifier will ensure that the landing pad attribute is used in the
appropriate manner. I.e., not applied to the entry block, and applied only to
basic blocks that are branched to via a `dispatch' instruction.

(This is a work-in-progress.)

llvm-svn: 129235
2011-04-10 00:04:27 +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
Tilmann Scheller 3bc0bcf3ad Use X86_thiscall calling convention for Win64 as well.
llvm-svn: 126934
2011-03-03 07:49:07 +00:00
Tilmann Scheller a3769f8021 Add Win64 thiscall calling convention.
llvm-svn: 126862
2011-03-02 19:29:22 +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
Chris Lattner 69229316aa convert ConstantVector::get to use ArrayRef.
llvm-svn: 125537
2011-02-15 00:14:00 +00:00
Chris Lattner 34442e6ebf revert my ConstantVector patch, it seems to have made the llvm-gcc
builders unhappy.

llvm-svn: 125504
2011-02-14 18:15:46 +00:00
Chris Lattner d9f5b88548 Switch ConstantVector::get to use ArrayRef instead of a pointer+size
idiom.  Change various clients to simplify their code.

llvm-svn: 125487
2011-02-14 07:55:32 +00:00
Chris Lattner a676c0fc77 implement .ll and .bc support for nsw/nuw on shl and exact on lshr/ashr.
Factor some code better.

llvm-svn: 125006
2011-02-07 16:40:21 +00:00
Chris Lattner 35315d065b enhance vmcore to know that udiv's can be exact, and add a trivial
instcombine xform to exercise this.

Nothing forms exact udivs yet though.  This is progress on PR8862

llvm-svn: 124992
2011-02-06 21:44:57 +00:00
Rafael Espindola 563eb4bb6c Move unnamed_addr after the function arguments on Sabre's request.
llvm-svn: 124209
2011-01-25 19:09:56 +00:00
Rafael Espindola 489e505adf Allow unnamed_addr on declarations.
llvm-svn: 123529
2011-01-15 08:15:00 +00:00
Rafael Espindola 026d152e58 Reject uses of unnamed_addr in declarations.
llvm-svn: 123358
2011-01-13 01:30:30 +00:00
Rafael Espindola 45e6c195d7 First step in fixing PR8927:
Add a unnamed_addr bit to global variables and functions. This will be used
to indicate that the address is not significant and therefore the constant
or function can be merged with others.

If an optimization pass can show that an address is not used, it can set this.

Examples of things that can have this set by the FE are globals created to
hold string literals and C++ constructors.

Adding unnamed_addr to a non-const global should have no effect unless
an optimization can transform that global into a constant.

Aliases are not allowed to have unnamed_addr since I couldn't figure
out any use for it.

llvm-svn: 123063
2011-01-08 16:42:36 +00:00
Nick Lewycky 0de20af7ba Add missing standard headers. Patch by Joerg Sonnenberger!
llvm-svn: 122193
2010-12-19 20:43:38 +00:00
Nick Lewycky b71afe82bf Add missing std:: prefixes to some calls. C++ doesn't require that <cfoo>
headers provide symbols outside namespace std and the LLVM coding standards
state that we should prefix all of them.

llvm-svn: 122192
2010-12-19 20:42:43 +00:00
Michael J. Spencer 39a0ffc394 MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> via an out parm.
llvm-svn: 121958
2010-12-16 03:29:14 +00:00
Michael J. Spencer 7b6fef82d4 Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec. And fix clients.
llvm-svn: 121379
2010-12-09 17:36:48 +00:00
Jay Foad 583abbc4df PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

llvm-svn: 121120
2010-12-07 08:25:19 +00:00
Charles Davis 22fe18625d Add a new 'hotpatch' attribute. This attribute will insert a two-byte no-op
instruction at the beginning of each function that has the attribute, allowing
the function to be easily hooked and/or patched.

llvm-svn: 117264
2010-10-25 15:37:09 +00:00
Duncan Sands 4c5c858d78 AlignLoc is never used for anything - zap it (gcc-4.6 warning).
llvm-svn: 117025
2010-10-21 16:07:10 +00:00
Benjamin Kramer 1dc34b48dd Eliminate some calls to Value::getNameStr.
llvm-svn: 116670
2010-10-16 11:28:23 +00:00
Nick Lewycky 912888fac9 Pacify a noisy compiler, and sink this variable declaration closer to its uses.
llvm-svn: 115206
2010-09-30 21:04:13 +00:00
Nick Lewycky 83e471180c Silence compiler warning.
llvm-svn: 115107
2010-09-29 23:32:20 +00:00
Benjamin Kramer c758311025 Push twines deeper into SourceMgr's error handling methods.
llvm-svn: 114847
2010-09-27 17:42:11 +00:00
Che-Liang Chiou 299479020a Add ret instruction to PTX backend
llvm-svn: 114788
2010-09-25 07:46:17 +00:00
Michael J. Spencer 93c9b2ea93 Revert "CMake: Get rid of LLVMLibDeps.cmake and export the libraries normally."
This reverts commit r113632

Conflicts:

	cmake/modules/AddLLVM.cmake

llvm-svn: 113819
2010-09-13 23:59:48 +00:00
Michael J. Spencer dc38d36ccb CMake: Get rid of LLVMLibDeps.cmake and export the libraries normally.
llvm-svn: 113632
2010-09-10 21:14:25 +00:00
Dale Johannesen baa5d045c9 Add X86 MMX type to bitcode and Type.
(The Ada bindings probably need it too, but all the
obvious places to change say "do not edit this file".)

llvm-svn: 113618
2010-09-10 20:55:01 +00:00
Chris Lattner 13ee795c42 remove unions from LLVM IR. They are severely buggy and not
being actively maintained, improved, or extended.

llvm-svn: 112356
2010-08-28 04:09:24 +00:00
Dan Gohman f0715b179a Add a comment explaining why this code doesn't just call
ParseMetadataValue.

llvm-svn: 111914
2010-08-24 14:35:45 +00:00
Dan Gohman 7c7f13a5e6 Add a comment explaining why this code is more complex than it
initially seems it should require.

llvm-svn: 111913
2010-08-24 14:31:06 +00:00
Dan Gohman c828c5465d Extend function-local metadata to be usable as attachments.
llvm-svn: 111895
2010-08-24 02:24:03 +00:00
Dan Gohman 338d9a4935 Give ParseInstructionMetadata access to the PerFunctionState object.
This is in preparation for generalizing its parsing of function-local
values.

llvm-svn: 111893
2010-08-24 02:05:17 +00:00
Bill Wendling 578ee4070c Create the new linker type "linker_private_weak_def_auto".
It's similar to "linker_private_weak", but it's known that the address of the
object is not taken. For instance, functions that had an inline definition, but
the compiler decided not to inline it. Note, unlike linker_private and
linker_private_weak, linker_private_weak_def_auto may have only default
visibility.  The symbols are removed by the linker from the final linked image
(executable or dynamic library).

llvm-svn: 111684
2010-08-20 22:05:50 +00:00
Dan Gohman 16a5d98c3a Introduce a new temporary MDNode concept. Temporary MDNodes are
not part of the IR, are not uniqued, and may be safely RAUW'd.
This replaces a variety of alternate mechanisms for achieving
the same effect.

llvm-svn: 111681
2010-08-20 22:02:26 +00:00
Dan Gohman 47053d972b Don't print the filename twice in file-not-found errors.
llvm-svn: 110179
2010-08-04 01:13:48 +00:00
Dan Gohman d566d2c7b5 Move MaximumAlignment to be a member of the Value class.
llvm-svn: 109891
2010-07-30 21:07:05 +00:00
Dan Gohman a7e5a24093 Define a maximum supported alignment value for load, store, and
alloca instructions (constrained by their internal encoding),
and add error checking for it. Fix an instcombine bug which
generated huge alignment values (null is infinitely aligned).
This fixes undefined behavior noticed by John Regehr.

llvm-svn: 109643
2010-07-28 20:12:04 +00:00
Eli Friedman 6cf5141824 Revert r109361; it's impossible to write a call with an argument with an
invalid type.

llvm-svn: 109365
2010-07-24 23:06:59 +00:00
Eli Friedman 9d9e4a83b5 Minor simplification.
llvm-svn: 109362
2010-07-24 23:00:59 +00:00
Eli Friedman 261c211089 Make the ll parser check that arguments have valid types.
llvm-svn: 109361
2010-07-24 23:00:26 +00:00
Dan Gohman 2637cc1a38 Make NamedMDNode not be a subclass of Value, and simplify the interface
for creating and populating NamedMDNodes.

llvm-svn: 109061
2010-07-21 23:38:33 +00:00
Dan Gohman 093cb79d4b Disallow null as a named metadata operand.
Make MDNode::destroy private.
Fix the one thing that used MDNode::destroy, outside of MDNode itself.

One should never delete or destroy an MDNode explicitly. MDNodes
implicitly go away when there are no references to them (implementation
details aside).

llvm-svn: 109028
2010-07-21 18:54:18 +00:00
Dan Gohman 8939ba337d Factor out metadata parsing into a separate function.
llvm-svn: 108343
2010-07-14 18:26:50 +00:00
Dan Gohman afd69cf5b7 Add support for empty named metadata too. This isn't particularly
useful, but it is nice for consistency.

llvm-svn: 108262
2010-07-13 19:42:44 +00:00
Dan Gohman 1e0213a758 Add support for empty metadata nodes: !{}.
llvm-svn: 108259
2010-07-13 19:33:27 +00:00
Bill Wendling 03bcd6ecc8 Implement the "linker_private_weak" linkage type. This will be used for
Objective-C metadata types which should be marked as "weak", but which the
linker will remove upon final linkage. However, this linkage isn't specific to
Objective-C.

For example, the "objc_msgSend_fixup_alloc" symbol is defined like this:

      .globl l_objc_msgSend_fixup_alloc
      .weak_definition l_objc_msgSend_fixup_alloc
      .section __DATA, __objc_msgrefs, coalesced
      .align 3
l_objc_msgSend_fixup_alloc:
       .quad   _objc_msgSend_fixup
       .quad   L_OBJC_METH_VAR_NAME_1

This is different from the "linker_private" linkage type, because it can't have
the metadata defined with ".weak_definition".

Currently only supported on Darwin platforms.

llvm-svn: 107433
2010-07-01 21:55:59 +00:00
Bill Wendling 3632171750 Revert r107205 and r107207.
llvm-svn: 107215
2010-06-29 22:34:52 +00:00
Bill Wendling 1767723dbe Introducing the "linker_weak" linkage type. This will be used for Objective-C
metadata types which should be marked as "weak", but which the linker will
remove upon final linkage. For example, the "objc_msgSend_fixup_alloc" symbol is
defined like this:

       .globl l_objc_msgSend_fixup_alloc
       .weak_definition l_objc_msgSend_fixup_alloc
       .section __DATA, __objc_msgrefs, coalesced
       .align 3
l_objc_msgSend_fixup_alloc:
        .quad   _objc_msgSend_fixup
        .quad   L_OBJC_METH_VAR_NAME_1

This is different from the "linker_private" linkage type, because it can't have
the metadata defined with ".weak_definition".

llvm-svn: 107205
2010-06-29 21:24:00 +00:00
Dan Gohman 2140a74979 Eliminate the restriction that the array size in an alloca must be i32.
This will help reduce the amount of casting required on 64-bit targets.

llvm-svn: 104911
2010-05-28 01:14:11 +00:00
Anton Korobeynikov 8f35fabbc1 Add support for thiscall calling convention.
Patch by Charles Davis and Steven Watanabe!

llvm-svn: 103902
2010-05-16 09:08:45 +00:00
Dan Gohman a2414ea190 Remove the API compatibility layer which converted add, sub, and mul
to fadd, fsub, and fmul, when used with a floating-point type. LLVM
has supported the new instructions since 2.6, so it's time to get
on board.

llvm-svn: 102971
2010-05-03 22:44:19 +00:00
Chris Lattner 95b0ff445c reject invalid comma stuff with a message. We reject the case in
PR6888 with:

$ llvm-as t.ll
llvm-as: t.ll:2:29: error: expected metadata or 'align'
 store <3 x i32> %x, i32 1, i32 1>, <3 x i32>* %p
                            ^

instead of:

$ llvm-as t.ll 
llvm-as: 

llvm-svn: 102154
2010-04-23 00:50:50 +00:00
Chris Lattner c239eb79bd reapply 'reject forward references to functions whose type don't match'
now that the testsuite has been updated.

llvm-svn: 101866
2010-04-20 04:49:11 +00:00
Daniel Dunbar c459a0ff81 Revert "reject forward references to functions whose type don't match", because DJG told me to!
llvm-svn: 101675
2010-04-17 21:24:55 +00:00
Chris Lattner 5a44950aae reject forward references to functions whose type don't match
up with the definition (and fix a broken testcase).  PR6491.

llvm-svn: 101670
2010-04-17 20:45:56 +00:00
Chris Lattner f60b74806f turn an assert into a proper check, fixing crash on invalid here:
$ llvm-as t.ll
llvm-as: t.ll:1:6: error: expected 'type' after '='
%0 = = type { i32, float, float, double }
     ^

PR6810.

llvm-svn: 100934
2010-04-10 18:01:25 +00:00
Chris Lattner 2e664bd915 fix a crash on invalid metadata, e.g.: call i32 @foo(), XXXX
We would return the error without inserting the new instruction
into the program, so it wouldn't get deallocated, and an abort
would trigger when the module was deleted. 

llvm-svn: 100602
2010-04-07 04:08:57 +00:00
Chris Lattner 97c4cb8947 enhance SMDiagnostic to also maintain a pointer to the SourceMgr.
Add a simplified constructor for clients that don't have locations
like "file not found" errors.

llvm-svn: 100538
2010-04-06 18:06:18 +00:00
Chris Lattner 3c799811c1 Give llvm::SourceMgr the ability to have a client-specified
diagnostic handler.

llvm-svn: 100503
2010-04-06 00:26:48 +00:00
Chris Lattner 0e45d24a4e stringref-ize the MemoryBuffer::get apis. This requires
a co-committed clang patch.

llvm-svn: 100485
2010-04-05 22:42:30 +00:00
Chris Lattner e04505e717 include header.
llvm-svn: 100087
2010-04-01 05:20:21 +00:00
Chris Lattner 8eff0157b2 rewrite handling of forward ref'd instruction metadata
to used deferred resolution instead of creating a temporary
node + rauw.  There is no reason to create the temporary
mdnode, then do rauw, then destroy it.

llvm-svn: 100086
2010-04-01 05:14:45 +00:00
Chris Lattner dba4346e91 no really, we don't need to copy strings around in the accessor.
llvm-svn: 100083
2010-04-01 04:53:22 +00:00
Chris Lattner ef0ec99665 eliminate a temporary smallvector
llvm-svn: 100082
2010-04-01 04:51:13 +00:00
Duncan Sands cbd43f89ac Introduce isOpaqueTy and use it rather than isa<OpaqueType>. Also, move some
methods to try to have the type predicates be more logically positioned.

llvm-svn: 96349
2010-02-16 14:50:09 +00:00
Duncan Sands 19d0b47b1f There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.

llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Duncan Sands 9dff9bec31 Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy.  Requested by Chris!

llvm-svn: 96223
2010-02-15 16:12:20 +00:00
Chris Lattner 392be58cad Add support for a union type in LLVM IR. Patch by Talin!
llvm-svn: 96011
2010-02-12 20:49:41 +00:00
Charles Davis be5557e86b Add a new function attribute, 'alignstack'. It will indicate (when the backends
implement support for it) that the stack should be forcibly realigned in the
prologue (and the process reversed in the epilogue).

llvm-svn: 95945
2010-02-12 00:31:15 +00:00
Jakob Stoklund Olesen 74bb06c0f0 Reintroduce the InlineHint function attribute.
This time it's for real! I am going to hook this up in the frontends as well.

The inliner has some experimental heuristics for dealing with the inline hint.
When given a -respect-inlinehint option, functions marked with the inline
keyword are given a threshold just above the default for -O3.

We need some experiments to determine if that is the right thing to do.

llvm-svn: 95466
2010-02-06 01:16:28 +00:00
Jeffrey Yasskin 091217be6f Kill ModuleProvider and ghost linkage by inverting the relationship between
Modules and ModuleProviders. Because the "ModuleProvider" simply materializes
GlobalValues now, and doesn't provide modules, it's renamed to
"GVMaterializer". Code that used to need a ModuleProvider to materialize
Functions can now materialize the Functions directly. Functions no longer use a
magic linkage to record that they're materializable; they simply ask the
GVMaterializer.

Because the C ABI must never change, we can't remove LLVMModuleProviderRef or
the functions that refer to it. Instead, because Module now exposes the same
functionality ModuleProvider used to, we store a Module* in any
LLVMModuleProviderRef and translate in the wrapper methods.  The bindings to
other languages still use the ModuleProvider concept.  It would probably be
worth some time to update them to follow the C++ more closely, but I don't
intend to do it.

Fixes http://llvm.org/PR5737 and http://llvm.org/PR5735.

llvm-svn: 94686
2010-01-27 20:34:15 +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
Devang Patel ac277eb930 Remove MetadataBase class because it is not adding significant value.
llvm-svn: 94243
2010-01-22 22:52:10 +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
Dan Gohman 9b85ae26b1 Make the parser include the lower level error message in its own error
message, to be more informative.

llvm-svn: 94072
2010-01-21 10:15:06 +00:00
Eric Christopher 8444d7536c Remove the InlineHint attribute. There are no current or planned
users.

llvm-svn: 93558
2010-01-15 21:36:30 +00:00
Victor Hernandez 9d75c966e0 Consolidate ConvertGlobalValIDToValue, ConvertGlobalOrMetadataValIDToValue, and ConvertValIDToValue into a more powerful ConvertValIDToValue() that does all three's work
llvm-svn: 93197
2010-01-11 22:31:58 +00:00
Victor Hernandez b8fd152d94 Compute isFunctionLocal in MDNode ctor or via argument in new function getWhenValsUnresolved().
Document PFS argument to ParseValID() and ConvertGlobalOrMetadataValIDToValue().

llvm-svn: 93108
2010-01-10 07:14:18 +00:00
Chris Lattner bbddd96406 fix PR5983, reject function bodies with no blocks per the grammar.
llvm-svn: 93067
2010-01-09 19:20:07 +00:00
Victor Hernandez 127286c58b When parsing function-local metadata, create a function-local MDNode
llvm-svn: 92838
2010-01-06 17:00:21 +00:00
Victor Hernandez dc6e65a6a8 Re-add parsing of function-local metadata; this time with testcase.
llvm-svn: 92793
2010-01-05 22:22:14 +00:00
Devang Patel 6edcd3994c Allow null to be an element of NamedMDNode. e.g. !llvm.stuff = !{!0, !1, null}
llvm-svn: 92783
2010-01-05 21:47:32 +00:00
Benjamin Kramer d2564e3afb Move remaining stuff to the isInteger predicate.
llvm-svn: 92771
2010-01-05 21:05:54 +00:00
Devang Patel e307348325 NamedMDNode is a collection MDNodes.
llvm-svn: 92761
2010-01-05 20:41:31 +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
Chris Lattner 16bafa6f14 remove some fixme's
llvm-svn: 92304
2009-12-30 06:00:36 +00:00
Chris Lattner 94b9c5a73b now that instruction metadata is only parsed in one place, eliminate the
parser-global MDsOnInst vector and make ParseInstructionMetadata return
its result by-ref through an argument like the entire rest of the parser.

llvm-svn: 92302
2009-12-30 05:48:36 +00:00
Chris Lattner b2f3950da7 reimplement ParseOptionalInfo as ParseOptionalCommaAlign, correctly
handle the comma case for metadata.

llvm-svn: 92301
2009-12-30 05:44:30 +00:00
Chris Lattner 5c42763452 rename ParseOptionalCustomMetadata -> ParseInstructionMetadata,
and make it non-optional.  This fixes the bug where we'd accept
and ignore a spurious comma after some instructions.

llvm-svn: 92300
2009-12-30 05:31:19 +00:00
Chris Lattner f4f0342b08 convert 4 more instructions over.
llvm-svn: 92299
2009-12-30 05:27:33 +00:00
Chris Lattner 77b89dc58b add facilities to start factoring instruction metadata parsing
out of each opcode's handler.  Change ret over so far.

llvm-svn: 92298
2009-12-30 05:23:43 +00:00
Chris Lattner 28f1eebe3e reimplement insertvalue/extractvalue metadata handling to not blindly
accept invalid input.  Actually add a testcase.

llvm-svn: 92297
2009-12-30 05:14:00 +00:00
Chris Lattner bafee45d2c remove two bogus calls that accepted metadata in the middle of insert/extract value
*constant exprs*.

llvm-svn: 92296
2009-12-30 05:04:46 +00:00
Chris Lattner eafe4de021 rename NamedOrCustomMD -> MetadataVar to follow conventions of all the rest of the code.
llvm-svn: 92295
2009-12-30 05:02:06 +00:00
Chris Lattner 1eed2d65c0 rename lltok::Metadata -> lltok::exclaim. We name tokens
after their syntactic form, not their semantic form.

llvm-svn: 92294
2009-12-30 04:56:59 +00:00
Chris Lattner fc58af26d5 rename MetadataCache -> NumberedMetadata to follow the convention
used by other things.  Convert it to a vector since it is a dense 
numbering.

llvm-svn: 92293
2009-12-30 04:51:58 +00:00
Chris Lattner a01ddfc2a3 rewrite ParseMDNodeVector to follow the normal patter used in the .ll parser.
llvm-svn: 92292
2009-12-30 04:42:57 +00:00
Chris Lattner 6dac02a4f7 rename ParseMDNode -> ParseMDNodeID, since it parses !42, not !{... } as you'd expect.
llvm-svn: 92291
2009-12-30 04:15:23 +00:00
Chris Lattner 0f3bb7b25e fix parsing of mdstring values.
llvm-svn: 92290
2009-12-30 04:13:37 +00:00
Chris Lattner 95471e49c5 remove the code added in r90497. It has several major issues and no tests.
llvm-svn: 92288
2009-12-30 02:20:07 +00:00
Chris Lattner 5b4a962bdd split t_Metadata into t_MDNode and t_MDString, eliminating some unsafe casting.
llvm-svn: 92287
2009-12-30 02:11:14 +00:00