Commit Graph

183105 Commits

Author SHA1 Message Date
Lang Hames b7fbf593e6 [MCJIT] Make RTDyldMemoryManager::getSymbolAddress's behaviour more consistent.
This patch modifies RTDyldMemoryManager::getSymbolAddress(Name)'s behavior to
make it consistent with how clients are using it: Name should be mangled, and
getSymbolAddress should demangle it on the caller's behalf before looking the
name up in the process. This patch also fixes the one client
(MCJIT::getPointerToFunction) that had been passing unmangled names (by having
it pass mangled names instead).

Background:

RTDyldMemoryManager::getSymbolAddress(Name) has always used a re-try mechanism
when looking up symbol names in the current process. Prior to this patch
getSymbolAddress first tried to look up 'Name' exactly as the user passed it in
and then, if that failed, tried to demangle 'Name' and re-try the look up. The
implication of this behavior is that getSymbolAddress expected to be called with
unmangled names, and that handling mangled names was a fallback for convenience.
This is inconsistent with how clients (particularly the RuntimeDyldImpl
subclasses, but also MCJIT) usually use this API. Most clients pass in mangled
names, and succeed only because of the fallback case. For clients passing in
mangled names, getSymbolAddress's old behavior was actually dangerous, as it
could cause unmangled names in the process to shadow mangled names being looked
up.

For example, consider:

foo.c:

int _x = 7;
int x() { return _x; }

foo.o:

000000000000000c D __x
0000000000000000 T _x

