platform/upstream/llvm.git
5 years ago[AArch64][Outliner] Don't outline BTI instructions
Oliver Stannard [Tue, 5 Feb 2019 17:21:57 +0000 (17:21 +0000)]
[AArch64][Outliner] Don't outline BTI instructions

We can't outline BTI instructions, because they need to be the very first
instruction executed after an indirect call or branch. If we outline them, then
an indirect call might go to the branch to the outlined function, which will
fault.

Differential revision: https://reviews.llvm.org/D57753

llvm-svn: 353190

5 years ago[X86][AVX] Attempt to combine shuffles to subvector broadcast load
Simon Pilgrim [Tue, 5 Feb 2019 17:02:49 +0000 (17:02 +0000)]
[X86][AVX] Attempt to combine shuffles to subvector broadcast load

llvm-svn: 353189

5 years agoAArch64/GlobalISel: Don't clamp from 2 to 2
Matt Arsenault [Tue, 5 Feb 2019 16:57:18 +0000 (16:57 +0000)]
AArch64/GlobalISel: Don't clamp from 2 to 2

This is equivalent to clampMaxNumElements, but saves a check.

llvm-svn: 353188

5 years ago[WebAssembly] Use wasm-ld rather than lld with -flavor in tests. NFC.
Sam Clegg [Tue, 5 Feb 2019 16:53:33 +0000 (16:53 +0000)]
[WebAssembly] Use wasm-ld rather than lld with -flavor in tests. NFC.

Differential Revision: https://reviews.llvm.org/D57758

llvm-svn: 353187

5 years ago[OPENMP] issue error messages for multiple teams contructs in a target construct
Kelvin Li [Tue, 5 Feb 2019 16:43:00 +0000 (16:43 +0000)]
[OPENMP] issue error messages for multiple teams contructs in a target construct

The fix is to issue error messages if there are more than one
teams construct inside a target constructs.

#pragma omp target
{
  #pragma omp teams
  {  ...  }

  #pragma omp teams
  { ... }
}

llvm-svn: 353186

5 years ago[libc++] Control whether exceptions are enabled in the macOS trunk testing script
Louis Dionne [Tue, 5 Feb 2019 16:42:37 +0000 (16:42 +0000)]
[libc++] Control whether exceptions are enabled in the macOS trunk testing script

llvm-svn: 353185

5 years ago[opaque pointer types] Pass function types for runtime function calls.
James Y Knight [Tue, 5 Feb 2019 16:42:33 +0000 (16:42 +0000)]
[opaque pointer types] Pass function types for runtime function calls.

Emit{Nounwind,}RuntimeCall{,OrInvoke} have been modified to take a
FunctionCallee as an argument, and CreateRuntimeFunction has been
modified to return a FunctionCallee. All callers have been updated.

Additionally, CreateBuiltinFunction is removed, as it was redundant
with CreateRuntimeFunction after some previous changes.

Differential Revision: https://reviews.llvm.org/D57668

llvm-svn: 353184

5 years ago[WebAssembly] Object: Remove redundant method. NFC.
Sam Clegg [Tue, 5 Feb 2019 16:30:21 +0000 (16:30 +0000)]
[WebAssembly] Object: Remove redundant method. NFC.

Differential Revision: https://reviews.llvm.org/D57719

llvm-svn: 353183

5 years ago[X86][AVX] Add PR34041 subvector broadcast test cases
Simon Pilgrim [Tue, 5 Feb 2019 16:18:30 +0000 (16:18 +0000)]
[X86][AVX] Add PR34041 subvector broadcast test cases

llvm-svn: 353182

5 years ago[opaque pointer types] Fix the CallInfo passed to EmitCall in some
James Y Knight [Tue, 5 Feb 2019 16:05:50 +0000 (16:05 +0000)]
[opaque pointer types] Fix the CallInfo passed to EmitCall in some
edge cases.

Currently, EmitCall emits a call instruction with a function type
derived from the pointee-type of the callee. This *should* be the same
as the type created from the CallInfo parameter, but in some cases an
incorrect CallInfo was being passed.

All of these fixes were discovered by the addition of the assert in
EmitCall which verifies that the passed-in CallInfo matches the
Callee's function type.

As far as I know, these issues caused no bugs at the moment, as the
correct types were ultimately being emitted. But, some would become
problematic when pointee types are removed.

List of fixes:

* arrangeCXXConstructorCall was passing an incorrect value for the
  number of Required args, when calling an inheriting constructor
  where the inherited constructor is variadic. (The inheriting
  constructor doesn't actually get passed any of the user's args, but
  the code was calculating it as if it did).

* arrangeFreeFunctionLikeCall was not including the count of the
  pass_object_size arguments in the count of required args.

* OpenCL uses other address spaces for the "this" pointer. However,
  commonEmitCXXMemberOrOperatorCall was not annotating the address
  space on the "this" argument of the call.

* Destructor calls were being created with EmitCXXMemberOrOperatorCall
  instead of EmitCXXDestructorCall in a few places. This was a problem
  because the calling convention sometimes has destructors returning
  "this" rather than void, and the latter function knows about that,
  and sets up the types properly (through calling
  arrangeCXXStructorDeclaration), while the former does not.

* generateObjCGetterBody: the 'objc_getProperty' function returns type
  'id', but was being called as if it returned the particular
  property's type. (That is of course the *dynamic* return type, and
  there's a downcast immediately after.)

* OpenMP user-defined reduction functions (#pragma omp declare
  reduction) can be called with a subclass of the declared type. In
  such case, the call was being setup as if the function had been
  actually declared to take the subtype, rather than the base type.

Differential Revision: https://reviews.llvm.org/D57664

llvm-svn: 353181

5 years ago[NFC][libc++] Reindent function
Louis Dionne [Tue, 5 Feb 2019 15:46:52 +0000 (15:46 +0000)]
[NFC][libc++] Reindent function

llvm-svn: 353180

5 years ago[CGP] add test for unsigned subtract of 1 with overflow; NFC
Sanjay Patel [Tue, 5 Feb 2019 15:27:40 +0000 (15:27 +0000)]
[CGP] add test for unsigned subtract of 1 with overflow; NFC

llvm-svn: 353179

5 years ago[AArch64][x86] add tests for unsigned subtract with overflow; NFC
Sanjay Patel [Tue, 5 Feb 2019 15:26:42 +0000 (15:26 +0000)]
[AArch64][x86] add tests for unsigned subtract with overflow; NFC

llvm-svn: 353178

