Commit Graph

91 Commits

Author SHA1 Message Date
Dimitry Andric
7a06320990 Pull in r185616 from llvm trunk:
FastISel can only append to basic blocks.

  Compute the insertion point from the end of the basic block instead of
  skipping labels from the front.

  This caused failures in landing pads when live-in copies where inserted
  before instruction selection.

I missed this change in r252720; without it, certain compilation flags
can cause exception labels to not be generated, but still referenced,
leading to link errors.

Reported by:	zeising
MFC after:	3 days
2013-07-08 17:57:11 +00:00
Dimitry Andric
6beeb09142 Pull in r185594 from llvm trunk:
Add MachineBasicBlock::addLiveIn().

  This function adds a live-in physical register to an MBB and ensures
  that it is copied to a virtual register immediately.

Pull in r185615 from llvm trunk:

  Live-in copies go *after* EH_LABELs.

  This will soon be tested by exception handling working at all.

Pull in r185617 from llvm trunk:

  Simplify landing pad lowering.

  Stop using the ISD::EXCEPTIONADDR and ISD::EHSELECTION when lowering
  landing pad arguments. These nodes were previously legalized into
  CopyFromReg nodes, but that never worked properly because the
  CopyFromReg node weren't guaranteed to be  scheduled at the top of the
  basic block.

  This meant the exception pointer and selector registers could be
  clobbered before being copied to a virtual register.

  This patch copies the two physical registers to virtual registers at
  the beginning of the basic block, and lowers the landingpad instruction
  directly to two CopyFromReg nodes reading the *virtual* registers. This
  is safe because virtual registers don't get clobbered.

  A future patch will remove the ISD::EXCEPTIONADDR and ISD::EHSELECTION
  nodes.