If foo.c becomes part of the process (E.g. via dlopen("libfoo.dylib")) it will
add symbols 'x' (the function) and '_x' (the variable) to the process. However
jit clients looking for the function 'x' will be using the mangled function name
'_x' (note how function 'x' appears in foo.o). When getSymbolAddress goes
looking for '_x' it will find the variable instead, and return its address and
in place of the function, leading to JIT'd code calling the variable and
crashing (if we're lucky).

By requiring that getSymbolAddress be called with mangled names, and demangling
only when we're about to do a lookup in the process, the new behavior
implemented in this patch should eliminate any chance of names being shadowed
during lookup.

There's no good way to test this at the moment: This issue only arrises when
looking up process symbols (not JIT'd symbols). Any test case would have to
generate a platform-appropriate dylib to pass to llvm-rtdyld, and I'm not
aware of any in-tree tool for doing this in a portable way.

llvm-svn: 218187
2014-09-20 17:44:56 +00:00
Todd Fiala 21130fbc04 Fix lldb-gdbserver build.
Build break change by Paul Osmialowski.

Minor changes to argument passing (converted unintentional pass-by-value to pass-by-ref) by Todd.

llvm-svn: 218186
2014-09-20 17:34:48 +00:00
Justin Bogner 19a93ba814 llvm-cov: Allow creating CoverageMappings from filenames
llvm-svn: 218185
2014-09-20 17:19:52 +00:00
Justin Bogner 953e2407ed llvm-cov: Disentangle the coverage data logic from the display (NFC)
This splits the logic for actually looking up coverage information
from the logic that displays it. These were tangled rather thoroughly
so this change is a bit large, but it mostly consists of moving things
around. The coverage lookup logic itself now lives in the library,
rather than being spread between the library and the tool.

llvm-svn: 218184
2014-09-20 15:31:56 +00:00
Justin Bogner f584649ae3 llvm-cov: Move some reader debug output out of the tool.
This debug output is really for testing CoverageMappingReader, not the
llvm-cov tool. Move it to where it can be more useful.

llvm-svn: 218183
2014-09-20 15:31:51 +00:00
Lenny Maiorani 9eefc81219 Using a deque to manage the stack of nodes is faster here.
Vector is slow due to many reallocations as the size regularly changes in
  unpredictable ways. See the investigation provided on the mailing list for
  more information:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120116/135228.html

llvm-svn: 218182
2014-09-20 13:29:20 +00:00
Jason Molenda e59b0d2c48 Have CommandObject::CheckRequirements() report the largest missing
requirement for a command instead of the smallest.  e.g. if a command
requires a Target, Process, Thread, and Frame, and none of those
are available, report the largest -- Target -- as being missing
instead of the smallest -- Frame.

Patch by Paul Osmialowski.

llvm-svn: 218181
2014-09-20 09:14:31 +00:00
David Majnemer b8dbebb31c MC: Treat ReadOnlyWithRel and ReadOnlyWithRelLocal as ReadOnly for COFF
A problem with our old behavior becomes observable under x86-64 COFF
when we need a read-only GV which has an initializer which is referenced
using a relocation: we would mark the section as writable.  Marking the
section as writable interferes with section merging.

This fixes PR21009.

llvm-svn: 218179
2014-09-20 07:31:46 +00:00
Chandler Carruth 8c4cccd4aa [x86] Teach the v4f32 path of the new shuffle lowering to handle the
tricky case of single-element insertion into the zero lane of a zero
vector.

We can't just use the same pattern here as we do in every other vector
type because the general insertion logic can handle insertion into the
non-zero lane of the vector. However, in SSE4.1 with v4f32 vectors we
have INSERTPS that is a much better choice than the generic one for such
lowerings. But INSERTPS can do lots of other lowerings as well so
factoring its logic into the general insertion logic doesn't work very
well. We also can't just extract the core common part of the general
insertion logic that is faster (forming VZEXT_MOVL synthetic nodes that
lower to MOVSS when they can) because VZEXT_MOVL is often *faster* than
a blend while INSERTPS is slower! So instead we do a restrictive
condition on attempting to use the generic insertion logic to narrow it
to those cases where VZEXT_MOVL won't need a shuffle afterward and thus
will do better than INSERTPS. Then we try blending. Then we go back to
INSERTPS.

This still doesn't generate perfect code for some silly reasons that can
be fixed by tweaking the td files for lowering VZEXT_MOVL to use
XORPS+BLENDPS when available rather than XORPS+MOVSS when the input ends
up in a register rather than a load from memory -- BLENDPSrr has twice
the reciprocal throughput of MOVSSrr. Don't you love this ISA?

llvm-svn: 218177
2014-09-20 04:15:22 +00:00
Chandler Carruth 87dcf09367 [x86] Refactor the code for emitting INSERTPS to reuse the zeroable mask
analysis used elsewhere. This removes the last duplicate of this logic.
Also simplify the code here quite a bit. No functionality changed.

llvm-svn: 218176
2014-09-20 03:57:01 +00:00
Chandler Carruth 00389f3ed9 [x86] Generalize the single-element insertion lowering to work with
floating point types and use it for both v2f64 and v2i64 single-element
insertion lowering.

This fixes the last non-AVX performance regression test case I've gotten
of for the new vector shuffle lowering. There is obvious analogous
lowering for v4f32 that I'll add in a follow-up patch (because with
INSERTPS, v4f32 requires special treatment). After that, its AVX stuff.

llvm-svn: 218175
2014-09-20 03:32:25 +00:00
Chandler Carruth dba8444c2a [x86] Replace some duplicated logic reasoning about whether particular
vector lanes can be modeled as zero with a call to the new function that
computes a bit-vector representing that information.

No functionality changed here, but will allow doing more clever things
with the zero-test.

llvm-svn: 218174
2014-09-20 02:44:21 +00:00
Akira Hatanaka 416efb5f90 Fix bugs in cpuid.h.
This commit makes two changes:

- Remove the push and pop instructions that were saving and restoring %ebx
  before and after cpuid in 32-bit pic mode. We were doing this to ensure we
  don't lose the GOT address in pic register %ebx, but this isn't necessary
  because the GOT address is kept in a virtual register.

- In 64-bit mode, preserve base register %rbx around cpuid.

This fixes PR20311 and rdar://problem/17686779.

llvm-svn: 218173
2014-09-20 01:31:09 +00:00
David Majnemer f4dc456eef llvm-readobj: pretty-print special COFF section names
Print IMAGE_SYM_DEBUG and the like instead of (-2).

llvm-svn: 218172
2014-09-20 00:25:06 +00:00
Peter Collingbourne 975726345c Fix crash with an insertvalue that produces an empty object.
llvm-svn: 218171
2014-09-20 00:10:47 +00:00
Robin Morisset d780781b1f [X86] Erase some obsolete comments from README.txt
I just tried reproducing some of the optimization failures in README.txt in the
X86 backend, and many of them could not be reproduced. In general the entire
file appears quite bit-rotted, whatever interesting parts remain should be
moved to bugzilla, and the rest deleted. I did not spend the time to do that,
so I just deleted the few I tried reproducing which are obsolete, to save some
time to whoever will find the courage to do it.

llvm-svn: 218170
2014-09-19 23:56:46 +00:00
Eric Christopher b152660075 constify the TargetMachine being passed through the Mips subtarget
creation.

llvm-svn: 218169
2014-09-19 23:30:42 +00:00
Chris Bieneman 1efe80109a Converting InstrProf's error_category to a ManagedStatic to avoid static constructors and destructors.
llvm-svn: 218168
2014-09-19 23:19:24 +00:00
Duncan P. N. Exon Smith 75b64a551d DIBuilder: Delete dead code, NFC
There are two versions of `DIBuilder::createObjCIVar()`.  Delete the one
that's apparently dead.

llvm-svn: 218167
2014-09-19 23:17:58 +00:00
Nico Weber d191063c6c Follow-up to r214408: Warn on other callee-cleanup functions without prototype too.
According to lore, we used to verifier-fail on:

  void __thiscall f();
  int main() { f(1); }

So that's fixed now. System headers use prototype-less __stdcall functions,
so make that a warning that's DefaultError -- then it fires on regular code
but is suppressed in system headers.

Since it's used in system headers, we have codegen tests for this; massage
them slightly so that they still compile.

llvm-svn: 218166
2014-09-19 23:07:12 +00:00
Matt Arsenault de0253791c R600: Un-xfail a test which passes with pass disabled
llvm-svn: 218165
2014-09-19 23:02:20 +00:00
Matt Arsenault 5e5b242946 R600/SI: Un-xfail tests which work now
llvm-svn: 218164
2014-09-19 23:02:18 +00:00
Chris Bieneman 1a98490ce5 Converting SpillPlacement's BlockFrequency threshold to a ManagedStatic to avoid static constructors and destructors.
llvm-svn: 218163
2014-09-19 22:46:28 +00:00
Matt Arsenault a986554377 R600/SI: Un xfail a test that works now
llvm-svn: 218162
2014-09-19 22:42:40 +00:00
Juergen Ributzka 92e8978e40 [FastIsel][AArch64] Fix a think-o in address computation.
When looking through sign/zero-extensions the code would always assume there is
such an extension instruction and use the wrong operand for the address.

There was also a minor issue in the handling of 'AND' instructions. I
accidentially used a 'cast' instead of a 'dyn_cast'.

llvm-svn: 218161
2014-09-19 22:23:46 +00:00
Chris Bieneman 684981e454 Converting object's error_category to a ManagedStatic to avoid static constructors and destructors.
llvm-svn: 218160
2014-09-19 22:09:18 +00:00
Dario Domizioli c4fb8ca7aa Fix ctor/dtor aliases losing 'dllexport' (for Itanium ABI)
This patch makes sure that the dllexport attribute is transferred to the alias when such alias is created. It only affects the Itanium ABI because for the MSVC ABI a workaround is in place to not generate aliases of dllexport ctors/dtors.
A new CodeGenModule function is provided, CodeGenModule::setAliasAttributes, to factor the code for transferring attributes to aliases.

llvm-svn: 218159
2014-09-19 22:06:24 +00:00
Rui Ueyama 44a7c7f1aa [PECOFF] Set ordinal to alias atoms
Atoms are ordered in the output file by ordinal. File has file ordinal,
and atom has atom ordinal which is unique within the file.
No two atoms should have the same combination of ordinals.

However that contract was not satisifed for alias atoms. Alias atom
is defined by /alternatename:sym1=sym2. In this case sym1 is defined
as an alias for sym2. sym1 always got ordinal 0.

As a result LLD failed with an assertion failure.

This patch assigns ordinal to alias atoms.

llvm-svn: 218158
2014-09-19 21:58:54 +00:00
Jim Ingham 16ebdd6c1b Fix a thinko in how the RemoteiOS Platform looked up files in the SDK & other
platform locations.  We didn't always do an exhaustive search through all the 
platform locations, so we would have to read some files out of memory even though
they existed in the exploded shared cache or SDK.

<rdar://problem/18385947>

llvm-svn: 218157
2014-09-19 21:58:45 +00:00
Jim Ingham 03d1730aad We had to squirrel away the dyld module before doing ResolveExecutableModule, since
that would clear the module list, and then put it back by hand.  But we forgot to 
also put its sections back in the target SectionList, so we would jettison it as
unloaded when we finished handling the first real load event.  Add its sections.

<rdar://problem/18385947>

llvm-svn: 218156
2014-09-19 21:56:45 +00:00
Chandler Carruth a6b7178b9d [x86] Hoist a function up to the rest of the non-type-specific lowering
helpers, and re-flow the logic to use early exit and be a bit more
readable.

No functionality changed.

llvm-svn: 218155
2014-09-19 21:52:10 +00:00
Chris Bieneman 194cdff88e Converting the JITDebugLock mutex to a ManagedStatic to avoid the static constructor and destructor.
llvm-svn: 218154
2014-09-19 21:38:20 +00:00
Chandler Carruth f85c6dfa45 [x86] Hoist the actual lowering logic into a helper function to separate
it from the shuffle pattern matching logic.

Also cleaned up variable names, comments, etc. No functionality changed.

llvm-svn: 218152
2014-09-19 21:20:08 +00:00
Chris Bieneman 3b1fd57e05 Converting FuncNames to a ManagedStatic to avoid static constructors and destructors.
llvm-svn: 218151
2014-09-19 21:07:01 +00:00
Tom Stellard ff795900eb R600/SI: Fix config value for number of gprs
In r217636, the value stored in KernelInfo.Num[VS]GPRSs was changed from
the highest GPR index used to the number of gprs in order to be
consistent with the name of the variable.

The code writing the config values still assumed that the value in this
variable was the highest GPR index used, which caused the compiler to
over report the number of GPRs being used.

https://bugs.freedesktop.org/show_bug.cgi?id=84089

llvm-svn: 218150
2014-09-19 20:42:37 +00:00
Chris Bieneman 770163e4f3 Eliminating static destructor for the BitCodeErrorCategory by converting to a ManagedStatic.
Summary: This is part of the overall goal of removing static initializers from LLVM.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: chandlerc, llvm-commits

Differential Revision: http://reviews.llvm.org/D5416

llvm-svn: 218149
2014-09-19 20:29:02 +00:00
Zachary Turner 4171da5cfe Make sure to #include <atomic> when using std::atomic.
llvm-svn: 218148
2014-09-19 20:12:32 +00:00
Carlo Kok b77aba7708 Fix for 218140 for SBTarget.i, the added functions were in the wrong class definition
llvm-svn: 218147
2014-09-19 20:12:24 +00:00
Greg Clayton 615eb7e609 Test suite runs better again after recent fixes that would select a platform if a "file a.out" auto selected a different platform than the selected one.
Changes include:
- fix it so you can select the "host" platform using "platform select host"
- change all callbacks that create platforms to returns shared pointers
- fix TestImageListMultiArchitecture.py to restore the "host" platform by running "platform select host"
- Add a new "PlatformSP Platform::Find(const ConstString &name)" method to get a cached platform
- cache platforms that are created and re-use them instead of always creating a new one

llvm-svn: 218145
2014-09-19 20:11:50 +00:00
Jonathan Roelofs 4f1561a5dd Support newlib as libc++'s C library [locale part]
http://reviews.llvm.org/D5385

llvm-svn: 218144
2014-09-19 20:09:12 +00:00
Chandler Carruth 0fc0c22fa9 [x86] Fully generalize the zext lowering in the new vector shuffle
lowering to support both anyext and zext and to custom lower for many
different microarchitectures.

Using this allows us to get *exactly* the right code for zext and anyext
shuffles in all the vector sizes. For v16i8, the improvement is *huge*.
The new SSE2 test case added I refused to add before this because it was
sooooo muny instructions.

llvm-svn: 218143
2014-09-19 20:00:32 +00:00
Matt Arsenault 3f9b021c00 Add hsail and amdil64 to Triple
llvm-svn: 218142
2014-09-19 19:52:11 +00:00
Rafael Espindola 2ae4b631fc In the Itanium ABI, move stuff to the comdat of variables with static init.
Clang can already handle

-------------------------------------------
struct S {
  static const int x;
};
template<typename T> struct U {
  static const int k;
};
template<typename T> const int U<T>::k = T::x;

const int S::x = 42;
extern const int *f();
const int *g() { return &U<S>::k; }
int main() {
  return *f() + U<S>::k;
}

const int *f() { return &U<S>::k; }
-------------------------------------------

since r217264 which puts the .inint_array section in the same COMDAT
as the variable.

This patch allows the linker to more easily delete some dead code and data by
putting the guard variable and init function in the same COMDAT.

This is a fixed version of r218089.

llvm-svn: 218141
2014-09-19 19:43:18 +00:00
Carlo Kok 0fd6fd4fd4 Adds two new functions to SBTarget FindGlobalVariables and FindGlobalFunctions that lets you search by name, by regular expression and by starts with.
llvm-svn: 218140
2014-09-19 19:38:19 +00:00
Justin Bogner 5a6edad3d8 llvm-cov: Return unique_ptrs instead of filling objects (NFC)
Having create* functions return the object they create is more
readable than using an in-out parameter.

llvm-svn: 218139
2014-09-19 19:07:17 +00:00
Justin Bogner a829fde160 llvm-cov: Prevent a test from matching its own check lines
Since llvm-cov shows the source file in its output, be careful about
potentially matching the check lines themselves.

llvm-svn: 218138
2014-09-19 19:04:08 +00:00
Alexey Samsonov 25c2224922 [UBSan] Introduce more flexible __ubsan_default_options function instead of UBSAN_DEFAULT_OPTIONS compile definition
llvm-svn: 218137
2014-09-19 18:54:52 +00:00
Eric Christopher abc1297a70 Revert my earlier change to add "all" as a dependency to check. In
retrospect it really wasn't a good idea.

llvm-svn: 218136
2014-09-19 18:44:27 +00:00
Alexey Samsonov 760750c44f [UBSan] Optionally report summary in UBSan error reports.
By default summary is not printed if UBSan is run in a standalone mode,
but is printed if it's combined with another sanitizer (like ASan).

llvm-svn: 218135
2014-09-19 18:33:45 +00:00
David Blaikie db119544a2 Fix test case to be portable to different architectures.
llvm-svn: 218134
2014-09-19 18:31:25 +00:00