5 years agogn build: BUILD.gn files for clang-tidy and clang-apply-replacements
Nico Weber [Tue, 5 Feb 2019 15:14:38 +0000 (15:14 +0000)]
gn build: BUILD.gn files for clang-tidy and clang-apply-replacements

Patch from Mirko Bonadei <mbonadei@webrtc.org>!

Differential Revision: https://reviews.llvm.org/D57329

llvm-svn: 353177

5 years agoFix typo in comment, NFCI
Krasimir Georgiev [Tue, 5 Feb 2019 15:00:56 +0000 (15:00 +0000)]
Fix typo in comment, NFCI

llvm-svn: 353176

5 years agogn build: Merge r353072
Nico Weber [Tue, 5 Feb 2019 14:47:36 +0000 (14:47 +0000)]
gn build: Merge r353072

llvm-svn: 353175

5 years agoUpdate Xcode project after r353047
Stefan Granitz [Tue, 5 Feb 2019 14:41:26 +0000 (14:41 +0000)]
Update Xcode project after r353047

llvm-svn: 353174

5 years agoRecommit: Detect incorrect FileCheck variable CLI definition
Thomas Preud'homme [Tue, 5 Feb 2019 14:17:28 +0000 (14:17 +0000)]
Recommit: Detect incorrect FileCheck variable CLI definition

Summary:
While the backend code of FileCheck relies on definition of variable
from the command-line to have an equal sign '=' and a variable name
before that, the frontend does not actually enforce it. This leads to
FileCheck crashing when invoked with invalid syntax for the -D option.

This patch adds the missing validation in the frontend. It also makes
the -D option an AlwaysPrefix option to be able to detect -D=FOO as
being a define without variable and -D as missing its value.

Copyright:
- Linaro (changes in version 2 of revision D55940)
- GraphCore (changes in later versions)

Reviewers: jdenny

Subscribers: JonChesterfield, hiraditya, kristina, probinson,
llvm-commits

Differential Revision: https://reviews.llvm.org/D55940

llvm-svn: 353173

5 years agoRecommit: Add support for prefix-only CLI options
Thomas Preud'homme [Tue, 5 Feb 2019 14:17:16 +0000 (14:17 +0000)]
Recommit: Add support for prefix-only CLI options

Summary:
Add support for options that always prefix their value, giving an error
if the value is in the next argument or if the option is given a value
assignment (ie. opt=val). This is the desired behavior for the -D option
of FileCheck for instance.

Copyright:
- Linaro (changes in version 2 of revision D55940)
- GraphCore (changes in later versions and introduced when creating
  D56549)

Reviewers: jdenny

Subscribers: llvm-commits, probinson, kristina, hiraditya,
JonChesterfield

Differential Revision: https://reviews.llvm.org/D56549

llvm-svn: 353172

5 years ago[X86][SSE] Rename SimplifyDemandedVectorElts BLENDV tests
Simon Pilgrim [Tue, 5 Feb 2019 14:11:50 +0000 (14:11 +0000)]
[X86][SSE] Rename SimplifyDemandedVectorElts BLENDV tests

I'm going to be adding SimplifyDemandedBits tests shortly.

llvm-svn: 353171

5 years ago[MCA] Moved the logic that updates register dependencies from DispatchStage to Regist...
Andrea Di Biagio [Tue, 5 Feb 2019 14:11:41 +0000 (14:11 +0000)]
[MCA] Moved the logic that updates register dependencies from DispatchStage to RegisterFile. NFC

DispatchStage should always delegate to an object of class RegisterFile the task
of updating data dependencies.  ReadState and WriteState objects should not be
modified directly by DispatchStage.
This patch also renames stage IS_AVAILABLE to IS_DISPATCHED.

llvm-svn: 353170

5 years agogn build: Fix Python 3 write_vcsrevision script compatibility
Serge Guelton [Tue, 5 Feb 2019 13:01:12 +0000 (13:01 +0000)]
gn build: Fix Python 3 write_vcsrevision script compatibility

Trivial fix: decode was not called for all subprocess.check_output calls.

Commited on behalf of Andrew Boyarshin

Differential Revision: https://reviews.llvm.org/D57505

llvm-svn: 353168

5 years ago[X86][SSE] Add SimplifyDemandedVectorElts support for X86ISD::BLENDV
Simon Pilgrim [Tue, 5 Feb 2019 12:27:29 +0000 (12:27 +0000)]
[X86][SSE] Add SimplifyDemandedVectorElts support for X86ISD::BLENDV

llvm-svn: 353165

5 years ago[X86][SSE] Add tests showing missing SimplifyDemandedVectorElts support for X86ISD...
Simon Pilgrim [Tue, 5 Feb 2019 12:18:34 +0000 (12:18 +0000)]
[X86][SSE] Add tests showing missing SimplifyDemandedVectorElts support for X86ISD::BLENDV

llvm-svn: 353164

