platform/upstream/llvm.git
2 years ago[RISCV] Add fixed-length vector instrinsics for segment load
Luke [Sun, 13 Feb 2022 14:22:34 +0000 (22:22 +0800)]
[RISCV] Add fixed-length vector instrinsics for segment load

Inspired by reviews.llvm.org/D107790.

Reviewed By: craig.topper

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

2 years ago[RISCV] Remove RISCVISD::VLE_VL/VSE_VL. Use intrinsics instead.
Craig Topper [Thu, 10 Mar 2022 06:44:27 +0000 (22:44 -0800)]
[RISCV] Remove RISCVISD::VLE_VL/VSE_VL. Use intrinsics instead.

Similar to what we do for other loads/stores, use the intrinsic
version that we already have custom isel for.

Reviewed By: rogfer01

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

2 years ago[RISCV] Add tests showing the optimization pipeline for O0 and O3.
Craig Topper [Thu, 10 Mar 2022 04:39:14 +0000 (20:39 -0800)]
[RISCV] Add tests showing the optimization pipeline for O0 and O3.

Other targets like ARM, AArch64, and X86 have similar tests.

Reviewed By: asb

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

2 years ago[BOLT][NFC] Fix print-cfg data race
Amir Ayupov [Thu, 10 Mar 2022 04:27:15 +0000 (20:27 -0800)]
[BOLT][NFC] Fix print-cfg data race

Addresses ThreadSanitizer warning

Reviewed By: rafauler

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

2 years ago[BOLT][NFC] Check errors from Obj.dynamicEntries
Amir Ayupov [Thu, 10 Mar 2022 04:24:20 +0000 (20:24 -0800)]
[BOLT][NFC] Check errors from Obj.dynamicEntries

Addresses fuzzer crash

Reviewed By: rafauler

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

2 years ago[libc] Use the constexpr constructor to initialize exit handlers mutex.
Siva Chandra Reddy [Wed, 9 Mar 2022 21:30:22 +0000 (21:30 +0000)]
[libc] Use the constexpr constructor to initialize exit handlers mutex.

Reviewed By: abrachet

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

2 years ago[MachineSink] Pre-commit test for D121277. NFC.
Carl Ritson [Thu, 10 Mar 2022 02:11:20 +0000 (11:11 +0900)]
[MachineSink] Pre-commit test for D121277. NFC.

2 years ago[clang][Driver] Get darwin -Xarch_ working for subtypes, again.
Ahmed Bougacha [Wed, 9 Mar 2022 23:52:21 +0000 (15:52 -0800)]
[clang][Driver] Get darwin -Xarch_ working for subtypes, again.

