platform/upstream/llvm.git
8 years agoMutatis mutandis for char * -> StringRef.
Jim Ingham [Fri, 23 Sep 2016 22:36:00 +0000 (22:36 +0000)]
Mutatis mutandis for char * -> StringRef.

llvm-svn: 282311

8 years agoAdd an accessor to get the value of RC_PLATFORM_NAME at build time
Enrico Granata [Fri, 23 Sep 2016 22:30:08 +0000 (22:30 +0000)]
Add an accessor to get the value of RC_PLATFORM_NAME at build time

llvm-svn: 282310

8 years agoFix build on Ubuntu.
Zachary Turner [Fri, 23 Sep 2016 22:27:03 +0000 (22:27 +0000)]
Fix build on Ubuntu.

This was in some code that was #ifdef'd out on Windows, so I
didn't see it.

llvm-svn: 282309

8 years agoUse llvm::to_string instead of std::to_string to fix bot
Teresa Johnson [Fri, 23 Sep 2016 22:25:03 +0000 (22:25 +0000)]
Use llvm::to_string instead of std::to_string to fix bot

This should fix the android build in this bot:
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-buildserver/builds/11143

llvm-svn: 282308

8 years agoCombine two StringSwitch::Cases because Cases now can take 6 parameters.
Rui Ueyama [Fri, 23 Sep 2016 22:22:34 +0000 (22:22 +0000)]
Combine two StringSwitch::Cases because Cases now can take 6 parameters.

llvm-svn: 282307

8 years agoChange FileAction::GetPath() to return a StringRef.
Zachary Turner [Fri, 23 Sep 2016 22:11:51 +0000 (22:11 +0000)]
Change FileAction::GetPath() to return a StringRef.

llvm-svn: 282306

8 years agoAdd StringSwitch::Cases functions that takes 6 to 10 arguments.
Rui Ueyama [Fri, 23 Sep 2016 22:10:06 +0000 (22:10 +0000)]
Add StringSwitch::Cases functions that takes 6 to 10 arguments.

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

llvm-svn: 282305

8 years agoRevert "[profile] Hide lprofCurFilename"
Vedant Kumar [Fri, 23 Sep 2016 21:58:25 +0000 (21:58 +0000)]
Revert "[profile] Hide lprofCurFilename"

This reverts commit r282294. It breaks a Linux bot:

  http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/12180

It looks like the test checks that __llvm_profile_set_filename() alters the raw
profile filename in both the dylib and the main program. Now that
lprofCurFilename is hidden, this can't work, and we get two profiles (one for
the call to "main" and one for "func").

Back this change out so that we don't affect external users.

llvm-svn: 282304

8 years ago[MC] Support .ds directives in assembler parser
Petr Hosek [Fri, 23 Sep 2016 21:53:36 +0000 (21:53 +0000)]
[MC] Support .ds directives in assembler parser

These directives are already supported by GNU assembler.

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

llvm-svn: 282303

8 years agollc: Add -start-before/-stop-before options
Matthias Braun [Fri, 23 Sep 2016 21:46:02 +0000 (21:46 +0000)]
llc: Add -start-before/-stop-before options

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

llvm-svn: 282302

8 years agoUpdate clang for r282299.
Peter Collingbourne [Fri, 23 Sep 2016 21:43:51 +0000 (21:43 +0000)]
Update clang for r282299.

llvm-svn: 282301

8 years agoannotate more function visibility
Saleem Abdulrasool [Fri, 23 Sep 2016 21:36:24 +0000 (21:36 +0000)]
annotate more function visibility

These data and text symbols were missing annotations for building with hidden
visibility.  As we do not currently enable hidden visibility by default, this is
a NFC for the buildbots.

llvm-svn: 282300

8 years agoLTO: Simplify caching interface.
Peter Collingbourne [Fri, 23 Sep 2016 21:33:43 +0000 (21:33 +0000)]
LTO: Simplify caching interface.

The NativeObjectOutput class has a design problem: it mixes up the caching
policy with the interface for output streams, which makes the client-side
code hard to follow and would for example make it harder to replace the
cache implementation in an arbitrary client.

This change separates the two aspects by moving the caching policy
to a separate field in Config, replacing NativeObjectOutput with a
NativeObjectStream class which only deals with streams and does not need to
be overridden by most clients and introducing an AddFile callback for adding
files (e.g. from the cache) to the link.

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

llvm-svn: 282299

8 years agoAllow for tests to be disabled at runtime
Francis Ricci [Fri, 23 Sep 2016 21:32:47 +0000 (21:32 +0000)]
Allow for tests to be disabled at runtime

Summary:
The current implementation of the test suite allows the user to run
a certain subset of tests using '-p', but does not allow the inverse,
where a user wants to run all but some number of known failing tests.
Implement this functionality.

Reviewers: labath, zturner, tfiala

Subscribers: jingham, sas, lldb-commits

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

llvm-svn: 282298

8 years agoInstall only the manpage and only in the proper location
Enrico Granata [Fri, 23 Sep 2016 21:24:08 +0000 (21:24 +0000)]
Install only the manpage and only in the proper location

llvm-svn: 282297

8 years ago[AMDGPU] Fix for bz30427: wrong MTBUF encoding on VI
Valery Pykhtin [Fri, 23 Sep 2016 21:21:21 +0000 (21:21 +0000)]
[AMDGPU] Fix for bz30427: wrong MTBUF encoding on VI

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

llvm-svn: 282296

8 years agoWarn if we can't find the entry symbol.
Rafael Espindola [Fri, 23 Sep 2016 21:04:56 +0000 (21:04 +0000)]
Warn if we can't find the entry symbol.

Fixes pr30465.

llvm-svn: 282295