5 years ago[NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 default
Nemanja Ivanovic [Tue, 5 Feb 2019 12:05:53 +0000 (12:05 +0000)]
[NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 default

When Clang/LLVM is built with the CLANG_DEFAULT_STD_CXX CMake macro that sets
the default standard to something other than C++14, there are a number of lit
tests that fail as they rely on the C++14 default.
This patch just adds the language standard option explicitly to such test cases.

Differential revision: https://reviews.llvm.org/D57581

llvm-svn: 353163

5 years ago[MCA] Simplify the logic in method WriteState::addUser. NFCI
Andrea Di Biagio [Tue, 5 Feb 2019 11:36:55 +0000 (11:36 +0000)]
[MCA] Simplify the logic in method WriteState::addUser. NFCI

In some cases, it is faster to just grow the set of 'Users' rather than
performing a llvm::find_if every time a new user is added to
the set. No functional change intended.

llvm-svn: 353162

5 years ago[Expressions] Fix -Wreorder warning from r353149
Krasimir Georgiev [Tue, 5 Feb 2019 11:35:45 +0000 (11:35 +0000)]
[Expressions] Fix -Wreorder warning from r353149

Summary:
```
ClangExpressionDeclMap.cpp:72:60: error: field 'm_struct_vars' will be initialized after field 'm_ctx_obj' [-Werror,-Wreorder]
      m_result_delegate(result_delegate), m_parser_vars(), m_struct_vars(),
```

Reviewers: bkramer, aleksandr.urakov

Reviewed By: aleksandr.urakov

Subscribers: aleksandr.urakov

Differential Revision: https://reviews.llvm.org/D57742

llvm-svn: 353161

5 years agoFix ICE on reference binding with mismatching addr spaces.
Anastasia Stulova [Tue, 5 Feb 2019 11:32:58 +0000 (11:32 +0000)]
Fix ICE on reference binding with mismatching addr spaces.

When we attempt to add an addr space qual to a type already
qualified by an addr space ICE is triggered. Before creating
a type with new address space, remove the old addr space.

Fixing PR38614!

Differential Revision: https://reviews.llvm.org/D57524

llvm-svn: 353160

5 years ago[DebugInfo][NFCI] Split salvageDebugInfo into helper functions
Jeremy Morse [Tue, 5 Feb 2019 11:11:28 +0000 (11:11 +0000)]
[DebugInfo][NFCI] Split salvageDebugInfo into helper functions

Some use cases are appearing where salvaging is needed that does not
correspond to an instruction being deleted -- for example an instruction
being sunk, or a Value not being available in a block being isel'd.

Enable more fine grained control over how salavging occurs by splitting
the logic into helper functions, separating things that are specific to
working on DbgVariableIntrinsics from those specific to interpreting IR
and building DIExpressions.

Differential Revision: https://reviews.llvm.org/D57696

llvm-svn: 353156

5 years agoFix format string in bindings/go/llvm/ir_test.go (PR40561)
Hans Wennborg [Tue, 5 Feb 2019 11:01:54 +0000 (11:01 +0000)]
Fix format string in bindings/go/llvm/ir_test.go (PR40561)

The test started failing for me recently. I don't see any changes around
this code, so maybe it's my local go version that changed or something.

The error seems real to me: we're trying to print an Attribute with %d.
The test talks about "attribute masks" I'm not sure what that refers to,
but I suppose we could print the raw pointer value, since that's
what the test seems to be comparing.

Differential revision: https://reviews.llvm.org/D57672

llvm-svn: 353155

5 years ago[X86][AVX] Attempt to share broadcasts of different widths (PR39454)
Simon Pilgrim [Tue, 5 Feb 2019 10:58:43 +0000 (10:58 +0000)]
[X86][AVX] Attempt to share broadcasts of different widths (PR39454)

If we have broadcasts of different vector widths, keep the longest vector width and extract subvectors for the shorter vectors (which should be free).

Differential Revision: https://reviews.llvm.org/D57663

llvm-svn: 353154

5 years ago[CostModel][X86] Add UMUL fixed point cost tests
Simon Pilgrim [Tue, 5 Feb 2019 10:55:38 +0000 (10:55 +0000)]
[CostModel][X86] Add UMUL fixed point cost tests

llvm-svn: 353153

5 years ago[CGP] Add support for sinking operands to their users, if they are free.
Florian Hahn [Tue, 5 Feb 2019 10:27:40 +0000 (10:27 +0000)]
[CGP] Add support for sinking operands to their users, if they are free.

This patch improves code generation for some AArch64 ACLE intrinsics. It adds
support to CGP to duplicate and sink operands to their user, if they can be
folded into a target instruction, like zexts and sub into usubl. It adds a
TargetLowering hook shouldSinkOperands, which looks at the operands of
instructions to see if sinking is profitable.

I decided to add a new target hook, as for the sinking to be profitable,
at least on AArch64, we have to look at multiple operands of an
instruction, instead of looking at the users of a zext for example.

The sinking is done in CGP, because it works around an instruction
selection limitation. If instruction selection is not limited to a
single basic block, this patch should not be needed any longer.

Alternatively this could be done in the LoopSink pass, which tries to
undo LICM for instructions in blocks that are not executed frequently.

Note that we do not force the operands to sink to have a single user,
because we duplicate them before sinking. Therefore this is only
desirable if they really can be done for free. Additionally we could
consider the impact on live ranges later on.

This should fix https://bugs.llvm.org/show_bug.cgi?id=40025.

As for performance, we have internal code that uses intrinsics and can
be speed up by 10% by this change.

Reviewers: SjoerdMeijer, t.p.northover, samparker, efriedma, RKSimon, spatel

Reviewed By: samparker

Differential Revision: https://reviews.llvm.org/D57377

llvm-svn: 353152

5 years ago[ARM GlobalISel] Support G_GEP for Thumb2
Diana Picus [Tue, 5 Feb 2019 10:21:37 +0000 (10:21 +0000)]
[ARM GlobalISel] Support G_GEP for Thumb2

Same as ARM, but use a different opcode in the instruction selection.

llvm-svn: 353151

5 years agoFix the sphinx buildbot after D54429
Kristof Umann [Tue, 5 Feb 2019 10:19:39 +0000 (10:19 +0000)]
Fix the sphinx buildbot after D54429

llvm-svn: 353150

5 years ago[Expressions] Add support of expressions evaluation in some object's context
Aleksandr Urakov [Tue, 5 Feb 2019 09:14:36 +0000 (09:14 +0000)]
[Expressions] Add support of expressions evaluation in some object's context

Summary:
This patch adds support of expression evaluation in a context of some object.
Consider the following example:
```
struct S {
  int a = 11;
  int b = 12;
};

int main() {
  S s;
  int a = 1;
  int b = 2;
  // We have stopped here
  return 0;
}
```
This patch allows to do something like that:
```
lldb.frame.FindVariable("s").EvaluateExpression("a + b")
```
and the result will be `33` (not `3`) because fields `a` and `b` of `s` will be
used (not locals `a` and `b`).

This is achieved by replacing of `this` type and object for the expression. This
has some limitations: an expression can be evaluated only for values located in
the debuggee process memory (they must have an address of `eAddressTypeLoad`
type).

Reviewers: teemperor, clayborg, jingham, zturner, labath, davide, spyffe, serge-sans-paille

Reviewed By: jingham

Subscribers: abidh, lldb-commits, leonid.mashinskiy

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D55318

llvm-svn: 353149

5 years agoPreviously if the user configured their build but then changed
Dan Liew [Tue, 5 Feb 2019 08:47:28 +0000 (08:47 +0000)]
Previously if the user configured their build but then changed
LLVM_ENABLED_PROJECT and reconfigured it had no effect on what
projects were actually built. This was very confusing behaviour. The
reason for this is that the value of the `LLVM_TOOL_<PROJECT>_BUILD`
variables are already set.

The problem here is that we have two sources of truth:

* The projects listed in LLVM_ENABLE_PROJECTS.
* The projects enabled/disabled with LLVM_TOOL_<PROJECT>_BUILD.

At configure time we have no real way of knowing which source of truth
the user wants so we apply the following heuristic:

If the user ever sets `LLVM_ENABLE_PROJECTS` in the CMakeCache then that
is used as the single source of truth and we force the
`LLVM_TOOL_<PROJECT>_BUILD` CMake cache variables to have the
appropriate values that match the contents of the
`LLVM_ENABLE_PROJECTS`. If the user never sets `LLVM_ENABLE_PROJECTS`
then they can continue to use and set the `LLVM_TOOL_<PROJECT>_BUILD`
variables as the "source of truth".

The problem with this approach is that if the user ever tries to use
both `LLVM_ENABLE_PROJECTS` and `LLVM_TOOL_<PROJECT>_BUILD` for the same
build directory then any user set value for `LLVM_TOOL_<PROJECT>_BUILD`
variables will get overwriten, likely without the user noticing.

Hopefully the above shouldn't matter in practice because the
LLVM_TOOL_<PROJECT>_BUILD variables are not documented, but
LLVM_ENABLE_PROJECTS is.

We should probably deprecate the `LLVM_TOOL_<PROJECT>_BUILD`
variables at some point by turning them into to regular CMake
variables that don't live in the CMake cache.

Differential Revision: https://reviews.llvm.org/D57535

llvm-svn: 353148

5 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Tue, 5 Feb 2019 08:30:48 +0000 (08:30 +0000)]
[NFC] fix trivial typos in comments

llvm-svn: 353147

5 years ago[COFF] Avoid O(n^2) accesses into PartialSections
Martin Storsjo [Tue, 5 Feb 2019 08:16:10 +0000 (08:16 +0000)]
[COFF] Avoid O(n^2) accesses into PartialSections

For MinGW, unique partial sections are much more common, e.g.
comdat functions get sections named e.g. text$symbol.

A moderate sized example of this contains over 200K Chunks
which create 174K unique PartialSections. Prior to SVN r352928
(D57574), linking this took around 1,5 seconds for me, while
it afterwards takes around 13 minutes. After this patch, the
linking time is back to what it was before.

The std::find_if in findPartialSection will do a linear scan of
the whole container until a match is found. To use something like
binary_search or the std::set container's own methods, we'd need
to already have a PartialSection*.

Reinstate a proper map instead of having a set with a custom sorting
comparator.

Differential Revision: https://reviews.llvm.org/D57666

llvm-svn: 353146

5 years ago[MinGW] Hook up the --no-insert-timestamp option
Martin Storsjo [Tue, 5 Feb 2019 08:16:06 +0000 (08:16 +0000)]
[MinGW] Hook up the --no-insert-timestamp option

This fixes PR40582.

Patch by Georg Koppen!

Differential Revision: https://reviews.llvm.org/D57679

llvm-svn: 353145

5 years ago[DAG][NFC] Add unit tests.
Clement Courbet [Tue, 5 Feb 2019 08:00:17 +0000 (08:00 +0000)]
[DAG][NFC] Add unit tests.

In preparation for D57541.

llvm-svn: 353144

5 years ago[DAG] BaseIndexOffset: FrameIndexSDNodes with the same FrameIndex compare equal.
Clement Courbet [Tue, 5 Feb 2019 07:36:20 +0000 (07:36 +0000)]
[DAG] BaseIndexOffset: FrameIndexSDNodes with the same FrameIndex compare equal.

Reviewers: niravd

Subscribers: arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57692

llvm-svn: 353143

5 years ago[X86] Change MS inline asm clobber list filter to check for 'fpsr' instead of 'fpsw...
Craig Topper [Tue, 5 Feb 2019 06:13:14 +0000 (06:13 +0000)]
[X86] Change MS inline asm clobber list filter to check for 'fpsr' instead of 'fpsw' after D57641.

Summary: The backend used to print the x87 FPSW register as 'fpsw', but gcc inline asm uses 'fpsr'. After D57641, the backend now uses 'fpsr' to match.

Reviewers: rnk

Reviewed By: rnk

Subscribers: eraman, cfe-commits, llvm-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57642

llvm-svn: 353142

5 years ago[X86] Connect the default fpsr and dirflag clobbers in inline assembly to the registe...
Craig Topper [Tue, 5 Feb 2019 06:13:06 +0000 (06:13 +0000)]
[X86] Connect the default fpsr and dirflag clobbers in inline assembly to the registers we have defined for them.

Summary:
We don't currently map these constraints to physical register numbers so they don't make it to the MachineIR representation of inline assembly.

This could have problems for proper dependency tracking in the machine schedulers though I don't have a test case that shows that.

Reviewers: rnk

Reviewed By: rnk

Subscribers: eraman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57641

llvm-svn: 353141

5 years agoFix double curlies
JF Bastien [Tue, 5 Feb 2019 05:34:12 +0000 (05:34 +0000)]
Fix double curlies

Pointed out by Arthur in D57624.

llvm-svn: 353140

5 years agogn build: Upgrade to NDK r19.
Peter Collingbourne [Tue, 5 Feb 2019 05:10:19 +0000 (05:10 +0000)]
gn build: Upgrade to NDK r19.

NDK r19 includes a sysroot that can be used directly by the compiler
without creating a standalone toolchain, so we just need a handful
of flags to point Clang there.

Differential Revision: https://reviews.llvm.org/D57733

llvm-svn: 353139

5 years ago[X86] Add test case from PR40529. NFC
Craig Topper [Tue, 5 Feb 2019 04:48:23 +0000 (04:48 +0000)]
[X86] Add test case from PR40529. NFC

llvm-svn: 353138

5 years ago[CMake] Update lit test configuration
Petr Hosek [Tue, 5 Feb 2019 04:44:03 +0000 (04:44 +0000)]
[CMake] Update lit test configuration

There are several changes:
- Don't stringify Pythonized bools (that's why we're Pythonizing them)
- Support specifying target and sysroot via CMake variables
- Use consistent spelling for --target, --sysroot, --gcc-toolchain

llvm-svn: 353137

5 years ago[LSR] Check SCEV on isZero() after extend. PR40514
Max Kazantsev [Tue, 5 Feb 2019 04:30:37 +0000 (04:30 +0000)]
[LSR] Check SCEV on isZero() after extend. PR40514

When LSR first adds SCEVs to BaseRegs, it only does it if `isZero()` has
returned false. In the end, in invocation of `InsertFormula`, it asserts that
all values there are still not zero constants. However between these two
points, it makes some transformations, in particular extends them to wider
type.

SCEV does not give us guarantee that if `S` is not a constant zero, then
`sext(S)` is also not a constant zero. It might have missed some optimizing
transforms when it was calculating `S` and then made them when it took `sext`.
For example, it may happen if previously optimizing transforms were limited
by depth or somehow else.

This patch adds a bailout when we may end up with a zero SCEV after extension.

Differential Revision: https://reviews.llvm.org/D57565
Reviewed By: samparker

llvm-svn: 353136

5 years ago[SamplePGO] More pipeline changes when flattened profile used in ThinLTO postlink
Teresa Johnson [Tue, 5 Feb 2019 04:09:19 +0000 (04:09 +0000)]
[SamplePGO] More pipeline changes when flattened profile used in ThinLTO postlink

Summary:
Follow on to D54819/r351476.

We also don't need to perform extra InstCombine pass when we aren't
loading the sample profile in the ThinLTO backend because we have a
flattened sample profile.

Additionally, for consistency and clarity, when we aren't reloading the
sample profile, perform ICP in the same location as non-sample PGO
backends. To this end I have moved the ICP invocation for non-SamplePGO
ThinLTO down into buildModuleSimplificationPipeline (partly addresses
the FIXME where we were previously setting this up).

Reviewers: wmi

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57705

llvm-svn: 353135

5 years agoFix narrowing issue from r353129
Richard Trieu [Tue, 5 Feb 2019 02:26:03 +0000 (02:26 +0000)]
Fix narrowing issue from r353129

llvm-svn: 353134

5 years ago[WebAssembly] Fix indentation after adding IsCanonical property (NFC)
Heejin Ahn [Tue, 5 Feb 2019 01:59:49 +0000 (01:59 +0000)]
[WebAssembly] Fix indentation after adding IsCanonical property (NFC)

llvm-svn: 353132

5 years ago[WebAssembly] Make disassembler always emit most canonical name.
Wouter van Oortmerssen [Tue, 5 Feb 2019 01:19:45 +0000 (01:19 +0000)]
[WebAssembly] Make disassembler always emit most canonical name.

Summary:
There are a few instructions that all map to the same opcode, so
when disassembling, we have to pick one. That was just the first one
before (the except_ref variant in the case of "call"), now it is the
one marked as IsCanonical in tablegen, or failing that, the shortest
name (which is typically the "canonical" one).

Also introduced a canonical "end" instruction for this purpose.

Reviewers: dschuff, tlively

Subscribers: sbc100, jgravelle-google, aheejin, llvm-commits, sunfish

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57713

llvm-svn: 353131

5 years ago[Python2 to Python 3] Fix print -> print().
Davide Italiano [Tue, 5 Feb 2019 00:59:57 +0000 (00:59 +0000)]
[Python2 to Python 3] Fix print -> print().

llvm-svn: 353130

5 years ago[SamplePGO][NFC] Minor improvement to replace a temporary vector with a
Wei Mi [Tue, 5 Feb 2019 00:57:50 +0000 (00:57 +0000)]
[SamplePGO][NFC] Minor improvement to replace a temporary vector with a
brace-enclosed init list.

Differential Revision: https://reviews.llvm.org/D57726

llvm-svn: 353129

5 years agoGlobalISel: Fix verifier crashing on non-register operands
Matt Arsenault [Tue, 5 Feb 2019 00:53:22 +0000 (00:53 +0000)]
GlobalISel: Fix verifier crashing on non-register operands

Also correct the wording of error on subregisters.

llvm-svn: 353128

5 years ago[WebAssembly] memory.copy
Thomas Lively [Tue, 5 Feb 2019 00:49:55 +0000 (00:49 +0000)]
[WebAssembly] memory.copy

Summary: Depends on D57495.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish

Differential Revision: https://reviews.llvm.org/D57498

llvm-svn: 353127

5 years ago[analyzer] Creating standard Sphinx documentation
Kristof Umann [Tue, 5 Feb 2019 00:39:33 +0000 (00:39 +0000)]
[analyzer] Creating standard Sphinx documentation

The lack of documentation has been a long standing issue in the Static Analyzer,
and one of the leading reasons behind this was a lack of good documentation
infrastucture.

This lead serious drawbacks, such as
* Not having proper release notes for years
* Not being able to have a sensible auto-generated checker documentations (which
lead to most of them not having any)
* The HTML website that has to updated manually is a chore, and has been
outdated for a long while
* Many design discussions are now hidden in phabricator revisions

This patch implements a new documentation infrastucture using Sphinx, like most
of the other subprojects in LLVM. It transformed some pages as a proof-of-
concept, with many others to follow in later patches. The eventual goal is to
preserve the original website's (https://clang-analyzer.llvm.org/) frontpage,
but move everything else to the new format.

Some other ideas, like creating a unipage for each checker (similar to how
clang-tidy works now), are also being discussed.

Patch by Dániel Krupp!

Differential Revision: https://reviews.llvm.org/D54429

llvm-svn: 353126

5 years agoGlobalISel: Consolidate load/store legalization
Matt Arsenault [Tue, 5 Feb 2019 00:26:12 +0000 (00:26 +0000)]
GlobalISel: Consolidate load/store legalization

The fewerElementsVectors implementation for load/stores
handles the scalar reduction case just as well, so drop
the redundant code in narrowScalar. This also introduces
support for narrowing irregular size breakdowns for
scalars.

llvm-svn: 353125

5 years ago[DAGCombiner] Discard pointer info when combining extract_vector_elt of a vector...
Craig Topper [Tue, 5 Feb 2019 00:22:23 +0000 (00:22 +0000)]
[DAGCombiner] Discard pointer info when combining extract_vector_elt of a vector load when the index isn't constant

Summary:
If the index isn't constant, this transform inserts a multiply and an add on the index to calculating the base pointer for a scalar load. But we still create a memory operand with an offset of 0 and the size of the scalar access. But the access is really to an unknown offset within the original access size.

This can cause the machine scheduler to incorrectly calculate dependencies between this load and other accesses. In the case we saw, there was a 32 byte vector store that was split into two 16 byte stores, one with offset 0 and one with offset 16. The size of the memory operand for both was 16. The scheduler correctly detected the alias with the offset 0 store, but not the offset 16 store.

This patch discards the pointer info so we don't incorrectly detect aliasing. I wasn't sure if we could keep using the original offset and size without risking some other transform on the load changing the size.

I tried to reduce a test case, but there's still a lot of memory operations needed to get the scheduler to do the bad reordering. So it looked pretty fragile to maintain.

Reviewers: efriedma

Reviewed By: efriedma

Subscribers: arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57616

llvm-svn: 353124

5 years ago[SamplePGO] Minor efficiency improvement in samplePGO ICP
Teresa Johnson [Tue, 5 Feb 2019 00:18:38 +0000 (00:18 +0000)]
[SamplePGO] Minor efficiency improvement in samplePGO ICP

Summary:
When attaching prof metadata to promoted direct calls in SamplePGO
mode, no need to construct and use a SmallVector to pass a single count
to the ArrayRef parameter, we can simply use a brace-enclosed init list.

This made a small but consistent improvement for a ThinLTO backend
compile I was measuring.

Reviewers: wmi

Subscribers: mehdi_amini, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57706

llvm-svn: 353123

5 years agoGlobalISel: Implement narrowScalar for select
Matt Arsenault [Tue, 5 Feb 2019 00:13:44 +0000 (00:13 +0000)]
GlobalISel: Implement narrowScalar for select

Don't handle vector conditions.

I think this can be merged in the future with
fewerElementsVectorSelect, although this becomes slightly tricky with
a vector condition.

llvm-svn: 353122

5 years agoGlobalISel: Combine g_extract with g_merge_values
Matt Arsenault [Mon, 4 Feb 2019 23:41:59 +0000 (23:41 +0000)]
GlobalISel: Combine g_extract with g_merge_values

Try to use the underlying source registers.

This enables legalization in more cases where some irregular
operations are widened and others narrowed.

This seems to make the test_combines_2 AArch64 test worse, since the
MERGE_VALUES has multiple uses. Since this should be required for
legalization, a hasOneUse check is probably inappropriate (or maybe
should only be used if the merge is legal?).

llvm-svn: 353121

5 years ago[Sanitizers] UBSan unreachable incompatible with Kernel ASan
Julian Lettner [Mon, 4 Feb 2019 23:37:50 +0000 (23:37 +0000)]
[Sanitizers] UBSan unreachable incompatible with Kernel ASan

Summary:
This is a follow up for https://reviews.llvm.org/D57278. The previous
revision should have also included Kernel ASan.

rdar://problem/40723397

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57711

llvm-svn: 353120

5 years ago[llvm-readobj] Fix readobj test expectation broken in rL353109. NFC.
Sam Clegg [Mon, 4 Feb 2019 23:36:38 +0000 (23:36 +0000)]
[llvm-readobj] Fix readobj test expectation broken in rL353109. NFC.

llvm-svn: 353119

5 years agoRevert "[PATCH] [TargetLibraryInfo] Update run time support for Windows"
Evandro Menezes [Mon, 4 Feb 2019 23:34:50 +0000 (23:34 +0000)]
Revert "[PATCH] [TargetLibraryInfo] Update run time support for Windows"

This reverts accidental commit ff5527718d5d3b9966f6e8948866c0dc15ffcf3c.

llvm-svn: 353118

5 years ago[ADT] Refactor the Windows query functions (NFC)
Evandro Menezes [Mon, 4 Feb 2019 23:34:38 +0000 (23:34 +0000)]
[ADT] Refactor the Windows query functions (NFC)

Increase reuse in the query functions for Windows.

llvm-svn: 353117

5 years ago[OBJC] Add attribute to mark Objective C class as non-lazy
Joe Daniels [Mon, 4 Feb 2019 23:32:55 +0000 (23:32 +0000)]
[OBJC] Add attribute to mark Objective C class as non-lazy

A non-lazy class will be initialized eagerly when the Objective-C runtime is
loaded. This is required for certain system classes which have instances allocated in
non-standard ways, such as the classes for blocks and constant strings.
Adding this attribute is essentially equivalent to providing a trivial
+load method but avoids the (fairly small) load-time overheads associated
with defining and calling such a method.

Differential Revision: https://reviews.llvm.org/D56555

llvm-svn: 353116

5 years ago[SemaObjC] Don't infer the availabilty of +new from -init if the receiver has Class...
Erik Pilkington [Mon, 4 Feb 2019 23:30:57 +0000 (23:30 +0000)]
[SemaObjC] Don't infer the availabilty of +new from -init if the receiver has Class type

rdar://47713266

Differential revision: https://reviews.llvm.org/D57712

llvm-svn: 353115

5 years ago[PATCH] [TargetLibraryInfo] Update run time support for Windows
Evandro Menezes [Mon, 4 Feb 2019 23:29:41 +0000 (23:29 +0000)]
[PATCH] [TargetLibraryInfo] Update run time support for Windows

It seems that the run time for Windows has changed and supports more math
functions than before.  Since LLVM requires at least VS2015, I assume that
this is the run time that would be redistributed with programs built with
Clang.  Thus, I based this update on the header file `math.h` that
accompanies it.

This patch addresses the PR40541.  Unfortunately, I have no access to a
Windows development environment to validate it.

llvm-svn: 353114

5 years agoGlobalISel: Enforce operand types for constants
Matt Arsenault [Mon, 4 Feb 2019 23:29:31 +0000 (23:29 +0000)]
GlobalISel: Enforce operand types for constants

A number of of tests were using imm operands, not cimm. Since CSE
relies on the exact ConstantInt* pointer used, and implicit
conversions are generally evil, also enforce the bitsize of the types.

llvm-svn: 353113

5 years agoGlobalISel: Verify g_select
Matt Arsenault [Mon, 4 Feb 2019 23:29:16 +0000 (23:29 +0000)]
GlobalISel: Verify g_select

Factor the common vector element consistency check many instructions
need out, although this makes the error messages worse.

llvm-svn: 353112

5 years agoMachineVerifier: Move verification of G_* instructions to function
Matt Arsenault [Mon, 4 Feb 2019 23:29:11 +0000 (23:29 +0000)]
MachineVerifier: Move verification of G_* instructions to function

llvm-svn: 353111

5 years ago[tsan] Disable fgetpwent_r to work around performance issues
Vitaly Buka [Mon, 4 Feb 2019 23:25:55 +0000 (23:25 +0000)]
[tsan] Disable fgetpwent_r to work around performance issues

This was missed from D54041 when SANITIZER_INTERCEPT_FGETPWENT_R was branched from SANITIZER_INTERCEPT_GETPWENT_R

llvm-svn: 353110

5 years ago[WebAssembly] MC: Mark more function aliases as functions
Sam Clegg [Mon, 4 Feb 2019 23:07:34 +0000 (23:07 +0000)]
[WebAssembly] MC: Mark more function aliases as functions

Aliases of functions are now marked as function symbols even if
they are bitcast to some other other non-function type.
This is important for WebAssembly where object and function
symbols can't alias each other.

Fixes PR38866

Differential Revision: https://reviews.llvm.org/D57538

llvm-svn: 353109

5 years ago[libFuzzer][Windows] Clean up RawPrint
Jonathan Metzman [Mon, 4 Feb 2019 23:01:06 +0000 (23:01 +0000)]
[libFuzzer][Windows] Clean up RawPrint

Summary:
Use `_write` instead of the deprecated alias `write` on Windows.
Also, remove comment saying RawPrint is untested on Windows.

Reviewers: vitalybuka

Reviewed By: vitalybuka

Subscribers: vitalybuka

Differential Revision: https://reviews.llvm.org/D57589

llvm-svn: 353108

5 years agoMIR: Validate LLT types when parsing
Matt Arsenault [Mon, 4 Feb 2019 22:59:56 +0000 (22:59 +0000)]
MIR: Validate LLT types when parsing

llvm-svn: 353107

5 years ago[CGP] fix bogus test names/comments; NFC
Sanjay Patel [Mon, 4 Feb 2019 22:37:05 +0000 (22:37 +0000)]
[CGP] fix bogus test names/comments; NFC

Inverted operand 0 and operand 1.

llvm-svn: 353106

5 years ago[WebAssembly] Update test to match new readobj output. NFC.
Sam Clegg [Mon, 4 Feb 2019 22:34:07 +0000 (22:34 +0000)]
[WebAssembly] Update test to match new readobj output. NFC.

Differential Revision: https://reviews.llvm.org/D57715

llvm-svn: 353105

5 years ago[llvm-readobj] Report more WebAssembly symbol info
Sam Clegg [Mon, 4 Feb 2019 22:27:46 +0000 (22:27 +0000)]
[llvm-readobj] Report more WebAssembly symbol info

Differential Revision: https://reviews.llvm.org/D57695

llvm-svn: 353104

5 years ago[CGP] add tests for usubo; NFC
Sanjay Patel [Mon, 4 Feb 2019 22:27:08 +0000 (22:27 +0000)]
[CGP] add tests for usubo; NFC

llvm-svn: 353103

5 years agoGlobalISel: Fix not calling observer when legalizing bitcount ops
Matt Arsenault [Mon, 4 Feb 2019 22:26:33 +0000 (22:26 +0000)]
GlobalISel: Fix not calling observer when legalizing bitcount ops

This was hiding bugs from never legalizing the source type.

llvm-svn: 353102

5 years agoAMDGPU: Don't rematerialize mov with implicit operands
Matt Arsenault [Mon, 4 Feb 2019 22:26:21 +0000 (22:26 +0000)]
AMDGPU: Don't rematerialize mov with implicit operands

This was pulling the mov used for register indexing on gfx9 out of the
loop.

llvm-svn: 353101

5 years ago[SanitizerCoverage] Clang crashes if user declares `__sancov_lowest_stack` variable
Julian Lettner [Mon, 4 Feb 2019 22:06:30 +0000 (22:06 +0000)]
[SanitizerCoverage] Clang crashes if user declares `__sancov_lowest_stack` variable

Summary:
If the user declares or defines `__sancov_lowest_stack` with an
unexpected type, then `getOrInsertGlobal` inserts a bitcast and the
following cast fails:
```
Constant *SanCovLowestStackConstant =
       M.getOrInsertGlobal(SanCovLowestStackName, IntptrTy);
SanCovLowestStack = cast<GlobalVariable>(SanCovLowestStackConstant);
```

This variable is a SanitizerCoverage implementation detail and the user
should generally never have a need to access it, so we emit an error
now.

rdar://problem/44143130

Reviewers: morehouse

Differential Revision: https://reviews.llvm.org/D57633

llvm-svn: 353100

5 years agogn build: Windows: use a more standard format for PDB filenames
David Major [Mon, 4 Feb 2019 21:27:38 +0000 (21:27 +0000)]
gn build: Windows: use a more standard format for PDB filenames

The current build was producing names like llvm-undname.exe.pdb, which looks unusual to me at least. This switches them to the more common llvm-undname.pdb style.

Differential Revision: https://reviews.llvm.org/D57613

llvm-svn: 353099

5 years agogn build: Revert r353094 (bad merge)
David Major [Mon, 4 Feb 2019 21:25:13 +0000 (21:25 +0000)]
gn build: Revert r353094 (bad merge)

llvm-svn: 353098

5 years ago[InstCombine] Cleanup the TFE/LWE check in AMDGPU SimplifyDemanded
Nicolai Haehnle [Mon, 4 Feb 2019 21:24:19 +0000 (21:24 +0000)]
[InstCombine] Cleanup the TFE/LWE check in AMDGPU SimplifyDemanded

Summary:
The fix added in r352904 is not quite correct, or rather misleading:

1. When the texfailctrl (TFC) argument was non-constant, the fix assumed
   non-TFE/LWE, which is incorrect.

2. Regardless, this code path cannot even be hit for correct
   TFE/LWE-enabled calls, because those return a struct. Added
   a test case for those for completeness.

Change-Id: I92d314dbc67a2670f6d7adaab765ef45f56a49cf

Reviewers: hliao, dstuttard, arsenm

Subscribers: kzhuravl, jvesely, wdng, yaxunl, tpr, t-tye, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57681

llvm-svn: 353097

5 years ago[X86] Add test case for report_fatal_error added in r352699.
Craig Topper [Mon, 4 Feb 2019 21:24:15 +0000 (21:24 +0000)]
[X86] Add test case for report_fatal_error added in r352699.

r352699 replaced an llvm_unreachable with a report_fatal_error. This patch adds a test case for it.

llvm-svn: 353096

5 years ago[CodeGen][ARC][SystemZ][WebAssembly] Use MachineInstr::isInlineAsm in more places...
Craig Topper [Mon, 4 Feb 2019 21:24:13 +0000 (21:24 +0000)]
[CodeGen][ARC][SystemZ][WebAssembly] Use MachineInstr::isInlineAsm in more places instead of just comparing opcode. NFCI

I'm looking at adding a second INLINEASM opcode for better modeling asm-goto
as a terminator. Using the existing predicate will reduce teh number of
places that will need to use the new opcode.

llvm-svn: 353095

5 years agogn build: Windows: use a more standard format for PDB filenames
David Major [Mon, 4 Feb 2019 21:20:25 +0000 (21:20 +0000)]
gn build: Windows: use a more standard format for PDB filenames

The current build was producing names like llvm-undname.exe.pdb, which looks unusual to me at least. This switches them to the more common llvm-undname.pdb style.

Differential Revision: https://reviews.llvm.org/D57613

llvm-svn: 353094

5 years agogn build: Windows: write PDBs when is_debug
David Major [Mon, 4 Feb 2019 21:13:43 +0000 (21:13 +0000)]
gn build: Windows: write PDBs when is_debug

Without /DEBUG, the /Zi doesn't on its own create PDB files.

And since ninja runs multiple compilations in parallel, we need /FS to prevent contention on PDBs.

Differential Revision: https://reviews.llvm.org/D57612

llvm-svn: 353093

5 years ago[clang-tidy] Handle unions with existing default-member-init
Malcolm Parsons [Mon, 4 Feb 2019 21:09:31 +0000 (21:09 +0000)]
[clang-tidy] Handle unions with existing default-member-init

Summary:
clang-tidy's modernize-use-default-member-init was crashing for unions
with an existing default member initializer.

Fixes PR40492

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, riccibruno, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D57665

llvm-svn: 353092

5 years ago[Tablegen][DAG]: Fix build breakage when LLVM_ENABLE_DAGISEL_COV=1
Aditya Nandakumar [Mon, 4 Feb 2019 21:06:24 +0000 (21:06 +0000)]
[Tablegen][DAG]: Fix build breakage when LLVM_ENABLE_DAGISEL_COV=1

LLVM_ENABLE_DAGISEL_COV can be used to instrument DAGISel tablegen
selection code to show which patterns along with Complex patterns were
used when selecting instructions. Unfortunately this is turned off by
default and was broken but never tested.
This required a simple fix (missing new line) to get it to build again.

llvm-svn: 353091

5 years ago[NewPM][MSan] Add Options Handling
Philip Pfaffe [Mon, 4 Feb 2019 21:02:49 +0000 (21:02 +0000)]
[NewPM][MSan] Add Options Handling

Summary: This patch enables passing options to msan via the passes pipeline, e.e., -passes=msan<recover;kernel;track-origins=4>.

Reviewers: chandlerc, fedor.sergeev, leonardchan

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57640

llvm-svn: 353090

5 years ago[DEBUGINFO] Reposting r352642: Handle restore instructions in LiveDebugValues
Wolfgang Pieb [Mon, 4 Feb 2019 20:42:45 +0000 (20:42 +0000)]
[DEBUGINFO] Reposting r352642: Handle restore instructions in LiveDebugValues

The LiveDebugValues pass recognizes spills but not restores, which can
cause large gaps in location information for some variables, depending
on control flow. This patch make LiveDebugValues recognize restores and
generate appropriate DBG_VALUE instructions.

This patch was posted previously with r352642 and reverted in r352666 due
to buildbot errors. A missing return statement was the cause for the
failures.

Reviewers: aprantl, NicolaPrica

Differential Revision: https://reviews.llvm.org/D57271

llvm-svn: 353089

5 years agoGeneralize pthread callback test case
Johannes Doerfert [Mon, 4 Feb 2019 20:42:38 +0000 (20:42 +0000)]
Generalize pthread callback test case

Changes suggested by Eli Friedman <efriedma@quicinc.com>

llvm-svn: 353088

5 years agoUpdate stale comment in lang/c/struct_types/main.c
Jonas Devlieghere [Mon, 4 Feb 2019 20:33:35 +0000 (20:33 +0000)]
Update stale comment in lang/c/struct_types/main.c

rdar://47322760

llvm-svn: 353087

5 years agoSupport tests in freestanding
JF Bastien [Mon, 4 Feb 2019 20:31:13 +0000 (20:31 +0000)]
Support tests in freestanding

Summary:
Freestanding is *weird*. The standard allows it to differ in a bunch of odd
manners from regular C++, and the committee would like to improve that
situation. I'd like to make libc++ behave better with what freestanding should
be, so that it can be a tool we use in improving the standard. To do that we
need to try stuff out, both with "freestanding the language mode" and
"freestanding the library subset".

Let's start with the super basic: run the libc++ tests in freestanding, using
clang as the compiler, and see what works. The easiest hack to do this:

In utils/libcxx/test/config.py add:

  self.cxx.compile_flags += ['-ffreestanding']

Run the tests and they all fail.

Why? Because in freestanding `main` isn't special. This "not special" property
has two effects: main doesn't get mangled, and main isn't allowed to omit its
`return` statement. The first means main gets mangled and the linker can't
create a valid executable for us to test. The second means we spew out warnings
(ew) and the compiler doesn't insert the `return` we omitted, and main just
falls of the end and does whatever undefined behavior (if you're luck, ud2
leading to non-zero return code).

Let's start my work with the basics. This patch changes all libc++ tests to
declare `main` as `int main(int, char**` so it mangles consistently (enabling us
to declare another `extern "C"` main for freestanding which calls the mangled
one), and adds `return 0;` to all places where it was missing. This touches 6124
files, and I apologize.

The former was done with The Magic Of Sed.

The later was done with a (not quite correct but decent) clang tool:

  https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed

This works for most tests, though I did have to adjust a few places when e.g.
the test runs with `-x c`, macros are used for main (such as for the filesystem
tests), etc.

Once this is in we can create a freestanding bot which will prevent further
regressions. After that, we can start the real work of supporting C++
freestanding fairly well in libc++.

<rdar://problem/47754795>

Reviewers: ldionne, mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits

Differential Revision: https://reviews.llvm.org/D57624

llvm-svn: 353086

5 years ago[CMake] Support CMake variables for setting target, sysroot and toolchain
Petr Hosek [Mon, 4 Feb 2019 20:02:26 +0000 (20:02 +0000)]
[CMake] Support CMake variables for setting target, sysroot and toolchain

CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.

libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.

This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.

Differential Revision: https://reviews.llvm.org/D57670

llvm-svn: 353084

5 years ago[AMDGPU] Support emitting GOT relocations for function calls
Scott Linder [Mon, 4 Feb 2019 20:00:07 +0000 (20:00 +0000)]
[AMDGPU] Support emitting GOT relocations for function calls

Differential Revision: https://reviews.llvm.org/D57416

llvm-svn: 353083