[llvm-branch-commits] [libcxx] d61805a - [libc++] Fix double file closing in `std::filesystem::remove_all()`.

2022-02-28 Thread Louis Dionne via llvm-branch-commits

Author: Konstantin Varlamov
Date: 2022-02-28T12:57:19-05:00
New Revision: d61805a8b6863663754b1d35ad5d3b25c30365cf

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

LOG: [libc++] Fix double file closing in `std::filesystem::remove_all()`.

According to Linux documentation (see e.g. 
https://linux.die.net/man/3/closedir):

> A successful call to `closedir()` also closes the underlying file
> descriptor associated with `dirp`.

Thus, calling `close()` after a successful call to `closedir()` is at
best redundant. Worse, should a different thread open a file in-between
the calls to `closedir()` and `close()` and get the same file descriptor,
the call to `close()` might actually close a different file than was
intended.

rdar://89251874

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

(cherry picked from commit 3906ebf750b80e36c2d6c52130cf40771e1b55fb)

Added: 


Modified: 
libcxx/src/filesystem/operations.cpp

Removed: 




diff  --git a/libcxx/src/filesystem/operations.cpp 
b/libcxx/src/filesystem/operations.cpp
index 7aeeffaae8f38..39fb5739739be 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -1414,12 +1414,14 @@ uintmax_t remove_all_impl(int parent_directory, const 
path& p, error_code& ec) {
   if (fd != -1) {
 // If that worked, iterate over the contents of the directory and
 // remove everything in it, recursively.
-scope_exit close_fd([=] { ::close(fd); });
 DIR* stream = ::fdopendir(fd);
 if (stream == nullptr) {
+  ::close(fd);
   ec = detail::capture_errno();
   return 0;
 }
+// Note: `::closedir` will also close the associated file descriptor, so
+// there should be no call to `close(fd)`.
 scope_exit close_stream([=] { ::closedir(stream); });
 
 uintmax_t count = 0;



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 8a323ad - [clang][SemaTemplate] Fix a stack use after scope

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2022-02-28T10:49:35-08:00
New Revision: 8a323ada234ba2859942772b446bf2692dadb573

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

LOG: [clang][SemaTemplate] Fix a stack use after scope

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

(cherry picked from commit c79c13cae61564d3a03831013ea24ff483ee3e82)

Added: 


Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/lib/AST/DeclTemplate.cpp
clang/test/SemaTemplate/friend-template.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index d216b359816e8..319e605a8a1c5 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2461,10 +2461,10 @@ class FriendTemplateDecl : public Decl {
   SourceLocation FriendLoc;
 
   FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- MutableArrayRef Params,
+ TemplateParameterList **Params, unsigned NumParams,
  FriendUnion Friend, SourceLocation FriendLoc)
-  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(Params.size()),
-Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
+  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
+Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}
 
   FriendTemplateDecl(EmptyShell Empty) : Decl(Decl::FriendTemplate, Empty) {}
 

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 223f06b9db1c9..d9ff3517a589c 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1098,7 +1099,13 @@ FriendTemplateDecl::Create(ASTContext &Context, 
DeclContext *DC,
SourceLocation L,
MutableArrayRef Params,
FriendUnion Friend, SourceLocation FLoc) {
-  return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
+  TemplateParameterList **TPL = nullptr;
+  if (!Params.empty()) {
+TPL = new (Context) TemplateParameterList *[Params.size()];
+llvm::copy(Params, TPL);
+  }
+  return new (Context, DC)
+  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
 }
 
 FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,

diff  --git a/clang/test/SemaTemplate/friend-template.cpp 
b/clang/test/SemaTemplate/friend-template.cpp
index e9b2b9b8e64e5..2dcee6c76da7d 100644
--- a/clang/test/SemaTemplate/friend-template.cpp
+++ b/clang/test/SemaTemplate/friend-template.cpp
@@ -329,3 +329,12 @@ namespace rdar12350696 {
 foo(b); // expected-note {{in instantiation}}
   }
 }
+
+namespace StackUseAfterScope {
+template  class Bar {};
+class Foo {
+  // Make sure this doesn't crash.
+  template <> friend class Bar; // expected-error {{template 
specialization declaration cannot be a friend}}
+  bool aux;
+};
+}



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] aadd03a - [clang][ASTReader] Fix memory leak while reading FriendTemplateDecls

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2022-02-28T10:50:01-08:00
New Revision: aadd03a2accd7af22a9377f5f76b140013f8841d

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

LOG: [clang][ASTReader] Fix memory leak while reading FriendTemplateDecls

Allocate on ASTContext, rather than just on heap, so that template
parameter lists are freed up.

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

(cherry picked from commit 977b1f574fa18219fde5f709b906c79202ef1916)

Added: 


Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 1ab26e58a4040..5d63a26132b73 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2103,7 +2103,7 @@ void 
ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
   VisitDecl(D);
   unsigned NumParams = Record.readInt();
   D->NumParams = NumParams;
-  D->Params = new TemplateParameterList*[NumParams];
+  D->Params = new (Reader.getContext()) TemplateParameterList *[NumParams];
   for (unsigned i = 0; i != NumParams; ++i)
 D->Params[i] = Record.readTemplateParameterList();
   if (Record.readInt()) // HasFriendDecl



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] a2398c5 - [Driver][OpenBSD] Enable unwind tables on all architectures

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Todd Mortimer
Date: 2022-02-28T10:50:51-08:00
New Revision: a2398c560144fbf30058c97c93492023d5c50cad

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

LOG: [Driver][OpenBSD] Enable unwind tables on all architectures

(cherry picked from commit bcbb03754ef19a8682635ab83fe5283db27b94f5)

Added: 


Modified: 
clang/lib/Driver/ToolChains/OpenBSD.h
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/OpenBSD.h 
b/clang/lib/Driver/ToolChains/OpenBSD.h
index 95c10cc62316e..9d668711b91b3 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.h
+++ b/clang/lib/Driver/ToolChains/OpenBSD.h
@@ -82,6 +82,10 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
   std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef 
Component,
 FileType Type = ToolChain::FT_Static) const 
