[llvm-branch-commits] [llvm] cd4ebb2 - [LazyCallGraph] Skip blockaddresses

2021-12-20 Thread Tom Stellard via llvm-branch-commits

Author: Arthur Eubanks
Date: 2021-12-20T10:20:54-08:00
New Revision: cd4ebb2918ae6cd938aabc3e95d5739b4d067f83

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

LOG: [LazyCallGraph] Skip blockaddresses

blockaddresses do not participate in the call graph since the only
instructions that use them must all return to someplace within the
current function. And passes cannot retrieve a function address from a
blockaddress.

This was suggested by efriedma in D58260.

Fixes PR50881.

Reviewed By: nickdesaulniers

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

(cherry picked from commit 029f1a53448979365ab965572356b83edc82f755)

Added: 
llvm/test/Analysis/LazyCallGraph/blockaddress.ll

Modified: 
llvm/include/llvm/Analysis/LazyCallGraph.h
llvm/test/Transforms/Attributor/IPConstantProp/dangling-block-address.ll
llvm/test/Transforms/Attributor/liveness.ll
llvm/unittests/Analysis/LazyCallGraphTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/LazyCallGraph.h 
b/llvm/include/llvm/Analysis/LazyCallGraph.h
index 81500905c0f50..148be34aa73b8 100644
--- a/llvm/include/llvm/Analysis/LazyCallGraph.h
+++ b/llvm/include/llvm/Analysis/LazyCallGraph.h
@@ -1098,28 +1098,10 @@ class LazyCallGraph {
 continue;
   }
 
-  // The blockaddress constant expression is a weird special case, we can't
-  // generically walk its operands the way we do for all other constants.
-  if (BlockAddress *BA = dyn_cast(C)) {
-// If we've already visited the function referred to by the block
-// address, we don't need to revisit it.
-if (Visited.count(BA->getFunction()))
-  continue;
-
-// If all of the blockaddress' users are instructions within the
-// referred to function, we don't need to insert a cycle.
-if (llvm::all_of(BA->users(), [&](User *U) {
-  if (Instruction *I = dyn_cast(U))
-return I->getFunction() == BA->getFunction();
-  return false;
-}))
-  continue;
-
-// Otherwise we should go visit the referred to function.
-Visited.insert(BA->getFunction());
-Worklist.push_back(BA->getFunction());
+  // blockaddresses are weird and don't participate in the call graph 
anyway,
+  // skip them.
+  if (isa(C))
 continue;
-  }
 
   for (Value *Op : C->operand_values())
 if (Visited.insert(cast(Op)).second)