8 years ago[profile] Hide lprofCurFilename
Vedant Kumar [Fri, 23 Sep 2016 20:53:42 +0000 (20:53 +0000)]
[profile] Hide lprofCurFilename

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

llvm-svn: 282294

8 years ago[analyzer] Fix crash in RetainCountChecker::checkEndFunction
Alexander Shaposhnikov [Fri, 23 Sep 2016 20:49:01 +0000 (20:49 +0000)]
[analyzer] Fix crash in RetainCountChecker::checkEndFunction

The class BodyFarm creates bodies for
OSAtomicCompareAndSwap*, objc_atomicCompareAndSwap*, dispatch_sync*, dispatch_once*
and for them the flag isBodyAutosynthesized is set to true.

This diff
1. makes AnalysisConsumer::HandleCode skip the autosynthesized code
2. replaces assert(LCtx->getParent()) in RetainCountChecker::checkEndFunction
by assert(!LCtx->inTopFrame()) (minor cleanup)

Test plan: make -j8 check-clang-analysis

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

llvm-svn: 282293

8 years ago[libFuzzer] first steps in adding a proper automated test suite based on real-life...
Kostya Serebryany [Fri, 23 Sep 2016 20:43:22 +0000 (20:43 +0000)]
[libFuzzer] first steps in adding a proper automated test suite based on real-life code: add a script to build RE2 at a revision that has known bugs

llvm-svn: 282292

8 years ago[LTO] Add -flto-jobs=N to control backend parallelism
Teresa Johnson [Fri, 23 Sep 2016 20:38:09 +0000 (20:38 +0000)]
[LTO] Add -flto-jobs=N to control backend parallelism

Summary:
Currently, a linker option must be used to control the backend
parallelism of ThinLTO. The linker option varies depending on the
linker (e.g. gold vs ld64). Add a new clang option -flto-jobs=N
to control this.

I've added in the wiring to pass this to the gold plugin. I also
added in the logic to pass this down in the form I understand that
ld64 uses on MacOS, for the darwin target.

Reviewers: mehdi_amini, dexonsmith

Subscribers: mehdi_amini, cfe-commits

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

llvm-svn: 282291

8 years ago[gold] Split plugin options controlling ThinLTO and codegen parallelism.
Teresa Johnson [Fri, 23 Sep 2016 20:35:19 +0000 (20:35 +0000)]
[gold] Split plugin options controlling ThinLTO and codegen parallelism.

Summary:
As suggested in D24826, use different options for ThinLTO backend
parallelism from the option controlling regular LTO code gen
parallelism. They are already split in the LTO API, and this enables
controlling them with different clang options.

Reviewers: pcc, mehdi_amini

Subscribers: dexonsmith, llvm-commits, mehdi_amini

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

llvm-svn: 282290

8 years agoRevert "set the underlying value of “#pragma STDC FP_CONTRACT” on by default"
Renato Golin [Fri, 23 Sep 2016 20:32:52 +0000 (20:32 +0000)]
Revert "set the underlying value of “#pragma STDC FP_CONTRACT” on by default"

This reverts commit r282259, as it broke the AArch64 test-suite bots.

llvm-svn: 282289

8 years ago[Coverage] Clarify a function contract (NFC)
Vedant Kumar [Fri, 23 Sep 2016 20:13:44 +0000 (20:13 +0000)]
[Coverage] Clarify a function contract (NFC)

llvm-svn: 282287

8 years ago[llvm-cov] Factor out logic to remove unmapped inputs (NFC)
Vedant Kumar [Fri, 23 Sep 2016 20:13:41 +0000 (20:13 +0000)]
[llvm-cov] Factor out logic to remove unmapped inputs (NFC)

llvm-svn: 282286

8 years agoAvoid counting sections twice.
Rafael Espindola [Fri, 23 Sep 2016 20:10:47 +0000 (20:10 +0000)]
Avoid counting sections twice.

We were counting the size of the bss section holding common symbols twice:

    Dot += CurOutSec->getSize();
    flush();

The new code is also simpler as now flush is the only function that
inserts in AlreadyOutputOS, which makes sense since the set hold fully
output sections.

llvm-svn: 282285

8 years ago[libFuzzer] reset Counters (trace-pc-guard) before every run
Kostya Serebryany [Fri, 23 Sep 2016 20:04:13 +0000 (20:04 +0000)]
[libFuzzer] reset Counters (trace-pc-guard) before every run

llvm-svn: 282284

8 years ago[MC] Support .dcb directives in assembler parser
Petr Hosek [Fri, 23 Sep 2016 19:25:15 +0000 (19:25 +0000)]
[MC] Support .dcb directives in assembler parser

These directives are already supported by GNU assembler.

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

llvm-svn: 282283

8 years ago[llvm-cov] Filter away source files that aren't in the coverage mapping
Vedant Kumar [Fri, 23 Sep 2016 18:57:35 +0000 (18:57 +0000)]
[llvm-cov] Filter away source files that aren't in the coverage mapping

... so that they don't show up in the index. This came up because polly
contains a .git directory and some other unmapped input in its source
dir.

llvm-svn: 282282

8 years ago[llvm-cov] Get rid of all invalid filename references
Vedant Kumar [Fri, 23 Sep 2016 18:57:32 +0000 (18:57 +0000)]
[llvm-cov] Get rid of all invalid filename references

We used to append filenames into a vector of std::string, and then
append a reference to each string into a separate vector. This made it
easier to work with the getUniqueSourceFiles API. But it's buggy.

std::string has a small-string optimization, so you can't expect to
capture a reference to one if you're copying it into a growing vector.
Add a test that triggers this invalid reference to std::string scenario,
and kill the issue with fire by just using ArrayRef<std::string>
everywhere.

llvm-svn: 282281

