[llvm-branch-commits] [libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)

2024-05-21 Thread Nick Desaulniers via llvm-branch-commits

https://github.com/nickdesaulniers approved this pull request.

libc parts LGTM

https://github.com/llvm/llvm-project/pull/89755
___
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] release/18.x: [llvm][AArch64] Autoupgrade function attributes from Module attributes. (#82763) (PR #84039)

2024-03-18 Thread Nick Desaulniers via llvm-branch-commits

nickdesaulniers wrote:

We'll have a 3rd iteration of the patch to backport. This version should not be.

https://github.com/llvm/llvm-project/pull/84039
___
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] release/18.x: [llvm][AArch64] Autoupgrade function attributes from Module attributes. (#82763) (PR #84039)

2024-03-14 Thread Nick Desaulniers via llvm-branch-commits

https://github.com/nickdesaulniers closed 
https://github.com/llvm/llvm-project/pull/84039
___
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] release/18.x: [llvm][AArch64] Autoupgrade function attributes from Module attributes. (#82763) (PR #84039)

2024-03-14 Thread Nick Desaulniers via llvm-branch-commits

nickdesaulniers wrote:

Changing my mind here, we've identified the issue with this commit.

https://github.com/llvm/llvm-project/pull/82763#issuecomment-1997950893

https://github.com/llvm/llvm-project/pull/84039
___
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] [llvm][AArch64] Autoupgrade function attributes from Module attributes (PR #82742)

2024-02-26 Thread Nick Desaulniers via llvm-branch-commits

https://github.com/nickdesaulniers requested changes to this pull request.

sounds like this got reverted

https://github.com/llvm/llvm-project/pull/82742
___
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] [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (PR #82743)

2024-02-26 Thread Nick Desaulniers via llvm-branch-commits

nickdesaulniers wrote:

(also, I think you can use `/backport ` comment in any issue and llvmbot 
will generate these PRs for you.)

https://github.com/llvm/llvm-project/pull/82743
___
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] [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (PR #82743)

2024-02-26 Thread Nick Desaulniers via llvm-branch-commits

https://github.com/nickdesaulniers approved this pull request.


https://github.com/llvm/llvm-project/pull/82743
___
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] [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (PR #82743)

2024-02-26 Thread Nick Desaulniers via llvm-branch-commits

nickdesaulniers wrote:

LGTM

https://github.com/llvm/llvm-project/pull/82743
___
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] de579ba - [LowerConstantIntrinsics] reuse isManifestLogic from ConstantFolding

2021-05-17 Thread Nick Desaulniers via llvm-branch-commits

Author: Nick Desaulniers
Date: 2021-05-17T11:05:31-07:00
New Revision: de579bae6eabd02b815e549776b8c680957a0769

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

LOG: [LowerConstantIntrinsics] reuse isManifestLogic from ConstantFolding

GlobalVariables are Constants, yet should not unconditionally be
considered true for __builtin_constant_p.

Via the LangRef
https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic:

This intrinsic generates no code. If its argument is known to be a
manifest compile-time constant value, then the intrinsic will be
converted to a constant true value. Otherwise, it will be converted
to a constant false value.

In particular, note that if the argument is a constant expression
which refers to a global (the address of which _is_ a constant, but
not manifest during the compile), then the intrinsic evaluates to
false.

Move isManifestConstant from ConstantFolding to be a method of
Constant so that we can reuse the same logic in
LowerConstantIntrinsics.

pr/41459

Reviewed By: rsmith, george.burgess.iv

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

(cherry picked from commit 8c72749bd92d35397e93908bc5a504d4cbcef1cb)

Added: 


Modified: 
llvm/include/llvm/IR/Constant.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
llvm/test/Transforms/LowerConstantIntrinsics/constant-intrinsics.ll

Removed: 




diff  --git a/llvm/include/llvm/IR/Constant.h b/llvm/include/llvm/IR/Constant.h
index 0190aca27b724..71692c7460155 100644
--- a/llvm/include/llvm/IR/Constant.h
+++ b/llvm/include/llvm/IR/Constant.h
@@ -214,6 +214,10 @@ class Constant : public User {
   /// both must either be scalars or vectors with the same element count. If no
   /// changes are made, the constant C is returned.
   static Constant *mergeUndefsWith(Constant *C, Constant *Other);
+
+  /// Return true if a constant is ConstantData or a ConstantAggregate or
+  /// ConstantExpr that contain only ConstantData.
+  bool isManifestConstant() const;
 };
 
 } // end namespace llvm

diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp 
b/llvm/lib/Analysis/ConstantFolding.cpp
index f73890d548f09..cc1ce4c65821f 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1808,19 +1808,6 @@ double getValueAsDouble(ConstantFP *Op) {
   return APF.convertToDouble();
 }
 
-static bool isManifestConstant(const Constant *c) {
-  if (isa(c)) {
-return true;
-  } else if (isa(c) || isa(c)) {
-for (const Value *subc : c->operand_values()) {
-  if (!isManifestConstant(cast(subc)))
-return false;
-}
-return true;
-  }
-  return false;
-}
-
 static bool getConstIntOrUndef(Value *Op, const APInt *) {
   if (auto *CI = dyn_cast(Op)) {
 C = >getValue();
@@ -1845,7 +1832,7 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
 // We know we have a "Constant" argument. But we want to only
 // return true for manifest constants, not those that depend on
 // constants with unknowable values, e.g. GlobalValue or BlockAddress.
-if (isManifestConstant(Operands[0]))
+if (Operands[0]->isManifestConstant())
   return ConstantInt::getTrue(Ty->getContext());
 return nullptr;
   }

diff  --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 6fd205c654a8a..9f05917cf7cc8 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -803,6 +803,18 @@ Constant *Constant::mergeUndefsWith(Constant *C, Constant 
*Other) {
   return C;
 }
 
+bool Constant::isManifestConstant() const {
+  if (isa(this))
+return true;
+  if (isa(this) || isa(this)) {
+for (const Value *Op : operand_values())
+  if (!cast(Op)->isManifestConstant())
+return false;
+return true;
+  }
+  return false;
+}
+
 
//===--===//
 //ConstantInt
 
//===--===//

diff  --git a/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp 
b/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
index bfe8db83b0271..bb30c48127a0f 100644
--- a/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
@@ -43,10 +43,10 @@ STATISTIC(ObjectSizeIntrinsicsHandled,
   "Number of 'objectsize' intrinsic calls handled");
 
 static Value *lowerIsConstantIntrinsic(IntrinsicInst *II) {
-  Value *Op = II->getOperand(0);
-
-  return isa(Op) ? ConstantInt::getTrue(II->getType())
-   : ConstantInt::getFalse(II->getType());
+  if (auto *C = 

[llvm-branch-commits] [llvm] d368128 - [GVN] do not repeat PRE on failure to split critical edge

2021-01-25 Thread Nick Desaulniers via llvm-branch-commits

Author: Nick Desaulniers
Date: 2021-01-25T11:23:44-08:00
New Revision: d36812892c16b551f058774babbc8727737f80cd

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

LOG: [GVN] do not repeat PRE on failure to split critical edge

Fixes an infinite loop encountered in GVN.

GVN will delay PRE if it encounters critical edges, attempt to split
them later via calls to SplitCriticalEdge(), then restart.

The caller of GVN::splitCriticalEdges() assumed a return value of true
meant that critical edges were split, that the IR had changed, and that
PRE should be re-attempted, upon which we loop infinitely.

This was exposed after D88438, by compiling the Linux kernel for s390,
but the test case is reproducible on x86.

Fixes: https://github.com/ClangBuiltLinux/linux/issues/1261

Reviewed By: void

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

Added: 
llvm/test/Transforms/GVN/critical-edge-split-failure.ll

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

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/GVN.cpp 
b/llvm/lib/Transforms/Scalar/GVN.cpp
index 72248babba7e..c6b6d75aefe8 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2673,9 +2673,11 @@ BasicBlock *GVN::splitCriticalEdges(BasicBlock *Pred, 
BasicBlock *Succ) {
   BasicBlock *BB = SplitCriticalEdge(
   Pred, Succ,
   CriticalEdgeSplittingOptions(DT, LI, MSSAU).unsetPreserveLoopSimplify());
-  if (MD)
-MD->invalidateCachedPredecessors();
-  InvalidBlockRPONumbers = true;
+  if (BB) {
+if (MD)
+  MD->invalidateCachedPredecessors();
+InvalidBlockRPONumbers = true;
+  }
   return BB;
 }
 
@@ -2684,14 +2686,20 @@ BasicBlock *GVN::splitCriticalEdges(BasicBlock *Pred, 
BasicBlock *Succ) {
 bool GVN::splitCriticalEdges() {
   if (toSplit.empty())
 return false;
+
+  bool Changed = false;
   do {
 std::pair Edge = toSplit.pop_back_val();
-SplitCriticalEdge(Edge.first, Edge.second,
-  CriticalEdgeSplittingOptions(DT, LI, MSSAU));
+Changed |= SplitCriticalEdge(Edge.first, Edge.second,
+ CriticalEdgeSplittingOptions(DT, LI, MSSAU)) 
!=
+   nullptr;
   } while (!toSplit.empty());
-  if (MD) MD->invalidateCachedPredecessors();
-  InvalidBlockRPONumbers = true;
-  return true;
+  if (Changed) {
+if (MD)
+  MD->invalidateCachedPredecessors();
+InvalidBlockRPONumbers = true;
+  }
+  return Changed;
 }
 
 /// Executes one iteration of GVN

diff  --git a/llvm/test/Transforms/GVN/critical-edge-split-failure.ll 
b/llvm/test/Transforms/GVN/critical-edge-split-failure.ll
new file mode 100644
index ..662efd45bf25
--- /dev/null
+++ b/llvm/test/Transforms/GVN/critical-edge-split-failure.ll
@@ -0,0 +1,49 @@
+; RUN: opt -gvn -S -o - %s | FileCheck %s
+; RUN: opt -passes=gvn -S -o - %s | FileCheck %s
+
+%struct.sk_buff = type opaque
+
+@l2tp_recv_dequeue_session = external dso_local local_unnamed_addr global i32, 
align 4
+@l2tp_recv_dequeue_skb = external dso_local local_unnamed_addr global 
%struct.sk_buff*, align 8
+@l2tp_recv_dequeue_session_2 = external dso_local local_unnamed_addr global 
i32, align 4
+@l2tp_recv_dequeue_session_0 = external dso_local local_unnamed_addr global 
i32, align 4
+
+declare void @llvm.assume(i1 noundef)
+
+define dso_local void @l2tp_recv_dequeue() local_unnamed_addr {
+entry:
+  %0 = load i32, i32* @l2tp_recv_dequeue_session, align 4
+  %conv = sext i32 %0 to i64
+  %1 = inttoptr i64 %conv to %struct.sk_buff*
+  %2 = load i32, i32* @l2tp_recv_dequeue_session_2, align 4
+  %tobool.not = icmp eq i32 %2, 0
+  br label %for.cond
+
+for.cond: ; preds = %if.end, %entry
+  %storemerge = phi %struct.sk_buff* [ %1, %entry ], [ null, %if.end ]
+  store %struct.sk_buff* %storemerge, %struct.sk_buff** 
@l2tp_recv_dequeue_skb, align 8
+  br i1 %tobool.not, label %if.end, label %if.then
+
+if.then:  ; preds = %for.cond
+  %ns = bitcast %struct.sk_buff* %storemerge to i32*
+  %3 = load i32, i32* %ns, align 4
+  store i32 %3, i32* @l2tp_recv_dequeue_session_0, align 4
+; Splitting the critical edge from if.then to if.end will fail, but should not
+; cause an infinite loop in GVN. If we can one day split edges of callbr
+; indirect targets, great!
+; CHECK: callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* 
blockaddress(@l2tp_recv_dequeue, %if.end))
+; CHECK-NEXT: to label %asm.fallthrough.i [label %if.end]
+  callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* 
blockaddress(@l2tp_recv_dequeue, %if.end))
+  to label %asm.fallthrough.i [label %if.end]
+
+asm.fallthrough.i:; preds = %if.then
+  br label %if.end

[llvm-branch-commits] [llvm] ed0fd56 - BreakCriticalEdges: do not split the critical edge from a CallBr indirect successor

2021-01-15 Thread Nick Desaulniers via llvm-branch-commits

Author: Nick Desaulniers
Date: 2021-01-15T13:51:47-08:00
New Revision: ed0fd567ebdc61eb87346a58196a73f9b814

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

LOG: BreakCriticalEdges: do not split the critical edge from a CallBr indirect 
successor

Otherwise we'll fail the assertion in SplitBlockPredecessors() related
to splitting the edges from CallBr's.

Fixes: https://github.com/ClangBuiltLinux/linux/issues/1161
Fixes: https://github.com/ClangBuiltLinux/linux/issues/1252

Reviewed By: void, MaskRay, jyknight

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

Added: 
llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting2.ll

Modified: 
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp 
b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
index c9f08e5a9ed5..939a1a3a868d 100644
--- a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
+++ b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
@@ -158,22 +158,21 @@ BasicBlock *llvm::SplitCriticalEdge(Instruction *TI, 
unsigned SuccNum,
   SmallVector LoopPreds;
   // Check if extra modifications will be required to preserve loop-simplify
   // form after splitting. If it would require splitting blocks with IndirectBr
-  // terminators, bail out if preserving loop-simplify form is requested.
+  // or CallBr terminators, bail out if preserving loop-simplify form is
+  // requested.
   if (LI) {
 if (Loop *TIL = LI->getLoopFor(TIBB)) {
 
-  // The only that we can break LoopSimplify form by splitting a critical
-  // edge is if after the split there exists some edge from TIL to DestBB
-  // *and* the only edge into DestBB from outside of TIL is that of
+  // The only way that we can break LoopSimplify form by splitting a
+  // critical edge is if after the split there exists some edge from TIL to
+  // DestBB *and* the only edge into DestBB from outside of TIL is that of
   // NewBB. If the first isn't true, then LoopSimplify still holds, NewBB
   // is the new exit block and it has no non-loop predecessors. If the
   // second isn't true, then DestBB was not in LoopSimplify form prior to
   // the split as it had a non-loop predecessor. In both of these cases,
   // the predecessor must be directly in TIL, not in a subloop, or again
   // LoopSimplify doesn't hold.
-  for (pred_iterator I = pred_begin(DestBB), E = pred_end(DestBB); I != E;
-   ++I) {
-BasicBlock *P = *I;
+  for (BasicBlock *P : predecessors(DestBB)) {
 if (P == TIBB)
   continue; // The new block is known.
 if (LI->getLoopFor(P) != TIL) {
@@ -186,7 +185,10 @@ BasicBlock *llvm::SplitCriticalEdge(Instruction *TI, 
unsigned SuccNum,
   // Loop-simplify form can be preserved, if we can split all in-loop
   // predecessors.
   if (any_of(LoopPreds, [](BasicBlock *Pred) {
-return isa(Pred->getTerminator());
+const Instruction *T = Pred->getTerminator();
+if (const auto *CBR = dyn_cast(T))
+  return CBR->getDefaultDest() != Pred;
+return isa(T);
   })) {
 if (Options.PreserveLoopSimplify)
   return nullptr;

diff  --git 
a/llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll 
b/llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
new file mode 100644
index ..8c62e9cf5caa
--- /dev/null
+++ b/llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
@@ -0,0 +1,39 @@
+; RUN: opt -loop-reduce %s -o - -S | FileCheck %s
+; RUN: opt -passes='loop(loop-reduce)' %s -o - -S | FileCheck %s
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define dso_local i32 @test1() local_unnamed_addr {
+entry:
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+; It's ok to modify this test in the future should be able to split critical
+; edges here, just noting that this is the critical edge that we care about.
+; CHECK: callbr void asm sideeffect "", "X,X,~{dirflag},~{fpsr},~{flags}"(i8* 
blockaddress(@test1, %cond.true.i), i8* blockaddress(@test1, %for.end))
+; CHECK-NEXT: to label %asm.fallthrough.i.i [label %cond.true.i, label 
%for.end]
+  callbr void asm sideeffect "", "X,X,~{dirflag},~{fpsr},~{flags}"(i8* 
blockaddress(@test1, %cond.true.i), i8* blockaddress(@test1, %for.end))
+  to label %asm.fallthrough.i.i [label %cond.true.i, label %for.end]
+
+asm.fallthrough.i.i:  ; preds = %for.cond
+  unreachable
+
+cond.true.i: 

[llvm-branch-commits] [clang] 0a23fbd - clang: Always pass PowerPC endian information to GNU as

2021-01-11 Thread Nick Desaulniers via llvm-branch-commits

Author: Nathan Chancellor
Date: 2021-01-11T14:50:28-08:00
New Revision: 0a23fbd28c7509f2f980946091e6055bf27164d2

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

LOG: clang: Always pass PowerPC endian information to GNU as

When building a 64-bit big endian PowerPC Linux kernel with a 64-bit
little endian PowerPC target, the 32-bit vDSO errors:

```
$ make ARCH=powerpc CC=clang CROSS_COMPILE=powerpc64le-linux-gnu- \
   pseries_defconfig arch/powerpc/kernel/vdso32/
ld.lld: error: arch/powerpc/kernel/vdso32/sigtramp.o is incompatible with 
elf32-powerpc
ld.lld: error: arch/powerpc/kernel/vdso32/gettimeofday.o is incompatible with 
elf32-powerpc
ld.lld: error: arch/powerpc/kernel/vdso32/datapage.o is incompatible with 
elf32-powerpc
ld.lld: error: arch/powerpc/kernel/vdso32/cacheflush.o is incompatible with 
elf32-powerpc
ld.lld: error: arch/powerpc/kernel/vdso32/note.o is incompatible with 
elf32-powerpc
ld.lld: error: arch/powerpc/kernel/vdso32/getcpu.o is incompatible with 
elf32-powerpc
ld.lld: error: arch/powerpc/kernel/vdso32/vgettimeofday.o is incompatible with 
elf32-powerpc
...
```

This happens because the endian information is missing from the call to
the assembler, even though it was explicitly passed to clang. See the
below example.

```
$ echo | clang --target=powerpc64le-linux-gnu \
   --prefix=/usr/bin/powerpc64le-linux-gnu- \
   -no-integrated-as -m32 -mbig-endian -### -x c -c -
 ".../clang-12" "-cc1" "-triple" "powerpc-unknown-linux-gnu" ...
...
  "/usr/bin/powerpc64le-linux-gnu-as" "-a32" "-mppc" "-many" "-o" "-.o" 
"/tmp/--e69e28.s"
```

clang sets the right target with -m32 and -mbig-endian but -mbig-endian
does not make it to the assembler, resulting in a 32-bit little endian
binary. This differs from the little endian targets, which always pass
-mlittle-endian.

```
$ echo | clang --target=powerpc64-linux-gnu \
   --prefix=/usr/bin/powerpc64-linux-gnu- \
   -no-integrated-as -m32 -mlittle-endian -### -x c -c -
 ".../clang-12" "-cc1" "-triple" "powerpcle-unknown-linux-gnu" ...
...
 "/usr/bin/powerpc64-linux-gnu-as" "-a32" "-mppc" "-mlittle-endian" "-many" 
"-o" "-.o" "/tmp/--405dbd.s"
```

Do the same thing for the big endian targets so that there is no more
error. This matches GCC's behavior, where -mbig and -mlittle are always
passed along to GNU as.

```
$ echo | powerpc64-linux-gcc -### -x c -c -
...
.../powerpc64-linux/bin/as -a64 -mpower4 -many -mbig -o -.o /tmp/ccVn7NAm.s
...

$ echo | powerpc64le-linux-gcc -### -x c -c -
...
.../powerpc64le-linux/bin/as -a64 -mpower8 -many -mlittle -o -.o /tmp/ccPN9ato.s
...
```

Reviewed By: nickdesaulniers, MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/ppc-features.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 164cf6e7..1d8a3cdce92a 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -731,6 +731,7 @@ void tools::gnutools::Assembler::ConstructJob(Compilation 
,
   case llvm::Triple::ppc: {
 CmdArgs.push_back("-a32");
 CmdArgs.push_back("-mppc");
+CmdArgs.push_back("-mbig-endian");
 CmdArgs.push_back(
   ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(;
 break;
@@ -746,6 +747,7 @@ void tools::gnutools::Assembler::ConstructJob(Compilation 
,
   case llvm::Triple::ppc64: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
+CmdArgs.push_back("-mbig-endian");
 CmdArgs.push_back(
   ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(;
 break;

diff  --git a/clang/test/Driver/ppc-features.cpp 
b/clang/test/Driver/ppc-features.cpp
index 05d71b95dba7..85060951aa16 100644
--- a/clang/test/Driver/ppc-features.cpp
+++ b/clang/test/Driver/ppc-features.cpp
@@ -156,14 +156,25 @@
 // CHECK-NOSPE: "-target-feature" "-spe"
 
 // Assembler features
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 
-no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_BE_AS_ARGS %s
-// CHECK_BE_AS_ARGS: "-mppc64"
-// CHECK_BE_AS_ARGS: "-many"
-
-// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
-no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_LE_AS_ARGS %s
-// CHECK_LE_AS_ARGS: "-mppc64"
-// CHECK_LE_AS_ARGS: "-mlittle-endian"
-// CHECK_LE_AS_ARGS: "-mpower8"
+// RUN: %clang -target powerpc-unknown-linux-gnu %s -### -o %t.o 
-no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_32_BE_AS_ARGS %s
+// CHECK_32_BE_AS_ARGS: "-mppc"
+// CHECK_32_BE_AS_ARGS-SAME: "-mbig-endian"
+// CHECK_32_BE_AS_ARGS-SAME: "-many"
+
+// RUN: %clang -target 

[llvm-branch-commits] [clang] e75fec2 - [AttrDocs] document always_inline

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

Author: Nick Desaulniers
Date: 2020-12-17T12:34:23-08:00
New Revision: e75fec2b238f0e26cfb7645f2208baebe3440d41

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

LOG: [AttrDocs] document always_inline

GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp

Reviewed By: ojeda

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

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ce2ee40dc036e..ba6c459f4a431 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -684,7 +684,7 @@ def AlignMac68k : InheritableAttr {
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index c3a412158aba0..6f47ca505b5e0 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5653,3 +5653,22 @@ Requirements on Development Tools - Engineering 
Specification Documentation
 `_ for more information.
   }];
 }
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Inlining heuristics are disabled and inlining is always attempted regardless of
+optimization level.
+
+Does not guarantee that inline substitution actually occurs.
+
+See also `the Microsoft Docs on Inline Functions`_, `the GCC Common Function
+Attribute docs`_, and `the GCC Inline docs`_.
+
+.. _the Microsoft Docs on Inline Functions: 
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp
+.. _the GCC Common Function Attribute docs: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+.. _the GCC Inline docs: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
+
+}];
+  let Heading = "always_inline, __force_inline";
+}



___
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] 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] 91aff1d - [InlineCost] prefer range-for. NFC

2020-11-30 Thread Nick Desaulniers via llvm-branch-commits

Author: Nick Desaulniers
Date: 2020-11-30T16:07:40-08:00
New Revision: 91aff1d8bae02fc65970b52895f05d3574cbb481

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

LOG: [InlineCost] prefer range-for. NFC

Prefer range-for over iterators when such methods exist. Precommitted
from https://reviews.llvm.org/D91816.

Signed-off-by: Nick Desaulniers 

Reviewed By: dblaikie

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

Added: 


Modified: 
llvm/lib/Analysis/InlineCost.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/InlineCost.cpp 
b/llvm/lib/Analysis/InlineCost.cpp
index f6a1f2dc3879..cb731f6a3a66 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -841,11 +841,11 @@ bool CallAnalyzer::accumulateGEPOffset(GEPOperator , 
APInt ) {
 bool CallAnalyzer::isGEPFree(GetElementPtrInst ) {
   SmallVector Operands;
   Operands.push_back(GEP.getOperand(0));
-  for (User::op_iterator I = GEP.idx_begin(), E = GEP.idx_end(); I != E; ++I)
-if (Constant *SimpleOp = SimplifiedValues.lookup(*I))
+  for (const Use  : GEP.indices())
+if (Constant *SimpleOp = SimplifiedValues.lookup(Op))
   Operands.push_back(SimpleOp);
 else
-  Operands.push_back(*I);
+  Operands.push_back(Op);
   return TargetTransformInfo::TCC_Free ==
  TTI.getUserCost(, Operands,
  TargetTransformInfo::TCK_SizeAndLatency);
@@ -1017,8 +1017,8 @@ bool CallAnalyzer::visitGetElementPtr(GetElementPtrInst 
) {
 
   // Lambda to check whether a GEP's indices are all constant.
   auto IsGEPOffsetConstant = [&](GetElementPtrInst ) {
-for (User::op_iterator I = GEP.idx_begin(), E = GEP.idx_end(); I != E; ++I)
-  if (!isa(*I) && !SimplifiedValues.lookup(*I))
+for (const Use  : GEP.indices())
+  if (!isa(Op) && !SimplifiedValues.lookup(Op))
 return false;
 return true;
   };
@@ -1884,8 +1884,8 @@ bool CallAnalyzer::visitInstruction(Instruction ) {
 
   // We found something we don't understand or can't handle. Mark any SROA-able
   // values in the operand list as no longer viable.
-  for (User::op_iterator OI = I.op_begin(), OE = I.op_end(); OI != OE; ++OI)
-disableSROA(*OI);
+  for (const Use  : I.operands())
+disableSROA(Op);
 
   return false;
 }
@@ -1900,7 +1900,7 @@ bool CallAnalyzer::visitInstruction(Instruction ) {
 InlineResult
 CallAnalyzer::analyzeBlock(BasicBlock *BB,
SmallPtrSetImpl ) {
-  for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
+  for (Instruction  : *BB) {
 // FIXME: Currently, the number of instructions in a function regardless of
 // our ability to simplify them during inline to constants or dead code,
 // are actually used by the vector bonus heuristic. As long as that's true,
@@ -1916,11 +1916,11 @@ CallAnalyzer::analyzeBlock(BasicBlock *BB,
   continue;
 
 // Skip ephemeral values.
-if (EphValues.count(&*I))
+if (EphValues.count())
   continue;
 
 ++NumInstructions;
-if (isa(I) || I->getType()->isVectorTy())
+if (isa(I) || I.getType()->isVectorTy())
   ++NumVectorInstructions;
 
 // If the instruction simplified to a constant, there is no cost to this
@@ -1928,14 +1928,14 @@ CallAnalyzer::analyzeBlock(BasicBlock *BB,
 // all of the per-instruction logic. The visit tree returns true if we
 // consumed the instruction in any way, and false if the instruction's base
 // cost should count against inlining.
-onInstructionAnalysisStart(&*I);
+onInstructionAnalysisStart();
 
-if (Base::visit(&*I))
+if (Base::visit())
   ++NumInstructionsSimplified;
 else
   onMissedSimplification();
 
-onInstructionAnalysisFinish(&*I);
+onInstructionAnalysisFinish();
 using namespace ore;
 // If the visit this instruction detected an uninlinable pattern, abort.
 InlineResult IR = InlineResult::success();
@@ -2096,23 +2096,23 @@ InlineResult CallAnalyzer::analyze() {
   // Populate our simplified values by mapping from function arguments to call
   // arguments with known important simplifications.
   auto CAI = CandidateCall.arg_begin();
-  for (Function::arg_iterator FAI = F.arg_begin(), FAE = F.arg_end();
-   FAI != FAE; ++FAI, ++CAI) {
+  for (Argument  : F.args()) {
 assert(CAI != CandidateCall.arg_end());
 if (Constant *C = dyn_cast(CAI))
-  SimplifiedValues[&*FAI] = C;
+  SimplifiedValues[] = C;
 
 Value *PtrArg = *CAI;
 if (ConstantInt *C = stripAndComputeInBoundsConstantOffsets(PtrArg)) {
-  ConstantOffsetPtrs[&*FAI] = std::make_pair(PtrArg, C->getValue());
+  ConstantOffsetPtrs[] = std::make_pair(PtrArg, C->getValue());
 
   // We can SROA any pointer arguments derived from alloca instructions.

[llvm-branch-commits] [clang] 001c8aa - Add C standard upgrade in clang-11 release note

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

Author: Nick Desaulniers
Date: 2020-03-02T10:11:00-08:00
New Revision: 001c8aac80e3924c33a4cc644cca58401c72fe6b

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

LOG: Add C standard upgrade in clang-11 release note

Summary: As per rsmith (https://reviews.llvm.org/D75383).

Reviewers: hans

Reviewed By: hans

Subscribers: cfe-commits, rsmith

Tags: #clang

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 116b47860d8b..a6ff29c630ed 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -545,6 +545,12 @@ Undefined Behavior Sanitizer (UBSan)
   return getelementpointer_inbounds(base, offset);
 }
 
+Changes deferred to Clang-11 release
+
+
+- The next release of clang (clang-11) will upgrade the default C language
+  standard used if not specified via command line from gnu11 to gnu17.
+
 
 Additional Information
 ==



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