35ca7d9ddf4 broke 471c4f829934 for -arch flags that don't map 1:1
to the triple arch.  This has been broken for the many years since.
It hasn't mattered much since then, mostly because few people use it,
but also because it works for x86_64/i386, armv7/armv7s
don't differ much, arm64 is its own arch, and arm64/arm64_32 have
different arches (and it's a rare combination anyway).

But arm64/arm64e exposes this issue again.

Patch by: Justin Bogner <mail@justinbogner.com>
with some added tests.

2 years ago[HIP] Fix -fno-gpu-sanitize
Yaxun (Sam) Liu [Wed, 9 Mar 2022 16:52:48 +0000 (11:52 -0500)]
[HIP] Fix -fno-gpu-sanitize

Fix a typo about -fno-gpu-sanitize handling and disable warnings when
-fno-gpu-sanitize is specified.

Reviewed by: Artem Belevich

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

2 years ago[HIP] Fix HIP include path
Yaxun (Sam) Liu [Wed, 9 Mar 2022 14:10:17 +0000 (09:10 -0500)]
[HIP] Fix HIP include path

The clang compiler prepends the HIP header include paths to the search
list using -internal-isystem when building for the HIP language. This
prevents warnings related to things like reserved identifiers when
including the HIP headers even when ROCm is installed in a non-system
directory, such as /opt/rocm.

However, when HIP is installed in /usr, then the prepended include
path would be /usr/include. That is a problem, because the C standard
library headers are stored in /usr/include and the C++ standard
library headers must come before the C library headers in the search
path list (because the C++ standard library headers use #include_next
to include the C standard library headers).

While the HIP wrapper headers _do_ need to be earlier in the search
than the C++ headers, those headers get their own subdirectory and
their own explicit -internal-isystem argument. This include path is for
<hip/hip_runtime_api.h> and <hip/hip_runtime.h>, which do not require a
particular search ordering with respect to the C or C++ headers. Thus,
HIP include path is added after other system include paths.

With contribution from Cordell Bloor.

Reviewed by: Artem Belevich

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

2 years ago[gn build] Port c31014322c0b
LLVM GN Syncbot [Thu, 10 Mar 2022 01:35:38 +0000 (01:35 +0000)]
[gn build] Port c31014322c0b

2 years ago[Driver][OpenBSD] Disable unwind tables on Arm
Brad Smith [Thu, 10 Mar 2022 01:29:49 +0000 (20:29 -0500)]
[Driver][OpenBSD] Disable unwind tables on Arm

Arm is not quite ready for unwinding yet.

2 years agoTLS loads opimization (hoist)
Xiang1 Zhang [Wed, 2 Mar 2022 06:47:54 +0000 (14:47 +0800)]
TLS loads opimization (hoist)

Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D120000

2 years ago[Support] Try 2: Reset option to its default if its Default field is undefined
Yevgeny Rouban [Wed, 9 Mar 2022 11:10:21 +0000 (18:10 +0700)]
[Support] Try 2: Reset option to its default if its Default field is undefined

opt::setDefaultImpl() is changed to set the option value to the option
type's default if the Default field is not set. This results in option
value reset by Option::reset() or ResetAllOptionOccurrences() even if
the cl::init() is not specified.

Example:
  StackOption<std::string> Str("str"); // No cl::init().
  Str = "some value";
  cl::ResetAllOptionOccurrences();
  EXPECT_EQ("", Str); // The Str is reset.

Reviewed By: lattner
Differential Revision: https://reviews.llvm.org/D115433

2 years ago[msan] Fix unittest for 9397bdc6
Vitaly Buka [Thu, 10 Mar 2022 01:20:49 +0000 (01:20 +0000)]
[msan] Fix unittest for 9397bdc6

"1.1" is double which can't be represented precicely as a float.

2 years ago[RISCV] Support 'generic' as a valid CPU name.
Craig Topper [Thu, 10 Mar 2022 00:43:17 +0000 (16:43 -0800)]
[RISCV] Support 'generic' as a valid CPU name.

Most other targets support 'generic', but RISCV issues an error.
This can require a special case in tools that use LLVM that aren't
clang.

This patch treats "generic" the same as an empty string and remaps
it to generic-rv/rv64 based on the triple. Unfortunately, it has to
be added to RISCV.td because MCSubtargetInfo is constructed and
parses the CPU before RISCVSubtarget's constructor gets a chance
to remap it. The CPU will then reparsed and the state in the
MCSubtargetInfo subclass will be updated again.

Fixes PR54146.

Reviewed By: khchen

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

2 years ago[NFC] [HWASan] document why we tag Size but untag AlignedSize.
Florian Mayer [Thu, 10 Mar 2022 00:16:24 +0000 (16:16 -0800)]
[NFC] [HWASan] document why we tag Size but untag AlignedSize.

2 years ago[mlir][sparse] add end2end test for linalg.dot sparsification
Aart Bik [Wed, 9 Mar 2022 23:11:31 +0000 (15:11 -0800)]
[mlir][sparse] add end2end test for linalg.dot sparsification

Reviewed By: bixia

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

2 years ago[OpenMP][CUDA] Fix the check of `setContext`
Shilei Tian [Wed, 9 Mar 2022 23:48:44 +0000 (18:48 -0500)]
[OpenMP][CUDA] Fix the check of `setContext`

2 years ago[mlir][sparse] added linalg.dot to sparse kernel collection
Aart Bik [Wed, 9 Mar 2022 19:04:00 +0000 (11:04 -0800)]
[mlir][sparse] added linalg.dot to sparse kernel collection

Reviewed By: bixia

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

2 years agoRevert "[MSAN] add interceptor for timer_create, timer_settime, timer_gettime"
Kevin Athey [Wed, 9 Mar 2022 22:57:05 +0000 (14:57 -0800)]
Revert "[MSAN] add interceptor for timer_create, timer_settime, timer_gettime"

This reverts commit 0a4dec6cc2bf17acacc883cd897481028f1cf425.

breaks buildbots

2 years agoRevert "[MSAN] adjust Posix/timer.cpp"
Kevin Athey [Wed, 9 Mar 2022 22:55:12 +0000 (14:55 -0800)]
Revert "[MSAN] adjust Posix/timer.cpp"

This reverts commit f2a97536809588f1748d32d2e79c9a2a6b4ec335.

breaks buildbot

2 years ago[Analysis] remove bogus smin/smax pattern detection
Sanjay Patel [Wed, 9 Mar 2022 22:36:37 +0000 (17:36 -0500)]
[Analysis] remove bogus smin/smax pattern detection

This is a revert of cfcc42bdc. The analysis is wrong as shown by
the minimal tests for instcombine:
https://alive2.llvm.org/ce/z/y9Dp8A

There may be a way to salvage some of the other tests,
but that can be done as follow-ups. This avoids a miscompile
and fixes #54311.

2 years ago[InstCombine] add tests to show miscompiled smin/smax; NFC
Sanjay Patel [Wed, 9 Mar 2022 22:18:35 +0000 (17:18 -0500)]
[InstCombine] add tests to show miscompiled smin/smax; NFC

2 years ago[SDAG] Use MMO flags in MemSDNode folding
Stanislav Mekhanoshin [Wed, 9 Mar 2022 20:55:11 +0000 (12:55 -0800)]
[SDAG] Use MMO flags in MemSDNode folding

SDNodes with different target flags may now be folded together
rightfully resulting in the assertion in the refineAlignment.
Folding nodes with different target flags may result in the
wrong load instructions produced at least on the AMDGPU.

Fixes: SWDEV-326805

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

2 years agoRevert "[libc++] Remove extension to support allocator<const T>"
Louis Dionne [Wed, 9 Mar 2022 21:59:59 +0000 (16:59 -0500)]
Revert "[libc++] Remove extension to support allocator<const T>"

This reverts commit 276ca873. That commit has quite a history at this
point. It was first landed in dbc647643577, which broke std::shared_ptr<T const>
and was reverted in 9138666f5. It was then re-applied in 276ca873, with
the std::shared_ptr issue fixed, but it caused widespread breakage at
Google (which suggests it would cause similar breakage in the wild too),
so now I'm reverting again.

Instead, I will add a escape hatch that vendors can turn on to enable
the extension and perform a phased transition over one or two releases
like we sometimes do when things become non-trivial.

2 years ago[debug-info] Debug salvage llvm.dbg.addr in original function that point into the...
Michael Gottesman [Wed, 9 Mar 2022 19:33:49 +0000 (11:33 -0800)]
[debug-info] Debug salvage llvm.dbg.addr in original function that point into the coroutine frame when splitting coros.

We are already doing this in the split functions while we clone. This just
handles the original function.

I also updated the coroutine split test to validate that we are always referring
to the msg in the context object instead of in a shadow copy.

rdar://83957028

Reviewed By: aprantl

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

2 years ago[AArch64][SLP] Add a test with mutual reductions. NFC
David Green [Wed, 9 Mar 2022 21:46:57 +0000 (21:46 +0000)]
[AArch64][SLP] Add a test with mutual reductions. NFC

2 years ago[CompilerRT] Fix build of compiler-rt with musl
Colin Cross [Wed, 9 Mar 2022 20:45:45 +0000 (12:45 -0800)]
[CompilerRT] Fix build of compiler-rt with musl

Use the correct types for OFF_T, __sanitizer_time_t and
__sanitizer_dirent and forward time_t related functions
 to fix using compiler-rt with 32-bit musl libc.

Also redirect the time_t functions that are affected by
https://musl.libc.org/time64.html to use their 64-bit
ABI names.

Reviewed By: MaskRay

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

2 years ago[RISCV] Switch undef -> poison in fixed-vector RVV tests
Craig Topper [Wed, 9 Mar 2022 21:38:32 +0000 (13:38 -0800)]
[RISCV] Switch undef -> poison in fixed-vector RVV tests

2 years ago[OpenMP][CUDA] Avoid calling `cuCtxSetCurrent` redundantly
Shilei Tian [Wed, 9 Mar 2022 21:32:40 +0000 (16:32 -0500)]
[OpenMP][CUDA] Avoid calling `cuCtxSetCurrent` redundantly

Currently we set ccontext everywhere accordingly, but that causes many
unnecessary function calls. For example, in the resource pool, if we need to
resize the pool, we need to get from allocator. Each call to allocate sets the
current context once, which is unnecessary. In this patch, we set the context
only in the entry interface functions, if needed. Actually in the best way this
should be implemented via RAII, but since `cuCtxSetCurrent` could return error,
and we don't use exception, we can't stop the execution if RAII fails.

Reviewed By: jdoerfert

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

2 years ago[NFC][llvm-nm] create a new helper function exportSymbolNamesFromFiles for --export...
zhijian [Wed, 9 Mar 2022 21:28:55 +0000 (16:28 -0500)]
[NFC][llvm-nm] create a new helper function exportSymbolNamesFromFiles for --export-symbols
Summary:

create a new helper function exportSymbolNamesFromFiles for --export-symbols

Reviewer : James Henderson,Fangrui Song
Differential Revision: https://reviews.llvm.org/D120913

2 years agoRevert "Disable -Wmissing-prototypes for internal linkage functions that aren't expli...
David Blaikie [Wed, 9 Mar 2022 21:05:03 +0000 (21:05 +0000)]
Revert "Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static""

Regresses:
typedef struct {
  static void  f() {
  }
} a_t;

Causing this to error instead of warn, because the linkage is computed
earlier/too early perhaps. I'll send out a review to see if there's some
other path forward or if this is an acceptable regression, etc.

This reverts commit 275c56226d7fbd6a4d554807374f78d323aa0c1c.

2 years ago[MSAN] adjust Posix/timer.cpp
Kevin Athey [Wed, 9 Mar 2022 20:57:06 +0000 (12:57 -0800)]
[MSAN] adjust Posix/timer.cpp

follow up to 0a4dec6cc2bf.
add unsupported for s390 (SEGV)
restore line that s390 complains, so following asserts work.

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

2 years ago[LoopInterchange] Detect output dependency of a store instruction with itself
Congzhe Cao [Wed, 9 Mar 2022 20:49:05 +0000 (15:49 -0500)]
[LoopInterchange] Detect output dependency of a store instruction with itself

This patch is motivated by pr48057 where an output dependency is not detected
since loop interchange did not check a store instruction with itself.
Fixed that deficiency.

Reviewed By: bmahjour, Meinersbur, #loopoptwg

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

2 years ago[llvm-nm][NFC] remove global variable " std::vector<NMSymbol> SymbolList"
zhijian [Wed, 9 Mar 2022 20:13:26 +0000 (15:13 -0500)]
[llvm-nm][NFC] remove global variable " std::vector<NMSymbol> SymbolList"

Summary:

according to Jame's comment in the patch https://reviews.llvm.org/D112735
Created a NFC patch to remove global variable " std::vector<NMSymbol> SymbolList"

Reviewer : James Henderson,Fangrui Song
Differential Revision: https://reviews.llvm.org/D120687

2 years ago[flang][NFC] Remove old RTBuilder.h
Valentin Clement [Wed, 9 Mar 2022 19:57:09 +0000 (20:57 +0100)]
[flang][NFC] Remove old RTBuilder.h

RTBuilder.h has been moved in `flang/Optimizer/Builder/Runtime/RTBuilder.h`.
This duplicate is not necessary anymore.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

2 years ago[OpenMP][CUDA] Fix an issue that multiple `CUmodule` are could be overwritten
Shilei Tian [Wed, 9 Mar 2022 19:55:07 +0000 (14:55 -0500)]
[OpenMP][CUDA] Fix an issue that multiple `CUmodule` are could be overwritten

This patch fixes the issue introduced in 14de0820e87f and D120089, that
if dynamic libraries are used, the `CUmodule` array could be overwritten.

Reviewed By: jdoerfert

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

2 years ago[OpenMP][doc]Minor doc fixes
Mark Dewing [Wed, 9 Mar 2022 19:52:15 +0000 (14:52 -0500)]
[OpenMP][doc]Minor doc fixes

In SupportAndFAQ.rst, add blank lines before and after a bullet list and
sublist.  This avoids an "Unepxected indentation" warning.

In Runtimes.rst, adjust the suggestion for setting LIBOMPTARGET_INFO.
The right shifts are not necessary as the bit mask values are already
correct.

Reviewed By: jdoerfert

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

2 years ago[llvm-nm]add helper function to print out the object file name, archive name, archite...
zhijian [Wed, 9 Mar 2022 19:45:27 +0000 (14:45 -0500)]
[llvm-nm]add helper function to print out the object file name, archive name, architecture name

Summary:

1. added helper function printObjectNamesInfo() to print out  object file name, archive name, architecture name.
2.  One small behaviors change.

     in the function dumpMachOUniversalBinaryArchAll , delete the functionality:

if (moreThanOneArch)
               outs() << "\n";

Reviewer : James Henderson,Fangrui Song
Differential Revision: https://reviews.llvm.org/D120357

2 years ago[MSAN] add interceptor for timer_create, timer_settime, timer_gettime
Kevin Athey [Wed, 9 Mar 2022 19:19:58 +0000 (11:19 -0800)]
[MSAN] add interceptor for timer_create, timer_settime, timer_gettime

Reviewed By: vitalybuka

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

2 years ago[DebugInfo][SROA] Correct debug info for global variables in case of SROA
Alok Kumar Sharma [Wed, 9 Mar 2022 19:11:30 +0000 (00:41 +0530)]
[DebugInfo][SROA] Correct debug info for global variables in case of SROA

The existing handling produced crash for test case (attached with patch).
Now the function transferSRADebugInfo is modified to
  - Ignore the current variable if it starts after the current Fragment.
  - Ignore the current variable if it ends before the current Fragment.
  - Generate (!DIExpression()) if current variable completely fits the
    current Fragment.
  - Otherwise (as earlier), generate the DW_OP_LLVM_fragment in IR if current
    Fragment partially defines current variable.

Reviewed By: aprantl

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

2 years ago[flang] Lower more array character cases
Valentin Clement [Wed, 9 Mar 2022 18:50:17 +0000 (19:50 +0100)]
[flang] Lower more array character cases

This patch adds more lowering and tests for character array assignment/copy.

This patch is part of the upstreaming effort from fir-dev branch.

Depends on D121300

Reviewed By: PeteSteinfeld, schweitz

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agolldb/ObjectFile: reflow a comment (NFC)
Saleem Abdulrasool [Wed, 9 Mar 2022 18:46:29 +0000 (18:46 +0000)]
lldb/ObjectFile: reflow a comment (NFC)

Reflow the textual comment which preserves formatted output from
tooling.  This makes the content legible again after the lldb source
code was reformatted with automated tooling.

2 years agoRevert "[PassManager] Add pretty stack entries before P->run() call."
Florian Hahn [Wed, 9 Mar 2022 18:46:11 +0000 (18:46 +0000)]
Revert "[PassManager] Add pretty stack entries before P->run() call."

This reverts commit 128745cc2681c284bc6d0150a319673a6d6e8424.

This increased compile-time unnecessarily. Revert this change and follow
ups 2c7afadb4789 & add0c5856d5f.

http://llvm-compile-time-tracker.com/compare.php?from=338dfcd60f843082bb589b287d890dbd9394eb82&to=128745cc2681c284bc6d0150a319673a6d6e8424&stat=instructions

2 years agoRevert "[MSAN] add interceptor for timer_create, timer_settime, timer_gettime"
Petr Hosek [Wed, 9 Mar 2022 18:45:27 +0000 (10:45 -0800)]
Revert "[MSAN] add interceptor for timer_create, timer_settime, timer_gettime"

This reverts commit c2aab0d3808b3e3058febe637148ca66b0f03c71 due to
a leak in timer.cpp that showed up on several bots.

2 years ago[IROutliner] Handling outlined code with no exit paths
Andrew Litteken [Thu, 3 Mar 2022 04:50:40 +0000 (22:50 -0600)]
[IROutliner] Handling outlined code with no exit paths

As a result of adding multiblock outlining, it became possible to outline the entirety of basic block, and branches that only pointed to the basic blocks contained in the outlined section. This means that there are no exit paths, and no return statement. There was a previous assertion from the older version of the outliner that explicitly made sure there was a return statement. This removes that assertion.

Reviewers: paquette

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

2 years agoAArch64: correct epilogue/prologue emission for swift async
Saleem Abdulrasool [Wed, 9 Mar 2022 04:12:59 +0000 (20:12 -0800)]
AArch64: correct epilogue/prologue emission for swift async

The prologue and epilogue emission were unbalanced in light of different
strategies of async frame context emission.  Adjust the epilogue emission
to match the prologue emission.  This makes the elision work properly as
well as the deployment based.  Due to the fact that the epilogue always
was clearing a bit (which should not be set in the first place), the
client would not notice the behavioural issue unless the deployment
version was in effect.

2 years ago[flang] Update ArrayValueCopy to support array_amend and array_access
Valentin Clement [Wed, 9 Mar 2022 18:32:55 +0000 (19:32 +0100)]
[flang] Update ArrayValueCopy to support array_amend and array_access

This patch update the array value copy pass to support fir-array_amend
and fir.array_access.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld, schweitz

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[sanitizer][mips] Fix the condition to include sanitizer_atomic_clang_mips.h
Xi Ruoyao [Wed, 9 Mar 2022 18:20:05 +0000 (10:20 -0800)]
[sanitizer][mips] Fix the condition to include sanitizer_atomic_clang_mips.h

The Glibc header [1] define _ABIO32 unconditionally on MIPS.  So we need
to compare _MIPS_SIM and _ABIO32 to know if we are actually building for
MIPS32.  Using sanitizer_atomic_clang_mips.h can cause test failures and
hangs on MIPS64.

[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/sgidefs.h

Reviewed By: dvyukov, vitalybuka, MaskRay

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

2 years ago[SDAG] match rotate pattern with extra 'or' operation
Sanjay Patel [Wed, 9 Mar 2022 18:12:43 +0000 (13:12 -0500)]
[SDAG] match rotate pattern with extra 'or' operation

This is another fold generalized from D111530.
We can find a common source for a rotate operation hidden inside an 'or':
https://alive2.llvm.org/ce/z/9pV8hn

Deciding when this is profitable vs. a funnel-shift is tricky, but this
does not show any regressions: if a target has a rotate but it does not
have a funnel-shift, then try to form the rotate here. That is why we
don't have x86 test diffs for the scalar tests that are duplicated from
AArch64 ( 74a65e3834d9487 ) - shld/shrd are available. That also makes it
difficult to show vector diffs - the only case where I found a diff was
on x86 AVX512 or XOP with i64 elements.

There's an additional check for a legal type to avoid a problem seen
with x86-32 where we form a 64-bit rotate but then it gets split
inefficiently. We might avoid that by adding more rotate folds, but
I didn't check to see what is missing on that path.

This gets most of the motivating patterns for AArch64 / ARM that are in
D111530.

We still need a couple of enhancements to setcc pattern matching with
rotate/funnel-shift to get the rest.

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

2 years agoAMDGPU: Set up User SGPRs for queue_ptr only when necessary
Changpeng Fang [Wed, 9 Mar 2022 18:14:05 +0000 (10:14 -0800)]
AMDGPU: Set up User SGPRs for queue_ptr only when necessary

Summary:
  In general, we need queue_ptr for aperture bases and trap handling,
and user SGPRs have to be set up to hold queue_ptr. In current implementation,
user SGPRs are set up unnecessarily for some cases. If the target has aperture
registers, queue_ptr is not needed to reference aperture bases. For trap
handling, if target suppots getDoorbellID, queue_ptr is also not necessary.
Futher, code object version 5 introduces new kernel ABI which passes queue_ptr
as an implicit kernel argument, so user SGPRs are no longer necessary for
queue_ptr. Based on the trap handling document:
https://llvm.org/docs/AMDGPUUsage.html#amdgpu-trap-handler-for-amdhsa-os-v4-onwards-table,
llvm.debugtrap does not need queue_ptr, we remove queue_ptr suport for llvm.debugtrap
in the backend.

Reviewers: sameerds, arsenm

Fixes: SWDEV-307189

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

2 years ago[AMDGPU] Merge flat with global in the SILoadStoreOptimizer
Stanislav Mekhanoshin [Thu, 24 Feb 2022 19:32:21 +0000 (11:32 -0800)]
[AMDGPU] Merge flat with global in the SILoadStoreOptimizer

Flat can be merged with flat global since address cast is a no-op.
A combined memory operation needs to be promoted to flat.

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

2 years ago[AMDGPU] Remove HasAtomicFaddInstsGFX90X and HasAtomicFaddInstsGFX940
Jay Foad [Wed, 9 Mar 2022 14:59:09 +0000 (14:59 +0000)]
[AMDGPU] Remove HasAtomicFaddInstsGFX90X and HasAtomicFaddInstsGFX940

These compound predicates are not required, since we can use a
combination of setting the SubtargetPredicate (to a subtarget
predicate like isGFX940Plus) and OtherPredicates (to a list of feature
predicates like HasAtomicFaddInsts) instead. NFC.

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

2 years agoFix linking error, undefined class static constants.
Benoit Jacob [Wed, 9 Mar 2022 18:00:54 +0000 (10:00 -0800)]
Fix linking error, undefined class static constants.

Reviewed By: spupyrev

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

2 years ago[libc++] Enable format_to and vformat_to tests even outside of Debug mode
Louis Dionne [Tue, 8 Mar 2022 19:48:16 +0000 (14:48 -0500)]
[libc++] Enable format_to and vformat_to tests even outside of Debug mode

These tests don't seem specific to the debug mode, so it makes sense to
run them even when the debug mode is disabled. When we run with the debug
mode enabled, we'll get the out-of-bounds checking that this test seems
to be concerned with.

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

2 years ago[flang] Add OpenACC flag to bbc
Valentin Clement [Wed, 9 Mar 2022 17:35:14 +0000 (18:35 +0100)]
[flang] Add OpenACC flag to bbc

Add `-fopenacc` flag to the `bbc` tool.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

2 years ago[AMDGPU] Add scheduler pass to rematerialize trivial defs
Vang Thao [Thu, 10 Feb 2022 17:16:09 +0000 (09:16 -0800)]
[AMDGPU] Add scheduler pass to rematerialize trivial defs

Add a new pass in the pre-ra AMDGPU scheduler to check if sinking trivially rematerializable defs that only has one use outside of the defining block will increase occupancy. If we can determine that occupancy can be increased, then rematerialize only the minimum amount of defs required to increase occupancy. Also re-schedule all regions that had occupancy matching the previous min occupancy using the new occupancy.

This is based off of the discussion in https://reviews.llvm.org/D117562.

The logic to determine the defs we should collect and determining if sinking would be beneficial is mostly the same. Main differences is that we are no longer limiting it to immediate defs and the def and use does not have to be part of a loop.

Reviewed By: rampitec

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

2 years ago[flang] Add OpenMP flag to bbc
Valentin Clement [Wed, 9 Mar 2022 17:30:46 +0000 (18:30 +0100)]
[flang] Add OpenMP flag to bbc

Add `-fopenmp` flag to the `bbc` tool.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz, awarzynski

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

2 years ago[InstCombine] Preserve FMF in foldLogicOfFCmps.
Craig Topper [Wed, 9 Mar 2022 17:07:22 +0000 (09:07 -0800)]
[InstCombine] Preserve FMF in foldLogicOfFCmps.

This patch intersects the fast math flags from the two fcmps instead
of dropping them.

I poked at this a bunch with Alive2 for nnan and ninf flags and it seemed
to check out. With the other flags it told me "Couldn't prove the
correctness of the transformation". Not sure if I should just preserve
nnan and ninf?

Reviewed By: spatel, lebedev.ri

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

2 years agoRevert "[lldb] Remove the global platform list"
Pavel Labath [Wed, 9 Mar 2022 17:12:28 +0000 (18:12 +0100)]
Revert "[lldb] Remove the global platform list"

It makes module dependencies loopier.

This reverts commits 49cffe3c7fab74252d4b6a073303c803dc1659f0 and
ffb9429b6f3c29ab4687b96fd85374924c98ad16.

2 years ago[AMDGPU] Fix some confusing check prefixes. NFC.
Jay Foad [Wed, 9 Mar 2022 17:03:09 +0000 (17:03 +0000)]
[AMDGPU] Fix some confusing check prefixes. NFC.

Tahiti is SI/GFX6.
Kaveri and Hawaii are CI/GFX7.
Fiji is VI/GFX8.

2 years ago[flang] Fix extent computation in finalization
Peter Klausler [Tue, 1 Mar 2022 19:50:49 +0000 (11:50 -0800)]
[flang] Fix extent computation in finalization

The code that computed the extent of a dimension of a
non-allocatable/non-automatic component array during
finalization had a reversed subtraction; fix, and
use variables to make the code a little more readable.

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

2 years ago[libc++][NFC] Cleanups in <charconv>.
Mark de Wever [Tue, 8 Mar 2022 16:34:33 +0000 (17:34 +0100)]
[libc++][NFC] Cleanups in <charconv>.

Based on review comments in D97705 applied some code cleanups in
<charconv>. The header now uses a more recent libc++ style.

Reviewed By: Quuxplusone, #libc, philnik

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

2 years ago[gn build] (manually) port ffb9429b6f3c29ab
Nico Weber [Wed, 9 Mar 2022 16:42:33 +0000 (11:42 -0500)]
[gn build] (manually) port ffb9429b6f3c29ab

2 years ago[lldb] Fix step-avoid-regexp logging
Dave Lee [Tue, 8 Feb 2022 23:34:04 +0000 (15:34 -0800)]
[lldb] Fix step-avoid-regexp logging

Ensure step-avoid-regexp logs are emitted in the case where the regex has no
capture groups.

Without this change, the log is printed only if the regex has at least one
capture group.

Another change is to the log message: the first capture group has been removed
from the message. There could be zero capture groups, and there could be two or
more capture groups.

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

2 years ago[lldb] Add SBType::IsAggregateType
Dave Lee [Tue, 8 Mar 2022 22:17:08 +0000 (14:17 -0800)]
[lldb] Add SBType::IsAggregateType

Add `IsAggregateType` to the SB API.

I'd like to use this from tests, and there are numerous other `Is<X>Type`
predicates on `SBType`.

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

2 years ago[LV] Do not consider instrs dead if used by phi that's not in plan.
Florian Hahn [Wed, 9 Mar 2022 16:04:44 +0000 (16:04 +0000)]
[LV] Do not consider instrs dead if used by phi that's not in plan.

Single value phis won't be modeled in VPlan. If the phi only gets used
outside the loop, the current code misses the fact that the incoming
value is not dead. Update the code to also look through such phis to
check for outside users.

Fixes #54266

2 years ago[lldb] Fix TestDebuggerAPI on windows (broken by D120810)
Pavel Labath [Wed, 9 Mar 2022 15:52:51 +0000 (16:52 +0100)]
[lldb] Fix TestDebuggerAPI on windows (broken by D120810)

2 years ago[flang][driver] Add support for -S and implement -c/-emit-obj
Andrzej Warzynski [Thu, 24 Feb 2022 17:34:27 +0000 (17:34 +0000)]
[flang][driver] Add support for -S and implement -c/-emit-obj

This patch adds support for:
  * `-S` in Flang's compiler and frontend drivers,
and implements:
  * `-emit-obj` in Flang's frontend driver and `-c` in Flang's compiler
    driver (this is consistent with Clang).
(these options were already available before, but only as placeholders).
The semantics of these options in Clang and Flang are identical.

The `EmitObjAction` frontend action is renamed as `BackendAction`. This
new name more accurately reflects the fact that this action will
primarily run the code-gen/backend pipeline in LLVM. It also makes more
sense as an action implementing both `-emit-obj` and `-S` (originally,
it was just `-emit-obj`).

`tripleName` from FirContext.cpp is deleted and, when a target triple is
required, `mlir::LLVM::LLVMDialect::getTargetTripleAttrName()` is used
instead. In practice, this means that `fir.triple` is replaced with
`llvm.target_triple`. The former was effectively ignored. The latter is
used when lowering from the LLVM dialect in MLIR to LLVM IR (i.e. it's
embedded in the generated LLVM IR module). The driver can then re-use
it when configuring the backend. With this change, the LLVM IR files
generated by e.g. `tco` will from now on contain the correct target
triple.

The code-gen.f90 test is replaced with code-gen-x86.f90 and
code-gen-aarch64.f90. With 2 seperate files we can verify that
`--target` is correctly taken into account. LIT configuration is updated
to enable e.g.:
```
! REQUIRES: aarch64-registered-target
```

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

2 years agoRevert "[clang][dataflow] Move dataflow testing support out of unittests"
Stanislav Gatev [Wed, 9 Mar 2022 15:38:51 +0000 (15:38 +0000)]
Revert "[clang][dataflow] Move dataflow testing support out of unittests"

This reverts commit 26bbde2612b2042c3a8a31aed7f45e065c3dd413.

2 years ago[clang][dataflow] Move dataflow testing support out of unittests
Stanislav Gatev [Wed, 9 Mar 2022 13:17:52 +0000 (13:17 +0000)]
[clang][dataflow] Move dataflow testing support out of unittests

This enables tests out of clang/unittests/Analysis/FlowSensitive to
use the testing support utilities.

Reviewed-by: ymandel, gribozavr2
Differential Revision: https://reviews.llvm.org/D121285

2 years ago[MachinePipeliner] Fix isPseduo typo.
Thomas Preud'homme [Wed, 9 Mar 2022 15:26:27 +0000 (15:26 +0000)]
[MachinePipeliner] Fix isPseduo typo.

2 years agoAdd the C and C++ Language Working Group meeting info
Aaron Ballman [Wed, 9 Mar 2022 15:18:35 +0000 (10:18 -0500)]
Add the C and C++ Language Working Group meeting info

2 years ago[lldb] Remove the global platform list
Pavel Labath [Fri, 25 Feb 2022 13:47:27 +0000 (14:47 +0100)]
[lldb] Remove the global platform list

This patch moves the platform creation and selection logic into the
per-debugger platform lists. I've tried to keep functional changes to a
minimum -- the main (only) observable difference in this change is that
APIs, which select a platform by name (e.g.,
Debugger::SetCurrentPlatform) will not automatically pick up a platform
associated with another debugger (or no debugger at all).

I've also added several tests for this functionality -- one of the
pleasant consequences of the debugger isolation is that it is now
possible to test the platform selection and creation logic.

This is a product of the discussion at
<https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>.

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

2 years ago[libc++] Don't manually override NDEBUG in the dylib build
Louis Dionne [Tue, 8 Mar 2022 20:13:24 +0000 (15:13 -0500)]
[libc++] Don't manually override NDEBUG in the dylib build

LIBCXX_ENABLE_ASSERTIONS does not have any relationship to the `assert`
macro -- it only controls assertions that are internal to the library.
Playing around with `NDEBUG` only muddies the picture further than it
already is.

Also, remove a failing assertion in the benchmarks. That assertion had
never been exercised because we defined `NDEBUG` manually, and it was
failing since we introduced the ability to generate a benchmark vector
with the Quicksort adversary ordering (which is obviously not sorted).

This was split off of https://llvm.org/D121123.

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

2 years ago[mlir][OpenMP] Generating enums in accordance with the guidelines
Shraiysh Vaishay [Wed, 9 Mar 2022 09:33:17 +0000 (15:03 +0530)]
[mlir][OpenMP] Generating enums in accordance with the guidelines

This patch changes the enums generated from `OMP.td` for MLIR according
to the enum naming guidelines in LLVM Coding Standards.

This also helps the issues we had with `static` being a C++ keyword and
also a value for the schedule clause.

Enumerator naming guidelines: https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly

Reviewed By: kiranchandramohan

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

2 years ago[X86] Add shift identity select tests
Simon Pilgrim [Wed, 9 Mar 2022 14:26:39 +0000 (14:26 +0000)]
[X86] Add shift identity select tests

Extension to D119654

2 years ago[JITLink][RISCV] Refactor range checking and alignment checking
fourdim [Wed, 9 Mar 2022 14:13:28 +0000 (22:13 +0800)]
[JITLink][RISCV] Refactor range checking and alignment checking

This patch refactors the range checking function to make it compatible with all relocation types and supports range checking for R_RISCV_BRANCH. Moreover, it refactors the alignment check functions.

Reviewed By: StephenFan

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

2 years ago[PassManager] Another adjustment to account for different printing.
Florian Hahn [Wed, 9 Mar 2022 14:09:23 +0000 (14:09 +0000)]
[PassManager] Another adjustment to account for different printing.

On some system, there's extra `class` specifiers when printing pass
manager types.

2 years ago[clang][sema] Enable first-class bool support for C2x
Timm Bäder [Mon, 21 Feb 2022 12:25:04 +0000 (13:25 +0100)]
[clang][sema] Enable first-class bool support for C2x

Implement N2395 for C2x.

This also covers adding "bool", which is part of N2394.

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

2 years ago[llvm-dwarfdump] Avoid possible div-by-zero in debug output
Dmitry Vassiliev [Wed, 9 Mar 2022 14:03:26 +0000 (18:03 +0400)]
[llvm-dwarfdump] Avoid possible div-by-zero in debug output

2 years ago[Coroutines] Avoid pointer element access for resume function type
Nikita Popov [Wed, 9 Mar 2022 13:45:24 +0000 (14:45 +0100)]
[Coroutines] Avoid pointer element access for resume function type

For switch ABI, the function type is always "void (%frame*)", so
just hardcode that rather than fetching it from a pointer element
type.

2 years ago[lldb] Don't print *trailing* nuls in char arrays
Pavel Labath [Wed, 2 Mar 2022 09:49:55 +0000 (10:49 +0100)]
[lldb] Don't print *trailing* nuls in char arrays

Embedded nul characters are still printed, and they don't terminate the
string. See also D111634.

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

2 years ago[lldb/driver] Fix SIGTSTP handling
Pavel Labath [Tue, 22 Feb 2022 13:25:39 +0000 (14:25 +0100)]
[lldb/driver] Fix SIGTSTP handling

Our SIGTSTP handler was working, but that was mostly accidental.

The reason it worked is because lldb is multithreaded for most of its
lifetime and the OS is reasonably fast at responding to signals. So,
what happened was that the kill(SIGTSTP) which we sent from inside the
handler was delivered to another thread while the handler was still set
to SIG_DFL (which then correctly put the entire process to sleep).

Sometimes it happened that the other thread got the second signal after
the first thread had already restored the handler, in which case the
signal handler would run again, and it would again attempt to send the
SIGTSTP signal back to itself.

Normally it didn't take many iterations for the signal to be delivered
quickly enough. However, if you were unlucky (or were playing around
with pexpect) you could get SIGTSTP while lldb was single-threaded, and
in that case, lldb would go into an endless loop because the second
SIGTSTP could only be handled on the main thread, and only after the
handler for the first signal returned (and re-installed itself). In that
situation the handler would keep re-sending the signal to itself.

This patch fixes the issue by implementing the handler the way it
supposed to be done:
- before sending the second SIGTSTP, we unblock the signal (it gets
  automatically blocked upon entering the handler)
- we use raise to send the signal, which makes sure it gets delivered to
  the thread which is running the handler

This also means we don't need the SIGCONT handler, as our TSTP handler
resumes right after the entire process is continued, and we can do the
required work there.

I also include a test case for the SIGTSTP flow. It uses pexpect, but it
includes a couple of extra twists. Specifically, I needed to create an
extra process on top of lldb, which will run lldb in a separate process
group and simulate the role of the shell. This is needed because SIGTSTP
is not effective on a session leader (the signal gets delivered, but it
does not cause a stop) -- normally there isn't anyone to notice the
stop.

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

2 years ago[lldb] Warn when we fail to find dwo/dwp files
Pavel Labath [Thu, 3 Mar 2022 11:32:52 +0000 (12:32 +0100)]
[lldb] Warn when we fail to find dwo/dwp files

This ensures that the user is aware that many commands will not work
correctly.

We print the warning only once (per module) to avoid spamming the user
with potentially thousands of error messages.

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

2 years ago[PassManager] Adjust check lines to account for different printing.
Florian Hahn [Wed, 9 Mar 2022 13:20:15 +0000 (13:20 +0000)]
[PassManager] Adjust check lines to account for different printing.

Relax some checks to account for types being printed differently on
different platforms, surfaced by different buildbots.

2 years ago[PassManager] Add pretty stack entries before P->run() call.
Florian Hahn [Wed, 9 Mar 2022 13:01:09 +0000 (13:01 +0000)]
[PassManager] Add pretty stack entries before P->run() call.

This patch adds PrettyStackEntries before running passes. The entries
include the pass name and the IR unit the pass runs on.

The information is used the print additional information when a pass
crashes, including the name and a reference to the IR unit on which it
crashed. This is similar to the behavior of the legacy pass manager.

The improved stack trace now includes:

Stack dump:
0. Program arguments: bin/opt -loop-vectorize -force-vector-width=4 crash.ll
1. Running pass 'ModuleToFunctionPassAdaptor' on module 'crash.ll'
2. Running pass 'LoopVectorizePass' on function '@a'

Reviewed By: aeubanks

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

2 years agoUpdate my office hours
Aaron Ballman [Wed, 9 Mar 2022 12:57:30 +0000 (07:57 -0500)]
Update my office hours

Adds "frontend attributes" to the list of things to come talk about,
removes the extra timezone information to hopefully reduce confusion
about daylight savings time.

2 years ago[IR] MatrixBuilder - CreateIndexAssumption - fix unused variable warning on NDEBUG...
Simon Pilgrim [Wed, 9 Mar 2022 12:02:37 +0000 (12:02 +0000)]
[IR] MatrixBuilder - CreateIndexAssumption - fix unused variable warning on NDEBUG builds

2 years ago[BOLT] Move some of the tests to common directory
Vladislav Khmelevsky [Tue, 8 Mar 2022 23:16:13 +0000 (02:16 +0300)]
[BOLT] Move some of the tests to common directory

Some of the tests are not x86-specific, move them to common directory.

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

2 years ago[lldb] Fix -Wformat warning after 5a27b99825a5ba3a7a2eec3d35aea381a3ba9a31
Krasimir Georgiev [Wed, 9 Mar 2022 11:39:09 +0000 (12:39 +0100)]
[lldb] Fix -Wformat warning after 5a27b99825a5ba3a7a2eec3d35aea381a3ba9a31

No functional changes intended.

2 years ago[clang] ScalarExprEmitter::VisitCastExpr - use castAs<> instead of getAs<> to avoid...
Simon Pilgrim [Wed, 9 Mar 2022 11:21:38 +0000 (11:21 +0000)]
[clang] ScalarExprEmitter::VisitCastExpr - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointers are always dereferenced, so assert the cast is correct instead of returning nullptr

2 years ago[clang] Environment::createValueUnlessSelfReferential - use castAs<> instead of getAs...
Simon Pilgrim [Wed, 9 Mar 2022 10:51:43 +0000 (10:51 +0000)]
[clang] Environment::createValueUnlessSelfReferential - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr

2 years ago[X86] Add common check prefixes to vector-bitreverse.ll
Simon Pilgrim [Wed, 9 Mar 2022 10:48:45 +0000 (10:48 +0000)]
[X86] Add common check prefixes to vector-bitreverse.ll

2 years ago[clang] Sema::ActOnModuleImport - remove superfluous nullptr test
Simon Pilgrim [Wed, 9 Mar 2022 10:47:26 +0000 (10:47 +0000)]
[clang] Sema::ActOnModuleImport - remove superfluous nullptr test

Mod has already been dereferenced

2 years agoFix for buildbot failure: https://lab.llvm.org/buildbot#builders/110/builds/11051
Alexey Lapshin [Wed, 9 Mar 2022 11:25:10 +0000 (14:25 +0300)]
Fix for buildbot failure: https://lab.llvm.org/buildbot#builders/110/builds/11051
after https://reviews.llvm.org/D121005

2 years ago[NFC] [C++20] [Modules] Add test to show private module fragment is not allowed in...
Chuanqi Xu [Wed, 9 Mar 2022 11:05:41 +0000 (19:05 +0800)]
[NFC] [C++20] [Modules] Add test to show private module fragment is not allowed in partition unit

2 years agoNFC. Clean up memref utils library
Uday Bondhugula [Wed, 9 Mar 2022 06:25:49 +0000 (11:55 +0530)]
NFC. Clean up memref utils library

NFC. Clean up memref utils library. This library had a single function
that was completely misplaced. MemRefUtils is expected to be (also per
its comment) a library providing analysis/transforms utilities on memref
dialect ops or memref types. However, in reality it had a helper that
was depended upon by the MemRef dialect, i.e., it was a helper for the
dialect ops library and couldn't contain anything that itself depends on
the MemRef dialect. Move the single method to the memref dialect that
will now allow actual utilities depending on the memref dialect to be
placed in it.

Put findDealloc in the `memref` namespace. This is a pure move.

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

2 years ago[flang] Remove 'using namespace mlir;` from header files
Andrzej Warzynski [Thu, 3 Mar 2022 13:25:09 +0000 (13:25 +0000)]
[flang] Remove 'using namespace mlir;` from header files

Currently, CGOps.h and FIROps.h contain `using namespace mlir;`. Every
file that includes one of these header files (directly and transitively)
will have the MLIR namespace enabled. With name-clashes within
sub-projects (LLVM and MLIR, MLIR and Flang), this is not desired. Also,
it is not possible to "un-use" a namespace once it is "used". Instead,
we should try to limit `using namespace` to implementation files (i.e.
*.cpp).

This patch removes `using namespace mlir;` from header files and adjusts
other files accordingly. In header and TableGen files, extra namespace
qualifier is added when referring to symbols defined in MLIR. Similar
approach is adopted in source files that didn't require many changes. In
files that would require a lot of changes, `using namespace mlir;` is
added instead.

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