diff  --git a/llvm/test/Analysis/LazyCallGraph/blockaddress.ll 
b/llvm/test/Analysis/LazyCallGraph/blockaddress.ll
new file mode 100644
index 0..cf2d00bce6db8
--- /dev/null
+++ b/llvm/test/Analysis/LazyCallGraph/blockaddress.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes="cgscc(function(sccp,simplifycfg))" < %s -S | FileCheck %s
+
+define i32 @baz(i32 %y, i1 %b) {
+; CHECK-LABEL: @baz(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br i1 [[B:%.*]], label [[LAB:%.*]], label [[FOR_COND:%.*]]
+; CHECK:   for.cond:
+; CHECK-NEXT:[[P_0:%.*]] = phi i8* [ null, [[FOR_COND]] ], [ 
blockaddress(@baz, [[LAB]]), [[ENTRY:%.*]] ]
+; CHECK-NEXT:[[INCDEC_PTR:%.*]] = getelementptr inbounds i8, i8* [[P_0]], 
i64 1
+; CHECK-NEXT:br label [[FOR_COND]]
+; CHECK:   lab:
+; CHECK-NEXT:ret i32 0
+;
+entry:
+  br i1 %b, label %lab, label %for.cond.preheader
+
+for.cond.preheader:
+  br label %for.cond
+
+for.cond:
+  %p.0 = phi i8* [ null, %for.cond ], [ blockaddress(@baz, %lab), 
%for.cond.preheader ]
+  %incdec.ptr = getelementptr inbounds i8, i8* %p.0, i64 1
+  br label %for.cond
+
+lab:
+  ret i32 0
+}

diff  --git 
a/llvm/test/Transforms/Attributor/IPConstantProp/dangling-block-address.ll 
b/llvm/test/Transforms/Attributor/IPConstantProp/dangling-block-address.ll
index 3ddf81dfc1ac7..c4ae94bdd9100 100644
--- a/llvm/test/Transforms/Attributor/IPConstantProp/dangling-block-address.ll
+++ b/llvm/test/Transforms/Attributor/IPConstantProp/dangling-block-address.ll
@@ -34,37 +34,23 @@ entry:
 }
 
 define internal void @bar(i32* nocapture %pc) nounwind readonly {
-; IS__CGSCC_OPM: Function Attrs: nounwind readonly
-; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@bar
-; IS__CGSCC_OPM-SAME: (i32* nocapture [[PC:%.*]]) #[[ATTR1:[0-9]+]] {
-; IS__CGSCC_OPM-NEXT:  entry:
-; IS__CGSCC_OPM-NEXT:br label [[INDIRECTGOTO:%.*]]
-; IS__CGSCC_OPM:   lab0:
-; IS__CGSCC_OPM-NEXT:[[INDVAR_NEXT:%.*]] = add i32 [[INDVAR:%.*]], 1
-; IS__CGSCC_OPM-NEXT:br label [[INDIRECTGOTO]]
-; IS__CGSCC_OPM:   end:
-; IS__CGSCC_OPM-NEXT:ret void
-; IS__CGSCC_OPM:   indirectgoto:
-; IS__CGSCC_OPM-NEXT:[[INDVAR]] = phi i32 [ [[INDVAR_NEXT]], [[LAB0:%.*]] 
], [ 0, [[ENTRY:%.*]] ]
-; IS__CGSCC_OPM-NEXT:[[PC_ADDR_0:%.*]] = g

[llvm-branch-commits] [clang] 578e500 - [Sparc] Create an error when `__builtin_longjmp` is used

2021-12-20 Thread Tom Stellard via llvm-branch-commits

Author: Tee KOBAYASHI
Date: 2021-12-20T10:25:14-08:00
New Revision: 578e500fe5ba0abbb1ed212db720ce22aa2147d2

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

LOG: [Sparc] Create an error when `__builtin_longjmp` is used

Support for builtin setjmp/longjmp was removed by 
https://reviews.llvm.org/D51487. An
error should be created when compiling C code using __builtin_setjmp or 
__builtin_longjmp.

Reviewed By: dcederman

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

(cherry picked from commit eeb4266f8137c232f0f218a727dd12b5d4f52adc)

Added: 


Modified: 
clang/lib/Basic/Targets/Sparc.h
clang/test/Sema/builtin-longjmp.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index 07844abafe11b..e9f8c10db7b04 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -50,8 +50,6 @@ class LLVM_LIBRARY_VISIBILITY SparcTargetInfo : public 
TargetInfo {
 
   bool hasFeature(StringRef Feature) const override;
 
-  bool hasSjLjLowering() const override { return true; }
-
   ArrayRef getTargetBuiltins() const override {
 // FIXME: Implement!
 return None;
@@ -180,7 +178,6 @@ class LLVM_LIBRARY_VISIBILITY SparcV8TargetInfo : public 
SparcTargetInfo {
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
-  bool hasSjLjLowering() const override { return true; }
   bool hasExtIntType() const override { return true; }
 };
 

diff  --git a/clang/test/Sema/builtin-longjmp.c 
b/clang/test/Sema/builtin-longjmp.c
index 3023098a76310..99463cf3385a1 100644
--- a/clang/test/Sema/builtin-longjmp.c
+++ b/clang/test/Sema/builtin-longjmp.c
@@ -3,12 +3,12 @@
 // RUN: %clang_cc1 -triple x86_64-windows -emit-llvm < %s| FileCheck %s
 // RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm < %s| FileCheck 
%s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm < %s| 
FileCheck %s
-// RUN: %clang_cc1 -triple sparc-eabi-unknown -emit-llvm < %s | FileCheck %s
 // RUN: %clang_cc1 -triple ve-unknown-unknown -emit-llvm < %s | FileCheck %s
 
 // RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm-only -verify %s
 // RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm-only -verify %s
 // RUN: %clang_cc1 -triple mips64-unknown-unknown -emit-llvm-only -verify %s
+// RUN: %clang_cc1 -triple sparc-eabi-unknown -emit-llvm-only -verify %s
 
 // Check that __builtin_longjmp and __builtin_setjmp are lowered into
 // IR intrinsics on those architectures that can handle them.



___
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] c1b51f0 - [msan] Disabled test failing on new GLIBC

2021-12-20 Thread Tom Stellard via llvm-branch-commits

Author: Vitaly Buka
Date: 2021-12-20T15:38:55-08:00
New Revision: c1b51f098751b384040c3f4c5a4608f208d5e3f5

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

LOG: [msan] Disabled test failing on new GLIBC

(cherry picked from commit 118757af11954ffd43c16a41e39348e0907bba92)

Added: 


Modified: 
compiler-rt/test/lit.common.cfg.py
compiler-rt/test/msan/preinit_array.cpp

Removed: 




diff  --git a/compiler-rt/test/lit.common.cfg.py 
b/compiler-rt/test/lit.common.cfg.py
index 9253aff2fb428..c7be6f640fcb3 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -491,7 +491,7 @@ def get_macos_aligned_version(macos_vers):
   if not config.android and len(ver_lines) and ver_lines[0].startswith(b"ldd 
"):
 from distutils.version import LooseVersion
 ver = LooseVersion(ver_lines[0].split()[-1].decode())
-for required in ["2.27", "2.30"]:
+for required in ["2.27", "2.30", "2.34"]:
   if ver >= LooseVersion(required):
 config.available_features.add("glibc-" + required)
 

diff  --git a/compiler-rt/test/msan/preinit_array.cpp 
b/compiler-rt/test/msan/preinit_array.cpp
index 6f877bac0b1c3..c72004ecfb21b 100644
--- a/compiler-rt/test/msan/preinit_array.cpp
+++ b/compiler-rt/test/msan/preinit_array.cpp
@@ -1,5 +1,8 @@
 // RUN: %clangxx_msan -O0 %s -o %t && %run %t
 
+// FIXME: Something changed in glibc 2.34, maybe earier.
+// UNSUPPORTED: glibc-2.34
+
 #include 
 
 volatile int global;



___
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] 2c6c3e4 - [asan] Fix "no matching function" on GCC

2021-12-20 Thread Tom Stellard via llvm-branch-commits

Author: Vitaly Buka
Date: 2021-12-20T21:50:02-08:00
New Revision: 2c6c3e4b713b05f249d75c3345785b6dad11c970

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

LOG: [asan] Fix "no matching function" on GCC

(cherry picked from commit 4b768eeb976ec15a2701f9a7b3eac2b0b43e8a7d)

Added: 


Modified: 
compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp

Removed: 




diff  --git 
a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp 
b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
index a2082ed082154..101c35fa10be6 100644
--- a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
@@ -139,7 +139,7 @@ void *threadFun(void *AltStack) {
 int main() {
   size_t const PageSize = sysconf(_SC_PAGESIZE);
   // The Solaris defaults of 4k (32-bit) and 8k (64-bit) are too small.
-  size_t const MinStackSize = std::max(PTHREAD_STACK_MIN, 16 * 1024);
+  size_t const MinStackSize = std::max(PTHREAD_STACK_MIN, 16 * 1024);
   // To align the alternate stack, we round this up to page_size.
   size_t const DefaultStackSize =
   (MinStackSize - 1 + PageSize) & ~(PageSize - 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] [compiler-rt] bdd28a2 - [sanitizer] Don't test __pthread_mutex_lock with GLIBC 2.34

2021-12-20 Thread Tom Stellard via llvm-branch-commits

Author: Vitaly Buka
Date: 2021-12-20T22:04:17-08:00
New Revision: bdd28a2a138f0a6db356233a6fe65f49e0016769

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

LOG: [sanitizer] Don't test __pthread_mutex_lock with GLIBC 2.34

(cherry picked from commit e60b3fcefa62311a93a9f7c8589a1da5f25b1ba9)

Added: 


Modified: 
compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_mutex.cpp

Removed: 




diff  --git 
a/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_mutex.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_mutex.cpp
index 610958143b472..fee88666b2ec0 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_mutex.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_mutex.cpp
@@ -4,7 +4,12 @@
 
 #include 
 
-#ifdef USE_GLIBC
+#if !defined(__GLIBC_PREREQ)
+#define __GLIBC_PREREQ(a, b) 0
+#endif
+
+#if defined(USE_GLIBC) && !__GLIBC_PREREQ(2, 34)
+// They were removed from GLIBC 2.34
 extern "C" int __pthread_mutex_lock(pthread_mutex_t *__mutex);
 extern "C" int __pthread_mutex_unlock(pthread_mutex_t *__mutex);
 #define LOCK __pthread_mutex_lock



___
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] 5b2990a - [ELF] #undef PPC to support GCC powerpc32 build

2021-12-20 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2021-12-20T22:18:21-08:00
New Revision: 5b2990a6ff77d8026258fc51c5767e9ee0662f1a

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

LOG: [ELF] #undef PPC to support GCC powerpc32 build

GCC's powerpc32 port predefines `PPC` as a macro in GNU C++ mode in some 
configurations (Linux,
FreeBSD, and some others. See `builtin_define_std ("PPC"); ` in 
gcc/config/rs6000).

```
% powerpc-linux-gnu-g++ -E -dM -xc++ /dev/null -o - | grep -w PPC
#define PPC 1
```

Fixes https://bugs.gentoo.org/829599

Reviewed By: thesamesam

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

(cherry picked from commit bee5bc9075a44ae74f57a956ebe6d7ce7aa7524b)

Added: 


Modified: 
lld/ELF/Arch/PPC.cpp

Removed: 




diff  --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp
index aaecef6ee94fc..d9334d5bf8538 100644
--- a/lld/ELF/Arch/PPC.cpp
+++ b/lld/ELF/Arch/PPC.cpp
@@ -20,6 +20,9 @@ using namespace llvm::ELF;
 using namespace lld;
 using namespace lld::elf;
 
+// Undefine the macro predefined by GCC powerpc32.
+#undef PPC
+
 namespace {
 class PPC final : public TargetInfo {
 public:



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