override;
 
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
+return true;
+  }
+
   LangOptions::StackProtectorMode
   GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
 return LangOptions::SSPStrong;

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index d6d5ae994e67e..e46de575aec09 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -121,3 +121,10 @@
 // RUN: %clang -target powerpc-unknown-openbsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-POWERPC-SECUREPLT %s
 // CHECK-POWERPC-SECUREPLT: "-target-feature" "+secure-plt"
+
+// Check that unwind tables are enabled
+// RUN: %clang -target arm-unknown-openbsd -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=UNWIND-TABLES %s
+// RUN: %clang -target mips64-unknown-openbsd -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=UNWIND-TABLES %s
+// UNWIND-TABLES: "-funwind-tables=2"



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 4fe93c0 - [SLP] Fix assert from non-constant index in insertelement

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Brendon Cahoon
Date: 2022-02-28T10:51:21-08:00
New Revision: 4fe93c000b204d4d8a9a458e5eb2d4fabd85ba5e

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

LOG: [SLP] Fix assert from non-constant index in insertelement

A call to getInsertIndex() in getTreeCost() is returning None,
which causes an assert because a non-constant index value for
insertelement was not expected. This case occurs when the
insertelement index value is defined with a PHI.

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

(cherry picked from commit 3cc15e2cb657f3a814c8bd482bb7108782561abd)