8 years ago[llvm-cov] Minor cleanup. NFC.
Vedant Kumar [Fri, 23 Sep 2016 18:57:27 +0000 (18:57 +0000)]
[llvm-cov] Minor cleanup. NFC.

llvm-svn: 282280

8 years ago[ELF] Resolve weak undefined TLS symbols when no phdr is available.
Davide Italiano [Fri, 23 Sep 2016 18:47:50 +0000 (18:47 +0000)]
[ELF] Resolve weak undefined TLS symbols when no phdr is available.

If we pass --gc-sections to lld and .tbss is not referenced,
the section is reclaimed and lld doesn't create a TLS program header.
R_TLS tries to access the program header -> lld crashes.
Mimic what bfd/gold do in this case and resolve a weak undefined
TLS symbol to the base of the TLS block, i.e. give it a value of zero.

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

llvm-svn: 282279

8 years ago[TLI] isdigit / isascii / toascii param type should match return type (PR30484)
Sanjay Patel [Fri, 23 Sep 2016 18:44:09 +0000 (18:44 +0000)]
[TLI] isdigit / isascii / toascii param type should match return type (PR30484)

We crash in LibCallSimplifier if we don't check the validity of the function signature properly.

llvm-svn: 282278

8 years agoChange Module::RemapPath to use StringRef.
Zachary Turner [Fri, 23 Sep 2016 18:42:38 +0000 (18:42 +0000)]
Change Module::RemapPath to use StringRef.

llvm-svn: 282277

8 years ago[ResetMachineFunction] Populate the comments in the header of the file.
Quentin Colombet [Fri, 23 Sep 2016 18:38:15 +0000 (18:38 +0000)]
[ResetMachineFunction] Populate the comments in the header of the file.

NFC

llvm-svn: 282276

8 years ago[ResetMachineFunction] Add statistic on the number of reset functions.
Quentin Colombet [Fri, 23 Sep 2016 18:38:13 +0000 (18:38 +0000)]
[ResetMachineFunction] Add statistic on the number of reset functions.

As the development of GlobalISel move forward, this statistic should
strictly decrease until it reaches zero. At this point, it would mean
GlobalISel can replace SDISel (at least on the tested inputs :P).

llvm-svn: 282275

8 years ago[RegisterBankInfo] Add statistics for dynamic partial mappings.
Quentin Colombet [Fri, 23 Sep 2016 18:38:06 +0000 (18:38 +0000)]
[RegisterBankInfo] Add statistics for dynamic partial mappings.

Collect statistics about the number of partial mappings dynamically
allocated and accessed. Ultimately, when the whole TableGen
infrastructure is set, those numbers should be zero.

llvm-svn: 282274

8 years agoScheduleDAG: Match enum names when printing sdep kinds
Matthias Braun [Fri, 23 Sep 2016 18:28:31 +0000 (18:28 +0000)]
ScheduleDAG: Match enum names when printing sdep kinds

It is less confusing to have the same names in the debug print as the
enum members.

llvm-svn: 282273

8 years agoBitcodeReader: Deduplicate code. NFC.
Peter Collingbourne [Fri, 23 Sep 2016 18:27:42 +0000 (18:27 +0000)]
BitcodeReader: Deduplicate code. NFC.

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

llvm-svn: 282272

8 years agoTry again to match the logic of the code before re-writing.
Zachary Turner [Fri, 23 Sep 2016 18:13:18 +0000 (18:13 +0000)]
Try again to match the logic of the code before re-writing.

llvm-svn: 282271

8 years agoTry to fix failing TestDataFormatterSkipSummary test case.
Zachary Turner [Fri, 23 Sep 2016 18:11:03 +0000 (18:11 +0000)]
Try to fix failing TestDataFormatterSkipSummary test case.

llvm-svn: 282270

8 years agoUpdate the prompt related functions to use StringRefs.
Zachary Turner [Fri, 23 Sep 2016 18:06:53 +0000 (18:06 +0000)]
Update the prompt related functions to use StringRefs.

llvm-svn: 282269

8 years agoSimplify. NFC.
Rui Ueyama [Fri, 23 Sep 2016 18:06:51 +0000 (18:06 +0000)]
Simplify. NFC.

llvm-svn: 282268

8 years ago[RegBankSelect] Use DEBUG_TYPE instead of repeating the name of the pass
Quentin Colombet [Fri, 23 Sep 2016 17:50:06 +0000 (17:50 +0000)]
[RegBankSelect] Use DEBUG_TYPE instead of repeating the name of the pass

NFC

llvm-svn: 282267

8 years ago[RegisterBank] Mark the dump method with LLVM_DUMP_METHOD.
Quentin Colombet [Fri, 23 Sep 2016 17:50:03 +0000 (17:50 +0000)]
[RegisterBank] Mark the dump method with LLVM_DUMP_METHOD.

NFC

llvm-svn: 282266

8 years agoUpdate OptionGroup::SetValue to take StringRef.
Zachary Turner [Fri, 23 Sep 2016 17:48:13 +0000 (17:48 +0000)]
Update OptionGroup::SetValue to take StringRef.

Then deal with all the fallout.

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

llvm-svn: 282265

8 years agoFix the following tests when running under cross-compilation:
Chad Rosier [Fri, 23 Sep 2016 17:40:40 +0000 (17:40 +0000)]
Fix the following tests when running under cross-compilation:

 Profile-aarch64 :: Linux/comdat_rename.test
 Profile-aarch64 :: Linux/extern_template.test
 Profile-aarch64 :: Linux/instrprof-comdat.test
 Profile-aarch64 :: Linux/instrprof-cs.c

The issue is that the created (aarch64) binaries were attempting to run natively
instead of running through %run, which guarantees running in the proper
environment if the compilation was configured correctly.

llvm-svn: 282264

8 years ago[compiler-rt] Fix a broken asan 64-bit test using ld_preload
Etienne Bergeron [Fri, 23 Sep 2016 17:40:31 +0000 (17:40 +0000)]
[compiler-rt] Fix a broken asan 64-bit test using ld_preload

Summary:
The 'asan_preload_test-1.cc' is not working with the i686 architecture.
To repro the error, run on a linux 64-bit:
```
ninja check-asan-dynamic
```

The following error occurs:
```
--
Exit Code: 1

Command Output (stderr):
--
/home/llvm/llvm/projects/compiler-rt/test/asan/TestCases/Linux/asan_preload_test-1.cc:18:12: error: expected string not found in input
 // CHECK: AddressSanitizer: heap-buffer-overflow
           ^
<stdin>:1:1: note: scanning from here
ERROR: ld.so: object 'libclang_rt.asan-i686.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
^
<stdin>:2:10: note: possible intended match here
==25982==AddressSanitizer CHECK failed: /home/llvm/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:736 "((__interception::real_memcpy)) != (0)" (0x0, 0x0)
```

The unittest is running (where %shared_libasan is replaced by libclang_rt.asan-i686.so):
```
// RUN: env LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s
```

But the executable also has a dependancy on libclang_rt.asan-i386.so (added by the clang driver):
```
linux-gate.so.1 =>  (0xf77cc000)
libclang_rt.asan-i386.so => not found
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf76ba000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7673000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf7656000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf74a7000)
```

By looking to the clang driver (tools.cpp) we can see that every x86 architecture are mapped to 'i386'.
```
 StringRef MyArch;
    switch (getToolChain().getArch()) {
    case llvm::Triple::arm:
      MyArch = "arm";
      break;
    case llvm::Triple::x86:
      MyArch = "i386";
      break;
    case llvm::Triple::x86_64:
      MyArch = "amd64";
      break;
    default:
      llvm_unreachable("Unsupported architecture");
    }
```

This patch is implementing the same mapping but in the compiler-rt unittest.

Reviewers: rnk, vitalybuka

Subscribers: aemerson, kubabrecka, dberris, llvm-commits, chrisha

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

llvm-svn: 282263

8 years agoEnhance calcColdCallHeuristics for InvokeInst
Jun Bum Lim [Fri, 23 Sep 2016 17:26:14 +0000 (17:26 +0000)]
Enhance calcColdCallHeuristics for InvokeInst

Summary: When identifying cold blocks, consider only the edge to the normal destination if the terminator is InvokeInst and let calcInvokeHeuristics() decide edge weights for the InvokeInst.

Reviewers: mcrosier, hfinkel, davidxl

Subscribers: mcrosier, llvm-commits

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

llvm-svn: 282262

8 years ago[asan] Stop appending -lm, -pthread and other linker options on Darwin for ASan unit...
Kuba Brecka [Fri, 23 Sep 2016 16:43:29 +0000 (16:43 +0000)]
[asan] Stop appending -lm, -pthread and other linker options on Darwin for ASan unit tests

On Darwin, -lm, -pthread and others are implied. -pthread currently produces a warning (compiler option unused).

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

llvm-svn: 282260

8 years agoset the underlying value of “#pragma STDC FP_CONTRACT” on by default
Sebastian Pop [Fri, 23 Sep 2016 16:16:25 +0000 (16:16 +0000)]
set the underlying value of “#pragma STDC FP_CONTRACT” on by default

Clang has the default FP contraction setting of “-ffp-contract=on”, which
doesn't really mean “on” in the conventional sense of the word, but rather
really means “according to the per-statement effective value of the relevant
pragma”.

Before this patch, Clang has that pragma defaulting to “off”. Since the
“-ffp-contract=on” mode is really an AND of two booleans and the second of them
defaults to “off”, the whole thing effectively defaults to “off”. This patch
changes the default value of the pragma to “on”, thus making the default pair of
booleans (on, on) rather than (on, off). This makes FP optimization slightly
more aggressive than before when not using either “-Ofast”, “-ffast-math”, or
“-ffp-contract=fast”. Even with this patch the compiler still respects
“-ffp-contract=off”.

As per a suggestion by Steve Canon, the added code does _not_ require “-O3” or
higher. This is so as to try our best to preserve identical floating-point
results for unchanged source code compiling for an unchanged target when only
changing from any optimization level in the set (“-O0”, “-O1”, “-O2”, “-O3”) to
any other optimization level in that set. “-Os” and “-Oz” seem to be behaving
identically, i.e. should probably be considered a part of the aforementioned
set, but I have not reviewed this rigorously. “-Ofast” is explicitly _not_ a
member of that set.

Patch authored by Abe Skolnik [a.skolnik@samsung.com] and Stephen Canon [scanon@apple.com].

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

llvm-svn: 282259

8 years agoadd hook for calling platform-dependent pre-kill action on a timed out test
Todd Fiala [Fri, 23 Sep 2016 16:10:01 +0000 (16:10 +0000)]
add hook for calling platform-dependent pre-kill action on a timed out test

differential review: https://reviews.llvm.org/D24850

reviewers: clayborg, labath
llvm-svn: 282258

8 years agoRevert of r282255 because of "Fell off the end of a string-switch" buildbot
Sjoerd Meijer [Fri, 23 Sep 2016 15:37:17 +0000 (15:37 +0000)]
Revert of r282255 because of "Fell off the end of a string-switch" buildbot
failures.

llvm-svn: 282257

8 years agoFix test when run in unusual test directories.
Rafael Espindola [Fri, 23 Sep 2016 15:34:53 +0000 (15:34 +0000)]
Fix test when run in unusual test directories.

It would fail for example if the directory contained an @. Both gold
and bfd require quotes for @, so just change the test to quote the
directory name.

Thanks to Vedant Kumar for the bug report.

llvm-svn: 282256

8 years agoFix for r280064 that added options for fp denormals and exceptions.
Sjoerd Meijer [Fri, 23 Sep 2016 15:21:33 +0000 (15:21 +0000)]
Fix for r280064 that added options for fp denormals and exceptions.
These options were forgotten to be copied in setCommandLineOpts.

llvm-svn: 282255

8 years ago[compiler-rt][lsan] Fix compiler error due to attribute (windows)
Etienne Bergeron [Fri, 23 Sep 2016 15:11:41 +0000 (15:11 +0000)]
[compiler-rt][lsan] Fix compiler error due to attribute (windows)

Summary:
Window compiler is stricter for attributes location. This patch fixes a compilation error.
```
D:\src\llvm\llvm\projects\compiler-rt\lib\lsan\lsan_thread.cc(39): error C2144: syntax error: 'int' should be preceded by ';'
```

Reviewers: rnk, majnemer

Subscribers: majnemer, llvm-commits, chrisha, dberris

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

llvm-svn: 282254

8 years ago[clang-format] support header deletion in cleanupAroundReplacemnts.
Eric Liu [Fri, 23 Sep 2016 15:10:56 +0000 (15:10 +0000)]
[clang-format] support header deletion in cleanupAroundReplacemnts.

Summary:
- If a replacement has offset UINT_MAX, length 0, and a replacement text
  that is an #include directive, this will insert the #include into the
  correct block in the \p Code.
- If a replacement has offset UINT_MAX, length 1, and a replacement text
  that is the name of the header to be removed, the header will be removed
  from \p Code if it exists.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 282253

8 years ago[OpenCL] Augment pipe built-ins with pipe packet size and alignment.
Alexey Bader [Fri, 23 Sep 2016 14:20:00 +0000 (14:20 +0000)]
[OpenCL] Augment pipe built-ins with pipe packet size and alignment.

Reviewers: Anastasia, vpykhtin

Subscribers: dmitry, cfe-commits

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

llvm-svn: 282252

8 years ago[asan] Fix incorrect SEH symbol mangling on win64.
Etienne Bergeron [Fri, 23 Sep 2016 14:07:47 +0000 (14:07 +0000)]
[asan] Fix incorrect SEH symbol mangling on win64.

Summary:
The ASAN unittests are failing (check-asan-dynamic) due to an incorrect symbol name:
```
LINK : error LNK2001: unresolved external symbol ___asan_seh_interceptor
```

On win64, the linker is not adding an extra underscore. This was correctly fixed in the same file for other uses.

After that patch, most of the unittests are passing, but some related to SEH needs to be fixed.
```
Failing Tests (4):
    AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memchr.cc
    AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memcpy_indirect.cc
    AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_seh.cc
    AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/seh.cc

  Expected Passes    : 339
  Passes With Retry  : 3
  Expected Failures  : 16
  Unsupported Tests  : 152
  Unexpected Failures: 4
```

Reviewers: rnk, kcc, majnemer

Subscribers: majnemer, chrisha, cfe-commits

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

llvm-svn: 282251

8 years ago[ARM] ARM TLS shouldn't use relaxations
Peter Smith [Fri, 23 Sep 2016 13:54:48 +0000 (13:54 +0000)]
[ARM] ARM TLS shouldn't use relaxations

The ARM TLS relocations are placed on literal data and not the
code-sequence, it is therefore not possible to implement the relaxTls*
functions. This change updates handleMipsTlsRelocation() to
handleNoRelaxTlsRelocation() and incorporates ARM as well as Mips.

The ARM support in handleNoRelaxTlsRelocation() currently needs to ouput
the module index dynamic relocation in all cases as it is relying on the
dynamic linker to set the module index in the got.

Should address PR30218

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

llvm-svn: 282250

8 years agoRevert "[ARM] Promote small global constants to constant pools"
James Molloy [Fri, 23 Sep 2016 13:35:43 +0000 (13:35 +0000)]
Revert "[ARM] Promote small global constants to constant pools"

This reverts commit r282241. It caused http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/19882.

llvm-svn: 282249

8 years ago[ELF] - Linkerscript: accept space between '=' and expression in section filler.
George Rimar [Fri, 23 Sep 2016 13:29:20 +0000 (13:29 +0000)]
[ELF] - Linkerscript: accept space between '=' and expression in section filler.

Previously we failed to parse next scripts because disallowed
a space between filler value and '=':

  .text : {
...
  } :text = 0x9090

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

llvm-svn: 282248

8 years ago[clang-move] The new.cc file should include new_header.h instead of old_header.h
Haojian Wu [Fri, 23 Sep 2016 13:28:38 +0000 (13:28 +0000)]
[clang-move] The new.cc file should include new_header.h instead of old_header.h

Summary:
Previously, all #includes (includeing old_header.h) in old.cc will be copied to new.cc,
however, the new.cc should include new_header.h instead of the old_header.h

Before applying the patch, the new.cc looks like:

```
#include "old_header.h"
...
```

The new.cc looks like with this patch:

```
#include "new_header"
...
```

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 282247

8 years ago[Power9] Exploit move and splat instructions for build_vector improvement
Nemanja Ivanovic [Fri, 23 Sep 2016 13:25:31 +0000 (13:25 +0000)]
[Power9] Exploit move and splat instructions for build_vector improvement

This patch corresponds to review:
https://reviews.llvm.org/D21135

This patch exploits the following instructions:
mtvsrws
lxvwsx
mtvsrdd
mfvsrld

In order to improve some build_vector and extractelement patterns.

llvm-svn: 282246

8 years ago[ELF] - Linkerscript: implement DEFINED() command.
George Rimar [Fri, 23 Sep 2016 13:17:23 +0000 (13:17 +0000)]
[ELF] - Linkerscript: implement DEFINED() command.

DEFINED(symbol)
Return 1 if symbol is in the linker global symbol table and is defined before
the statement using DEFINED in the script, otherwise return 0.

Can be used to define default values for symbols. Found it in the wild.

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

llvm-svn: 282245

8 years agoLinker script: fix crash when discarding section
Eugene Leviant [Fri, 23 Sep 2016 13:17:16 +0000 (13:17 +0000)]
Linker script: fix crash when discarding section

If section contains local symbols ldd crashes, because local
symbols are added to symbol table before section is discarded
by linker script processor. This patch calls copyLocalSymbols()
after createSections, so discarded section symbols are not copied

llvm-svn: 282244

8 years ago[ELF] - Linkerscript: Implemented >> and <<
George Rimar [Fri, 23 Sep 2016 13:13:55 +0000 (13:13 +0000)]
[ELF] - Linkerscript: Implemented >> and <<

Found this operators used in the wild scripts, for example:

__got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
__fixup_entries = (. - _FIXUP_TABLE_)>>2;

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

llvm-svn: 282243

8 years agoMinor tweak. Avoid hardcoding.
Daniel Marjamaki [Fri, 23 Sep 2016 12:23:44 +0000 (12:23 +0000)]
Minor tweak. Avoid hardcoding.

llvm-svn: 282242

8 years ago[ARM] Promote small global constants to constant pools
James Molloy [Fri, 23 Sep 2016 12:15:58 +0000 (12:15 +0000)]
[ARM] Promote small global constants to constant pools

If a constant is unamed_addr and is only used within one function, we can save
on the code size and runtime cost of an indirection by changing the global's storage
to inside the constant pool. For example, instead of:

      ldr r0, .CPI0
      bl printf
      bx lr
    .CPI0: &format_string
    format_string: .asciz "hello, world!\n"

We can emit:

      adr r0, .CPI0
      bl printf
      bx lr
    .CPI0: .asciz "hello, world!\n"

This can cause significant code size savings when many small strings are used in one
function (4 bytes per string).

This recommit contains fixes for a nasty bug related to fast-isel fallback - because
fast-isel doesn't know about this optimization, if it runs and emits references to
a string that we inline (because fast-isel fell back to SDAG) we will end up
with an inlined string and also an out-of-line string, and we won't emit the
out-of-line string, causing backend failures.

It also contains fixes for emitting .text relocations which made the sanitizer
bots unhappy.

llvm-svn: 282241

8 years agocmake: Support overriding Sphinx HTML doc install directory
Michal Gorny [Fri, 23 Sep 2016 11:09:33 +0000 (11:09 +0000)]
cmake: Support overriding Sphinx HTML doc install directory

Provide ${PROJECT}_INSTALL_SPHINX_HTML_DIR variables (e.g.
LLVM_INSTALL_SPHINX_HTML_DIR) to override Sphinx HTML doc install
directory.

Bug: https://llvm.org/bugs/show_bug.cgi?id=23780

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

llvm-svn: 282240

