[llvm-branch-commits] [mlir] d9adde5 - [mlir][gpu] Move gpu.wait ops from async.execute regions to its dependencies.

2020-12-02 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2020-12-03T08:52:28+01:00
New Revision: d9adde5ae2164ed076d5683fd716deec49400d8b

URL: 
https://github.com/llvm/llvm-project/commit/d9adde5ae2164ed076d5683fd716deec49400d8b
DIFF: 
https://github.com/llvm/llvm-project/commit/d9adde5ae2164ed076d5683fd716deec49400d8b.diff

LOG: [mlir][gpu] Move gpu.wait ops from async.execute regions to its 
dependencies.

This can prevent unnecessary host synchronization.

Reviewed By: herhut

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

Added: 


Modified: 
mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp
mlir/test/Dialect/GPU/async-region.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp 
b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp
index 917c27714b4a..f2c7010be291 100644
--- a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "PassDetail.h"
+#include "mlir/Dialect/Async/IR/Async.h"
 #include "mlir/Dialect/GPU/GPUDialect.h"
 #include "mlir/Dialect/GPU/Passes.h"
 #include "mlir/Dialect/GPU/Utils.h"
@@ -22,24 +23,35 @@
 #include "mlir/IR/SymbolTable.h"
 #include "mlir/Support/LLVM.h"
 #include "mlir/Transforms/RegionUtils.h"
+#include "llvm/ADT/TypeSwitch.h"
 
 using namespace mlir;
 namespace {
 class GpuAsyncRegionPass : public GpuAsyncRegionPassBase {
-  struct Callback;
+  struct ThreadTokenCallback;
+  struct DeferWaitCallback;
   void runOnFunction() override;
 };
 } // namespace
 
+static bool isTerminator(Operation *op) { return !op->isKnownNonTerminator(); }
+static bool hasSideEffects(Operation *op) {
+  return !MemoryEffectOpInterface::hasNoEffect(op);
+}
+
 // Region walk callback which makes GPU ops implementing the AsyncOpInterface
 // execute asynchronously.
-struct GpuAsyncRegionPass::Callback {
+struct GpuAsyncRegionPass::ThreadTokenCallback {
+  ThreadTokenCallback(MLIRContext ) : builder() {}
+
   // If `op` implements the AsyncOpInterface, insert a `gpu.wait async` to
   // create a current token (unless it already exists), and 'thread' that token
   // through the `op` so that it executes asynchronously.
   //
   // If `op` is a terminator or an op with side-effects, insert a `gpu.wait` to
-  // host-synchronize execution.
+  // host-synchronize execution. A `!gpu.async.token` will therefore only be
+  // used inside of its block and GPU execution will always synchronize with
+  // the host at block boundaries.
   WalkResult operator()(Operation *op) {
 if (isa(op))
   return op->emitOpError("replace with gpu.launch_func first");
@@ -50,14 +62,13 @@ struct GpuAsyncRegionPass::Callback {
   return rewriteAsyncOp(asyncOp); // Replace GPU op with async version.
 if (!currentToken)
   return success();
-if (!op->hasTrait() &&
-MemoryEffectOpInterface::hasNoEffect(op))
-  return success();
 // Insert host synchronization before terminator or op with side effects.
-currentToken = createWaitOp(op->getLoc(), Type(), {currentToken});
+if (isTerminator(op) || hasSideEffects(op))
+  currentToken = createWaitOp(op->getLoc(), Type(), {currentToken});
 return success();
   }
 
+private:
   // Replaces asyncOp with a clone that returns a token.
   LogicalResult rewriteAsyncOp(gpu::AsyncOpInterface asyncOp) {
 auto *op = asyncOp.getOperation();
@@ -104,13 +115,159 @@ struct GpuAsyncRegionPass::Callback {
   Value currentToken = {};
 };
 
+// Callback for `async.execute` ops which tries to push the contained
+// synchronous `gpu.wait` op to the dependencies of the `async.execute`.
+struct GpuAsyncRegionPass::DeferWaitCallback {
+  // If the `executeOp`s token is used only in `async.execute` or `async.await`
+  // ops, add the region's last `gpu.wait` op to the worklist if it is
+  // synchronous and is the last op with side effects.
+  void operator()(async::ExecuteOp executeOp) {
+if (!areAllUsersExecuteOrAwait(executeOp.token()))
+  return;
+// async.execute's region is currently restricted to one block.
+for (auto  : llvm::reverse(executeOp.getBody()->without_terminator())) {
+  if (auto waitOp = dyn_cast(op)) {
+if (!waitOp.asyncToken())
+  worklist.push_back(waitOp);
+return;
+  }
+  if (hasSideEffects())
+return;
+}
+  }
+
+  // The destructor performs the actual rewrite work.
+  ~DeferWaitCallback() {
+for (size_t i = 0; i < worklist.size(); ++i) {
+  auto waitOp = worklist[i];
+  auto executeOp = waitOp.getParentOfType();
+  auto numDependencies = waitOp.asyncDependencies().size();
+
+  // Erase `gpu.wait` and return async dependencies from region instead.
+  auto  = executeOp.getBody()->getOperations().back();
+  

[llvm-branch-commits] [clang] a36f8fb - [NFC] Add proper triple for arc.ll test

2020-12-02 Thread via llvm-branch-commits

Author: Yuanfang Chen
Date: 2020-12-02T23:31:06-08:00
New Revision: a36f8fb021d0a1719400eda446131290be21c3ed

URL: 
https://github.com/llvm/llvm-project/commit/a36f8fb021d0a1719400eda446131290be21c3ed
DIFF: 
https://github.com/llvm/llvm-project/commit/a36f8fb021d0a1719400eda446131290be21c3ed.diff

LOG: [NFC] Add proper triple for arc.ll test

Added: 


Modified: 
clang/test/CodeGenObjC/arc.ll

Removed: 




diff  --git a/clang/test/CodeGenObjC/arc.ll b/clang/test/CodeGenObjC/arc.ll
index f23c656c3498..7b903d05cd17 100644
--- a/clang/test/CodeGenObjC/arc.ll
+++ b/clang/test/CodeGenObjC/arc.ll
@@ -1,4 +1,4 @@
-; RUN: %clang_cc1 -Os -emit-llvm -fobjc-arc -o - %s | FileCheck %s
+; RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Os -emit-llvm -fobjc-arc -o - 
%s | FileCheck %s
 
 target triple = "x86_64-apple-darwin10"
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 61a06c0 - BPF: add a test for selectiondag alias analysis w.r.t. lifetime

2020-12-02 Thread Yonghong Song via llvm-branch-commits

Author: Yonghong Song
Date: 2020-12-02T22:27:17-08:00
New Revision: 61a06c071dd16a9725d3b7bfac806520dc1b95aa

URL: 
https://github.com/llvm/llvm-project/commit/61a06c071dd16a9725d3b7bfac806520dc1b95aa
DIFF: 
https://github.com/llvm/llvm-project/commit/61a06c071dd16a9725d3b7bfac806520dc1b95aa.diff

LOG: BPF: add a test for selectiondag alias analysis w.r.t. lifetime

This adds a test for the bug
  https://bugs.llvm.org/show_bug.cgi?id=47591

Previously, selection dag has a bug which may incorrectly
assume no alias when crossing a lifetime boundary and this
may generate incorrect code as demonstrated in the above bug.

It looks the bug is fixed by https://reviews.llvm.org/D91833.
Basically, when comparing two potential memory access dag nodes,
  a store and a lifetime.start,
with the same frame index.
Previously, it may be decided no alias. With the above fix,
these two will be considered aliasing which will prevent
incorrect code scheduling.

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

Added: 
llvm/test/CodeGen/BPF/selectiondag-bug.ll

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/BPF/selectiondag-bug.ll 
b/llvm/test/CodeGen/BPF/selectiondag-bug.ll
new file mode 100644
index ..786f1ed4acd1
--- /dev/null
+++ b/llvm/test/CodeGen/BPF/selectiondag-bug.ll
@@ -0,0 +1,82 @@
+; RUN: llc -march=bpf < %s | FileCheck %s
+;
+; The IR is generated from a bpftrace script 
(https://github.com/iovisor/bpftrace/issues/1305)
+; and then slightly adapted for easy unit testing.
+; The llvm bugzilla link: https://bugs.llvm.org/show_bug.cgi?id=47591
+
+%printf_t = type { i64, i64 }
+
+define i64 @"kprobe:blk_update_request"(i8* %0) local_unnamed_addr section 
"s_kprobe:blk_update_request_1" {
+entry:
+  %"struct kernfs_node.parent" = alloca i64, align 8
+  %printf_args = alloca %printf_t, align 8
+  %"struct cgroup.kn" = alloca i64, align 8
+  %"struct cgroup_subsys_state.cgroup" = alloca i64, align 8
+  %"struct blkcg_gq.blkcg" = alloca i64, align 8
+  %"struct bio.bi_blkg" = alloca i64, align 8
+  %"struct request.bio" = alloca i64, align 8
+  %1 = getelementptr i8, i8* %0, i64 112
+  %2 = bitcast i8* %1 to i64*
+  %arg0 = load volatile i64, i64* %2, align 8
+  %3 = add i64 %arg0, 56
+  %4 = bitcast i64* %"struct request.bio" to i8*
+  call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %4)
+  %probe_read = call i64 inttoptr (i64 4 to i64 (i64*, i32, i64)*)(i64* 
nonnull %"struct request.bio", i32 8, i64 %3)
+  %5 = load i64, i64* %"struct request.bio", align 8
+  call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %4)
+  %6 = add i64 %5, 72
+  %7 = bitcast i64* %"struct bio.bi_blkg" to i8*
+  call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %7)
+  %probe_read1 = call i64 inttoptr (i64 5 to i64 (i64*, i32, i64)*)(i64* 
nonnull %"struct bio.bi_blkg", i32 8, i64 %6)
+  %8 = load i64, i64* %"struct bio.bi_blkg", align 8
+  call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %7)
+  %9 = add i64 %8, 40
+  %10 = bitcast i64* %"struct blkcg_gq.blkcg" to i8*
+  call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %10)
+  %probe_read2 = call i64 inttoptr (i64 6 to i64 (i64*, i32, i64)*)(i64* 
nonnull %"struct blkcg_gq.blkcg", i32 8, i64 %9)
+  %11 = load i64, i64* %"struct blkcg_gq.blkcg", align 8
+  call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %10)
+  %12 = bitcast i64* %"struct cgroup_subsys_state.cgroup" to i8*
+  call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %12)
+  %probe_read3 = call i64 inttoptr (i64 7 to i64 (i64*, i32, i64)*)(i64* 
nonnull %"struct cgroup_subsys_state.cgroup", i32 8, i64 %11)
+  %13 = load i64, i64* %"struct cgroup_subsys_state.cgroup", align 8
+  call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %12)
+  %14 = add i64 %13, 288
+  %15 = bitcast i64* %"struct cgroup.kn" to i8*
+  call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %15)
+  %probe_read4 = call i64 inttoptr (i64 8 to i64 (i64*, i32, i64)*)(i64* 
nonnull %"struct cgroup.kn", i32 8, i64 %14)
+  %16 = load i64, i64* %"struct cgroup.kn", align 8
+  call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %15)
+  %17 = bitcast %printf_t* %printf_args to i8*
+  call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %17)
+  %18 = add i64 %16, 8
+  %19 = bitcast i64* %"struct kernfs_node.parent" to i8*
+  %20 = getelementptr inbounds %printf_t, %printf_t* %printf_args, i64 0, i32 0
+  store i64 0, i64* %20, align 8
+  call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %19)
+
+; CHECK:call 8
+; CHECK-NOT:r{{[0-9]+}} = 0
+; CHECK:[[REG3:r[0-9]+]] = *(u64 *)(r10 - 24)
+; CHECK:[[REG1:r[0-9]+]] = 0
+; CHECK:*(u64 *)(r10 - 24) = [[REG1]]
+
+  %probe_read5 = call i64 inttoptr (i64 9 to i64 (i64*, i32, i64)*)(i64* 
nonnull %"struct kernfs_node.parent", i32 8, i64 %18)
+  %21 = load i64, i64* %"struct kernfs_node.parent", align 8
+  call void 

[llvm-branch-commits] [llvm] 1d6ebdf - Switch from llvm::is_trivially_copyable to std::is_trivially_copyable

2020-12-02 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-02T22:02:48-08:00
New Revision: 1d6ebdfb66b9d63d34f34ec6ac7ec57eff7cd24b

URL: 
https://github.com/llvm/llvm-project/commit/1d6ebdfb66b9d63d34f34ec6ac7ec57eff7cd24b
DIFF: 
https://github.com/llvm/llvm-project/commit/1d6ebdfb66b9d63d34f34ec6ac7ec57eff7cd24b.diff

LOG: Switch from llvm::is_trivially_copyable to std::is_trivially_copyable

GCC<5 did not support std::is_trivially_copyable. Now LLVM builds require 5.1
we can migrate to std::is_trivially_copyable.

The Optional.h change made MSVC choke
(https://buildkite.com/llvm-project/premerge-checks/builds/18587#cd1bb616-ffdc-4581-9795-b42c284196de)
so I leave it out for now.

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

Added: 


Modified: 
llvm/docs/ProgrammersManual.rst
llvm/include/llvm/ADT/DenseMap.h
llvm/include/llvm/ADT/STLExtras.h
llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
llvm/tools/llvm-diff/DifferenceEngine.cpp
llvm/unittests/ADT/ArrayRefTest.cpp
llvm/unittests/ADT/ImmutableListTest.cpp
llvm/unittests/ADT/OptionalTest.cpp
llvm/unittests/ADT/PointerIntPairTest.cpp
llvm/unittests/ADT/StringRefTest.cpp
llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
llvm/unittests/Bitstream/BitstreamReaderTest.cpp
llvm/unittests/CodeGen/MachineInstrTest.cpp
llvm/unittests/CodeGen/TypeTraitsTest.cpp
llvm/unittests/IR/CFGBuilder.cpp
llvm/unittests/Support/ScaledNumberTest.cpp

Removed: 




diff  --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index d9925d69d9f6..e303a7a18eba 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -1530,7 +1530,7 @@ SmallVector has grown a few other minor advantages over 
std::vector, causing
 #. std::vector is exception-safe, and some implementations have pessimizations
that copy elements when SmallVector would move them.
 
-#. SmallVector understands ``llvm::is_trivially_copyable`` and uses 
realloc aggressively.
+#. SmallVector understands ``std::is_trivially_copyable`` and uses 
realloc aggressively.
 
 #. Many LLVM APIs take a SmallVectorImpl as an out parameter (see the note
below).

diff  --git a/llvm/include/llvm/ADT/DenseMap.h 
b/llvm/include/llvm/ADT/DenseMap.h
index 42e4fc84175c..7f7a4593ae36 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -426,8 +426,8 @@ class DenseMapBase : public DebugEpochBase {
 setNumEntries(other.getNumEntries());
 setNumTombstones(other.getNumTombstones());
 
-if (is_trivially_copyable::value &&
-is_trivially_copyable::value)
+if (std::is_trivially_copyable::value &&
+std::is_trivially_copyable::value)
   memcpy(reinterpret_cast(getBuckets()), other.getBuckets(),
  getNumBuckets() * sizeof(BucketT));
 else

diff  --git a/llvm/include/llvm/ADT/STLExtras.h 
b/llvm/include/llvm/ADT/STLExtras.h
index 5a5d47b783c2..1d6faf6509f9 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1428,7 +1428,7 @@ template 
 // is trivially copyable.
 using sort_trivially_copyable = conjunction<
 std::is_pointer,
-is_trivially_copyable::value_type>>;
+std::is_trivially_copyable::value_type>>;
 } // namespace detail
 
 // Provide wrappers to std::sort which shuffle the elements before sorting

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h 
b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
index e6ade770457c..9f34d026b1ba 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -171,15 +171,10 @@ struct GloballyHashedType {
 return Hashes;
   }
 };
-#if defined(_MSC_VER)
-// is_trivially_copyable is not available in older versions of libc++, but it 
is
-// available in all supported versions of MSVC, so at least this gives us some
-// coverage.
 static_assert(std::is_trivially_copyable::value,
   "GloballyHashedType must be trivially copyable so that we can "
   "reinterpret_cast arrays of hash data to arrays of "
   "GloballyHashedType");
-#endif
 } // namespace codeview
 
 template <> struct DenseMapInfo {

diff  --git a/llvm/tools/llvm-
diff /DifferenceEngine.cpp b/llvm/tools/llvm-
diff /DifferenceEngine.cpp
index 2cf1afbc6af5..64c0dc61e806 100644
--- a/llvm/tools/llvm-
diff /DifferenceEngine.cpp
+++ b/llvm/tools/llvm-
diff /DifferenceEngine.cpp
@@ -67,7 +67,7 @@ class PriorityQueue {
 unsigned NewSize = Storage.size() - 1;
 if (NewSize) {
   // Move the slot at the end to the beginning.
-  if (is_trivially_copyable::value)
+  if (std::is_trivially_copyable::value)
 Storage[0] = Storage[NewSize];
   else
 std::swap(Storage[0], Storage[NewSize]);

diff  --git a/llvm/unittests/ADT/ArrayRefTest.cpp 
b/llvm/unittests/ADT/ArrayRefTest.cpp
index 

[llvm-branch-commits] [llvm] bd726d2 - [dfsan] Rename ShadowTy/ZeroShadow with prefix Primitive

2020-12-02 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2020-12-03T05:31:01Z
New Revision: bd726d2796b1a5d2c936b5708bfb49a4b7fb89de

URL: 
https://github.com/llvm/llvm-project/commit/bd726d2796b1a5d2c936b5708bfb49a4b7fb89de
DIFF: 
https://github.com/llvm/llvm-project/commit/bd726d2796b1a5d2c936b5708bfb49a4b7fb89de.diff

LOG: [dfsan] Rename ShadowTy/ZeroShadow with prefix Primitive

This is a child diff of D92261.

After supporting field/index-level shadow, the existing shadow with type
i16 works for only primitive types.

Reviewed-by: morehouse

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

Added: 


Modified: 
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 46f4becb511f..9dad9817acea 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -354,10 +354,13 @@ class DataFlowSanitizer {
   Module *Mod;
   LLVMContext *Ctx;
   Type *Int8Ptr;
-  IntegerType *ShadowTy;
-  PointerType *ShadowPtrTy;
+  /// The shadow type for all primitive types. Until we support field/index
+  /// level shadow values, aggregate and vector types also use this shadow
+  /// type.
+  IntegerType *PrimitiveShadowTy;
+  PointerType *PrimitiveShadowPtrTy;
   IntegerType *IntptrTy;
-  ConstantInt *ZeroShadow;
+  ConstantInt *ZeroPrimitiveShadow;
   ConstantInt *ShadowPtrMask;
   ConstantInt *ShadowPtrMul;
   Constant *ArgTLS;
@@ -504,12 +507,12 @@ DataFlowSanitizer::DataFlowSanitizer(
 
 FunctionType *DataFlowSanitizer::getArgsFunctionType(FunctionType *T) {
   SmallVector ArgTypes(T->param_begin(), T->param_end());
-  ArgTypes.append(T->getNumParams(), ShadowTy);
+  ArgTypes.append(T->getNumParams(), PrimitiveShadowTy);
   if (T->isVarArg())
-ArgTypes.push_back(ShadowPtrTy);
+ArgTypes.push_back(PrimitiveShadowPtrTy);
   Type *RetType = T->getReturnType();
   if (!RetType->isVoidTy())
-RetType = StructType::get(RetType, ShadowTy);
+RetType = StructType::get(RetType, PrimitiveShadowTy);
   return FunctionType::get(RetType, ArgTypes, T->isVarArg());
 }
 
@@ -518,10 +521,10 @@ FunctionType 
*DataFlowSanitizer::getTrampolineFunctionType(FunctionType *T) {
   SmallVector ArgTypes;
   ArgTypes.push_back(T->getPointerTo());
   ArgTypes.append(T->param_begin(), T->param_end());
-  ArgTypes.append(T->getNumParams(), ShadowTy);
+  ArgTypes.append(T->getNumParams(), PrimitiveShadowTy);
   Type *RetType = T->getReturnType();
   if (!RetType->isVoidTy())
-ArgTypes.push_back(ShadowPtrTy);
+ArgTypes.push_back(PrimitiveShadowPtrTy);
   return FunctionType::get(T->getReturnType(), ArgTypes, false);
 }
 
@@ -547,12 +550,12 @@ TransformedFunction 
DataFlowSanitizer::getCustomFunctionType(FunctionType *T) {
 }
   }
   for (unsigned i = 0, e = T->getNumParams(); i != e; ++i)
-ArgTypes.push_back(ShadowTy);
+ArgTypes.push_back(PrimitiveShadowTy);
   if (T->isVarArg())
-ArgTypes.push_back(ShadowPtrTy);
+ArgTypes.push_back(PrimitiveShadowPtrTy);
   Type *RetType = T->getReturnType();
   if (!RetType->isVoidTy())
-ArgTypes.push_back(ShadowPtrTy);
+ArgTypes.push_back(PrimitiveShadowPtrTy);
   return TransformedFunction(
   T, FunctionType::get(T->getReturnType(), ArgTypes, T->isVarArg()),
   ArgumentIndexMapping);
@@ -570,10 +573,10 @@ bool DataFlowSanitizer::init(Module ) {
   Mod = 
   Ctx = ();
   Int8Ptr = Type::getInt8PtrTy(*Ctx);
-  ShadowTy = IntegerType::get(*Ctx, ShadowWidthBits);
-  ShadowPtrTy = PointerType::getUnqual(ShadowTy);
+  PrimitiveShadowTy = IntegerType::get(*Ctx, ShadowWidthBits);
+  PrimitiveShadowPtrTy = PointerType::getUnqual(PrimitiveShadowTy);
   IntptrTy = DL.getIntPtrType(*Ctx);
-  ZeroShadow = ConstantInt::getSigned(ShadowTy, 0);
+  ZeroPrimitiveShadow = ConstantInt::getSigned(PrimitiveShadowTy, 0);
   ShadowPtrMul = ConstantInt::getSigned(IntptrTy, ShadowWidthBytes);
   if (IsX86_64)
 ShadowPtrMask = ConstantInt::getSigned(IntptrTy, ~0x7000LL);
@@ -585,28 +588,30 @@ bool DataFlowSanitizer::init(Module ) {
   else
 report_fatal_error("unsupported triple");
 
-  Type *DFSanUnionArgs[2] = { ShadowTy, ShadowTy };
+  Type *DFSanUnionArgs[2] = {PrimitiveShadowTy, PrimitiveShadowTy};
   DFSanUnionFnTy =
-  FunctionType::get(ShadowTy, DFSanUnionArgs, /*isVarArg=*/ false);
-  Type *DFSanUnionLoadArgs[2] = { ShadowPtrTy, IntptrTy };
-  DFSanUnionLoadFnTy =
-  FunctionType::get(ShadowTy, DFSanUnionLoadArgs, /*isVarArg=*/ false);
+  FunctionType::get(PrimitiveShadowTy, DFSanUnionArgs, /*isVarArg=*/false);
+  Type *DFSanUnionLoadArgs[2] = {PrimitiveShadowPtrTy, IntptrTy};
+  DFSanUnionLoadFnTy = FunctionType::get(PrimitiveShadowTy, DFSanUnionLoadArgs,
+ /*isVarArg=*/false);
   DFSanUnimplementedFnTy = 

[llvm-branch-commits] [llvm] 1ccd361 - [RISCV] Add additional half precision fnmadd/fnmsub tests with an fneg on the second operand instead of the first.

2020-12-02 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-02T21:13:42-08:00
New Revision: 1ccd36161d54c098ecb8a6b35695844a16943043

URL: 
https://github.com/llvm/llvm-project/commit/1ccd36161d54c098ecb8a6b35695844a16943043
DIFF: 
https://github.com/llvm/llvm-project/commit/1ccd36161d54c098ecb8a6b35695844a16943043.diff

LOG: [RISCV] Add additional half precision fnmadd/fnmsub tests with an fneg on 
the second operand instead of the first.

This matches the float/double tests added in 
defe11866a326491ee9767f84bb3f70cfc4f4bcb

Added: 


Modified: 
llvm/test/CodeGen/RISCV/half-arith.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/half-arith.ll 
b/llvm/test/CodeGen/RISCV/half-arith.ll
index cc94f3e23cc7..ad4978e117cf 100644
--- a/llvm/test/CodeGen/RISCV/half-arith.ll
+++ b/llvm/test/CodeGen/RISCV/half-arith.ll
@@ -302,6 +302,30 @@ define half @fnmadd_s(half %a, half %b, half %c) nounwind {
   ret half %1
 }
 
+define half @fnmadd_s_2(half %a, half %b, half %c) nounwind {
+; RV32IZFH-LABEL: fnmadd_s_2:
+; RV32IZFH:   # %bb.0:
+; RV32IZFH-NEXT:fmv.h.x ft0, zero
+; RV32IZFH-NEXT:fadd.h ft1, fa1, ft0
+; RV32IZFH-NEXT:fadd.h ft0, fa2, ft0
+; RV32IZFH-NEXT:fnmadd.h fa0, ft1, fa0, ft0
+; RV32IZFH-NEXT:ret
+;
+; RV64IZFH-LABEL: fnmadd_s_2:
+; RV64IZFH:   # %bb.0:
+; RV64IZFH-NEXT:fmv.h.x ft0, zero
+; RV64IZFH-NEXT:fadd.h ft1, fa1, ft0
+; RV64IZFH-NEXT:fadd.h ft0, fa2, ft0
+; RV64IZFH-NEXT:fnmadd.h fa0, ft1, fa0, ft0
+; RV64IZFH-NEXT:ret
+  %b_ = fadd half 0.0, %b
+  %c_ = fadd half 0.0, %c
+  %negb = fsub half -0.0, %b_
+  %negc = fsub half -0.0, %c_
+  %1 = call half @llvm.fma.f16(half %a, half %negb, half %negc)
+  ret half %1
+}
+
 define half @fnmsub_s(half %a, half %b, half %c) nounwind {
 ; RV32IZFH-LABEL: fnmsub_s:
 ; RV32IZFH:   # %bb.0:
@@ -322,6 +346,26 @@ define half @fnmsub_s(half %a, half %b, half %c) nounwind {
   ret half %1
 }
 
+define half @fnmsub_s_2(half %a, half %b, half %c) nounwind {
+; RV32IZFH-LABEL: fnmsub_s_2:
+; RV32IZFH:   # %bb.0:
+; RV32IZFH-NEXT:fmv.h.x ft0, zero
+; RV32IZFH-NEXT:fadd.h ft0, fa1, ft0
+; RV32IZFH-NEXT:fnmsub.h fa0, ft0, fa0, fa2
+; RV32IZFH-NEXT:ret
+;
+; RV64IZFH-LABEL: fnmsub_s_2:
+; RV64IZFH:   # %bb.0:
+; RV64IZFH-NEXT:fmv.h.x ft0, zero
+; RV64IZFH-NEXT:fadd.h ft0, fa1, ft0
+; RV64IZFH-NEXT:fnmsub.h fa0, ft0, fa0, fa2
+; RV64IZFH-NEXT:ret
+  %b_ = fadd half 0.0, %b
+  %negb = fsub half -0.0, %b_
+  %1 = call half @llvm.fma.f16(half %a, half %negb, half %c)
+  ret half %1
+}
+
 define half @fmadd_s_contract(half %a, half %b, half %c) nounwind {
 ; RV32IZFH-LABEL: fmadd_s_contract:
 ; RV32IZFH:   # %bb.0:



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 9bf0fea - [PowerPC] Add the hw sqrt test for vector type v4f32/v2f64

2020-12-02 Thread QingShan Zhang via llvm-branch-commits

Author: QingShan Zhang
Date: 2020-12-03T03:19:18Z
New Revision: 9bf0fea3729e3ad63da24f94ce22c6b4628bec15

URL: 
https://github.com/llvm/llvm-project/commit/9bf0fea3729e3ad63da24f94ce22c6b4628bec15
DIFF: 
https://github.com/llvm/llvm-project/commit/9bf0fea3729e3ad63da24f94ce22c6b4628bec15.diff

LOG: [PowerPC] Add the hw sqrt test for vector type v4f32/v2f64

PowerPC ISA support the input test for vector type v4f32 and v2f64.
Replace the software compare with hw test will improve the perf.

Reviewed By: ChenZheng

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrVSX.td
llvm/test/CodeGen/PowerPC/recipest.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index f9f84aa668bc..101ef686c180 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -12760,9 +12760,10 @@ static int getEstimateRefinementSteps(EVT VT, const 
PPCSubtarget ) {
 
 SDValue PPCTargetLowering::getSqrtInputTest(SDValue Op, SelectionDAG ,
 const DenormalMode ) const {
-  // TODO - add support for v2f64/v4f32
+  // We only have VSX Vector Test for software Square Root.
   EVT VT = Op.getValueType();
-  if (VT != MVT::f64)
+  if (VT != MVT::f64 &&
+  ((VT != MVT::v2f64 && VT != MVT::v4f32) || !Subtarget.hasVSX()))
 return SDValue();
 
   SDLoc DL(Op);
@@ -12788,9 +12789,10 @@ SDValue PPCTargetLowering::getSqrtInputTest(SDValue 
Op, SelectionDAG ,
 SDValue
 PPCTargetLowering::getSqrtResultForDenormInput(SDValue Op,
SelectionDAG ) const {
-  // TODO - add support for v2f64/v4f32
+  // We only have VSX Vector Square Root.
   EVT VT = Op.getValueType();
-  if (VT != MVT::f64)
+  if (VT != MVT::f64 &&
+  ((VT != MVT::v2f64 && VT != MVT::v4f32) || !Subtarget.hasVSX()))
 return TargetLowering::getSqrtResultForDenormInput(Op, DAG);
 
   return DAG.getNode(PPCISD::FSQRT, SDLoc(Op), VT, Op);

diff  --git a/llvm/lib/Target/PowerPC/PPCInstrVSX.td 
b/llvm/lib/Target/PowerPC/PPCInstrVSX.td
index e778ca4be6b5..35a0abcfd632 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -640,10 +640,12 @@ let hasSideEffects = 0 in {
 
   def XVTSQRTDP : XX2Form_1<60, 234,
   (outs crrc:$crD), (ins vsrc:$XB),
-  "xvtsqrtdp $crD, $XB", IIC_FPCompare, []>;
+  "xvtsqrtdp $crD, $XB", IIC_FPCompare,
+  [(set i32:$crD, (PPCftsqrt v2f64:$XB))]>;
   def XVTSQRTSP : XX2Form_1<60, 170,
   (outs crrc:$crD), (ins vsrc:$XB),
-  "xvtsqrtsp $crD, $XB", IIC_FPCompare, []>;
+  "xvtsqrtsp $crD, $XB", IIC_FPCompare,
+  [(set i32:$crD, (PPCftsqrt v4f32:$XB))]>;
   }
 
   def XVDIVDP : XX3Form<60, 120,
@@ -2464,6 +2466,8 @@ def : Pat<(PPCfnmsub v4f32:$A, v4f32:$B, (fneg v4f32:$C)),
   (XVNMADDASP $C, $A, $B)>;
 
 def : Pat<(PPCfsqrt f64:$frA), (XSSQRTDP $frA)>;
+def : Pat<(PPCfsqrt v2f64:$frA), (XVSQRTDP $frA)>;
+def : Pat<(PPCfsqrt v4f32:$frA), (XVSQRTSP $frA)>;
 
 def : Pat<(v2f64 (bitconvert v4f32:$A)),
   (COPY_TO_REGCLASS $A, VSRC)>;

diff  --git a/llvm/test/CodeGen/PowerPC/recipest.ll 
b/llvm/test/CodeGen/PowerPC/recipest.ll
index 3d9f2efc32e0..46da4cc6c471 100644
--- a/llvm/test/CodeGen/PowerPC/recipest.ll
+++ b/llvm/test/CodeGen/PowerPC/recipest.ll
@@ -953,24 +953,30 @@ define <4 x float> @hoo3_fmf(<4 x float> %a) #1 {
 ;
 ; CHECK-P8-LABEL: hoo3_fmf:
 ; CHECK-P8:   # %bb.0:
+; CHECK-P8-NEXT:xvtsqrtsp 0, 34
+; CHECK-P8-NEXT:bc 12, 2, .LBB24_2
+; CHECK-P8-NEXT:  # %bb.1:
 ; CHECK-P8-NEXT:xvrsqrtesp 0, 34
 ; CHECK-P8-NEXT:addis 3, 2, .LCPI24_0@toc@ha
 ; CHECK-P8-NEXT:addis 4, 2, .LCPI24_1@toc@ha
 ; CHECK-P8-NEXT:addi 3, 3, .LCPI24_0@toc@l
-; CHECK-P8-NEXT:lvx 3, 0, 3
-; CHECK-P8-NEXT:addi 3, 4, .LCPI24_1@toc@l
-; CHECK-P8-NEXT:lvx 4, 0, 3
 ; CHECK-P8-NEXT:xvmulsp 1, 34, 0
-; CHECK-P8-NEXT:xvmaddasp 35, 1, 0
-; CHECK-P8-NEXT:xvmulsp 0, 1, 36
-; CHECK-P8-NEXT:xxlxor 1, 1, 1
-; CHECK-P8-NEXT:xvcmpeqsp 2, 34, 1
-; CHECK-P8-NEXT:xvmulsp 0, 0, 35
-; CHECK-P8-NEXT:xxsel 34, 0, 1, 2
+; CHECK-P8-NEXT:lvx 2, 0, 3
+; CHECK-P8-NEXT:addi 3, 4, .LCPI24_1@toc@l
+; CHECK-P8-NEXT:lvx 3, 0, 3
+; CHECK-P8-NEXT:xvmaddasp 34, 1, 0
+; CHECK-P8-NEXT:xvmulsp 0, 1, 35
+; CHECK-P8-NEXT:xvmulsp 34, 0, 34
+; CHECK-P8-NEXT:blr
+; CHECK-P8-NEXT:  .LBB24_2:
+; CHECK-P8-NEXT:xvsqrtsp 34, 34
 ; CHECK-P8-NEXT:blr
 ;
 ; CHECK-P9-LABEL: hoo3_fmf:
 ; CHECK-P9:   # %bb.0:
+; CHECK-P9-NEXT:xvtsqrtsp 0, 34
+; CHECK-P9-NEXT:bc 12, 2, 

[llvm-branch-commits] [llvm] 7a4af2a - [SelectionDAG] Use is_contained (NFC)

2020-12-02 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-02T19:09:45-08:00
New Revision: 7a4af2a8e701838598cad254123b8a7855ee44c4

URL: 
https://github.com/llvm/llvm-project/commit/7a4af2a8e701838598cad254123b8a7855ee44c4
DIFF: 
https://github.com/llvm/llvm-project/commit/7a4af2a8e701838598cad254123b8a7855ee44c4.diff

LOG: [SelectionDAG] Use is_contained (NFC)

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 20e4ac590136..b0c8d4660f61 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -9317,7 +9317,7 @@ bool SDNode::areOnlyUsersOf(ArrayRef 
Nodes, const SDNode *N) {
 
 /// isOperand - Return true if this node is an operand of N.
 bool SDValue::isOperandOf(const SDNode *N) const {
-  return any_of(N->op_values(), [this](SDValue Op) { return *this == Op; });
+  return is_contained(N->op_values(), *this);
 }
 
 bool SDNode::isOperandOf(const SDNode *N) const {



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 222da77 - [NFC] [Clang] Move ppc64le f128 vaargs OpenMP test

2020-12-02 Thread Qiu Chaofan via llvm-branch-commits

Author: Qiu Chaofan
Date: 2020-12-03T10:50:42+08:00
New Revision: 222da77a82d17cbc6b989779e2ba2bb4904bb672

URL: 
https://github.com/llvm/llvm-project/commit/222da77a82d17cbc6b989779e2ba2bb4904bb672
DIFF: 
https://github.com/llvm/llvm-project/commit/222da77a82d17cbc6b989779e2ba2bb4904bb672.diff

LOG: [NFC] [Clang] Move ppc64le f128 vaargs OpenMP test

This case for long-double semantics mismatch on OpenMP references
%clang, which should be located in Driver directory.

Added: 
clang/test/Driver/ppc-openmp-f128.c

Modified: 
clang/test/CodeGen/ppc64le-varargs-f128.c

Removed: 




diff  --git a/clang/test/CodeGen/ppc64le-varargs-f128.c 
b/clang/test/CodeGen/ppc64le-varargs-f128.c
index 5e9930ec716f..0b085859c5ac 100644
--- a/clang/test/CodeGen/ppc64le-varargs-f128.c
+++ b/clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -5,46 +5,11 @@
 // RUN:   -target-cpu pwr9 -target-feature +float128 \
 // RUN:   -o - %s | FileCheck %s -check-prefix=IBM
 
-// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
-// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \
-// RUN:   -Xopenmp-target=ppc64le -mcpu=pwr9 -Xopenmp-target=ppc64le \
-// RUN:   -mfloat128 -fopenmp=libomp -o - %s | FileCheck %s -check-prefix=OMP
-
 #include 
 
 void foo_ld(long double);
 void foo_fq(__float128);
 
-// Verify cases when OpenMP target's and host's long-double semantics 
diff er.
-
-// OMP-LABEL: define internal void @.omp_outlined.
-// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8**
-// OMP: %[[V2:[0-9a-zA-Z_.]+]] = bitcast i8* %[[CUR]] to ppc_fp128*
-// OMP: %[[V3:[0-9a-zA-Z_.]+]] = load ppc_fp128, ppc_fp128* %[[V2]], align 8
-// OMP: call void @foo_ld(ppc_fp128 %[[V3]])
-
-// OMP-LABEL: define dso_local void @omp
-// OMP: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
-// OMP: call void @llvm.va_start(i8* %[[AP1]])
-// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]], align 8
-// OMP: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
-// OMP: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
-// OMP: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
-// OMP: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
-// OMP: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
-// OMP: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
-// OMP: call void @foo_ld(fp128 %[[V4]])
-void omp(int n, ...) {
-  va_list ap;
-  va_start(ap, n);
-  foo_ld(va_arg(ap, long double));
-  #pragma omp target parallel
-  for (int i = 1; i < n; ++i) {
-foo_ld(va_arg(ap, long double));
-  }
-  va_end(ap);
-}
-
 // IEEE-LABEL: define void @f128
 // IEEE: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
 // IEEE: call void @llvm.va_start(i8* %[[AP1]])

diff  --git a/clang/test/Driver/ppc-openmp-f128.c 
b/clang/test/Driver/ppc-openmp-f128.c
new file mode 100644
index ..bff6fe35e526
--- /dev/null
+++ b/clang/test/Driver/ppc-openmp-f128.c
@@ -0,0 +1,39 @@
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
+// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \
+// RUN:   -Xopenmp-target=ppc64le -mcpu=pwr9 -Xopenmp-target=ppc64le \
+// RUN:   -mfloat128 -fopenmp=libomp -o - %s | FileCheck %s -check-prefix=OMP
+
+#include 
+
+void foo_ld(long double);
+void foo_fq(__float128);
+
+// Verify cases when OpenMP target's and host's long-double semantics 
diff er.
+
+// OMP-LABEL: define internal void @.omp_outlined.
+// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8**
+// OMP: %[[V2:[0-9a-zA-Z_.]+]] = bitcast i8* %[[CUR]] to ppc_fp128*
+// OMP: %[[V3:[0-9a-zA-Z_.]+]] = load ppc_fp128, ppc_fp128* %[[V2]], align 8
+// OMP: call void @foo_ld(ppc_fp128 %[[V3]])
+
+// OMP-LABEL: define dso_local void @omp
+// OMP: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
+// OMP: call void @llvm.va_start(i8* %[[AP1]])
+// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]], align 8
+// OMP: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
+// OMP: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
+// OMP: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
+// OMP: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
+// OMP: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
+// OMP: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
+// OMP: call void @foo_ld(fp128 %[[V4]])
+void omp(int n, ...) {
+  va_list ap;
+  va_start(ap, n);
+  foo_ld(va_arg(ap, long double));
+  #pragma omp target parallel
+  for (int i = 1; i < n; ++i) {
+foo_ld(va_arg(ap, long double));
+  }
+  va_end(ap);
+}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 8b40324 - [RISCV] Initialize MergeBaseOffsetOptPass so it will work with print-before/after-all.

2020-12-02 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-02T18:04:22-08:00
New Revision: 8b403243a845dd0af2799caa830cea4a2c75f5fb

URL: 
https://github.com/llvm/llvm-project/commit/8b403243a845dd0af2799caa830cea4a2c75f5fb
DIFF: 
https://github.com/llvm/llvm-project/commit/8b403243a845dd0af2799caa830cea4a2c75f5fb.diff

LOG: [RISCV] Initialize MergeBaseOffsetOptPass so it will work with 
print-before/after-all.

If its not in the PassRegistry it's not recognized as
a pass when we print before/after. Happened to notice while
I was working on a new pass.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp 
b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
index 4dca1a88843e..5bd49bd7a7ff 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -37,6 +37,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void 
LLVMInitializeRISCVTarget() {
   RegisterTargetMachine Y(getTheRISCV64Target());
   auto PR = PassRegistry::getPassRegistry();
   initializeGlobalISel(*PR);
+  initializeRISCVMergeBaseOffsetOptPass(*PR);
   initializeRISCVExpandPseudoPass(*PR);
 }
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] c4fb772 - PR48339: Improve diagnostics for invalid dependent unqualified function calls.

2020-12-02 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-02T17:54:55-08:00
New Revision: c4fb7720ceb30f25c38d994fb375e4d1978de144

URL: 
https://github.com/llvm/llvm-project/commit/c4fb7720ceb30f25c38d994fb375e4d1978de144
DIFF: 
https://github.com/llvm/llvm-project/commit/c4fb7720ceb30f25c38d994fb375e4d1978de144.diff

LOG: PR48339: Improve diagnostics for invalid dependent unqualified function 
calls.

Fix bogus diagnostics that would get confused and think a "no viable
fuctions" case was an "undeclared identifiers" case, resulting in an
incorrect diagnostic preceding the correct one. Use overload resolution
to determine which function we should select when we can find call
candidates from a dependent base class. Make the diagnostics for a call
that could call a function from a dependent base class more specific,
and use a different diagnostic message for the case where the call
target is instead declared later in the same class. Plus some minor
diagnostic wording improvements.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/drs/dr2xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
clang/test/SemaTemplate/cxx1z-using-declaration.cpp
clang/test/SemaTemplate/dependent-names.cpp
clang/test/SemaTemplate/dependent-typos-recovery.cpp
clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
clang/test/SemaTemplate/recovery-crash.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3067c077ddb2..44195cc9db45 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5204,11 +5204,17 @@ def ext_undeclared_unqual_id_with_dependent_base : 
ExtWarn<
   "use of undeclared identifier %0; "
   "unqualified lookup into dependent bases of class template %1 is a Microsoft 
extension">,
   InGroup;
-def ext_found_via_dependent_bases_lookup : ExtWarn<"use of identifier %0 "
+def err_found_in_dependent_base : Error<
+  "explicit qualification required to use member %0 from dependent base 
class">;
+def ext_found_in_dependent_base : ExtWarn<"use of member %0 "
   "found via unqualified lookup into dependent bases of class templates is a "
   "Microsoft extension">, InGroup;
-def note_dependent_var_use : Note<"must qualify identifier to find this "
-"declaration in dependent base class">;
+def err_found_later_in_class : Error<"member %0 used before its declaration">;
+def ext_found_later_in_class : ExtWarn<
+  "use of member %0 before its declaration is a Microsoft extension">,
+  InGroup;
+def note_dependent_member_use : Note<
+  "must qualify identifier to find this declaration in dependent base class">;
 def err_not_found_by_two_phase_lookup : Error<"call to function %0 that is 
neither "
 "visible in the template definition nor found by argument-dependent 
lookup">;
 def note_not_found_by_two_phase_lookup : Note<"%0 should be declared prior to 
the "

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 775dd1793dea..8b4a18ab11d6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3676,6 +3676,9 @@ class Sema final {
ArrayRef Args,
OverloadCandidateSet ,
bool PartialOverloading = false);
+  void AddOverloadedCallCandidates(
+  LookupResult , TemplateArgumentListInfo *ExplicitTemplateArgs,
+  ArrayRef Args, OverloadCandidateSet );
 
   // An enum used to represent the 
diff erent possible results of building a
   // range-based for loop.
@@ -4958,6 +4961,8 @@ class Sema final {
   DeclarationNameInfo ,
   const TemplateArgumentListInfo *);
 
+  bool DiagnoseDependentMemberLookup(LookupResult );
+
   bool
   DiagnoseEmptyLookup(Scope *S, CXXScopeSpec , LookupResult ,
   CorrectionCandidateCallback ,

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7da854f4fb9e..6da530c245fe 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -255,7 +255,7 @@ static ParsedType recoverFromTypeInKnownDependentBase(Sema 
,
   // We found some types in dependent base classes.  Recover as if the user
   // wrote 'typename MyClass::II' instead of 'II'.  We'll fully resolve the
   // lookup during template instantiation.
-  S.Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << 
+  S.Diag(NameLoc, diag::ext_found_in_dependent_base) << 
 
   ASTContext  = S.Context;
   auto *NNS = NestedNameSpecifier::Create(Context, nullptr, false,

diff  --git a/clang/lib/Sema/SemaExpr.cpp 

[llvm-branch-commits] [llvm] 4cc56d2 - [MemorySSA] Remove unused declaration findDominatingDef (NFC)

2020-12-02 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-02T17:40:20-08:00
New Revision: 4cc56d2b1975cb30c6ba5ea4e948905e11c8625e

URL: 
https://github.com/llvm/llvm-project/commit/4cc56d2b1975cb30c6ba5ea4e948905e11c8625e
DIFF: 
https://github.com/llvm/llvm-project/commit/4cc56d2b1975cb30c6ba5ea4e948905e11c8625e.diff

LOG: [MemorySSA] Remove unused declaration findDominatingDef (NFC)

The function definition was removed on Feb 22, 2017 in commit
17e8d0eae24ffa41cf7641d984c05e00d59b93a4.  The declaration has
remained since.

Added: 


Modified: 
llvm/include/llvm/Analysis/MemorySSA.h

Removed: 




diff  --git a/llvm/include/llvm/Analysis/MemorySSA.h 
b/llvm/include/llvm/Analysis/MemorySSA.h
index e73af5f89ed6..a1511aa3ad34 100644
--- a/llvm/include/llvm/Analysis/MemorySSA.h
+++ b/llvm/include/llvm/Analysis/MemorySSA.h
@@ -857,7 +857,6 @@ class MemorySSA {
   template 
   MemoryUseOrDef *createNewAccess(Instruction *, AliasAnalysisType *,
   const MemoryUseOrDef *Template = nullptr);
-  MemoryAccess *findDominatingDef(BasicBlock *, enum InsertionPlace);
   void placePHINodes(const SmallPtrSetImpl &);
   MemoryAccess *renameBlock(BasicBlock *, MemoryAccess *, bool);
   void renameSuccessorPhis(BasicBlock *, MemoryAccess *, bool);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] b346322 - Revert "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"

2020-12-02 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T17:36:20-08:00
New Revision: b34632201987eed369bb7ef4646f341b901c95b8

URL: 
https://github.com/llvm/llvm-project/commit/b34632201987eed369bb7ef4646f341b901c95b8
DIFF: 
https://github.com/llvm/llvm-project/commit/b34632201987eed369bb7ef4646f341b901c95b8.diff

LOG: Revert "Frontend: Sink named pipe logic from CompilerInstance down to 
FileManager"

This reverts commit 3b18a594c7717a328c33b9c1eba675e9f4bd367c, since
apparently this doesn't work everywhere. E.g.,
clang-x86_64-debian-fast/3889
(http://lab.llvm.org:8011/#/builders/109/builds/3889) gives me:
```
+ : 'RUN: at line 8'
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -x c /dev/fd/0 -E
+ cat /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Misc/dev-fd-fs.c
fatal error: file '/dev/fd/0' modified since it was first processed
1 error generated.
```

Added: 


Modified: 
clang/lib/Basic/FileManager.cpp
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index f3afe6dd5f48..c0d3685001ee 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -489,7 +489,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool 
isVolatile,
   uint64_t FileSize = Entry->getSize();
   // If there's a high enough chance that the file have changed since we
   // got its size, force a stat before opening it.
-  if (isVolatile || Entry->isNamedPipe())
+  if (isVolatile)
 FileSize = -1;
 
   StringRef Filename = Entry->getName();

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index e3018b218b76..5c82878d8e21 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -858,8 +858,30 @@ bool CompilerInstance::InitializeSourceManager(const 
FrontendInputFile ,
 }
 FileEntryRef File = *FileOrErr;
 
-SourceMgr.setMainFileID(
-SourceMgr.createFileID(File, SourceLocation(), Kind));
+// The natural SourceManager infrastructure can't currently handle named
+// pipes, but we would at least like to accept them for the main
+// file. Detect them here, read them with the volatile flag so FileMgr will
+// pick up the correct size, and simply override their contents as we do 
for
+// STDIN.
+if (File.getFileEntry().isNamedPipe()) {
+  auto MB =
+  FileMgr.getBufferForFile((), /*isVolatile=*/true);
+  if (MB) {
+// Create a new virtual file that will have the correct size.
+const FileEntry *FE =
+FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
+SourceMgr.overrideFileContents(FE, std::move(*MB));
+SourceMgr.setMainFileID(
+SourceMgr.createFileID(FE, SourceLocation(), Kind));
+  } else {
+Diags.Report(diag::err_cannot_open_file) << InputFile
+ << MB.getError().message();
+return false;
+  }
+} else {
+  SourceMgr.setMainFileID(
+  SourceMgr.createFileID(File, SourceLocation(), Kind));
+}
   } else {
 llvm::ErrorOr> SBOrErr =
 llvm::MemoryBuffer::getSTDIN();



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 715ba18 - [llvm-link] use file magic when deciding if input should be loaded as archive

2020-12-02 Thread Sergey Dmitriev via llvm-branch-commits

Author: Sergey Dmitriev
Date: 2020-12-02T17:21:34-08:00
New Revision: 715ba18d3e11bc3636a9d0f701d8e5a2fdf66852

URL: 
https://github.com/llvm/llvm-project/commit/715ba18d3e11bc3636a9d0f701d8e5a2fdf66852
DIFF: 
https://github.com/llvm/llvm-project/commit/715ba18d3e11bc3636a9d0f701d8e5a2fdf66852.diff

LOG: [llvm-link] use file magic when deciding if input should be loaded as 
archive

llvm-link should not rely on the '.a' file extension when deciding if input file
should be loaded as archive. Archives may have other extensions (f.e. .lib) or 
no
extensions at all. This patch changes llvm-link to use llvm::file_magic to check
if input file is an archive.

Reviewed By: RaviNarayanaswamy

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

Added: 


Modified: 
llvm/test/tools/llvm-link/archive-bad.ll
llvm/test/tools/llvm-link/archive.ll
llvm/tools/llvm-link/CMakeLists.txt
llvm/tools/llvm-link/llvm-link.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-link/archive-bad.ll 
b/llvm/test/tools/llvm-link/archive-bad.ll
index 80ce6fc1fe0d..7a4bddb43c0a 100644
--- a/llvm/test/tools/llvm-link/archive-bad.ll
+++ b/llvm/test/tools/llvm-link/archive-bad.ll
@@ -1,7 +1,7 @@
-# RUN: cp %S/Inputs/f.ll %t.fg.a
+# RUN: echo -e '!\nwith invalid contents' > %t.fg.a
 # RUN: not llvm-link %S/Inputs/h.ll %t.fg.a -o %t.linked.bc 2>&1 | FileCheck %s
 
 # RUN: rm -f %t.fg.a
 # RUN: rm -f %t.linked.bc
 
-# CHECK: file too small to be an archive
+# CHECK: truncated or malformed archive

diff  --git a/llvm/test/tools/llvm-link/archive.ll 
b/llvm/test/tools/llvm-link/archive.ll
index 10ab83a3d5be..b027db0753d9 100644
--- a/llvm/test/tools/llvm-link/archive.ll
+++ b/llvm/test/tools/llvm-link/archive.ll
@@ -1,8 +1,8 @@
 # RUN: llvm-as %S/Inputs/f.ll -o %t.f.bc
 # RUN: llvm-as %S/Inputs/g.ll -o %t.g.bc
 # RUN: llvm-ar cr %t.fg.a %t.f.bc %t.g.bc
-# RUN: llvm-ar cr %t.empty.a
-# RUN: llvm-link %S/Inputs/h.ll %t.fg.a %t.empty.a -o %t.linked.bc
+# RUN: llvm-ar cr %t.empty.lib
+# RUN: llvm-link %S/Inputs/h.ll %t.fg.a %t.empty.lib -o %t.linked.bc
 
 # RUN: llvm-nm %t.linked.bc | FileCheck %s
 

diff  --git a/llvm/tools/llvm-link/CMakeLists.txt 
b/llvm/tools/llvm-link/CMakeLists.txt
index 051489f94bc9..c0f286e8fd10 100644
--- a/llvm/tools/llvm-link/CMakeLists.txt
+++ b/llvm/tools/llvm-link/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  BinaryFormat
   BitReader
   BitWriter
   Core

diff  --git a/llvm/tools/llvm-link/llvm-link.cpp 
b/llvm/tools/llvm-link/llvm-link.cpp
index 7141bd1ca7a1..0f851a3e7c38 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -11,8 +11,8 @@
 //
 
//===--===//
 
-#include "llvm/Object/Archive.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/AutoUpgrade.h"
@@ -24,6 +24,7 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
+#include "llvm/Object/Archive.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -115,17 +116,18 @@ static ExitOnError ExitOnErr;
 // link path for the specified file to try to find it...
 //
 static std::unique_ptr loadFile(const char *argv0,
-const std::string ,
+std::unique_ptr Buffer,
 LLVMContext ,
 bool MaterializeMetadata = true) {
   SMDiagnostic Err;
   if (Verbose)
-errs() << "Loading '" << FN << "'\n";
+errs() << "Loading '" << Buffer->getBufferIdentifier() << "'\n";
   std::unique_ptr Result;
   if (DisableLazyLoad)
-Result = parseIRFile(FN, Err, Context);
+Result = parseIR(*Buffer, Err, Context);
   else
-Result = getLazyIRFileModule(FN, Err, Context, !MaterializeMetadata);
+Result =
+getLazyIRModule(std::move(Buffer), Err, Context, !MaterializeMetadata);
 
   if (!Result) {
 Err.print(argv0, errs());
@@ -141,19 +143,17 @@ static std::unique_ptr loadFile(const char *argv0,
 }
 
 static std::unique_ptr loadArFile(const char *Argv0,
-  const std::string ,
+  std::unique_ptr Buffer,
   LLVMContext , Linker ,
   unsigned OrigFlags,
   unsigned ApplicableFlags) {
   std::unique_ptr Result(new Module("ArchiveModule", Context));
+  StringRef ArchiveName = Buffer->getBufferIdentifier();
   if (Verbose)
 errs() << "Reading library archive file '" << ArchiveName
<< "' to memory\n";
-  ErrorOr> Buf =
-

[llvm-branch-commits] [clang] 432d051 - [RISCV] Handle zfh in the arch string.

2020-12-02 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2020-12-03T09:16:44+08:00
New Revision: 432d05174ed00a217c0ad37e2e823154624c1311

URL: 
https://github.com/llvm/llvm-project/commit/432d05174ed00a217c0ad37e2e823154624c1311
DIFF: 
https://github.com/llvm/llvm-project/commit/432d05174ed00a217c0ad37e2e823154624c1311.diff

LOG: [RISCV] Handle zfh in the arch string.

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-arch.c
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 37e688d14b4a..2b076c9c16f2 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -135,6 +135,9 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
,
 
   if (HasB)
 Builder.defineMacro("__riscv_bitmanip");
+
+  if (HasZfh)
+Builder.defineMacro("__riscv_zfh");
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -150,6 +153,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
   .Case("d", HasD)
   .Case("c", HasC)
   .Case("experimental-b", HasB)
+  .Case("experimental-zfh", HasZfh)
   .Default(false);
 }
 
@@ -169,6 +173,8 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector ,
   HasC = true;
 else if (Feature == "+experimental-b")
   HasB = true;
+else if (Feature == "+experimental-zfh")
+  HasZfh = true;
   }
 
   return true;

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index a4e6777a11e2..20a7b1c73175 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -31,11 +31,12 @@ class RISCVTargetInfo : public TargetInfo {
   bool HasD;
   bool HasC;
   bool HasB;
+  bool HasZfh;
 
 public:
   RISCVTargetInfo(const llvm::Triple , const TargetOptions &)
-  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false), HasB(false) {
+  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false), HasD(false),
+HasC(false), HasB(false), HasZfh(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = ::APFloat::IEEEquad();

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 7ca05a1f3a39..aa1a5d8c803f 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -64,6 +64,8 @@ isExperimentalExtension(StringRef Ext) {
 return RISCVExtensionVersion{"0", "92"};
   if (Ext == "v")
 return RISCVExtensionVersion{"0", "9"};
+  if (Ext == "zfh")
+return RISCVExtensionVersion{"0", "1"};
   return None;
 }
 

diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 8b630b1846c9..533f1cff42af 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -383,3 +383,12 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZFH-NOFLAG %s
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: error: invalid arch name 'rv32izfh'
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh0p1 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZFH %s
+// RV32-EXPERIMENTAL-ZFH: "-target-feature" "+experimental-zfh"

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index d8c18f76e53b..c0ffd83bc7e2 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -78,3 +78,9 @@
 // CHECK-DOUBLE: __riscv_float_abi_double 1
 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
+
+// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions -march=rv32izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions -march=rv64izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// CHECK-ZFH-EXT: __riscv_zfh 1



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 3b18a59 - Frontend: Sink named pipe logic from CompilerInstance down to FileManager

2020-12-02 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T17:14:27-08:00
New Revision: 3b18a594c7717a328c33b9c1eba675e9f4bd367c

URL: 
https://github.com/llvm/llvm-project/commit/3b18a594c7717a328c33b9c1eba675e9f4bd367c
DIFF: 
https://github.com/llvm/llvm-project/commit/3b18a594c7717a328c33b9c1eba675e9f4bd367c.diff

LOG: Frontend: Sink named pipe logic from CompilerInstance down to FileManager

Remove compilicated logic from CompilerInstance::InitializeSourceManager
to deal with named pipes, updating FileManager::getBufferForFile to
handle it in a more straightforward way. The existing test at
clang/test/Misc/dev-fd-fs.c covers the new behaviour (just like it did
the old behaviour).

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

Added: 


Modified: 
clang/lib/Basic/FileManager.cpp
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index c0d3685001ee..f3afe6dd5f48 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -489,7 +489,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool 
isVolatile,
   uint64_t FileSize = Entry->getSize();
   // If there's a high enough chance that the file have changed since we
   // got its size, force a stat before opening it.
-  if (isVolatile)
+  if (isVolatile || Entry->isNamedPipe())
 FileSize = -1;
 
   StringRef Filename = Entry->getName();

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 5c82878d8e21..e3018b218b76 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -858,30 +858,8 @@ bool CompilerInstance::InitializeSourceManager(const 
FrontendInputFile ,
 }
 FileEntryRef File = *FileOrErr;
 
-// The natural SourceManager infrastructure can't currently handle named
-// pipes, but we would at least like to accept them for the main
-// file. Detect them here, read them with the volatile flag so FileMgr will
-// pick up the correct size, and simply override their contents as we do 
for
-// STDIN.
-if (File.getFileEntry().isNamedPipe()) {
-  auto MB =
-  FileMgr.getBufferForFile((), /*isVolatile=*/true);
-  if (MB) {
-// Create a new virtual file that will have the correct size.
-const FileEntry *FE =
-FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
-SourceMgr.overrideFileContents(FE, std::move(*MB));
-SourceMgr.setMainFileID(
-SourceMgr.createFileID(FE, SourceLocation(), Kind));
-  } else {
-Diags.Report(diag::err_cannot_open_file) << InputFile
- << MB.getError().message();
-return false;
-  }
-} else {
-  SourceMgr.setMainFileID(
-  SourceMgr.createFileID(File, SourceLocation(), Kind));
-}
+SourceMgr.setMainFileID(
+SourceMgr.createFileID(File, SourceLocation(), Kind));
   } else {
 llvm::ErrorOr> SBOrErr =
 llvm::MemoryBuffer::getSTDIN();



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] dd2054d - [lldb] Treat remote macOS debugging like any other remote darwin platform

2020-12-02 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-02T17:03:22-08:00
New Revision: dd2054d38a848a75fe84fb68d9c3a97e5ade6753

URL: 
https://github.com/llvm/llvm-project/commit/dd2054d38a848a75fe84fb68d9c3a97e5ade6753
DIFF: 
https://github.com/llvm/llvm-project/commit/dd2054d38a848a75fe84fb68d9c3a97e5ade6753.diff

LOG: [lldb] Treat remote macOS debugging like any other remote darwin platform

Extract remote debugging logic from PlatformMacOSX and move it into
PlatformRemoteMacOSX so it can benefit from all the logic necessary for
remote debugging.

Until now, remote macOS debugging was treated almost identical to local
macOS debugging. By moving in into its own class, we can have it inherit
from PlatformRemoteDarwinDevice and all the functionality it provides,
such as looking at the correct DeviceSupport directory.

rdar://68167374

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

Added: 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
lldb/test/API/commands/platform/sdk/Makefile
lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
lldb/test/API/commands/platform/sdk/main.c

Modified: 
lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
lldb/unittests/Process/ProcessEventDataTest.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt 
b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
index 8b5be337f45b..bd9343773b3c 100644
--- a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -10,11 +10,12 @@ list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
   PlatformDarwin.cpp
   PlatformDarwinKernel.cpp
   PlatformMacOSX.cpp
-  PlatformRemoteiOS.cpp
+  PlatformRemoteAppleBridge.cpp
   PlatformRemoteAppleTV.cpp
   PlatformRemoteAppleWatch.cpp
   PlatformRemoteDarwinDevice.cpp
-  PlatformRemoteAppleBridge.cpp
+  PlatformRemoteMacOSX.cpp
+  PlatformRemoteiOS.cpp
   )
 
 list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index a139d4a2c454..24df03e18dda 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "PlatformMacOSX.h"
+#include "PlatformRemoteMacOSX.h"
 #include "PlatformRemoteiOS.h"
 #if defined(__APPLE__)
 #include "PlatformAppleSimulator.h"
@@ -44,6 +45,7 @@ static uint32_t g_initialize_count = 0;
 void PlatformMacOSX::Initialize() {
   PlatformDarwin::Initialize();
   PlatformRemoteiOS::Initialize();
+  PlatformRemoteMacOSX::Initialize();
 #if defined(__APPLE__)
   PlatformAppleSimulator::Initialize();
   PlatformDarwinKernel::Initialize();
@@ -54,12 +56,12 @@ void PlatformMacOSX::Initialize() {
 
   if (g_initialize_count++ == 0) {
 #if defined(__APPLE__)
-PlatformSP default_platform_sp(new PlatformMacOSX(true));
+PlatformSP default_platform_sp(new PlatformMacOSX());
 default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
 Platform::SetHostPlatform(default_platform_sp);
 #endif
-PluginManager::RegisterPlugin(PlatformMacOSX::GetPluginNameStatic(false),
-  PlatformMacOSX::GetDescriptionStatic(false),
+PluginManager::RegisterPlugin(PlatformMacOSX::GetPluginNameStatic(),
+  PlatformMacOSX::GetDescriptionStatic(),
   PlatformMacOSX::CreateInstance);
   }
 }
@@ -78,98 +80,28 @@ void PlatformMacOSX::Terminate() {
   PlatformDarwinKernel::Terminate();
   PlatformAppleSimulator::Terminate();
 #endif
+  PlatformRemoteMacOSX::Initialize();
   PlatformRemoteiOS::Terminate();
   PlatformDarwin::Terminate();
 }
 
-PlatformSP PlatformMacOSX::CreateInstance(bool force, const ArchSpec *arch) {
-  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
-  if (log) {
-const char *arch_name;
-if (arch && arch->GetArchitectureName())
-  arch_name = arch->GetArchitectureName();
-else
-  arch_name = "";
-
-const char *triple_cstr =
-arch ? arch->GetTriple().getTriple().c_str() : "";
-
-LLDB_LOGF(log, "PlatformMacOSX::%s(force=%s, arch={%s,%s})", __FUNCTION__,
-  force ? "true" : "false", arch_name, triple_cstr);
-  }
-
-  // The only time we create an instance is when we are creating a remote
-  // macosx platform
-  const bool is_host = false;
-
-  bool create = force;
-  if (!create && arch && arch->IsValid()) {
-const llvm::Triple  = arch->GetTriple();
-switch (triple.getVendor()) {
-case llvm::Triple::Apple:
-  create = true;
-  break;

[llvm-branch-commits] [llvm] 9c955b7 - Revert "[llvm-link] use file magic when deciding if input should be loaded as archive"

2020-12-02 Thread Sergey Dmitriev via llvm-branch-commits

Author: Sergey Dmitriev
Date: 2020-12-02T16:53:57-08:00
New Revision: 9c955b79fb2b86c5acdd0665e5ea2866cbc309c2

URL: 
https://github.com/llvm/llvm-project/commit/9c955b79fb2b86c5acdd0665e5ea2866cbc309c2
DIFF: 
https://github.com/llvm/llvm-project/commit/9c955b79fb2b86c5acdd0665e5ea2866cbc309c2.diff

LOG: Revert "[llvm-link] use file magic when deciding if input should be loaded 
as archive"

This reverts commit 55f8c2fdfbc5eda1be946e97ecffa2dea44a883e.

Added: 


Modified: 
llvm/test/tools/llvm-link/archive-bad.ll
llvm/test/tools/llvm-link/archive.ll
llvm/tools/llvm-link/llvm-link.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-link/archive-bad.ll 
b/llvm/test/tools/llvm-link/archive-bad.ll
index 7a4bddb43c0a..80ce6fc1fe0d 100644
--- a/llvm/test/tools/llvm-link/archive-bad.ll
+++ b/llvm/test/tools/llvm-link/archive-bad.ll
@@ -1,7 +1,7 @@
-# RUN: echo -e '!\nwith invalid contents' > %t.fg.a
+# RUN: cp %S/Inputs/f.ll %t.fg.a
 # RUN: not llvm-link %S/Inputs/h.ll %t.fg.a -o %t.linked.bc 2>&1 | FileCheck %s
 
 # RUN: rm -f %t.fg.a
 # RUN: rm -f %t.linked.bc
 
-# CHECK: truncated or malformed archive
+# CHECK: file too small to be an archive

diff  --git a/llvm/test/tools/llvm-link/archive.ll 
b/llvm/test/tools/llvm-link/archive.ll
index b027db0753d9..10ab83a3d5be 100644
--- a/llvm/test/tools/llvm-link/archive.ll
+++ b/llvm/test/tools/llvm-link/archive.ll
@@ -1,8 +1,8 @@
 # RUN: llvm-as %S/Inputs/f.ll -o %t.f.bc
 # RUN: llvm-as %S/Inputs/g.ll -o %t.g.bc
 # RUN: llvm-ar cr %t.fg.a %t.f.bc %t.g.bc
-# RUN: llvm-ar cr %t.empty.lib
-# RUN: llvm-link %S/Inputs/h.ll %t.fg.a %t.empty.lib -o %t.linked.bc
+# RUN: llvm-ar cr %t.empty.a
+# RUN: llvm-link %S/Inputs/h.ll %t.fg.a %t.empty.a -o %t.linked.bc
 
 # RUN: llvm-nm %t.linked.bc | FileCheck %s
 

diff  --git a/llvm/tools/llvm-link/llvm-link.cpp 
b/llvm/tools/llvm-link/llvm-link.cpp
index 0f851a3e7c38..7141bd1ca7a1 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -11,8 +11,8 @@
 //
 
//===--===//
 
+#include "llvm/Object/Archive.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/BinaryFormat/Magic.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/AutoUpgrade.h"
@@ -24,7 +24,6 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
-#include "llvm/Object/Archive.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -116,18 +115,17 @@ static ExitOnError ExitOnErr;
 // link path for the specified file to try to find it...
 //
 static std::unique_ptr loadFile(const char *argv0,
-std::unique_ptr Buffer,
+const std::string ,
 LLVMContext ,
 bool MaterializeMetadata = true) {
   SMDiagnostic Err;
   if (Verbose)
-errs() << "Loading '" << Buffer->getBufferIdentifier() << "'\n";
+errs() << "Loading '" << FN << "'\n";
   std::unique_ptr Result;
   if (DisableLazyLoad)
-Result = parseIR(*Buffer, Err, Context);
+Result = parseIRFile(FN, Err, Context);
   else
-Result =
-getLazyIRModule(std::move(Buffer), Err, Context, !MaterializeMetadata);
+Result = getLazyIRFileModule(FN, Err, Context, !MaterializeMetadata);
 
   if (!Result) {
 Err.print(argv0, errs());
@@ -143,17 +141,19 @@ static std::unique_ptr loadFile(const char *argv0,
 }
 
 static std::unique_ptr loadArFile(const char *Argv0,
-  std::unique_ptr Buffer,
+  const std::string ,
   LLVMContext , Linker ,
   unsigned OrigFlags,
   unsigned ApplicableFlags) {
   std::unique_ptr Result(new Module("ArchiveModule", Context));
-  StringRef ArchiveName = Buffer->getBufferIdentifier();
   if (Verbose)
 errs() << "Reading library archive file '" << ArchiveName
<< "' to memory\n";
+  ErrorOr> Buf =
+MemoryBuffer::getFile(ArchiveName, -1, false);
+  ExitOnErr(errorCodeToError(Buf.getError()));
   Error Err = Error::success();
-  object::Archive Archive(*Buffer, Err);
+  object::Archive Archive(Buf.get()->getMemBufferRef(), Err);
   ExitOnErr(std::move(Err));
   for (const object::Archive::Child  : Archive.children(Err)) {
 Expected Ename = C.getName();
@@ -287,9 +287,7 @@ static bool importFunctions(const char *argv0, Module 
) {
 
   auto ModuleLoader = [](const char *argv0,
 const std::string ) {
-std::unique_ptr Buffer =
-ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(Identifier)));
-  

[llvm-branch-commits] [llvm] 80b0f74 - Small improvements to Intrinsic::getName

2020-12-02 Thread Xun Li via llvm-branch-commits

Author: Xun Li
Date: 2020-12-02T16:49:12-08:00
New Revision: 80b0f74c8c539b2385f897467aa99b2b6b298c04

URL: 
https://github.com/llvm/llvm-project/commit/80b0f74c8c539b2385f897467aa99b2b6b298c04
DIFF: 
https://github.com/llvm/llvm-project/commit/80b0f74c8c539b2385f897467aa99b2b6b298c04.diff

LOG: Small improvements to Intrinsic::getName

While I was adding a new intrinsic instruction (not overloaded), I accidentally 
used CreateUnaryIntrinsic to create the intrinsics, which turns out to be 
passing the type list to getName, and ended up naming the intrinsics function 
with type suffix, which leads to wierd bugs latter on. It took me a long time 
to debug.
It seems a good idea to add an assertion in getName so that it fails if types 
are passed but it's not a overloaded function.
Also, the overloade version of getName is less efficient because it creates an 
std::string. We should avoid calling it if we know that there are no types 
provided.

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

Added: 


Modified: 
llvm/lib/IR/Function.cpp

Removed: 




diff  --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index a2857707..37fa3d272781 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -781,6 +781,8 @@ StringRef Intrinsic::getName(ID id) {
 
 std::string Intrinsic::getName(ID id, ArrayRef Tys) {
   assert(id < num_intrinsics && "Invalid intrinsic ID!");
+  assert((Tys.empty() || Intrinsic::isOverloaded(id)) &&
+ "This version of getName is for overloaded intrinsics only");
   std::string Result(IntrinsicNameTable[id]);
   for (Type *Ty : Tys) {
 Result += "." + getMangledTypeStr(Ty);
@@ -1243,7 +1245,7 @@ Function *Intrinsic::getDeclaration(Module *M, ID id, 
ArrayRef Tys) {
   // There can never be multiple globals with the same name of 
diff erent types,
   // because intrinsics must be a specific type.
   return cast(
-  M->getOrInsertFunction(getName(id, Tys),
+  M->getOrInsertFunction(Tys.empty() ? getName(id) : getName(id, Tys),
  getType(M->getContext(), id, Tys))
   .getCallee());
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 55f8c2f - [llvm-link] use file magic when deciding if input should be loaded as archive

2020-12-02 Thread Sergey Dmitriev via llvm-branch-commits

Author: Sergey Dmitriev
Date: 2020-12-02T16:29:41-08:00
New Revision: 55f8c2fdfbc5eda1be946e97ecffa2dea44a883e

URL: 
https://github.com/llvm/llvm-project/commit/55f8c2fdfbc5eda1be946e97ecffa2dea44a883e
DIFF: 
https://github.com/llvm/llvm-project/commit/55f8c2fdfbc5eda1be946e97ecffa2dea44a883e.diff

LOG: [llvm-link] use file magic when deciding if input should be loaded as 
archive

llvm-link should not rely on the '.a' file extension when deciding if input file
should be loaded as archive. Archives may have other extensions (f.e. .lib) or 
no
extensions at all. This patch changes llvm-link to use llvm::file_magic to check
if input file is an archive.

Reviewed By: RaviNarayanaswamy

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

Added: 


Modified: 
llvm/test/tools/llvm-link/archive-bad.ll
llvm/test/tools/llvm-link/archive.ll
llvm/tools/llvm-link/llvm-link.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-link/archive-bad.ll 
b/llvm/test/tools/llvm-link/archive-bad.ll
index 80ce6fc1fe0d..7a4bddb43c0a 100644
--- a/llvm/test/tools/llvm-link/archive-bad.ll
+++ b/llvm/test/tools/llvm-link/archive-bad.ll
@@ -1,7 +1,7 @@
-# RUN: cp %S/Inputs/f.ll %t.fg.a
+# RUN: echo -e '!\nwith invalid contents' > %t.fg.a
 # RUN: not llvm-link %S/Inputs/h.ll %t.fg.a -o %t.linked.bc 2>&1 | FileCheck %s
 
 # RUN: rm -f %t.fg.a
 # RUN: rm -f %t.linked.bc
 
-# CHECK: file too small to be an archive
+# CHECK: truncated or malformed archive

diff  --git a/llvm/test/tools/llvm-link/archive.ll 
b/llvm/test/tools/llvm-link/archive.ll
index 10ab83a3d5be..b027db0753d9 100644
--- a/llvm/test/tools/llvm-link/archive.ll
+++ b/llvm/test/tools/llvm-link/archive.ll
@@ -1,8 +1,8 @@
 # RUN: llvm-as %S/Inputs/f.ll -o %t.f.bc
 # RUN: llvm-as %S/Inputs/g.ll -o %t.g.bc
 # RUN: llvm-ar cr %t.fg.a %t.f.bc %t.g.bc
-# RUN: llvm-ar cr %t.empty.a
-# RUN: llvm-link %S/Inputs/h.ll %t.fg.a %t.empty.a -o %t.linked.bc
+# RUN: llvm-ar cr %t.empty.lib
+# RUN: llvm-link %S/Inputs/h.ll %t.fg.a %t.empty.lib -o %t.linked.bc
 
 # RUN: llvm-nm %t.linked.bc | FileCheck %s
 

diff  --git a/llvm/tools/llvm-link/llvm-link.cpp 
b/llvm/tools/llvm-link/llvm-link.cpp
index 7141bd1ca7a1..0f851a3e7c38 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -11,8 +11,8 @@
 //
 
//===--===//
 
-#include "llvm/Object/Archive.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/AutoUpgrade.h"
@@ -24,6 +24,7 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
+#include "llvm/Object/Archive.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -115,17 +116,18 @@ static ExitOnError ExitOnErr;
 // link path for the specified file to try to find it...
 //
 static std::unique_ptr loadFile(const char *argv0,
-const std::string ,
+std::unique_ptr Buffer,
 LLVMContext ,
 bool MaterializeMetadata = true) {
   SMDiagnostic Err;
   if (Verbose)
-errs() << "Loading '" << FN << "'\n";
+errs() << "Loading '" << Buffer->getBufferIdentifier() << "'\n";
   std::unique_ptr Result;
   if (DisableLazyLoad)
-Result = parseIRFile(FN, Err, Context);
+Result = parseIR(*Buffer, Err, Context);
   else
-Result = getLazyIRFileModule(FN, Err, Context, !MaterializeMetadata);
+Result =
+getLazyIRModule(std::move(Buffer), Err, Context, !MaterializeMetadata);
 
   if (!Result) {
 Err.print(argv0, errs());
@@ -141,19 +143,17 @@ static std::unique_ptr loadFile(const char *argv0,
 }
 
 static std::unique_ptr loadArFile(const char *Argv0,
-  const std::string ,
+  std::unique_ptr Buffer,
   LLVMContext , Linker ,
   unsigned OrigFlags,
   unsigned ApplicableFlags) {
   std::unique_ptr Result(new Module("ArchiveModule", Context));
+  StringRef ArchiveName = Buffer->getBufferIdentifier();
   if (Verbose)
 errs() << "Reading library archive file '" << ArchiveName
<< "' to memory\n";
-  ErrorOr> Buf =
-MemoryBuffer::getFile(ArchiveName, -1, false);
-  ExitOnErr(errorCodeToError(Buf.getError()));
   Error Err = Error::success();
-  object::Archive Archive(Buf.get()->getMemBufferRef(), Err);
+  object::Archive Archive(*Buffer, Err);
   ExitOnErr(std::move(Err));
   for (const object::Archive::Child  : Archive.children(Err)) {
 Expected Ename = C.getName();
@@ 

[llvm-branch-commits] [clang] dcc4f7f - ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T16:28:33-08:00
New Revision: dcc4f7f3c4b4442710ae73d6f73cded665426678

URL: 
https://github.com/llvm/llvm-project/commit/dcc4f7f3c4b4442710ae73d6f73cded665426678
DIFF: 
https://github.com/llvm/llvm-project/commit/dcc4f7f3c4b4442710ae73d6f73cded665426678.diff

LOG: ARCMigrate: Stop abusing PreprocessorOptions for passing back file 
remappings, NFC

As part of reducing use of PreprocessorOptions::RemappedFileBuffers,
stop abusing it to pass information around remapped files in
`ARCMigrate`.  This simplifies an eventual follow-up to switch to using
an `InMemoryFileSystem` for this.

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

Added: 


Modified: 
clang/include/clang/ARCMigrate/FileRemapper.h
clang/lib/ARCMigrate/ARCMT.cpp
clang/lib/ARCMigrate/FileRemapper.cpp
clang/tools/arcmt-test/arcmt-test.cpp

Removed: 




diff  --git a/clang/include/clang/ARCMigrate/FileRemapper.h 
b/clang/include/clang/ARCMigrate/FileRemapper.h
index 76b65b2f6884..4da68a678be2 100644
--- a/clang/include/clang/ARCMigrate/FileRemapper.h
+++ b/clang/include/clang/ARCMigrate/FileRemapper.h
@@ -12,11 +12,13 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 
 namespace llvm {
   class MemoryBuffer;
+  class MemoryBufferRef;
 }
 
 namespace clang {
@@ -55,6 +57,12 @@ class FileRemapper {
 
   void applyMappings(PreprocessorOptions ) const;
 
+  /// Iterate through all the mappings.
+  void forEachMapping(
+  llvm::function_ref CaptureFile,
+  llvm::function_ref
+  CaptureBuffer) const;
+
   void clear(StringRef outputDir = StringRef());
 
 private:

diff  --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index e18def8a0b19..36fbe90e1e3a 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -416,9 +416,11 @@ bool 
arcmt::getFileRemappings(std::vector > &
   if (err)
 return true;
 
-  PreprocessorOptions PPOpts;
-  remapper.applyMappings(PPOpts);
-  remap = PPOpts.RemappedFiles;
+  remapper.forEachMapping(
+  [&](StringRef From, StringRef To) {
+remap.push_back(std::make_pair(From.str(), To.str()));
+  },
+  [](StringRef, const llvm::MemoryBufferRef &) {});
 
   return false;
 }

diff  --git a/clang/lib/ARCMigrate/FileRemapper.cpp 
b/clang/lib/ARCMigrate/FileRemapper.cpp
index 0222583c015b..f536af1795ed 100644
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -190,6 +190,21 @@ bool FileRemapper::overwriteOriginal(DiagnosticsEngine 
,
   return false;
 }
 
+void FileRemapper::forEachMapping(
+llvm::function_ref CaptureFile,
+llvm::function_ref
+CaptureBuffer) const {
+  for (auto  : FromToMappings) {
+if (const FileEntry *FE = Mapping.second.dyn_cast()) {
+  CaptureFile(Mapping.first->getName(), FE->getName());
+  continue;
+}
+CaptureBuffer(
+Mapping.first->getName(),
+Mapping.second.get()->getMemBufferRef());
+  }
+}
+
 void FileRemapper::applyMappings(PreprocessorOptions ) const {
   for (MappingsTy::const_iterator
  I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {

diff  --git a/clang/tools/arcmt-test/arcmt-test.cpp 
b/clang/tools/arcmt-test/arcmt-test.cpp
index c4ba12d4f7cf..940e622b8a68 100644
--- a/clang/tools/arcmt-test/arcmt-test.cpp
+++ b/clang/tools/arcmt-test/arcmt-test.cpp
@@ -139,11 +139,10 @@ static bool checkForMigration(StringRef resourcesPath,
 }
 
 static void printResult(FileRemapper , raw_ostream ) {
-  PreprocessorOptions PPOpts;
-  remapper.applyMappings(PPOpts);
-  // The changed files will be in memory buffers, print them.
-  for (const auto  : PPOpts.RemappedFileBuffers)
-OS << RB.second->getBuffer();
+  remapper.forEachMapping([](StringRef, StringRef) {},
+  [&](StringRef, const llvm::MemoryBufferRef ) {
+OS << Buffer.getBuffer();
+  });
 }
 
 static bool performTransformations(StringRef resourcesPath,



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] 0a09c1c - [scudo][standalone] Add missing va_end() in ScopedString::append

2020-12-02 Thread Kostya Kortchinsky via llvm-branch-commits

Author: Kostya Kortchinsky
Date: 2020-12-02T16:10:50-08:00
New Revision: 0a09c1cc9dcbec8126344123e9481bed6524e5ec

URL: 
https://github.com/llvm/llvm-project/commit/0a09c1cc9dcbec8126344123e9481bed6524e5ec
DIFF: 
https://github.com/llvm/llvm-project/commit/0a09c1cc9dcbec8126344123e9481bed6524e5ec.diff

LOG:  [scudo][standalone] Add missing va_end() in ScopedString::append

In ScopedString::append va_list ArgsCopy is created but never cleanuped
which can lead to undefined behaviour, like stack corruption.

Reviewed By: cryptoad

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/string_utils.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/string_utils.cpp 
b/compiler-rt/lib/scudo/standalone/string_utils.cpp
index 7578123da361..f304491019b2 100644
--- a/compiler-rt/lib/scudo/standalone/string_utils.cpp
+++ b/compiler-rt/lib/scudo/standalone/string_utils.cpp
@@ -222,6 +222,7 @@ void ScopedString::append(const char *Format, va_list Args) 
{
   static_cast(formatString(C, sizeof(C), Format, Args)) + 1;
   String.resize(Length + AdditionalLength);
   formatString(String.data() + Length, AdditionalLength, Format, ArgsCopy);
+  va_end(ArgsCopy);
   Length = strlen(String.data());
   CHECK_LT(Length, String.size());
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 3a781b9 - Fix assertion in tryEmitAsConstant

2020-12-02 Thread Yaxun Liu via llvm-branch-commits

Author: Yaxun (Sam) Liu
Date: 2020-12-02T19:10:01-05:00
New Revision: 3a781b912fc7b492a21fe52cc8ce6c9e5854a9ab

URL: 
https://github.com/llvm/llvm-project/commit/3a781b912fc7b492a21fe52cc8ce6c9e5854a9ab
DIFF: 
https://github.com/llvm/llvm-project/commit/3a781b912fc7b492a21fe52cc8ce6c9e5854a9ab.diff

LOG: Fix assertion in tryEmitAsConstant

due to cd95338ee3022bffd658e52cd3eb9419b4c218ca

Need to check if result is LValue before getLValueBase.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGenCUDA/lambda-reference-var.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 92d0cba7a733..11914b6cd9fb 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1529,7 +1529,7 @@ CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) {
   // global variable as compile time constant, since the host variable is not
   // accessible on device. The DRE of the captured reference variable has to be
   // loaded from captures.
-  if (CGM.getLangOpts().CUDAIsDevice &&
+  if (CGM.getLangOpts().CUDAIsDevice && result.Val.isLValue() &&
   refExpr->refersToEnclosingVariableOrCapture()) {
 auto *MD = dyn_cast_or_null(CurCodeDecl);
 if (MD && MD->getParent()->isLambda() &&

diff  --git a/clang/test/CodeGenCUDA/lambda-reference-var.cu 
b/clang/test/CodeGenCUDA/lambda-reference-var.cu
index 6d7b343b3193..44b012956507 100644
--- a/clang/test/CodeGenCUDA/lambda-reference-var.cu
+++ b/clang/test/CodeGenCUDA/lambda-reference-var.cu
@@ -27,6 +27,15 @@ __device__ void dev_capture_dev_ref_by_copy(int *out) {
   [=](){ *out = ref;}();
 }
 
+// DEV-LABEL: @_ZZ28dev_capture_dev_rval_by_copyPiENKUlvE_clEv(
+// DEV: store i32 3
+__device__ void dev_capture_dev_rval_by_copy(int *out) {
+  constexpr int a = 1;
+  constexpr int b = 2;
+  constexpr int c = a + b;
+  [=](){ *out = c;}();
+}
+
 // DEV-LABEL: @_ZZ26dev_capture_dev_ref_by_refPiENKUlvE_clEv(
 // DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* 
@global_device_var to i32*)
 // DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] dcdd231 - [lldb] Return the original path when tilde expansion fails.

2020-12-02 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-02T16:01:30-08:00
New Revision: dcdd231df6c7b6f4a635fe7941c1f87955328183

URL: 
https://github.com/llvm/llvm-project/commit/dcdd231df6c7b6f4a635fe7941c1f87955328183
DIFF: 
https://github.com/llvm/llvm-project/commit/dcdd231df6c7b6f4a635fe7941c1f87955328183.diff

LOG: [lldb] Return the original path when tilde expansion fails.

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

Added: 


Modified: 
lldb/source/Utility/TildeExpressionResolver.cpp
lldb/unittests/Utility/TildeExpressionResolverTest.cpp

Removed: 




diff  --git a/lldb/source/Utility/TildeExpressionResolver.cpp 
b/lldb/source/Utility/TildeExpressionResolver.cpp
index c8a0800cb807..75d9c47e656d 100644
--- a/lldb/source/Utility/TildeExpressionResolver.cpp
+++ b/lldb/source/Utility/TildeExpressionResolver.cpp
@@ -75,9 +75,8 @@ bool 
StandardTildeExpressionResolver::ResolvePartial(StringRef Expr,
 
 bool TildeExpressionResolver::ResolveFullPath(
 StringRef Expr, llvm::SmallVectorImpl ) {
-  Output.clear();
   if (!Expr.startswith("~")) {
-Output.append(Expr.begin(), Expr.end());
+Output.assign(Expr.begin(), Expr.end());
 return false;
   }
 
@@ -85,8 +84,10 @@ bool TildeExpressionResolver::ResolveFullPath(
   StringRef Left =
   Expr.take_until([](char c) { return path::is_separator(c); });
 
-  if (!ResolveExact(Left, Output))
+  if (!ResolveExact(Left, Output)) {
+Output.assign(Expr.begin(), Expr.end());
 return false;
+  }
 
   Output.append(Expr.begin() + Left.size(), Expr.end());
   return true;

diff  --git a/lldb/unittests/Utility/TildeExpressionResolverTest.cpp 
b/lldb/unittests/Utility/TildeExpressionResolverTest.cpp
index bc1ca7a44811..bcb7fdb8604d 100644
--- a/lldb/unittests/Utility/TildeExpressionResolverTest.cpp
+++ b/lldb/unittests/Utility/TildeExpressionResolverTest.cpp
@@ -31,6 +31,9 @@ TEST(TildeExpressionResolver, ResolveFullPath) {
   EXPECT_EQ("/lars", Result);
 
   ASSERT_FALSE(Resolver.ResolveFullPath("~Jaso", Result));
+  EXPECT_EQ("~Jaso", Result);
   ASSERT_FALSE(Resolver.ResolveFullPath("", Result));
+  EXPECT_EQ("", Result);
   ASSERT_FALSE(Resolver.ResolveFullPath("Jason", Result));
+  EXPECT_EQ("Jason", Result);
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] ea0029f - Revert "[mac/lld] Implement -why_load"

2020-12-02 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-02T18:57:46-05:00
New Revision: ea0029f55da9e34a58bcc79d0af76a940f2330a6

URL: 
https://github.com/llvm/llvm-project/commit/ea0029f55da9e34a58bcc79d0af76a940f2330a6
DIFF: 
https://github.com/llvm/llvm-project/commit/ea0029f55da9e34a58bcc79d0af76a940f2330a6.diff

LOG: Revert "[mac/lld] Implement -why_load"

This reverts commit 542d3b609dbe99a30759942271398890fc7770dc.
Seems to break check-lld. Reverting while I take a look.

Added: 


Modified: 
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Driver.h
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.cpp
lld/MachO/Options.td

Removed: 
lld/test/MachO/why-load.s



diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index bc22680db58f..82c017063d44 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -38,7 +38,6 @@ struct Configuration {
   bool staticLink = false;
   bool isPic = false;
   bool headerPadMaxInstallNames = false;
-  bool printWhyLoad = false;
   bool searchDylibsFirst = false;
   bool saveTemps = false;
   uint32_t headerPad;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 9822ecdd9f2a..426101f4f9e1 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -275,8 +275,6 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
 for (const ArchiveMember  : getArchiveMembers(*buffer)) {
   inputFiles.push_back(
   make(member.mbref, member.modTime, path));
-  printWhyLoad((forceLoadArchive ? "-force_load" : "-all_load"),
-   inputFiles.back());
 }
   }
 } else if (config->forceLoadObjC) {
@@ -293,7 +291,6 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
   if (hasObjCSection(member.mbref)) {
 inputFiles.push_back(
 make(member.mbref, member.modTime, path));
-printWhyLoad("-ObjC", inputFiles.back());
   }
 }
   }
@@ -640,7 +637,6 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
   config->headerPad = args::getHex(args, OPT_headerpad, /*Default=*/32);
   config->headerPadMaxInstallNames =
   args.hasArg(OPT_headerpad_max_install_names);
-  config->printWhyLoad = args.hasArg(OPT_why_load);
   config->outputType = getOutputType(args);
   config->runtimePaths = args::getStrings(args, OPT_rpath);
   config->allLoad = args.hasArg(OPT_all_load);

diff  --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h
index db7c54c59966..d5625fd3873e 100644
--- a/lld/MachO/Driver.h
+++ b/lld/MachO/Driver.h
@@ -19,7 +19,6 @@ namespace lld {
 namespace macho {
 
 class DylibFile;
-class InputFile;
 
 class MachOOptTable : public llvm::opt::OptTable {
 public:
@@ -46,8 +45,6 @@ llvm::Optional 
makeDylibFromTAPI(llvm::MemoryBufferRef mbref,
 
 uint32_t getModTime(llvm::StringRef path);
 
-void printWhyLoad(StringRef reason, const InputFile *);
-
 } // namespace macho
 } // namespace lld
 

diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 9c09ff682286..77f76b522d7e 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "Driver.h"
-#include "Config.h"
 #include "InputFiles.h"
 
 #include "lld/Common/Args.h"
@@ -186,10 +185,3 @@ uint32_t macho::getModTime(StringRef path) {
   warn("failed to get modification time of " + path);
   return 0;
 }
-
-void macho::printWhyLoad(StringRef reason, const InputFile *f) {
-  if (!config->printWhyLoad)
-return;
-  lld::outs() << reason << " forced load of " << toString(f)
-  << '\n';
-}

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index a24d045096c6..4fd9873bcbd3 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -621,10 +621,6 @@ void ArchiveFile::fetch(const object::Archive::Symbol 
) {
 
   auto file = make(mb, modTime, getName());
 
-  // ld64 doesn't demangle sym here even with -demangle. Match that, so
-  // intentionally no call to toMachOString() here.
-  printWhyLoad(sym.getName(), file);
-
   symbols.insert(symbols.end(), file->symbols.begin(), file->symbols.end());
   subsections.insert(subsections.end(), file->subsections.begin(),
  file->subsections.end());

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 5b38fc650e9f..399928e8d9ae 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -426,7 +426,8 @@ def commons : Separate<["-"], "commons">,
 def grp_introspect : OptionGroup<"introspect">, HelpText<"INTROSPECTING THE 
LINKER">;
 
 def why_load : Flag<["-"], "why_load">,
- HelpText<"Log why each object file is loaded from a static library">,
+ HelpText<"Log the symbol that compels loading of each object file from a 
static library">,
+ Flags<[HelpHidden]>,
  Group;
 def whyload : Flag<["-"], 

[llvm-branch-commits] [llvm] 65c5c9f - ADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T15:56:12-08:00
New Revision: 65c5c9f92ec514ae41c8ea407d1c885737d699ec

URL: 
https://github.com/llvm/llvm-project/commit/65c5c9f92ec514ae41c8ea407d1c885737d699ec
DIFF: 
https://github.com/llvm/llvm-project/commit/65c5c9f92ec514ae41c8ea407d1c885737d699ec.diff

LOG: ADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC

Instead of computing the alignment and size of the `char` buffer in
`AlignedCharArrayUnion`, rely on the math in `std::aligned_union_t`.
Because some users of this rely on the `buffer` field existing with a
type convertible to `char *`, we can't change the field type, but we can
still avoid duplicating the logic.

A potential follow up would be to delete `AlignedCharArrayUnion` after
updating its users to use `std::aligned_union_t` directly; or if we like
our template parameters better, could update users to stop peeking
inside and then replace the definition with:
```
template 
using AlignedCharArrayUnion = std::aligned_union_t<1, T, Ts...>;
```

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

Added: 


Modified: 
llvm/include/llvm/Support/AlignOf.h

Removed: 




diff  --git a/llvm/include/llvm/Support/AlignOf.h 
b/llvm/include/llvm/Support/AlignOf.h
index eb42542b777f..f9dcde4d4ff1 100644
--- a/llvm/include/llvm/Support/AlignOf.h
+++ b/llvm/include/llvm/Support/AlignOf.h
@@ -13,32 +13,10 @@
 #ifndef LLVM_SUPPORT_ALIGNOF_H
 #define LLVM_SUPPORT_ALIGNOF_H
 
-#include "llvm/Support/Compiler.h"
-#include 
+#include 
 
 namespace llvm {
 
-namespace detail {
-
-template  class AlignerImpl {
-  T t;
-  AlignerImpl rest;
-  AlignerImpl() = delete;
-};
-
-template  class AlignerImpl {
-  T t;
-  AlignerImpl() = delete;
-};
-
-template  union SizerImpl {
-  char arr[sizeof(T)];
-  SizerImpl rest;
-};
-
-template  union SizerImpl { char arr[sizeof(T)]; };
-} // end namespace detail
-
 /// A suitably aligned and sized character array member which can hold elements
 /// of any type.
 ///
@@ -46,8 +24,8 @@ template  union SizerImpl { char 
arr[sizeof(T)]; };
 /// `buffer` member which can be used as suitable storage for a placement new 
of
 /// any of these types.
 template  struct AlignedCharArrayUnion {
-  alignas(::llvm::detail::AlignerImpl) char buffer[sizeof(
-  llvm::detail::SizerImpl)];
+  using AlignedUnion = std::aligned_union_t<1, T, Ts...>;
+  alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)];
 };
 
 } // end namespace llvm



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] bab72dd - [NFC][MC] TargetRegisterInfo::getSubReg is a MCRegister.

2020-12-02 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-02T15:46:38-08:00
New Revision: bab72dd5d5122817f41320ddde8e3246dfb5fc28

URL: 
https://github.com/llvm/llvm-project/commit/bab72dd5d5122817f41320ddde8e3246dfb5fc28
DIFF: 
https://github.com/llvm/llvm-project/commit/bab72dd5d5122817f41320ddde8e3246dfb5fc28.diff

LOG: [NFC][MC] TargetRegisterInfo::getSubReg is a MCRegister.

Typing the API appropriately.

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
llvm/lib/CodeGen/CalcSpillWeights.cpp
llvm/lib/CodeGen/RegAllocFast.cpp
llvm/lib/CodeGen/RegisterCoalescer.cpp
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
llvm/lib/Target/ARM/ARMAsmPrinter.cpp
llvm/lib/Target/Hexagon/BitTracker.cpp
llvm/lib/Target/Hexagon/BitTracker.h
llvm/lib/Target/Hexagon/HexagonBitTracker.cpp
llvm/lib/Target/Hexagon/HexagonBitTracker.h
llvm/lib/Target/Hexagon/HexagonExpandCondsets.cpp
llvm/lib/Target/Mips/MipsExpandPseudo.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h 
b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
index ff5104c11500..de2c1b069784 100644
--- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
@@ -1030,7 +1030,7 @@ class TargetRegisterInfo : public MCRegisterInfo {
   /// Returns the physical register number of sub-register "Index"
   /// for physical register RegNo. Return zero if the sub-register does not
   /// exist.
-  inline Register getSubReg(MCRegister Reg, unsigned Idx) const {
+  inline MCRegister getSubReg(MCRegister Reg, unsigned Idx) const {
 return static_cast(this)->getSubReg(Reg, Idx);
   }
 };

diff  --git a/llvm/lib/CodeGen/CalcSpillWeights.cpp 
b/llvm/lib/CodeGen/CalcSpillWeights.cpp
index 0a268a20d365..bf31441c37bb 100644
--- a/llvm/lib/CodeGen/CalcSpillWeights.cpp
+++ b/llvm/lib/CodeGen/CalcSpillWeights.cpp
@@ -64,7 +64,7 @@ static Register copyHint(const MachineInstr *MI, unsigned Reg,
 return Sub == HSub ? HReg : Register();
 
   const TargetRegisterClass *rc = MRI.getRegClass(Reg);
-  Register CopiedPReg = (HSub ? TRI.getSubReg(HReg, HSub) : HReg);
+  MCRegister CopiedPReg = HSub ? TRI.getSubReg(HReg, HSub) : HReg.asMCReg();
   if (rc->contains(CopiedPReg))
 return CopiedPReg;
 

diff  --git a/llvm/lib/CodeGen/RegAllocFast.cpp 
b/llvm/lib/CodeGen/RegAllocFast.cpp
index 3d83fcf8e09c..09c4674e4be6 100644
--- a/llvm/lib/CodeGen/RegAllocFast.cpp
+++ b/llvm/lib/CodeGen/RegAllocFast.cpp
@@ -950,7 +950,7 @@ void RegAllocFast::setPhysReg(MachineInstr , 
MachineOperand ,
   }
 
   // Handle subregister index.
-  MO.setReg(PhysReg ? TRI->getSubReg(PhysReg, MO.getSubReg()) : Register());
+  MO.setReg(PhysReg ? TRI->getSubReg(PhysReg, MO.getSubReg()) : MCRegister());
   MO.setIsRenamable(true);
   // Note: We leave the subreg number around a little longer in case of defs.
   // This is so that the register freeing logic in allocateInstruction can 
still

diff  --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp 
b/llvm/lib/CodeGen/RegisterCoalescer.cpp
index d244434801fb..7deabe6761d9 100644
--- a/llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -538,8 +538,8 @@ bool CoalescerPair::isCoalescable(const MachineInstr *MI) 
const {
   }
 
   // Now check that Dst matches DstReg.
-  if (Register::isPhysicalRegister(DstReg)) {
-if (!Register::isPhysicalRegister(Dst))
+  if (DstReg.isPhysical()) {
+if (!Dst.isPhysical())
   return false;
 assert(!DstIdx && !SrcIdx && "Inconsistent CoalescerPair state.");
 // DstSub could be set for a physreg from INSERT_SUBREG.
@@ -549,7 +549,7 @@ bool CoalescerPair::isCoalescable(const MachineInstr *MI) 
const {
 if (!SrcSub)
   return DstReg == Dst;
 // This is a partial register copy. Check that the parts match.
-return TRI.getSubReg(DstReg, SrcSub) == Dst;
+return Register(TRI.getSubReg(DstReg, SrcSub)) == Dst;
   } else {
 // DstReg is virtual.
 if (DstReg != Dst)

diff  --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index 71db374081e0..9d7a041390ca 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -840,9 +840,10 @@ void 
SIRegisterInfo::buildSpillLoadStore(MachineBasicBlock::iterator MI,
 
   // FIXME: Flat scratch does not have to be limited to a dword per store.
   for (unsigned i = 0, e = NumSubRegs; i != e; ++i, Offset += EltSize) {
-Register SubReg = NumSubRegs == 1
-  ? Register(ValueReg)
-  : getSubReg(ValueReg, getSubRegFromChannel(i));
+Register SubReg =
+NumSubRegs == 1
+? ValueReg
+: Register(getSubReg(ValueReg, getSubRegFromChannel(i)));
 
 unsigned SOffsetRegState = 0;
 unsigned SrcDstRegState = 

[llvm-branch-commits] [lldb] 640567d - [lldb] X-FAIL class template parameter pack tests on Windows

2020-12-02 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-03T00:38:05+01:00
New Revision: 640567d4646292f77e87e77b8710ebf1bde1f390

URL: 
https://github.com/llvm/llvm-project/commit/640567d4646292f77e87e77b8710ebf1bde1f390
DIFF: 
https://github.com/llvm/llvm-project/commit/640567d4646292f77e87e77b8710ebf1bde1f390.diff

LOG: [lldb] X-FAIL class template parameter pack tests on Windows

Both seem to fail to read values from the non-running target.

Added: 


Modified: 

lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py

lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
 
b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
index 6b4b96049cdb1..3a51e08d75e08 100644
--- 
a/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
+++ 
b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
@@ -7,6 +7,7 @@ class TestCaseClassTemplateNonTypeParameterPack(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
+@expectedFailureAll(oslist=["windows"]) # Fails to read memory from target.
 @no_debug_info_test
 def test(self):
 self.build()

diff  --git 
a/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
 
b/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
index 223ba52242742..88beac18e891a 100644
--- 
a/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
+++ 
b/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
@@ -7,6 +7,7 @@ class TestCaseClassTemplateTypeParameterPack(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
+@expectedFailureAll(oslist=["windows"]) # Fails to read memory from target.
 @no_debug_info_test
 def test(self):
 self.build()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] 542d3b6 - [mac/lld] Implement -why_load

2020-12-02 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-02T18:33:12-05:00
New Revision: 542d3b609dbe99a30759942271398890fc7770dc

URL: 
https://github.com/llvm/llvm-project/commit/542d3b609dbe99a30759942271398890fc7770dc
DIFF: 
https://github.com/llvm/llvm-project/commit/542d3b609dbe99a30759942271398890fc7770dc.diff

LOG: [mac/lld] Implement -why_load

This is useful for debugging why lld loads .o files it shouldn't load.
It's also useful for users of lld -- I've used ld64's version of this a
few times.

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

Added: 
lld/test/MachO/why-load.s

Modified: 
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Driver.h
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.cpp
lld/MachO/Options.td

Removed: 




diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index 82c017063d44..bc22680db58f 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -38,6 +38,7 @@ struct Configuration {
   bool staticLink = false;
   bool isPic = false;
   bool headerPadMaxInstallNames = false;
+  bool printWhyLoad = false;
   bool searchDylibsFirst = false;
   bool saveTemps = false;
   uint32_t headerPad;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 426101f4f9e1..9822ecdd9f2a 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -275,6 +275,8 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
 for (const ArchiveMember  : getArchiveMembers(*buffer)) {
   inputFiles.push_back(
   make(member.mbref, member.modTime, path));
+  printWhyLoad((forceLoadArchive ? "-force_load" : "-all_load"),
+   inputFiles.back());
 }
   }
 } else if (config->forceLoadObjC) {
@@ -291,6 +293,7 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
   if (hasObjCSection(member.mbref)) {
 inputFiles.push_back(
 make(member.mbref, member.modTime, path));
+printWhyLoad("-ObjC", inputFiles.back());
   }
 }
   }
@@ -637,6 +640,7 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
   config->headerPad = args::getHex(args, OPT_headerpad, /*Default=*/32);
   config->headerPadMaxInstallNames =
   args.hasArg(OPT_headerpad_max_install_names);
+  config->printWhyLoad = args.hasArg(OPT_why_load);
   config->outputType = getOutputType(args);
   config->runtimePaths = args::getStrings(args, OPT_rpath);
   config->allLoad = args.hasArg(OPT_all_load);

diff  --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h
index d5625fd3873e..db7c54c59966 100644
--- a/lld/MachO/Driver.h
+++ b/lld/MachO/Driver.h
@@ -19,6 +19,7 @@ namespace lld {
 namespace macho {
 
 class DylibFile;
+class InputFile;
 
 class MachOOptTable : public llvm::opt::OptTable {
 public:
@@ -45,6 +46,8 @@ llvm::Optional 
makeDylibFromTAPI(llvm::MemoryBufferRef mbref,
 
 uint32_t getModTime(llvm::StringRef path);
 
+void printWhyLoad(StringRef reason, const InputFile *);
+
 } // namespace macho
 } // namespace lld
 

diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 77f76b522d7e..9c09ff682286 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Driver.h"
+#include "Config.h"
 #include "InputFiles.h"
 
 #include "lld/Common/Args.h"
@@ -185,3 +186,10 @@ uint32_t macho::getModTime(StringRef path) {
   warn("failed to get modification time of " + path);
   return 0;
 }
+
+void macho::printWhyLoad(StringRef reason, const InputFile *f) {
+  if (!config->printWhyLoad)
+return;
+  lld::outs() << reason << " forced load of " << toString(f)
+  << '\n';
+}

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 4fd9873bcbd3..a24d045096c6 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -621,6 +621,10 @@ void ArchiveFile::fetch(const object::Archive::Symbol 
) {
 
   auto file = make(mb, modTime, getName());
 
+  // ld64 doesn't demangle sym here even with -demangle. Match that, so
+  // intentionally no call to toMachOString() here.
+  printWhyLoad(sym.getName(), file);
+
   symbols.insert(symbols.end(), file->symbols.begin(), file->symbols.end());
   subsections.insert(subsections.end(), file->subsections.begin(),
  file->subsections.end());

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 399928e8d9ae..5b38fc650e9f 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -426,8 +426,7 @@ def commons : Separate<["-"], "commons">,
 def grp_introspect : OptionGroup<"introspect">, HelpText<"INTROSPECTING THE 
LINKER">;
 
 def why_load : Flag<["-"], "why_load">,
- HelpText<"Log the symbol that compels loading of each object file from a 
static library">,
- Flags<[HelpHidden]>,
+ HelpText<"Log why each object 

[llvm-branch-commits] [flang] 86f59de - [flang] Fix bugs related to merging generics during USE

2020-12-02 Thread Tim Keith via llvm-branch-commits

Author: Tim Keith
Date: 2020-12-02T15:13:50-08:00
New Revision: 86f59de13b8058280d468984727bd1e6727f2112

URL: 
https://github.com/llvm/llvm-project/commit/86f59de13b8058280d468984727bd1e6727f2112
DIFF: 
https://github.com/llvm/llvm-project/commit/86f59de13b8058280d468984727bd1e6727f2112.diff

LOG: [flang] Fix bugs related to merging generics during USE

When the same generic name is use-associated from two modules, the
generics are merged into a single one in the current scope. This change
fixes some bugs in that process.

When a generic is merged, it can have two specific procedures with the
same name as the generic (c.f. module m7c in modfile07.f90). We were
disallowing that by checking for duplicate names in the generic rather
than duplicate symbols. Changing `namesSeen` to `symbolsSeen` in
`ResolveSpecificsInGeneric` fixes that.

We weren't including each USE of those generics in the .mod file so in
some cases they were incorrect. Extend GenericDetails to specify all
use-associated symbols that are merged into the generic. This is used to
write out .mod files correctly.

The distinguishability check for specific procedures of a generic
sometimes have to refer to procedures from a use-associated generic in
error messages. In that case we don't have the source location of the
procedure so adapt the message to say where is was use-associated from.
This requires passing the scope through the checks to make that
determination.

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

Added: 


Modified: 
flang/include/flang/Semantics/symbol.h
flang/lib/Semantics/check-declarations.cpp
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/resolve-names.cpp
flang/lib/Semantics/symbol.cpp
flang/test/Semantics/getsymbols03-a.f90
flang/test/Semantics/modfile07.f90
flang/test/Semantics/resolve17.f90

Removed: 




diff  --git a/flang/include/flang/Semantics/symbol.h 
b/flang/include/flang/Semantics/symbol.h
index 246bf2d0b338..833e3ab77720 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -155,6 +155,7 @@ class AssocEntityDetails : public EntityDetails {
   MaybeExpr expr_;
   std::optional rank_;
 };
+llvm::raw_ostream <<(llvm::raw_ostream &, const AssocEntityDetails &);
 
 // An entity known to be an object.
 class ObjectEntityDetails : public EntityDetails {
@@ -432,6 +433,7 @@ class GenericDetails {
   const SymbolVector () const { return specificProcs_; }
   const std::vector () const { return bindingNames_; }
   void AddSpecificProc(const Symbol &, SourceName bindingName);
+  const SymbolVector () const { return uses_; }
 
   // specific and derivedType indicate a specific procedure or derived type
   // with the same name as this generic. Only one of them may be set.
@@ -441,6 +443,7 @@ class GenericDetails {
   Symbol *derivedType() { return derivedType_; }
   const Symbol *derivedType() const { return derivedType_; }
   void set_derivedType(Symbol );
+  void AddUse(const Symbol &);
 
   // Copy in specificProcs, specific, and derivedType from another generic
   void CopyFrom(const GenericDetails &);
@@ -450,22 +453,19 @@ class GenericDetails {
   const Symbol *CheckSpecific() const;
   Symbol *CheckSpecific();
 
-  const std::optional () const { return useDetails_; }
-  void set_useDetails(const UseDetails ) { useDetails_ = details; }
-
 private:
   GenericKind kind_;
   // all of the specific procedures for this generic
   SymbolVector specificProcs_;
   std::vector bindingNames_;
+  // Symbols used from other modules merged into this one
+  SymbolVector uses_;
   // a specific procedure with the same name as this generic, if any
   Symbol *specific_{nullptr};
   // a derived type with the same name as this generic, if any
   Symbol *derivedType_{nullptr};
-  // If two USEs of generics were merged to form this one, this is the
-  // UseDetails for one of them. Used for reporting USE errors.
-  std::optional useDetails_;
 };
+llvm::raw_ostream <<(llvm::raw_ostream &, const GenericDetails &);
 
 class UnknownDetails {};
 

diff  --git a/flang/lib/Semantics/check-declarations.cpp 
b/flang/lib/Semantics/check-declarations.cpp
index a0b445b8d046..782e4c864421 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -120,11 +120,12 @@ class DistinguishabilityHelper {
 public:
   DistinguishabilityHelper(SemanticsContext ) : context_{context} {}
   void Add(const Symbol &, GenericKind, const Symbol &, const Procedure &);
-  void Check();
+  void Check(const Scope &);
 
 private:
-  void SayNotDistinguishable(
-  const SourceName &, GenericKind, const Symbol &, const Symbol &);
+  void SayNotDistinguishable(const Scope &, const SourceName &, GenericKind,
+  const Symbol &, const Symbol &);
+  void AttachDeclaration(parser::Message &, const Scope &, const Symbol &);
 
   

[llvm-branch-commits] [lldb] c49e718 - [lldb][NFC] Make DeclOrigin::Valid() const

2020-12-02 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-03T00:08:19+01:00
New Revision: c49e71805142ac3a27a5567ce516890e9243b34e

URL: 
https://github.com/llvm/llvm-project/commit/c49e71805142ac3a27a5567ce516890e9243b34e
DIFF: 
https://github.com/llvm/llvm-project/commit/c49e71805142ac3a27a5567ce516890e9243b34e.diff

LOG: [lldb][NFC] Make DeclOrigin::Valid() const

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index b8c751479d4b..bf4ad174cf9c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -160,7 +160,7 @@ class ClangASTImporter {
   decl = rhs.decl;
 }
 
-bool Valid() { return (ctx != nullptr || decl != nullptr); }
+bool Valid() const { return (ctx != nullptr || decl != nullptr); }
 
 clang::ASTContext *ctx;
 clang::Decl *decl;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 168b803 - ADT: Remove redundant `alignas` from IntervalMap, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T14:33:20-08:00
New Revision: 168b803b4519ea49b11dfc98560623beb20e812f

URL: 
https://github.com/llvm/llvm-project/commit/168b803b4519ea49b11dfc98560623beb20e812f
DIFF: 
https://github.com/llvm/llvm-project/commit/168b803b4519ea49b11dfc98560623beb20e812f.diff

LOG: ADT: Remove redundant `alignas` from IntervalMap, NFC

`AlignedArrayCharUnion` is now using `alignas`, which is properly
supported now by all the host toolchains we support. As a result, the
extra `alignas` on `IntervalMap` isn't needed anymore.

This is effectively a revert of 379daa29744cd96b0a87ed0d4a010fa4bc47ce73.

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

Added: 


Modified: 
llvm/include/llvm/ADT/IntervalMap.h

Removed: 




diff  --git a/llvm/include/llvm/ADT/IntervalMap.h 
b/llvm/include/llvm/ADT/IntervalMap.h
index db7804d0a551..b6c9fc79108c 100644
--- a/llvm/include/llvm/ADT/IntervalMap.h
+++ b/llvm/include/llvm/ADT/IntervalMap.h
@@ -963,8 +963,7 @@ class IntervalMap {
 
 private:
   // The root data is either a RootLeaf or a RootBranchData instance.
-  alignas(RootLeaf) alignas(RootBranchData)
-  AlignedCharArrayUnion data;
+  AlignedCharArrayUnion data;
 
   // Tree height.
   // 0: Leaves in root.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 91e66bf - Revert "Use std::is_trivially_copyable", breaks MSVC build

2020-12-02 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-12-02T14:30:46-08:00
New Revision: 91e66bfd321ff3e932a9f9706b22fcf455a4a686

URL: 
https://github.com/llvm/llvm-project/commit/91e66bfd321ff3e932a9f9706b22fcf455a4a686
DIFF: 
https://github.com/llvm/llvm-project/commit/91e66bfd321ff3e932a9f9706b22fcf455a4a686.diff

LOG: Revert "Use std::is_trivially_copyable", breaks MSVC build

Revert "Delete llvm::is_trivially_copyable and CMake variable 
HAVE_STD_IS_TRIVIALLY_COPYABLE"

This reverts commit 4d4bd40b578d77b8c5bc349ded405fb58c333c78.

This reverts commit 557b00e0afb2dc1776f50948094ca8cc62d97be4.

Added: 


Modified: 
llvm/cmake/config-ix.cmake
llvm/docs/ProgrammersManual.rst
llvm/include/llvm/ADT/DenseMap.h
llvm/include/llvm/ADT/Optional.h
llvm/include/llvm/ADT/PointerIntPair.h
llvm/include/llvm/ADT/STLExtras.h
llvm/include/llvm/Config/config.h.cmake
llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
llvm/include/llvm/Support/type_traits.h
llvm/tools/llvm-diff/DifferenceEngine.cpp
llvm/unittests/ADT/ArrayRefTest.cpp
llvm/unittests/ADT/ImmutableListTest.cpp
llvm/unittests/ADT/OptionalTest.cpp
llvm/unittests/ADT/PointerIntPairTest.cpp
llvm/unittests/ADT/StringRefTest.cpp
llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
llvm/unittests/Bitstream/BitstreamReaderTest.cpp
llvm/unittests/CodeGen/MachineInstrTest.cpp
llvm/unittests/CodeGen/TypeTraitsTest.cpp
llvm/unittests/IR/CFGBuilder.cpp
llvm/unittests/Support/ScaledNumberTest.cpp
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

Removed: 




diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index b4c54da01912..818fafbce148 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -351,6 +351,15 @@ else()
   unset(HAVE_FFI_CALL CACHE)
 endif( LLVM_ENABLE_FFI )
 
+# Whether we can use std::is_trivially_copyable to verify 
llvm::is_trivially_copyable.
+CHECK_CXX_SOURCE_COMPILES("
+#include 
+struct T { int val; };
+static_assert(std::is_trivially_copyable::value, \"ok\");
+int main() { return 0;}
+" HAVE_STD_IS_TRIVIALLY_COPYABLE)
+
+
 # Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported.
 include(CheckAtomic)
 

diff  --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index e303a7a18eba..d9925d69d9f6 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -1530,7 +1530,7 @@ SmallVector has grown a few other minor advantages over 
std::vector, causing
 #. std::vector is exception-safe, and some implementations have pessimizations
that copy elements when SmallVector would move them.
 
-#. SmallVector understands ``std::is_trivially_copyable`` and uses 
realloc aggressively.
+#. SmallVector understands ``llvm::is_trivially_copyable`` and uses 
realloc aggressively.
 
 #. Many LLVM APIs take a SmallVectorImpl as an out parameter (see the note
below).

diff  --git a/llvm/include/llvm/ADT/DenseMap.h 
b/llvm/include/llvm/ADT/DenseMap.h
index 7f7a4593ae36..42e4fc84175c 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -426,8 +426,8 @@ class DenseMapBase : public DebugEpochBase {
 setNumEntries(other.getNumEntries());
 setNumTombstones(other.getNumTombstones());
 
-if (std::is_trivially_copyable::value &&
-std::is_trivially_copyable::value)
+if (is_trivially_copyable::value &&
+is_trivially_copyable::value)
   memcpy(reinterpret_cast(getBuckets()), other.getBuckets(),
  getNumBuckets() * sizeof(BucketT));
 else

diff  --git a/llvm/include/llvm/ADT/Optional.h 
b/llvm/include/llvm/ADT/Optional.h
index 5fff0acca816..be32178cb185 100644
--- a/llvm/include/llvm/ADT/Optional.h
+++ b/llvm/include/llvm/ADT/Optional.h
@@ -17,10 +17,10 @@
 
 #include "llvm/ADT/None.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/type_traits.h"
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace llvm {
@@ -32,7 +32,7 @@ namespace optional_detail {
 struct in_place_t {};
 
 /// Storage for any type.
-template ::value>
+template ::value>
 class OptionalStorage {
   union {
 char empty;

diff  --git a/llvm/include/llvm/ADT/PointerIntPair.h 
b/llvm/include/llvm/ADT/PointerIntPair.h
index 600fcebff3ea..cb8b202c48b7 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -15,6 +15,7 @@
 
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
+#include "llvm/Support/type_traits.h"
 #include 
 #include 
 #include 
@@ -126,6 +127,19 @@ class PointerIntPair {
   }
 };
 
+// Specialize is_trivially_copyable to avoid limitation of 
llvm::is_trivially_copyable
+// when compiled with gcc 4.9.
+template 
+struct is_trivially_copyable> : std::true_type {
+#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
+  

[llvm-branch-commits] [llvm] c9be4ef - [X86] Add TLS_(base_)addrX32 for X32 mode

2020-12-02 Thread Harald van Dijk via llvm-branch-commits

Author: Harald van Dijk
Date: 2020-12-02T22:20:36Z
New Revision: c9be4ef184c1a8cb042ae846f9f1818b3ffcddb0

URL: 
https://github.com/llvm/llvm-project/commit/c9be4ef184c1a8cb042ae846f9f1818b3ffcddb0
DIFF: 
https://github.com/llvm/llvm-project/commit/c9be4ef184c1a8cb042ae846f9f1818b3ffcddb0.diff

LOG: [X86] Add TLS_(base_)addrX32 for X32 mode

LLVM has TLS_(base_)addr32 for 32-bit TLS addresses in 32-bit mode, and
TLS_(base_)addr64 for 64-bit TLS addresses in 64-bit mode. x32 mode wants 32-bit
TLS addresses in 64-bit mode, which were not yet handled. This adds
TLS_(base_)addrX32 as copies of TLS_(base_)addr64, except that they use
tls32(base)addr rather than tls64(base)addr, and then restricts
TLS_(base_)addr64 to 64-bit LP64 mode, TLS_(base_)addrX32 to 64-bit ILP32 mode.

Reviewed By: RKSimon

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

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/test/CodeGen/X86/pic.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 56e098a48dd5..caf9e690f5b8 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -19123,7 +19123,7 @@ LowerToTLSGeneralDynamicModel32(GlobalAddressSDNode 
*GA, SelectionDAG ,
   return GetTLSADDR(DAG, Chain, GA, , PtrVT, X86::EAX, X86II::MO_TLSGD);
 }
 
-// Lower ISD::GlobalTLSAddress using the "general dynamic" model, 64 bit
+// Lower ISD::GlobalTLSAddress using the "general dynamic" model, 64 bit LP64
 static SDValue
 LowerToTLSGeneralDynamicModel64(GlobalAddressSDNode *GA, SelectionDAG ,
 const EVT PtrVT) {
@@ -19131,6 +19131,14 @@ LowerToTLSGeneralDynamicModel64(GlobalAddressSDNode 
*GA, SelectionDAG ,
 X86::RAX, X86II::MO_TLSGD);
 }
 
+// Lower ISD::GlobalTLSAddress using the "general dynamic" model, 64 bit ILP32
+static SDValue
+LowerToTLSGeneralDynamicModelX32(GlobalAddressSDNode *GA, SelectionDAG ,
+ const EVT PtrVT) {
+  return GetTLSADDR(DAG, DAG.getEntryNode(), GA, nullptr, PtrVT,
+X86::EAX, X86II::MO_TLSGD);
+}
+
 static SDValue LowerToTLSLocalDynamicModel(GlobalAddressSDNode *GA,
SelectionDAG ,
const EVT PtrVT,
@@ -19241,8 +19249,11 @@ X86TargetLowering::LowerGlobalTLSAddress(SDValue Op, 
SelectionDAG ) const {
 TLSModel::Model model = DAG.getTarget().getTLSModel(GV);
 switch (model) {
   case TLSModel::GeneralDynamic:
-if (Subtarget.is64Bit())
-  return LowerToTLSGeneralDynamicModel64(GA, DAG, PtrVT);
+if (Subtarget.is64Bit()) {
+  if (Subtarget.isTarget64BitLP64())
+return LowerToTLSGeneralDynamicModel64(GA, DAG, PtrVT);
+  return LowerToTLSGeneralDynamicModelX32(GA, DAG, PtrVT);
+}
 return LowerToTLSGeneralDynamicModel32(GA, DAG, PtrVT);
   case TLSModel::LocalDynamic:
 return LowerToTLSLocalDynamicModel(GA, DAG, PtrVT,
@@ -33511,8 +33522,10 @@ 
X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr ,
   default: llvm_unreachable("Unexpected instr type to insert");
   case X86::TLS_addr32:
   case X86::TLS_addr64:
+  case X86::TLS_addrX32:
   case X86::TLS_base_addr32:
   case X86::TLS_base_addr64:
+  case X86::TLS_base_addrX32:
 return EmitLoweredTLSAddr(MI, BB);
   case X86::INDIRECT_THUNK_CALL32:
   case X86::INDIRECT_THUNK_CALL64:

diff  --git a/llvm/lib/Target/X86/X86InstrCompiler.td 
b/llvm/lib/Target/X86/X86InstrCompiler.td
index 9f180c4c91aa..0c9f972cf225 100644
--- a/llvm/lib/Target/X86/X86InstrCompiler.td
+++ b/llvm/lib/Target/X86/X86InstrCompiler.td
@@ -467,11 +467,19 @@ let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
 def TLS_addr64 : I<0, Pseudo, (outs), (ins i64mem:$sym),
"# TLS_addr64",
   [(X86tlsaddr tls64addr:$sym)]>,
-  Requires<[In64BitMode]>;
+  Requires<[In64BitMode, IsLP64]>;
 def TLS_base_addr64 : I<0, Pseudo, (outs), (ins i64mem:$sym),
"# TLS_base_addr64",
   [(X86tlsbaseaddr tls64baseaddr:$sym)]>,
-  Requires<[In64BitMode]>;
+  Requires<[In64BitMode, IsLP64]>;
+def TLS_addrX32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
+   "# TLS_addrX32",
+  [(X86tlsaddr tls32addr:$sym)]>,
+  Requires<[In64BitMode, NotLP64]>;
+def TLS_base_addrX32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
+   "# TLS_base_addrX32",
+  [(X86tlsbaseaddr tls32baseaddr:$sym)]>,
+  Requires<[In64BitMode, NotLP64]>;
 }
 
 // Darwin TLS Support

diff  --git a/llvm/lib/Target/X86/X86MCInstLower.cpp 

[llvm-branch-commits] [llvm] 18ce612 - Use PC-relative address for x32 TLS address

2020-12-02 Thread Harald van Dijk via llvm-branch-commits

Author: H.J. Lu
Date: 2020-12-02T22:20:36Z
New Revision: 18ce612353795da6838aade2b933503cbe3cf9b9

URL: 
https://github.com/llvm/llvm-project/commit/18ce612353795da6838aade2b933503cbe3cf9b9
DIFF: 
https://github.com/llvm/llvm-project/commit/18ce612353795da6838aade2b933503cbe3cf9b9.diff

LOG: Use PC-relative address for x32 TLS address

Since x32 supports PC-relative address, it shouldn't use EBX for TLS
address.  Instead of checking N.getValueType(), we should check
Subtarget->is32Bit().  This fixes PR 22676.

Reviewed By: RKSimon

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

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp 
b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 9a16dc17ba61..de8c2f345fb5 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2694,12 +2694,12 @@ bool X86DAGToDAGISel::selectTLSADDRAddr(SDValue N, 
SDValue ,
   AM.Disp += GA->getOffset();
   AM.SymbolFlags = GA->getTargetFlags();
 
-  MVT VT = N.getSimpleValueType();
-  if (VT == MVT::i32) {
+  if (Subtarget->is32Bit()) {
 AM.Scale = 1;
 AM.IndexReg = CurDAG->getRegister(X86::EBX, MVT::i32);
   }
 
+  MVT VT = N.getSimpleValueType();
   getAddressOperands(AM, SDLoc(N), VT, Base, Scale, Index, Disp, Segment);
   return true;
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 32c501d - Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T14:07:23-08:00
New Revision: 32c501dd88b62787d3a5ffda7aabcf4650dbe3cd

URL: 
https://github.com/llvm/llvm-project/commit/32c501dd88b62787d3a5ffda7aabcf4650dbe3cd
DIFF: 
https://github.com/llvm/llvm-project/commit/32c501dd88b62787d3a5ffda7aabcf4650dbe3cd.diff

LOG: Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and 
DirectoryName, NFC

Push `FileEntryRef` and `DirectoryEntryRef` further, using it them
`Module::Umbrella`, `Module::Header::Entry`, and
`Module::DirectoryName::Entry`.

- Add `DirectoryEntryRef::operator const DirectoryEntry *` and
  `OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr`, to get the
  same "degrades to `DirectoryEntry*` behaviour `FileEntryRef` enjoys
  (this avoids a bunch of churn in various clang tools).
- Fix the `DirectoryEntryRef` constructor from `MapEntry` to take it by
  `const&`.

Note that we cannot get rid of the `...AsWritten` names leveraging the
new classes, since these need to be as written in the `ModuleMap` file
and the module directory path is preprended for the lookup in the
`FileManager`.

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

Added: 


Modified: 
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/Module.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Basic/Module.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DirectoryEntry.h 
b/clang/include/clang/Basic/DirectoryEntry.h
index a6ec5f89aa28..4e229962bdcc 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -51,7 +51,26 @@ class DirectoryEntryRef {
   const MapEntry () const { return *ME; }
 
   DirectoryEntryRef() = delete;
-  DirectoryEntryRef(MapEntry ) : ME() {}
+  DirectoryEntryRef(const MapEntry ) : ME() {}
+
+  /// Allow DirectoryEntryRef to degrade into 'const DirectoryEntry*' to
+  /// facilitate incremental adoption.
+  ///
+  /// The goal is to avoid code churn due to dances like the following:
+  /// \code
+  /// // Old code.
+  /// lvalue = rvalue;
+  ///
+  /// // Temporary code from an incremental patch.
+  /// lvalue = ();
+  ///
+  /// // Final code.
+  /// lvalue = rvalue;
+  /// \endcode
+  ///
+  /// FIXME: Once DirectoryEntryRef is "everywhere" and DirectoryEntry::getName
+  /// has been deleted, delete this implicit conversion.
+  operator const DirectoryEntry *() const { return (); }
 
 private:
   friend class FileMgr::MapEntryOptionalStorage;
@@ -147,4 +166,76 @@ static_assert(
 } // end namespace optional_detail
 } // end namespace llvm
 
+namespace clang {
+
+/// Wrapper around Optional that degrades to 'const
+/// DirectoryEntry*', facilitating incremental patches to propagate
+/// DirectoryEntryRef.
+///
+/// This class can be used as return value or field where it's convenient for
+/// an Optional to degrade to a 'const DirectoryEntry*'. The
+/// purpose is to avoid code churn due to dances like the following:
+/// \code
+/// // Old code.
+/// lvalue = rvalue;
+///
+/// // Temporary code from an incremental patch.
+/// Optional MaybeF = rvalue;
+/// lvalue = MaybeF ? () : nullptr;
+///
+/// // Final code.
+/// lvalue = rvalue;
+/// \endcode
+///
+/// FIXME: Once DirectoryEntryRef is "everywhere" and DirectoryEntry::LastRef
+/// and DirectoryEntry::getName have been deleted, delete this class and
+/// replace instances with Optional.
+class OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr
+: public Optional {
+public:
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr() = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &&) = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(
+  const OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &) = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
+  operator=(OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &&) = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
+  operator=(const OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &) = 
default;
+
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(llvm::NoneType) {}
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(DirectoryEntryRef Ref)
+  : Optional(Ref) {}
+  
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(Optional
 MaybeRef)
+  : Optional(MaybeRef) {}
+
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr 
=(llvm::NoneType) {
+Optional::operator=(None);
+return *this;
+  }
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr 
=(DirectoryEntryRef Ref) {
+Optional::operator=(Ref);
+return *this;
+  }
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
+  operator=(Optional MaybeRef) {
+

[llvm-branch-commits] [llvm] 327af6a - [gn build] Port 24d4291ca70

2020-12-02 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-02T21:52:41Z
New Revision: 327af6aa60bf689713ff7dde42a9caa3a2dd03f8

URL: 
https://github.com/llvm/llvm-project/commit/327af6aa60bf689713ff7dde42a9caa3a2dd03f8
DIFF: 
https://github.com/llvm/llvm-project/commit/327af6aa60bf689713ff7dde42a9caa3a2dd03f8.diff

LOG: [gn build] Port 24d4291ca70

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
index c0d6746d11596..1ae43869fbe5d 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
@@ -147,6 +147,7 @@ static_library("CodeGen") {
 "PreISelIntrinsicLowering.cpp",
 "ProcessImplicitDefs.cpp",
 "PrologEpilogInserter.cpp",
+"PseudoProbeInserter.cpp",
 "PseudoSourceValue.cpp",
 "RDFGraph.cpp",
 "RDFLiveness.cpp",



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 4277add - [libc++] Install missing packages to cross-compile to 32 bits during CI

2020-12-02 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-02T16:45:53-05:00
New Revision: 4277adda1d2f1e88e3556806dfc71d736146213c

URL: 
https://github.com/llvm/llvm-project/commit/4277adda1d2f1e88e3556806dfc71d736146213c
DIFF: 
https://github.com/llvm/llvm-project/commit/4277adda1d2f1e88e3556806dfc71d736146213c.diff

LOG: [libc++] Install missing packages to cross-compile to 32 bits during CI

Added: 


Modified: 
libcxx/utils/ci/Dockerfile

Removed: 




diff  --git a/libcxx/utils/ci/Dockerfile b/libcxx/utils/ci/Dockerfile
index 21fb7ff535e8..ea9856d950eb 100644
--- a/libcxx/utils/ci/Dockerfile
+++ b/libcxx/utils/ci/Dockerfile
@@ -46,6 +46,7 @@ RUN apt-get update && apt-get install -y bash curl
 
 # Install various tools used by the build or the test suite
 RUN apt-get update && apt-get install -y ninja-build python3 python3-sphinx 
python3-distutils git gdb
+RUN apt-get update && apt-get install -y libc6-dev-i386 # Required to 
cross-compile to 32 bits
 
 # Install the most recently released LLVM
 RUN apt-get update && apt-get install -y lsb-release wget 
software-properties-common



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 24d4291 - [CSSPGO] Pseudo probes for function calls.

2020-12-02 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-02T13:45:20-08:00
New Revision: 24d4291ca704fa5ee2419b4163aa324eca693fd6

URL: 
https://github.com/llvm/llvm-project/commit/24d4291ca704fa5ee2419b4163aa324eca693fd6
DIFF: 
https://github.com/llvm/llvm-project/commit/24d4291ca704fa5ee2419b4163aa324eca693fd6.diff

LOG: [CSSPGO] Pseudo probes for function calls.

An indirect call site needs to be probed for its potential call targets. With 
CSSPGO a direct call also needs a probe so that a calling context can be 
represented by a stack of callsite probes. Unlike pseudo probes for basic 
blocks that are in form of standalone intrinsic call instructions, pseudo 
probes for callsites have to be attached to the call instruction, thus a 
separate instruction would not work.

One possible way of attaching a probe to a call instruction is to use a special 
metadata that carries information about the probe. The special metadata will 
have to make its way through the optimization pipeline down to object emission. 
This requires additional efforts to maintain the metadata in various places. 
Given that the `!dbg` metadata is a first-class metadata and has all essential 
support in place , leveraging the `!dbg` metadata as a channel to encode pseudo 
probe information is probably the easiest solution.

With the requirement of not inflating `!dbg` metadata that is allocated for 
almost every instruction, we found that the 32-bit DWARF discriminator field 
which mainly serves AutoFDO can be reused for pseudo probes. DWARF 
discriminators distinguish identical source locations between instructions and 
with pseudo probes such support is not required. In this change we are using 
the discriminator field to encode the ID and type of a callsite probe and the 
encoded value will be unpacked and consumed right before object emission. When 
a callsite is inlined, the callsite discriminator field will go with the 
inlined instructions. The `!dbg` metadata of an inlined instruction is in form 
of a scope stack. The top of the stack is the instruction's original `!dbg` 
metadata and the bottom of the stack is for the original callsite of the 
top-level inliner. Except for the top of the stack, all other elements of the 
stack actually refer to the nested inlined callsites whose discriminator field 
(which actually represents a calliste probe) can be used together to represent 
the inline context of an inlined PseudoProbeInst or CallInst.

To avoid collision with the baseline AutoFDO in various places that handles 
dwarf discriminators where a check against  the `-pseudo-probe-for-profiling` 
switch is not available, a special encoding scheme is used to tell apart a 
pseudo probe discriminator from a regular discriminator. For the regular 
discriminator, if all lowest 3 bits are non-zero, it means the discriminator is 
basically empty and all higher 29 bits can be reversed for pseudo probe use.

Callsite pseudo probes are inserted in `SampleProfileProbePass` and a 
target-independent MIR pass `PseudoProbeInserter` is added to unpack the probe 
ID/type from `!dbg`.

Note that with this work the switch -debug-info-for-profiling will not work 
with -pseudo-probe-for-profiling anymore. They cannot be used at the same time.

Reviewed By: wmi

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

Added: 
llvm/include/llvm/IR/PseudoProbe.h
llvm/lib/CodeGen/PseudoProbeInserter.cpp

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Target/TargetOptions.h
llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index b62a66a51d26..724e2ec16fc3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -555,6 +555,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
   Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
   Options.EnableAIXExtendedAltivecABI = 
CodeGenOpts.EnableAIXExtendedAltivecABI;
+  Options.PseudoProbeForProfiling = CodeGenOpts.PseudoProbeForProfiling;
   Options.ValueTrackingVariableLocations =
   CodeGenOpts.ValueTrackingVariableLocations;
   Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;

diff  --git a/llvm/include/llvm/CodeGen/CommandFlags.h 

[llvm-branch-commits] [llvm] dad5d95 - [dfsan] Rename CachedCombinedShadow to be CachedShadow

2020-12-02 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2020-12-02T21:39:16Z
New Revision: dad5d9588335d6e4232b7c263da24ae2676673da

URL: 
https://github.com/llvm/llvm-project/commit/dad5d9588335d6e4232b7c263da24ae2676673da
DIFF: 
https://github.com/llvm/llvm-project/commit/dad5d9588335d6e4232b7c263da24ae2676673da.diff

LOG: [dfsan] Rename CachedCombinedShadow to be CachedShadow

At D92261, this type will be used to cache both combined shadow and
converted shadow values.

Reviewed-by: morehouse

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

Added: 


Modified: 
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 4fd6308fcc49..46f4becb511f 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -428,12 +428,12 @@ struct DFSanFunction {
   std::vector NonZeroChecks;
   bool AvoidNewBlocks;
 
-  struct CachedCombinedShadow {
-BasicBlock *Block;
+  struct CachedShadow {
+BasicBlock *Block; // The block where Shadow is defined.
 Value *Shadow;
   };
-  DenseMap, CachedCombinedShadow>
-  CachedCombinedShadows;
+  /// Maps a value to its latest shadow value in terms of domination tree.
+  DenseMap, CachedShadow> CachedShadows;
   DenseMap> ShadowElements;
 
   DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI)
@@ -1145,7 +1145,7 @@ Value *DFSanFunction::combineShadows(Value *V1, Value 
*V2, Instruction *Pos) {
   auto Key = std::make_pair(V1, V2);
   if (V1 > V2)
 std::swap(Key.first, Key.second);
-  CachedCombinedShadow  = CachedCombinedShadows[Key];
+  CachedShadow  = CachedShadows[Key];
   if (CCS.Block && DT.dominates(CCS.Block, Pos->getParent()))
 return CCS.Shadow;
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 838ecf2 - [dfsan] Test loading global ptrs

2020-12-02 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2020-12-02T21:35:41Z
New Revision: 838ecf2ea483ce6986a1d38208555155bbc53bba

URL: 
https://github.com/llvm/llvm-project/commit/838ecf2ea483ce6986a1d38208555155bbc53bba
DIFF: 
https://github.com/llvm/llvm-project/commit/838ecf2ea483ce6986a1d38208555155bbc53bba.diff

LOG: [dfsan] Test loading global ptrs

This covers a branch in the loadShadow method.

Reviewed-by: morehouse

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

Added: 


Modified: 
llvm/test/Instrumentation/DataFlowSanitizer/load.ll

Removed: 




diff  --git a/llvm/test/Instrumentation/DataFlowSanitizer/load.ll 
b/llvm/test/Instrumentation/DataFlowSanitizer/load.ll
index 5bb3984227df..9cdf69d11ddb 100644
--- a/llvm/test/Instrumentation/DataFlowSanitizer/load.ll
+++ b/llvm/test/Instrumentation/DataFlowSanitizer/load.ll
@@ -166,3 +166,12 @@ define i64 @load64(i64* %p) {
   %a = load i64, i64* %p
   ret i64 %a
 }
+
+@X = constant i1 1
+define i1 @load_global() {
+  ; NO_COMBINE_PTR_LABEL: @"dfs$load_global"
+  ; NO_COMBINE_PTR_LABEL: store i16 0, i16* @__dfsan_retval_tls, align 2
+
+  %a = load i1, i1* @X
+  ret i1 %a
+}
\ No newline at end of file



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] acb6f80 - [CUDA][HIP] Fix overloading resolution

2020-12-02 Thread Yaxun Liu via llvm-branch-commits

Author: Yaxun (Sam) Liu
Date: 2020-12-02T16:33:33-05:00
New Revision: acb6f80d96b74af3ec515bb9811d213abb406c31

URL: 
https://github.com/llvm/llvm-project/commit/acb6f80d96b74af3ec515bb9811d213abb406c31
DIFF: 
https://github.com/llvm/llvm-project/commit/acb6f80d96b74af3ec515bb9811d213abb406c31.diff

LOG: [CUDA][HIP] Fix overloading resolution

This patch implements correct hostness based overloading resolution
in isBetterOverloadCandidate.

Based on hostness, if one candidate is emittable whereas the other
candidate is not emittable, the emittable candidate is better.

If both candidates are emittable, or neither is emittable based on hostness, 
then
other rules should be used to determine which is better. This is because
hostness based overloading resolution is mostly for determining
viability of a function. If two functions are both viable, other factors
should take precedence in preference.

If other rules cannot determine which is better, CUDA preference will be
used again to determine which is better.

However, correct hostness based overloading resolution
requires overloading resolution diagnostics to be deferred,
which is not on by default. The rationale is that deferring
overloading resolution diagnostics may hide overloading reslolutions
issues in header files.

An option -fgpu-exclude-wrong-side-overloads is added, which is off by
default.

When -fgpu-exclude-wrong-side-overloads is off, keep the original behavior,
that is, exclude wrong side overloads only if there are same side overloads.
This may result in incorrect overloading resolution when there are no
same side candates, but is sufficient for most CUDA/HIP applications.

When -fgpu-exclude-wrong-side-overloads is on, enable deferring
overloading resolution diagnostics and enable correct hostness
based overloading resolution, i.e., always exclude wrong side overloads.

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Overload.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/Driver/hip-options.hip
clang/test/SemaCUDA/deferred-oeverload.cu
clang/test/SemaCUDA/function-overload.cu

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index f41febf30c53..071cc314b7d1 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -243,6 +243,7 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate 
relocatable device code")
 LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions 
for HIP")
 LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for 
kernel launch bounds for HIP")
 LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for 
CUDA/HIP")
+LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side 
overloads in overloading resolution for CUDA/HIP")
 
 LANGOPT(SYCL  , 1, 0, "SYCL")
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6e37a3154bdf..b58f5cbc63d0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -721,6 +721,9 @@ defm gpu_allow_device_init : 
OptInFFlag<"gpu-allow-device-init",
 defm gpu_defer_diag : OptInFFlag<"gpu-defer-diag",
   "Defer", "Don't defer", " host/device related diagnostic messages"
   " for CUDA/HIP">;
+defm gpu_exclude_wrong_side_overloads : 
OptInFFlag<"gpu-exclude-wrong-side-overloads",
+  "Always exclude wrong side overloads", "Exclude wrong side overloads only if 
there are same side overloads",
+  " in overloading resolution for CUDA/HIP", [HelpHidden]>;
 def gpu_max_threads_per_block_EQ : Joined<["--"], 
"gpu-max-threads-per-block=">,
   Flags<[CC1Option]>,
   HelpText<"Default max threads per block for kernel launch bounds for HIP">;

diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 4f5e497bc202..5be6a618711c 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -1051,6 +1051,9 @@ class Sema;
 
 void destroyCandidates();
 
+/// Whether diagnostics should be deferred.
+bool shouldDeferDiags(Sema , ArrayRef Args, SourceLocation 
OpLoc);
+
   public:
 OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK,
  OperatorRewriteInfo RewriteInfo = {})

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index caa77123f7eb..a513c0025a62 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5610,6 +5610,12 @@ void 

[llvm-branch-commits] [llvm] baa005c - [dfsan] Add a test case for phi

2020-12-02 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2020-12-02T21:29:44Z
New Revision: baa005c96ce610e9ee91ef55a3a1b1eacd5a0a27

URL: 
https://github.com/llvm/llvm-project/commit/baa005c96ce610e9ee91ef55a3a1b1eacd5a0a27
DIFF: 
https://github.com/llvm/llvm-project/commit/baa005c96ce610e9ee91ef55a3a1b1eacd5a0a27.diff

LOG: [dfsan] Add a test case for phi

Added: 
llvm/test/Instrumentation/DataFlowSanitizer/phi.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Instrumentation/DataFlowSanitizer/phi.ll 
b/llvm/test/Instrumentation/DataFlowSanitizer/phi.ll
new file mode 100644
index ..08c457f3bfc7
--- /dev/null
+++ b/llvm/test/Instrumentation/DataFlowSanitizer/phi.ll
@@ -0,0 +1,24 @@
+; RUN: opt < %s -dfsan -S | FileCheck %s
+target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define {i32, i32} @test({i32, i32} %a, i1 %c) {
+  ; CHECK: [[E0:%.*]] = load i16, i16* getelementptr inbounds ([64 x i16], [64 
x i16]* @__dfsan_arg_tls, i64 0, i64 0), align 2
+  ; CHECK: [[E3:%.*]] = phi i16 [ [[E0]], %T ], [ [[E0]], %F ]
+  ; CHECK: store i16 [[E3]], i16* @__dfsan_retval_tls, align 2
+
+entry:
+  br i1 %c, label %T, label %F
+  
+T:
+  %at = insertvalue {i32, i32} %a, i32 1, 0
+  br label %done
+  
+F:
+  %af = insertvalue {i32, i32} %a, i32 1, 1
+  br label %done
+  
+done:
+  %b = phi {i32, i32} [%at, %T], [%af, %F]
+  ret {i32, i32} %b  
+}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 0849047 - Add a less ambiguous macro for Android version.

2020-12-02 Thread Dan Albert via llvm-branch-commits

Author: Dan Albert
Date: 2020-12-02T13:26:28-08:00
New Revision: 0849047860a343d8bcf1f828a82d585e89079943

URL: 
https://github.com/llvm/llvm-project/commit/0849047860a343d8bcf1f828a82d585e89079943
DIFF: 
https://github.com/llvm/llvm-project/commit/0849047860a343d8bcf1f828a82d585e89079943.diff

LOG: Add a less ambiguous macro for Android version.

Android has a handful of API levels relevant to developers described
here: https://developer.android.com/studio/build#module-level.
`__ANDROID_API__` is too vague and confuses a lot of people. Introduce
a new macro name that is explicit about which one it represents. Keep
the old name around because code has been using it for a decade.

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 60e47bcacbf4..0d5d6f553093 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -383,8 +383,12 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+  if (Maj) {
+Builder.defineMacro("__ANDROID_MIN_SDK_VERSION__", Twine(Maj));
+// This historical but ambiguous name for the minSdkVersion macro. Keep
+// defined for compatibility.
+Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  }
 } else {
 Builder.defineMacro("__gnu_linux__");
 }

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 079ec6e021f8..e599d9afb42e 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1397,6 +1397,7 @@
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
+// ANDROID-NOT:#define __ANDROID_MIN_SDK_VERSION__
 // ANDROID:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //
@@ -1407,7 +1408,8 @@
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
-// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
+// ANDROID20:#define __ANDROID_MIN_SDK_VERSION__ 20
 // ANDROID20:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] 6fa0662 - [dfsan] Add test cases for struct/pair

2020-12-02 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2020-12-02T21:25:23Z
New Revision: 6fa06628a728ac161b3f61a2a2fb749cd8e4b41b

URL: 
https://github.com/llvm/llvm-project/commit/6fa06628a728ac161b3f61a2a2fb749cd8e4b41b
DIFF: 
https://github.com/llvm/llvm-project/commit/6fa06628a728ac161b3f61a2a2fb749cd8e4b41b.diff

LOG: [dfsan] Add test cases for struct/pair

This is a child diff of D92261.

This locks down the behavior before the change.

Added: 
compiler-rt/test/dfsan/pair.cpp
compiler-rt/test/dfsan/struct.c

Modified: 


Removed: 




diff  --git a/compiler-rt/test/dfsan/pair.cpp b/compiler-rt/test/dfsan/pair.cpp
new file mode 100644
index ..830fe393b17b
--- /dev/null
+++ b/compiler-rt/test/dfsan/pair.cpp
@@ -0,0 +1,138 @@
+// RUN: %clangxx_dfsan %s -mllvm -dfsan-fast-16-labels -mllvm 
-dfsan-track-select-control-flow=false -mllvm 
-dfsan-combine-pointer-labels-on-load=false -o %t && %run %t
+
+#include 
+#include 
+#include 
+#include 
+
+__attribute__((noinline))
+std::pair
+make_pair(int *p, int i) { return {p, i}; }
+
+__attribute__((noinline))
+std::pair
+copy_pair1(const std::pair ) {
+  return pair;
+}
+
+__attribute__((noinline))
+std::pair
+copy_pair2(std::pair *pair) {
+  return *pair;
+}
+
+__attribute__((noinline))
+std::pair
+copy_pair3(std::pair &) {
+  return std::move(pair);
+}
+
+__attribute__((noinline))
+std::pair
+return_ptr_and_i32(const char *p, uint32_t res) {
+  for (uint32_t i = 2; i < 5; i++) {
+uint32_t byte = static_cast(p[i]);
+res += (byte - 1) << (7 * i);
+if (byte < 128) {
+  return {p + i + 1, res};
+}
+  }
+  return {nullptr, 0};
+}
+
+__attribute__((noinline))
+std::pair
+return_ptr_and_i64(const char *p, uint32_t res32) {
+  uint64_t res = res32;
+  for (uint32_t i = 2; i < 10; i++) {
+uint64_t byte = static_cast(p[i]);
+res += (byte - 1) << (7 * i);
+if (byte < 128) {
+  return {p + i + 1, res};
+}
+  }
+  return {nullptr, 0};
+}
+
+void test_simple_constructors() {
+  int i = 1;
+  int *ptr = NULL;
+  dfsan_set_label(8, , sizeof(i));
+  dfsan_set_label(2, , sizeof(ptr));
+
+  std::pair pair1 = make_pair(ptr, i);
+  int i1 = pair1.second;
+  int *ptr1 = pair1.first;
+
+  assert(dfsan_read_label(, sizeof(i1)) == 10);
+  assert(dfsan_read_label(, sizeof(ptr1)) == 10);
+
+  std::pair pair2 = copy_pair1(pair1);
+  int i2 = pair2.second;
+  int *ptr2 = pair2.first;
+
+  assert(dfsan_read_label(, sizeof(i2)) == 10);
+  assert(dfsan_read_label(, sizeof(ptr2)) == 10);
+
+  std::pair pair3 = copy_pair2();
+  int i3 = pair3.second;
+  int *ptr3 = pair3.first;
+
+  assert(dfsan_read_label(, sizeof(i3)) == 10);
+  assert(dfsan_read_label(, sizeof(ptr3)) == 10);
+
+  std::pair pair4 = copy_pair3(std::move(pair1));
+  int i4 = pair4.second;
+  int *ptr4 = pair4.first;
+
+  assert(dfsan_read_label(, sizeof(i4)) == 10);
+  assert(dfsan_read_label(, sizeof(ptr4)) == 10);
+}
+
+void test_branches() {
+  uint32_t res = 4;
+  dfsan_set_label(8, , sizeof(res));
+
+  char p[100];
+  const char *q = p;
+  dfsan_set_label(2, , sizeof(q));
+
+  {
+std::fill_n(p, 100, static_cast(128));
+
+{
+  std::pair r = return_ptr_and_i32(q, res);
+  assert(dfsan_read_label(, sizeof(r.first)) == 0);
+  assert(dfsan_read_label(, sizeof(r.second)) == 0);
+}
+
+{
+  std::pair r = return_ptr_and_i64(q, res);
+  assert(dfsan_read_label(, sizeof(r.first)) == 0);
+  assert(dfsan_read_label(, sizeof(r.second)) == 0);
+}
+  }
+
+  {
+std::fill_n(p, 100, 0);
+
+{
+  std::pair r = return_ptr_and_i32(q, res);
+  assert(dfsan_read_label(, sizeof(r.first)) == 10);
+  assert(dfsan_read_label(, sizeof(r.second)) == 10);
+}
+
+{
+  std::pair r = return_ptr_and_i64(q, res);
+  assert(dfsan_read_label(, sizeof(r.first)) == 10);
+  assert(dfsan_read_label(, sizeof(r.second)) == 10);
+}
+  }
+}
+
+int main(void) {
+  test_simple_constructors();
+  test_branches();
+
+  return 0;
+}

diff  --git a/compiler-rt/test/dfsan/struct.c b/compiler-rt/test/dfsan/struct.c
new file mode 100644
index ..6441ad4de163
--- /dev/null
+++ b/compiler-rt/test/dfsan/struct.c
@@ -0,0 +1,77 @@
+// RUN: %clang_dfsan %s -o %t && %run %t
+
+#include 
+#include 
+
+typedef struct Pair {
+  int i;
+  char *ptr;
+} Pair;
+
+__attribute__((noinline))
+Pair make_pair(int i, char *ptr) {
+  Pair pair;
+  pair.i = i;
+  pair.ptr = ptr;
+  return pair;
+}
+
+__attribute__((noinline))
+Pair copy_pair1(const Pair *pair0) {
+  Pair pair;
+  pair.i = pair0->i;
+  pair.ptr = pair0->ptr;
+  return pair;
+}
+
+__attribute__((noinline))
+Pair copy_pair2(const Pair pair0) {
+  Pair pair;
+  pair.i = pair0.i;
+  pair.ptr = pair0.ptr;
+  return pair;
+}
+
+int main(void) {
+  int i = 1;
+  char *ptr = NULL;
+  dfsan_label i_label = dfsan_create_label("i", 0);
+  dfsan_set_label(i_label, , sizeof(i));
+  dfsan_label ptr_label = 

[llvm-branch-commits] [llvm] ee571f8 - [ThinLTO][test] Fix X86/nossp.ll after D91816

2020-12-02 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-02T13:13:58-08:00
New Revision: ee571f87bf41ed0f0232c3daf40909bc3135d620

URL: 
https://github.com/llvm/llvm-project/commit/ee571f87bf41ed0f0232c3daf40909bc3135d620
DIFF: 
https://github.com/llvm/llvm-project/commit/ee571f87bf41ed0f0232c3daf40909bc3135d620.diff

LOG: [ThinLTO][test] Fix X86/nossp.ll after D91816

Added: 


Modified: 
llvm/test/ThinLTO/X86/nossp.ll

Removed: 




diff  --git a/llvm/test/ThinLTO/X86/nossp.ll b/llvm/test/ThinLTO/X86/nossp.ll
index 128796c384dd..c542a85c6f74 100644
--- a/llvm/test/ThinLTO/X86/nossp.ll
+++ b/llvm/test/ThinLTO/X86/nossp.ll
@@ -1,17 +1,17 @@
 ; RUN: split-file %s %t
-; RUN: opt -module-summary %t/a.ll -o %a.bc
-; RUN: opt -module-summary %t/b.ll -o %b.bc
-; RUN: llvm-lto2 run %a.bc %b.bc -o %c.bc -save-temps \
-; RUN:   -r=%a.bc,nossp_caller,px \
-; RUN:   -r=%a.bc,ssp_caller,px \
-; RUN:   -r=%a.bc,nossp_caller2,px \
-; RUN:   -r=%a.bc,ssp_caller2,px \
-; RUN:   -r=%a.bc,nossp_callee,x \
-; RUN:   -r=%a.bc,ssp_callee,x \
-; RUN:   -r=%b.bc,nossp_callee,px \
-; RUN:   -r=%b.bc,ssp_callee,px \
-; RUN:   -r=%b.bc,foo
-; RUN: llvm-dis %c.bc.1.4.opt.bc -o - | FileCheck %s
+; RUN: opt -module-summary %t/a.ll -o %ta.bc
+; RUN: opt -module-summary %t/b.ll -o %tb.bc
+; RUN: llvm-lto2 run %ta.bc %tb.bc -o %tc.bc -save-temps \
+; RUN:   -r=%ta.bc,nossp_caller,px \
+; RUN:   -r=%ta.bc,ssp_caller,px \
+; RUN:   -r=%ta.bc,nossp_caller2,px \
+; RUN:   -r=%ta.bc,ssp_caller2,px \
+; RUN:   -r=%ta.bc,nossp_callee,x \
+; RUN:   -r=%ta.bc,ssp_callee,x \
+; RUN:   -r=%tb.bc,nossp_callee,px \
+; RUN:   -r=%tb.bc,ssp_callee,px \
+; RUN:   -r=%tb.bc,foo
+; RUN: llvm-dis %tc.bc.1.4.opt.bc -o - | FileCheck %s
 
 ;--- a.ll
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] b276bf5 - [MLIR][NFC] Fix mix up between dialect attribute values and names

2020-12-02 Thread Uday Bondhugula via llvm-branch-commits

Author: Uday Bondhugula
Date: 2020-12-03T02:34:15+05:30
New Revision: b276bf5a572b64a02bd4b067125d4f2c9cf6fb6b

URL: 
https://github.com/llvm/llvm-project/commit/b276bf5a572b64a02bd4b067125d4f2c9cf6fb6b
DIFF: 
https://github.com/llvm/llvm-project/commit/b276bf5a572b64a02bd4b067125d4f2c9cf6fb6b.diff

LOG: [MLIR][NFC] Fix mix up between dialect attribute values and names

Clear up documentation on dialect attribute values. Fix/improve
ModuleOp verifier error message on dialect prefixed attribute names.
Additional discussion is here:
https://llvm.discourse.group/t/moduleop-attributes/2325

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

Added: 


Modified: 
mlir/docs/LangRef.md
mlir/lib/IR/BuiltinDialect.cpp
mlir/test/IR/invalid-module-op.mlir

Removed: 




diff  --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md
index 82272d1b729f..fd78d51afd6d 100644
--- a/mlir/docs/LangRef.md
+++ b/mlir/docs/LangRef.md
@@ -1369,39 +1369,39 @@ Example:
 
 Similarly to operations, dialects may define custom attribute values. The
 syntactic structure of these values is identical to custom dialect type values,
-except that dialect attributes values are distinguished with a leading '#',
-while dialect types are distinguished with a leading '!'.
+except that dialect attribute values are distinguished with a leading '#', 
while
+dialect types are distinguished with a leading '!'.
 
 ```
-dialect-attribute ::= '#' opaque-dialect-item
-dialect-attribute ::= '#' pretty-dialect-item
+dialect-attribute-value ::= '#' opaque-dialect-item
+dialect-attribute-value ::= '#' pretty-dialect-item
 ```
 
-Dialect attributes can be specified in a verbose form, e.g. like this:
+Dialect attribute values can be specified in a verbose form, e.g. like this:
 
 ```mlir
-// Complex attribute
+// Complex attribute value.
 #foo<"something">
 
-// Even more complex attribute
+// Even more complex attribute value.
 #foo<"something>>">
 ```
 
-Dialect attributes that are simple enough can use the pretty format, which is a
-lighter weight syntax that is equivalent to the above forms:
+Dialect attribute values that are simple enough can use the pretty format, 
which
+is a lighter weight syntax that is equivalent to the above forms:
 
 ```mlir
 // Complex attribute
 #foo.something
 ```
 
-Sufficiently complex dialect attributes are required to use the verbose form 
for
-generality. For example, the more complex type shown above wouldn't be valid in
-the lighter syntax: `#foo.something>>` because it contains 
characters
-that are not allowed in the lighter syntax, as well as unbalanced `<>`
-characters.
+Sufficiently complex dialect attribute values are required to use the verbose
+form for generality. For example, the more complex type shown above would not 
be
+valid in the lighter syntax: `#foo.something>>` because it contains
+characters that are not allowed in the lighter syntax, as well as unbalanced
+`<>` characters.
 
-See [here](Tutorials/DefiningAttributesAndTypes.md) to learn how to define 
dialect
+See [here](Tutorials/DefiningAttributesAndTypes.md) on how to define dialect
 attribute values.
 
 ### Standard Attribute Values

diff  --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp
index 5c0a0380f9af..8f872ac7c9ab 100644
--- a/mlir/lib/IR/BuiltinDialect.cpp
+++ b/mlir/lib/IR/BuiltinDialect.cpp
@@ -228,9 +228,9 @@ static LogicalResult verify(ModuleOp op) {
 ArrayRef{mlir::SymbolTable::getSymbolAttrName(),
 mlir::SymbolTable::getVisibilityAttrName()},
 attr.first.strref()))
-  return op.emitOpError()
- << "can only contain dialect-specific attributes, found: '"
- << attr.first << "'";
+  return op.emitOpError() << "can only contain attributes with "
+ "dialect-prefixed names, found: '"
+  << attr.first << "'";
   }
 
   return success();

diff  --git a/mlir/test/IR/invalid-module-op.mlir 
b/mlir/test/IR/invalid-module-op.mlir
index 73fe188209d1..520821a7b0b4 100644
--- a/mlir/test/IR/invalid-module-op.mlir
+++ b/mlir/test/IR/invalid-module-op.mlir
@@ -44,7 +44,7 @@ func @module_op() {
 
 // -
 
-// expected-error@+1 {{can only contain dialect-specific attributes}}
+// expected-error@+1 {{can only contain attributes with dialect-prefixed 
names}}
 module attributes {attr} {
 }
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 2ac5880 - Update MS ABI mangling for union constants based on new information from

2020-12-02 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-02T12:17:52-08:00
New Revision: 2ac58801873ab99dd5de48ad7557b76f1803100b

URL: 
https://github.com/llvm/llvm-project/commit/2ac58801873ab99dd5de48ad7557b76f1803100b
DIFF: 
https://github.com/llvm/llvm-project/commit/2ac58801873ab99dd5de48ad7557b76f1803100b.diff

LOG: Update MS ABI mangling for union constants based on new information from
Jon Caves.

Added: 


Modified: 
clang/lib/AST/MicrosoftMangle.cpp
clang/test/CodeGenCXX/mangle-class-nttp.cpp

Removed: 




diff  --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index b093b2514c19..1fba1392d0ed 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -1681,14 +1681,13 @@ void 
MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
   }
 
   case APValue::Union:
-Out << '2';
+Out << '7';
 mangleType(T, SourceRange(), QMM_Escape);
-// FIXME: MSVC doesn't mangle the active member, only the type, leading to
-// collisions if more than one member has the same type.
-// FIXME: MSVC doesn't yet support unions with no active member, but
-// there's an obvious mangling for that, so we use it.
-if (const FieldDecl *FD = V.getUnionField())
-  mangleTemplateArgValue(FD->getType(), V.getUnionValue());
+if (const FieldDecl *FD = V.getUnionField()) {
+  mangleUnqualifiedName(FD);
+  mangleTemplateArgValue(FD->getType(), V.getUnionValue(),
+ /*WithType*/false);
+}
 Out << '@';
 return;
 

diff  --git a/clang/test/CodeGenCXX/mangle-class-nttp.cpp 
b/clang/test/CodeGenCXX/mangle-class-nttp.cpp
index 9bb83fcf3246..579afd0a01be 100644
--- a/clang/test/CodeGenCXX/mangle-class-nttp.cpp
+++ b/clang/test/CodeGenCXX/mangle-class-nttp.cpp
@@ -120,16 +120,16 @@ template void f() {}
 // CHECK: define weak_odr void @_Z1fIXL1vv(
 // FIXME: MSVC rejects this; check this is the mangling MSVC uses when they
 // start accepting.
-// MSABI: define {{.*}} @"??$f@$2TE@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1vv(
-// MSABI: define {{.*}} @"??$f@$2TE@@H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@@n@0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1Edi1nLi42vv(
-// MSABI: define {{.*}} @"??$f@$2TE@@H0CKYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@@n@0CKYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1Edi1fLfvv(
-// MSABI: define {{.*}} @"??$f@$2TE@@MAAYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@@0AAYAXXZ"
 template void f();
 
 // immintrin.h vector types.
@@ -210,24 +210,22 @@ template void f() {}
 template void f() {}
 template void f() {}
 // CHECK: define weak_odr void @_Z1fIXL2H1EEEvv
-// MSABI: define {{.*}} @"??$f@$2TH1@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH1@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXL2H2EEEvv
-// MSABI: define {{.*}} @"??$f@$2TH2@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH2@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl2H3EEEvv
-// MSABI: define {{.*}} @"??$f@$2TH3@@H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH3@@a@0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl2H3di1aLi1vv
-// MSABI: define {{.*}} @"??$f@$2TH3@@H00@@@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH3@@a@00@@@YAXXZ"
 template void f();
-// FIXME: Leads to mangling collision under MS ABI; same mangling as the {.a = 
0} case.
-#ifndef _WIN32
 // CHECK: define weak_odr void @_Z1fIXtl2H3di1bLi0vv
+// MSABI: define {{.*}} @"??$f@$7TH3@@b@0AYAXXZ"
 template void f();
-#endif
 // CHECK: define weak_odr void @_Z1fIXtl2H4EEEvv
-// MSABI: define {{.*}} @"??$f@$2UH4@@2TH2@@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UH4@@7TH2@@YAXXZ"
 template void f();
 
 // Floating-point.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] a4ac434 - [AArch64] Compiler-rt interface for out-of-line atomics.

2020-12-02 Thread Pavel Iliin via llvm-branch-commits

Author: Pavel Iliin
Date: 2020-12-02T20:07:12Z
New Revision: a4ac434c47434d80bca54bab96f295ed4e972cc6

URL: 
https://github.com/llvm/llvm-project/commit/a4ac434c47434d80bca54bab96f295ed4e972cc6
DIFF: 
https://github.com/llvm/llvm-project/commit/a4ac434c47434d80bca54bab96f295ed4e972cc6.diff

LOG: [AArch64] Compiler-rt interface for out-of-line atomics.

Out-of-line helper functions to support LSE deployment added.
This is a port of libgcc implementation:
https://gcc.gnu.org/git/?p=gcc.git;h=33befddcb849235353dc263db1c7d07dc15c9faa

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

Added: 
compiler-rt/lib/builtins/aarch64/lse.S

Modified: 
compiler-rt/cmake/builtin-config-ix.cmake
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/assembly.h
compiler-rt/lib/builtins/cpu_model.c

Removed: 




diff  --git a/compiler-rt/cmake/builtin-config-ix.cmake 
b/compiler-rt/cmake/builtin-config-ix.cmake
index 16d82b127878..2eeedd49e392 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -23,6 +23,12 @@ int foo(int x, int y) {
 ")
 
 
+builtin_check_c_compiler_source(COMPILER_RT_HAS_ASM_LSE
+"
+asm(\".arch armv8-a+lse\");
+asm(\"cas w0, w1, [x2]\");
+")
+
 set(ARM64 aarch64)
 set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k)
 set(HEXAGON hexagon)

diff  --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index 3c29bba612e1..7f3df6ff548d 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -502,9 +502,39 @@ endif()
 set(aarch64_SOURCES
   ${GENERIC_TF_SOURCES}
   ${GENERIC_SOURCES}
+  cpu_model.c
   aarch64/fp_mode.c
 )
 
+# Generate outline atomics helpers from lse.S base
+set(CUSTOM_FLAGS ${CMAKE_C_FLAGS})
+if(NOT ANDROID)
+  append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG -DVISIBILITY_HIDDEN 
CUSTOM_FLAGS)
+endif()
+append_list_if(COMPILER_RT_HAS_ASM_LSE -DHAS_ASM_LSE CUSTOM_FLAGS)
+string(REPLACE " " "\t" CUSTOM_FLAGS "${CUSTOM_FLAGS}")
+
+foreach(pat cas swp ldadd ldclr ldeor ldset)
+  foreach(size 1 2 4 8 16)
+foreach(model 1 2 3 4)
+  if(pat STREQUAL "cas" OR NOT size STREQUAL "16")
+set(helper_asm outline_atomic_${pat}${size}_${model}.S)
+add_custom_command(
+  OUTPUT ${helper_asm}
+  COMMAND ${CMAKE_C_COMPILER} -E ${CUSTOM_FLAGS} -DL_${pat} 
-DSIZE=${size} -DMODEL=${model}
+  ${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S -o ${helper_asm}
+  DEPENDS aarch64/lse.S assembly.h
+)
+set_source_files_properties(${helper_asm} PROPERTIES GENERATED TRUE)
+set(aarch64_SOURCES
+  ${aarch64_SOURCES}
+  ${helper_asm}
+)
+  endif()
+endforeach(model)
+  endforeach(size)
+endforeach(pat)
+
 if (MINGW)
   set(aarch64_SOURCES
 ${aarch64_SOURCES}

diff  --git a/compiler-rt/lib/builtins/aarch64/lse.S 
b/compiler-rt/lib/builtins/aarch64/lse.S
new file mode 100644
index ..4c75fa524c44
--- /dev/null
+++ b/compiler-rt/lib/builtins/aarch64/lse.S
@@ -0,0 +1,227 @@
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#include "../assembly.h"
+
+// Out-of-line LSE atomics helpers. Ported from libgcc library.
+// N = {1, 2, 4, 8}
+// M = {1, 2, 4, 8, 16}
+// ORDER = {'relax', 'acq', 'rel', 'acq_rel'}
+// Routines implemented:
+//
+//  iM __aarch64_casM_ORDER(iM expected, iM desired, iM *ptr)
+//  iN __aarch64_swpN_ORDER(iN val, iN *ptr)
+//  iN __aarch64_ldaddN_ORDER(iN val, iN *ptr)
+//  iN __aarch64_ldclrN_ORDER(iN val, iN *ptr)
+//  iN __aarch64_ldeorN_ORDER(iN val, iN *ptr)
+//  iN __aarch64_ldsetN_ORDER(iN val, iN *ptr)
+//
+// Routines may modify temporary registers tmp0, tmp1, tmp2,
+// return value x0 and the flags only.
+
+#ifdef __aarch64__
+
+#ifdef HAS_ASM_LSE
+.arch armv8-a+lse
+#else
+.arch armv8-a
+#endif
+
+HIDDEN(__aarch64_have_lse_atomics)
+
+// Generate mnemonics for
+// L_cas: SIZE: 1,2,4,8,16 MODEL: 1,2,3,4
+// L_swp L_ldadd L_ldclr L_ldeor L_ldset: SIZE: 1,2,4,8MODEL: 1,2,3,4
+
+#if SIZE == 1
+#define S b
+#define UXT uxtb
+#define B 0x
+#elif SIZE == 2
+#define S h
+#define UXT uxth
+#define B 0x4000
+#elif SIZE == 4 || SIZE == 8 || SIZE == 16
+#define S
+#define UXT mov
+#if SIZE == 4
+#define B 0x8000
+#elif SIZE == 8
+#define B 0xc000
+#endif
+#else
+#error
+#endif // SIZE
+
+#if MODEL == 1
+#define SUFF _relax
+#define A
+#define L
+#define M 0x00
+#define N 0x00
+#elif MODEL == 2
+#define SUFF _acq
+#define A a
+#define L
+#define M 0x40
+#define N 0x80
+#elif MODEL == 3
+#define SUFF _rel
+#define A
+#define L l
+#define M 0x008000
+#define N 0x40
+#elif MODEL == 4
+#define 

[llvm-branch-commits] [llvm] 2c63e76 - [XCOFF][AIX] Alternative path in EHStreamer for platforms do not have uleb128 support

2020-12-02 Thread via llvm-branch-commits

Author: jasonliu
Date: 2020-12-02T20:03:15Z
New Revision: 2c63e7604c87d97723919ca00d80ea38cddca8f9

URL: 
https://github.com/llvm/llvm-project/commit/2c63e7604c87d97723919ca00d80ea38cddca8f9
DIFF: 
https://github.com/llvm/llvm-project/commit/2c63e7604c87d97723919ca00d80ea38cddca8f9.diff

LOG: [XCOFF][AIX] Alternative path in EHStreamer for platforms do not have 
uleb128 support

Summary:
Not all system assembler supports `.uleb128 label2 - label1` form.
When the target do not support this form, we have to take
alternative manual calculation to get the offsets from them.

Reviewed By: hubert.reinterpretcast

Diffierential Revision: https://reviews.llvm.org/D92058

Added: 
llvm/test/CodeGen/X86/gnu-eh-alternative.ll

Modified: 
llvm/include/llvm/MC/MCAsmInfo.h
llvm/include/llvm/Target/TargetLoweringObjectFile.h
llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
llvm/lib/MC/MCAsmInfo.cpp
llvm/lib/MC/MCAsmInfoXCOFF.cpp
llvm/lib/Target/TargetLoweringObjectFile.cpp
llvm/test/CodeGen/PowerPC/aix-exception.ll

Removed: 




diff  --git a/llvm/include/llvm/MC/MCAsmInfo.h 
b/llvm/include/llvm/MC/MCAsmInfo.h
index 2b889d0ed5fa..c55dab4e7973 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -186,6 +186,9 @@ class MCAsmInfo {
   /// alignment is supported.
   bool UseDotAlignForAlignment = false;
 
+  /// True if the target supports LEB128 directives.
+  bool HasLEB128Directives = true;
+
   //===--- Data Emission Directives -===//
 
   /// This should be set to the directive used to get some number of zero (and
@@ -575,6 +578,8 @@ class MCAsmInfo {
 return UseDotAlignForAlignment;
   }
 
+  bool hasLEB128Directives() const { return HasLEB128Directives; }
+
   const char *getZeroDirective() const { return ZeroDirective; }
   bool doesZeroDirectiveSupportNonZeroValue() const {
 return ZeroDirectiveSupportsNonZeroValue;

diff  --git a/llvm/include/llvm/Target/TargetLoweringObjectFile.h 
b/llvm/include/llvm/Target/TargetLoweringObjectFile.h
index edae4bb509ee..90041f077523 100644
--- a/llvm/include/llvm/Target/TargetLoweringObjectFile.h
+++ b/llvm/include/llvm/Target/TargetLoweringObjectFile.h
@@ -157,7 +157,7 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
   unsigned getLSDAEncoding() const { return LSDAEncoding; }
   unsigned getTTypeEncoding() const { return TTypeEncoding; }
-  unsigned getCallSiteEncoding() const { return CallSiteEncoding; }
+  unsigned getCallSiteEncoding() const;
 
   const MCExpr *getTTypeReference(const MCSymbolRefExpr *Sym, unsigned 
Encoding,
   MCStreamer ) const;

diff  --git a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp 
b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
index b6fc83285a20..2ffe8a7b0469 100644
--- a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
@@ -413,6 +413,7 @@ MCSymbol *EHStreamer::emitExceptionTable() {
 
   bool IsSJLJ = Asm->MAI->getExceptionHandlingType() == 
ExceptionHandling::SjLj;
   bool IsWasm = Asm->MAI->getExceptionHandlingType() == 
ExceptionHandling::Wasm;
+  bool HasLEB128Directives = Asm->MAI->hasLEB128Directives();
   unsigned CallSiteEncoding =
   IsSJLJ ? static_cast(dwarf::DW_EH_PE_udata4) :
Asm->getObjFileLowering().getCallSiteEncoding();
@@ -505,6 +506,79 @@ MCSymbol *EHStreamer::emitExceptionTable() {
 Asm->OutStreamer->emitLabel(CstBeginLabel);
   };
 
+  // An alternative path to EmitTypeTableRefAndCallSiteTableEndRef.
+  // For some platforms, the system assembler does not accept the form of
+  // `.uleb128 label2 - label1`. In those situations, we would need to 
calculate
+  // the size between label1 and label2 manually.
+  // In this case, we would need to calculate the LSDA size and the call
+  // site table size.
+  auto EmitTypeTableOffsetAndCallSiteTableOffset = [&]() {
+assert(CallSiteEncoding == dwarf::DW_EH_PE_udata4 && !HasLEB128Directives 
&&
+   "Targets supporting .uleb128 do not need to take this path.");
+if (CallSiteRanges.size() > 1)
+  report_fatal_error(
+  "-fbasic-block-sections is not yet supported on "
+  "platforms that do not have general LEB128 directive support.");
+
+uint64_t CallSiteTableSize = 0;
+const CallSiteRange  = CallSiteRanges.back();
+for (size_t CallSiteIdx = CSRange.CallSiteBeginIdx;
+ CallSiteIdx < CSRange.CallSiteEndIdx; ++CallSiteIdx) {
+  const CallSiteEntry  = CallSites[CallSiteIdx];
+  // Each call site entry consists of 3 udata4 fields (12 bytes) and
+  // 1 ULEB128 field.
+  CallSiteTableSize += 12 + getULEB128Size(S.Action);
+  assert(isUInt<32>(CallSiteTableSize) && "CallSiteTableSize overflows.");
+}
+
+Asm->emitEncodingByte(TTypeEncoding, 

[llvm-branch-commits] [clang] 70764c0 - [CMake][Fuchsia] Install llvm-elfabi

2020-12-02 Thread Roland McGrath via llvm-branch-commits

Author: Roland McGrath
Date: 2020-12-02T11:59:14-08:00
New Revision: 70764c02e474504e2ebfb5b230a3b2ccdbedc5c2

URL: 
https://github.com/llvm/llvm-project/commit/70764c02e474504e2ebfb5b230a3b2ccdbedc5c2
DIFF: 
https://github.com/llvm/llvm-project/commit/70764c02e474504e2ebfb5b230a3b2ccdbedc5c2.diff

LOG: [CMake][Fuchsia] Install llvm-elfabi

The canonical Fuchsia toolchain configuration installs llvm-elfabi.

Reviewed By: haowei

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 74c393fa7a8b..16bc96be1138 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -245,6 +245,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-dlltool
   llvm-dwarfdump
   llvm-dwp
+  llvm-elfabi
   llvm-gsymutil
   llvm-lib
   llvm-mt



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] 827e075 - [lsan] Use final on Fuchsia ThreadContext declaration

2020-12-02 Thread Roland McGrath via llvm-branch-commits

Author: Roland McGrath
Date: 2020-12-02T11:58:03-08:00
New Revision: 827e075676f604106631c68901a0747ce8cb05cf

URL: 
https://github.com/llvm/llvm-project/commit/827e075676f604106631c68901a0747ce8cb05cf
DIFF: 
https://github.com/llvm/llvm-project/commit/827e075676f604106631c68901a0747ce8cb05cf.diff

LOG: [lsan] Use final on Fuchsia ThreadContext declaration

This is consistent with other platforms' versions and
eliminates a compiler warning.

Reviewed By: leonardchan

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

Added: 


Modified: 
compiler-rt/lib/lsan/lsan_fuchsia.h

Removed: 




diff  --git a/compiler-rt/lib/lsan/lsan_fuchsia.h 
b/compiler-rt/lib/lsan/lsan_fuchsia.h
index 65d20ea21148..e730d8f25f21 100644
--- a/compiler-rt/lib/lsan/lsan_fuchsia.h
+++ b/compiler-rt/lib/lsan/lsan_fuchsia.h
@@ -23,7 +23,7 @@
 
 namespace __lsan {
 
-class ThreadContext : public ThreadContextLsanBase {
+class ThreadContext final : public ThreadContextLsanBase {
  public:
   explicit ThreadContext(int tid);
   void OnCreated(void *arg) override;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] 19c3894 - [libc] Fix couple of corner cases in remquo.

2020-12-02 Thread Siva Chandra Reddy via llvm-branch-commits

Author: Siva Chandra Reddy
Date: 2020-12-02T11:48:49-08:00
New Revision: 19c3894f9436ef68f33f80ee1fd589166267b5a1

URL: 
https://github.com/llvm/llvm-project/commit/19c3894f9436ef68f33f80ee1fd589166267b5a1
DIFF: 
https://github.com/llvm/llvm-project/commit/19c3894f9436ef68f33f80ee1fd589166267b5a1.diff

LOG: [libc] Fix couple of corner cases in remquo.

These two cases are fixed:
1. If numerator is not zero and denominator is infinity, then the
numerator is returned as the remainder.
2. If numerator and denominator are equal in magnitude, then quotient
with the right sign is returned.

The differet tests of remquo, remquof and remquol have been unified
into a single file to avoid duplication.

Reviewed By: lntue

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

Added: 
libc/test/src/math/RemQuoTest.h

Modified: 
libc/test/src/math/CMakeLists.txt
libc/test/src/math/remquo_test.cpp
libc/test/src/math/remquof_test.cpp
libc/test/src/math/remquol_test.cpp
libc/utils/FPUtil/DivisionAndRemainderOperations.h

Removed: 




diff  --git a/libc/test/src/math/CMakeLists.txt 
b/libc/test/src/math/CMakeLists.txt
index 2220cef00791..cdffe737d8df 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -686,6 +686,8 @@ add_fp_unittest(
 libc_math_unittests
   SRCS
 remquof_test.cpp
+  HDRS
+RemQuoTest.h
   DEPENDS
 libc.include.math
 libc.src.math.remquof
@@ -699,6 +701,8 @@ add_fp_unittest(
 libc_math_unittests
   SRCS
 remquo_test.cpp
+  HDRS
+RemQuoTest.h
   DEPENDS
 libc.include.math
 libc.src.math.remquo
@@ -712,6 +716,8 @@ add_fp_unittest(
 libc_math_unittests
   SRCS
 remquol_test.cpp
+  HDRS
+RemQuoTest.h
   DEPENDS
 libc.include.math
 libc.src.math.remquol

diff  --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h
new file mode 100644
index ..29fcdb83b6a2
--- /dev/null
+++ b/libc/test/src/math/RemQuoTest.h
@@ -0,0 +1,144 @@
+//===-- Utility class to test 
diff erent flavors of remquo ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
+#define LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
+
+#include "utils/FPUtil/BasicOperations.h"
+#include "utils/FPUtil/FPBits.h"
+#include "utils/FPUtil/TestHelpers.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+#include "utils/UnitTest/Test.h"
+#include 
+
+namespace mpfr = __llvm_libc::testing::mpfr;
+
+template 
+class RemQuoTestTemplate : public __llvm_libc::testing::Test {
+  using FPBits = __llvm_libc::fputil::FPBits;
+  using UIntType = typename FPBits::UIntType;
+
+  const T zero = __llvm_libc::fputil::FPBits::zero();
+  const T negZero = __llvm_libc::fputil::FPBits::negZero();
+  const T inf = __llvm_libc::fputil::FPBits::inf();
+  const T negInf = __llvm_libc::fputil::FPBits::negInf();
+  const T nan = __llvm_libc::fputil::FPBits::buildNaN(1);
+
+public:
+  typedef T (*RemQuoFunc)(T, T, int *);
+
+  void testSpecialNumbers(RemQuoFunc func) {
+int quotient;
+T x, y;
+
+y = T(1.0);
+x = inf;
+EXPECT_NE(isnan(func(x, y, )), 0);
+x = negInf;
+EXPECT_NE(isnan(func(x, y, )), 0);
+
+x = T(1.0);
+y = zero;
+EXPECT_NE(isnan(func(x, y, )), 0);
+y = negZero;
+EXPECT_NE(isnan(func(x, y, )), 0);
+
+y = nan;
+x = T(1.0);
+EXPECT_NE(isnan(func(x, y, )), 0);
+
+y = T(1.0);
+x = nan;
+EXPECT_NE(isnan(func(x, y, )), 0);
+
+x = nan;
+y = nan;
+EXPECT_NE(isnan(func(x, y, )), 0);
+
+x = zero;
+y = T(1.0);
+EXPECT_FP_EQ(func(x, y, ), zero);
+
+x = negZero;
+y = T(1.0);
+EXPECT_FP_EQ(func(x, y, ), negZero);
+
+x = T(1.125);
+y = inf;
+EXPECT_FP_EQ(func(x, y, ), x);
+EXPECT_EQ(quotient, 0);
+  }
+
+  void testEqualNumeratorAndDenominator(RemQuoFunc func) {
+T x = T(1.125), y = T(1.125);
+int q;
+
+// When the remainder is zero, the standard requires it to
+// have the same sign as x.
+
+EXPECT_FP_EQ(func(x, y, ), zero);
+EXPECT_EQ(q, 1);
+
+EXPECT_FP_EQ(func(x, -y, ), zero);
+EXPECT_EQ(q, -1);
+
+EXPECT_FP_EQ(func(-x, y, ), negZero);
+EXPECT_EQ(q, -1);
+
+EXPECT_FP_EQ(func(-x, -y, ), negZero);
+EXPECT_EQ(q, 1);
+  }
+
+  void testSubnormalRange(RemQuoFunc func) {
+constexpr UIntType count = 101;
+constexpr UIntType step =
+(FPBits::maxSubnormal - FPBits::minSubnormal) / count;
+for (UIntType v = FPBits::minSubnormal, w = FPBits::maxSubnormal;
+ v <= FPBits::maxSubnormal && w >= FPBits::minSubnormal;
+ v += step, w -= step) {
+  T x = 

[llvm-branch-commits] [llvm] bc044a8 - [Inline] prevent inlining on stack protector mismatch

2020-12-02 Thread Nick Desaulniers via llvm-branch-commits

Author: Nick Desaulniers
Date: 2020-12-02T11:00:16-08:00
New Revision: bc044a88ee3c16e4164740732a7adc91a29b24f5

URL: 
https://github.com/llvm/llvm-project/commit/bc044a88ee3c16e4164740732a7adc91a29b24f5
DIFF: 
https://github.com/llvm/llvm-project/commit/bc044a88ee3c16e4164740732a7adc91a29b24f5.diff

LOG: [Inline] prevent inlining on stack protector mismatch

It's common for code that manipulates the stack via inline assembly or
that has to set up its own stack canary (such as the Linux kernel) would
like to avoid stack protectors in certain functions. In this case, we've
been bitten by numerous bugs where a callee with a stack protector is
inlined into an attribute((no_stack_protector)) caller, which
generally breaks the caller's assumptions about not having a stack
protector. LTO exacerbates the issue.

While developers can avoid this by putting all no_stack_protector
functions in one translation unit together and compiling those with
-fno-stack-protector, it's generally not very ergonomic or as
ergonomic as a function attribute, and still doesn't work for LTO. See also:
https://lore.kernel.org/linux-pm/20200915172658.1432732-1-r...@google.com/
https://lore.kernel.org/lkml/20200918201436.2932360-30-samitolva...@google.com/T/#u

SSP attributes can be ordered by strength. Weakest to strongest, they
are: ssp, sspstrong, sspreq.  Callees with differing SSP attributes may be
inlined into each other, and the strongest attribute will be applied to the
caller. (No change)

After this change:
* A callee with no SSP attributes will no longer be inlined into a
  caller with SSP attributes.
* The reverse is also true: a callee with an SSP attribute will not be
  inlined into a caller with no SSP attributes.
* The alwaysinline attribute overrides these rules.

Functions that get synthesized by the compiler may not get inlined as a
result if they are not created with the same stack protector function
attribute as their callers.

Alternative approach to https://reviews.llvm.org/D87956.

Fixes pr/47479.

Signed-off-by: Nick Desaulniers 

Reviewed By: rnk, MaskRay

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

Added: 
llvm/test/ThinLTO/X86/nossp.ll
llvm/test/Transforms/Inline/inline_nossp.ll

Modified: 
llvm/include/llvm/IR/Function.h
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/CodeGen/StackProtector.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Function.cpp
llvm/test/CodeGen/AArch64/stack-guard-remat-bitcast.ll
llvm/test/CodeGen/X86/stack-protector-2.ll
llvm/test/Transforms/CodeExtractor/PartialInlineAttributes.ll
llvm/test/Transforms/Inline/devirtualize.ll
llvm/test/Transforms/Inline/inline-byval-bonus.ll
llvm/test/Transforms/Inline/inline_ssp.ll

Removed: 




diff  --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index 1736b3ed0363..cf61db1d3347 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -381,6 +381,9 @@ class Function : public GlobalObject, public 
ilist_node {
   void setGC(std::string Str);
   void clearGC();
 
+  /// Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
+  bool hasStackProtectorFnAttr() const;
+
   /// adds the attribute to the list of attributes.
   void addAttribute(unsigned i, Attribute::AttrKind Kind);
 

diff  --git a/llvm/lib/Analysis/InlineCost.cpp 
b/llvm/lib/Analysis/InlineCost.cpp
index cb731f6a3a66..077b05edcd13 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2382,6 +2382,15 @@ Optional 
llvm::getAttributeBasedInliningDecision(
   if (Call.isNoInline())
 return InlineResult::failure("noinline call site attribute");
 
+  // Don't inline functions if one does not have any stack protector attribute
+  // but the other does.
+  if (Caller->hasStackProtectorFnAttr() && !Callee->hasStackProtectorFnAttr())
+return InlineResult::failure(
+"stack protected caller but callee requested no stack protector");
+  if (Callee->hasStackProtectorFnAttr() && !Caller->hasStackProtectorFnAttr())
+return InlineResult::failure(
+"stack protected callee but caller requested no stack protector");
+
   return None;
 }
 
@@ -2441,7 +2450,8 @@ InlineResult llvm::isInlineViable(Function ) {
 continue;
 
   // Disallow recursive calls.
-  if ( == Call->getCalledFunction())
+  Function *Callee = Call->getCalledFunction();
+  if ( == Callee)
 return InlineResult::failure("recursive call");
 
   // Disallow calls which expose returns-twice to a function not previously
@@ -2450,8 +2460,8 @@ InlineResult llvm::isInlineViable(Function ) {
   cast(Call)->canReturnTwice())
 return InlineResult::failure("exposes returns-twice attribute");
 
-  if (Call->getCalledFunction())
-switch (Call->getCalledFunction()->getIntrinsicID()) {
+  if (Callee)
+switch 

[llvm-branch-commits] [llvm] e5085a6 - [gn build] Port a65d8c5d720

2020-12-02 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-02T18:50:30Z
New Revision: e5085a62d1e731a6b81028673cdba8e82246190e

URL: 
https://github.com/llvm/llvm-project/commit/e5085a62d1e731a6b81028673cdba8e82246190e
DIFF: 
https://github.com/llvm/llvm-project/commit/e5085a62d1e731a6b81028673cdba8e82246190e.diff

LOG: [gn build] Port a65d8c5d720

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
index 6815640fbf45..5bd7ec8f5818 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
@@ -15,6 +15,7 @@ static_library("AsmPrinter") {
 "//llvm/lib/Target",
   ]
   sources = [
+"AIXException.cpp",
 "ARMException.cpp",
 "AccelTable.cpp",
 "AddressPool.cpp",



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 644f68e - [libc++] Add slice_array operator= valarray overload.

2020-12-02 Thread via llvm-branch-commits

Author: zoecarver
Date: 2020-12-02T10:49:20-08:00
New Revision: 644f68ed4d741f33d254354c2b7bc9606b77c721

URL: 
https://github.com/llvm/llvm-project/commit/644f68ed4d741f33d254354c2b7bc9606b77c721
DIFF: 
https://github.com/llvm/llvm-project/commit/644f68ed4d741f33d254354c2b7bc9606b77c721.diff

LOG: [libc++] Add slice_array operator= valarray overload.

Add the slice_array::operator=(const std::valarray& val_arr) overload.

Fixes https://llvm.org/PR40792.

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

Added: 

libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/template.pass.cpp

Modified: 
libcxx/include/valarray

libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp

Removed: 




diff  --git a/libcxx/include/valarray b/libcxx/include/valarray
index aaae6fbd5b3f..9654cd5aa998 100644
--- a/libcxx/include/valarray
+++ b/libcxx/include/valarray
@@ -136,6 +136,7 @@ public:
 void operator>>=(const valarray& v) const;
 
 void operator=(const value_type& x) const;
+void operator=(const valarray& val_arr) const;
 
 slice_array() = delete;
 };
@@ -1264,6 +1265,9 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 void operator=(const value_type& __x) const;
 
+_LIBCPP_INLINE_VISIBILITY
+void operator=(const valarray& __va) const;
+
 private:
 _LIBCPP_INLINE_VISIBILITY
 slice_array(const slice& __sl, const valarray& __v)
@@ -1303,6 +1307,15 @@ slice_array<_Tp>::operator=(const _Expr& __v) const
 *__t = __v[__i];
 }
 
+template 
+inline void
+slice_array<_Tp>::operator=(const valarray& __va) const
+{
+value_type* __t = __vp_;
+for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
+*__t = __va[__i];
+}
+
 template 
 template 
 inline

diff  --git 
a/libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/template.pass.cpp
 
b/libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/template.pass.cpp
new file mode 100644
index ..de2ffce12b90
--- /dev/null
+++ 
b/libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/template.pass.cpp
@@ -0,0 +1,33 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// template  class slice_array
+
+// void operator=(const T& value) const;
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main(int, char**)
+{
+double a[] = { 0, 0, 0 };
+std::valarray m(a, sizeof(a)/sizeof(a[0]));
+std::slice_array s = m[std::slice(0, 3, 1)];
+s = 42;
+assert(m[0] == 42);
+assert(m[1] == 42);
+assert(m[2] == 42);
+
+ASSERT_SAME_TYPE(decltype(s = 42), void);
+
+return 0;
+}

diff  --git 
a/libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
 
b/libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
index d1d9fe18bea7..a09ef7971368 100644
--- 
a/libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
+++ 
b/libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
@@ -23,7 +23,8 @@ int main(int, char**)
 int a2[] = {-1, -2, -3, -4, -5};
 std::valarray v1(a1, sizeof(a1)/sizeof(a1[0]));
 std::valarray v2(a2, sizeof(a2)/sizeof(a2[0]));
-v1[std::slice(1, 5, 3)] = v2;
+std::slice_array s1 = v1[std::slice(1, 5, 3)];
+s1 = v2;
 assert(v1.size() == 16);
 assert(v1[ 0] ==  0);
 assert(v1[ 1] == -1);
@@ -42,5 +43,19 @@ int main(int, char**)
 assert(v1[14] == 14);
 assert(v1[15] == 15);
 
-  return 0;
+ASSERT_SAME_TYPE(decltype(s1 = v2), void);
+
+// The initializer list constructor is disabled in C++03 mode.
+#if TEST_STD_VER > 03
+std::valarray m = { 0, 0, 0 };
+std::slice_array s2 = m[std::slice(0, 3, 1)];
+s2 = { 1, 2, 3 };
+assert(m[0] == 1);
+assert(m[1] == 2);
+assert(m[2] == 3);
+
+ASSERT_SAME_TYPE(decltype(s2 = {1, 2, 3}), void);
+#endif // TEST_STD_VER > 03
+
+return 0;
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] f80b630 - [mlir][PDL] Use explicit loop over llvm::find to fix MSVC breakage

2020-12-02 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-02T10:43:16-08:00
New Revision: f80b630460e2a1646fe432f919fa378cabb002c8

URL: 
https://github.com/llvm/llvm-project/commit/f80b630460e2a1646fe432f919fa378cabb002c8
DIFF: 
https://github.com/llvm/llvm-project/commit/f80b630460e2a1646fe432f919fa378cabb002c8.diff

LOG: [mlir][PDL] Use explicit loop over llvm::find to fix MSVC breakage

Added: 


Modified: 
mlir/lib/Rewrite/ByteCode.cpp

Removed: 




diff  --git a/mlir/lib/Rewrite/ByteCode.cpp b/mlir/lib/Rewrite/ByteCode.cpp
index 33a754bb3c07..481e7b6db1d1 100644
--- a/mlir/lib/Rewrite/ByteCode.cpp
+++ b/mlir/lib/Rewrite/ByteCode.cpp
@@ -769,8 +769,10 @@ class ByteCodeExecutor {
 
 // Check to see if the attribute value is within the case list. Jump to
 // the correct successor index based on the result.
-auto it = llvm::find(cases, value);
-selectJump(it == cases.end() ? size_t(0) : ((it - cases.begin()) + 1));
+for (auto it = cases.begin(), e = cases.end(); it != e; ++it)
+  if (*it == value)
+return selectJump(size_t((it - cases.begin()) + 1));
+selectJump(size_t(0));
   }
 
   /// Internal implementation of reading various data types from the bytecode



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] a65d8c5 - [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-02 Thread via llvm-branch-commits

Author: jasonliu
Date: 2020-12-02T18:42:44Z
New Revision: a65d8c5d720db8c646adb0ad9dac54da5d5fa230

URL: 
https://github.com/llvm/llvm-project/commit/a65d8c5d720db8c646adb0ad9dac54da5d5fa230
DIFF: 
https://github.com/llvm/llvm-project/commit/a65d8c5d720db8c646adb0ad9dac54da5d5fa230.diff

LOG: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

Summary:
AIX uses the existing EH infrastructure in clang and llvm.
The major differences would be
1. AIX do not have CFI instructions.
2. AIX uses a new personality routine, named __xlcxx_personality_v1.
   It doesn't use the GCC personality rountine, because the
   interoperability is not there yet on AIX.
3. AIX do not use eh_frame sections. Instead, it would use a eh_info
section (compat unwind section) to store the information about
personality routine and LSDA data address.

Reviewed By: daltenty, hubert.reinterpretcast

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

Added: 
llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
llvm/test/CodeGen/PowerPC/aix-exception.ll

Modified: 
clang/lib/CodeGen/CGCleanup.h
clang/lib/CodeGen/CGException.cpp
clang/test/CodeGenCXX/personality.cpp
llvm/include/llvm/Analysis/EHPersonalities.h
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/lib/Analysis/EHPersonalities.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
llvm/lib/CodeGen/AsmPrinter/DwarfException.h
llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/MC/MCAsmInfoXCOFF.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h
index ef4f6b9ec133..1b54c0018d27 100644
--- a/clang/lib/CodeGen/CGCleanup.h
+++ b/clang/lib/CodeGen/CGCleanup.h
@@ -612,6 +612,7 @@ struct EHPersonality {
   static const EHPersonality MSVC_C_specific_handler;
   static const EHPersonality MSVC_CxxFrameHandler3;
   static const EHPersonality GNU_Wasm_CPlusPlus;
+  static const EHPersonality XL_CPlusPlus;
 
   /// Does this personality use landingpads or the family of pad instructions
   /// designed to form funclets?

diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index bdf70252b5ad..85604cf5e611 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -113,6 +113,8 @@ const EHPersonality
 EHPersonality::MSVC_CxxFrameHandler3 = { "__CxxFrameHandler3", nullptr };
 const EHPersonality
 EHPersonality::GNU_Wasm_CPlusPlus = { "__gxx_wasm_personality_v0", nullptr };
+const EHPersonality EHPersonality::XL_CPlusPlus = {"__xlcxx_personality_v1",
+   nullptr};
 
 static const EHPersonality (const TargetInfo ,
 const LangOptions ) {
@@ -161,6 +163,8 @@ static const EHPersonality (const 
TargetInfo ,
   const llvm::Triple  = Target.getTriple();
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
+  if (T.isOSAIX())
+return EHPersonality::XL_CPlusPlus;
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)

diff  --git a/clang/test/CodeGenCXX/personality.cpp 
b/clang/test/CodeGenCXX/personality.cpp
index ce4bad370d91..1bdc7736c4da 100644
--- a/clang/test/CodeGenCXX/personality.cpp
+++ b/clang/test/CodeGenCXX/personality.cpp
@@ -12,6 +12,9 @@
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions 
-fseh-exceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-GNU-SEH
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions 
-fsjlj-exceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-GNU-SJLJ
 
+// RUN: %clang_cc1 -triple powerpc-unknown-aix-xcoff -fexceptions 
-fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -fexceptions 
-fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX
+
 extern void g();
 
 // CHECK-GNU: personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
@@ -21,6 +24,8 @@ extern void g();
 
 // CHECK-WIN: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
 
+// CHECK-AIX: personality i8* bitcast (i32 (...)* @__xlcxx_personality_v1 to 
i8*)
+
 void f() {
   try {
 g();

diff  --git a/llvm/include/llvm/Analysis/EHPersonalities.h 
b/llvm/include/llvm/Analysis/EHPersonalities.h
index 1905e0543fee..eaada6627494 100644
--- a/llvm/include/llvm/Analysis/EHPersonalities.h
+++ 

[llvm-branch-commits] [llvm] 9d6d24c - [JumpThreading][VectorUtils] avoid infinite loop on unreachable IR

2020-12-02 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-02T13:39:33-05:00
New Revision: 9d6d24c25056c17db56cf1ef5124f82eb18afc2c

URL: 
https://github.com/llvm/llvm-project/commit/9d6d24c25056c17db56cf1ef5124f82eb18afc2c
DIFF: 
https://github.com/llvm/llvm-project/commit/9d6d24c25056c17db56cf1ef5124f82eb18afc2c.diff

LOG: [JumpThreading][VectorUtils] avoid infinite loop on unreachable IR

https://llvm.org/PR48362

It's possible that we could stub this out sooner somewhere
within JumpThreading, but I'm not sure how to do that, and
then we would still have potential danger in other callers.

I can't find a way to trigger this using 'instsimplify',
however, because that already has a bailout on unreachable
blocks.

Added: 


Modified: 
llvm/lib/Analysis/VectorUtils.cpp
llvm/test/Transforms/JumpThreading/unreachable-loops.ll

Removed: 




diff  --git a/llvm/lib/Analysis/VectorUtils.cpp 
b/llvm/lib/Analysis/VectorUtils.cpp
index bd69055ac246..90726979ca4a 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -290,6 +290,10 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) {
 if (EltNo == IIElt)
   return III->getOperand(1);
 
+// Guard against infinite loop on malformed, unreachable IR.
+if (III == III->getOperand(0))
+  return nullptr;
+
 // Otherwise, the insertelement doesn't modify the value, recurse on its
 // vector input.
 return findScalarElement(III->getOperand(0), EltNo);

diff  --git a/llvm/test/Transforms/JumpThreading/unreachable-loops.ll 
b/llvm/test/Transforms/JumpThreading/unreachable-loops.ll
index 3f75aeae906c..a0f1c2127209 100644
--- a/llvm/test/Transforms/JumpThreading/unreachable-loops.ll
+++ b/llvm/test/Transforms/JumpThreading/unreachable-loops.ll
@@ -1,11 +1,12 @@
 ; RUN: opt -jump-threading -S < %s | FileCheck %s
 ; RUN: opt -passes=jump-threading -S < %s | FileCheck %s
+
 ; Check the unreachable loop won't cause infinite loop
 ; in jump-threading when it tries to update the predecessors'
 ; profile metadata from a phi node.
 
 define void @unreachable_single_bb_loop() {
-; CHECK-LABEL: @unreachable_single_bb_loop()
+; CHECK-LABEL: @unreachable_single_bb_loop(
 bb:
   %tmp = call i32 @a()
   %tmp1 = icmp eq i32 %tmp, 1
@@ -15,8 +16,8 @@ bb:
 bb2:  ; preds = %bb2
   %tmp4 = icmp ne i32 %tmp, 1
   switch i1 %tmp4, label %bb2 [
-i1 0, label %bb5
-i1 1, label %bb8
+  i1 0, label %bb5
+  i1 1, label %bb8
   ]
 
 bb5:  ; preds = %bb2, %bb
@@ -31,7 +32,7 @@ bb8:  ; preds = 
%bb8, %bb7, %bb5, %b
 }
 
 define void @unreachable_multi_bbs_loop() {
-; CHECK-LABEL: @unreachable_multi_bbs_loop()
+; CHECK-LABEL: @unreachable_multi_bbs_loop(
 bb:
   %tmp = call i32 @a()
   %tmp1 = icmp eq i32 %tmp, 1
@@ -44,8 +45,8 @@ bb3:  ; preds = 
%bb2
 bb2:  ; preds = %bb3
   %tmp4 = icmp ne i32 %tmp, 1
   switch i1 %tmp4, label %bb3 [
-i1 0, label %bb5
-i1 1, label %bb8
+  i1 0, label %bb5
+  i1 1, label %bb8
   ]
 
 bb5:  ; preds = %bb2, %bb
@@ -60,4 +61,85 @@ bb8:  ; preds = 
%bb8, %bb7, %bb5, %b
 }
 declare i32 @a()
 
+; This gets into a state that could cause instruction simplify
+; to hang - an insertelement instruction has itself as an operand.
+
+define void @PR48362() {
+; CHECK-LABEL: @PR48362(
+cleanup1491:  ; preds = %for.body1140
+  switch i32 0, label %cleanup2343.loopexit4 [
+  i32 0, label %cleanup.cont1500
+  i32 128, label %lbl_555.loopexit
+  ]
+
+cleanup.cont1500: ; preds = %cleanup1491
+  unreachable
+
+lbl_555.loopexit: ; preds = %cleanup1491
+  br label %for.body1509
+
+for.body1509: ; preds = %for.inc2340, 
%lbl_555.loopexit
+  %l_580.sroa.0.0 = phi <4 x i32> [ , %lbl_555.loopexit ], [ %l_580.sroa.0.2, 
%for.inc2340 ]
+  %p_55.addr.10 = phi i16 [ 0, %lbl_555.loopexit ], [ %p_55.addr.11, 
%for.inc2340 ]
+  %i82 = load i32, i32* undef, align 1
+  %tobool1731.not = icmp eq i32 %i82, 0
+  br i1 %tobool1731.not, label %if.end1733, label %if.then1732
+
+if.then1732:  ; preds = %for.body1509
+  br label %cleanup2329
+
+if.end1733:   ; preds = %for.body1509
+  %tobool1735.not = icmp eq i16 %p_55.addr.10, 0
+  br i1 %tobool1735.not, label %if.then1736, label %if.else1904
+
+if.then1736:  ; preds = %if.end1733
+  br label %cleanup2329
+
+if.else1904:  ; preds = %if.end1733
+  br label %for.body1911
+
+for.body1911: ; 

[llvm-branch-commits] [flang] 1f525ec - [flang][NFC] Add GetTopLevelUnitContaining functions

2020-12-02 Thread Tim Keith via llvm-branch-commits

Author: Tim Keith
Date: 2020-12-02T10:28:49-08:00
New Revision: 1f525ece4abfb6077d73e34acac0666855d19052

URL: 
https://github.com/llvm/llvm-project/commit/1f525ece4abfb6077d73e34acac0666855d19052
DIFF: 
https://github.com/llvm/llvm-project/commit/1f525ece4abfb6077d73e34acac0666855d19052.diff

LOG: [flang][NFC] Add GetTopLevelUnitContaining functions

`GetTopLevelUnitContaining` returns the Scope nested in the global scope
that contains the given Scope or Symbol.

Use "Get" rather than "Find" in the name because "Find" implies it might
not be found, which can't happen. Following that logic, rename
`FindProgramUnitContaining` to `GetProgramUnitContaining` and have it
also return a reference rather that a pointer.

Note that the use of "ProgramUnit" is slightly confusing. In the Fortran
standard, "program-unit" refers to what is called a "TopLevelUnit" here.
What we are calling a "ProgramUnit" (here and in `ProgramTree`) includes
internal subprograms while "TopLevelUnit" does not.

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

Added: 


Modified: 
flang/include/flang/Semantics/tools.h
flang/lib/Semantics/check-return.cpp
flang/lib/Semantics/resolve-names.cpp
flang/lib/Semantics/tools.cpp

Removed: 




diff  --git a/flang/include/flang/Semantics/tools.h 
b/flang/include/flang/Semantics/tools.h
index 02faad4ecb2f..033c496c24b4 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -30,9 +30,14 @@ class DerivedTypeSpec;
 class Scope;
 class Symbol;
 
+// Note: Here ProgramUnit includes internal subprograms while TopLevelUnit
+// does not. "program-unit" in the Fortran standard matches TopLevelUnit.
+const Scope (const Scope &);
+const Scope (const Symbol &);
+const Scope (const Scope &);
+const Scope (const Symbol &);
+
 const Scope *FindModuleContaining(const Scope &);
-const Scope *FindProgramUnitContaining(const Scope &);
-const Scope *FindProgramUnitContaining(const Symbol &);
 const Scope *FindPureProcedureContaining(const Scope &);
 const Scope *FindPureProcedureContaining(const Symbol &);
 const Symbol *FindPointerComponent(const Scope &);

diff  --git a/flang/lib/Semantics/check-return.cpp 
b/flang/lib/Semantics/check-return.cpp
index 602ecc8a22f7..7830df034b55 100644
--- a/flang/lib/Semantics/check-return.cpp
+++ b/flang/lib/Semantics/check-return.cpp
@@ -16,11 +16,10 @@
 namespace Fortran::semantics {
 
 static const Scope *FindContainingSubprogram(const Scope ) {
-  const Scope *scope{FindProgramUnitContaining(start)};
-  return scope &&
-  (scope->kind() == Scope::Kind::MainProgram ||
-  scope->kind() == Scope::Kind::Subprogram)
-  ? scope
+  const Scope {GetProgramUnitContaining(start)};
+  return scope.kind() == Scope::Kind::MainProgram ||
+  scope.kind() == Scope::Kind::Subprogram
+  ? 
   : nullptr;
 }
 

diff  --git a/flang/lib/Semantics/resolve-names.cpp 
b/flang/lib/Semantics/resolve-names.cpp
index a879d009d12d..fd994b9d2827 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -5602,11 +5602,11 @@ bool DeclarationVisitor::CheckForHostAssociatedImplicit(
 }
 
 bool DeclarationVisitor::IsUplevelReference(const Symbol ) {
-  const Scope *symbolUnit{FindProgramUnitContaining(symbol)};
-  if (symbolUnit == FindProgramUnitContaining(currScope())) {
+  const Scope {GetProgramUnitContaining(symbol)};
+  if (symbolUnit == GetProgramUnitContaining(currScope())) {
 return false;
   } else {
-Scope::Kind kind{DEREF(symbolUnit).kind()};
+Scope::Kind kind{symbolUnit.kind()};
 return kind == Scope::Kind::Subprogram || kind == Scope::Kind::MainProgram;
   }
 }

diff  --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 0ab2b376b3e2..b27c8b7cc867 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -37,13 +37,24 @@ static const Scope *FindScopeContaining(
   }
 }
 
+const Scope (const Scope ) {
+  CHECK(!start.IsGlobal());
+  return DEREF(FindScopeContaining(
+  start, [](const Scope ) { return scope.parent().IsGlobal(); }));
+}
+
+const Scope (const Symbol ) {
+  return GetTopLevelUnitContaining(symbol.owner());
+}
+
 const Scope *FindModuleContaining(const Scope ) {
   return FindScopeContaining(
   start, [](const Scope ) { return scope.IsModule(); });
 }
 
-const Scope *FindProgramUnitContaining(const Scope ) {
-  return FindScopeContaining(start, [](const Scope ) {
+const Scope (const Scope ) {
+  CHECK(!start.IsGlobal());
+  return DEREF(FindScopeContaining(start, [](const Scope ) {
 switch (scope.kind()) {
 case Scope::Kind::Module:
 case Scope::Kind::MainProgram:
@@ -53,23 +64,19 @@ const Scope *FindProgramUnitContaining(const Scope ) {
 default:
   return false;
 }
-  });
+  }));
 }
 
-const Scope *FindProgramUnitContaining(const Symbol ) {
-  return 

[llvm-branch-commits] [lldb] 291cc1b - [lldb][NFC] Give class template pack test files unique class names

2020-12-02 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-02T19:19:35+01:00
New Revision: 291cc1bbea1f4a6cab829509e95b3efe40af908f

URL: 
https://github.com/llvm/llvm-project/commit/291cc1bbea1f4a6cab829509e95b3efe40af908f
DIFF: 
https://github.com/llvm/llvm-project/commit/291cc1bbea1f4a6cab829509e95b3efe40af908f.diff

LOG: [lldb][NFC] Give class template pack test files unique class names

Added: 


Modified: 

lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py

lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
 
b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
index d366d9d69222..6b4b96049cdb 100644
--- 
a/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
+++ 
b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
@@ -3,7 +3,7 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-class TestCase(TestBase):
+class TestCaseClassTemplateNonTypeParameterPack(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
@@ -73,4 +73,4 @@ def test(self):
 self.expect_expr("emptyNonTypePackAfterNonTypeParam", 
result_type="NonTypePackAfterNonTypeParam<1>",
 result_children=[ValueCheck(name="j", type="int")])
 self.expect_expr("oneElemNonTypePackAfterNonTypeParam", 
result_type="NonTypePackAfterNonTypeParam<1, 2>",
-result_children=[ValueCheck(name="j", type="int")])
\ No newline at end of file
+result_children=[ValueCheck(name="j", type="int")])

diff  --git 
a/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
 
b/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
index 48ea59d6e5eb..223ba5224274 100644
--- 
a/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
+++ 
b/lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
@@ -3,7 +3,7 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-class TestCase(TestBase):
+class TestCaseClassTemplateTypeParameterPack(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
@@ -73,4 +73,4 @@ def test(self):
 self.expect_expr("emptyTypePackAfterNonTypeParam", 
result_type="TypePackAfterNonTypeParam<1>",
 result_children=[ValueCheck(name="j", type="int")])
 self.expect_expr("oneElemTypePackAfterNonTypeParam", 
result_type="TypePackAfterNonTypeParam<1, int>",
-result_children=[ValueCheck(name="j", type="int")])
\ No newline at end of file
+result_children=[ValueCheck(name="j", type="int")])



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] a8034fc - [LoopVectorize] Fix optimal-epilog-vectorization-limitations.ll test on non-debug build bots

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T18:00:42Z
New Revision: a8034fc1ad8ba11a42bbfe5d40cae4836366ef84

URL: 
https://github.com/llvm/llvm-project/commit/a8034fc1ad8ba11a42bbfe5d40cae4836366ef84
DIFF: 
https://github.com/llvm/llvm-project/commit/a8034fc1ad8ba11a42bbfe5d40cae4836366ef84.diff

LOG: [LoopVectorize] Fix optimal-epilog-vectorization-limitations.ll test on 
non-debug build bots

Add "REQUIRES: asserts" as the test uses the "--debug-only" switch

Should fix the clang-with-thin-lto-ubuntu buildbot failure

Added: 


Modified: 

llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll

Removed: 




diff  --git 
a/llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll
 
b/llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll
index e4d62a649edd..c4a8f0ded86b 100644
--- 
a/llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll
+++ 
b/llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll
@@ -1,3 +1,4 @@
+; REQUIRES: asserts
 ; RUN: opt < %s  -passes='loop-vectorize' -force-vector-width=2 
-enable-epilogue-vectorization -epilogue-vectorization-force-VF=2 
--debug-only=loop-vectorize -S 2>&1 | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-n32:64-v256:256:256-v512:512:512"



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 1f23537 - [Thumb2] Regenerate predicated-liveout-unknown-lanes.ll test

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T18:00:42Z
New Revision: 1f2353734da373d8df396f40dca1a1155a0d7adc

URL: 
https://github.com/llvm/llvm-project/commit/1f2353734da373d8df396f40dca1a1155a0d7adc
DIFF: 
https://github.com/llvm/llvm-project/commit/1f2353734da373d8df396f40dca1a1155a0d7adc.diff

LOG: [Thumb2] Regenerate predicated-liveout-unknown-lanes.ll test

Helps to reduce diff in D90113

Added: 


Modified: 

llvm/test/CodeGen/Thumb2/LowOverheadLoops/predicated-liveout-unknown-lanes.ll

Removed: 




diff  --git 
a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/predicated-liveout-unknown-lanes.ll 
b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/predicated-liveout-unknown-lanes.ll
index f6e175d792d1..01da3ce20b9a 100644
--- 
a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/predicated-liveout-unknown-lanes.ll
+++ 
b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/predicated-liveout-unknown-lanes.ll
@@ -17,6 +17,13 @@ define arm_aapcs_vfpcc <4 x float> 
@arm_max_no_idx_f32_mve(float* %pSrc, i32 %bl
 ; CHECK-NEXT:letp lr, .LBB0_1
 ; CHECK-NEXT:  @ %bb.2: @ %do.end
 ; CHECK-NEXT:pop {r7, pc}
+; CHECK-NEXT:.p2align 4
+; CHECK-NEXT:  @ %bb.3:
+; CHECK-NEXT:  .LCPI0_0:
+; CHECK-NEXT:.long 0xff80 @ float -Inf
+; CHECK-NEXT:.long 0xff80 @ float -Inf
+; CHECK-NEXT:.long 0xff80 @ float -Inf
+; CHECK-NEXT:.long 0xff80 @ float -Inf
 entry:
   br label %do.body
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 8aa40de - [PowerPC] Regenerate cmpb tests

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T18:00:41Z
New Revision: 8aa40de5ec24b741ac222db235dbe16fd35fa223

URL: 
https://github.com/llvm/llvm-project/commit/8aa40de5ec24b741ac222db235dbe16fd35fa223
DIFF: 
https://github.com/llvm/llvm-project/commit/8aa40de5ec24b741ac222db235dbe16fd35fa223.diff

LOG: [PowerPC] Regenerate cmpb tests

Helps to reduce diff in D90113

Added: 


Modified: 
llvm/test/CodeGen/PowerPC/cmpb-ppc32.ll
llvm/test/CodeGen/PowerPC/cmpb.ll

Removed: 




diff  --git a/llvm/test/CodeGen/PowerPC/cmpb-ppc32.ll 
b/llvm/test/CodeGen/PowerPC/cmpb-ppc32.ll
index ec80b351cf4e..ab63784134f9 100644
--- a/llvm/test/CodeGen/PowerPC/cmpb-ppc32.ll
+++ b/llvm/test/CodeGen/PowerPC/cmpb-ppc32.ll
@@ -1,9 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 < %s | FileCheck %s
 target datalayout = "E-m:e-p:32:32-i64:64-n32"
 target triple = "powerpc-unknown-linux-gnu"
 
 ; Function Attrs: nounwind readnone
 define zeroext i16 @test16(i16 zeroext %x, i16 zeroext %y) #0 {
+; CHECK-LABEL: test16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cmpb 3, 4, 3
+; CHECK-NEXT:clrlwi 3, 3, 16
+; CHECK-NEXT:blr
 entry:
   %0 = xor i16 %y, %x
   %1 = and i16 %0, 255
@@ -14,14 +20,13 @@ entry:
   %or = or i32 %conv25, %conv27
   %conv29 = trunc i32 %or to i16
   ret i16 %conv29
-
-; CHECK-LABEL: @test16
-; CHECK: cmpb [[REG1:[0-9]+]], 4, 3
-; CHECK: clrlwi 3, [[REG1]], 16
-; CHECK: blr
 }
 
 define i32 @test32(i32 %x, i32 %y) #0 {
+; CHECK-LABEL: test32:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cmpb 3, 4, 3
+; CHECK-NEXT:blr
 entry:
   %0 = xor i32 %y, %x
   %1 = and i32 %0, 255
@@ -39,11 +44,6 @@ entry:
   %or49 = or i32 %or, %conv44
   %or52 = or i32 %or49, %conv47
   ret i32 %or52
-
-; CHECK-LABEL: @test32
-; CHECK: cmpb 3, 4, 3
-; CHECK-NOT: rlwinm
-; CHECK: blr
 }
 
 attributes #0 = { nounwind readnone }

diff  --git a/llvm/test/CodeGen/PowerPC/cmpb.ll 
b/llvm/test/CodeGen/PowerPC/cmpb.ll
index e7f5579e0a45..6e499e55d7dc 100644
--- a/llvm/test/CodeGen/PowerPC/cmpb.ll
+++ b/llvm/test/CodeGen/PowerPC/cmpb.ll
@@ -1,9 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mcpu pwr7 < %s | FileCheck %s
 target datalayout = "E-m:e-i64:64-n32:64"
 target triple = "powerpc64-unknown-linux-gnu"
 
 ; Function Attrs: nounwind readnone
 define zeroext i16 @test16(i16 zeroext %x, i16 zeroext %y) #0 {
+; CHECK-LABEL: test16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cmpb 3, 4, 3
+; CHECK-NEXT:clrldi 3, 3, 48
+; CHECK-NEXT:blr
 entry:
   %0 = xor i16 %y, %x
   %1 = and i16 %0, 255
@@ -14,14 +20,14 @@ entry:
   %or = or i32 %conv25, %conv27
   %conv29 = trunc i32 %or to i16
   ret i16 %conv29
-
-; CHECK-LABEL: @test16
-; CHECK: cmpb [[REG1:[0-9]+]], 4, 3
-; CHECK: clrldi 3, [[REG1]], 48
-; CHECK: blr
 }
 
 define zeroext i16 @test16p1(i16 zeroext %x, i16 zeroext %y) #0 {
+; CHECK-LABEL: test16p1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cmpb 3, 4, 3
+; CHECK-NEXT:andi. 3, 3, 65285
+; CHECK-NEXT:blr
 entry:
   %0 = xor i16 %y, %x
   %1 = and i16 %0, 255
@@ -32,15 +38,15 @@ entry:
   %or = or i32 %conv28, %conv30
   %conv32 = trunc i32 %or to i16
   ret i16 %conv32
-
-; CHECK-LABEL: @test16p1
-; CHECK: cmpb [[REG1:[0-9]+]], 4, 3
-; CHECK: andi. 3, [[REG1]], 65285
-; CHECK: blr
 }
 
 ; Function Attrs: nounwind readnone
 define zeroext i16 @test16p2(i16 zeroext %x, i16 zeroext %y) #0 {
+; CHECK-LABEL: test16p2:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cmpb 3, 4, 3
+; CHECK-NEXT:andi. 3, 3, 1535
+; CHECK-NEXT:blr
 entry:
   %0 = xor i16 %y, %x
   %1 = and i16 %0, 255
@@ -51,15 +57,16 @@ entry:
   %or = or i32 %conv28, %conv30
   %conv32 = trunc i32 %or to i16
   ret i16 %conv32
-
-; CHECK-LABEL: @test16p2
-; CHECK: cmpb [[REG1:[0-9]+]], 4, 3
-; CHECK: andi. 3, [[REG1]], 1535
-; CHECK: blr
 }
 
 ; Function Attrs: nounwind readnone
 define zeroext i16 @test16p3(i16 zeroext %x, i16 zeroext %y) #0 {
+; CHECK-LABEL: test16p3:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cmpb 3, 4, 3
+; CHECK-NEXT:clrldi 3, 3, 55
+; CHECK-NEXT:xori 3, 3, 1280
+; CHECK-NEXT:blr
 entry:
   %0 = xor i16 %y, %x
   %1 = and i16 %0, 255
@@ -70,15 +77,14 @@ entry:
   %or = or i32 %conv27, %conv29
   %conv31 = trunc i32 %or to i16
   ret i16 %conv31
-
-; CHECK-LABEL: @test16p3
-; CHECK: cmpb [[REG1:[0-9]+]], 4, 3
-; CHECK: clrldi [[REG2:[0-9]+]], [[REG1]], 55
-; CHECK: xori 3, [[REG2]], 1280
-; CHECK: blr
 }
 
 define zeroext i32 @test32(i32 zeroext %x, i32 zeroext %y) #0 {
+; CHECK-LABEL: test32:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cmpb 3, 4, 3
+; CHECK-NEXT:clrldi 3, 3, 32
+; CHECK-NEXT:blr
 entry:
   %0 = xor i32 %y, %x
   %1 = and i32 %0, 255
@@ -96,14 +102,15 @@ entry:
   %or49 = or i32 %or, %conv44

[llvm-branch-commits] [llvm] 557b00e - Delete llvm::is_trivially_copyable and CMake variable HAVE_STD_IS_TRIVIALLY_COPYABLE

2020-12-02 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-02T09:58:08-08:00
New Revision: 557b00e0afb2dc1776f50948094ca8cc62d97be4

URL: 
https://github.com/llvm/llvm-project/commit/557b00e0afb2dc1776f50948094ca8cc62d97be4
DIFF: 
https://github.com/llvm/llvm-project/commit/557b00e0afb2dc1776f50948094ca8cc62d97be4.diff

LOG: Delete llvm::is_trivially_copyable and CMake variable 
HAVE_STD_IS_TRIVIALLY_COPYABLE

GCC<5 did not support std::is_trivially_copyable. Now LLVM builds
require 5.1 we can delete llvm::is_trivially_copyable after the users
have been migrated to std::is_trivially_copyable.

Added: 


Modified: 
llvm/cmake/config-ix.cmake
llvm/include/llvm/ADT/PointerIntPair.h
llvm/include/llvm/Config/config.h.cmake
llvm/include/llvm/Support/type_traits.h
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

Removed: 




diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 818fafbce148..b4c54da01912 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -351,15 +351,6 @@ else()
   unset(HAVE_FFI_CALL CACHE)
 endif( LLVM_ENABLE_FFI )
 
-# Whether we can use std::is_trivially_copyable to verify 
llvm::is_trivially_copyable.
-CHECK_CXX_SOURCE_COMPILES("
-#include 
-struct T { int val; };
-static_assert(std::is_trivially_copyable::value, \"ok\");
-int main() { return 0;}
-" HAVE_STD_IS_TRIVIALLY_COPYABLE)
-
-
 # Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported.
 include(CheckAtomic)
 

diff  --git a/llvm/include/llvm/ADT/PointerIntPair.h 
b/llvm/include/llvm/ADT/PointerIntPair.h
index cb8b202c48b7..600fcebff3ea 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -15,7 +15,6 @@
 
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
-#include "llvm/Support/type_traits.h"
 #include 
 #include 
 #include 
@@ -127,19 +126,6 @@ class PointerIntPair {
   }
 };
 
-// Specialize is_trivially_copyable to avoid limitation of 
llvm::is_trivially_copyable
-// when compiled with gcc 4.9.
-template 
-struct is_trivially_copyable> : std::true_type {
-#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
-  static_assert(std::is_trivially_copyable>::value,
-"inconsistent behavior between llvm:: and std:: implementation 
of is_trivially_copyable");
-#endif
-};
-
-
 template 
 struct PointerIntPairInfo {
   static_assert(PtrTraits::NumLowBitsAvailable <

diff  --git a/llvm/include/llvm/Config/config.h.cmake 
b/llvm/include/llvm/Config/config.h.cmake
index 6664ad335584..4da1d199db67 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -332,9 +332,6 @@
 /* Define as the return type of signal handlers (`int' or `void'). */
 #cmakedefine RETSIGTYPE ${RETSIGTYPE}
 
-/* Define if std::is_trivially_copyable is supported */
-#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE ${HAVE_STD_IS_TRIVIALLY_COPYABLE}
-
 /* Define to a function implementing stricmp */
 #cmakedefine stricmp ${stricmp}
 

diff  --git a/llvm/include/llvm/Support/type_traits.h 
b/llvm/include/llvm/Support/type_traits.h
index 7b7d5d991f3f..383f087f4bc2 100644
--- a/llvm/include/llvm/Support/type_traits.h
+++ b/llvm/include/llvm/Support/type_traits.h
@@ -85,11 +85,6 @@ template union 
move_construction_triviality_helper {
 ~move_construction_triviality_helper() = default;
 };
 
-template
-union trivial_helper {
-T t;
-};
-
 } // end namespace detail
 
 /// An implementation of `std::is_trivially_copy_constructible` since we have
@@ -114,78 +109,6 @@ struct is_trivially_move_constructible : 
std::true_type {};
 template 
 struct is_trivially_move_constructible : std::true_type {};
 
-
-template 
-struct is_copy_assignable {
-  template
-static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{});
-static std::false_type get(...);
-static constexpr bool value = decltype(get((T*)nullptr))::value;
-};
-
-template 
-struct is_move_assignable {
-  template
-static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{});
-static std::false_type get(...);
-static constexpr bool value = decltype(get((T*)nullptr))::value;
-};
-
-
-// An implementation of `std::is_trivially_copyable` since STL version
-// is not equally supported by all compilers, especially GCC 4.9.
-// Uniform implementation of this trait is important for ABI compatibility
-// as it has an impact on SmallVector's ABI (among others).
-template 
-class is_trivially_copyable {
-
-  // copy constructors
-  static constexpr bool has_trivial_copy_constructor =
-  std::is_copy_constructible>::value;
-  static constexpr bool has_deleted_copy_constructor =
-  !std::is_copy_constructible::value;
-
-  // move constructors
-  static constexpr bool has_trivial_move_constructor =
-  std::is_move_constructible>::value;
-  static constexpr bool 

[llvm-branch-commits] [llvm] 4d4bd40 - Use std::is_trivially_copyable

2020-12-02 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-02T09:58:07-08:00
New Revision: 4d4bd40b578d77b8c5bc349ded405fb58c333c78

URL: 
https://github.com/llvm/llvm-project/commit/4d4bd40b578d77b8c5bc349ded405fb58c333c78
DIFF: 
https://github.com/llvm/llvm-project/commit/4d4bd40b578d77b8c5bc349ded405fb58c333c78.diff

LOG: Use std::is_trivially_copyable

GCC<5 did not support std::is_trivially_copyable. Now LLVM builds require 5.1
we can migrate to std::is_trivially_copyable.

Added: 


Modified: 
llvm/docs/ProgrammersManual.rst
llvm/include/llvm/ADT/DenseMap.h
llvm/include/llvm/ADT/Optional.h
llvm/include/llvm/ADT/STLExtras.h
llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
llvm/tools/llvm-diff/DifferenceEngine.cpp
llvm/unittests/ADT/ArrayRefTest.cpp
llvm/unittests/ADT/ImmutableListTest.cpp
llvm/unittests/ADT/OptionalTest.cpp
llvm/unittests/ADT/PointerIntPairTest.cpp
llvm/unittests/ADT/StringRefTest.cpp
llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
llvm/unittests/Bitstream/BitstreamReaderTest.cpp
llvm/unittests/CodeGen/MachineInstrTest.cpp
llvm/unittests/CodeGen/TypeTraitsTest.cpp
llvm/unittests/IR/CFGBuilder.cpp
llvm/unittests/Support/ScaledNumberTest.cpp

Removed: 




diff  --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index d9925d69d9f6..e303a7a18eba 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -1530,7 +1530,7 @@ SmallVector has grown a few other minor advantages over 
std::vector, causing
 #. std::vector is exception-safe, and some implementations have pessimizations
that copy elements when SmallVector would move them.
 
-#. SmallVector understands ``llvm::is_trivially_copyable`` and uses 
realloc aggressively.
+#. SmallVector understands ``std::is_trivially_copyable`` and uses 
realloc aggressively.
 
 #. Many LLVM APIs take a SmallVectorImpl as an out parameter (see the note
below).

diff  --git a/llvm/include/llvm/ADT/DenseMap.h 
b/llvm/include/llvm/ADT/DenseMap.h
index 42e4fc84175c..7f7a4593ae36 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -426,8 +426,8 @@ class DenseMapBase : public DebugEpochBase {
 setNumEntries(other.getNumEntries());
 setNumTombstones(other.getNumTombstones());
 
-if (is_trivially_copyable::value &&
-is_trivially_copyable::value)
+if (std::is_trivially_copyable::value &&
+std::is_trivially_copyable::value)
   memcpy(reinterpret_cast(getBuckets()), other.getBuckets(),
  getNumBuckets() * sizeof(BucketT));
 else

diff  --git a/llvm/include/llvm/ADT/Optional.h 
b/llvm/include/llvm/ADT/Optional.h
index be32178cb185..5fff0acca816 100644
--- a/llvm/include/llvm/ADT/Optional.h
+++ b/llvm/include/llvm/ADT/Optional.h
@@ -17,10 +17,10 @@
 
 #include "llvm/ADT/None.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/type_traits.h"
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace llvm {
@@ -32,7 +32,7 @@ namespace optional_detail {
 struct in_place_t {};
 
 /// Storage for any type.
-template ::value>
+template ::value>
 class OptionalStorage {
   union {
 char empty;

diff  --git a/llvm/include/llvm/ADT/STLExtras.h 
b/llvm/include/llvm/ADT/STLExtras.h
index 5a5d47b783c2..1d6faf6509f9 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1428,7 +1428,7 @@ template 
 // is trivially copyable.
 using sort_trivially_copyable = conjunction<
 std::is_pointer,
-is_trivially_copyable::value_type>>;
+std::is_trivially_copyable::value_type>>;
 } // namespace detail
 
 // Provide wrappers to std::sort which shuffle the elements before sorting

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h 
b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
index e6ade770457c..9f34d026b1ba 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -171,15 +171,10 @@ struct GloballyHashedType {
 return Hashes;
   }
 };
-#if defined(_MSC_VER)
-// is_trivially_copyable is not available in older versions of libc++, but it 
is
-// available in all supported versions of MSVC, so at least this gives us some
-// coverage.
 static_assert(std::is_trivially_copyable::value,
   "GloballyHashedType must be trivially copyable so that we can "
   "reinterpret_cast arrays of hash data to arrays of "
   "GloballyHashedType");
-#endif
 } // namespace codeview
 
 template <> struct DenseMapInfo {

diff  --git a/llvm/tools/llvm-
diff /DifferenceEngine.cpp b/llvm/tools/llvm-
diff /DifferenceEngine.cpp
index 2cf1afbc6af5..64c0dc61e806 100644
--- a/llvm/tools/llvm-
diff /DifferenceEngine.cpp
+++ b/llvm/tools/llvm-
diff /DifferenceEngine.cpp
@@ -67,7 +67,7 @@ class PriorityQueue {
 unsigned NewSize = Storage.size() - 1;

[llvm-branch-commits] [lld] 92475f6 - [test] Make verify-invalid.ll work with legacy and new PMs

2020-12-02 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-02T09:56:18-08:00
New Revision: 92475f698ec20c153114da5ba88a2948c7cfae59

URL: 
https://github.com/llvm/llvm-project/commit/92475f698ec20c153114da5ba88a2948c7cfae59
DIFF: 
https://github.com/llvm/llvm-project/commit/92475f698ec20c153114da5ba88a2948c7cfae59.diff

LOG: [test] Make verify-invalid.ll work with legacy and new PMs

Added: 


Modified: 
lld/test/ELF/lto/verify-invalid.ll
lld/test/wasm/lto/verify-invalid.ll

Removed: 




diff  --git a/lld/test/ELF/lto/verify-invalid.ll 
b/lld/test/ELF/lto/verify-invalid.ll
index c18c264ef632..4ad38d604fb7 100644
--- a/lld/test/ELF/lto/verify-invalid.ll
+++ b/lld/test/ELF/lto/verify-invalid.ll
@@ -1,10 +1,10 @@
 ; REQUIRES: x86
 ; RUN: llvm-as %s -o %t.o
-; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments \
+; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments 
--no-lto-new-pass-manager \
 ; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT-LPM %s
-; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments \
+; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments 
--no-lto-new-pass-manager \
 ; RUN:   -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE-LPM %s
-; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments \
+; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments 
--no-lto-new-pass-manager \
 ; RUN:   --plugin-opt=disable-verify 2>&1 | FileCheck 
-check-prefix=DISABLE-LPM %s
 ; RUN: ld.lld %t.o -o %t2 --lto-new-pass-manager --lto-debug-pass-manager \
 ; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT-NPM %s

diff  --git a/lld/test/wasm/lto/verify-invalid.ll 
b/lld/test/wasm/lto/verify-invalid.ll
index c4a5bcdc67d1..5e6daac85888 100644
--- a/lld/test/wasm/lto/verify-invalid.ll
+++ b/lld/test/wasm/lto/verify-invalid.ll
@@ -1,8 +1,12 @@
 ; RUN: llvm-as %s -o %t.o
-; RUN: wasm-ld %t.o -o %t2 -mllvm -debug-pass=Arguments \
-; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT %s
-; RUN: wasm-ld %t.o -o %t2 -mllvm -debug-pass=Arguments \
-; RUN:   -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE %s
+; RUN: wasm-ld %t.o -o %t2 --no-lto-new-pass-manager -mllvm 
-debug-pass=Arguments \
+; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT-LPM %s
+; RUN: wasm-ld %t.o -o %t2 --no-lto-new-pass-manager -mllvm 
-debug-pass=Arguments \
+; RUN:   -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE-LPM %s
+; RUN: wasm-ld %t.o -o %t2 --lto-new-pass-manager --lto-debug-pass-manager \
+; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT-NPM %s
+; RUN: wasm-ld %t.o -o %t2 --lto-new-pass-manager --lto-debug-pass-manager \
+; RUN:   -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE-NPM %s
 
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
@@ -12,5 +16,9 @@ define void @_start() {
 }
 
 ; -disable-verify should disable the verification of bitcode.
-; DEFAULT: Pass Arguments: {{.*}} -verify {{.*}} -verify
-; DISABLE-NOT: Pass Arguments: {{.*}} -verify {{.*}} -verify
+; DEFAULT-LPM: Pass Arguments: {{.*}} -verify {{.*}} -verify
+; DISABLE-LPM-NOT: Pass Arguments: {{.*}} -verify {{.*}} -verify
+; DEFAULT-NPM: Running pass: VerifierPass
+; DEFAULT-NPM: Running pass: VerifierPass
+; DEFAULT-NPM-NOT: Running pass: VerifierPass
+; DISABLE-NPM-NOT: Running pass: VerifierPass



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] f019362 - [X86] EltsFromConsecutiveLoads - remove old FIXME comment. NFC.

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T17:21:41Z
New Revision: f019362329734ddc7d17fc76bcb7f2a4b3ea50a7

URL: 
https://github.com/llvm/llvm-project/commit/f019362329734ddc7d17fc76bcb7f2a4b3ea50a7
DIFF: 
https://github.com/llvm/llvm-project/commit/f019362329734ddc7d17fc76bcb7f2a4b3ea50a7.diff

LOG: [X86] EltsFromConsecutiveLoads - remove old FIXME comment. NFC.

Its unlikely an undef element in a zero vector will be any use.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 1a822c086b6a..56e098a48dd5 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -8398,8 +8398,6 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, 
ArrayRef Elts,
   // Handle Special Cases - all undef or undef/zero.
   if (UndefMask.countPopulation() == NumElems)
 return DAG.getUNDEF(VT);
-
-  // FIXME: Should we return this as a BUILD_VECTOR instead?
   if ((ZeroMask.countPopulation() + UndefMask.countPopulation()) == NumElems)
 return VT.isInteger() ? DAG.getConstant(0, DL, VT)
   : DAG.getConstantFP(0.0, DL, VT);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] ed09d41 - [LSR][X86] Replace -march with -mtriples

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T17:05:15Z
New Revision: ed09d41c8aa11fd8412211c38bc13220ffaf3070

URL: 
https://github.com/llvm/llvm-project/commit/ed09d41c8aa11fd8412211c38bc13220ffaf3070
DIFF: 
https://github.com/llvm/llvm-project/commit/ed09d41c8aa11fd8412211c38bc13220ffaf3070.diff

LOG: [LSR][X86] Replace -march with -mtriples

Fixes build on gnux32 hosts

Added: 


Modified: 
llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll
llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll
llvm/test/Transforms/LoopStrengthReduce/X86/lsr-insns-2.ll

Removed: 




diff  --git a/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll 
b/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll
index 2e32d916fe32..44da8b7f72cf 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -O3 -march=x86-64 -mcpu=core2 | FileCheck %s
+; RUN: llc < %s -O3 -mtriple=x86_64-- -mcpu=core2 | FileCheck %s
 
 declare i1 @check() nounwind
 declare i1 @foo(i8*, i8*, i8*) nounwind

diff  --git a/llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll 
b/llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll
index 7925bf01020e..fc3c875d7e56 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll
@@ -1,6 +1,6 @@
 ; REQUIRES: asserts
-; RUN: llc < %s -O3 -march=x86-64 -mcpu=core2 -stress-ivchain | FileCheck %s 
-check-prefix=X64
-; RUN: llc < %s -O3 -march=x86 -mcpu=core2 -stress-ivchain | FileCheck %s 
-check-prefix=X32
+; RUN: llc < %s -O3 -mtriple=x86_64-- -mcpu=core2 -stress-ivchain | FileCheck 
%s -check-prefix=X64
+; RUN: llc < %s -O3 -mtriple=i686-- -mcpu=core2 -stress-ivchain | FileCheck %s 
-check-prefix=X86
 
 ; @sharedidx is an unrolled variant of this loop:
 ;  for (unsigned long i = 0; i < len; i += s) {
@@ -17,14 +17,14 @@
 ; X64-NOT: leal ({{.*}},4)
 ; X64: %for.body.1
 
-; X32: sharedidx:
-; X32: %for.body.2
-; X32: add
-; X32: add
-; X32: add
-; X32: add
-; X32: add
-; X32: %for.body.3
+; X86: sharedidx:
+; X86: %for.body.2
+; X86: add
+; X86: add
+; X86: add
+; X86: add
+; X86: add
+; X86: %for.body.3
 define void @sharedidx(i8* nocapture %a, i8* nocapture %b, i8* nocapture %c, 
i32 %s, i32 %len) nounwind ssp {
 entry:
   %cmp8 = icmp eq i32 %len, 0

diff  --git a/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-insns-2.ll 
b/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-insns-2.ll
index 613e65d0c650..240eb8c19744 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-insns-2.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-insns-2.ll
@@ -1,6 +1,6 @@
-; RUN: opt < %s -loop-reduce -mtriple=x86_64 -S | FileCheck %s 
-check-prefix=BOTH -check-prefix=INSN
-; RUN: opt < %s -loop-reduce -mtriple=x86_64 -lsr-insns-cost=false -S | 
FileCheck %s -check-prefix=BOTH -check-prefix=REGS
-; RUN: llc < %s -O2 -march=x86-64 -lsr-insns-cost -asm-verbose=0 | FileCheck %s
+; RUN: opt < %s -loop-reduce -mtriple=x86_64-- -S | FileCheck %s 
-check-prefix=BOTH -check-prefix=INSN
+; RUN: opt < %s -loop-reduce -mtriple=x86_64-- -lsr-insns-cost=false -S | 
FileCheck %s -check-prefix=BOTH -check-prefix=REGS
+; RUN: llc < %s -O2 -mtriple=x86_64-- -lsr-insns-cost -asm-verbose=0 | 
FileCheck %s
 
 ; OPT checks that LSR prefers less instructions to less registers.
 ; For x86 LSR should prefer complicated address to new lsr induction



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] c904c32 - [GWP-ASan] Fix flaky test on Fuchsia

2020-12-02 Thread Kostya Kortchinsky via llvm-branch-commits

Author: Kostya Kortchinsky
Date: 2020-12-02T09:00:51-08:00
New Revision: c904c32b9c9243b11ffc18e46b7350f000e9c088

URL: 
https://github.com/llvm/llvm-project/commit/c904c32b9c9243b11ffc18e46b7350f000e9c088
DIFF: 
https://github.com/llvm/llvm-project/commit/c904c32b9c9243b11ffc18e46b7350f000e9c088.diff

LOG: [GWP-ASan] Fix flaky test on Fuchsia

The LateInit test might be reusing some already initialized thread
specific data if run within the main thread. This means that there
is a chance that the current value will not be enough for the 100
iterations, hence the test flaking.

Fix this by making the test run in its own thread.

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

Added: 


Modified: 
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp

Removed: 




diff  --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp 
b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
index a895032c7c8f..13888cbbe3c3 100644
--- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
+++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
@@ -148,6 +148,7 @@ void GuardedPoolAllocator::uninitTestOnly() {
 State.PageSize));
 FreeSlots = nullptr;
   }
+  *getThreadLocals() = ThreadLocalPackedVariables();
 }
 
 void *GuardedPoolAllocator::allocate(size_t Size) {



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] b40b319 - [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Gabor Marton via llvm-branch-commits

Author: Gabor Marton
Date: 2020-12-02T17:54:48+01:00
New Revision: b40b3196b32110f00b7610851f4ef182ac751ba0

URL: 
https://github.com/llvm/llvm-project/commit/b40b3196b32110f00b7610851f4ef182ac751ba0
DIFF: 
https://github.com/llvm/llvm-project/commit/b40b3196b32110f00b7610851f4ef182ac751ba0.diff

LOG: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to 
functions with BufferSize

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index f8eafde3218d..8a34950ce734 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -457,6 +457,10 @@ class StdLibraryFunctionsChecker
   CaseConstraints.push_back(std::move(CS));
   return *this;
 }
+Summary (const ConstraintSet ) {
+  CaseConstraints.push_back(CS);
+  return *this;
+}
 Summary (ValueConstraintPtr VC) {
   assert(VC->getArgNo() != Ret &&
  "Arg constraint should not refer to the return value");
@@ -1235,9 +1239,8 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   // read()-like functions that never return more than buffer size.
   auto FreadSummary =
   Summary(NoEvalCall)
-  .Case({
-  ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-  })
+  .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+ ReturnValueCondition(WithinRange, Range(0, SizeMax))})
   .ArgConstraint(NotNull(ArgNo(0)))
   .ArgConstraint(NotNull(ArgNo(3)))
   .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(0), /*BufSize=*/ArgNo(1),
@@ -1764,6 +1767,8 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Signature(ArgTypes{ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
   RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(1),
@@ -1779,6 +1784,8 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 ArgTypes{IntTy, ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
 RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(3)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(NotNull(ArgNo(2)))
@@ -1842,6 +1849,9 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Optional Socklen_tPtrRestrictTy = getRestrictTy(Socklen_tPtrTy);
 Optional Socklen_tMax = getMaxValue(Socklen_tTy);
 
+const auto ReturnsZeroOrMinusOne =
+ConstraintSet{ReturnValueCondition(WithinRange, Range(-1, 0))};
+
 // In 'socket.h' of some libc implementations with C99, sockaddr parameter
 // is a transparent union of the underlying sockaddr_ family of pointers
 // instead of being a pointer to struct sockaddr. In these cases, the
@@ -1850,6 +1860,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 // constraints which require pointer types for the sockaddr param.
 auto Accept =
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, IntMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, 
IntMax)));
 if (!addToFunctionSummaryMap(
 "accept",
@@ -1872,6 +1883,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Signature(ArgTypes{IntTy, ConstStructSockaddrPtrTy, Socklen_tTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1884,6 +1896,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   "bind",
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tTy}, RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case(ReturnsZeroOrMinusOne)
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax)))
   .ArgConstraint(
@@ -1897,6 +1910,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
Socklen_tPtrRestrictTy},
   RetType{IntTy}),

[llvm-branch-commits] [llvm] 3900ec6 - [X86] combineX86ShufflesRecursively - remove old FIXME comment. NFC.

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T16:29:38Z
New Revision: 3900ec6f0538368e6bb6ce6743e7e5e0ef13f895

URL: 
https://github.com/llvm/llvm-project/commit/3900ec6f0538368e6bb6ce6743e7e5e0ef13f895
DIFF: 
https://github.com/llvm/llvm-project/commit/3900ec6f0538368e6bb6ce6743e7e5e0ef13f895.diff

LOG: [X86] combineX86ShufflesRecursively - remove old FIXME comment. NFC.

Its unlikely an undef element in a zero vector will be any use, and 
SimplifyDemandedVectorElts now calls combineX86ShufflesRecursively so its 
unlikely we actually have a dependency on these specific elements.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index eefd7219ae3f..1a822c086b6a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -36248,10 +36248,6 @@ static SDValue combineX86ShufflesRecursively(
   // Handle the all undef/zero cases early.
   if (all_of(Mask, [](int Idx) { return Idx == SM_SentinelUndef; }))
 return DAG.getUNDEF(Root.getValueType());
-
-  // TODO - should we handle the mixed zero/undef case as well? Just returning
-  // a zero mask will lose information on undef elements possibly reducing
-  // future combine possibilities.
   if (all_of(Mask, [](int Idx) { return Idx < 0; }))
 return getZeroVector(Root.getSimpleValueType(), Subtarget, DAG,
  SDLoc(Root));



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 793192d - [X86] Regenerate 32-bit merge-consecutive-loads tests

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T16:29:38Z
New Revision: 793192da7f4a0b89fc42247feeca33d456fc2bda

URL: 
https://github.com/llvm/llvm-project/commit/793192da7f4a0b89fc42247feeca33d456fc2bda
DIFF: 
https://github.com/llvm/llvm-project/commit/793192da7f4a0b89fc42247feeca33d456fc2bda.diff

LOG: [X86] Regenerate 32-bit merge-consecutive-loads tests

Avoid use of X32 check prefix - we try to only use that for gnux32 triple tests

Added: 


Modified: 
llvm/test/CodeGen/X86/merge-consecutive-loads-128.ll
llvm/test/CodeGen/X86/merge-consecutive-loads-256.ll
llvm/test/CodeGen/X86/merge-consecutive-loads-512.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/merge-consecutive-loads-128.ll 
b/llvm/test/CodeGen/X86/merge-consecutive-loads-128.ll
index 636e18efb862..f26c19b7dc76 100644
--- a/llvm/test/CodeGen/X86/merge-consecutive-loads-128.ll
+++ b/llvm/test/CodeGen/X86/merge-consecutive-loads-128.ll
@@ -6,8 +6,8 @@
 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f | FileCheck %s 
--check-prefix=AVX
 ;
 ; 32-bit SSE tests to make sure we do reasonable things.
-; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse | FileCheck %s 
--check-prefixes=X32-SSE,X32-SSE1
-; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse4.1 | FileCheck %s 
--check-prefixes=X32-SSE,X32-SSE41
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse | FileCheck %s 
--check-prefixes=X86-SSE,X86-SSE1
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse4.1 | FileCheck %s 
--check-prefixes=X86-SSE,X86-SSE41
 
 define <2 x double> @merge_2f64_f64_23(double* %ptr) nounwind uwtable noinline 
ssp {
 ; SSE-LABEL: merge_2f64_f64_23:
@@ -20,19 +20,19 @@ define <2 x double> @merge_2f64_f64_23(double* %ptr) 
nounwind uwtable noinline s
 ; AVX-NEXT:vmovups 16(%rdi), %xmm0
 ; AVX-NEXT:retq
 ;
-; X32-SSE1-LABEL: merge_2f64_f64_23:
-; X32-SSE1:   # %bb.0:
-; X32-SSE1-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-SSE1-NEXT:fldl 16(%eax)
-; X32-SSE1-NEXT:fldl 24(%eax)
-; X32-SSE1-NEXT:fxch %st(1)
-; X32-SSE1-NEXT:retl
-;
-; X32-SSE41-LABEL: merge_2f64_f64_23:
-; X32-SSE41:   # %bb.0:
-; X32-SSE41-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-SSE41-NEXT:movups 16(%eax), %xmm0
-; X32-SSE41-NEXT:retl
+; X86-SSE1-LABEL: merge_2f64_f64_23:
+; X86-SSE1:   # %bb.0:
+; X86-SSE1-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-SSE1-NEXT:fldl 16(%eax)
+; X86-SSE1-NEXT:fldl 24(%eax)
+; X86-SSE1-NEXT:fxch %st(1)
+; X86-SSE1-NEXT:retl
+;
+; X86-SSE41-LABEL: merge_2f64_f64_23:
+; X86-SSE41:   # %bb.0:
+; X86-SSE41-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-SSE41-NEXT:movups 16(%eax), %xmm0
+; X86-SSE41-NEXT:retl
   %ptr0 = getelementptr inbounds double, double* %ptr, i64 2
   %ptr1 = getelementptr inbounds double, double* %ptr, i64 3
   %val0 = load double, double* %ptr0
@@ -53,35 +53,35 @@ define <2 x i64> @merge_2i64_i64_12(i64* %ptr) nounwind 
uwtable noinline ssp {
 ; AVX-NEXT:vmovups 8(%rdi), %xmm0
 ; AVX-NEXT:retq
 ;
-; X32-SSE1-LABEL: merge_2i64_i64_12:
-; X32-SSE1:   # %bb.0:
-; X32-SSE1-NEXT:pushl %edi
-; X32-SSE1-NEXT:.cfi_def_cfa_offset 8
-; X32-SSE1-NEXT:pushl %esi
-; X32-SSE1-NEXT:.cfi_def_cfa_offset 12
-; X32-SSE1-NEXT:.cfi_offset %esi, -12
-; X32-SSE1-NEXT:.cfi_offset %edi, -8
-; X32-SSE1-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-SSE1-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-SSE1-NEXT:movl 8(%ecx), %edx
-; X32-SSE1-NEXT:movl 12(%ecx), %esi
-; X32-SSE1-NEXT:movl 16(%ecx), %edi
-; X32-SSE1-NEXT:movl 20(%ecx), %ecx
-; X32-SSE1-NEXT:movl %ecx, 12(%eax)
-; X32-SSE1-NEXT:movl %edi, 8(%eax)
-; X32-SSE1-NEXT:movl %esi, 4(%eax)
-; X32-SSE1-NEXT:movl %edx, (%eax)
-; X32-SSE1-NEXT:popl %esi
-; X32-SSE1-NEXT:.cfi_def_cfa_offset 8
-; X32-SSE1-NEXT:popl %edi
-; X32-SSE1-NEXT:.cfi_def_cfa_offset 4
-; X32-SSE1-NEXT:retl $4
-;
-; X32-SSE41-LABEL: merge_2i64_i64_12:
-; X32-SSE41:   # %bb.0:
-; X32-SSE41-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-SSE41-NEXT:movups 8(%eax), %xmm0
-; X32-SSE41-NEXT:retl
+; X86-SSE1-LABEL: merge_2i64_i64_12:
+; X86-SSE1:   # %bb.0:
+; X86-SSE1-NEXT:pushl %edi
+; X86-SSE1-NEXT:.cfi_def_cfa_offset 8
+; X86-SSE1-NEXT:pushl %esi
+; X86-SSE1-NEXT:.cfi_def_cfa_offset 12
+; X86-SSE1-NEXT:.cfi_offset %esi, -12
+; X86-SSE1-NEXT:.cfi_offset %edi, -8
+; X86-SSE1-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-SSE1-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-SSE1-NEXT:movl 8(%ecx), %edx
+; X86-SSE1-NEXT:movl 12(%ecx), %esi
+; X86-SSE1-NEXT:movl 16(%ecx), %edi
+; X86-SSE1-NEXT:movl 20(%ecx), %ecx
+; X86-SSE1-NEXT:movl %ecx, 12(%eax)
+; X86-SSE1-NEXT:movl %edi, 8(%eax)
+; X86-SSE1-NEXT:movl %esi, 4(%eax)
+; X86-SSE1-NEXT:movl %edx, (%eax)
+; X86-SSE1-NEXT:popl %esi
+; X86-SSE1-NEXT:

[llvm-branch-commits] [llvm] 0dab7ec - [X86] EltsFromConsecutiveLoads - pull out repeated NumLoadedElts. NFCI.

2020-12-02 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-02T16:29:37Z
New Revision: 0dab7ecc5dd1e34267dba4cb1595a70f1d08aa58

URL: 
https://github.com/llvm/llvm-project/commit/0dab7ecc5dd1e34267dba4cb1595a70f1d08aa58
DIFF: 
https://github.com/llvm/llvm-project/commit/0dab7ecc5dd1e34267dba4cb1595a70f1d08aa58.diff

LOG: [X86] EltsFromConsecutiveLoads - pull out repeated NumLoadedElts. NFCI.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 3020354ca499..eefd7219ae3f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -8414,7 +8414,8 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, 
ArrayRef Elts,
   assert(LDBase && "Did not find base load for merging consecutive loads");
   unsigned BaseSizeInBits = EltBaseVT.getStoreSizeInBits();
   unsigned BaseSizeInBytes = BaseSizeInBits / 8;
-  int LoadSizeInBits = (1 + LastLoadedElt - FirstLoadedElt) * BaseSizeInBits;
+  int NumLoadedElts = (1 + LastLoadedElt - FirstLoadedElt);
+  int LoadSizeInBits = NumLoadedElts * BaseSizeInBits;
   assert((BaseSizeInBits % 8) == 0 && "Sub-byte element loads detected");
 
   // TODO: Support offsetting the base load.
@@ -8476,7 +8477,7 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, 
ArrayRef Elts,
   // base pointer. If the vector contains zeros, then attempt to shuffle those
   // elements.
   if (FirstLoadedElt == 0 &&
-  (LastLoadedElt == (int)(NumElems - 1) || IsDereferenceable) &&
+  (NumLoadedElts == (int)NumElems || IsDereferenceable) &&
   (IsConsecutiveLoad || IsConsecutiveLoadWithZeros)) {
 if (isAfterLegalize && !TLI.isOperationLegal(ISD::LOAD, VT))
   return SDValue();



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 21d7417 - Remove `-Wunused-result` and `-Wpedantic` warnings from GCC. NFC.

2020-12-02 Thread Michael Liao via llvm-branch-commits

Author: Michael Liao
Date: 2020-12-02T10:53:59-05:00
New Revision: 21d74172dff79378c5c45ca21b7faa70df64f41a

URL: 
https://github.com/llvm/llvm-project/commit/21d74172dff79378c5c45ca21b7faa70df64f41a
DIFF: 
https://github.com/llvm/llvm-project/commit/21d74172dff79378c5c45ca21b7faa70df64f41a.diff

LOG: Remove `-Wunused-result` and `-Wpedantic` warnings from GCC. NFC.

Added: 


Modified: 
llvm/lib/Support/ErrorHandling.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/llvm/lib/Support/ErrorHandling.cpp 
b/llvm/lib/Support/ErrorHandling.cpp
index 23b9f962422e..ce6344284f06 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -170,9 +170,9 @@ void llvm::report_bad_alloc_error(const char *Reason, bool 
GenCrashDiag) {
   // an OOM to stderr and abort.
   const char *OOMMessage = "LLVM ERROR: out of memory\n";
   const char *Newline = "\n";
-  (void)::write(2, OOMMessage, strlen(OOMMessage));
-  (void)::write(2, Reason, strlen(Reason));
-  (void)::write(2, Newline, strlen(Newline));
+  (void)!::write(2, OOMMessage, strlen(OOMMessage));
+  (void)!::write(2, Reason, strlen(Reason));
+  (void)!::write(2, Newline, strlen(Newline));
   abort();
 #endif
 }

diff  --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp 
b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index 2d86b924e4b0..fbf6c2fe4076 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -77,7 +77,7 @@ static Value *findStoredValue(Value *AllocaValue) {
   if (!Store)
 return nullptr;
   return Store->getValueOperand();
-};
+}
 
 TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
   OpenMPIRBuilder OMPBuilder(*M);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] d8949a8 - [hip] Fix host object creation from fatbin

2020-12-02 Thread Michael Liao via llvm-branch-commits

Author: Michael Liao
Date: 2020-12-02T10:36:01-05:00
New Revision: d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0

URL: 
https://github.com/llvm/llvm-project/commit/d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0
DIFF: 
https://github.com/llvm/llvm-project/commit/d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0.diff

LOG: [hip] Fix host object creation from fatbin

- `__hip_fatbin` should a symbol in `.hip_fatbin` section.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIP.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index a06835eee024..fc1103b48a99 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -178,8 +178,7 @@ void 
AMDGCN::Linker::constructGenerateObjFileFromHIPFatBinary(
   ObjStream << "#   HIP Object Generator\n";
   ObjStream << "# *** Automatically generated by Clang ***\n";
   ObjStream << "  .type __hip_fatbin,@object\n";
-  ObjStream << "  .section .hip_fatbin,\"aMS\",@progbits,1\n";
-  ObjStream << "  .data\n";
+  ObjStream << "  .section .hip_fatbin,\"a\",@progbits\n";
   ObjStream << "  .globl __hip_fatbin\n";
   ObjStream << "  .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign))
 << "\n";



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 5c8911d - [CUDA][HIP] Diagnose reference of host variable

2020-12-02 Thread Yaxun Liu via llvm-branch-commits

Author: Yaxun (Sam) Liu
Date: 2020-12-02T10:15:56-05:00
New Revision: 5c8911d0ba3862119d2507aa55b94766263be13b

URL: 
https://github.com/llvm/llvm-project/commit/5c8911d0ba3862119d2507aa55b94766263be13b
DIFF: 
https://github.com/llvm/llvm-project/commit/5c8911d0ba3862119d2507aa55b94766263be13b.diff

LOG: [CUDA][HIP] Diagnose reference of host variable

This patch diagnoses invalid references of global host variables in device,
global, or host device functions.

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

Added: 
clang/test/SemaCUDA/device-use-host-var.cu

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGenCUDA/function-overload.cu
clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f2b2b1d3ab6f..3067c077ddb2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8145,7 +8145,7 @@ def err_global_call_not_config : Error<
   "call to global function %0 not configured">;
 def err_ref_bad_target : Error<
   "reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
-  "function %1 in %select{__device__|__global__|__host__|__host__ __device__}2 
function">;
+  "%select{function|variable}1 %2 in 
%select{__device__|__global__|__host__|__host__ __device__}3 function">;
 def err_ref_bad_target_global_initializer : Error<
   "reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
   "function %1 in global initializer">;

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 12a28ab392f8..0f06adf38f7a 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -743,7 +743,8 @@ bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl 
*Callee) {
 return true;
 
   SemaDiagnosticBuilder(DiagKind, Loc, diag::err_ref_bad_target, Caller, *this)
-  << IdentifyCUDATarget(Callee) << Callee << IdentifyCUDATarget(Caller);
+  << IdentifyCUDATarget(Callee) << /*function*/ 0 << Callee
+  << IdentifyCUDATarget(Caller);
   if (!Callee->getBuiltinID())
 SemaDiagnosticBuilder(DiagKind, Callee->getLocation(),
   diag::note_previous_decl, Caller, *this)

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9c2fc1b9e6dd..527605ac4fb8 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -354,6 +354,24 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef Locs,
 
   diagnoseUseOfInternalDeclInInlineFunction(*this, D, Loc);
 
+  // CUDA/HIP: Diagnose invalid references of host global variables in device
+  // functions. Reference of device global variables in host functions is
+  // allowed through shadow variables therefore it is not diagnosed.
+  if (LangOpts.CUDAIsDevice) {
+auto *FD = dyn_cast_or_null(CurContext);
+auto Target = IdentifyCUDATarget(FD);
+if (FD && Target != CFT_Host) {
+  const auto *VD = dyn_cast(D);
+  if (VD && VD->hasGlobalStorage() && !VD->hasAttr() &&
+  !VD->hasAttr() && !VD->hasAttr() &&
+  !VD->getType()->isCUDADeviceBuiltinSurfaceType() &&
+  !VD->getType()->isCUDADeviceBuiltinTextureType() &&
+  !VD->isConstexpr() && !VD->getType().isConstQualified())
+targetDiag(*Locs.begin(), diag::err_ref_bad_target)
+<< /*host*/ 2 << /*variable*/ 1 << VD << Target;
+}
+  }
+
   if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) {
 if (const auto *VD = dyn_cast(D))
   checkDeviceDecl(VD, Loc);

diff  --git a/clang/test/CodeGenCUDA/function-overload.cu 
b/clang/test/CodeGenCUDA/function-overload.cu
index c82b2e96f6c3..9677a5b43b8c 100644
--- a/clang/test/CodeGenCUDA/function-overload.cu
+++ b/clang/test/CodeGenCUDA/function-overload.cu
@@ -12,6 +12,9 @@
 #include "Inputs/cuda.h"
 
 // Check constructors/destructors for D/H functions
+#ifdef __CUDA_ARCH__
+__device__
+#endif
 int x;
 struct s_cd_dh {
   __host__ s_cd_dh() { x = 11; }

diff  --git a/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp 
b/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
index 77ea3d485c8a..16600d15f2c4 100644
--- a/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
+++ b/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
@@ -124,7 +124,7 @@ __attribute__((device)) void test_shared64() {
   val = __builtin_amdgcn_atomic_dec64(, val, __ATOMIC_SEQ_CST, 
"workgroup");
 }
 
-__UINT32_TYPE__ global_val32;
+__attribute__((device)) __UINT32_TYPE__ global_val32;
 __attribute__((device)) void test_global32() {
   // CHECK-LABEL: test_global32
   // CHECK: %0 = load i32, i32* addrspacecast (i32 addrspace(1)* @global_val32 
to i32*), align 4
@@ -138,7 

[llvm-branch-commits] [clang] cd95338 - [CUDA][HIP] Fix capturing reference to host variable

2020-12-02 Thread Yaxun Liu via llvm-branch-commits

Author: Yaxun (Sam) Liu
Date: 2020-12-02T10:14:46-05:00
New Revision: cd95338ee3022bffd658e52cd3eb9419b4c218ca

URL: 
https://github.com/llvm/llvm-project/commit/cd95338ee3022bffd658e52cd3eb9419b4c218ca
DIFF: 
https://github.com/llvm/llvm-project/commit/cd95338ee3022bffd658e52cd3eb9419b4c218ca.diff

LOG: [CUDA][HIP] Fix capturing reference to host variable

In C++ when a reference variable is captured by copy, the lambda
is supposed to make a copy of the referenced variable in the captures
and refer to the copy in the lambda. Therefore, it is valid to capture
a reference to a host global variable in a device lambda since the
device lambda will refer to the copy of the host global variable instead
of access the host global variable directly.

However, clang tries to avoid capturing of reference to a host global variable
if it determines the use of the reference variable in the lambda function is
not odr-use. Clang also tries to emit load of the reference to a global variable
as load of the global variable if it determines that the reference variable is
a compile-time constant.

For a device lambda to capture a reference variable to host global variable
and use the captured value, clang needs to be taught that in such cases the use 
of the reference
variable is odr-use and the reference variable is not compile-time constant.

This patch fixes that.

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

Added: 
clang/test/CodeGenCUDA/lambda-reference-var.cu

Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 325801c83de9..92d0cba7a733 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1522,6 +1522,29 @@ CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) 
{
   if (result.HasSideEffects)
 return ConstantEmission();
 
+  // In CUDA/HIP device compilation, a lambda may capture a reference variable
+  // referencing a global host variable by copy. In this case the lambda should
+  // make a copy of the value of the global host variable. The DRE of the
+  // captured reference variable cannot be emitted as load from the host
+  // global variable as compile time constant, since the host variable is not
+  // accessible on device. The DRE of the captured reference variable has to be
+  // loaded from captures.
+  if (CGM.getLangOpts().CUDAIsDevice &&
+  refExpr->refersToEnclosingVariableOrCapture()) {
+auto *MD = dyn_cast_or_null(CurCodeDecl);
+if (MD && MD->getParent()->isLambda() &&
+MD->getOverloadedOperator() == OO_Call) {
+  const APValue::LValueBase  = result.Val.getLValueBase();
+  if (const ValueDecl *D = base.dyn_cast()) {
+if (const VarDecl *VD = dyn_cast(D)) {
+  if (!VD->hasAttr()) {
+return ConstantEmission();
+  }
+}
+  }
+}
+  }
+
   // Emit as a constant.
   auto C = ConstantEmitter(*this).emitAbstract(refExpr->getLocation(),
result.Val, resultType);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 88dab26f2e3b..9c2fc1b9e6dd 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1934,6 +1934,35 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, 
ExprValueKind VK,
   TemplateArgs);
 }
 
+// CUDA/HIP: Check whether a captured reference variable is referencing a
+// host variable in a device or host device lambda.
+static bool isCapturingReferenceToHostVarInCUDADeviceLambda(const Sema ,
+VarDecl *VD) {
+  if (!S.getLangOpts().CUDA || !VD->hasInit())
+return false;
+  assert(VD->getType()->isReferenceType());
+
+  // Check whether the reference variable is referencing a host variable.
+  auto *DRE = dyn_cast(VD->getInit());
+  if (!DRE)
+return false;
+  auto *Referee = dyn_cast(DRE->getDecl());
+  if (!Referee || !Referee->hasGlobalStorage() ||
+  Referee->hasAttr())
+return false;
+
+  // Check whether the current function is a device or host device lambda.
+  // Check whether the reference variable is a capture by getDeclContext()
+  // since refersToEnclosingVariableOrCapture() is not ready at this point.
+  auto *MD = dyn_cast_or_null(S.CurContext);
+  if (MD && MD->getParent()->isLambda() &&
+  MD->getOverloadedOperator() == OO_Call && MD->hasAttr() 
&&
+  VD->getDeclContext() != MD)
+return true;
+
+  return false;
+}
+
 NonOdrUseReason Sema::getNonOdrUseReasonInCurrentContext(ValueDecl *D) {
   // A declaration named in an unevaluated operand never constitutes an 
odr-use.
   if (isUnevaluatedContext())
@@ -1943,9 +1972,16 @@ NonOdrUseReason 
Sema::getNonOdrUseReasonInCurrentContext(ValueDecl *D) {
   //   A variable x whose name appears as a 

[llvm-branch-commits] [compiler-rt] 5045b83 - [PowerPC] Mark sanitizer test case unsupported for powerpc64

2020-12-02 Thread Ahsan Saghir via llvm-branch-commits

Author: Ahsan Saghir
Date: 2020-12-02T09:03:28-06:00
New Revision: 5045b831a3b9c364d6ef0f09c7a773ca451ae1cc

URL: 
https://github.com/llvm/llvm-project/commit/5045b831a3b9c364d6ef0f09c7a773ca451ae1cc
DIFF: 
https://github.com/llvm/llvm-project/commit/5045b831a3b9c364d6ef0f09c7a773ca451ae1cc.diff

LOG: [PowerPC] Mark sanitizer test case unsupported for powerpc64

The author of "https://reviews.llvm.org/D92428; marked
'resize_tls_dynamic.cpp' with XFAIL for powerpc64 since
it fails on a bunch of PowerPC buildbots. However, the
original test case passes on clang-ppc64le-rhel bot. So
marking this as XFAIL makes this bot to fail as the test
case passes unexpectedly. We are marking this unsupported
on all PowerPC64 for now until it is fixed for all the
PowerPC buildbots.

Added: 


Modified: 
compiler-rt/test/sanitizer_common/TestCases/Linux/resize_tls_dynamic.cpp

Removed: 




diff  --git 
a/compiler-rt/test/sanitizer_common/TestCases/Linux/resize_tls_dynamic.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Linux/resize_tls_dynamic.cpp
index fd8f73ca713b..11c0e48a855e 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/resize_tls_dynamic.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/resize_tls_dynamic.cpp
@@ -9,7 +9,7 @@
 // UNSUPPORTED: lsan, ubsan, android
 
 // FIXME: Investigate
-// XFAIL: powerpc64 && tsan
+// UNSUPPORTED: powerpc64
 
 #include 
 
@@ -55,4 +55,4 @@ extern "C" void StoreToTLS(char c) {
 // CHECK-NEXT: DTLS_NextBlock [[DTLS]] 0
 // CHECK:  DTLS_Find [[DTLS:0x[a-f0-9]+]] 255
 // CHECK-NEXT: DTLS_NextBlock [[DTLS]] 1
-// CHECK-NOT:  DTLS_NextBlock
\ No newline at end of file
+// CHECK-NOT:  DTLS_NextBlock



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] ca63439 - [mac/lld] Make --reproduce work with thin archives

2020-12-02 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-02T09:48:31-05:00
New Revision: ca634393fc797f766a68e8537e20a1bf0ec8ca94

URL: 
https://github.com/llvm/llvm-project/commit/ca634393fc797f766a68e8537e20a1bf0ec8ca94
DIFF: 
https://github.com/llvm/llvm-project/commit/ca634393fc797f766a68e8537e20a1bf0ec8ca94.diff

LOG: [mac/lld] Make --reproduce work with thin archives

See http://reviews.llvm.org/rL268229 and
http://reviews.llvm.org/rL313832 which did the same for the ELF port.

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

Added: 
lld/test/MachO/reproduce-thin-archives.s

Modified: 
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index c3b8224750ab..426101f4f9e1 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -24,6 +24,7 @@
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/LLVM.h"
 #include "lld/Common/Memory.h"
+#include "lld/Common/Reproduce.h"
 #include "lld/Common/Version.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringExtras.h"
@@ -230,11 +231,17 @@ static std::vector 
getArchiveMembers(MemoryBufferRef mb) {
 
   std::vector v;
   Error err = Error::success();
+
+  // Thin archives refer to .o files, so --reproduces needs the .o files too.
+  bool addToTar = archive->isThin() && tar;
+
   for (const Archive::Child  : archive->children(err)) {
 MemoryBufferRef mbref =
 CHECK(c.getMemoryBufferRef(),
   mb.getBufferIdentifier() +
   ": could not get the buffer for a child of the archive");
+if (addToTar)
+  tar->append(relativeToRoot(check(c.getFullName())), mbref.getBuffer());
 uint32_t modTime = toTimeT(
 CHECK(c.getLastModified(), mb.getBufferIdentifier() +
": could not get the modification "

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 3a87a42ded08..4fd9873bcbd3 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -610,6 +610,9 @@ void ArchiveFile::fetch(const object::Archive::Symbol ) 
{
 ": could not get the buffer for the member defining symbol " +
 toMachOString(sym));
 
+  if (tar && c.getParent()->isThin())
+tar->append(relativeToRoot(CHECK(c.getFullName(), this)), mb.getBuffer());
+
   uint32_t modTime = toTimeT(
   CHECK(c.getLastModified(), toString(this) +
  ": could not get the modification time "

diff  --git a/lld/test/MachO/reproduce-thin-archives.s 
b/lld/test/MachO/reproduce-thin-archives.s
new file mode 100644
index ..9dee3f400e06
--- /dev/null
+++ b/lld/test/MachO/reproduce-thin-archives.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+
+# RUN: rm -rf %t.dir
+# RUN: mkdir -p %t.dir
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.dir/foo.o
+# RUN: cd %t.dir
+# RUN: llvm-ar rcsT foo.a foo.o
+
+# RUN: %lld foo.a -o /dev/null --reproduce repro.tar
+# RUN: tar tf repro.tar | FileCheck -DPATH='repro/%:t.dir' %s
+
+# RUN: %lld -all_load foo.a -o /dev/null --reproduce repro2.tar
+# RUN: tar tf repro2.tar | FileCheck -DPATH='repro2/%:t.dir' %s
+
+# CHECK-DAG: [[PATH]]/foo.a
+# CHECK-DAG: [[PATH]]/foo.o
+
+.globl _main
+_main:
+  nop



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] c4a0405 - Add `Operation* OpState::operator->()` to provide more convenient access to members of Operation.

2020-12-02 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2020-12-02T15:46:20+01:00
New Revision: c4a04059026b98e8c23981f1195a61494a661cdb

URL: 
https://github.com/llvm/llvm-project/commit/c4a04059026b98e8c23981f1195a61494a661cdb
DIFF: 
https://github.com/llvm/llvm-project/commit/c4a04059026b98e8c23981f1195a61494a661cdb.diff

LOG: Add `Operation* OpState::operator->()` to provide more convenient access 
to members of Operation.

Given that OpState already implicit converts to Operator*, this seems 
reasonable.

The alternative would be to add more functions to OpState which forward to 
Operation.

Reviewed By: rriddle, ftynse

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

Added: 


Modified: 
mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
mlir/include/mlir/Dialect/Vector/VectorTransforms.h
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/Interfaces/VectorInterfaces.td
mlir/lib/Analysis/AffineAnalysis.cpp
mlir/lib/Analysis/BufferAliasAnalysis.cpp
mlir/lib/Analysis/Utils.cpp
mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp
mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp
mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/lib/Dialect/SCF/SCF.cpp
mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp
mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/Parser/Parser.cpp
mlir/lib/Transforms/Inliner.cpp
mlir/lib/Transforms/LoopFusion.cpp
mlir/lib/Transforms/SCCP.cpp
mlir/lib/Transforms/Utils/InliningUtils.cpp
mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
mlir/lib/Transforms/Utils/LoopUtils.cpp
mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
mlir/test/lib/Transforms/TestLoopFusion.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

Removed: 




diff  --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp 
b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
index 6daccaef7cd3..46d8fe40e5d4 100644
--- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
@@ -39,13 +39,13 @@ static Value insertAllocAndDealloc(MemRefType type, 
Location loc,
   auto alloc = rewriter.create(loc, type);
 
   // Make sure to allocate at the beginning of the block.
-  auto *parentBlock = alloc.getOperation()->getBlock();
-  alloc.getOperation()->moveBefore(>front());
+  auto *parentBlock = alloc->getBlock();
+  alloc->moveBefore(>front());
 
   // Make sure to deallocate this alloc at the end of the block. This is fine
   // as toy functions have no control flow.
   auto dealloc = rewriter.create(loc, alloc);
-  dealloc.getOperation()->moveBefore(>back());
+  dealloc->moveBefore(>back());
   return alloc;
 }
 

diff  --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp 
b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
index 14f68e6176b5..2089b6579ccb 100644
--- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
@@ -39,13 +39,13 @@ static 

[llvm-branch-commits] [llvm] 56fd29e - [SLP] use 'match' for binop/select; NFC

2020-12-02 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-02T09:04:08-05:00
New Revision: 56fd29e93bd133d354e7e639bca1c025162e91ac

URL: 
https://github.com/llvm/llvm-project/commit/56fd29e93bd133d354e7e639bca1c025162e91ac
DIFF: 
https://github.com/llvm/llvm-project/commit/56fd29e93bd133d354e7e639bca1c025162e91ac.diff

LOG: [SLP] use 'match' for binop/select; NFC

This might be a small improvement in readability, but the
real motivation is to make it easier to adapt the code to
deal with intrinsics like 'maxnum' and/or integer min/max.

There is potentially help in doing that with D92086, but
we might also just add specialized wrappers here to deal
with the expected patterns.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index bfec51f0ada6..66d736974fbc 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7463,9 +7463,10 @@ static bool tryToVectorizeHorReductionOrInstOperands(
 Instruction *Inst;
 unsigned Level;
 std::tie(Inst, Level) = Stack.pop_back_val();
-auto *BI = dyn_cast(Inst);
-auto *SI = dyn_cast(Inst);
-if (BI || SI) {
+Value *B0, *B1;
+bool IsBinop = match(Inst, m_BinOp(m_Value(B0), m_Value(B1)));
+bool IsSelect = match(Inst, m_Select(m_Value(), m_Value(), m_Value()));
+if (IsBinop || IsSelect) {
   HorizontalReduction HorRdx;
   if (HorRdx.matchAssociativeReduction(P, Inst)) {
 if (HorRdx.tryToReduce(R, TTI)) {
@@ -7476,10 +7477,10 @@ static bool tryToVectorizeHorReductionOrInstOperands(
   continue;
 }
   }
-  if (P && BI) {
-Inst = dyn_cast(BI->getOperand(0));
+  if (P && IsBinop) {
+Inst = dyn_cast(B0);
 if (Inst == P)
-  Inst = dyn_cast(BI->getOperand(1));
+  Inst = dyn_cast(B1);
 if (!Inst) {
   // Set P to nullptr to avoid re-analysis of phi node in
   // matchAssociativeReduction function unless this is the root node.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 240dd92 - [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-02 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-12-02T14:59:41+01:00
New Revision: 240dd92432ebbfbf24ef85779f2cdf93e6ddf605

URL: 
https://github.com/llvm/llvm-project/commit/240dd92432ebbfbf24ef85779f2cdf93e6ddf605
DIFF: 
https://github.com/llvm/llvm-project/commit/240dd92432ebbfbf24ef85779f2cdf93e6ddf605.diff

LOG: [OpenMPIRBuilder] forward arguments as pointers to outlined function

OpenMPIRBuilder::createParallel outlines the body region of the parallel
construct into a new function that accepts any value previously defined outside
the region as a function argument. This function is called back by OpenMP
runtime function __kmpc_fork_call, which expects trailing arguments to be
pointers. If the region uses a value that is not of a pointer type, e.g. a
struct, the produced code would be invalid. In such cases, make createParallel
emit IR that stores the value on stack and pass the pointer to the outlined
function instead. The outlined function then loads the value back and uses as
normal.

Reviewed By: jdoerfert, llitchev

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/parallel_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 2fb4144930df..5e8d98cfe5ef 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1693,7 +1693,7 @@ void CodeGenFunction::EmitOMPParallelDirective(const 
OMPParallelDirective ) {
 //
 // TODO: This defaults to shared right now.
 auto PrivCB = [](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
- llvm::Value , llvm::Value *) {
+ llvm::Value &, llvm::Value , llvm::Value *) {
   // The next line is appropriate only for variables (Val) with the
   // data-sharing attribute "shared".
   ReplVal = 

diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index bceab0637f6a..83561ce6f6a8 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -133,22 +133,26 @@ int main (int argc, char **argv) {
 // CHECK-DEBUG-DAG:   define internal void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i64 [[VLA_SIZE:%.+]], i32* {{.+}} 
[[VLA_ADDR:%[^)]+]])
 // CHECK-DEBUG-DAG:   call void [[OMP_OUTLINED_DEBUG]]
 
+// Note that OpenMPIRBuilder puts the trailing arguments in a 
diff erent order:
+// arguments that are wrapped into additional pointers precede the other
+// arguments. This is expected and not problematic because both the call and 
the
+// function are generated from the same place, and the function is internal.
 // ALL:   define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** %argc)
 // ALL:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
-// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
+// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i{{64|32}}*, i8***)* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i{{64|32}}* %{{.+}}, i8*** 
[[ARGC_ADDR]])
 // ALL:  ret i32 0
 // ALL-NEXT:  }
 // ALL-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
 
 // CHECK-DEBUG:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.*}}, i32 2, void (i32*, 
i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] to 
void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
-// IRBUILDER-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.*}}, i32 2, void (i32*, 
i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] to 
void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
+// IRBUILDER-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) 

[llvm-branch-commits] [llvm] 437c465 - [ThinLTO] Import symver directives for imported symbols (PR48214)

2020-12-02 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2020-12-02T14:56:43+01:00
New Revision: 437c4653855fbbe47a860ae95eb445fd004aa4de

URL: 
https://github.com/llvm/llvm-project/commit/437c4653855fbbe47a860ae95eb445fd004aa4de
DIFF: 
https://github.com/llvm/llvm-project/commit/437c4653855fbbe47a860ae95eb445fd004aa4de.diff

LOG: [ThinLTO] Import symver directives for imported symbols (PR48214)

When importing symbols from another module, also import any
corresponding symver directives.

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

Added: 
llvm/test/ThinLTO/X86/Inputs/import-symver-foo.ll
llvm/test/ThinLTO/X86/import-symver.ll

Modified: 
llvm/lib/Linker/CMakeLists.txt
llvm/lib/Linker/IRMover.cpp
llvm/utils/gn/secondary/llvm/lib/Linker/BUILD.gn

Removed: 




diff  --git a/llvm/lib/Linker/CMakeLists.txt b/llvm/lib/Linker/CMakeLists.txt
index 5abfc8c02efa..a2a71de975b8 100644
--- a/llvm/lib/Linker/CMakeLists.txt
+++ b/llvm/lib/Linker/CMakeLists.txt
@@ -10,6 +10,7 @@ add_llvm_component_library(LLVMLinker
 
   LINK_COMPONENTS
   Core
+  Object
   Support
   TransformUtils
   )

diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 5a67266a9f46..b7a9bb1a 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -17,6 +17,7 @@
 #include "llvm/IR/GVMaterializer.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/TypeFinder.h"
+#include "llvm/Object/ModuleSymbolTable.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Transforms/Utils/Cloning.h"
 #include 
@@ -1438,12 +1439,6 @@ Error IRLinker::run() {
 
   DstM.setTargetTriple(SrcTriple.merge(DstTriple));
 
-  // Append the module inline asm string.
-  if (!IsPerformingImport && !SrcM->getModuleInlineAsm().empty()) {
-DstM.appendModuleInlineAsm(adjustInlineAsm(SrcM->getModuleInlineAsm(),
-   SrcTriple));
-  }
-
   // Loop over all of the linked values to compute type mappings.
   computeTypeMapping();
 
@@ -1474,6 +1469,24 @@ Error IRLinker::run() {
   // are properly remapped.
   linkNamedMDNodes();
 
+  if (!IsPerformingImport && !SrcM->getModuleInlineAsm().empty()) {
+// Append the module inline asm string.
+DstM.appendModuleInlineAsm(adjustInlineAsm(SrcM->getModuleInlineAsm(),
+   SrcTriple));
+  } else if (IsPerformingImport) {
+// Import any symver directives for symbols in DstM.
+ModuleSymbolTable::CollectAsmSymvers(*SrcM,
+ [&](StringRef Name, StringRef Alias) {
+  if (DstM.getNamedValue(Name)) {
+SmallString<256> S(".symver ");
+S += Name;
+S += ", ";
+S += Alias;
+DstM.appendModuleInlineAsm(S);
+  }
+});
+  }
+
   // Merge the module flags into the DstM module.
   return linkModuleFlagsMetadata();
 }

diff  --git a/llvm/test/ThinLTO/X86/Inputs/import-symver-foo.ll 
b/llvm/test/ThinLTO/X86/Inputs/import-symver-foo.ll
new file mode 100644
index ..95545b433f98
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/Inputs/import-symver-foo.ll
@@ -0,0 +1,12 @@
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+module asm ".symver bar, bar@BAR_1.2.3"
+
+declare dso_local i32 @bar()
+
+define dso_local i32 @foo() {
+entry:
+  %call = tail call i32 @bar()
+  ret i32 %call
+}

diff  --git a/llvm/test/ThinLTO/X86/import-symver.ll 
b/llvm/test/ThinLTO/X86/import-symver.ll
new file mode 100644
index ..556c4fd992f0
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/import-symver.ll
@@ -0,0 +1,28 @@
+; RUN: opt -thinlto-bc %s -o %t1.bc
+; RUN: opt -thinlto-bc %p/Inputs/import-symver-foo.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink %t1.bc %t2.bc -o %t3.index.bc
+
+; RUN: llvm-lto -thinlto-action=import -exported-symbol=main %t1.bc 
-thinlto-index=%t3.index.bc
+; RUN: llvm-dis %t1.bc.thinlto.imported.bc -o - | FileCheck 
--check-prefix=IMPORT %s
+
+; RUN: llvm-lto -thinlto-action=import -exported-symbol=main 
-import-instr-limit=0 %t1.bc -thinlto-index=%t3.index.bc
+; RUN: llvm-dis %t1.bc.thinlto.imported.bc -o - | FileCheck 
--check-prefix=NOIMPORT %s
+
+; When @bar gets imported, the symver must be imported too.
+; IMPORT: module asm ".symver bar, bar@BAR_1.2.3"
+; IMPORT: declare dso_local i32 @bar()
+
+; When @bar isn't imported, the symver is also not imported.
+; NOIMPORT-NOT: module asm
+; NOIMPORT-NOT: declare dso_local i32 @bar()
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare dso_local i32 @foo()
+
+define dso_local i32 @main() {
+entry:
+  %call = tail call i32 @foo()
+  ret i32 %call
+}

diff  --git a/llvm/utils/gn/secondary/llvm/lib/Linker/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/Linker/BUILD.gn
index 

[llvm-branch-commits] [llvm] 45d8a78 - Simplify append to module inline asm string in IRLinker::run()

2020-12-02 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2020-12-02T14:56:43+01:00
New Revision: 45d8a7843253ec68367c26114a2aa6bff2a7a4bb

URL: 
https://github.com/llvm/llvm-project/commit/45d8a7843253ec68367c26114a2aa6bff2a7a4bb
DIFF: 
https://github.com/llvm/llvm-project/commit/45d8a7843253ec68367c26114a2aa6bff2a7a4bb.diff

LOG: Simplify append to module inline asm string in IRLinker::run()

This also removes the empty extra "module asm" that would be created,
and updates the test to reflect that while making it more explicit.

Broken out from https://reviews.llvm.org/D92335

Added: 


Modified: 
llvm/lib/Linker/IRMover.cpp
llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll

Removed: 




diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index d55c53eef23d..5a67266a9f46 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1440,13 +1440,8 @@ Error IRLinker::run() {
 
   // Append the module inline asm string.
   if (!IsPerformingImport && !SrcM->getModuleInlineAsm().empty()) {
-std::string SrcModuleInlineAsm = 
adjustInlineAsm(SrcM->getModuleInlineAsm(),
- SrcTriple);
-if (DstM.getModuleInlineAsm().empty())
-  DstM.setModuleInlineAsm(SrcModuleInlineAsm);
-else
-  DstM.setModuleInlineAsm(DstM.getModuleInlineAsm() + "\n" +
-  SrcModuleInlineAsm);
+DstM.appendModuleInlineAsm(adjustInlineAsm(SrcM->getModuleInlineAsm(),
+   SrcTriple));
   }
 
   // Loop over all of the linked values to compute type mappings.

diff  --git a/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll 
b/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll
index 13779f37ffa0..5e12a8c88d90 100644
--- a/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll
+++ b/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll
@@ -9,12 +9,11 @@ target triple = "armv7-linux-gnueabihf"
 
 module asm "add r1, r2, r2"
 
-; CHECK: .text
-; CHECK-NEXT: .balign 4
-; CHECK-NEXT: .arm
-; CHECK-NEXT: add r1, r2, r2
-; CHECK-NEXT: module asm
-; CHECK-NEXT: .text
-; CHECK-NEXT: .balign 2
-; CHECK-NEXT: .thumb
-; CHECK-NEXT: orn r1, r2, r2
+; CHECK:  module asm ".text"
+; CHECK-NEXT: module asm ".balign 4"
+; CHECK-NEXT: module asm ".arm"
+; CHECK-NEXT: module asm "add r1, r2, r2"
+; CHECK-NEXT: module asm ".text"
+; CHECK-NEXT: module asm ".balign 2"
+; CHECK-NEXT: module asm ".thumb"
+; CHECK-NEXT: module asm "orn r1, r2, r2"



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] dd0159b - [VE] Add vand, vor, and vxor intrinsic instructions

2020-12-02 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-02T22:52:54+09:00
New Revision: dd0159bd814132473fceaba43b864c6db64c96ab

URL: 
https://github.com/llvm/llvm-project/commit/dd0159bd814132473fceaba43b864c6db64c96ab
DIFF: 
https://github.com/llvm/llvm-project/commit/dd0159bd814132473fceaba43b864c6db64c96ab.diff

LOG: [VE] Add vand, vor, and vxor intrinsic instructions

Add vand, vor, and vxor intrinsic instructions and regression tests.

Reviewed By: simoll

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

Added: 
llvm/test/CodeGen/VE/VELIntrinsics/vand.ll
llvm/test/CodeGen/VE/VELIntrinsics/vor.ll
llvm/test/CodeGen/VE/VELIntrinsics/vxor.ll

Modified: 
llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td 
b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
index 10758eaf483a..7c3b523b16b4 100644
--- a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
+++ b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
@@ -359,3 +359,39 @@ let TargetPrefix = "ve" in def int_ve_vl_vminsl_vsvl : 
GCCBuiltin<"__builtin_ve_
 let TargetPrefix = "ve" in def int_ve_vl_vminsl_vsvvl : 
GCCBuiltin<"__builtin_ve_vl_vminsl_vsvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType], 
[IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_vminsl_vvvmvl : 
GCCBuiltin<"__builtin_ve_vl_vminsl_vvvmvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_vminsl_vsvmvl : 
GCCBuiltin<"__builtin_ve_vl_vminsl_vsvmvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vand_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vand_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vand_l : 
GCCBuiltin<"__builtin_ve_vl_vand_l">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType], 
[IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vand_vsvl : 
GCCBuiltin<"__builtin_ve_vl_vand_vsvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vand_vsvvl : 
GCCBuiltin<"__builtin_ve_vl_vand_vsvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType], 
[IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vand_vvvmvl : 
GCCBuiltin<"__builtin_ve_vl_vand_vvvmvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vand_vsvmvl : 
GCCBuiltin<"__builtin_ve_vl_vand_vsvmvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_pvand_vvvl : 
GCCBuiltin<"__builtin_ve_vl_pvand_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_pvand_l : 
GCCBuiltin<"__builtin_ve_vl_pvand_l">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType], 
[IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_pvand_vsvl : 
GCCBuiltin<"__builtin_ve_vl_pvand_vsvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_pvand_vsvvl : 
GCCBuiltin<"__builtin_ve_vl_pvand_vsvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType], 
[IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_pvand_vvvMvl : 
GCCBuiltin<"__builtin_ve_vl_pvand_vvvMvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_pvand_vsvMvl : 
GCCBuiltin<"__builtin_ve_vl_pvand_vsvMvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vor_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vor_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vor_l : 
GCCBuiltin<"__builtin_ve_vl_vor_l">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType], 
[IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vor_vsvl : 
GCCBuiltin<"__builtin_ve_vl_vor_vsvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vor_vsvvl : 
GCCBuiltin<"__builtin_ve_vl_vor_vsvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType], 
[IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vor_vvvmvl : 
GCCBuiltin<"__builtin_ve_vl_vor_vvvmvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vor_vsvmvl : 
GCCBuiltin<"__builtin_ve_vl_vor_vsvmvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType, LLVMType, 
LLVMType], [IntrNoMem]>;
+let TargetPrefix 

[llvm-branch-commits] [llvm] f03c21d - [SystemZ] Adding extra extended mnemonics for SystemZ target

2020-12-02 Thread Kai Nacke via llvm-branch-commits

Author: Anirudh Prasad
Date: 2020-12-02T08:25:31-05:00
New Revision: f03c21df7b845e2ffcef42f242764f36603fdbb4

URL: 
https://github.com/llvm/llvm-project/commit/f03c21df7b845e2ffcef42f242764f36603fdbb4
DIFF: 
https://github.com/llvm/llvm-project/commit/f03c21df7b845e2ffcef42f242764f36603fdbb4.diff

LOG: [SystemZ] Adding extra extended mnemonics for SystemZ target

This patch consists of the addition of some common additional
extended mnemonics to the SystemZ target.

- These are jnop, jct, jctg, jas, jasl, jxh, jxhg, jxle,
  jxleg, bru, brul, br*, br*l.
- These mnemonics and the instructions they map to are
  defined here, Chapter 4 - Branching with extended
  mnemonic codes.
- Except for jnop (which is a variant of brc 0, label), every
  other mnemonic is marked as a MnemonicAlias since there is
  already a "defined" instruction with the same encoding
  and/or condition mask values.
- brc 0, label doesn't have a defined extended mnemonic, thus
  jnop is defined using as an InstAlias. Furthermore, the
  applyMnemonicAliases function is called in the overridden
  parseInstruction function in SystemZAsmParser.cpp to ensure
  any mnemonic aliases are applied before any further
  processing on the instruction is done.

Reviewed By: uweigand

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

Added: 


Modified: 
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
llvm/lib/Target/SystemZ/SystemZInstrFormats.td
llvm/lib/Target/SystemZ/SystemZInstrInfo.td
llvm/test/MC/SystemZ/insn-bad.s
llvm/test/MC/SystemZ/insn-good.s

Removed: 




diff  --git a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp 
b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
index 8da460381783..2b815a366ccd 100644
--- a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
+++ b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
@@ -1322,6 +1322,11 @@ OperandMatchResultTy 
SystemZAsmParser::tryParseRegister(unsigned ,
 bool SystemZAsmParser::ParseInstruction(ParseInstructionInfo ,
 StringRef Name, SMLoc NameLoc,
 OperandVector ) {
+
+  // Apply mnemonic aliases first, before doing anything else, in
+  // case the target uses it.
+  applyMnemonicAliases(Name, getAvailableFeatures(), 0 /*VariantID*/);
+
   Operands.push_back(SystemZOperand::createToken(Name, NameLoc));
 
   // Read the remaining operands.

diff  --git a/llvm/lib/Target/SystemZ/SystemZInstrFormats.td 
b/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
index 4aac2eec655f..95e94c4c8e1c 100644
--- a/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
+++ b/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
@@ -1911,6 +1911,11 @@ class ICV
 !cast("IntCondVariant"#name).suffix,
 !cast("IntCondVariant"#name).alternate>;
 
+// Defines a class that makes it easier to define
+// a MnemonicAlias when CondVariant's are involved.
+class MnemonicCondBranchAlias
+  : MnemonicAlias;
+
 
//===--===//
 // Instruction definitions with semantics
 
//===--===//

diff  --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td 
b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td
index d11404ed7c1b..c37e30556ddb 100644
--- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td
+++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td
@@ -110,6 +110,12 @@ let isAsmParserOnly = 1, hasNoSchedulingInfo = 1, M1 = 0, 
XBD2 = 0 in
 def NOPR : InstAlias<"nopr\t$R", (BCRAsm 0, GR64:$R), 0>;
 def NOPR_bare : InstAlias<"nopr", (BCRAsm 0, R0D), 0>;
 
+// An alias of BRC 0, label
+def JNOP : InstAlias<"jnop\t$RI2", (BRCAsm 0, brtarget16:$RI2), 0>;
+
+// An alias of BRCL 0, label
+def JGNOP : InstAlias<"jgnop\t$RI2", (BRCLAsm 0, brtarget32:$RI2), 0>;
+
 // Fused compare-and-branch instructions.
 //
 // These instructions do not use or clobber the condition codes.
@@ -2338,3 +2344,25 @@ defm : BlockLoadStore;
 defm : BlockLoadStore;
+
+//===--===//
+// Mnemonic Aliases
+//===--===//
+
+def JCT   : MnemonicAlias<"jct", "brct">;
+def JCTG  : MnemonicAlias<"jctg", "brctg">;
+def JAS   : MnemonicAlias<"jas", "bras">;
+def JASL  : MnemonicAlias<"jasl", "brasl">;
+def JXH   : MnemonicAlias<"jxh", "brxh">;
+def JXLE  : MnemonicAlias<"jxle", "brxle">;
+def JXHG  : MnemonicAlias<"jxhg", "brxhg">;
+def JXLEG : MnemonicAlias<"jxleg", "brxlg">;
+
+def BRU   : MnemonicAlias<"bru", "j">;
+def BRUL  : MnemonicAlias<"brul", "jg">;
+
+foreach V = [ "E", "NE", "H", "NH", "L", "NL", "HE", "NHE", "LE", "NLE",
+  "Z", "NZ", "P", "NP", "M", "NM", "LH", "NLH", "O", "NO" ] in {
+  def BRUAsm#V : MnemonicCondBranchAlias , "br#", "j#">;
+  def BRULAsm#V : 

[llvm-branch-commits] [llvm] 71bd59f - [SVE] Add support for scalable vectors with vectorize.scalable.enable loop attribute

2020-12-02 Thread David Sherwood via llvm-branch-commits

Author: David Sherwood
Date: 2020-12-02T13:23:43Z
New Revision: 71bd59f0cb6db0211418b07127e8b311d944e2c2

URL: 
https://github.com/llvm/llvm-project/commit/71bd59f0cb6db0211418b07127e8b311d944e2c2
DIFF: 
https://github.com/llvm/llvm-project/commit/71bd59f0cb6db0211418b07127e8b311d944e2c2.diff

LOG: [SVE] Add support for scalable vectors with vectorize.scalable.enable loop 
attribute

In this patch I have added support for a new loop hint called
vectorize.scalable.enable that says whether we should enable scalable
vectorization or not. If a user wants to instruct the compiler to
vectorize a loop with scalable vectors they can now do this as
follows:

  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !2
  ...
  !2 = !{!2, !3, !4}
  !3 = !{!"llvm.loop.vectorize.width", i32 8}
  !4 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}

Setting the hint to false simply reverts the behaviour back to the
default, using fixed width vectors.

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

Added: 
llvm/test/Transforms/LoopVectorize/no_array_bounds_scalable.ll

Modified: 
llvm/docs/LangRef.rst
llvm/include/llvm/Transforms/Utils/LoopUtils.h
llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/metadata-width.ll

Removed: 




diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 1964f2416b8f..03a8387d9d1f 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5956,6 +5956,21 @@ vectorization:
!0 = !{!"llvm.loop.vectorize.predicate.enable", i1 0}
!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 1}
 
+'``llvm.loop.vectorize.scalable.enable``' Metadata
+^^^
+
+This metadata selectively enables or disables scalable vectorization for the
+loop, and only has any effect if vectorization for the loop is already enabled.
+The first operand is the string ``llvm.loop.vectorize.scalable.enable``
+and the second operand is a bit. If the bit operand value is 1 scalable
+vectorization is enabled, whereas a value of 0 reverts to the default fixed
+width vectorization:
+
+.. code-block:: llvm
+
+   !0 = !{!"llvm.loop.vectorize.scalable.enable", i1 0}
+   !1 = !{!"llvm.loop.vectorize.scalable.enable", i1 1}
+
 '``llvm.loop.vectorize.width``' Metadata
 
 

diff  --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h 
b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
index 360e262e8ae0..ef348ed56129 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
@@ -213,6 +213,13 @@ Optional 
findStringMetadataForLoop(const Loop *TheLoop,
 /// Find named metadata for a loop with an integer value.
 llvm::Optional getOptionalIntLoopAttribute(Loop *TheLoop, StringRef Name);
 
+/// Find a combination of metadata ("llvm.loop.vectorize.width" and
+/// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a
+/// ElementCount. If the metadata "llvm.loop.vectorize.width" cannot be found
+/// then None is returned.
+Optional
+getOptionalElementCountLoopAttribute(Loop *TheLoop);
+
 /// Create a new loop identifier for a loop created from a loop transformation.
 ///
 /// @param OrigLoopID The loop ID of the loop before the transformation.

diff  --git 
a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h 
b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index 2be9ef10ac4f..f701e08961a0 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -29,6 +29,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
+#include "llvm/Support/TypeSize.h"
 #include "llvm/Transforms/Utils/LoopUtils.h"
 
 namespace llvm {
@@ -43,8 +44,14 @@ namespace llvm {
 /// for example 'force', means a decision has been made. So, we need to be
 /// careful NOT to add them if the user hasn't specifically asked so.
 class LoopVectorizeHints {
-  enum HintKind { HK_WIDTH, HK_UNROLL, HK_FORCE, HK_ISVECTORIZED,
-  HK_PREDICATE };
+  enum HintKind {
+HK_WIDTH,
+HK_UNROLL,
+HK_FORCE,
+HK_ISVECTORIZED,
+HK_PREDICATE,
+HK_SCALABLE
+  };
 
   /// Hint - associates name and validation with the hint value.
   struct Hint {
@@ -73,6 +80,9 @@ class LoopVectorizeHints {
   /// Vector Predicate
   Hint Predicate;
 
+  /// Says whether we should use fixed width or scalable vectorization.
+  Hint Scalable;
+
   /// Return the loop metadata prefix.
   static StringRef 

[llvm-branch-commits] [clang] f770ec1 - [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

2020-12-02 Thread Abhina Sreeskantharajan via llvm-branch-commits

Author: Abhina Sreeskantharajan
Date: 2020-12-02T08:23:27-05:00
New Revision: f770ec1a4e8d9b274d205073e2c8b01d248cf9cb

URL: 
https://github.com/llvm/llvm-project/commit/f770ec1a4e8d9b274d205073e2c8b01d248cf9cb
DIFF: 
https://github.com/llvm/llvm-project/commit/f770ec1a4e8d9b274d205073e2c8b01d248cf9cb.diff

LOG: [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

This patch moves all s390x tests in init.c and init-zos.c to init-s390x.c.

Reviewed By: muiez

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

Added: 
clang/test/Preprocessor/init-s390x.c

Modified: 
clang/test/Preprocessor/init.c

Removed: 
clang/test/Preprocessor/init-zos.c



diff  --git a/clang/test/Preprocessor/init-s390x.c 
b/clang/test/Preprocessor/init-s390x.c
new file mode 100644
index ..b0e45b5348ce
--- /dev/null
+++ b/clang/test/Preprocessor/init-s390x.c
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X 
%s
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X 
-check-prefix S390X-CXX %s
+
+// S390X:#define __BIGGEST_ALIGNMENT__ 8
+// S390X:#define __CHAR16_TYPE__ unsigned short
+// S390X:#define __CHAR32_TYPE__ unsigned int
+// S390X:#define __CHAR_BIT__ 8
+// S390X:#define __CHAR_UNSIGNED__ 1
+// S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// S390X:#define __DBL_DIG__ 15
+// S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// S390X:#define __DBL_HAS_DENORM__ 1
+// S390X:#define __DBL_HAS_INFINITY__ 1
+// S390X:#define __DBL_HAS_QUIET_NAN__ 1
+// S390X:#define __DBL_MANT_DIG__ 53
+// S390X:#define __DBL_MAX_10_EXP__ 308
+// S390X:#define __DBL_MAX_EXP__ 1024
+// S390X:#define __DBL_MAX__ 1.7976931348623157e+308
+// S390X:#define __DBL_MIN_10_EXP__ (-307)
+// S390X:#define __DBL_MIN_EXP__ (-1021)
+// S390X:#define __DBL_MIN__ 2.2250738585072014e-308
+// S390X:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// S390X:#define __FLT_DIG__ 6
+// S390X:#define __FLT_EPSILON__ 1.19209290e-7F
+// S390X:#define __FLT_EVAL_METHOD__ 0
+// S390X:#define __FLT_HAS_DENORM__ 1
+// S390X:#define __FLT_HAS_INFINITY__ 1
+// S390X:#define __FLT_HAS_QUIET_NAN__ 1
+// S390X:#define __FLT_MANT_DIG__ 24
+// S390X:#define __FLT_MAX_10_EXP__ 38
+// S390X:#define __FLT_MAX_EXP__ 128
+// S390X:#define __FLT_MAX__ 3.40282347e+38F
+// S390X:#define __FLT_MIN_10_EXP__ (-37)
+// S390X:#define __FLT_MIN_EXP__ (-125)
+// S390X:#define __FLT_MIN__ 1.17549435e-38F
+// S390X:#define __FLT_RADIX__ 2
+// S390X:#define __INT16_C_SUFFIX__
+// S390X:#define __INT16_FMTd__ "hd"
+// S390X:#define __INT16_FMTi__ "hi"
+// S390X:#define __INT16_MAX__ 32767
+// S390X:#define __INT16_TYPE__ short
+// S390X:#define __INT32_C_SUFFIX__
+// S390X:#define __INT32_FMTd__ "d"
+// S390X:#define __INT32_FMTi__ "i"
+// S390X:#define __INT32_MAX__ 2147483647
+// S390X:#define __INT32_TYPE__ int
+// S390X:#define __INT64_C_SUFFIX__ L
+// S390X:#define __INT64_FMTd__ "ld"
+// S390X:#define __INT64_FMTi__ "li"
+// S390X:#define __INT64_MAX__ 9223372036854775807L
+// S390X:#define __INT64_TYPE__ long int
+// S390X:#define __INT8_C_SUFFIX__
+// S390X:#define __INT8_FMTd__ "hhd"
+// S390X:#define __INT8_FMTi__ "hhi"
+// S390X:#define __INT8_MAX__ 127
+// S390X:#define __INT8_TYPE__ signed char
+// S390X:#define __INTMAX_C_SUFFIX__ L
+// S390X:#define __INTMAX_FMTd__ "ld"
+// S390X:#define __INTMAX_FMTi__ "li"
+// S390X:#define __INTMAX_MAX__ 9223372036854775807L
+// S390X:#define __INTMAX_TYPE__ long int
+// S390X:#define __INTMAX_WIDTH__ 64
+// S390X:#define __INTPTR_FMTd__ "ld"
+// S390X:#define __INTPTR_FMTi__ "li"
+// S390X:#define __INTPTR_MAX__ 9223372036854775807L
+// S390X:#define __INTPTR_TYPE__ long int
+// S390X:#define __INTPTR_WIDTH__ 64
+// S390X:#define __INT_FAST16_FMTd__ "hd"
+// S390X:#define __INT_FAST16_FMTi__ "hi"
+// S390X:#define __INT_FAST16_MAX__ 32767
+// S390X:#define __INT_FAST16_TYPE__ short
+// S390X:#define __INT_FAST32_FMTd__ "d"
+// S390X:#define __INT_FAST32_FMTi__ "i"
+// S390X:#define __INT_FAST32_MAX__ 2147483647
+// S390X:#define __INT_FAST32_TYPE__ int
+// S390X:#define __INT_FAST64_FMTd__ "ld"
+// S390X:#define __INT_FAST64_FMTi__ "li"
+// S390X:#define __INT_FAST64_MAX__ 9223372036854775807L
+// S390X:#define __INT_FAST64_TYPE__ long int
+// S390X:#define __INT_FAST8_FMTd__ "hhd"
+// S390X:#define __INT_FAST8_FMTi__ "hhi"
+// S390X:#define __INT_FAST8_MAX__ 127
+// S390X:#define __INT_FAST8_TYPE__ signed char
+// S390X:#define __INT_LEAST16_FMTd__ "hd"
+// S390X:#define __INT_LEAST16_FMTi__ "hi"
+// S390X:#define __INT_LEAST16_MAX__ 32767
+// S390X:#define __INT_LEAST16_TYPE__ short
+// S390X:#define __INT_LEAST32_FMTd__ "d"
+// S390X:#define __INT_LEAST32_FMTi__ "i"

[llvm-branch-commits] [libc] 60cef89 - [libc] Add strncpy implementation.

2020-12-02 Thread Cheng Wang via llvm-branch-commits

Author: Cheng Wang
Date: 2020-12-02T20:45:51+08:00
New Revision: 60cef893627be169f22dc540834c4d085847d94a

URL: 
https://github.com/llvm/llvm-project/commit/60cef893627be169f22dc540834c4d085847d94a
DIFF: 
https://github.com/llvm/llvm-project/commit/60cef893627be169f22dc540834c4d085847d94a.diff

LOG: [libc] Add strncpy implementation.

Add libc strncpy implementation.

Reviewed By: sivachandra, gchatelet

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

Added: 
libc/src/string/strncpy.cpp
libc/src/string/strncpy.h
libc/test/src/string/strncpy_test.cpp

Modified: 
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/src/string/CMakeLists.txt
libc/test/src/string/CMakeLists.txt

Removed: 




diff  --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 3a34d95b36e1..1d8e5dd83672 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -29,6 +29,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 libc.src.string.strcpy
 libc.src.string.strcspn
 libc.src.string.strlen
+libc.src.string.strncpy
 libc.src.string.strnlen
 libc.src.string.strpbrk
 libc.src.string.strrchr

diff  --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 4eb964b2c047..d6d56f2e33a5 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -47,6 +47,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 libc.src.string.strcpy
 libc.src.string.strcspn
 libc.src.string.strlen
+libc.src.string.strncpy
 libc.src.string.strnlen
 libc.src.string.strpbrk
 libc.src.string.strrchr

diff  --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index 8a2adbe08e0b..94df8a9d2166 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -74,6 +74,14 @@ add_entrypoint_object(
 strstr.h
 )
 
+add_entrypoint_object(
+  strncpy
+  SRCS
+strncpy.cpp
+  HDRS
+strncpy.h
+)
+
 add_entrypoint_object(
   strnlen
   SRCS

diff  --git a/libc/src/string/strncpy.cpp b/libc/src/string/strncpy.cpp
new file mode 100644
index ..45255e30ac52
--- /dev/null
+++ b/libc/src/string/strncpy.cpp
@@ -0,0 +1,28 @@
+//===-- Implementation of strncpy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "src/string/strncpy.h"
+
+#include "src/__support/common.h"
+#include  // For size_t.
+
+namespace __llvm_libc {
+
+char *LLVM_LIBC_ENTRYPOINT(strncpy)(char *__restrict dest,
+const char *__restrict src, size_t n) {
+  size_t i = 0;
+  // Copy up until \0 is found.
+  for (; i < n && src[i] != '\0'; ++i)
+dest[i] = src[i];
+  // When n>strlen(src), n-strlen(src) \0 are appended.
+  for (; i < n; ++i)
+dest[i] = '\0';
+  return dest;
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/string/strncpy.h b/libc/src/string/strncpy.h
new file mode 100644
index ..c419df990cd7
--- /dev/null
+++ b/libc/src/string/strncpy.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for strncpy ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC_STRING_STRNCPY_H
+#define LLVM_LIBC_SRC_STRING_STRNCPY_H
+
+#include 
+
+namespace __llvm_libc {
+
+char *strncpy(char *__restrict dest, const char *__restrict src, size_t n);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_STRING_STRNCPY_H

diff  --git a/libc/test/src/string/CMakeLists.txt 
b/libc/test/src/string/CMakeLists.txt
index df824cd18ecc..8b78fcfdd020 100644
--- a/libc/test/src/string/CMakeLists.txt
+++ b/libc/test/src/string/CMakeLists.txt
@@ -72,6 +72,16 @@ add_libc_unittest(
 libc.src.string.strstr
 )
 
+add_libc_unittest(
+  strncpy_test
+  SUITE
+libc_string_unittests
+  SRCS
+strncpy_test.cpp
+  DEPENDS
+libc.src.string.strncpy
+)
+
 add_libc_unittest(
   strnlen_test
   SUITE

diff  --git a/libc/test/src/string/strncpy_test.cpp 
b/libc/test/src/string/strncpy_test.cpp
new file mode 100644
index ..814870613251
--- /dev/null
+++ b/libc/test/src/string/strncpy_test.cpp
@@ -0,0 +1,57 @@
+//===-- Unittests for strncpy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 

[llvm-branch-commits] [lldb] d055e3a - [LLDB/Python] Fix segfault on Python scripted entrypoints

2020-12-02 Thread Pedro Tammela via llvm-branch-commits

Author: Pedro Tammela
Date: 2020-12-02T11:25:31Z
New Revision: d055e3a0eb4e957159b075c0937a960beb75c975

URL: 
https://github.com/llvm/llvm-project/commit/d055e3a0eb4e957159b075c0937a960beb75c975
DIFF: 
https://github.com/llvm/llvm-project/commit/d055e3a0eb4e957159b075c0937a960beb75c975.diff

LOG: [LLDB/Python] Fix segfault on Python scripted entrypoints

The code that gets the ScriptInterpreter was not considering the
case that it receives a Lua interpreter.

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

Added: 
lldb/test/Shell/ScriptInterpreter/Python/scripted_breakpoint_lua.test

Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index e5802ad041e4..0d13884e8089 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Host/Config.h"
+#include "lldb/lldb-enumerations.h"
 
 #if LLDB_ENABLE_PYTHON
 
@@ -214,6 +215,12 @@ extern "C" void *
 LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
  const lldb::TargetSP _sp);
 
+static ScriptInterpreterPythonImpl *GetPythonInterpreter(Debugger ) {
+  ScriptInterpreter *script_interpreter =
+  debugger.GetScriptInterpreter(true, lldb::eScriptLanguagePython);
+  return static_cast(script_interpreter);
+}
+
 static bool g_initialized = false;
 
 namespace {
@@ -1825,11 +1832,10 @@ StructuredData::ObjectSP 
ScriptInterpreterPythonImpl::CreateScriptedThreadPlan(
 return {};
 
   Debugger  = thread_plan_sp->GetTarget().GetDebugger();
-  ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
   ScriptInterpreterPythonImpl *python_interpreter =
-  static_cast(script_interpreter);
+  GetPythonInterpreter(debugger);
 
-  if (!script_interpreter)
+  if (!python_interpreter)
 return {};
 
   void *ret_val;
@@ -1929,11 +1935,10 @@ 
ScriptInterpreterPythonImpl::CreateScriptedBreakpointResolver(
 return StructuredData::GenericSP();
 
   Debugger  = bkpt_sp->GetTarget().GetDebugger();
-  ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
   ScriptInterpreterPythonImpl *python_interpreter =
-  static_cast(script_interpreter);
+  GetPythonInterpreter(debugger);
 
-  if (!script_interpreter)
+  if (!python_interpreter)
 return StructuredData::GenericSP();
 
   void *ret_val;
@@ -2003,11 +2008,10 @@ StructuredData::GenericSP 
ScriptInterpreterPythonImpl::CreateScriptedStopHook(
 return StructuredData::GenericSP();
   }
 
-  ScriptInterpreter *script_interpreter = m_debugger.GetScriptInterpreter();
   ScriptInterpreterPythonImpl *python_interpreter =
-  static_cast(script_interpreter);
+  GetPythonInterpreter(m_debugger);
 
-  if (!script_interpreter) {
+  if (!python_interpreter) {
 error.SetErrorString("No script interpreter for scripted stop-hook.");
 return StructuredData::GenericSP();
   }
@@ -2103,11 +2107,10 @@ 
ScriptInterpreterPythonImpl::CreateSyntheticScriptedProvider(
 return StructuredData::ObjectSP();
 
   Debugger  = target->GetDebugger();
-  ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
   ScriptInterpreterPythonImpl *python_interpreter =
-  (ScriptInterpreterPythonImpl *)script_interpreter;
+  GetPythonInterpreter(debugger);
 
-  if (!script_interpreter)
+  if (!python_interpreter)
 return StructuredData::ObjectSP();
 
   void *ret_val = nullptr;
@@ -2274,11 +2277,10 @@ bool 
ScriptInterpreterPythonImpl::BreakpointCallbackFunction(
 return true;
 
   Debugger  = target->GetDebugger();
-  ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
   ScriptInterpreterPythonImpl *python_interpreter =
-  (ScriptInterpreterPythonImpl *)script_interpreter;
+  GetPythonInterpreter(debugger);
 
-  if (!script_interpreter)
+  if (!python_interpreter)
 return true;
 
   if (python_function_name && python_function_name[0]) {
@@ -2340,11 +2342,10 @@ bool 
ScriptInterpreterPythonImpl::WatchpointCallbackFunction(
 return true;
 
   Debugger  = target->GetDebugger();
-  ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
   ScriptInterpreterPythonImpl *python_interpreter =
-  (ScriptInterpreterPythonImpl *)script_interpreter;
+  GetPythonInterpreter(debugger);
 
-  if (!script_interpreter)
+  if (!python_interpreter)
 return true;
 
   if (python_function_name && python_function_name[0]) {

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/scripted_breakpoint_lua.test 

[llvm-branch-commits] [llvm] 137a25f - [llvm-readobj, libSupport] - Refine the implementation of the code that dumps build attributes.

2020-12-02 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-12-02T13:51:32+03:00
New Revision: 137a25f04a515e5ea8f24c897e34b4cd236239a8

URL: 
https://github.com/llvm/llvm-project/commit/137a25f04a515e5ea8f24c897e34b4cd236239a8
DIFF: 
https://github.com/llvm/llvm-project/commit/137a25f04a515e5ea8f24c897e34b4cd236239a8.diff

LOG: [llvm-readobj, libSupport] - Refine the implementation of the code that 
dumps build attributes.

This implementation of `ELFDumper::printAttributes()` in llvm-readobj has 
issues:
1) It crashes when the content of the attribute section is empty.
2) It uses `unwrapOrError` and `reportWarning` calls, though
   ideally we want to use `reportUniqueWarning`.
3) It contains a TODO about redundant format version check.

`lib/Support/ELFAttributeParser.cpp` uses a hardcoded constant instead of the 
named constant.

This patch fixes all these issues.

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

Added: 


Modified: 
llvm/lib/Support/ELFAttributeParser.cpp
llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/lib/Support/ELFAttributeParser.cpp 
b/llvm/lib/Support/ELFAttributeParser.cpp
index df955cdf5d30..2a30794bc1e9 100644
--- a/llvm/lib/Support/ELFAttributeParser.cpp
+++ b/llvm/lib/Support/ELFAttributeParser.cpp
@@ -200,7 +200,7 @@ Error ELFAttributeParser::parse(ArrayRef section,
 
   // Unrecognized format-version.
   uint8_t formatVersion = de.getU8(cursor);
-  if (formatVersion != 'A')
+  if (formatVersion != ELFAttrs::Format_Version)
 return createStringError(errc::invalid_argument,
  "unrecognized format-version: 0x" +
  utohexstr(formatVersion));

diff  --git a/llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test 
b/llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test
index 547ed93bcd10..882bbb53b577 100644
--- a/llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test
+++ b/llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test
@@ -5,11 +5,16 @@
 ## here we use 'B' (42).
 
 # RUN: yaml2obj %s -D BITS=32 -DCONTENT=42 -o %t1.32.o
-# RUN: llvm-readobj -A %t1.32.o 2>&1 | FileCheck -DFILE=%t1 %s 
--check-prefix=ERR-FORMAT
+# RUN: llvm-readobj -A %t1.32.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t1 %s --implicit-check-not=warning: 
--check-prefix=ERR-FORMAT
 # RUN: yaml2obj %s -D BITS=64 -DCONTENT=42 -o %t1.64.o
-# RUN: llvm-readobj -A %t1.64.o 2>&1 | FileCheck -DFILE=%t1 %s 
--check-prefix=ERR-FORMAT
+# RUN: llvm-readobj -A %t1.64.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t1 %s --implicit-check-not=warning: 
--check-prefix=ERR-FORMAT
 
-# ERR-FORMAT: warning: '[[FILE]].{{32|64}}.o': unrecognised FormatVersion: 0x42
+# ERR-FORMAT:  BuildAttributes {
+# ERR-FORMAT-NEXT:   FormatVersion: 0x42
+# ERR-FORMAT-NEXT: warning: '[[FILE]].{{32|64}}.o': unable to dump attributes 
from the SHT_RISCV_ATTRIBUTES section with index 1: unrecognized 
format-version: 0x42
+# ERR-FORMAT-NEXT: }
 
 --- !ELF
 FileHeader:
@@ -18,15 +23,54 @@ FileHeader:
   Type:ET_REL
   Machine: EM_RISCV
 Sections:
-  - Name:.riscv.attributes
-Type:SHT_RISCV_ATTRIBUTES
-Content: [[CONTENT]]
+  - Name: .riscv.attributes
+Type: SHT_RISCV_ATTRIBUTES
+Content:  [[CONTENT]]
+ShOffset: [[SHOFFSET=]]
 
 ## Check we report a warning when we are unable to parse the attribute section 
data.
+## FIXME: this test case documents that we don't close the "Section X" clause 
of
+##the output properly when a warning is reported by the attributes 
parser.
 
 # RUN: yaml2obj %s -D BITS=32 -DCONTENT=41 -o %t2.32.o
-# RUN: llvm-readobj -A %t2.32.o 2>&1 | FileCheck -DFILE=%t2 %s 
--check-prefix=ERR-LENGTH
+# RUN: llvm-readobj -A %t2.32.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t2 %s --implicit-check-not=warning: 
--check-prefix=ERR-LENGTH
 # RUN: yaml2obj %s -D BITS=64 -DCONTENT=41 -o %t2.64.o
-# RUN: llvm-readobj -A %t2.64.o 2>&1 | FileCheck -DFILE=%t2 %s 
--check-prefix=ERR-LENGTH
+# RUN: llvm-readobj -A %t2.64.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t2 %s --implicit-check-not=warning: 
--check-prefix=ERR-LENGTH
 
-# ERR-LENGTH: warning: '[[FILE]].{{32|64}}.o': invalid section length 0 at 
offset 0x1
+# ERR-LENGTH:  BuildAttributes {
+# ERR-LENGTH-NEXT:   FormatVersion: 0x41
+# ERR-LENGTH-NEXT:   Section 1 {
+# ERR-LENGTH-NEXT: warning: '[[FILE]].{{32|64}}.o': unable to dump attributes 
from the SHT_RISCV_ATTRIBUTES section with index 1: invalid section length 0 at 
offset 0x1
+# ERR-LENGTH-NEXT:   }
+# ERR-LENGTH-NOT: {{.}}
+
+## Check that we don't report a warning when the SHT_RISCV_ATTRIBUTES section 
contains the
+## valid format version byte and no other data.
+
+# RUN: yaml2obj %s -DCONTENT=41 -o %t3.o
+# RUN: llvm-readobj -A %t3.o 2>&1 | \
+# RUN:   FileCheck %s --implicit-check-not=warning: 

[llvm-branch-commits] [llvm] 14557cd - [InstructionsTest] NFC: Replace VectorType::get(.., .., true) with ScalableVectorType::get

2020-12-02 Thread Cullen Rhodes via llvm-branch-commits

Author: Cullen Rhodes
Date: 2020-12-02T10:50:05Z
New Revision: 14557cdf9427341e60b9bd34807c46b2ee826f99

URL: 
https://github.com/llvm/llvm-project/commit/14557cdf9427341e60b9bd34807c46b2ee826f99
DIFF: 
https://github.com/llvm/llvm-project/commit/14557cdf9427341e60b9bd34807c46b2ee826f99.diff

LOG: [InstructionsTest] NFC: Replace VectorType::get(.., .., true) with 
ScalableVectorType::get

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/unittests/IR/InstructionsTest.cpp

Removed: 




diff  --git a/llvm/unittests/IR/InstructionsTest.cpp 
b/llvm/unittests/IR/InstructionsTest.cpp
index dfd292ff60bb..b2cfa891dcca 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -200,10 +200,10 @@ TEST(InstructionsTest, CastInst) {
   Type *V4Int16Ty = FixedVectorType::get(Int16Ty, 4);
   Type *V1Int16Ty = FixedVectorType::get(Int16Ty, 1);
 
-  Type *VScaleV2Int32Ty = VectorType::get(Int32Ty, 2, true);
-  Type *VScaleV2Int64Ty = VectorType::get(Int64Ty, 2, true);
-  Type *VScaleV4Int16Ty = VectorType::get(Int16Ty, 4, true);
-  Type *VScaleV1Int16Ty = VectorType::get(Int16Ty, 1, true);
+  Type *VScaleV2Int32Ty = ScalableVectorType::get(Int32Ty, 2);
+  Type *VScaleV2Int64Ty = ScalableVectorType::get(Int64Ty, 2);
+  Type *VScaleV4Int16Ty = ScalableVectorType::get(Int16Ty, 4);
+  Type *VScaleV1Int16Ty = ScalableVectorType::get(Int16Ty, 1);
 
   Type *Int32PtrTy = PointerType::get(Int32Ty, 0);
   Type *Int64PtrTy = PointerType::get(Int64Ty, 0);
@@ -214,15 +214,15 @@ TEST(InstructionsTest, CastInst) {
   Type *V2Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 2);
   Type *V2Int64PtrAS1Ty = FixedVectorType::get(Int64PtrAS1Ty, 2);
   Type *V4Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 4);
-  Type *VScaleV4Int32PtrAS1Ty = VectorType::get(Int32PtrAS1Ty, 4, true);
+  Type *VScaleV4Int32PtrAS1Ty = ScalableVectorType::get(Int32PtrAS1Ty, 4);
   Type *V4Int64PtrAS1Ty = FixedVectorType::get(Int64PtrAS1Ty, 4);
 
   Type *V2Int64PtrTy = FixedVectorType::get(Int64PtrTy, 2);
   Type *V2Int32PtrTy = FixedVectorType::get(Int32PtrTy, 2);
-  Type *VScaleV2Int32PtrTy = VectorType::get(Int32PtrTy, 2, true);
+  Type *VScaleV2Int32PtrTy = ScalableVectorType::get(Int32PtrTy, 2);
   Type *V4Int32PtrTy = FixedVectorType::get(Int32PtrTy, 4);
-  Type *VScaleV4Int32PtrTy = VectorType::get(Int32PtrTy, 4, true);
-  Type *VScaleV4Int64PtrTy = VectorType::get(Int64PtrTy, 4, true);
+  Type *VScaleV4Int32PtrTy = ScalableVectorType::get(Int32PtrTy, 4);
+  Type *VScaleV4Int64PtrTy = ScalableVectorType::get(Int64PtrTy, 4);
 
   const Constant* c8 = Constant::getNullValue(V8x8Ty);
   const Constant* c64 = Constant::getNullValue(V8x64Ty);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 28797e9 - [libc++] [docs] Mark LWG2296 as complete not only on clang.

2020-12-02 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-12-02T11:39:43+01:00
New Revision: 28797e99522b6c3a520c876ad463acd578bf5f33

URL: 
https://github.com/llvm/llvm-project/commit/28797e99522b6c3a520c876ad463acd578bf5f33
DIFF: 
https://github.com/llvm/llvm-project/commit/28797e99522b6c3a520c876ad463acd578bf5f33.diff

LOG: [libc++] [docs] Mark LWG2296 as complete not only on clang.

std::addressof was made constexpr in gcc 7.
libc++ fixed it in ac473034fc771e5f1b4ef0ac405df70ed27412a1 (Provide a 
constexpr addressof with GCC 7.)

Added: 


Modified: 
libcxx/docs/Cxx1zStatusIssuesStatus.csv

Removed: 




diff  --git a/libcxx/docs/Cxx1zStatusIssuesStatus.csv 
b/libcxx/docs/Cxx1zStatusIssuesStatus.csv
index d5c43103b4bd..218782b0071b 100644
--- a/libcxx/docs/Cxx1zStatusIssuesStatus.csv
+++ b/libcxx/docs/Cxx1zStatusIssuesStatus.csv
@@ -103,7 +103,7 @@
 "","","",""
 "`2192 `__","Validity and return type of 
``std::abs(0u)``\  is unclear","Jacksonville","|Complete|"
 "`2276 `__","Missing requirement on 
``std::promise::set_exception``\ ","Jacksonville","|Complete|"
-"`2296 `__","``std::addressof``\  should be 
``constexpr``\ ","Jacksonville","Complete (Clang Only)"
+"`2296 `__","``std::addressof``\  should be 
``constexpr``\ ","Jacksonville","|Complete|"
 "`2450 
`__","``(greater|less|greater_equal|less_equal)``\
  do not yield a total order for pointers","Jacksonville","|Complete|"
 "`2520 `__","N4089 broke initializing 
``unique_ptr``\  from a ``nullptr``\ ","Jacksonville","|Complete|"
 "`2522 `__","[fund.ts.v2] Contradiction in 
``set_default_resource``\  specification","Jacksonville","|Complete|"



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] d82fb60 - [libc++] [docs] Mark P1424 as superseded by P1902.

2020-12-02 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-12-02T11:19:37+01:00
New Revision: d82fb6022bd8406a406722e01658273fdd209e5f

URL: 
https://github.com/llvm/llvm-project/commit/d82fb6022bd8406a406722e01658273fdd209e5f
DIFF: 
https://github.com/llvm/llvm-project/commit/d82fb6022bd8406a406722e01658273fdd209e5f.diff

LOG: [libc++] [docs] Mark P1424 as superseded by P1902.

Added: 


Modified: 
libcxx/docs/Cxx2aStatusPaperStatus.csv

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv 
b/libcxx/docs/Cxx2aStatusPaperStatus.csv
index 793fc92be5f2..88d5641403f5 100644
--- a/libcxx/docs/Cxx2aStatusPaperStatus.csv
+++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv
@@ -116,7 +116,7 @@
 "`P1355 `__","LWG","Exposing a narrow contract for 
ceil2","Cologne","|Complete|","9.0"
 "`P1361 `__","LWG","Integration of chrono with text 
formatting","Cologne","",""
 "`P1423 `__","LWG","char8_t backward compatibility 
remediation","Cologne","",""
-"`P1424 `__","LWG","'constexpr' feature macro 
concerns","Cologne","",""
+"`P1424 `__","LWG","'constexpr' feature macro 
concerns","Cologne","Superseded by `P1902 `__",""
 "`P1466 `__","LWG","Miscellaneous minor fixes for 
chrono","Cologne","",""
 "`P1474 `__","LWG","Helpful pointers for 
ContiguousIterator","Cologne","",""
 "`P1502 `__","LWG","Standard library header units for 
C++20","Cologne","",""



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 1daace3 - [llvm-readelf/obj] - Lowercase the warning message reported.

2020-12-02 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-12-02T13:09:47+03:00
New Revision: 1daace3fbb307d09ef8445bede5559143da1712d

URL: 
https://github.com/llvm/llvm-project/commit/1daace3fbb307d09ef8445bede5559143da1712d
DIFF: 
https://github.com/llvm/llvm-project/commit/1daace3fbb307d09ef8445bede5559143da1712d.diff

LOG: [llvm-readelf/obj] - Lowercase the warning message reported.

Our warnings/errors reported are using lowercase normally.

This addresses one of review comments from D92382.

Added: 


Modified: 
llvm/test/Object/invalid.test
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
llvm/test/tools/llvm-readobj/ELF/dynamic-tags.test
llvm/test/tools/llvm-readobj/ELF/loadname.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test
index 74ad8fcc9c72..57fb006351eb 100644
--- a/llvm/test/Object/invalid.test
+++ b/llvm/test/Object/invalid.test
@@ -437,7 +437,7 @@ DynamicSymbols:
 # RUN: yaml2obj %s --docnum=20 -o %t20
 # RUN: llvm-readobj --dynamic-table %t20 2>&1 | FileCheck -DFILE=%t20 
--check-prefix=INVALID-DTSTRTAB %s
 
-# INVALID-DTSTRTAB: warning: '[[FILE]]': Unable to parse DT_STRTAB: virtual 
address is not in any segment: 0x
+# INVALID-DTSTRTAB: warning: '[[FILE]]': unable to parse DT_STRTAB: virtual 
address is not in any segment: 0x
 
 --- !ELF
 FileHeader:

diff  --git a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test 
b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
index 43ca57a80b61..4b4a4bed4c8b 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
@@ -90,7 +90,7 @@ ProgramHeaders:
 # RUN: llvm-readelf %t2.so --dyn-symbols 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t2.so --implicit-check-not=warning: 
-DNAME=.dynsym --check-prefix=NOPHDRS-GNU
 
-# NOPHDRS-LLVM: warning: '[[FILE]]': Unable to parse DT_SYMTAB: virtual 
address is not in any segment: 0x1234
+# NOPHDRS-LLVM: warning: '[[FILE]]': unable to parse DT_SYMTAB: virtual 
address is not in any segment: 0x1234
 # NOPHDRS-LLVM:  DynamicSymbols [
 # NOPHDRS-LLVM-NEXT:   Symbol {
 # NOPHDRS-LLVM-NEXT: Name:  (0)
@@ -112,7 +112,7 @@ ProgramHeaders:
 # NOPHDRS-LLVM-NEXT:   }
 # NOPHDRS-LLVM-NEXT: ]
 
-# NOPHDRS-GNU:  warning: '[[FILE]]': Unable to parse DT_SYMTAB: virtual 
address is not in any segment: 0x1234
+# NOPHDRS-GNU:  warning: '[[FILE]]': unable to parse DT_SYMTAB: virtual 
address is not in any segment: 0x1234
 # NOPHDRS-NAMEWARN: warning: '[[FILE]]': unable to get the name of SHT_DYNSYM 
section with index 2: a section [index 2] has an invalid sh_name (0x) 
offset which goes past the end of the section name string table
 # NOPHDRS-GNU:  Symbol table '[[NAME]]' contains 2 entries:
 # NOPHDRS-GNU-NEXT:  Num:Value  Size TypeBind   Vis   Ndx 
Name
@@ -153,7 +153,7 @@ DynamicSymbols:
 # RUN: llvm-readobj %t3.so --dyn-symbols 2>&1 | FileCheck %s -DFILE=%t3.so 
--check-prefixes=NOSHT-DYNSYM,NOSHT-DYNSYM-LLVM
 # RUN: llvm-readelf %t3.so --dyn-symbols 2>&1 | FileCheck %s -DFILE=%t3.so 
--check-prefix=NOSHT-DYNSYM
 
-# NOSHT-DYNSYM:   warning: '[[FILE]]': Unable to parse DT_SYMTAB: 
virtual address is not in any segment: 0x0
+# NOSHT-DYNSYM:   warning: '[[FILE]]': unable to parse DT_SYMTAB: 
virtual address is not in any segment: 0x0
 # NOSHT-DYNSYM-LLVM:  DynamicSymbols [
 # NOSHT-DYNSYM-LLVM-NEXT: ]
 
@@ -181,7 +181,7 @@ DynamicSymbols:
 # RUN: llvm-readobj %t4.so --dyn-symbols 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefixes=BROKEN-DTSYMTAB,BROKEN-DTSYMTAB-LLVM
 # RUN: llvm-readelf %t4.so --dyn-symbols 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefixes=BROKEN-DTSYMTAB,BROKEN-DTSYMTAB-GNU
 
-# BROKEN-DTSYMTAB:  warning: '[[FILE]]': Unable to parse DT_SYMTAB: 
virtual address is not in any segment: 0x1234
+# BROKEN-DTSYMTAB:  warning: '[[FILE]]': unable to parse DT_SYMTAB: 
virtual address is not in any segment: 0x1234
 # BROKEN-DTSYMTAB-LLVM: Name: foo
 # BROKEN-DTSYMTAB-GNU:  1:  0 NOTYPE  LOCAL  DEFAULT   UND 
foo
 

diff  --git a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test 
b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
index bb12ce80d9e2..6bcf890949c8 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
@@ -187,7 +187,7 @@ ProgramHeaders:
 # RUN:   FileCheck -DFILE=%t.bad-strtab %s --implicit-check-not=warning: 
--check-prefix=BAD-STRTAB-ERR
 # RUN: llvm-readelf --dynamic-table %t.bad-strtab 2>&1 >/dev/null | \
 # RUN:   FileCheck -DFILE=%t.bad-strtab %s --implicit-check-not=warning: 
--check-prefix=BAD-STRTAB-ERR
-# BAD-STRTAB-ERR:warning: '[[FILE]]': Unable to parse DT_STRTAB: virtual 
address is 

[llvm-branch-commits] [llvm] 21b6c04 - [llvm-readelf/obj] - Report unique warnings in `parseDynamicTable`.

2020-12-02 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-12-02T12:52:42+03:00
New Revision: 21b6c04e3a02d67cebb3e3bc3d43d3e9311ea915

URL: 
https://github.com/llvm/llvm-project/commit/21b6c04e3a02d67cebb3e3bc3d43d3e9311ea915
DIFF: 
https://github.com/llvm/llvm-project/commit/21b6c04e3a02d67cebb3e3bc3d43d3e9311ea915.diff

LOG: [llvm-readelf/obj] - Report unique warnings in `parseDynamicTable`.

This makes the warnings reported to be unique and adds test cases.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test 
b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
index eb976f673b93..43ca57a80b61 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
@@ -451,11 +451,15 @@ DynamicSymbols: []
 ## c) In the case when the DT_SYMENT tag is present, we report when it's value 
does not match the
 # value of the symbol size for the platform.
 # RUN: yaml2obj %s -D BITS=32 --docnum=12 -o %t12
-# RUN: llvm-readobj --dyn-symbols %t12 2>&1 | FileCheck %s -DFILE=%t12 
--check-prefix=DYNSYM-SIZE-INVALID3
-# RUN: llvm-readelf --dyn-symbols %t12 2>&1 | FileCheck %s -DFILE=%t12 
--check-prefix=DYNSYM-SIZE-INVALID3
+# RUN: llvm-readobj --dyn-symbols %t12 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t12 --implicit-check-not=warning: 
--check-prefix=DYNSYM-SIZE-INVALID3
+# RUN: llvm-readelf --dyn-symbols %t12 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t12 --implicit-check-not=warning: 
--check-prefix=DYNSYM-SIZE-INVALID3
 # RUN: yaml2obj %s -D BITS=64 --docnum=12 -o %t13
-# RUN: llvm-readobj --dyn-symbols %t13 2>&1 | FileCheck %s -DFILE=%t13 
--check-prefix=DYNSYM-SIZE-INVALID4
-# RUN: llvm-readelf --dyn-symbols %t13 2>&1 | FileCheck %s -DFILE=%t13 
--check-prefix=DYNSYM-SIZE-INVALID4
+# RUN: llvm-readobj --dyn-symbols %t13 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t13 --implicit-check-not=warning: 
--check-prefix=DYNSYM-SIZE-INVALID4
+# RUN: llvm-readelf --dyn-symbols %t13 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t13 --implicit-check-not=warning: 
--check-prefix=DYNSYM-SIZE-INVALID4
 
 # DYNSYM-SIZE-INVALID3: warning: '[[FILE]]': DT_SYMENT value of 0x123 is not 
the size of a symbol (0x10){{$}}
 # DYNSYM-SIZE-INVALID4: warning: '[[FILE]]': DT_SYMENT value of 0x123 is not 
the size of a symbol (0x18){{$}}
@@ -502,6 +506,8 @@ Sections:
   - Name:.dynamic
 Type:SHT_DYNAMIC
 Entries:
+  - Tag:   DT_SYMENT
+Value: 0x123
   - Tag:   DT_SYMENT
 Value: 0x123
   - Tag:   DT_NULL

diff  --git a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test 
b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
index 48ab1d914c3b..bb12ce80d9e2 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
@@ -215,6 +215,9 @@ Sections:
 Type:SHT_DYNAMIC
 Address: 0x1000
 Entries:
+## Two DT_STRTAB entries are needed to check that we don't report it twice.
+  - Tag:   DT_STRTAB
+Value: 0x200
   - Tag:   DT_STRTAB
 Value: 0x200
   - Tag:   DT_STRSZ

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index be018e18a912..8a774da52772 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -2090,11 +2090,9 @@ void ELFDumper::parseDynamicTable() {
   auto toMappedAddr = [&](uint64_t Tag, uint64_t VAddr) -> const uint8_t * {
 auto MappedAddrOrError = Obj.toMappedAddr(VAddr);
 if (!MappedAddrOrError) {
-  Error Err =
-  createError("Unable to parse DT_" + Obj.getDynamicTagAsString(Tag) +
-  ": " + llvm::toString(MappedAddrOrError.takeError()));
-
-  reportWarning(std::move(Err), ObjF.getFileName());
+  this->reportUniqueWarning("Unable to parse DT_" +
+Obj.getDynamicTagAsString(Tag) + ": " +
+llvm::toString(MappedAddrOrError.takeError()));
   return nullptr;
 }
 return MappedAddrOrError.get();
@@ -2134,11 +2132,10 @@ void ELFDumper::parseDynamicTable() {
 case ELF::DT_SYMENT: {
   uint64_t Val = Dyn.getVal();
   if (Val != sizeof(Elf_Sym))
-reportWarning(createError("DT_SYMENT value of 0x" +
+this->reportUniqueWarning("DT_SYMENT value of 0x" +
   Twine::utohexstr(Val) +
   " is not the size of a symbol (0x" +
-  Twine::utohexstr(sizeof(Elf_Sym)) + ")"),
-  ObjF.getFileName());
+  Twine::utohexstr(sizeof(Elf_Sym)) + ")");
   break;
 

[llvm-branch-commits] [lldb] c526426 - [lldb] Don't reject empty or unnamed template parameter packs

2020-12-02 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-02T10:50:41+01:00
New Revision: c526426f5cba5308782ea4f86822047ee2ee3818

URL: 
https://github.com/llvm/llvm-project/commit/c526426f5cba5308782ea4f86822047ee2ee3818
DIFF: 
https://github.com/llvm/llvm-project/commit/c526426f5cba5308782ea4f86822047ee2ee3818.diff

LOG: [lldb] Don't reject empty or unnamed template parameter packs

We currently reject all templates that have either zero args or that have a
parameter pack without a name. Both cases are actually allowed in C++, so
rejecting them leads to LLDB instead falling back to a dummy 'void' type. This
leads to all kind of errors later on (most notable, variables that have such
template types appear to be missing as we can't have 'void' variables and
inheriting from such a template type will cause Clang to hit some asserts when
finding that the base class is 'void').

This just removes the too strict tests and adds a few tests for this stuff (+
some combinations of these tests with preceding template parameters).

Things that I left for follow-up patches:
* All the possible interactions with template-template arguments which seem 
like a whole new source of possible bugs.
* Function templates which completely lack sanity checks.
* Variable templates are not implemented.
* Alias templates are not implemented too.
* The rather strange checks that just make sure that the separate list of
  template arg names and values always have the same length. I believe those
  ought to be asserts, but my current plan is to move both those things into a
  single list that can't end up in this inconsistent state.

Reviewed By: JDevlieghere, shafik

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

Added: 
lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/Makefile

lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/main.cpp
lldb/test/API/lang/cpp/class-template-type-parameter-pack/Makefile

lldb/test/API/lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py
lldb/test/API/lang/cpp/class-template-type-parameter-pack/main.cpp

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 6633acd70a50..2c045d6dc9c0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1944,8 +1944,6 @@ bool DWARFASTParserClang::ParseTemplateParameterInfos(
   break;
 }
   }
-  if (template_param_infos.args.empty())
-return false;
   return template_param_infos.args.size() == template_param_infos.names.size();
 }
 

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 5eb492f0dbc2..6879d2566183 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -332,10 +332,11 @@ class TypeSystemClang : public TypeSystem {
   class TemplateParameterInfos {
   public:
 bool IsValid() const {
-  if (args.empty())
+  // Having a pack name but no packed args doesn't make sense, so mark
+  // these template parameters as invalid.
+  if (pack_name && !packed_args)
 return false;
   return args.size() == names.size() &&
-((bool)pack_name == (bool)packed_args) &&
 (!packed_args || !packed_args->packed_args);
 }
 

diff  --git 
a/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/Makefile 
b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
 
b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
new file mode 100644
index ..d366d9d69222
--- /dev/null
+++ 
b/lldb/test/API/lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py
@@ -0,0 +1,76 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+  

[llvm-branch-commits] [llvm] 99eb0f1 - [Intrinsics] Re-remove experimental_vector_reduce intrinsics

2020-12-02 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-02T09:22:41Z
New Revision: 99eb0f16c35cdaa04dea4c5bbad4f86408e9dcfd

URL: 
https://github.com/llvm/llvm-project/commit/99eb0f16c35cdaa04dea4c5bbad4f86408e9dcfd
DIFF: 
https://github.com/llvm/llvm-project/commit/99eb0f16c35cdaa04dea4c5bbad4f86408e9dcfd.diff

LOG: [Intrinsics] Re-remove experimental_vector_reduce intrinsics

These were re-added by fbfb1c790982277eaa5134c2b6aa001e97fe828d but
should not have been. This removes the old experimental versions of the
reduction intrinsics again, leaving the new non experimental ones.

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

Added: 


Modified: 
llvm/include/llvm/IR/Intrinsics.td

Removed: 




diff  --git a/llvm/include/llvm/IR/Intrinsics.td 
b/llvm/include/llvm/IR/Intrinsics.td
index 6f7317827ef8..9e64a61cf481 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1518,34 +1518,6 @@ let IntrProperties = [IntrNoMem] in {
  [llvm_anyvector_ty]>;
   def int_vector_reduce_fmin : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_v2_fadd : 
DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
- [LLVMMatchType<0>,
-  llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_v2_fmul : 
DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
- [LLVMMatchType<0>,
-  llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_add : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
- [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_mul : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
- [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_and : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
- [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_or : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
-[llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_xor : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
- [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_smax : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
-  [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_smin : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
-  [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_umax : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
-  [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_umin : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
-  [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_fmax : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
-  [llvm_anyvector_ty]>;
-  def int_experimental_vector_reduce_fmin : 
DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
-  [llvm_anyvector_ty]>;
 }
 
 //===- Matrix intrinsics -===//



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] ffa2dce - [PowerPC] Fix FLT_ROUNDS_ on little endian

2020-12-02 Thread Qiu Chaofan via llvm-branch-commits

Author: Qiu Chaofan
Date: 2020-12-02T17:16:32+08:00
New Revision: ffa2dce59070636e0d83d2797fb80c4ca2d7ea2d

URL: 
https://github.com/llvm/llvm-project/commit/ffa2dce59070636e0d83d2797fb80c4ca2d7ea2d
DIFF: 
https://github.com/llvm/llvm-project/commit/ffa2dce59070636e0d83d2797fb80c4ca2d7ea2d.diff

LOG: [PowerPC] Fix FLT_ROUNDS_ on little endian

In lowering of FLT_ROUNDS_, FPSCR content will be moved into FP register
and then GPR, and then truncated into word.

For subtargets without direct move support, it will store and then load.
The load address needs adjustment (+4) only on big-endian targets. This
patch fixes it on using generic opcodes on little-endian and subtargets
with direct-move.

Reviewed By: steven.zhang

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/frounds.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 1864dc7f3113..f9f84aa668bc 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -8975,16 +8975,24 @@ SDValue PPCTargetLowering::LowerFLT_ROUNDS_(SDValue Op,
   SDValue MFFS = DAG.getNode(PPCISD::MFFS, dl, {MVT::f64, MVT::Other}, Chain);
   Chain = MFFS.getValue(1);
 
-  // Save FP register to stack slot
-  int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false);
-  SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT);
-  Chain = DAG.getStore(Chain, dl, MFFS, StackSlot, MachinePointerInfo());
-
-  // Load FP Control Word from low 32 bits of stack slot.
-  SDValue Four = DAG.getConstant(4, dl, PtrVT);
-  SDValue Addr = DAG.getNode(ISD::ADD, dl, PtrVT, StackSlot, Four);
-  SDValue CWD = DAG.getLoad(MVT::i32, dl, Chain, Addr, MachinePointerInfo());
-  Chain = CWD.getValue(1);
+  SDValue CWD;
+  if (isTypeLegal(MVT::i64)) {
+CWD = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32,
+  DAG.getNode(ISD::BITCAST, dl, MVT::i64, MFFS));
+  } else {
+// Save FP register to stack slot
+int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false);
+SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT);
+Chain = DAG.getStore(Chain, dl, MFFS, StackSlot, MachinePointerInfo());
+
+// Load FP Control Word from low 32 bits of stack slot.
+assert(hasBigEndianPartOrdering(MVT::i64, MF.getDataLayout()) &&
+   "Stack slot adjustment is valid only on big endian subtargets!");
+SDValue Four = DAG.getConstant(4, dl, PtrVT);
+SDValue Addr = DAG.getNode(ISD::ADD, dl, PtrVT, StackSlot, Four);
+CWD = DAG.getLoad(MVT::i32, dl, Chain, Addr, MachinePointerInfo());
+Chain = CWD.getValue(1);
+  }
 
   // Transform as necessary
   SDValue CWD1 =

diff  --git a/llvm/test/CodeGen/PowerPC/frounds.ll 
b/llvm/test/CodeGen/PowerPC/frounds.ll
index df339ceb3a09..277423f6e2b5 100644
--- a/llvm/test/CodeGen/PowerPC/frounds.ll
+++ b/llvm/test/CodeGen/PowerPC/frounds.ll
@@ -42,7 +42,7 @@ define i32 @foo() {
 ; PPC64LE:   # %bb.0: # %entry
 ; PPC64LE-NEXT:mffs 0
 ; PPC64LE-NEXT:stfd 0, -16(1)
-; PPC64LE-NEXT:lwz 3, -12(1)
+; PPC64LE-NEXT:lwz 3, -16(1)
 ; PPC64LE-NEXT:not 4, 3
 ; PPC64LE-NEXT:clrlwi 3, 3, 30
 ; PPC64LE-NEXT:rlwinm 4, 4, 31, 31, 31
@@ -54,8 +54,7 @@ define i32 @foo() {
 ; DM-LABEL: foo:
 ; DM:   # %bb.0: # %entry
 ; DM-NEXT:mffs 0
-; DM-NEXT:stfd 0, -16(1)
-; DM-NEXT:lwz 3, -12(1)
+; DM-NEXT:mffprd 3, 0
 ; DM-NEXT:not 4, 3
 ; DM-NEXT:clrlwi 3, 3, 30
 ; DM-NEXT:rlwinm 4, 4, 31, 31, 31



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


  1   2   >