Added: 
llvm/test/Transforms/SLPVectorizer/slp-variable-insertelement.ll

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 8a58b52df45d0..9eafd94efea28 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5682,39 +5682,41 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef 
VectorizedVals) {
 // to detect it as a final shuffled/identity match.
 if (auto *VU = dyn_cast_or_null(EU.User)) {
   if (auto *FTy = dyn_cast(VU->getType())) {
-unsigned InsertIdx = *getInsertIndex(VU);
-auto *It = find_if(FirstUsers, [VU](Value *V) {
-  return areTwoInsertFromSameBuildVector(VU,
- cast(V));
-});
-int VecId = -1;
-if (It == FirstUsers.end()) {
-  VF.push_back(FTy->getNumElements());
-  ShuffleMask.emplace_back(VF.back(), UndefMaskElem);
-  // Find the insertvector, vectorized in tree, if any.
-  Value *Base = VU;
-  while (isa(Base)) {
-// Build the mask for the vectorized insertelement instructions.
-if (const TreeEntry *E = getTreeEntry(Base)) {
-  VU = cast(Base);
-  do {
-int Idx = E->findLaneForValue(Base);
-ShuffleMask.back()[Idx] = Idx;
-Base = cast(Base)->getOperand(0);
-  } while (E == getTreeEntry(Base));
-  break;
+Optional InsertIdx = getInsertIndex(VU);
+if (InsertIdx) {
+  auto *It = find_if(FirstUsers, [VU](Value *V) {
+return areTwoInsertFromSameBuildVector(VU,
+   cast(V));
+  });
+  int VecId = -1;
+  if (It == FirstUsers.end()) {
+VF.push_back(FTy->getNumElements());
+ShuffleMask.emplace_back(VF.back(), UndefMaskElem);
+// Find the insertvector, vectorized in tree, if any.
+Value *Base = VU;
+while (isa(Base)) {
+  // Build the mask for the vectorized insertelement instructions.
+  if (const TreeEntry *E = getTreeEntry(Base)) {
+VU = cast(Base);
+do {
+  int Idx = E->findLaneForValue(Base);
+  ShuffleMask.back()[Idx] = Idx;
+  Base = cast(Base)->getOperand(0);
+} while (E == getTreeEntry(Base));
+break;
+  }
+  Base = cast(Base)->getOperand(0);
 }
-Base = cast(Base)->getOperand(0);
+FirstUsers.push_back(VU);
+DemandedElts.push_back(APInt::getZero(VF.back()));
+VecId = FirstUsers.size() - 1;
+  } else {
+VecId = std::distance(FirstUsers.begin(), It);
   }
-  FirstUsers.push_back(VU);
-  DemandedElts.push_back(APInt::getZero(VF.back()));
-  VecId = FirstUsers.size() - 1;
-} else {
-  VecId = std::distance(FirstUsers.begin(), It);
+  ShuffleMask[VecId][*InsertIdx] = EU.Lane;
+  DemandedElts[VecId].setBit(*InsertIdx);
+  continue;
 }
-ShuffleMask[VecId][InsertIdx] = EU.Lane;
-DemandedElts[VecId].setBit(InsertIdx);
-continue;
   }
 }
 

diff  --git a/llvm/test/Transforms/SLPVectorizer/slp-variable-insertelement.ll 
b/llvm/test/Transforms/SLPVectorizer/slp-variable-insertelement.ll
new file mode 100644
index 0..d97bfe59e55c6
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/slp-variable-insertelement.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -slp-vectorizer -slp-max-vf=2 -slp-min-reg-size=32 -S < %s | 
FileCheck %s
+
+; It is possible to compute the tree cost for an insertelement that does not
+; have a constant index when the index is a PHI. Check if getInsertIndex
+; returns None.
+
+define void @test() local_unnamed_addr {
+; CHECK-LABEL: @test(

[llvm-branch-commits] [llvm] 64534d2 - [InstCombine] Bail out of load-store forwarding for scalable vector types

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: David Sherwood
Date: 2022-02-28T10:51:43-08:00
New Revision: 64534d2f406c0cb87502b617940cb0d39b7ff489

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

LOG: [InstCombine] Bail out of load-store forwarding for scalable vector types

This patch fixes an invalid TypeSize->uint64_t implicit conversion in
FoldReinterpretLoadFromConst. If the size of the constant is scalable
we bail out of the optimisation for now.

Tests added here:

  Transforms/InstCombine/load-store-forward.ll

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

(cherry picked from commit 47eff645d8e873ba531014751c1c06a716a367e9)

Added: 


Modified: 
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Transforms/InstCombine/load-store-forward.ll

Removed: 




diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp 
b/llvm/lib/Analysis/ConstantFolding.cpp
index 7cf69f613c669..c0a9304b6257f 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -589,14 +589,17 @@ Constant *FoldReinterpretLoadFromConst(Constant *C, Type 
*LoadTy,
   if (BytesLoaded > 32 || BytesLoaded == 0)
 return nullptr;
 
-  int64_t InitializerSize = DL.getTypeAllocSize(C->getType()).getFixedSize();
-
   // If we're not accessing anything in this constant, the result is undefined.
   if (Offset <= -1 * static_cast(BytesLoaded))
 return UndefValue::get(IntType);
 
+  // TODO: We should be able to support scalable types.
+  TypeSize InitializerSize = DL.getTypeAllocSize(C->getType());
+  if (InitializerSize.isScalable())
+return nullptr;
+
   // If we're not accessing anything in this constant, the result is undefined.
-  if (Offset >= InitializerSize)
+  if (Offset >= InitializerSize.getFixedValue())
 return UndefValue::get(IntType);
 
   unsigned char RawBytes[32] = {0};

diff  --git a/llvm/test/Transforms/InstCombine/load-store-forward.ll 
b/llvm/test/Transforms/InstCombine/load-store-forward.ll
index c1a01454772f2..c7afe3c4c79fc 100644
--- a/llvm/test/Transforms/InstCombine/load-store-forward.ll
+++ b/llvm/test/Transforms/InstCombine/load-store-forward.ll
@@ -120,3 +120,172 @@ define i32 @vec_store_load_overlap(i32* %p) {
   %load = load i32, i32* %p5, align 2
   ret i32 %load
 }
+
+define i32 @load_i32_store_nxv4i32(i32* %a) {
+; CHECK-LABEL: @load_i32_store_nxv4i32(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast i32* [[A:%.*]] to *
+; CHECK-NEXT:store  shufflevector ( 
insertelement ( poison, i32 1, i64 0),  
poison,  zeroinitializer), * [[TMP0]], 
align 16
+; CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[A]], align 4
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+entry:
+  %0 = bitcast i32* %a to *
+  store  shufflevector ( insertelement 
( poison, i32 1, i64 0),  poison,  zeroinitializer), * %0, align 16
+  %1 = load i32, i32* %a, align 4
+  ret i32 %1
+}
+
+define i64 @load_i64_store_nxv8i8(i8* %a) {
+; CHECK-LABEL: @load_i64_store_nxv8i8(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[A:%.*]] to *
+; CHECK-NEXT:store  shufflevector ( 
insertelement ( poison, i8 1, i32 0),  
poison,  zeroinitializer), * [[TMP0]], align 
16
+; CHECK-NEXT:[[A2:%.*]] = bitcast i8* [[A]] to i64*
+; CHECK-NEXT:[[LOAD:%.*]] = load i64, i64* [[A2]], align 8
+; CHECK-NEXT:ret i64 [[LOAD]]
+;
+entry:
+  %0 = bitcast i8* %a to *
+  store  shufflevector ( insertelement 
( poison, i8 1, i32 0),  poison,  zeroinitializer), * %0, align 16
+  %a2 = bitcast i8* %a to i64*
+  %load = load i64, i64* %a2, align 8
+  ret i64 %load
+}
+
+define i64 @load_i64_store_nxv4i32(i32* %a) {
+; CHECK-LABEL: @load_i64_store_nxv4i32(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast i32* [[A:%.*]] to *
+; CHECK-NEXT:store  shufflevector ( 
insertelement ( poison, i32 1, i64 0),  
poison,  zeroinitializer), * [[TMP0]], 
align 16
+; CHECK-NEXT:[[A2:%.*]] = bitcast i32* [[A]] to i64*
+; CHECK-NEXT:[[LOAD:%.*]] = load i64, i64* [[A2]], align 8
+; CHECK-NEXT:ret i64 [[LOAD]]
+;
+entry:
+  %0 = bitcast i32* %a to *
+  store  shufflevector ( insertelement 
( poison, i32 1, i64 0),  poison,  zeroinitializer), * %0, align 16
+  %a2 = bitcast i32* %a to i64*
+  %load = load i64, i64* %a2, align 8
+  ret i64 %load
+}
+
+define i8 @load_i8_store_nxv4i32(i32* %a) {
+; CHECK-LABEL: @load_i8_store_nxv4i32(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast i32* [[A:%.*]] to *
+; CHECK-NEXT:store  shufflevector ( 
insertelement ( poison, i32 1, i64 0),  
poison,  zeroinitializer), * [[TMP0]], 
align 16
+; CHECK-NEXT:[[A2:%.*]] = bitcast i32* [[A]] to i8*
+; CHECK-NEXT:[[LOAD:%.*]] = load i8, i8* [[A2]], align 1
+; CHECK-NEXT:ret i8 [[LOAD]]
+;
+entry:
+  %0 = bitcast i32* %a to *
+  store  shufflevector ( insertelement 
( p

[llvm-branch-commits] [llvm] 5f5b687 - Fix warning introduced by 47eff645d8e873ba531014751c1c06a716a367e9

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: David Sherwood
Date: 2022-02-28T10:51:43-08:00
New Revision: 5f5b687460c3b1660e7a8a034ddfc5807fe41a8c

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

LOG: Fix warning introduced by 47eff645d8e873ba531014751c1c06a716a367e9

(cherry picked from commit dc0657277f2ff53f4e3ab01d856bcc576867ba9e)

Added: 


Modified: 
llvm/lib/Analysis/ConstantFolding.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp 
b/llvm/lib/Analysis/ConstantFolding.cpp
index c0a9304b6257..f6b955162fa5 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -599,7 +599,7 @@ Constant *FoldReinterpretLoadFromConst(Constant *C, Type 
*LoadTy,
 return nullptr;
 
   // If we're not accessing anything in this constant, the result is undefined.
-  if (Offset >= InitializerSize.getFixedValue())
+  if (Offset >= (int64_t)InitializerSize.getFixedValue())
 return UndefValue::get(IntType);
 
   unsigned char RawBytes[32] = {0};



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libunwind] 61e78c6 - [libunwind] Only include cet.h if __CET__ defined

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2022-02-28T10:52:06-08:00
New Revision: 61e78c64a38ae4a4d1e0ab1fa87d81de830a0162

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

LOG: [libunwind] Only include cet.h if __CET__ defined

We should not assume that the cet.h header exists just because
we're on x86 linux. Only include it if __CET__ is defined. This
makes the code more similar to what compiler-rt does in
https://github.com/llvm/llvm-project/blob/ee423d93ead39e94c2970b3cc7ef6e6faa75d10b/compiler-rt/lib/builtins/assembly.h#L17
(though that one also has a __has_include() check -- I've not found
that to be necessary).

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

(cherry picked from commit 2d2ef384b2f6e723edb793d08f52e7f4dc94ba3a)

Added: 


Modified: 
libunwind/src/assembly.h

Removed: 




diff  --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h
index 978f6bd619bd3..89293a555bfc4 100644
--- a/libunwind/src/assembly.h
+++ b/libunwind/src/assembly.h
@@ -15,7 +15,7 @@
 #ifndef UNWIND_ASSEMBLY_H
 #define UNWIND_ASSEMBLY_H
 
-#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__)
+#if defined(__linux__) && defined(__CET__)
 #include 
 #define _LIBUNWIND_CET_ENDBR _CET_ENDBR
 #else



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] ee0ae47 - [RISCV] Avoid infinite loop between DAGCombiner::visitMUL and RISCVISelLowering::transformAddImmMulImm

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Alex Bradbury
Date: 2022-02-28T10:52:32-08:00
New Revision: ee0ae47691d30802ae1eeb056d53886800d3c2fa

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

LOG: [RISCV] Avoid infinite loop between DAGCombiner::visitMUL and 
RISCVISelLowering::transformAddImmMulImm

See https://github.com/llvm/llvm-project/issues/53831 for a full discussion.

The basic issue is that DAGCombiner::visitMUL and
RISCVISelLowering;:transformAddImmMullImm get stuck in a loop, as the
current checks in transformAddImmMulImm aren't sufficient to avoid all
cases where DAGCombiner::isMulAddWithConstProfitable might trigger a
transformation. This patch makes transformAddImmMulImm bail out if C0
(the constant used for multiplication) has more than one use.

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

(cherry picked from commit c5bcfb983e47167a8a1826c1a64d7aa1849add06)

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/addimm-mulimm.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 2fe491ad5ea42..7fb9b7a85 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -7203,6 +7203,11 @@ static SDValue transformAddImmMulImm(SDNode *N, 
SelectionDAG &DAG,
   auto *N1C = dyn_cast(N->getOperand(1));
   if (!N0C || !N1C)
 return SDValue();
+  // If N0C has multiple uses it's possible one of the cases in
+  // DAGCombiner::isMulAddWithConstProfitable will be true, which would result
+  // in an infinite loop.
+  if (!N0C->hasOneUse())
+return SDValue();
   int64_t C0 = N0C->getSExtValue();
   int64_t C1 = N1C->getSExtValue();
   int64_t CA, CB;

diff  --git a/llvm/test/CodeGen/RISCV/addimm-mulimm.ll 
b/llvm/test/CodeGen/RISCV/addimm-mulimm.ll
index 4706f3904701d..adf0b98742e1b 100644
--- a/llvm/test/CodeGen/RISCV/addimm-mulimm.ll
+++ b/llvm/test/CodeGen/RISCV/addimm-mulimm.ll
@@ -872,3 +872,16 @@ define i64 @mulneg3000_sub8990_c(i64 %x) {
   %tmp1 = add i64 %tmp0, -8990
   ret i64 %tmp1
 }
+
+; This test case previously caused an infinite loop between transformations
+; performed in RISCVISelLowering;:transformAddImmMulImm and
+; DAGCombiner::visitMUL.
+define i1 @pr53831(i32 %x) {
+  %tmp0 = add i32 %x, 1
+  %tmp1 = mul i32 %tmp0, 24
+  %tmp2 = add i32 %tmp1, 1
+  %tmp3 = mul i32 %x, 24
+  %tmp4 = add i32 %tmp3, 2048
+  %tmp5 = icmp eq i32 %tmp4, %tmp2
+   ret i1 %tmp5
+}



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 03cf88f - [DSE] Extract a common PDT check (NFC)

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2022-02-28T10:53:06-08:00
New Revision: 03cf88fc94da55b989f1c14cb0460777834749c0

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

LOG: [DSE] Extract a common PDT check (NFC)

Added: 


Modified: 
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp 
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index ae636e7b61f72..8739ddce91606 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1508,54 +1508,49 @@ struct DSEState {
 CommonPred = PDT.findNearestCommonDominator(CommonPred, BB);
   }
 
-  // If CommonPred is in the set of killing blocks, just check if it
-  // post-dominates MaybeDeadAccess.
-  if (KillingBlocks.count(CommonPred)) {
-if (PDT.dominates(CommonPred, MaybeDeadAccess->getBlock()))
-  return {MaybeDeadAccess};
-return None;
-  }
-
   // If the common post-dominator does not post-dominate MaybeDeadAccess,
   // there is a path from MaybeDeadAccess to an exit not going through a
   // killing block.
-  if (PDT.dominates(CommonPred, MaybeDeadAccess->getBlock())) {
-SetVector WorkList;
-
-// If CommonPred is null, there are multiple exits from the function.
-// They all have to be added to the worklist.
-if (CommonPred)
-  WorkList.insert(CommonPred);
-else
-  for (BasicBlock *R : PDT.roots())
-WorkList.insert(R);
-
-NumCFGTries++;
-// Check if all paths starting from an exit node go through one of the
-// killing blocks before reaching MaybeDeadAccess.
-for (unsigned I = 0; I < WorkList.size(); I++) {
-  NumCFGChecks++;
-  BasicBlock *Current = WorkList[I];
-  if (KillingBlocks.count(Current))
-continue;
-  if (Current == MaybeDeadAccess->getBlock())
-return None;
+  if (!PDT.dominates(CommonPred, MaybeDeadAccess->getBlock()))
+return None;
 
-  // MaybeDeadAccess is reachable from the entry, so we don't have to
-  // explore unreachable blocks further.
-  if (!DT.isReachableFromEntry(Current))
-continue;
+  // If CommonPred itself is in the set of killing blocks, we're done.
+  if (KillingBlocks.count(CommonPred))
+return {MaybeDeadAccess};
 
-  for (BasicBlock *Pred : predecessors(Current))
-WorkList.insert(Pred);
+  SetVector WorkList;
 
-  if (WorkList.size() >= MemorySSAPathCheckLimit)
-return None;
-}
-NumCFGSuccess++;
-return {MaybeDeadAccess};
+  // If CommonPred is null, there are multiple exits from the function.
+  // They all have to be added to the worklist.
+  if (CommonPred)
+WorkList.insert(CommonPred);
+  else
+for (BasicBlock *R : PDT.roots())
+  WorkList.insert(R);
+
+  NumCFGTries++;
+  // Check if all paths starting from an exit node go through one of the
+  // killing blocks before reaching MaybeDeadAccess.
+  for (unsigned I = 0; I < WorkList.size(); I++) {
+NumCFGChecks++;
+BasicBlock *Current = WorkList[I];
+if (KillingBlocks.count(Current))
+  continue;
+if (Current == MaybeDeadAccess->getBlock())
+  return None;
+
+// MaybeDeadAccess is reachable from the entry, so we don't have to
+// explore unreachable blocks further.
+if (!DT.isReachableFromEntry(Current))
+  continue;
+
+for (BasicBlock *Pred : predecessors(Current))
+  WorkList.insert(Pred);
+
+if (WorkList.size() >= MemorySSAPathCheckLimit)
+  return None;
   }
-  return None;
+  NumCFGSuccess++;
 }
 
 // No aliasing MemoryUses of MaybeDeadAccess found, MaybeDeadAccess is



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 453361d - [DSE] Fall back to CFG scan for unreachable terminators.

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Florian Hahn
Date: 2022-02-28T10:53:06-08:00
New Revision: 453361d5ac0131ca713904bdd87166d429e17612

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

LOG: [DSE] Fall back to CFG scan for unreachable terminators.

Blocks with UnreachableInst terminators are considered as root nodes in
the PDT. This pessimize DSE, if there are no aliasing reads from the
potentially dead store and the block with the unreachable terminator.

If any of the root nodes of the PDF has UnreachableInst as terminator,
fall back to the CFG scan, even the common dominator of all killing
blocks does not post-dominate the block with potentially dead store.

It looks like the compile-time impact for the extra scans is negligible.
https://llvm-compile-time-tracker.com/compare.php?from=779bbbf27fe631154bdfaac7a443f198d4654688&to=ac59945f1bec1c6a7d7f5590c8c69fd9c5369c53&stat=instructions

Fixes #53800.

Reviewed By: nikic

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/multiblock-unreachable.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp 
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 8739ddce91606..c5c8e880eb3d5 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -770,6 +770,10 @@ struct DSEState {
   /// Keep track of instructions (partly) overlapping with killing MemoryDefs 
per
   /// basic block.
   MapVector IOLs;
+  // Check if there are root nodes that are terminated by UnreachableInst.
+  // Those roots pessimize post-dominance queries. If there are such roots,
+  // fall back to CFG scan starting from all non-unreachable roots.
+  bool AnyUnreachableExit;
 
   // Class contains self-reference, make sure it's not copied/moved.
   DSEState(const DSEState &) = delete;
@@ -805,6 +809,10 @@ struct DSEState {
 
 // Collect whether there is any irreducible control flow in the function.
 ContainsIrreducibleLoops = mayContainIrreducibleControl(F, &LI);
+
+AnyUnreachableExit = any_of(PDT.roots(), [](const BasicBlock *E) {
+  return isa(E->getTerminator());
+});
   }
 
   /// Return 'OW_Complete' if a store to the 'KillingLoc' location (by \p
@@ -1511,22 +1519,29 @@ struct DSEState {
   // If the common post-dominator does not post-dominate MaybeDeadAccess,
   // there is a path from MaybeDeadAccess to an exit not going through a
   // killing block.
-  if (!PDT.dominates(CommonPred, MaybeDeadAccess->getBlock()))
-return None;
+  if (!PDT.dominates(CommonPred, MaybeDeadAccess->getBlock())) {
+if (!AnyUnreachableExit)
+  return None;
+
+// Fall back to CFG scan starting at all non-unreachable roots if not
+// all paths to the exit go through CommonPred.
+CommonPred = nullptr;
+  }
 
   // If CommonPred itself is in the set of killing blocks, we're done.
   if (KillingBlocks.count(CommonPred))
 return {MaybeDeadAccess};
 
   SetVector WorkList;
-
   // If CommonPred is null, there are multiple exits from the function.
   // They all have to be added to the worklist.
   if (CommonPred)
 WorkList.insert(CommonPred);
   else
-for (BasicBlock *R : PDT.roots())
-  WorkList.insert(R);
+for (BasicBlock *R : PDT.roots()) {
+  if (!isa(R->getTerminator()))
+WorkList.insert(R);
+}
 
   NumCFGTries++;
   // Check if all paths starting from an exit node go through one of the

diff  --git 
a/llvm/test/Transforms/DeadStoreElimination/multiblock-unreachable.ll 
b/llvm/test/Transforms/DeadStoreElimination/multiblock-unreachable.ll
index 6548ec34ae0ac..a1af7271dcce0 100644
--- a/llvm/test/Transforms/DeadStoreElimination/multiblock-unreachable.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/multiblock-unreachable.ll
@@ -57,3 +57,139 @@ bb50: ; preds = 
%bb43
 bb53: ; preds = %bb53, %bb50, 
%bb22, %bb
   br label %bb53
 }
+
+declare void @exit()
+
+define void @unreachable_exit_with_no_call(i64* noalias %ptr, i1 %c.1) {
+; CHECK-LABEL: @unreachable_exit_with_no_call(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br i1 [[C_1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK:   if.then:
+; CHECK-NEXT:unreachable
+; CHECK:   if.end:
+; CHECK-NEXT:store i64 0, i64* [[PTR:%.*]], align 8
+; CHECK-NEXT:ret void
+;
+entry:
+  store i64 1, i64* %ptr, align 8
+  br i1 %c.1, label %if.then, label %if.end
+
+if.then:
+  unreachable
+
+if.end:
+  store i64 0, i64* %ptr, align 8
+  ret 

[llvm-branch-commits] [clang] b29813f - [OpenMP] Use executable path when searching for lld

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Joseph Huber
Date: 2022-02-28T15:16:01-08:00
New Revision: b29813fbbbaf222d80e422320fe67f4e3c0992be

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

LOG: [OpenMP] Use executable path when searching for lld

Summary:
This patch changes the ClangLinkerWrapper to use the executable path
when searching for the lld binary. Previously we relied on the program
name. Also not finding 'llvm-strip' is not considered an error anymore
because it is an optional optimization.

(cherry picked from commit 7ee8bd60f225b36623114f52103b0ecb91e2fb64)

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 2f5ddb77b7b3f..65c9a87edf3f1 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -174,6 +174,12 @@ static StringRef getDeviceFileExtension(StringRef 
DeviceTriple,
   return "o";
 }
 
+std::string getMainExecutable(const char *Name) {
+  void *Ptr = (void *)(intptr_t)&getMainExecutable;
+  auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+  return sys::path::parent_path(COWPath).str();
+}
+
 /// Extract the device file from the string '-=.bc'.
 DeviceFile getBitcodeLibrary(StringRef LibraryStr) {
   auto DeviceAndPath = StringRef(LibraryStr).split('=');
@@ -310,16 +316,12 @@ extractFromBinary(const ObjectFile &Obj,
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  void *P = (void *)(intptr_t)&Help;
-  StringRef COWDir = "";
-  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
-  if (!COWPath.empty())
-COWDir = sys::path::parent_path(COWPath);
   ErrorOr StripPath =
-  sys::findProgramByName("llvm-strip", {COWDir});
+  sys::findProgramByName("llvm-strip", {getMainExecutable("llvm-strip")});
   if (!StripPath)
-return createStringError(StripPath.getError(),
- "Unable to find 'llvm-strip' in path");
+StripPath = sys::findProgramByName("llvm-strip");
+  if (!StripPath)
+return None;
 
   SmallString<128> TempFile;
   if (Error Err = createOutputFile(Prefix + "-host", Extension, TempFile))
@@ -608,9 +610,9 @@ Expected link(ArrayRef 
InputFiles, Triple TheTriple,
 namespace amdgcn {
 Expected link(ArrayRef InputFiles, Triple TheTriple,
StringRef Arch) {
-  // AMDGPU uses the lld binary to link device object files.
+  // AMDGPU uses lld to link device object files.
   ErrorOr LLDPath =
-  sys::findProgramByName("lld", sys::path::parent_path(LinkerExecutable));
+  sys::findProgramByName("lld", {getMainExecutable("lld")});
   if (!LLDPath)
 LLDPath = sys::findProgramByName("lld");
   if (!LLDPath)



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 4de8e56 - [RISCV] Fix parseBareSymbol to not double-parse top-level operators

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Jessica Clarke
Date: 2022-02-28T15:18:17-08:00
New Revision: 4de8e56982784b4eafa7df70662129cb553a5f10

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

LOG: [RISCV] Fix parseBareSymbol to not double-parse top-level operators

By failing to lex the token we end up both parsing it as a binary
operator ourselves and parsing it as a unary operator when calling
parseExpression on the RHS. For plus this is harmless but for minus this
parses "foo - 4" as "foo - -4", effectively treating a top-level minus
as a plus.

Fixes https://github.com/llvm/llvm-project/issues/54105

Reviewed By: asb, MaskRay

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

(cherry picked from commit 6aa8521fdb7a551e32927cce71ecb0c424b51955)

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/rvi-pseudos.s

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 95319d1b0b74e..9a6ffb20615b2 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1607,9 +1607,11 @@ OperandMatchResultTy 
RISCVAsmParser::parseBareSymbol(OperandVector &Operands) {
 return MatchOperand_Success;
   case AsmToken::Plus:
 Opcode = MCBinaryExpr::Add;
+getLexer().Lex();
 break;
   case AsmToken::Minus:
 Opcode = MCBinaryExpr::Sub;
+getLexer().Lex();
 break;
   }
 

diff  --git a/llvm/test/MC/RISCV/rvi-pseudos.s 
b/llvm/test/MC/RISCV/rvi-pseudos.s
index 859f5fe640f6e..7a20cfc292fbc 100644
--- a/llvm/test/MC/RISCV/rvi-pseudos.s
+++ b/llvm/test/MC/RISCV/rvi-pseudos.s
@@ -187,3 +187,9 @@ sw a3, zero, a4
 # CHECK: auipc a5, %pcrel_hi((255+a_symbol)-4)
 # CHECK: addi  a5, a5, %pcrel_lo(.Lpcrel_hi30)
 lla a5, (0xFF + a_symbol) - 4
+
+## Check that we don't double-parse a top-level minus.
+# CHECK: .Lpcrel_hi31:
+# CHECK: auipc a5, %pcrel_hi(a_symbol-4)
+# CHECK: addi  a5, a5, %pcrel_lo(.Lpcrel_hi31)
+lla a5, a_symbol - 4



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 14c432b - [OpenMP] Add search path for llvm-strip

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Kelvin Li
Date: 2022-02-28T15:16:01-08:00
New Revision: 14c432b6a17a9ff447f2adecff4850fb62907aee

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

LOG: [OpenMP] Add search path for llvm-strip

Add the build directory to the search path for llvm-strip instead
of solely relying on the PATH environment variable setting.

Reviewed By: jhuber6

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

(cherry picked from commit 8ea4aed50a9f84d9617219ccc936c005c5f31c24)

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index de0af187731d3..2f5ddb77b7b3f 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -310,7 +310,13 @@ extractFromBinary(const ObjectFile &Obj,
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  ErrorOr StripPath = sys::findProgramByName("llvm-strip");
+  void *P = (void *)(intptr_t)&Help;
+  StringRef COWDir = "";
+  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
+  if (!COWPath.empty())
+COWDir = sys::path::parent_path(COWPath);
+  ErrorOr StripPath =
+  sys::findProgramByName("llvm-strip", {COWDir});
   if (!StripPath)
 return createStringError(StripPath.getError(),
  "Unable to find 'llvm-strip' in path");



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 779871c - [mlir-tblgen] Fix non-deterministic generating static verifier in DRR.

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Chia-hung Duan
Date: 2022-02-28T15:19:46-08:00
New Revision: 779871c3515add46508aa2901c838650eb01f2d3

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

LOG: [mlir-tblgen] Fix non-deterministic generating static verifier in DRR.

Use SetVector instead of DenseSet to ensure we always generate the same
name for the same function. This issue is found in
https://github.com/llvm/llvm-project/issues/53768.

Reviewed By: quinnp, rdzhabarov

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

(cherry picked from commit d56ef5ed20c5c1380c2d97e970c8fc4d4166bdb8)

Added: 


Modified: 
mlir/include/mlir/TableGen/CodeGenHelpers.h
mlir/tools/mlir-tblgen/CodeGenHelpers.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp

Removed: 




diff  --git a/mlir/include/mlir/TableGen/CodeGenHelpers.h 
b/mlir/include/mlir/TableGen/CodeGenHelpers.h
index db753f55cdf0f..d4d3294ea2a6f 100644
--- a/mlir/include/mlir/TableGen/CodeGenHelpers.h
+++ b/mlir/include/mlir/TableGen/CodeGenHelpers.h
@@ -114,7 +114,7 @@ class StaticVerifierFunctionEmitter {
   ///
   /// Constraints that do not meet the restriction that they can only reference
   /// `$_self`, `$_op`, and `$_builder` are not uniqued.
-  void emitPatternConstraints(const DenseSet &constraints);
+  void emitPatternConstraints(const ArrayRef constraints);
 
   /// Get the name of the static function used for the given type constraint.
   /// These functions are used for operand and result constraints and have the
@@ -178,7 +178,7 @@ class StaticVerifierFunctionEmitter {
   /// Collect and unique all the constraints used by operations.
   void collectOpConstraints(ArrayRef opDefs);
   /// Collect and unique all pattern constraints.
-  void collectPatternConstraints(const DenseSet &constraints);
+  void collectPatternConstraints(ArrayRef constraints);
 
   /// The output stream.
   raw_ostream &os;

diff  --git a/mlir/tools/mlir-tblgen/CodeGenHelpers.cpp 
b/mlir/tools/mlir-tblgen/CodeGenHelpers.cpp
index 973d50dab7ef3..7fb6d953b47f9 100644
--- a/mlir/tools/mlir-tblgen/CodeGenHelpers.cpp
+++ b/mlir/tools/mlir-tblgen/CodeGenHelpers.cpp
@@ -62,7 +62,7 @@ void StaticVerifierFunctionEmitter::emitOpConstraints(
 }
 
 void StaticVerifierFunctionEmitter::emitPatternConstraints(
-const llvm::DenseSet &constraints) {
+const llvm::ArrayRef constraints) {
   collectPatternConstraints(constraints);
   emitPatternConstraints();
 }
@@ -332,7 +332,7 @@ void StaticVerifierFunctionEmitter::collectOpConstraints(
 }
 
 void StaticVerifierFunctionEmitter::collectPatternConstraints(
-const llvm::DenseSet &constraints) {
+const llvm::ArrayRef constraints) {
   for (auto &leaf : constraints) {
 assert(leaf.isOperandMatcher() || leaf.isAttrMatcher());
 collectConstraint(

diff  --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp 
b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 4fcc880464c98..d37856112b196 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -322,7 +322,7 @@ class StaticMatcherHelper {
   int staticMatcherCounter = 0;
 
   // The DagLeaf which contains type or attr constraint.
-  DenseSet constraints;
+  SetVector constraints;
 
   // Static type/attribute verification function emitter.
   StaticVerifierFunctionEmitter staticVerifierEmitter;
@@ -1708,7 +1708,7 @@ void 
StaticMatcherHelper::populateStaticMatchers(raw_ostream &os) {
 }
 
 void StaticMatcherHelper::populateStaticConstraintFunctions(raw_ostream &os) {
-  staticVerifierEmitter.emitPatternConstraints(constraints);
+  staticVerifierEmitter.emitPatternConstraints(constraints.getArrayRef());
 }
 
 void StaticMatcherHelper::addPattern(Record *record) {



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 21f87ad - [Driver][NetBSD] -r: imply -nostdlib like GCC

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Brad Smith
Date: 2022-02-28T16:19:51-08:00
New Revision: 21f87ad9f590df3f016fa6c738b374b9971fb36e

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

LOG: [Driver][NetBSD] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

(cherry picked from commit d241ce0f97e47afa4f01a643ebbb4eafd729b403)

Added: 


Modified: 
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/test/Driver/netbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 37b1fc5215ff5..d1eda14a51f01 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -236,7 +236,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back(
   Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
@@ -294,7 +295,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 // Use the static OpenMP runtime with -static-openmp
 bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
 !Args.hasArg(options::OPT_static);
@@ -330,7 +332,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
   CmdArgs.push_back(
   Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));

diff  --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index 812889309a0f7..b549b3cde9b5a 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -467,3 +467,11 @@
 // RUN: %clang -target powerpc-unknown-netbsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=POWERPC-SECUREPLT %s
 // POWERPC-SECUREPLT: "-target-feature" "+secure-plt"
+
+// -r suppresses default -l and crt*.o like -nostdlib.
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-netbsd -r \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=RELOCATABLE %s
+// RELOCATABLE: "-r"
+// RELOCATABLE-NOT: "-l
+// RELOCATABLE-NOT: crt{{[^.]+}}.o



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] e08bab8 - [Driver][DragonFly] -r: imply -nostdlib like GCC

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Brad Smith
Date: 2022-02-28T16:21:03-08:00
New Revision: e08bab88c9007a76a61330db3266eaa49ebe5683

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

LOG: [Driver][DragonFly] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

(cherry picked from commit cbd9d136ef8164970957317737cf51182acd236c)

Added: 


Modified: 
clang/lib/Driver/ToolChains/DragonFly.cpp
clang/test/Driver/dragonfly.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/DragonFly.cpp 
b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 9568b47e89e67..8cfec6a6c4e05 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -91,7 +91,8 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared)) {
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
@@ -119,7 +120,8 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 CmdArgs.push_back("-L/usr/lib/gcc80");
 
 if (!Args.hasArg(options::OPT_static)) {
@@ -158,7 +160,8 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
   CmdArgs.push_back(
   Args.MakeArgString(getToolChain().GetFilePath("crtendS.o")));

diff  --git a/clang/test/Driver/dragonfly.c b/clang/test/Driver/dragonfly.c
index 20921bb38af0e..6c6d1909fe1b0 100644
--- a/clang/test/Driver/dragonfly.c
+++ b/clang/test/Driver/dragonfly.c
@@ -4,4 +4,9 @@
 // CHECK: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-dragonfly"
 // CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" 
"/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=gnu" "--enable-new-dtags" "-o" 
"a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" 
"-L{{.*}}gcc{{.*}}" "-rpath" "{{.*}}gcc{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" 
"{{.*}}crtn.o"
 
-
+// -r suppresses default -l and crt*.o like -nostdlib.
+// RUN: %clang -### %s --target=x86_64-pc-dragonfly -r \
+// RUN:   2>&1 | FileCheck %s --check-prefix=RELOCATABLE
+// RELOCATABLE: "-r"
+// RELOCATABLE-NOT: "-l
+// RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] d09f84a - [compiler-rt] Force ABI to libcxxabi when building cxustom libc++

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Dimitry Andric
Date: 2022-02-28T16:53:34-08:00
New Revision: d09f84adff1eb6003eedad1069e22e7d78a54e08

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

LOG: [compiler-rt] Force ABI to libcxxabi when building cxustom libc++

Follow-up to 458ead66dc37, which replaced the bespoke CMakeLists.txt
file for building a custom instrumented libc++ with an invocation of the
runtimes build.

In the the bespoke CMakeLists.txt, the LIBCXX_CXX_ABI setting was forced
to libcxxabi, but this was not done for the CMake invocation for the
runtimes build. This would cause CMake configuration issues on platforms
where the default LIBCXX_CXX_ABI setting is not libcxxabi, such as
FreeBSD.

Add `-DLIBCXX_CXX_ABI=libcxxabi` to that invocation, to make sure the
custom instrumented libc++ always uses the expected ABI.

Reviewed By: phosek

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

(cherry picked from commit a9f1a9c00af3badc991028b313fcc701599c8ac2)

Added: 


Modified: 
compiler-rt/cmake/Modules/AddCompilerRT.cmake

Removed: 




diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index b69833cbcc09b..4a496fc18f657 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -638,6 +638,7 @@ macro(add_custom_libcxx name prefix)
-DLIBCXXABI_ENABLE_SHARED=OFF
-DLIBCXXABI_HERMETIC_STATIC_LIBRARY=ON
-DLIBCXXABI_INCLUDE_TESTS=OFF
+   -DLIBCXX_CXX_ABI=libcxxabi
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
-DLIBCXX_ENABLE_SHARED=OFF
-DLIBCXX_HERMETIC_STATIC_LIBRARY=ON



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libunwind] b3e9abd - [libunwind] Further fix for 32-bit PowerPC processors without AltiVec

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: George Koehler
Date: 2022-02-28T21:08:16-08:00
New Revision: b3e9abd9683b11e81b7711fd654157b6b81b0509

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

LOG: [libunwind] Further fix for 32-bit PowerPC processors without AltiVec

https://reviews.llvm.org/D91906 did most of the work necessary to fix libunwind 
on
32-bit PowerPC processors without AltiVec, but there was one more piece 
necessary.

Reviewed By: luporl

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

(cherry picked from commit 3fa2e66c10aadac1d209afadba34d90c9bd95221)

Added: 


Modified: 
libunwind/src/UnwindRegistersSave.S

Removed: 




diff  --git a/libunwind/src/UnwindRegistersSave.S 
b/libunwind/src/UnwindRegistersSave.S
index 9566bb0335fee..b39489235ce63 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -603,9 +603,11 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   stw 30,128(3)
   stw 31,132(3)
 
+#if defined(__ALTIVEC__)
   // save VRSave register
   mfspr   0, 256
   stw 0, 156(3)
+#endif
   // save CR registers
   mfcr0
   stw 0, 136(3)



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 3d913ec - [llvm] [cmake] Fix finding modern ounit2

2022-02-28 Thread Tom Stellard via llvm-branch-commits

Author: Michał Górny
Date: 2022-02-28T21:11:17-08:00
New Revision: 3d913ec923083be7f8baeb3128849949e97b1f43

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

LOG: [llvm] [cmake] Fix finding modern ounit2

Apparently modern versions of ounit2 can only be found as "ounit2"
rather than "oUnit" version 2.  Update the CMake check to support both
variants.  This makes the OCaml tests run again with ounit2-2.2.4.

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

(cherry picked from commit 919dba9248f63d50e679ad5741d99ed8a8047227)

Added: 


Modified: 
llvm/cmake/config-ix.cmake

Removed: 




diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index a138d372d3b29..c70b8b3787a0a 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -650,7 +650,12 @@ else()
   find_ocamlfind_package(ctypes VERSION 0.4 OPTIONAL)
   if( HAVE_OCAML_CTYPES )
 message(STATUS "OCaml bindings enabled.")
-find_ocamlfind_package(oUnit VERSION 2 OPTIONAL)
+find_ocamlfind_package(ounit2 OPTIONAL)
+if ( HAVE_OCAML_OUNIT2 )
+  set(HAVE_OCAML_OUNIT TRUE)
+else()
+  find_ocamlfind_package(oUnit VERSION 2 OPTIONAL)
+endif()
 set(LLVM_BINDINGS "${LLVM_BINDINGS} ocaml")
 
 set(LLVM_OCAML_INSTALL_PATH "${OCAML_STDLIB_PATH}" CACHE STRING



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits