[llvm-branch-commits] [llvm] 703ee97 - [AlignFromAssume] Bailout w/non-constant alignments (pr51680)

2021-09-01 Thread Tom Stellard via llvm-branch-commits

Author: Philip Reames
Date: 2021-09-01T17:36:37-07:00
New Revision: 703ee975d26a1542e2a431722af0ce904a0ca149

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

LOG: [AlignFromAssume] Bailout w/non-constant alignments (pr51680)

This is a bailout for pr51680.  This pass appears to assume that the alignment 
operand to an align tag on an assume bundle is constant.  This doesn't appear 
to be required anywhere, and clang happily generates non-constant alignments 
for cases such as this case taken from the bug report:

// clang -cc1 -triple powerpc64-- -S -O1 opal_pci-min.c
extern int a[];
long *b;
long c;
void *d(long, int *, int, long, long, long) __attribute__((__alloc_align__(6)));
void e() {
  b = d(c, a, 0, 0, 5, c);
  b[0] = 0;
}

This was exposed by a SCEV change which allowed a non-constant alignment to 
reach further into the pass' code.  We could generalize the pass, but for now, 
let's fix the crash.

(cherry picked from commit 9b45fd909ffa754acbb4e927bc2d55c7ab0d4e3f)

Added: 


Modified: 
llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
llvm/test/Transforms/AlignmentFromAssumptions/simple.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp 
b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
index be21db9087d2e..e4ec5f266eb85 100644
--- a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -221,6 +221,10 @@ bool 
AlignmentFromAssumptionsPass::extractAlignmentInfo(CallInst *I,
   AAPtr = AAPtr->stripPointerCastsSameRepresentation();
   AlignSCEV = SE->getSCEV(AlignOB.Inputs[1].get());
   AlignSCEV = SE->getTruncateOrZeroExtend(AlignSCEV, Int64Ty);
+  if (!isa(AlignSCEV))
+// Added to suppress a crash because consumer doesn't expect non-constant
+// alignments in the assume bundle.  TODO: Consider generalizing caller.
+return false;
   if (AlignOB.Inputs.size() == 3)
 OffSCEV = SE->getSCEV(AlignOB.Inputs[2].get());
   else

diff  --git a/llvm/test/Transforms/AlignmentFromAssumptions/simple.ll 
b/llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
index 80761ad3be6b2..d8b1c618e74bd 100644
--- a/llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
+++ b/llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
@@ -252,6 +252,19 @@ entry:
 ; CHECK: ret i32 undef
 }
 
+
+; Variable alignments appear to be legal, don't crash
+define i32 @pr51680(i32* nocapture %a, i32 %align) nounwind uwtable readonly {
+entry:
+  tail call void @llvm.assume(i1 true) ["align"(i32* %a, i32 %align)]
+  %0 = load i32, i32* %a, align 4
+  ret i32 %0
+
+; CHECK-LABEL: @pr51680
+; CHECK: load i32, i32* {{[^,]+}}, align 4
+; CHECK: ret i32
+}
+
 declare void @llvm.assume(i1) nounwind
 
 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind



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


[llvm-branch-commits] [llvm] bcb4361 - [NewPM] Add missing LTO ArgPromotion pass

2021-09-01 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2021-09-01T17:37:57-07:00
New Revision: bcb43617cb7f124ea5c10c29818eca6f44dc5f58

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

LOG: [NewPM] Add missing LTO ArgPromotion pass

This is a followup to D96780 to add one more pass missing from the
NewPM LTO pipeline. The missing ArgPromotion run is inserted at
the same position as in the LegacyPM, resolving the already
present FIXME:
https://github.com/llvm/llvm-project/blob/16086d47c0d0cd08ffae8e69a69c88653e654d01/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp#L1096-L1098

The compile-time impact is minimal with ~0.1% geomean regression
on CTMark.

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

(cherry picked from commit b28c3b9d9f4292d7779a0e2661d308f1230c6ecd)

Added: 


Modified: 
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pm-lto-defaults.ll

Removed: 




diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 79fcc8569b6d0..0bc955dbbfea3 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -1784,9 +1784,12 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel 
Level,
   MPM.addPass(GlobalOptPass());
 
   // Garbage collect dead functions.
-  // FIXME: Add ArgumentPromotion pass after once it's ported.
   MPM.addPass(GlobalDCEPass());
 
+  // If we didn't decide to inline a function, check to see if we can
+  // transform it to pass arguments by value instead of by reference.
+  
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(ArgumentPromotionPass()));
+
   FunctionPassManager FPM;
   // The IPO Passes may leave cruft around. Clean up after them.
   FPM.addPass(InstCombinePass());

diff  --git a/llvm/test/Other/new-pm-lto-defaults.ll 
b/llvm/test/Other/new-pm-lto-defaults.ll
index 8f1830dbc610d..9a00f1931bff5 100644
--- a/llvm/test/Other/new-pm-lto-defaults.ll
+++ b/llvm/test/Other/new-pm-lto-defaults.ll
@@ -73,6 +73,7 @@
 ; CHECK-O23SZ-NEXT: Running pass: InlinerPass
 ; CHECK-O23SZ-NEXT: Running pass: GlobalOptPass
 ; CHECK-O23SZ-NEXT: Running pass: GlobalDCEPass
+; CHECK-O23SZ-NEXT: Running pass: ArgumentPromotionPass
 ; CHECK-O23SZ-NEXT: Running pass: InstCombinePass
 ; CHECK-EP-Peephole-NEXT: Running pass: NoOpFunctionPass
 ; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass



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


[llvm-branch-commits] [clang] 73c36a9 - [OpenMP][FIX] Allow declare variant to work with reference types

2021-09-01 Thread Tom Stellard via llvm-branch-commits

Author: Johannes Doerfert
Date: 2021-09-01T17:38:52-07:00
New Revision: 73c36a9be5584a9185c7ca922a50c58603e4a35e

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

LOG: [OpenMP][FIX] Allow declare variant to work with reference types

Reference types in the return or parameter position did cause the OpenMP
declare variant overload reasoning to give up. We should allow them as
we allow any other type.

This should fix the bug reported on the mailing list:
https://lists.llvm.org/pipermail/openmp-dev/2021-August/004094.html

Reviewed By: ABataev, pdhaliwal

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

(cherry picked from commit 2930c839a5877356db6966409f4f9f2cdbcf3a07)

Added: 
clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp

Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index fdba204fbe7ff..0e163f3161a3d 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9653,11 +9653,19 @@ static QualType mergeEnumWithInteger(ASTContext 
&Context, const EnumType *ET,
 QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
 bool OfBlockPointer,
 bool Unqualified, bool BlockReturnType) {
+  // For C++ we will not reach this code with reference types (see below),
+  // for OpenMP variant call overloading we might.
+  //
   // C++ [expr]: If an expression initially has the type "reference to T", the
   // type is adjusted to "T" prior to any further analysis, the expression
   // designates the object or function denoted by the reference, and the
   // expression is an lvalue unless the reference is an rvalue reference and
   // the expression is a function call (possibly inside parentheses).
+  if (LangOpts.OpenMP && LHS->getAs() &&
+  RHS->getAs() && LHS->getTypeClass() == 
RHS->getTypeClass())
+return mergeTypes(LHS->getAs()->getPointeeType(),
+  RHS->getAs()->getPointeeType(),
+  OfBlockPointer, Unqualified, BlockReturnType);
   if (LHS->getAs() || RHS->getAs())
 return {};
 

diff  --git 
a/clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp 
b/clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
new file mode 100644
index 0..6fa8cdc59bb40
--- /dev/null
+++ b/clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
@@ -0,0 +1,414 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump 
%s   | FileCheck %s
+// expected-no-diagnostics
+
+// Our very own std::move, copied from libcxx.
+template  struct remove_reference { typedef _Tp type; };
+template  struct remove_reference<_Tp &> { typedef _Tp type; };
+template  struct remove_reference<_Tp &&> { typedef _Tp type; };
+
+template 
+inline typename remove_reference<_Tp>::type &&
+move(_Tp &&__t) {
+  typedef typename remove_reference<_Tp>::type _Up;
+  return static_cast<_Up &&>(__t);
+}
+// ---
+
+int Good, Bad;
+int &also_before() {
+  return Bad;
+}
+int also_before(float &&) {
+  return 0;
+}
+
+#pragma omp begin declare variant match(implementation = {vendor(score(100) \
+ : llvm)})
+int also_after(void) {
+  return 1;
+}
+int also_after(int &) {
+  return 2;
+}
+// This one does overload the int(*)(double&) version!
+int also_after(double &) {
+  return 0;
+}
+int also_after(double &&) {
+  return 3;
+}
+int also_after(short &) {
+  return 5;
+}
+int also_after(short &&) {
+  return 0;
+}
+#pragma omp end declare variant
+#pragma omp begin declare variant match(implementation = {vendor(score(0) \
+ : llvm)})
+// This one does overload the int&(*)(void) version!
+int &also_before() {
+  return Good;
+}
+// This one does *not* overload the int(*)(float&&) version!
+int also_before(float &) {
+  return 6;
+}
+#pragma omp end declare variant
+
+int also_after(void) {
+  return 7;
+}
+int also_after(int) {
+  return 8;
+}
+int also_after(double &) {
+  return 9;
+}
+int also_after(short &&) {
+  return 10;
+}
+
+int test1() {
+  // Should return 0.
+  double d;
+  return also_after(d);
+}
+
+int test2() {
+  // Should return 0.
+  return &also_before() == &Good;
+}
+
+int test3(float &&f) {
+  // Should return 0.
+  return also_before(move(f));
+}
+
+int test4(short &&s) {
+  // Should return 0.
+  return also_after(move(s));
+}
+
+int test(float &&f, short &&s) {
+  // Should return 0.
+  return test1() + test2() + test3(move(f)) + test4(move(s));
+}
+
+// CHECK:  |-ClassTemplateDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, col:66> 
col:29 remove_reference
+// CHECK-NEXT: | |-TemplateTy

[llvm-branch-commits] [llvm] 9e41dc7 - [docs] Mention that the legacy PM is deprecated and will be removed after 14

2021-09-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2021-09-01T23:33:00-07:00
New Revision: 9e41dc71b8d4040fa5f0742022d6cf9852096744

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

LOG: [docs] Mention that the legacy PM is deprecated and will be removed after 
14

Per https://lists.llvm.org/pipermail/llvm-dev/2021-August/152305.html.

Reviewed By: MaskRay, fhahn

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

(cherry picked from commit 2413d6063b788c3abc69072d48afa0b2a6e3583c)

Added: 


Modified: 
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 9e9a7722b5e04..515e9fef6d2aa 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -64,6 +64,10 @@ Changes to the LLVM IR
 * The opaque pointer type ``ptr`` has been introduced. It is still in the
   process of being worked on and should not be used yet.
 
+* Using the legacy pass manager for the optimization pipeline is deprecated and
+  will be removed after LLVM 14. In the meantime, only minimal effort will be
+  made to maintain the legacy pass manager for the optimization pipeline.
+
 Changes to building LLVM
 
 



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