8 years agoRevert r282238 "Revert r282235 "[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index...
George Rimar [Fri, 23 Sep 2016 11:01:53 +0000 (11:01 +0000)]
Revert r282238 "Revert r282235 "[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section.""

Build bot issues (http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15856/steps/ninja%20check%201/logs/FAIL%3A%20LLVM%3A%3Adwarfdump-dump-gdbindex.test)
should be fixed in that version. Issue was that MSVS does not support "%zu". Though it works fine on MSCS 2015,
Bot looks running MSVS 2013 that does not like it. MSDN also says that "z" prefix is not supported: https://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
I had to use PRId64 instead.

Original commit message:

[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section.

gold linker's --gdb-index option currently is able to create the .gdb_index section that allows GDB to locate and read the .dwo files as it needs them,
this helps reduce the total size of the object files processed by the linker.

More info about that:
https://gcc.gnu.org/wiki/DebugFission
https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html

Patch teaches dwarfdump tool to dump this section.

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

llvm-svn: 282239

8 years agoRevert r282235 "[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section."
George Rimar [Fri, 23 Sep 2016 10:12:56 +0000 (10:12 +0000)]
Revert r282235 "[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section."

It broke BB:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15856

llvm-svn: 282238

8 years ago[InstCombine] Fix for PR29124: reduce insertelements to shufflevector
Alexey Bataev [Fri, 23 Sep 2016 09:14:08 +0000 (09:14 +0000)]
[InstCombine] Fix for PR29124: reduce insertelements to shufflevector

If inserting more than one constant into a vector:

define <4 x float> @foo(<4 x float> %x) {
  %ins1 = insertelement <4 x float> %x, float 1.0, i32 1
  %ins2 = insertelement <4 x float> %ins1, float 2.0, i32 2
  ret <4 x float> %ins2
}

InstCombine could reduce that to a shufflevector:

define <4 x float> @goo(<4 x float> %x) {
 %shuf = shufflevector <4 x float> %x, <4 x float> <float undef, float 1.0, float 2.0, float undef>, <4 x i32><i32 0, i32 5, i32 6, i32 3>
 ret <4 x float> %shuf
}
Also, InstCombine tries to convert shuffle instruction to single insertelement, if one of the vectors is a constant vector and only a single element from this constant should be used in shuffle, i.e.
shufflevector <4 x float> %v, <4 x float> <float undef, float 1.0, float
undef, float undef>, <4 x i32> <i32 0, i32 5, i32 undef, i32 undef> ->
insertelement <4 x float> %v, float 1.0, 1

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

llvm-svn: 282237

8 years ago[gdb-remote] Remove the const char * version of SendPacketAndWaitForResponse
Pavel Labath [Fri, 23 Sep 2016 09:11:49 +0000 (09:11 +0000)]
[gdb-remote] Remove the const char * version of SendPacketAndWaitForResponse

Switch all callers to use the StringRef version.

llvm-svn: 282236

8 years ago[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section.
George Rimar [Fri, 23 Sep 2016 09:09:26 +0000 (09:09 +0000)]
[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section.

gold linker's --gdb-index option currently is able to create the .gdb_index section that allows GDB to locate and read the .dwo files as it needs them,
this helps reduce the total size of the object files processed by the linker.

More info about that:
https://gcc.gnu.org/wiki/DebugFission
https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html

Patch teaches dwarfdump tool to dump this section.

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

llvm-svn: 282235

8 years ago[AMDGPU] Refactor VOP1 and VOP2 instruction TD definitions
Valery Pykhtin [Fri, 23 Sep 2016 09:08:07 +0000 (09:08 +0000)]
[AMDGPU] Refactor VOP1 and VOP2 instruction TD definitions

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

llvm-svn: 282234

8 years agoFix indentation
Daniel Marjamaki [Fri, 23 Sep 2016 08:27:24 +0000 (08:27 +0000)]
Fix indentation

llvm-svn: 282233

8 years ago[msan] Prevent initialization failure with newer (2.23+) glibc in use.
Maxim Ostapenko [Fri, 23 Sep 2016 07:40:55 +0000 (07:40 +0000)]
[msan] Prevent initialization failure with newer (2.23+) glibc in use.

This patch is pretty the same as http://reviews.llvm.org/D20235 that we used
for ASan. Using the same hack for MSan fixes its initialization with newer
Glibc in use.

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

llvm-svn: 282232

8 years ago[AVX-512] Split X86ISD::VFPROUND and X86ISD::VFPEXT into separate opcodes for each...
Craig Topper [Fri, 23 Sep 2016 06:24:43 +0000 (06:24 +0000)]
[AVX-512] Split X86ISD::VFPROUND and X86ISD::VFPEXT into separate opcodes for each type constraint.

This revealed that scalar intrinsics could create nodes with a rounding mode of FROUND_CUR_DIRECTION, but the patterns didn't check for it. It just worked because isel doesn't check operand count and we had a pattern without the rounding mode argument at all.

llvm-svn: 282231

8 years ago[AVX-512] Add separate ISD opcodes for each form of CVT instructions. Don't reuse...
Craig Topper [Fri, 23 Sep 2016 06:24:39 +0000 (06:24 +0000)]
[AVX-512] Add separate ISD opcodes for each form of CVT instructions. Don't reuse non-X86 ISD opcodes with extra X86 specific arguments.

llvm-svn: 282230

8 years ago[AVX-512] Use different ISD opcodes for some of the scalar intrinsic lowering. Isel...
Craig Topper [Fri, 23 Sep 2016 06:24:35 +0000 (06:24 +0000)]
[AVX-512] Use different ISD opcodes for some of the scalar intrinsic lowering. Isel is not very robust against using the same ISD opcode with different number of operands so its better to separate.

llvm-svn: 282229

8 years ago[AVX-512] Add initial support for checking rounding mode arguments of builtins.
Craig Topper [Fri, 23 Sep 2016 04:48:31 +0000 (04:48 +0000)]
[AVX-512] Add initial support for checking rounding mode arguments of builtins.

The backend can't encode all possible values of the argument and will fail isel. Checking in the frontend presents a friendlier experience to the user.

I started with builtins that can only take _MM_CUR_DIRECTION or _MM_NO_EXC. More builtins coming in the future.

llvm-svn: 282228

8 years ago[X86] Split up the single switch statement in Sema::CheckX86BuiltinFunctionCall into...
Craig Topper [Fri, 23 Sep 2016 04:48:27 +0000 (04:48 +0000)]
[X86] Split up the single switch statement in Sema::CheckX86BuiltinFunctionCall into different switches or ifs for each type of check.

This in preparation for a new check that will check some of the builtins that already had the immediate range check.

llvm-svn: 282227

8 years agoFix windows build caused by mixing enum and enum class.
Zachary Turner [Fri, 23 Sep 2016 02:54:26 +0000 (02:54 +0000)]
Fix windows build caused by mixing enum and enum class.

llvm-svn: 282226

8 years ago[libFuzzer] be more precise about what we reset in TracePC
Kostya Serebryany [Fri, 23 Sep 2016 02:18:59 +0000 (02:18 +0000)]
[libFuzzer] be more precise about what we reset in TracePC

llvm-svn: 282225

8 years ago[libFuzzer] fix merging with trace-pc-guard
Kostya Serebryany [Fri, 23 Sep 2016 01:58:51 +0000 (01:58 +0000)]
[libFuzzer] fix merging with trace-pc-guard

llvm-svn: 282224

8 years agoAMDGPU/SI: Include implicit arguments in kernarg_segment_byte_size
Tom Stellard [Fri, 23 Sep 2016 01:33:26 +0000 (01:33 +0000)]
AMDGPU/SI: Include implicit arguments in kernarg_segment_byte_size

Reviewers: arsenm

Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, llvm-commits, tony-tye

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

llvm-svn: 282223

8 years ago[libFuzzer] simplify the TracePC logic
Kostya Serebryany [Fri, 23 Sep 2016 01:20:07 +0000 (01:20 +0000)]
[libFuzzer] simplify the TracePC logic

llvm-svn: 282222

8 years ago[RegisterBankInfo] Mark the dump methods with LLVM_DUMP_METHOD.
Quentin Colombet [Fri, 23 Sep 2016 00:59:12 +0000 (00:59 +0000)]
[RegisterBankInfo] Mark the dump methods with LLVM_DUMP_METHOD.

NFC

llvm-svn: 282221

8 years ago[AArch64][RegisterBankInfo] Sanity check TableGen'ed like inputs.
Quentin Colombet [Fri, 23 Sep 2016 00:59:07 +0000 (00:59 +0000)]
[AArch64][RegisterBankInfo] Sanity check TableGen'ed like inputs.

Make sure the entries written to mimic the behavior of TableGen are
sane.

llvm-svn: 282220

8 years ago[libFuzzer] move value profiling logic into TracePC
Kostya Serebryany [Fri, 23 Sep 2016 00:46:18 +0000 (00:46 +0000)]
[libFuzzer] move value profiling logic into TracePC

llvm-svn: 282219

8 years agoTriple: Add opencl environment type
Tom Stellard [Fri, 23 Sep 2016 00:42:56 +0000 (00:42 +0000)]
Triple: Add opencl environment type

Summary:
For AMDGPU, we have been using the operating system component of the triple
for specifying the low-level runtime that is being used.  The rationale for
this is that the host operating system (e.g. Linux) is irrelevant for GPU code,
since its execution enviroment will be mostly controled by the low-level runtime
being used to execute the code.

In most cases, higher level languages have their own runtime which is
implemented on top of the low-level runtime.  The kernel ABIs of each
language mostly depend on the low-level runtime, but there may be some
slight differences between languages.  OpenCL for example, may append
additional arguments to the kernel in order to pass values like global
offsets or buffers for printf.  OpenMP, HCC, or other languages may want
to add their own values which differ from OpenCL.

The reason for adding a new opencl environment type is to make it possible for the backend
to distinguish between the ABIs of the higher-level languages and handle them correctly.
It seems cleaner to use the enviroment component for this rather than creating a new
OS type for every combination of low-level runtime / high-level language.

Reviewers: Anastasia, chandlerc

Subscribers: whchung, pekka.jaaskelainen, wdng, yaxunl, llvm-commits

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

llvm-svn: 282218

8 years ago[MC] Support skip and count for .incbin directive
Petr Hosek [Fri, 23 Sep 2016 00:41:06 +0000 (00:41 +0000)]
[MC] Support skip and count for .incbin directive

These optional arguments are supported by GNU assembler.

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

llvm-svn: 282217

8 years ago[libFuzzer] change ValueBitMap to remember the number of bits in it
Kostya Serebryany [Fri, 23 Sep 2016 00:22:46 +0000 (00:22 +0000)]
[libFuzzer] change ValueBitMap to remember the number of bits in it

llvm-svn: 282216

8 years ago[AArch64][RegisterBankInfo] Switch to TableGen'ed like PartialMapping.
Quentin Colombet [Fri, 23 Sep 2016 00:14:36 +0000 (00:14 +0000)]
[AArch64][RegisterBankInfo] Switch to TableGen'ed like PartialMapping.

Statically instanciate the most common PartialMappings. This should
be closer to what the code would look like when TableGen support is
added for GlobalISel. As a side effect, this should improve compile
time.

llvm-svn: 282215

8 years ago[RegisterBankInfo] Check that the mapping covers the interesting bits.
Quentin Colombet [Fri, 23 Sep 2016 00:14:34 +0000 (00:14 +0000)]
[RegisterBankInfo] Check that the mapping covers the interesting bits.

In the verify method of the ValueMapping class we used to check that the
mapping exactly matches the bits of the input value. This is problematic
for statically allocated mappings because we would need a different
mapping for each different size of the value that maps on one
instruction. For instance, with such scheme, we would need a different
mapping for a value of size 1, 5, 23 whereas they all end up on a 32-bit
wide instruction.

Therefore, change the verifier to check that the meaningful bits are
covered by the mapping instead of matching them.

llvm-svn: 282214

8 years ago[RegisterBankInfo] Use array instead of SmallVector for BreakDown.
Quentin Colombet [Fri, 23 Sep 2016 00:14:30 +0000 (00:14 +0000)]
[RegisterBankInfo] Use array instead of SmallVector for BreakDown.

This is another step toward TableGen'ed like structures. The BreakDown of
the mapping of the value will be statically computed by TableGen, thus
we only have to point to the right entry in the table instead of
dynamically allocate the mapping for each instruction.

We still support the dynamic allocation through a factory of
PartialMapping to ease the bring-up of the targets while the TableGen
backend is not available.

llvm-svn: 282213

8 years agoAdd the ability to append breakpoints to the save file.
Jim Ingham [Thu, 22 Sep 2016 23:42:42 +0000 (23:42 +0000)]
Add the ability to append breakpoints to the save file.

llvm-svn: 282212

8 years ago[libFuzzer] simplify the crash minimizer; split MaxLen into two: MaxInputLen and...
Kostya Serebryany [Thu, 22 Sep 2016 23:16:36 +0000 (23:16 +0000)]
[libFuzzer] simplify the crash minimizer; split MaxLen into two: MaxInputLen and MaxMutationLen, allow MaxMutationLen to be less than MaxInputLen

llvm-svn: 282211

8 years ago[InstCombine] fold X urem C -> X < C ? X : X - C when C is big (PR28672)
Sanjay Patel [Thu, 22 Sep 2016 22:36:26 +0000 (22:36 +0000)]
[InstCombine] fold X urem C -> X < C ? X : X - C when C is big (PR28672)

We already have the udiv variant of this transform, so I think this is ok for
InstCombine too even though there is an increase in IR instructions. As the
tests and TODO comments show, the transform can lead to follow-on combines.

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

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

llvm-svn: 282209