Together, these changes fix llvm PR 16038 ('qt4 webcore file results in
"Bad machine code: Using an undefined physical register"'), and should
make it possible again to compile the www/qt4-webkit port again on the
i386 arch, without using a CPUTYPE=i686 or higher setting.
2013-07-04 20:10:33 +00:00
Dimitry Andric
0cf157db98 Pull in r185446 from clang trunk:
Fix to PR15826 - clang hits assert in clang::ASTContext::getASTRecordLayout.

Reported by:	glebius
2013-07-03 19:08:10 +00:00
Andrew Turner
b206d4e77f Work around an ARM EABI issue where clang would sometimes incorrectly align
the stack in a leaf function that uses TLS.

The issue is, when using TLS, the function is no longer a leaf as it calls
__aeabi_read_tp. With statically linked programs this is not an issue as
it doesn't make use of the stack, however with dynamically linked
applications we enter rtld which does use the stack and makes assumptions
about it's alignment.

This is only a temporary fix until a better patch can be made and submitted
upstream.
2013-07-02 08:04:41 +00:00
Dimitry Andric
707d0cef66 Pull in r183984 from llvm trunk:
Make PrologEpilogInserter save/restore all callee saved registers in
  functions which call __builtin_unwind_init()

  __builtin_unwind_init() is an undocumented gcc intrinsic which has
  this effect, and is used in libgcc_eh.

  Goes part of the way toward fixing PR8541.

This obsoletes the ugly hack to libgcc's unwind code from r245272, and
should also work for other arches, so revert the hack too.
2013-06-20 18:25:10 +00:00
Andrew Turner
1f4f127b99 Pull in r183926 from LLVM trunk:
Allow clang to build __clear_cache on ARM.

  __clear_cache is special. It needs no signature, but is a real function in
  compiler_rt or libgcc.

  Patch by Andrew Turner.

This allows us to build the __clear_cache function in compiler-rt.
2013-06-15 12:13:22 +00:00
Ed Schouten
d23f3f67b5 Pull in r184040 from upstream clang trunk:
Emit native implementations of atomic operations on FreeBSD/armv6.

  Just like on Linux, FreeBSD/armv6 assumes the system supports
  ldrex/strex unconditionally. It is also used by the kernel. We can
  therefore enable support for it, like we do on Linux.

  While there, change one of the unit tests to explicitly test against
  armv5 instead of armv7, as it actually tests whether libcalls are
  emitted.
2013-06-15 09:42:43 +00:00
Dimitry Andric
b6fdb9ab2f Pull in r181620 from llvm trunk:
[ms-inline asm] Fix a crasher when we fail on a direct match.

  The issue was that the MatchingInlineAsm and VariantID args to the
  MatchInstructionImpl function weren't being set properly.  Specifically, when
  parsing intel syntax, the parser thought it was parsing inline assembly in the
  at&t dialect; that will never be the case.

  The crash was caused when the emitter tried to emit the instruction, but the
  operands weren't set.  When parsing inline assembly we only set the opcode, not
  the operands, which is used to lookup the instruction descriptor.
  rdar://13854391 and PR15945

  Also, this commit reverts r176036.  Now that we're correctly parsing the intel
  syntax the pushad/popad don't match properly.  I've reimplemented that fix using
  a MnemonicAlias.

Pull in r183907 from llvm trunk:

  X86: Make the cmov aliases work with intel syntax too.

These commits make a number of Intel-style inline assembly mnemonics
aliases (occurring in several ports) work properly, which could cause
assertions otherwise.

Reported by:	kwm, bapt
2013-06-14 21:14:36 +00:00
Dimitry Andric
284c197886 Upgrade our copy of llvm/clang to 3.3 release.
Release notes are still in the works, these will follow soon.

MFC after:	1 month
2013-06-12 18:48:53 +00:00
Dimitry Andric
89d5a4380e Pull in r183297 from upstream llvm trunk:
PR15662: Optimized debug info produces out of order function
  parameters

  When a function is inlined we lazily construct the variables
  representing the function's parameters. After that, we add any
  remaining unused parameters.

  If the function doesn't use all the parameters, or uses them out of
  order, then the DWARF would produce them in that order, producing a
  parameter order that doesn't match the source.

  This fix causes us to always keep the arg variables at the start of
  the variable list & in the original order from the source.

Reported by:	avg
MFC after:	1 week
2013-06-05 19:46:39 +00:00
Ed Schouten
6306ff32fd Pull in r183033 and r183036 from LLVM trunk:
Add support for optimized (non-generic) atomic libcalls.

  For integer types of sizes 1, 2, 4 and 8, libcompiler-rt (and libgcc)
  provide atomic functions that pass parameters by value and return
  results directly.

  libgcc and libcompiler-rt only provide optimized libcalls for
  __atomic_fetch_*, as generic libcalls on non-integer types would make
  little sense. This means that we can finally make __atomic_fetch_*
  work
  on architectures for which we don't provide these operations as
  builtins
  (e.g. ARM).

  This should fix the dreaded "cannot compile this atomic library call
  yet" error that would pop up once every while.

This should make it possible for me to get C11 atomics working on all of
our platforms.
2013-06-01 08:07:09 +00:00
Dimitry Andric
b3eb0ffbc9 Pull in r182656 from upstream llvm trunk:
LoopVectorize: LoopSimplify can't canonicalize loops with an
  indirectbr in it, don't assert on those cases.

  Fixes PR16139.

This should fix clang assertion failures when optimizing at -O3, similar
to:

  Assertion failed: (TheLoop->getLoopPreheader() && "No preheader!!"),
  function canVectorize, file
  contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp, line 2171.

Reported by:	O. Hartmann <ohartman@zedat.fu-berlin.de>
PR:		ports/178332, ports/178977
MFC after:	3 days
2013-05-26 14:14:42 +00:00
Dimitry Andric
779aaa5564 Pull in r181286 from upstream llvm trunk:
LoopVectorize: getConsecutiveVector must respect signed arithmetic

  We were passing an i32 to ConstantInt::get where an i64 was needed and we must
  also pass the sign if we pass negatives numbers. The start index passed to
  getConsecutiveVector must also be signed.

  Should fix PR15882.

This should fix Firefox crashes some people have been reporting, when it
is compiled with -O3.
2013-05-13 07:02:15 +00:00
Dimitry Andric
5c47cd667d Pull in r180121 from upstream llvm trunk:
LoopVectorizer: Fix 15830. When scalarizing and unrolling stores make
  sure that the order in which the elements are scalarized is the same
  as the original order.
  This fixes a miscompilation in FreeBSD's regex library.

This should fix lib/libc/regex/regcomp.c at -O3 with clang 3.3 r178860
on CPUs with SSE.  Before this change, the vectorizer could incorrectly
rearrange the second loop in computejumps(), leading to possibly invalid
entries in the re_gets::charjump table.

The net result was that for example "sed s/@CC@/foo/" failed to work
correctly, leading to trouble with many configure scripts.
2013-04-23 18:58:39 +00:00
Dimitry Andric
139f7f9bf5 Upgrade our copy of llvm/clang to trunk r178860, in preparation of the
upcoming 3.3 release (branching and freezing expected in a few weeks).

Preliminary release notes can be found at the usual location:
<http://llvm.org/docs/ReleaseNotes.html>

An MFC is planned once the actual 3.3 release is finished.
2013-04-12 17:57:40 +00:00
Andrew Turner
e9a848494f Pull in r177252 from upstream clang trunk:
Make sure to use same EABI version for external assembler as for
 integrated as.

This allows us to use gcc on a world built with clang on ARM.
2013-03-20 08:34:30 +00:00
Dimitry Andric
b2a67e7b16 Pull in r175962 from upstream llvm trunk:
X86: Disable cmov-memory patterns on subtargets without cmov.

  Fixes PR15115.

For the i386 arch, this should enable cmov instructions only on
-march=pentiumpro and higher.  Since our default CPU is i486, cmov
instructions will now be disabled by default.

MFC after:	1 week
2013-02-23 22:48:12 +00:00
Dimitry Andric
2d97b320fb Pull in r172354 from upstream clang trunk:
Refactor the x86 CPU name logic in the driver and pass -march and -mcpu
  flag information down from the Clang driver into the Gold linker plugin
  for LTO. This allows specifying -march on the linker commandline and
  should hopefully have it pass all the way through to the LTO optimizer.

  Fixes PR14697.

Pull in r175919 from upstream clang trunk:

  Driver: Pass down the -march setting down to -cc1as on x86 too.

  The assembler historically didn't make use of any target features, but this has
  changed when support for old CPUs that don't support long nops was added.

This should fix the long nops that still occurred in crt*.o, and
possibly other object files, if the system was compiled for a CPU that
does not support those, such as Geode.

Note that gcc on i386 also does not pass through any -march, -mcpu or
-mtune setting to gas, but this has not caused any trouble yet, because
gas defaults to i386.

Reported by:	lev
MFC after:	1 week
2013-02-22 22:40:10 +00:00
Dimitry Andric
953290ffde Pull in r175360 from upstream llvm trunk:
MCParser: Reject .balign with non-pow2 alignments.

  GNU as rejects them and there are configure scripts in the wild that
  check if the assembler rejects ".align 3" to determine whether the
  alignment is in bytes or powers of two.

MFC after:	3 days
2013-02-19 17:53:32 +00:00
Dimitry Andric
74870cdedf Pull in r175057 from upstream llvm trunk:
X86: Disable generation of rep;movsl when %esi is used as a base pointer.

  This happens when there is both stack realignment and a dynamic alloca in the
  function. If we overwrite %esi (rep;movsl uses fixed registers) we'll lose the
  base pointer and the next register spill will write into oblivion.

  Fixes PR15249 and unbreaks firefox on i386/freebsd. Mozilla uses dynamic allocas
  and freebsd a 4 byte stack alignment.

MFC after:	1 week
2013-02-15 23:12:58 +00:00
Dimitry Andric
df5d2454a3 Pull in r170135 from upstream clang trunk:
Dont use/link ARCMT, StaticAnalyzer and Rewriter to clang when the user
  specifies not to. Dont build ASTMatchers with Rewriter disabled and
  StaticAnalyzer when it's disabled.

  Without all those three, the clang binary shrinks (x86_64) from ~36MB
  to ~32MB (unstripped).

To disable these clang components, and get a smaller clang binary built
and installed, set WITHOUT_CLANG_FULL in src.conf(5).  During the
initial stages of buildworld, those extra components are already
disabled automatically, to save some build time.

MFC after:	1 week
2013-02-02 22:28:29 +00:00
Pedro F. Giffuni
646a7fea0c Clean some 'svn:executable' properties in the tree.
Submitted by:	Christoph Mallon
MFC after:	3 days
2013-01-26 22:08:21 +00:00
Andrew Turner
0d526975ee Pull in r170096 from upstream clang trunk:
Initial support for FreeBSD on ARM.
2012-12-23 21:41:39 +00:00
Dimitry Andric
c80e6c4bec Upgrade our copy of llvm/clang to 3.2 release.
Release notes for llvm:
http://llvm.org/releases/3.2/docs/ReleaseNotes.html

Release notes for clang:
http://llvm.org/releases/3.2/tools/clang/docs/ReleaseNotes.html

MFC after:	2 weeks
2012-12-23 13:04:00 +00:00
Dimitry Andric
d1ff5f1ee2 Pull in r170353 from upstream llvm trunk:
Fix another SROA crasher, PR14601.

  This was a silly oversight, we weren't pruning allocas which were used
  by variable-length memory intrinsics from the set that could be widened
  and promoted as integers. Fix that.

This should fix the following assertion failure:

  Assertion failed: (CanSROA), function visitUsers, file
  /usr/src/lib/clang/libllvmscalaropts/../../../contrib/llvm/lib/Transforms/Scalar/SROA.cpp,
  line 2395.

Reported by:	gerald
2012-12-22 20:16:21 +00:00
Dimitry Andric
3861d79fd7 Upgrade our copy of llvm/clang to r168974, from upstream's release_32
branch.  This is effectively llvm/clang 3.2 RC2; the 3.2 release is
coming soon.
2012-12-03 19:24:08 +00:00
Dimitry Andric
39d9149396 Reduce LLVM's default stack alignment for i386 from 16 to 4 bytes, as
the FreeBSD ABI requires.  This is essentially a revert of upstream llvm
commit r126226, and it will be reverted by upstream too.

MFC after:	1 week
2012-11-09 18:56:27 +00:00
Dimitry Andric
762496516b Pull in r165377 from upstream llvm trunk:
X86: fcmov doesn't handle all possible EFLAGS, fall back to a branch
  for the others.

  Otherwise it will try to use SSE patterns and fail horribly if sse is
  disabled.

  Fixes PR14035.

This should fix the following assertion failure:

  Assertion failed: (Reg >= X86::FP0 && Reg <= X86::FP6 && "Expected FP
  register!"), function getFPReg, file
  contrib/llvm/lib/Target/X86/X86FloatingPoint.cpp, line 330.

which can show up when compiling contrib/compiler-rt, using -march=i686
through -march=pentium3 (CPU's which do support fcmov, but don't support
SSE2).

MFC after:	1 week
2012-10-30 22:09:53 +00:00
Ed Schouten
77d6b25fab Pull in r166498 from upstream clang trunk:
Add a new warning -Wmissing-variable-declarations, to warn about variables
defined without a previous declaration.  This is similar to
-Wmissing-prototypes, but for variables instead of functions.
2012-10-25 10:13:58 +00:00
Dimitry Andric
04a978f91b Pull in r165367 from upstream llvm trunk:
Make sure always-inline functions get inlined. <rdar://problem/12423986>

  Without this change, when the estimated cost for inlining a function with
  an "alwaysinline" attribute was lower than the inlining threshold, the
  getInlineCost function was returning that estimated cost rather than the
  special InlineCost::AlwaysInlineCost value. That is fine in the normal
  inlining case, but it can fail when the inliner considers the opportunity
  cost of inlining into an internal or linkonce-odr function. It may decide
  not to inline the always-inline function in that case. The fix here is just
  to make getInlineCost always return the special value for always-inline
  functions. I ran into this building clang with libc++. Tablegen failed to
  link because of an always-inline function that was not inlined. I have been
  unable to reduce the testcase down to a reasonable size.

This should fix the link errors that were reported when atf-run was
compiled with clang -stdlib=libc++.  In this case, at -O3 optimization,
some calls to basic_ios::clear() were not inlined, even when the
function was marked __always_inline__.

Reported by:	Jan Beich <jbeich@tormail.org>
MFC after:	1 week
2012-10-24 16:39:49 +00:00
Dimitry Andric
bf3d102133 Pull in r165878 from upstream llvm trunk:
X86: Disable long nops for all cpus prior to pentiumpro/i686.

This is the safest approach for now.  If you think long nops matter a
lot for performance, compile with -march=i686 or higher. :)

MFC after:	3 days
2012-10-22 17:47:37 +00:00
Dimitry Andric
6239851166 Pull in r164132 from upstream llvm trunk:
When creating MCAsmBackend pass the CPU string as well. In X86AsmBackend
  store this and use it to not emit long nops when the CPU is geode which
  doesnt support them.

  Fixes PR11212.

Pull in r164133 from upstream clang trunk:

  Follow up on llvm r164132.

This should prevent illegal instructions when building world on Geode
CPUs (e.g. Soekris).

MFC after:	3 days
2012-10-10 21:37:21 +00:00
Dimitry Andric
4802a8772c Pull in r163710 from upstream llvm trunk:
Add support for AMD Geode.

MFC after:	3 days
2012-10-10 21:29:00 +00:00
Dimitry Andric
75286ea4ca Pull in r164717 from upstream clang trunk:
Allow -MF to be used in combination with -E -M or -E -MM.

This should help with building the lang/ghc port.

MFC after:	1 week
2012-10-03 16:48:28 +00:00
Dimitry Andric
d2e1803774 Pull in r163967 from upstream llvm trunk:
X86: Emitting x87 fsin/fcos for sinf/cosf is not safe without unsafe
  fp math.

This should make clang emit calls to libm for sinf/cosf by default.

MFC after:	1 week
2012-09-15 17:02:05 +00:00
Dimitry Andric
3ed7dc5f46 Pull in r162360 from upstream clang trunk:
Merge existing attributes before processing pragmas in friend template
  declarations.
  Fixes pr13662.

This should help when building Firefox with libc++.
2012-08-23 18:14:59 +00:00
Dimitry Andric
7ae0e2c9f0 Upgrade our copy of llvm/clang to trunk r162107. With thanks to
Benjamin Kramer and Joerg Sonnenberger for their input and fixes.
2012-08-20 18:33:03 +00:00
Dimitry Andric
e07d856055 Similar to what is already done for Linux, make clang not complain about
unused -g, -emit-llvm or -w arguments when doing linking.  E.g. invoking
"clang -g foo.o -o foo" will now be silent.

Reported by:	Jakub Lach <jakub_lach@mailplus.pl>
MFC after:	1 week
2012-07-28 13:12:57 +00:00
Dimitry Andric
38bce0dde0 Similar to r238472, let clang pass --enable-new-dtags to the linker
invocation by default.  Also make sure --hash-style=both is passed for
the same arches as gcc, e.g. arm, sparc and x86.

X-MFC-with:	r238472
2012-07-28 12:50:25 +00:00
Dimitry Andric
f8079271e6 Pull in r159895 from upstream clang trunk:
When marking virtual functions as used for a class' vtable, mark all functions
  which will appear in the vtable as used, not just those ones which were
  declared within the class itself. Fixes an issue reported as comment#3 in
  PR12763 -- we sometimes assert in codegen if we try to emit a reference to a
  function declaration which we've not marked as referenced. This also matches
  gcc's observed behavior.

This should fix clang assertions when building certain components of the
LibreOffice port.

MFC after:	3 days
2012-07-13 21:48:01 +00:00
Dimitry Andric
3e2e1f1f0a Pull in r155978 from upstream llvm trunk:
Fix unintentional use of operator bool.

This enables llvm's bugpoint tool to build with libc++.

MFC after:	3 days
2012-06-01 06:50:37 +00:00
Dimitry Andric
96ccbf68a6 Pull in r156591 from upstream llvm trunk:
Allow unique_file to take a mode for file permissions, but default
  to user only read/write.

and r156592 from upstream clang trunk:

  For final output files create them with mode 0664 to match other
  compilers and expected defaults.

This should fix clang creating files with mode 0600.

Reported by:	James <james@hicag.org>
MFC after:	3 days
2012-05-29 21:59:09 +00:00
Dimitry Andric
baa749209e For clang, similar to r236137, enable gnu hash generation for dynamic
ELF binaries on x86.
2012-05-29 20:21:24 +00:00
Dimitry Andric
1cbbf59138 Pull in r157212 from upstream clang trunk:
Revert r115805. An array type is required to have a range type,
  however, the range can be unknown for the upper bound.

  Testcase to follow.

  Part of rdar://11457152

This should fix ctfconvert producing error messages during kernel
builds, similar to:

  ERROR: scsi_all.c: die 24561: failed to retrieve array bounds

These were caused by incorrect debug information for flexible array
members of structs.

MFC after:	3 days
2012-05-27 13:33:54 +00:00
Dimitry Andric
64cc5073b2 Upgrade our copy of llvm/clang to 3.1 release. Release notes can be
found at: http://llvm.org/releases/3.1/docs/ReleaseNotes.html

MFC after:	3 days
2012-05-23 21:48:49 +00:00
Dimitry Andric
cb4dff8563 Upgrade our copy of llvm/clang to r155985, from upstream's release_31
branch.  This brings us very close to the 3.1 release, which is planned
for May 14th.

MFC after:	2 weeks
2012-05-03 20:41:21 +00:00
Dimitry Andric
dff0c46c97 Upgrade our copy of llvm/clang to trunk r154661, in preparation of the
upcoming 3.1 release (expected in a few weeks).  Preliminary release
notes can be found at: <http://llvm.org/docs/ReleaseNotes.html>

MFC after:	2 weeks
2012-04-16 21:23:25 +00:00
Dimitry Andric
937b9d55e7 Pull in r145194 from upstream clang trunk:
Make our handling of MMX x SSE closer to what gcc does:

  * Enabling sse enables mmx.
  * Disabling (-mno-mmx) mmx, doesn't disable sse (we got this right already).
  * The order in not important. -msse -mno-mmx is the same as -mno-mmx -msse.

Some configure scripts depend on this.

PR:		i386/165968
MFC after:	3 days
2012-03-12 21:07:22 +00:00
Dimitry Andric
6bb1cadd56 Add a WITH_CLANG_EXTRAS option for src.conf(5), disabled by default,
that builds the following additional llvm/clang tools:

- bugpoint
- llc
- lli
- llvm-ar
- llvm-as
- llvm-bcanalyzer
- llvm-diff
- llvm-dis
- llvm-extract
- llvm-ld
- llvm-link
- llvm-mc
- llvm-nm
- llvm-objdump
- llvm-prof
- llvm-ranlib
- llvm-rtdyld
- llvm-stub
- macho-dump
- opt

These tools are mainly useful for people that want to manipulate llvm
bitcode (.bc) and llvm assembly language (.ll) files, or want to tinker
with llvm and clang themselves.

MFC after:	2 weeks
2012-02-05 23:56:22 +00:00
Dimitry Andric
462386c6b1 Pull in r148240 from upstream llvm trunk:
Make sure the non-SSE lowering for fences correctly clobbers EFLAGS.
  PR11768.

In particular, this fixes segfaults during the build of devel/icu on
i386.  The __sync_synchronize() builtin used for implementing icu's
internal barrier could lead to incorrect behaviour.

MFC after:	3 days
2012-01-20 19:18:11 +00:00