[llvm-branch-commits] [lld] 465e0bf - [lld][WebAssebmly] Ensure stub symbols always get address 0

2020-11-24 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2020-11-24T08:13:04-08:00
New Revision: 465e0bf415e1449919ec2f62027dc5df0ebc338d

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

LOG: [lld][WebAssebmly] Ensure stub symbols always get address 0

Without this extra flag we can't distingish between stub functions and
functions that happen to have address 0 (relative to __table_base).

Adding this flag bit the base symbol class actually avoids growing the
SymbolUnion struct which would not be true if we added it to the
FunctionSymbol subclass (due to bitbacking).

The previous approach of setting it's table index to zero worked for
normal static relocations but not for `-fPIC` code.

See https://github.com/emscripten-core/emscripten/issues/12819

Added: 
lld/test/wasm/weak-undefined-pic.s

Modified: 
lld/wasm/MarkLive.cpp
lld/wasm/Relocations.cpp
lld/wasm/SymbolTable.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp

Removed: 




diff  --git a/lld/test/wasm/weak-undefined-pic.s 
b/lld/test/wasm/weak-undefined-pic.s
new file mode 100644
index ..f0c85268fe79
--- /dev/null
+++ b/lld/test/wasm/weak-undefined-pic.s
@@ -0,0 +1,36 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: wasm-ld %t.o -o %t.wasm
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+# Test that undefined weak external functions get resolved to address zero
+# under static linking, and also with `-pie --unresolved-symbols=ignore`
+
+.globl get_foo_addr
+get_foo_addr:
+  .functype get_foo_addr () -> (i32)
+  global.get foo@GOT
+  end_function
+
+.globl _start
+_start:
+  .functype _start () -> ()
+  call get_foo_addr
+  end_function
+
+.weak foo
+.functype foo () -> (i32)
+
+#  CHECK:  - Type:CUSTOM
+# CHECK-NEXT:Name:name
+# CHECK-NEXT:FunctionNames:
+# CHECK-NEXT:  - Index:   0
+# CHECK-NEXT:Name:'undefined_weak:foo'
+# CHECK-NEXT:  - Index:   1
+# CHECK-NEXT:Name:get_foo_addr
+# CHECK-NEXT:  - Index:   2
+# CHECK-NEXT:Name:_start
+# CHECK-NEXT:GlobalNames:
+# CHECK-NEXT:  - Index:   0
+# CHECK-NEXT:Name:__stack_pointer
+# CHECK-NEXT:  - Index:   1
+# CHECK-NEXT:Name:'undefined_weak:foo'

diff  --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp
index 4bce68877040..235936e4ef3e 100644
--- a/lld/wasm/MarkLive.cpp
+++ b/lld/wasm/MarkLive.cpp
@@ -142,7 +142,7 @@ void MarkLive::mark() {
   reloc.Type == R_WASM_TABLE_INDEX_I32 ||
   reloc.Type == R_WASM_TABLE_INDEX_I64) {
 auto *funcSym = cast(sym);
-if (funcSym->hasTableIndex() && funcSym->getTableIndex() == 0)
+if (funcSym->isStub)
   continue;
   }
 

diff  --git a/lld/wasm/Relocations.cpp b/lld/wasm/Relocations.cpp
index 5b131d4f23f4..bd07c0410dc5 100644
--- a/lld/wasm/Relocations.cpp
+++ b/lld/wasm/Relocations.cpp
@@ -62,7 +62,9 @@ static void reportUndefined(Symbol *sym) {
  << "ignoring undefined symbol: " + toString(*sym) + "\n");
   f->stubFunction = symtab->createUndefinedStub(*f->getSignature());
   f->stubFunction->markLive();
-  f->setTableIndex(0);
+  // Mark the function itself as a stub which prevents it from being
+  // assigned a table entry.
+  f->isStub = true;
 }
   }
   break;

diff  --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp
index fc92020d07dd..e469aca89ad7 100644
--- a/lld/wasm/SymbolTable.cpp
+++ b/lld/wasm/SymbolTable.cpp
@@ -673,9 +673,7 @@ InputFunction *SymbolTable::replaceWithUnreachable(Symbol 
*sym,
   // to be exported outside the object file.
   replaceSymbol(sym, debugName, WASM_SYMBOL_BINDING_LOCAL,
  nullptr, func);
-  // Ensure it compares equal to the null pointer, and so that table relocs
-  // don't pull in the stub body (only call-operand relocs should do that).
-  func->setTableIndex(0);
+  sym->isStub = true;
   return func;
 }
 

diff  --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h
index 865a9e7fee99..90fb5194edcd 100644
--- a/lld/wasm/Symbols.h
+++ b/lld/wasm/Symbols.h
@@ -124,7 +124,7 @@ class Symbol {
   Symbol(StringRef name, Kind k, uint32_t flags, InputFile *f)
   : name(name), file(f), symbolKind(k), referenced(!config->gcSections),
 requiresGOT(false), isUsedInRegularObj(false), forceExport(false),
-canInline(false), traced(false), flags(flags) {}
+canInline(false), traced(false), isStub(false), flags(flags) {}
 
   StringRef name;
   InputFile *file;
@@ -157,6 +157,11 @@ class Symbol {
   // True if this symbol is specified by --trace-symbol option.
   bool traced : 1;
 
+  // T

[llvm-branch-commits] [clang] e42021d - [Clang][-fvisibility-from-dllstorageclass] Set DSO Locality from final visibility

2020-11-24 Thread Ben Dunbobbin via llvm-branch-commits

Author: Ben Dunbobbin
Date: 2020-11-24T00:32:14Z
New Revision: e42021d5cc25a8dc7e3efac1e7007cc0c1a7b2bd

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

LOG: [Clang][-fvisibility-from-dllstorageclass] Set DSO Locality from final 
visibility

Ensure that the DSO Locality of the globals in the IR is derived from
their final visibility when using -fvisibility-from-dllstorageclass.

To accomplish this we reset the DSO locality of globals (before
setting their visibility from their dllstorageclass) at the end of
IRGen in Clang. This removes any effects that visibility options or
annotations may have had on the DSO locality.

The resulting DSO locality of the globals will be pessimistic
w.r.t. to the normal compiler IRGen.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/visibility-dllstorageclass.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index f56b7374082f..6d0228e9e2e9 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -420,6 +420,13 @@ static void setVisibilityFromDLLStorageClass(const 
clang::LangOptions &LO,
 if (GV.hasAppendingLinkage() || GV.hasLocalLinkage())
   continue;
 
+// Reset DSO locality before setting the visibility. This removes
+// any effects that visibility options and annotations may have
+// had on the DSO locality. Setting the visibility will implicitly set
+// appropriate globals to DSO Local; however, this will be pessimistic
+// w.r.t. to the normal compiler IRGen.
+GV.setDSOLocal(false);
+
 if (GV.isDeclarationForLinker()) {
   GV.setVisibility(GV.getDLLStorageClass() ==
llvm::GlobalValue::DLLImportStorageClass

diff  --git a/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp 
b/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
index 9003909f3ee0..c4dddcec2eb0 100644
--- a/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
+++ b/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
@@ -5,12 +5,14 @@
 
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
 // RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -x c++ %s -S -emit-llvm -o - | \
-// RUN:   FileCheck %s --check-prefixes=DEFAULT
+// RUN:   FileCheck %s --check-prefixes=DEFAULTS
 
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
 // RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -fvisibility-dllexport=hidden \
 // RUN: -fvisibility-nodllstorageclass=protected \
@@ -19,45 +21,78 @@
 // RUN: -x c++  %s -S -emit-llvm -o - | \
 // RUN:   FileCheck %s --check-prefixes=EXPLICIT
 
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
+// RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
+// RUN: -fvisibility-from-dllstorageclass \
+// RUN: -fvisibility-dllexport=default \
+// RUN: -fvisibility-nodllstorageclass=default \
+// RUN: -fvisibility-externs-dllimport=default \
+// RUN: -fvisibility-externs-nodllstorageclass=default \
+// RUN: -x c++  %s -S -emit-llvm -o - | \
+// RUN:   FileCheck %s --check-prefixes=ALL_DEFAULT
+
 // Local
 static void l() {}
 void use_locals(){l();}
-// DEFAULT-DAG: define internal void @_ZL1lv()
+// DEFAULTS-DAG: define internal void @_ZL1lv()
 // EXPLICIT-DAG: define internal void @_ZL1lv()
+// ALL_DEFAULT-DAG: define internal void @_ZL1lv()
 
 // Function
 void f() {}
 void __declspec(dllexport) exported_f() {}
-// DEFAULT-DAG: define hidden void @_Z1fv()
-// DEFAULT-DAG: define dso_local void @_Z10exported_fv()
+// DEFAULTS-DAG: define hidden void @_Z1fv()
+// DEFAULTS-DAG: define void @_Z10exported_fv()
 // EXPLICIT-DAG: define protected void @_Z1fv()
 // EXPLICIT-DAG: define hidden void @_Z10exported_fv()
+// ALL_DEFAULT-DAG: define void @_Z1fv()
+// ALL_DEFAULT-DAG: define void @_Z10exported_fv()
 
 // Variable
 int d = 123;
 __declspec(dllexport) int exported_d = 123;
-// DEFAULT-DAG: @d = hidden global
-// DEFAULT-DAG: @exported_d = dso_local global
+// DEFAULTS-DAG: @d = hidden global
+// DEFAULTS-DAG: @exported_d = global
 // EXPLICIT-DAG: @d = protected global
 // EXPLICIT-DAG: @exported_d = hidden global
+// ALL_DEFAULT-DAG: @d = global
+// ALL_DEFAULT-DAG: @exported_d = global
 
 // Alias
 extern "C" void aliased() {}
 void a() __attribute__((alias("aliased")));
 void __declspec(dllexport) a_exported() __attribute__((alias("aliased")));
-// DEFAULT-DAG: @_Z1av = hidden alias
-//

[llvm-branch-commits] [llvm] 4bc88a0 - Enable support for floating-point division reductions

2020-11-24 Thread Valentin Churavy via llvm-branch-commits

Author: Yichao Yu
Date: 2020-11-23T20:00:58-05:00
New Revision: 4bc88a0e9a2ee29959a9053e867ae6f051348554

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

LOG: Enable support for floating-point division reductions

Similar to fsub, fdiv can also be vectorized using fmul.

Also http://llvm.org/viewvc/llvm-project?view=revision&revision=215200

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

Co-authored-by: Jameson Nash 

Added: 


Modified: 
llvm/lib/Analysis/IVDescriptors.cpp
llvm/test/Transforms/LoopVectorize/float-reduction.ll

Removed: 




diff  --git a/llvm/lib/Analysis/IVDescriptors.cpp 
b/llvm/lib/Analysis/IVDescriptors.cpp
index 86cbcb015f0f..a5cc622279c4 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -578,6 +578,7 @@ RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, 
RecurrenceKind Kind,
 return InstDesc(Kind == RK_IntegerOr, I);
   case Instruction::Xor:
 return InstDesc(Kind == RK_IntegerXor, I);
+  case Instruction::FDiv:
   case Instruction::FMul:
 return InstDesc(Kind == RK_FloatMult, I, UAI);
   case Instruction::FSub:

diff  --git a/llvm/test/Transforms/LoopVectorize/float-reduction.ll 
b/llvm/test/Transforms/LoopVectorize/float-reduction.ll
index f3b95d0ead7d..dec854845800 100644
--- a/llvm/test/Transforms/LoopVectorize/float-reduction.ll
+++ b/llvm/test/Transforms/LoopVectorize/float-reduction.ll
@@ -44,3 +44,47 @@ for.body: ; preds = 
%for.body, %entry
 for.end:  ; preds = %for.body
   ret float %sub
 }
+
+;CHECK-LABEL: @foodiv(
+;CHECK: fdiv fast <4 x float>
+;CHECK: ret
+define float @foodiv(float* nocapture %A, i32* nocapture %n) nounwind uwtable 
readonly ssp {
+entry:
+  br label %for.body
+
+for.body: ; preds = %for.body, %entry
+  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+  %sum.04 = phi float [ 1.00e+00, %entry ], [ %sub, %for.body ]
+  %arrayidx = getelementptr inbounds float, float* %A, i64 %indvars.iv
+  %0 = load float, float* %arrayidx, align 4
+  %sub = fdiv fast float %sum.04, %0
+  %indvars.iv.next = add i64 %indvars.iv, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+  %exitcond = icmp eq i32 %lftr.wideiv, 200
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:  ; preds = %for.body
+  ret float %sub
+}
+
+;CHECK-LABEL: @foonodiv(
+;CHECK-NOT: fdiv fast <4 x float>
+;CHECK: ret
+define float @foonodiv(float* nocapture %A, i32* nocapture %n) nounwind 
uwtable readonly ssp {
+entry:
+  br label %for.body
+
+for.body: ; preds = %for.body, %entry
+  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+  %sum.04 = phi float [ 1.00e+00, %entry ], [ %sub, %for.body ]
+  %arrayidx = getelementptr inbounds float, float* %A, i64 %indvars.iv
+  %0 = load float, float* %arrayidx, align 4
+  %sub = fdiv fast float %0, %sum.04
+  %indvars.iv.next = add i64 %indvars.iv, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+  %exitcond = icmp eq i32 %lftr.wideiv, 200
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:  ; preds = %for.body
+  ret float %sub
+}



___
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] 8f1e0dc - fix some Wundef warnings in public headers

2020-11-24 Thread Jameson Nash via llvm-branch-commits

Author: Jameson Nash
Date: 2020-11-23T20:17:46-05:00
New Revision: 8f1e0dcbb090243423faa4228ba58ddbae909c70

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

LOG: fix some Wundef warnings in public headers

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

Added: 


Modified: 
llvm/include/llvm/ADT/Statistic.h
llvm/include/llvm/Config/abi-breaking.h.cmake

Removed: 




diff  --git a/llvm/include/llvm/ADT/Statistic.h 
b/llvm/include/llvm/ADT/Statistic.h
index d7aff6c5939a..aa338ccff19a 100644
--- a/llvm/include/llvm/ADT/Statistic.h
+++ b/llvm/include/llvm/ADT/Statistic.h
@@ -36,6 +36,8 @@
 // configure time.
 #if !defined(NDEBUG) || LLVM_FORCE_ENABLE_STATS
 #define LLVM_ENABLE_STATS 1
+#else
+#define LLVM_ENABLE_STATS 0
 #endif
 
 namespace llvm {

diff  --git a/llvm/include/llvm/Config/abi-breaking.h.cmake 
b/llvm/include/llvm/Config/abi-breaking.h.cmake
index a1ffad660770..2d27e02b1d54 100644
--- a/llvm/include/llvm/Config/abi-breaking.h.cmake
+++ b/llvm/include/llvm/Config/abi-breaking.h.cmake
@@ -20,7 +20,7 @@
 
 /* Allow selectively disabling link-time mismatch checking so that header-only
ADT content from LLVM can be used without linking libSupport. */
-#if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
+#if !defined(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) || 
!LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
 
 // ABI_BREAKING_CHECKS protection: provides link-time failure when clients 
build
 // mismatch with LLVM



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


[llvm-branch-commits] [llvm] 97c8fba - Fix signed integer overflow bug that's causing test failures with UBSan.

2020-11-24 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-11-23T17:20:58-08:00
New Revision: 97c8fba7e490db57d24a31c68ad12d7f840256d6

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

LOG: Fix signed integer overflow bug that's causing test failures with UBSan.

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp 
b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index f7102dccf6ee..01293deb647d 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -2012,7 +2012,7 @@ static unsigned mapToSinitPriority(int P) {
   if (P < 64512)
 return 2047 + (P - 1124) * 33878;
 
-  return 2147482625 + (P - 64512);
+  return 2147482625u + (P - 64512);
 }
 
 static std::string convertToSinitPriority(int Priority) {



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


[llvm-branch-commits] [clang-tools-extra] 3e6e6a2 - [clangd] Call hierarchy (XRefs layer, incoming calls)

2020-11-24 Thread Nathan Ridge via llvm-branch-commits

Author: Nathan Ridge
Date: 2020-11-23T20:43:38-05:00
New Revision: 3e6e6a2db674cd85b33c06b75685c6bce5acb154

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

LOG: [clangd] Call hierarchy (XRefs layer, incoming calls)

Support for outgoing calls is left for a future change.

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

Added: 
clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/unittests/TestTU.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 0cd8695da92d..e319636f9076 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -47,6 +47,7 @@
 #include "clang/Index/USRGeneration.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
@@ -1339,9 +1340,9 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, 
const LocatedSymbol &S) {
   return OS;
 }
 
-// FIXME(nridge): Reduce duplication between this function and declToSym().
-static llvm::Optional
-declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND) {
+template 
+static llvm::Optional declToHierarchyItem(const NamedDecl &ND) {
+  ASTContext &Ctx = ND.getASTContext();
   auto &SM = Ctx.getSourceManager();
   SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
   SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
@@ -1365,54 +1366,84 @@ declToTypeHierarchyItem(ASTContext &Ctx, const 
NamedDecl &ND) {
   // correctly.
   SymbolKind SK = indexSymbolKindToSymbolKind(SymInfo.Kind);
 
-  TypeHierarchyItem THI;
-  THI.name = printName(Ctx, ND);
-  THI.kind = SK;
-  THI.deprecated = ND.isDeprecated();
-  THI.range = Range{sourceLocToPosition(SM, DeclRange->getBegin()),
-sourceLocToPosition(SM, DeclRange->getEnd())};
-  THI.selectionRange = Range{NameBegin, NameEnd};
-  if (!THI.range.contains(THI.selectionRange)) {
+  HierarchyItem HI;
+  HI.name = printName(Ctx, ND);
+  HI.kind = SK;
+  HI.range = Range{sourceLocToPosition(SM, DeclRange->getBegin()),
+   sourceLocToPosition(SM, DeclRange->getEnd())};
+  HI.selectionRange = Range{NameBegin, NameEnd};
+  if (!HI.range.contains(HI.selectionRange)) {
 // 'selectionRange' must be contained in 'range', so in cases where clang
 // reports unrelated ranges we need to reconcile somehow.
-THI.range = THI.selectionRange;
+HI.range = HI.selectionRange;
   }
 
-  THI.uri = URIForFile::canonicalize(*FilePath, *TUPath);
+  HI.uri = URIForFile::canonicalize(*FilePath, *TUPath);
 
   // Compute the SymbolID and store it in the 'data' field.
   // This allows typeHierarchy/resolve to be used to
   // resolve children of items returned in a previous request
   // for parents.
   if (auto ID = getSymbolID(&ND))
-THI.data = ID.str();
+HI.data = ID.str();
+
+  return HI;
+}
 
-  return THI;
+static llvm::Optional
+declToTypeHierarchyItem(const NamedDecl &ND) {
+  auto Result = declToHierarchyItem(ND);
+  if (Result)
+Result->deprecated = ND.isDeprecated();
+  return Result;
 }
 
-static Optional
-symbolToTypeHierarchyItem(const Symbol &S, const SymbolIndex *Index,
-  PathRef TUPath) {
+static llvm::Optional
+declToCallHierarchyItem(const NamedDecl &ND) {
+  auto Result = declToHierarchyItem(ND);
+  if (Result && ND.isDeprecated())
+Result->tags.push_back(SymbolTag::Deprecated);
+  return Result;
+}
+
+template 
+static llvm::Optional symbolToHierarchyItem(const Symbol &S,
+   PathRef TUPath) {
   auto Loc = symbolToLocation(S, TUPath);
   if (!Loc) {
-log("Type hierarchy: {0}", Loc.takeError());
+elog("Failed to convert symbol to hierarchy item: {0}", Loc.takeError());
 return llvm::None;
   }
-  TypeHierarchyItem THI;
-  THI.name = std::string(S.Name);
-  THI.kind = indexSymbolKindToSymbolKind(S.SymInfo.Kind);
-  THI.deprecated = (S.Flags & Symbol::Deprecated);
-  THI.selectionRange = Loc->range;
+  HierarchyItem HI;
+  HI.name = std::string(S.Name);
+  HI.kind = indexSymbolKindToSymbolKind(S.SymInfo.Kind);
+  HI.selectionRange = Loc->range;
   // FIXME: Populate 'range' correctly
   // (https://github.com/clangd/clangd/issues/59).
-  THI.range = THI.selectionRange;
-  THI.uri = Loc->uri;
+  HI.range = HI.selectionRange;
+  HI.uri = Loc->uri;
   // Store the SymbolID in the 'data' field. The client will
-  // send this back in typeHierarchy/resolve, allowing us to
-  // continu

[llvm-branch-commits] [clang-tools-extra] 4cb976e - [clangd] Call hierarchy (ClangdServer layer)

2020-11-24 Thread Nathan Ridge via llvm-branch-commits

Author: Nathan Ridge
Date: 2020-11-23T20:43:41-05:00
New Revision: 4cb976e014db80efd20dfca45ba218c3a69aac42

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

LOG: [clangd] Call hierarchy (ClangdServer layer)

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 889d2cbcf280..523931d9cc7b 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -678,6 +678,26 @@ void ClangdServer::resolveTypeHierarchy(
   CB(Item);
 }
 
+void ClangdServer::prepareCallHierarchy(
+PathRef File, Position Pos, Callback> CB) {
+  auto Action = [File = File.str(), Pos,
+ CB = std::move(CB)](Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::prepareCallHierarchy(InpAST->AST, Pos, File));
+  };
+  WorkScheduler.runWithAST("Call Hierarchy", File, std::move(Action));
+}
+
+void ClangdServer::incomingCalls(
+const CallHierarchyItem &Item,
+Callback> CB) {
+  WorkScheduler.run("Incoming Calls", "",
+[CB = std::move(CB), Item, this]() mutable {
+  CB(clangd::incomingCalls(Item, Index));
+});
+}
+
 void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams &Params) {
   // FIXME: Do nothing for now. This will be used for indexing and potentially
   // invalidating other caches.

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 1ccb4c5899f8..18c35e701e5b 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -242,6 +242,14 @@ class ClangdServer {
 TypeHierarchyDirection Direction,
 Callback> CB);
 
+  /// Get information about call hierarchy for a given position.
+  void prepareCallHierarchy(PathRef File, Position Pos,
+Callback> CB);
+
+  /// Resolve incoming calls for a given call hierarchy item.
+  void incomingCalls(const CallHierarchyItem &Item,
+ Callback>);
+
   /// Retrieve the top symbols from the workspace matching a query.
   void workspaceSymbols(StringRef Query, int Limit,
 Callback> CB);



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


[llvm-branch-commits] [clang-tools-extra] 0a4f99c - [clangd] Call hierarchy (ClangdLSPServer layer)

2020-11-24 Thread Nathan Ridge via llvm-branch-commits

Author: Nathan Ridge
Date: 2020-11-23T20:44:07-05:00
New Revision: 0a4f99c494d007a21652b1b3939bde4753042c33

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

LOG: [clangd] Call hierarchy (ClangdLSPServer layer)

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

Added: 
clang-tools-extra/clangd/test/call-hierarchy.test

Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 335a6fc9ad94..66dee68ec474 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -625,6 +625,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
  }},
 {"typeHierarchyProvider", true},
 {"memoryUsageProvider", true}, // clangd extension.
+{"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)
 Result["offsetEncoding"] = *Opts.Encoding;
@@ -1224,6 +1225,26 @@ void ClangdLSPServer::onResolveTypeHierarchy(
std::move(Reply));
 }
 
+void ClangdLSPServer::onPrepareCallHierarchy(
+const CallHierarchyPrepareParams &Params,
+Callback> Reply) {
+  Server->prepareCallHierarchy(Params.textDocument.uri.file(), Params.position,
+   std::move(Reply));
+}
+
+void ClangdLSPServer::onCallHierarchyIncomingCalls(
+const CallHierarchyIncomingCallsParams &Params,
+Callback> Reply) {
+  Server->incomingCalls(Params.item, std::move(Reply));
+}
+
+void ClangdLSPServer::onCallHierarchyOutgoingCalls(
+const CallHierarchyOutgoingCallsParams &Params,
+Callback> Reply) {
+  // FIXME: To be implemented.
+  Reply(std::vector{});
+}
+
 void ClangdLSPServer::applyConfiguration(
 const ConfigurationSettings &Settings) {
   // Per-file update to the compilation database.
@@ -1468,6 +1489,9 @@ ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
   MsgHandler->bind("textDocument/symbolInfo", &ClangdLSPServer::onSymbolInfo);
   MsgHandler->bind("textDocument/typeHierarchy", 
&ClangdLSPServer::onTypeHierarchy);
   MsgHandler->bind("typeHierarchy/resolve", 
&ClangdLSPServer::onResolveTypeHierarchy);
+  MsgHandler->bind("textDocument/prepareCallHierarchy", 
&ClangdLSPServer::onPrepareCallHierarchy);
+  MsgHandler->bind("callHierarchy/incomingCalls", 
&ClangdLSPServer::onCallHierarchyIncomingCalls);
+  MsgHandler->bind("callHierarchy/outgoingCalls", 
&ClangdLSPServer::onCallHierarchyOutgoingCalls);
   MsgHandler->bind("textDocument/selectionRange", 
&ClangdLSPServer::onSelectionRange);
   MsgHandler->bind("textDocument/documentLink", 
&ClangdLSPServer::onDocumentLink);
   MsgHandler->bind("textDocument/semanticTokens/full", 
&ClangdLSPServer::onSemanticTokens);

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 4d568bc13d8b..e65fc0e8a006 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -135,6 +135,14 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
Callback>);
   void onResolveTypeHierarchy(const ResolveTypeHierarchyItemParams &,
   Callback>);
+  void onPrepareCallHierarchy(const CallHierarchyPrepareParams &,
+  Callback>);
+  void onCallHierarchyIncomingCalls(
+  const CallHierarchyIncomingCallsParams &,
+  Callback>);
+  void onCallHierarchyOutgoingCalls(
+  const CallHierarchyOutgoingCallsParams &,
+  Callback>);
   void onChangeConfiguration(const DidChangeConfigurationParams &);
   void onSymbolInfo(const TextDocumentPositionParams &,
 Callback>);

diff  --git a/clang-tools-extra/clangd/test/call-hierarchy.test 
b/clang-tools-extra/clangd/test/call-hierarchy.test
new file mode 100644
index ..6548ea0068a8
--- /dev/null
+++ b/clang-tools-extra/clangd/test/call-hierarchy.test
@@ -0,0 +1,39 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"void
 callee(int);\nvoid caller1() {\n  callee(42);\n}\nvoid caller2() {\n  
caller1();\n  caller1();\n}\nvoid caller3() {\n  caller1();\n  
caller2();\n}\n","uri":"test:///main.cpp","version":1}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/prepareCallHierarchy","params":

[llvm-branch-commits] [clang-tools-extra] dced150 - [clangd] Use WorkScheduler.run() in ClangdServer::resolveTypeHierarchy()

2020-11-24 Thread Nathan Ridge via llvm-branch-commits

Author: Nathan Ridge
Date: 2020-11-23T20:44:14-05:00
New Revision: dced150375d09df6266448342fbb066d638b59ef

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

LOG: [clangd] Use WorkScheduler.run() in ClangdServer::resolveTypeHierarchy()

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 523931d9cc7bf..502078c776db9 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -674,8 +674,11 @@ void ClangdServer::typeHierarchy(PathRef File, Position 
Pos, int Resolve,
 void ClangdServer::resolveTypeHierarchy(
 TypeHierarchyItem Item, int Resolve, TypeHierarchyDirection Direction,
 Callback> CB) {
-  clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
-  CB(Item);
+  WorkScheduler.run(
+  "Resolve Type Hierarchy", "", [=, CB = std::move(CB)]() mutable {
+clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
+CB(Item);
+  });
 }
 
 void ClangdServer::prepareCallHierarchy(



___
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] 53310ae - [gn build] Port 3e6e6a2db67

2020-11-24 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-11-24T01:44:50Z
New Revision: 53310ae70841a771b1706dc6f7740957089a748b

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

LOG: [gn build] Port 3e6e6a2db67

Added: 


Modified: 
llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
index d9715d8a26db..1d5fdf8b3f42 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
@@ -44,6 +44,7 @@ unittest("ClangdTests") {
 "ASTTests.cpp",
 "Annotations.cpp",
 "BackgroundIndexTests.cpp",
+"CallHierarchyTests.cpp",
 "CanonicalIncludesTests.cpp",
 "ClangdLSPServerTests.cpp",
 "ClangdTests.cpp",



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


[llvm-branch-commits] [lldb] b20f3cc - [lldb] Add platform select to TestProcessConnect.py

2020-11-24 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-11-23T18:02:00-08:00
New Revision: b20f3cc5b560ae15a8f9018eb96d65e6f5e125d1

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

LOG: [lldb] Add platform select to TestProcessConnect.py

Extend TestProcessConnect to cover the scenario fixed by
6c0cd5676e0a0feaf836e0399023a6e21224467b. This replaces
command-process-connect.test which would fail if port 4321
was open.

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
index c2d06ad5d67e..80b83fbe2919 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
@@ -38,6 +38,8 @@ def test_process_connect_sync(self):
 """Test the gdb-remote command in synchronous mode"""
 try:
 self.dbg.SetAsync(False)
+self.expect("platform select remote-gdb-server",
+substrs=['Platform: remote-gdb-server', 'Connected: 
no'])
 self.expect("process connect connect://" +
 self.server.get_connect_address(),
 substrs=['Process', 'stopped'])
@@ -50,6 +52,8 @@ def test_process_connect_async(self):
 """Test the gdb-remote command in asynchronous mode"""
 try:
 self.dbg.SetAsync(True)
+self.expect("platform select remote-gdb-server",
+substrs=['Platform: remote-gdb-server', 'Connected: 
no'])
 self.expect("process connect connect://" +
 self.server.get_connect_address(),
 matching=False,



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


[llvm-branch-commits] [lldb] 2bd4540 - [LLDB] Fix typo in RegisterContextPOSIXProcessMonitor_arm64

2020-11-24 Thread Muhammad Omair Javaid via llvm-branch-commits

Author: Muhammad Omair Javaid
Date: 2020-11-24T07:09:00+05:00
New Revision: 2bd4540f3816bb7acda31cba5351d02192d63f81

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

LOG: [LLDB] Fix typo in RegisterContextPOSIXProcessMonitor_arm64

This patch fixes a minor typo in RegisterContextPOSIXProcessMonitor_arm64
constructor where memset target was wrongly specified as m_fpr instead of
m_gpr_arm64.

Added: 


Modified: 

lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
 
b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
index 035bf59cc9c9..39ae0b9b9e7f 100644
--- 
a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
@@ -25,7 +25,7 @@ RegisterContextPOSIXProcessMonitor_arm64::
 lldb_private::Thread &thread,
 std::unique_ptr register_info)
 : RegisterContextPOSIX_arm64(thread, std::move(register_info)) {
-  ::memset(&m_fpr, 0, sizeof m_gpr_arm64);
+  ::memset(&m_gpr_arm64, 0, sizeof m_gpr_arm64);
   ::memset(&m_fpr, 0, sizeof m_fpr);
 }
 



___
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] 9194aa8 - [gn build] modify hotfix in 17df195f705cef76a9 to work with all enabled targets

2020-11-24 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-23T21:28:54-05:00
New Revision: 9194aa88676fbf6d215efbe461abe9ac18bc0ffc

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

LOG: [gn build] modify hotfix in 17df195f705cef76a9 to work with all enabled 
targets

llvm-config output with the gn build is just good enough to make
tests pass, but llvm-config wants all .a files it knows about to
actually exist. So let it know about fewer .a files that don't
exist if not all targets are enabled.

Added: 


Modified: 
llvm/utils/gn/build/write_library_dependencies.py

Removed: 




diff  --git a/llvm/utils/gn/build/write_library_dependencies.py 
b/llvm/utils/gn/build/write_library_dependencies.py
index 6d5349942881..4ab6c6eb1b7c 100644
--- a/llvm/utils/gn/build/write_library_dependencies.py
+++ b/llvm/utils/gn/build/write_library_dependencies.py
@@ -22,8 +22,8 @@
 const char *RequiredLibraries[84];
   } AvailableComponents[84] = {
   { "aggressiveinstcombine", "LLVMAggressiveInstCombine", true, {"analysis", 
"core", "support", "transformutils"} },
-{ "all", nullptr, true, {"demangle", "support", "tablegen", "core", 
"fuzzmutate", "filecheck", "interfacestub", "irreader", "codegen", 
"selectiondag", "asmprinter", "mirparser", "globalisel", "binaryformat", 
"bitreader", "bitwriter", "bitstreamreader", "dwarflinker", "extensions", 
"frontendopenmp", "transformutils", "instrumentation", "aggressiveinstcombine", 
"instcombine", "scalaropts", "ipo", "vectorize", "hellonew", "objcarcopts", 
"coroutines", "cfguard", "linker", "analysis", "lto", "mc", "mcparser", 
"mcdisassembler", "mca", "object", "objectyaml", "option", "remarks", 
"debuginfodwarf", "debuginfogsym", "debuginfomsf", "debuginfocodeview", 
"debuginfopdb", "symbolize", "executionengine", "interpreter", "jitlink", 
"mcjit", "orcjit", "orcshared", "orctargetprocess", "runtimedyld", "target", 
"x86codegen", "x86asmparser", "x86disassembler", "x86desc", "x86info", 
"webassemblycodegen", "webassemblyasmparser", "webassemblydisassembler", 
"webassemblydesc", "webassemblyinfo", "asmparser", "lineeditor", "profiledata", 
"coverage", "passes", "textapi", "dlltooldriver", "libdriver", "xray", 
"windowsmanifest"} },
-{ "all-targets", nullptr, true, {"x86", "webassembly"} },
+{ "all", nullptr, true, {"demangle", "support", "tablegen", "core", 
"fuzzmutate", "filecheck", "interfacestub", "irreader", "codegen", 
"selectiondag", "asmprinter", "mirparser", "globalisel", "binaryformat", 
"bitreader", "bitwriter", "bitstreamreader", "dwarflinker", "extensions", 
"frontendopenmp", "transformutils", "instrumentation", "aggressiveinstcombine", 
"instcombine", "scalaropts", "ipo", "vectorize", "hellonew", "objcarcopts", 
"coroutines", "cfguard", "linker", "analysis", "lto", "mc", "mcparser", 
"mcdisassembler", "mca", "object", "objectyaml", "option", "remarks", 
"debuginfodwarf", "debuginfogsym", "debuginfomsf", "debuginfocodeview", 
"debuginfopdb", "symbolize", "executionengine", "interpreter", "jitlink", 
"mcjit", "orcjit", "orcshared", "orctargetprocess", "runtimedyld", "target", 
"asmparser", "lineeditor", "profiledata", "coverage", "passes", "textapi", 
"dlltooldriver", "libdriver", "xray", "windowsmanifest"} },
+{ "all-targets", nullptr, true, {} },
 { "analysis", "LLVMAnalysis", true, {"binaryformat", "core", "object", 
"profiledata", "support"} },
 { "asmparser", "LLVMAsmParser", true, {"binaryformat", "core", "support"} },
 { "asmprinter", "LLVMAsmPrinter", true, {"analysis", "binaryformat", 
"codegen", "core", "debuginfocodeview", "debuginfodwarf", "debuginfomsf", "mc", 
"mcparser", "remarks", "support", "target"} },
@@ -69,8 +69,8 @@
 { "mcjit", "LLVMMCJIT", true, {"core", "executionengine", "object", 
"runtimedyld", "support", "target"} },
 { "mcparser", "LLVMMCParser", true, {"mc", "support"} },
 { "mirparser", "LLVMMIRParser", true, {"asmparser", "binaryformat", "codegen", 
"core", "mc", "support", "target"} },
-{ "native", nullptr, true, {"x86"} },
-{ "nativecodegen", nullptr, true, {"x86codegen"} },
+{ "native", nullptr, true, {} },
+{ "nativecodegen", nullptr, true, {} },
 { "objcarcopts", "LLVMObjCARCOpts", true, {"analysis", "core", "support", 
"transformutils"} },
 { "object", "LLVMObject", true, {"bitreader", "core", "mc", "binaryformat", 
"mcparser", "support", "textapi"} },
 { "objectyaml", "LLVMObjectYAML", true, {"binaryformat", "object", "support", 
"debuginfocodeview", "mc"} },
@@ -91,19 +91,7 @@
 { "textapi", "LLVMTextAPI", true, {"support", "binaryformat"} },
 { "transformutils", "LLVMTransformUtils", true, {"analysis", "core", 
"support"} },
 { "vectorize", "LLVMVectorize", true, {"analysis", "core", "support", 
"transformutils"} },
-{ "webassembly", nullptr, true, {"webassemblycodegen", "webassemblyasmparser", 
"webassemblydisassembler"

[llvm-branch-commits] [libunwind] bb13411 - [libunwind] Multiple preprocessor fixes on PowerPC*

2020-11-24 Thread Fangrui Song via llvm-branch-commits

Author: Brandon Bergren
Date: 2020-11-23T19:07:21-08:00
New Revision: bb1341161478dc589893cda9f808e5f5b859b5ae

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

LOG: [libunwind] Multiple preprocessor fixes on PowerPC*

* Remove misnamed `PPC64_HAS_VMX` in preference of directly checking 
`defined(__VSX__)`.

libunwind was using "VMX" to mean "VSX". "VMX" is just another name for 
Altivec, while "VSX" is the vector-scalar extensions first used in POWER7. 
Exposing a "PPC64_HAS_VMX" define was misleading and incorrect.

* Add `defined(__ALTIVEC__)` guards around vector register operations to fix 
non-altivec CPUS such as the e5500.

When compiling for certain Book-E processors such as the e5500, we want to skip 
vector save/restore, as the Altivec registers are illegal on non-Altivec 
implementations.

* Add `!defined(__NO_FPRS__)` guards around traditional floating-point 
save/restore.

When compiling for powerpcspe, we cannot access floating point registers, as 
there aren't any. (The SPE on e500v2 is a 64-bit extension of the GPRs, and it 
doesn't have the normal floating-point registers at all.)
This fixes building for powerpcspe, although no actual handling for SPE 
save/restore is written yet.

Reviewed By: MaskRay, #libunwind, compnerd

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

Added: 


Modified: 
libunwind/src/Registers.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/assembly.h
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index 4d963b4156d1..e0cb84f00e7f 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -1514,12 +1514,12 @@ inline void Registers_ppc64::setFloatRegister(int 
regNum, double value) {
 }
 
 inline bool Registers_ppc64::validVectorRegister(int regNum) const {
-#ifdef PPC64_HAS_VMX
+#if defined(__VSX__)
   if (regNum >= UNW_PPC64_VS0 && regNum <= UNW_PPC64_VS31)
 return true;
   if (regNum >= UNW_PPC64_VS32 && regNum <= UNW_PPC64_VS63)
 return true;
-#else
+#elif defined(__ALTIVEC__)
   if (regNum >= UNW_PPC64_V0 && regNum <= UNW_PPC64_V31)
 return true;
 #endif

diff  --git a/libunwind/src/UnwindRegistersRestore.S 
b/libunwind/src/UnwindRegistersRestore.S
index d817e6dae948..289afe98b0b2 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -170,7 +170,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
   PPC64_LR(30)
   PPC64_LR(31)
 
-#ifdef PPC64_HAS_VMX
+#if defined(__VSX__)
 
   // restore VS registers
   // (note that this also restores floating point registers and V registers,
@@ -312,6 +312,7 @@ PPC64_CLVS_BOTTOM(n)
   PPC64_LF(30)
   PPC64_LF(31)
 
+#if defined(__ALTIVEC__)
   // restore vector registers if any are in use
   ld%r5, PPC64_OFFS_VRSAVE(%r3)   // test VRsave
   cmpwi %r5, 0
@@ -373,6 +374,7 @@ PPC64_CLV_UNALIGNED_BOTTOM(n)
   PPC64_CLV_UNALIGNEDh(31)
 
 #endif
+#endif
 
 Lnovec:
   ld%r0, PPC64_OFFS_CR(%r3)
@@ -431,6 +433,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
   lwz %r30,128(%r3)
   lwz %r31,132(%r3)
 
+#ifndef __NO_FPRS__
   // restore float registers
   lfd %f0, 160(%r3)
   lfd %f1, 168(%r3)
@@ -464,7 +467,9 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
   lfd %f29,392(%r3)
   lfd %f30,400(%r3)
   lfd %f31,408(%r3)
+#endif
 
+#if defined(__ALTIVEC__)
   // restore vector registers if any are in use
   lwz %r5, 156(%r3)   // test VRsave
   cmpwi   %r5, 0
@@ -537,6 +542,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
   LOAD_VECTOR_UNALIGNEDh(29)
   LOAD_VECTOR_UNALIGNEDh(30)
   LOAD_VECTOR_UNALIGNEDh(31)
+#endif
 
 Lnovec:
   lwz %r0, 136(%r3)   // __cr

diff  --git a/libunwind/src/UnwindRegistersSave.S 
b/libunwind/src/UnwindRegistersSave.S
index 51bb9b0688fd..94fc8365455d 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -384,7 +384,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   mfvrsave%r0
   std   %r0,  PPC64_OFFS_VRSAVE(%r3)
 
-#ifdef PPC64_HAS_VMX
+#if defined(__VSX__)
   // save VS registers
   // (note that this also saves floating point registers and V registers,
   // because part of VS is mapped to these registers)
@@ -501,6 +501,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   PPC64_STF(30)
   PPC64_STF(31)
 
+#if defined(__ALTIVEC__)
   // save vector registers
 
   // Use 16-bytes below the stack pointer as an
@@ -548,6 +549,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   PPC64_STV_UNALIGNED(30)
   PPC64_STV_UNALIGNED(31)
 
+#endif
 #endif
 
   li%r3,  0   // return UNW_ESUCCESS
@@ -608,6 +61

[llvm-branch-commits] [clang] c2fb114 - [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-24 Thread Fangrui Song via llvm-branch-commits

Author: John Paul Adrian Glaubitz
Date: 2020-11-23T19:25:36-08:00
New Revision: c2fb114475d15a1d39545f700b8c6d6e18367ca9

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

LOG: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

This fixes the Builtins-sparc-linux testsuite failures on Linux
SPARC which occur because clang cannot find the 32-bit runtime
libraries when -m32 is passed on the command line. The same
workaround is already being used on X86 and PPC.

Also, switch the CHECK-DEBIAN-SPARC tests to use debian_multiarch_tree
as both sparc and sparc64 are using the MultiArch mechanism on modern Debian
systems the same way as x86_64, powerpc64el and others. Thus, switch the
CHECK-DEBIAN-SPARC32 and CHECK-DEBIAN-SPARC64 tests to use the files from
the debian_multiarch_tree directory for the header and linker path tests.

Finally, rename CHECK-DEBIAN-SPARC32 to CHECK-DEBIAN-SPARC to match the naming
scheme of the Debian MultiArch checks for the other Debian architectures.

Reviewed By: MaskRay, phosek

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

Added: 
clang/test/Driver/Inputs/debian_multiarch_tree/lib/sparc-linux-gnu/.keep
clang/test/Driver/Inputs/debian_multiarch_tree/lib/sparc64-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/sparc-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/sparc64-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/sparc-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/sparc64-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/sparc-linux-gnu/4.5/crtbegin.o

clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/sparc64-linux-gnu/4.5/crtbegin.o
clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/sparc-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/sparc64-linux-gnu/.keep

Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-header-search.cpp
clang/test/Driver/linux-ld.c

Removed: 
clang/test/Driver/Inputs/debian_8_sparc64_tree/lib/sparc64-linux-gnu/.keep
clang/test/Driver/Inputs/debian_8_sparc64_tree/lib64/.keep
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/include/c++/4.9/.keep

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/include/sparc64-linux-gnu/c++/4.9/.keep

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/4.9/crtbegin.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/4.9/crtend.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crt1.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crti.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crtn.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/lib/sparc-linux-gnu/.keep
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/lib64/.keep

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/include/c++/4.9/backward/.keep

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/include/sparc-linux-gnu/c++/4.9/64/.keep

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/64/crtbegin.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/64/crtend.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/crtbegin.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/crtend.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crt1.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crti.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crtn.o
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crt1.o
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crti.o
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crtn.o



diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 180350476c38..c2e21159b316 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -185,17 +185,18 @@ static StringRef getOSLibDir(const llvm::Triple &Triple, 
const ArgList &Args) {
 return Triple.isArch32Bit() ? "lib" : "lib64";
   }
 
-  // It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and
-  // using that variant while targeting other architectures causes problems
-  // because the libraries are laid out in shared system roots that can't cope
-  // with a 'li

[llvm-branch-commits] [llvm] b3a8a15 - [LAA] Minor code style tweaks [NFC]

2020-11-24 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-11-24T15:49:27-08:00
New Revision: b3a8a153433f65c419b891ae6763f458b33e9605

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

LOG: [LAA] Minor code style tweaks [NFC]

Added: 


Modified: 
llvm/lib/Analysis/LoopAccessAnalysis.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp 
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 34de1a052ddf..0bffa7dbddec 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -149,27 +149,23 @@ const SCEV 
*llvm::replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE,
   // symbolic stride replaced by one.
   ValueToValueMap::const_iterator SI =
   PtrToStride.find(OrigPtr ? OrigPtr : Ptr);
-  if (SI != PtrToStride.end()) {
-Value *StrideVal = SI->second;
+  if (SI == PtrToStride.end())
+// For a non-symbolic stride, just return the original expression.
+return OrigSCEV;
 
-// Strip casts.
-StrideVal = stripIntegerCast(StrideVal);
+  Value *StrideVal = stripIntegerCast(SI->second);
 
-ScalarEvolution *SE = PSE.getSE();
-const auto *U = cast(SE->getSCEV(StrideVal));
-const auto *CT =
-static_cast(SE->getOne(StrideVal->getType()));
+  ScalarEvolution *SE = PSE.getSE();
+  const auto *U = cast(SE->getSCEV(StrideVal));
+  const auto *CT =
+static_cast(SE->getOne(StrideVal->getType()));
 
-PSE.addPredicate(*SE->getEqualPredicate(U, CT));
-auto *Expr = PSE.getSCEV(Ptr);
+  PSE.addPredicate(*SE->getEqualPredicate(U, CT));
+  auto *Expr = PSE.getSCEV(Ptr);
 
-LLVM_DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV
-  << " by: " << *Expr << "\n");
-return Expr;
-  }
-
-  // Otherwise, just return the SCEV of the original pointer.
-  return OrigSCEV;
+  LLVM_DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV
+<< " by: " << *Expr << "\n");
+  return Expr;
 }
 
 RuntimeCheckingPtrGroup::RuntimeCheckingPtrGroup(
@@ -2150,12 +2146,8 @@ bool LoopAccessInfo::isUniform(Value *V) const {
 }
 
 void LoopAccessInfo::collectStridedAccess(Value *MemAccess) {
-  Value *Ptr = nullptr;
-  if (LoadInst *LI = dyn_cast(MemAccess))
-Ptr = LI->getPointerOperand();
-  else if (StoreInst *SI = dyn_cast(MemAccess))
-Ptr = SI->getPointerOperand();
-  else
+  Value *Ptr = getLoadStorePointerOperand(MemAccess);
+  if (!Ptr)
 return;
 
   Value *Stride = getStrideFromPointer(Ptr, PSE->getSE(), TheLoop);



___
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] 1bc85cb - [Sanitizer][RISCV] Fix redefinition of REG_SP

2020-11-24 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2020-11-25T00:04:47Z
New Revision: 1bc85cbbb80397cbc165500cc336fe8325bed07d

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

LOG: [Sanitizer][RISCV] Fix redefinition of REG_SP

The include header sys/ucontext.h already defines REG_SP as 2, causing
redefinition warnings during compilation. This patch fixes that issue.
(We also can't just use the numerical definition provided by the header,
as REG_SP is used in this file this refers to a struct field.)

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

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp

Removed: 




diff  --git 
a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
index 0f1cadfeae39..2ecf87b096a1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
@@ -513,6 +513,8 @@ static constexpr uptr kExtraRegs[] = {0};
 
 #elif SANITIZER_RISCV64
 typedef struct user_regs_struct regs_struct;
+// sys/ucontext.h already defines REG_SP as 2. Undefine it first.
+#undef REG_SP
 #define REG_SP sp
 static constexpr uptr kExtraRegs[] = {0};
 #define ARCH_IOVEC_FOR_GETREGSET



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


[llvm-branch-commits] [clang] c2cb61b - Fix mangling of substitutions for template-prefixes.

2020-11-24 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-11-24T16:25:18-08:00
New Revision: c2cb61bed3652126278b4a738e367f524e040ccc

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

LOG: Fix mangling of substitutions for template-prefixes.

Previously we only considered using a substitution for a template-name
after already having mangled its prefix, so we'd produce nonsense
manglings like NS3_S4_IiEE where we should simply produce NS4_IiEE.

This is not ABI-compatible with previous Clang versions, and the old
behavior is restored by -fclang-abi-compat=11.0 or earlier.

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ItaniumMangle.cpp
clang/test/CodeGenCXX/clang-abi-compat.cpp
clang/test/CodeGenCXX/mangle-template.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d54bfcd7245b..203c45fdd9a7 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -155,7 +155,8 @@ class LangOptions : public LangOptionsBase {
 
 /// Attempt to be ABI-compatible with code generated by Clang 11.0.x
 /// (git  2e10b7a39b93). This causes clang to pass unions with a 256-bit
-/// vector member on the stack instead of using registers.
+/// vector member on the stack instead of using registers, and to not
+/// properly mangle substitutions for template names in some cases.
 Ver11,
 
 /// Conform to the underlying platform's C and C++ ABIs as closely

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 2b6fda4d9dcc..172b94f26018 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -479,8 +479,6 @@ class CXXNameMangler {
   const AbiTagList *AdditionalAbiTags);
   void mangleUnscopedTemplateName(GlobalDecl GD,
   const AbiTagList *AdditionalAbiTags);
-  void mangleUnscopedTemplateName(TemplateName,
-  const AbiTagList *AdditionalAbiTags);
   void mangleSourceName(const IdentifierInfo *II);
   void mangleRegCallName(const IdentifierInfo *II);
   void mangleDeviceStubName(const IdentifierInfo *II);
@@ -994,29 +992,6 @@ void CXXNameMangler::mangleUnscopedTemplateName(
   addSubstitution(ND);
 }
 
-void CXXNameMangler::mangleUnscopedTemplateName(
-TemplateName Template, const AbiTagList *AdditionalAbiTags) {
-  //  ::= 
-  //  ::= 
-  if (TemplateDecl *TD = Template.getAsTemplateDecl())
-return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
-
-  if (mangleSubstitution(Template))
-return;
-
-  assert(!AdditionalAbiTags &&
- "dependent template name cannot have abi tags");
-
-  DependentTemplateName *Dependent = Template.getAsDependentTemplateName();
-  assert(Dependent && "Not a dependent template name?");
-  if (const IdentifierInfo *Id = Dependent->getIdentifier())
-mangleSourceName(Id);
-  else
-mangleOperatorName(Dependent->getOperator(), UnknownArity);
-
-  addSubstitution(Template);
-}
-
 void CXXNameMangler::mangleFloat(const llvm::APFloat &f) {
   // ABI:
   //   Floating-point literals are encoded using a fixed-length
@@ -1944,21 +1919,28 @@ void CXXNameMangler::mangleTemplatePrefix(TemplateName 
Template) {
   if (TemplateDecl *TD = Template.getAsTemplateDecl())
 return mangleTemplatePrefix(TD);
 
-  if (QualifiedTemplateName *Qualified = Template.getAsQualifiedTemplateName())
-manglePrefix(Qualified->getQualifier());
+  DependentTemplateName *Dependent = Template.getAsDependentTemplateName();
+  assert(Dependent && "unexpected template name kind");
 
-  if (OverloadedTemplateStorage *Overloaded
-  = Template.getAsOverloadedTemplate()) {
-mangleUnqualifiedName(GlobalDecl(), (*Overloaded->begin())->getDeclName(),
-  UnknownArity, nullptr);
+  // Clang 11 and before mangled the substitution for a dependent template name
+  // after already having emitted (a substitution for) the prefix.
+  bool Clang11Compat = getASTContext().getLangOpts().getClangABICompat() <=
+   LangOptions::ClangABI::Ver11;
+  if (!Clang11Compat && mangleSubstitution(Template))
 return;
-  }
 
-  DependentTemplateName *Dependent = Template.getAsDependentTemplateName();
-  assert(Dependent && "Unknown template name kind?");
   if (NestedNameSpecifier *Qualifier = Dependent->getQualifier())
 manglePrefix(Qualifier);
-  mangleUnscopedTemplateName(Template, /* AdditionalAbiTags */ nullptr);
+
+  if (Clang11Compat && mangleSubstitution(Template))
+return;
+
+  if (const IdentifierInfo *Id = Dependent->getIdentifier())
+mangleSourceName(Id);
+  else
+mangl

[llvm-branch-commits] [lld] 07f234b - [lld] Add --no-lto-whole-program-visibility

2020-11-24 Thread Teresa Johnson via llvm-branch-commits

Author: Teresa Johnson
Date: 2020-11-24T16:46:08-08:00
New Revision: 07f234be1ccbce131704f580aa3f117083a887f7

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

LOG: [lld] Add --no-lto-whole-program-visibility

Enables overriding earlier --lto-whole-program-visibility.

Variant of D91583 while discussing alternate ways to identify and
handle the --export-dynamic case.

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

Added: 


Modified: 
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/test/ELF/lto/devirt_vcall_vis_public.ll

Removed: 




diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 783b85e7e27a6..c3f3d88b5d2d4 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -990,7 +990,8 @@ static void readConfigs(opt::InputArgList &args) {
   config->ltoNewPassManager = args.hasArg(OPT_lto_new_pass_manager);
   config->ltoNewPmPasses = args.getLastArgValue(OPT_lto_newpm_passes);
   config->ltoWholeProgramVisibility =
-  args.hasArg(OPT_lto_whole_program_visibility);
+  args.hasFlag(OPT_lto_whole_program_visibility,
+   OPT_no_lto_whole_program_visibility, false);
   config->ltoo = args::getInteger(args, OPT_lto_O, 2);
   config->ltoObjPath = args.getLastArgValue(OPT_lto_obj_path_eq);
   config->ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1);

diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 5171c08a8291f..db1c5d9698423 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -539,8 +539,9 @@ def lto_cs_profile_file: JJ<"lto-cs-profile-file=">,
 def lto_obj_path_eq: JJ<"lto-obj-path=">;
 def lto_sample_profile: JJ<"lto-sample-profile=">,
   HelpText<"Sample profile file path">;
-def lto_whole_program_visibility: FF<"lto-whole-program-visibility">,
-  HelpText<"Asserts that the LTO link has whole program visibility">;
+defm lto_whole_program_visibility: BB<"lto-whole-program-visibility",
+  "Asserts that the LTO link has whole program visibility",
+  "Asserts that the LTO link does not have whole program visibility">;
 def disable_verify: F<"disable-verify">;
 defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option 
processing">;
 def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,

diff  --git a/lld/test/ELF/lto/devirt_vcall_vis_public.ll 
b/lld/test/ELF/lto/devirt_vcall_vis_public.ll
index 0d344ec9483df..46e23537d4fa5 100644
--- a/lld/test/ELF/lto/devirt_vcall_vis_public.ll
+++ b/lld/test/ELF/lto/devirt_vcall_vis_public.ll
@@ -1,6 +1,9 @@
 ; REQUIRES: x86
 ; Test that --lto-whole-program-visibility enables devirtualization.
 
+; Note that the --export-dynamic used below is simply to ensure symbols are
+; retained during linking.
+
 ; Index based WPD
 ; Generate unsplit module with summary for ThinLTO index-based WPD.
 ; RUN: opt --thinlto-bc -o %t2.o %s
@@ -31,6 +34,10 @@
 ; RUN: ld.lld %t2.o -o %t3 -save-temps \
 ; RUN:  -mllvm -pass-remarks=. --export-dynamic 2>&1 | FileCheck %s 
--implicit-check-not single-impl --allow-empty
 ; RUN: llvm-dis %t2.o.4.opt.bc -o - | FileCheck %s 
--check-prefix=CHECK-NODEVIRT-IR
+; Ensure --no-lto-whole-program-visibility overrides explicit 
--lto-whole-program-visibility.
+; RUN: ld.lld %t2.o -o %t3 -save-temps --lto-whole-program-visibility 
--no-lto-whole-program-visibility \
+; RUN:  -mllvm -pass-remarks=. --export-dynamic 2>&1 | FileCheck %s 
--implicit-check-not single-impl --allow-empty
+; RUN: llvm-dis %t2.o.4.opt.bc -o - | FileCheck %s 
--check-prefix=CHECK-NODEVIRT-IR
 
 ; Hybrid WPD
 ; RUN: ld.lld %t.o -o %t3 -save-temps \



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


[llvm-branch-commits] [clang] 23dc049 - Treat a placeholder type for class template argument deduction as

2020-11-24 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-11-24T16:59:06-08:00
New Revision: 23dc04981be29b8398b7a409540646b58af76983

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

LOG: Treat a placeholder type for class template argument deduction as
substitutable for the deduced template.

As agreed in https://github.com/itanium-cxx-abi/cxx-abi/issues/109.

Added: 


Modified: 
clang/lib/AST/ItaniumMangle.cpp
clang/test/CodeGenCXX/cxx1z-class-deduction.cpp

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 172b94f26018..f5a4f6708c83 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2507,6 +2507,12 @@ static bool isTypeSubstitutable(Qualifiers Quals, const 
Type *Ty,
   if (Ctx.getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver6 &&
   isa(Ty))
 return false;
+  // A placeholder type for class template deduction is substitutable with
+  // its corresponding template name; this is handled specially when mangling
+  // the type.
+  if (auto *DeducedTST = Ty->getAs())
+if (DeducedTST->getDeducedType().isNull())
+  return false;
   return true;
 }
 
@@ -3696,16 +3702,16 @@ void CXXNameMangler::mangleType(const AutoType *T) {
 void CXXNameMangler::mangleType(const DeducedTemplateSpecializationType *T) {
   QualType Deduced = T->getDeducedType();
   if (!Deduced.isNull())
-mangleType(Deduced);
-  else if (TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl())
-mangleName(GlobalDecl(TD));
-  else {
-// For an unresolved template-name, mangle it as if it were a template
-// specialization but leave off the template arguments.
-Out << 'N';
-mangleTemplatePrefix(T->getTemplateName());
-Out << 'E';
-  }
+return mangleType(Deduced);
+
+  TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl();
+  assert(TD && "shouldn't form deduced TST unless we know we have a template");
+
+  if (mangleSubstitution(TD))
+return;
+
+  mangleName(GlobalDecl(TD));
+  addSubstitution(TD);
 }
 
 void CXXNameMangler::mangleType(const AtomicType *T) {

diff  --git a/clang/test/CodeGenCXX/cxx1z-class-deduction.cpp 
b/clang/test/CodeGenCXX/cxx1z-class-deduction.cpp
index 8edab748338e..bf436e7ec980 100644
--- a/clang/test/CodeGenCXX/cxx1z-class-deduction.cpp
+++ b/clang/test/CodeGenCXX/cxx1z-class-deduction.cpp
@@ -29,9 +29,9 @@ struct X {
   template struct C { C(T); };
 };
 
-// CHECK: @_Z1gIiEDaT_DTcv1AfL0p_E1AIS0_E(
+// CHECK: @_Z1gIiEDaT_DTcv1AfL0p_ES1_IS0_E
 template auto g(T x, decltype(A(x)), A) {}
-// CHECK: @_Z1hIiEDaT_DTcvN1N1BEfL0p_ENS1_1BIS0_EE(
+// CHECK: @_Z1hIiEDaT_DTcvN1N1BEfL0p_ENS2_IS0_EE
 template auto h(T x, decltype(B(x)), B) {}
 // CHECK: @_Z1iI1XiEDaT0_DTcvNT_1CEfL0p_ENS2_1CIS1_EE(
 template auto i(T x, decltype(typename U::C(x)), 
typename U::template C) {}



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


[llvm-branch-commits] [mlir] 5c4e397 - [mlir][sparse] add parallelization strategies to sparse compiler

2020-11-24 Thread Aart Bik via llvm-branch-commits

Author: Aart Bik
Date: 2020-11-24T17:17:13-08:00
New Revision: 5c4e397e6ce5c89d63f590857e5cb0e80237de62

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

LOG: [mlir][sparse] add parallelization strategies to sparse compiler

This CL adds the ability to request different parallelization strategies
for the generate code. Every "parallel" loop is a candidate, and converted
to a parallel op if it is an actual for-loop (not a while) and the strategy
allows dense/sparse outer/inner parallelization.

This will connect directly with the work of @ezhulenev on parallel loops.

Still TBD: vectorization strategy

Reviewed By: penpornk

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

Added: 
mlir/test/Dialect/Linalg/sparse_parallel.mlir

Modified: 
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
mlir/test/lib/Transforms/TestSparsification.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index d67e81ceab87..7a96a5ed1390 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -783,9 +783,62 @@ LogicalResult applyStagedPatterns(
 
 
//===--===//
 // Support for sparse tensor code generation.
+//
+// The sparse compiler part of MLIR lowers a tensor expression formulated as a
+// Linalg operation into a sequence of loops depending on what dimensions of 
the
+// tensors are marked dense or sparse. The generated code distinguishes 
between:
+// (1) for-loops that iterate over a single dense dimension,
+// (2) for-loops that iterate over a single sparse dimension,
+// (3) while-loops that co-iterate over several sparse dimensions.
+// The for-loops may be subsequently optimized for parallel or vector 
execution.
+//
+// For more details, the Dialect/Linalg/Transforms/Sparsification.cpp file.
 
//===--===//
-void populateSparsificationPatterns(MLIRContext *context,
-OwningRewritePatternList &patterns);
+
+/// Defines a parallelization strategy. Any implicit loop in the Linalg
+/// operation that is marked "parallel" (thus not "reduction") is a candidate
+/// for parallelization. The loop is made parallel if (1) allowed by the
+/// strategy (e.g., AnyStorageOuterLoop considers either a dense or sparse
+/// outermost loop only), and (2) the generated code is an actual for-loop
+/// (and not a co-iterating while-loop).
+enum class SparseParallelizationStrategy {
+  kNone,
+  kDenseOuterLoop,
+  kAnyStorageOuterLoop,
+  kDenseAnyLoop,
+  kAnyStorageAnyLoop
+  // TODO: support reduction parallelization too?
+};
+
+/// Defines a vectorization strategy. Any implicit inner loop in the Linalg
+/// operation is a candidate (full SIMD for "parallel" loops and horizontal
+/// SIMD for "reduction" loops). A loop is actually vectorized if (1) allowed
+/// by the strategy, and (2) the emitted code is an actual for-loop (and not
+/// a co-iterating while-loop).
+enum class SparseVectorizationStrategy {
+  kNone,
+  kDenseInnerLoop,
+  kAnyStorageInnerLoop
+};
+
+/// Sparsification options.
+struct SparsificationOptions {
+  SparsificationOptions(SparseParallelizationStrategy p,
+SparseVectorizationStrategy v, unsigned vl)
+  : parallelizationStrategy(p), vectorizationStrategy(v), vectorLength(vl) 
{
+  }
+  SparsificationOptions()
+  : SparsificationOptions(SparseParallelizationStrategy::kNone,
+  SparseVectorizationStrategy::kNone, 1u) {}
+  SparseParallelizationStrategy parallelizationStrategy;
+  SparseVectorizationStrategy vectorizationStrategy;
+  unsigned vectorLength;
+};
+
+/// Set up sparsification rewriting rules with the given options.
+void populateSparsificationPatterns(
+MLIRContext *context, OwningRewritePatternList &patterns,
+const SparsificationOptions &options = SparsificationOptions());
 
 } // namespace linalg
 } // namespace mlir

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
index 69a4d7e5648e..729268393ed9 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
@@ -235,22 +235,30 @@ class Merger {
 
 // Code generation.
 struct CodeGen {
-  CodeGen(unsigned numTensors, unsigned numLoops)
-  : loops(numLoops), sizes(numLoops), buffers(numTensors),
+  CodeGen(linalg::SparsificationOptions o, unsigned numTensors,
+  unsigned numLoops)
+  : o

[llvm-branch-commits] [clang-tools-extra] 9c4df9e - [clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier naming checks

2020-11-24 Thread Nathan James via llvm-branch-commits

Author: smhc
Date: 2020-11-25T01:18:44Z
New Revision: 9c4df9eecb6ca6b53d919cec9b460de46dd40302

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

LOG: [clang-tidy] Support IgnoredRegexp configuration to selectively suppress 
identifier naming checks

The idea of suppressing naming checks for variables is to support code bases 
that allow short variables named e.g 'x' and 'i' without prefix/suffixes or 
casing styles. This was originally proposed as a 'ShortSizeThreshold' however 
has been made more generic with a regex to suppress identifier naming checks 
for those that match.

Reviewed By: njames93, aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index d7160d52750f..efc683c6c05d 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -122,14 +122,32 @@ static StringRef const StyleNames[] = {
 #undef NAMING_KEYS
 // clang-format on
 
+IdentifierNamingCheck::NamingStyle::NamingStyle(
+llvm::Optional Case,
+const std::string &Prefix, const std::string &Suffix,
+const std::string &IgnoredRegexpStr)
+: Case(Case), Prefix(Prefix), Suffix(Suffix),
+  IgnoredRegexpStr(IgnoredRegexpStr) {
+  if (!IgnoredRegexpStr.empty()) {
+IgnoredRegexp =
+llvm::Regex(llvm::SmallString<128>({"^", IgnoredRegexpStr, "$"}));
+if (!IgnoredRegexp.isValid())
+  llvm::errs() << "Invalid IgnoredRegexp regular expression: "
+   << IgnoredRegexpStr;
+  }
+}
+
 static IdentifierNamingCheck::FileStyle
 getFileStyleFromOptions(const ClangTidyCheck::OptionsView &Options) {
-  SmallVector, 0> Styles(
-  SK_Count);
+  SmallVector, 0> Styles;
+  Styles.resize(SK_Count);
   SmallString<64> StyleString;
   for (unsigned I = 0; I < SK_Count; ++I) {
 StyleString = StyleNames[I];
 size_t StyleSize = StyleString.size();
+StyleString.append("IgnoredRegexp");
+std::string IgnoredRegexpStr = Options.get(StyleString, "");
+StyleString.resize(StyleSize);
 StyleString.append("Prefix");
 std::string Prefix(Options.get(StyleString, ""));
 // Fast replacement of [Pre]fix -> [Suf]fix.
@@ -141,9 +159,10 @@ getFileStyleFromOptions(const ClangTidyCheck::OptionsView 
&Options) {
 auto CaseOptional =
 Options.getOptional(StyleString);
 
-if (CaseOptional || !Prefix.empty() || !Postfix.empty())
+if (CaseOptional || !Prefix.empty() || !Postfix.empty() ||
+!IgnoredRegexpStr.empty())
   Styles[I].emplace(std::move(CaseOptional), std::move(Prefix),
-std::move(Postfix));
+std::move(Postfix), std::move(IgnoredRegexpStr));
   }
   bool IgnoreMainLike = Options.get("IgnoreMainLikeFunctions", false);
   return {std::move(Styles), IgnoreMainLike};
@@ -175,6 +194,9 @@ void 
IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   continue;
 StyleString = StyleNames[I];
 size_t StyleSize = StyleString.size();
+StyleString.append("IgnoredRegexp");
+Options.store(Opts, StyleString, Styles[I]->IgnoredRegexpStr);
+StyleString.resize(StyleSize);
 StyleString.append("Prefix");
 Options.store(Opts, StyleString, Styles[I]->Prefix);
 // Fast replacement of [Pre]fix -> [Suf]fix.
@@ -194,7 +216,7 @@ void 
IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 static bool matchesStyle(StringRef Name,
- IdentifierNamingCheck::NamingStyle Style) {
+ const IdentifierNamingCheck::NamingStyle &Style) {
   static llvm::Regex Matchers[] = {
   llvm::Regex("^.*$"),
   llvm::Regex("^[a-z][a-z0-9_]*$"),
@@ -681,6 +703,9 @@ static llvm::Optional 
getFailureInfo(
 return None;
 
   const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK];
+  if (Style.IgnoredRegexp.isValid() && Style.IgnoredRegexp.match(Name))
+return None;
+
   if (matchesStyle(Name, Style))
 return None;
 

diff  --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
index 77c03f77d91d..565eb9d11474 100644
--- a/clang-tools-extra/clang-tidy/readabi

[llvm-branch-commits] [clang] 09ba206 - Fix compilation issue reported by MSVC user on cfe-dev

2020-11-24 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-11-24T17:31:25-08:00
New Revision: 09ba2063dc9339957b999c08d3810a3cec2b745b

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

LOG: Fix compilation issue reported by MSVC user on cfe-dev

MSVC seems to think this `friend class TrailingObjects;` declaration is
declaring a TrailingObjects class instead of naming the injected base
class. Remove `class` so it does the right thing.

Added: 


Modified: 
clang/include/clang/AST/ExprCXX.h

Removed: 




diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index d4e0eb83bcc3..2f89b43267b6 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4864,7 +4864,7 @@ class BuiltinBitCastExpr final
   private llvm::TrailingObjects {
   friend class ASTStmtReader;
   friend class CastExpr;
-  friend class TrailingObjects;
+  friend TrailingObjects;
 
   SourceLocation KWLoc;
   SourceLocation RParenLoc;



___
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] cbd7541 - DebugInfo: Add some missing explicit target triples.

2020-11-24 Thread David Blaikie via llvm-branch-commits

Author: David Blaikie
Date: 2020-11-24T17:35:00-08:00
New Revision: cbd754163934a64e65b87a0f1b2c6741af8d24db

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

LOG: DebugInfo: Add some missing explicit target triples.

Based on D91043 by Luís Marques. Thanks Luís!

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

Added: 


Modified: 
llvm/test/DebugInfo/X86/abstract_origin.ll
llvm/test/DebugInfo/X86/convert-debugloc.ll
llvm/test/DebugInfo/X86/convert-inlined.ll
llvm/test/DebugInfo/X86/convert-linked.ll
llvm/test/DebugInfo/X86/convert-loclist.ll
llvm/test/DebugInfo/X86/dbg-byval-parameter.ll
llvm/test/DebugInfo/X86/debug-macro.ll
llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll

Removed: 




diff  --git a/llvm/test/DebugInfo/X86/abstract_origin.ll 
b/llvm/test/DebugInfo/X86/abstract_origin.ll
index 36992177e341..4cf49055cbd8 100644
--- a/llvm/test/DebugInfo/X86/abstract_origin.ll
+++ b/llvm/test/DebugInfo/X86/abstract_origin.ll
@@ -1,4 +1,4 @@
-; RUN: %llc_dwarf -filetype=obj %s -o - | llvm-dwarfdump -debug-info - | 
FileCheck %s
+; RUN: llc -mtriple=x86_64 -filetype=obj %s -o - | llvm-dwarfdump -debug-info 
- | FileCheck %s
 ; Generated at -O2 from:
 ;   void f();
 ;   __attribute__((always_inline)) void g() {

diff  --git a/llvm/test/DebugInfo/X86/convert-debugloc.ll 
b/llvm/test/DebugInfo/X86/convert-debugloc.ll
index a61127ab6932..fc31c3f72549 100644
--- a/llvm/test/DebugInfo/X86/convert-debugloc.ll
+++ b/llvm/test/DebugInfo/X86/convert-debugloc.ll
@@ -1,4 +1,4 @@
-; RUN: %llc_dwarf -dwarf-version=4 -filetype=obj -O0 < %s | llvm-dwarfdump - \
+; RUN: llc -mtriple=x86_64 -dwarf-version=4 -filetype=obj -O0 < %s | 
llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=NOCONV 
"--implicit-check-not={{DW_TAG|NULL}}"
 
 ; Test lldb default: OP_convert is unsupported when using MachO
@@ -8,13 +8,13 @@
 ; RUN:   | FileCheck %s --check-prefix=NOCONV 
"--implicit-check-not={{DW_TAG|NULL}}"
 
 ; Test gdb default: OP_convert is only disabled in split DWARF
-; RUN: %llc_dwarf -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=gdb  
| llvm-dwarfdump - \
+; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s 
-debugger-tune=gdb  | llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=CONV 
"--implicit-check-not={{DW_TAG|NULL}}"
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu  -dwarf-version=5 -filetype=obj -O0 < 
%s -debugger-tune=gdb   -split-dwarf-file=baz.dwo | llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=NOCONV --check-prefix=SPLIT 
"--implicit-check-not={{DW_TAG|NULL}}"
 
 ; Test the ability to override the platform default in either direction
-; RUN: %llc_dwarf -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=gdb  
-dwarf-op-convert=Disable | llvm-dwarfdump - \
+; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s 
-debugger-tune=gdb  -dwarf-op-convert=Disable | llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=NOCONV 
"--implicit-check-not={{DW_TAG|NULL}}"
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -dwarf-version=5 -filetype=obj -O0 < 
%s -debugger-tune=lldb -dwarf-op-convert=Enable | llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=CONV 
"--implicit-check-not={{DW_TAG|NULL}}"
@@ -23,7 +23,7 @@
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -dwarf-version=5 -filetype=obj -O0 < 
%s -debugger-tune=lldb -dwarf-op-convert=Enable -split-dwarf-file=baz.dwo | 
llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=CONV --check-prefix=SPLITCONV 
--check-prefix=SPLIT "--implicit-check-not={{DW_TAG|NULL}}"
 
-; RUN: %llc_dwarf -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=gdb  
| llvm-dwarfdump -v -debug-info - \
+; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s 
-debugger-tune=gdb  | llvm-dwarfdump -v -debug-info - \
 ; RUN:   | FileCheck %s --check-prefix=VERBOSE --check-prefix=CONV 
"--implicit-check-not={{DW_TAG|NULL}}"
 
 

diff  --git a/llvm/test/DebugInfo/X86/convert-inlined.ll 
b/llvm/test/DebugInfo/X86/convert-inlined.ll
index 5e28a7293d80..14f9a8a3e26e 100644
--- a/llvm/test/DebugInfo/X86/convert-inlined.ll
+++ b/llvm/test/DebugInfo/X86/convert-inlined.ll
@@ -1,6 +1,6 @@
-; RUN: %llc_dwarf -dwarf-version=5 -filetype=obj -O0 < %s | llvm-dwarfdump - \
+; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s | 
llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=DW5 
"--implicit-check-not={{DW_TAG|NULL}}"
-; RUN: %llc_dwarf -dwarf-version=4 -filetype=obj -O0 < %s | llvm-dwarfdump - \
+; RUN: llc -mtriple=x86_64 -dwarf-version=4 -filetype=obj -O0 < %s | 
llvm-dwarfdump - \
 ; RUN:   | FileCheck %s --check-prefix=DW4 
"--implicit-check-not={{DW_TAG|NULL}}"
 
 ; DW5: .debug_info contents:

diff  --git a/llvm/test/DebugInfo/X86/convert-

[llvm-branch-commits] [llvm] fa42f08 - [PowerPC][FP128] Fix the incorrect calling convention for IEEE long double on Power8

2020-11-24 Thread QingShan Zhang via llvm-branch-commits

Author: QingShan Zhang
Date: 2020-11-25T01:43:48Z
New Revision: fa42f08b2643d0a2e53fde8949e7f88b6d965bb8

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

LOG: [PowerPC][FP128] Fix the incorrect calling convention for IEEE long double 
on Power8

For now, we are using the GPR to pass the arguments/return value for fp128 on 
Power8,
which is incorrect. It should be VSR. The reason why we do it this way is that,
we are setting the fp128 as illegal which make LLVM try to emulate it with i128 
on
Power8. So, we need to correct it as legal.

Reviewed By: Nemanjai

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCCallingConv.td
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrAltivec.td
llvm/test/CodeGen/PowerPC/f128-arith.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCCallingConv.td 
b/llvm/lib/Target/PowerPC/PPCCallingConv.td
index 9a15490f1fb0..64de7353c516 100644
--- a/llvm/lib/Target/PowerPC/PPCCallingConv.td
+++ b/llvm/lib/Target/PowerPC/PPCCallingConv.td
@@ -59,7 +59,7 @@ def RetCC_PPC_Cold : CallingConv<[
 
   CCIfType<[f32], CCAssignToReg<[F1]>>,
   CCIfType<[f64], CCAssignToReg<[F1]>>,
-  CCIfType<[f128], CCIfSubtarget<"hasP9Vector()", CCAssignToReg<[V2]>>>,
+  CCIfType<[f128], CCIfSubtarget<"hasAltivec()", CCAssignToReg<[V2]>>>,
 
   CCIfType<[v16i8, v8i16, v4i32, v2i64, v1i128, v4f32, v2f64],
CCIfSubtarget<"hasAltivec()",
@@ -92,7 +92,7 @@ def RetCC_PPC : CallingConv<[
 
   // For P9, f128 are passed in vector registers.
   CCIfType<[f128],
-   CCIfSubtarget<"hasP9Vector()",
+   CCIfSubtarget<"hasAltivec()",
CCAssignToReg<[V2, V3, V4, V5, V6, V7, V8, V9]>>>,
 
   // Vector types returned as "direct" go into V2 .. V9; note that only the
@@ -149,7 +149,7 @@ def RetCC_PPC64_ELF_FIS : CallingConv<[
   CCIfType<[f32],  CCAssignToReg<[F1, F2, F3, F4, F5, F6, F7, F8]>>,
   CCIfType<[f64],  CCAssignToReg<[F1, F2, F3, F4, F5, F6, F7, F8]>>,
   CCIfType<[f128],
-   CCIfSubtarget<"hasP9Vector()",
+   CCIfSubtarget<"hasAltivec()",
CCAssignToReg<[V2, V3, V4, V5, V6, V7, V8, V9]>>>,
   CCIfType<[v16i8, v8i16, v4i32, v2i64, v1i128, v4f32, v2f64],
CCIfSubtarget<"hasAltivec()",
@@ -216,7 +216,7 @@ def CC_PPC32_SVR4_Common : CallingConv<[
 
   // Vectors and float128 get 16-byte stack slots that are 16-byte aligned.
   CCIfType<[v16i8, v8i16, v4i32, v4f32, v2f64, v2i64], CCAssignToStack<16, 
16>>,
-  CCIfType<[f128], CCIfSubtarget<"hasP9Vector()", CCAssignToStack<16, 16>>>
+  CCIfType<[f128], CCIfSubtarget<"hasAltivec()", CCAssignToStack<16, 16>>>
 ]>;
 
 // This calling convention puts vector arguments always on the stack. It is 
used
@@ -238,7 +238,7 @@ def CC_PPC32_SVR4 : CallingConv<[
 
   // Float128 types treated as vector arguments.
   CCIfType<[f128],
-   CCIfSubtarget<"hasP9Vector()", CCAssignToReg<[V2, V3, V4, V5, V6, 
V7,
+   CCIfSubtarget<"hasAltivec()", CCAssignToReg<[V2, V3, V4, V5, V6, V7,
   V8, V9, V10, V11, V12, V13]>>>,

   CCDelegateTo

diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 5b42dbdb9bee..10aecf97fcdf 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -121,6 +121,11 @@ cl::desc("don't always align innermost loop to 32 bytes on 
ppc"), cl::Hidden);
 static cl::opt UseAbsoluteJumpTables("ppc-use-absolute-jumptables",
 cl::desc("use absolute jump tables on ppc"), cl::Hidden);
 
+// TODO - Remove this option if soft fp128 has been fully supported .
+static cl::opt
+EnableSoftFP128("enable-soft-fp128",
+cl::desc("temp option to enable soft fp128"), cl::Hidden);
+
 STATISTIC(NumTailCalls, "Number of tail calls");
 STATISTIC(NumSiblingCalls, "Number of sibling calls");
 STATISTIC(ShufflesHandledWithVPERM, "Number of shuffles lowered to a VPERM");
@@ -1161,6 +1166,32 @@ PPCTargetLowering::PPCTargetLowering(const 
PPCTargetMachine &TM,
   setOperationAction(ISD::BSWAP, MVT::v4i32, Legal);
   setOperationAction(ISD::BSWAP, MVT::v2i64, Legal);
   setOperationAction(ISD::BSWAP, MVT::v1i128, Legal);
+} else if (Subtarget.hasAltivec() && EnableSoftFP128) {
+  addRegisterClass(MVT::f128, &PPC::VRRCRegClass);
+
+  for (MVT FPT : MVT::fp_valuetypes())
+setLoadExtAction(ISD::EXTLOAD, MVT::f128, FPT, Expand);
+
+  setOperationAction(ISD::LOAD, MVT::f128, Promote);
+  setOperationAction(ISD::STORE, MVT::f128, Promote);
+
+  AddPromotedToType(ISD::LOAD, MVT::f128, MVT::v4i32);
+  AddPromotedToType(ISD::STORE, MVT::f128, MVT::v4i32);
+
+  setOperationActi

[llvm-branch-commits] [llvm] 01cee92 - DebugInfo: Remove llc_dwarf usage from tests already relying on a target triple in the IR

2020-11-24 Thread David Blaikie via llvm-branch-commits

Author: David Blaikie
Date: 2020-11-24T17:48:11-08:00
New Revision: 01cee921abe924ae98027ce599d3c76ca5780a38

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

LOG: DebugInfo: Remove llc_dwarf usage from tests already relying on a target 
triple in the IR

Added: 


Modified: 
llvm/test/DebugInfo/X86/DIModuleContext.ll
llvm/test/DebugInfo/X86/Fortran-DIModule.ll
llvm/test/DebugInfo/X86/align_c11.ll
llvm/test/DebugInfo/X86/align_cpp11.ll
llvm/test/DebugInfo/X86/align_objc.ll
llvm/test/DebugInfo/X86/atomic-c11-dwarf-4.ll
llvm/test/DebugInfo/X86/atomic-c11-dwarf-5.ll
llvm/test/DebugInfo/X86/constant-loclist.ll
llvm/test/DebugInfo/X86/containing-type-extension-rust.ll
llvm/test/DebugInfo/X86/debug-info-auto-return.ll
llvm/test/DebugInfo/X86/debug-info-packed-struct.ll
llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
llvm/test/DebugInfo/X86/debug-macro-dwo.ll
llvm/test/DebugInfo/X86/debug-macro-gnu-dwo.ll
llvm/test/DebugInfo/X86/debug-macro-gnu.ll
llvm/test/DebugInfo/X86/debug-macro-v5.ll
llvm/test/DebugInfo/X86/distringtype.ll
llvm/test/DebugInfo/X86/gmlt-no-split-dwarf-inlining-empty.ll
llvm/test/DebugInfo/X86/inline-namespace.ll
llvm/test/DebugInfo/X86/noreturn_c11.ll
llvm/test/DebugInfo/X86/noreturn_cpp11.ll
llvm/test/DebugInfo/X86/noreturn_objc.ll
llvm/test/DebugInfo/X86/partial-constant.ll
llvm/test/DebugInfo/X86/single-dbg_value.ll
llvm/test/DebugInfo/X86/split-dwarf-multiple-cu-hash.ll
llvm/test/DebugInfo/X86/split-dwarf-omit-empty.ll
llvm/test/DebugInfo/X86/split-dwarf-sysroot.ll
llvm/test/DebugInfo/X86/static_member_array.ll
llvm/test/DebugInfo/X86/unattached-global.ll

Removed: 




diff  --git a/llvm/test/DebugInfo/X86/DIModuleContext.ll 
b/llvm/test/DebugInfo/X86/DIModuleContext.ll
index e9dd9116b393..aee57033f431 100644
--- a/llvm/test/DebugInfo/X86/DIModuleContext.ll
+++ b/llvm/test/DebugInfo/X86/DIModuleContext.ll
@@ -1,6 +1,6 @@
 source_filename = "test/DebugInfo/X86/DIModuleContext.ll"
 target triple = "x86_64-apple-macosx"
-; RUN: %llc_dwarf %s -o - -filetype=obj \
+; RUN: llc %s -o - -filetype=obj \
 ; RUN:   | llvm-dwarfdump -debug-info - | FileCheck %s
 ; CHECK: DW_TAG_module
 ; CHECK-NOT: NULL

diff  --git a/llvm/test/DebugInfo/X86/Fortran-DIModule.ll 
b/llvm/test/DebugInfo/X86/Fortran-DIModule.ll
index 37c46d1d02e8..39ada5e42f40 100644
--- a/llvm/test/DebugInfo/X86/Fortran-DIModule.ll
+++ b/llvm/test/DebugInfo/X86/Fortran-DIModule.ll
@@ -1,5 +1,5 @@
 ; This test checks attributes of a Fortran module.
-; RUN: %llc_dwarf %s -filetype=obj -o - | \
+; RUN: llc %s -filetype=obj -o - | \
 ; RUN:   llvm-dwarfdump - | FileCheck %s
 
 ; CHECK: DW_TAG_module

diff  --git a/llvm/test/DebugInfo/X86/align_c11.ll 
b/llvm/test/DebugInfo/X86/align_c11.ll
index cc0383a8ca93..baadca1ba6a4 100644
--- a/llvm/test/DebugInfo/X86/align_c11.ll
+++ b/llvm/test/DebugInfo/X86/align_c11.ll
@@ -1,4 +1,4 @@
-; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump -debug-info - | 
FileCheck %s
+; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
 
 ; Generated by clang -c -g -std=c11 -S -emit-llvm from the following C11 source
 ;

diff  --git a/llvm/test/DebugInfo/X86/align_cpp11.ll 
b/llvm/test/DebugInfo/X86/align_cpp11.ll
index 92dfdaee5390..10116e3c6a89 100644
--- a/llvm/test/DebugInfo/X86/align_cpp11.ll
+++ b/llvm/test/DebugInfo/X86/align_cpp11.ll
@@ -1,4 +1,4 @@
-; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump -debug-info - | 
FileCheck %s
+; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
 
 ; Generated by clang++ -c -g -std=c++11 -S -emit-llvm from the following C++11 
source
 ; struct S {

diff  --git a/llvm/test/DebugInfo/X86/align_objc.ll 
b/llvm/test/DebugInfo/X86/align_objc.ll
index 9ce6dea0a41d..13bbf862e9b1 100644
--- a/llvm/test/DebugInfo/X86/align_objc.ll
+++ b/llvm/test/DebugInfo/X86/align_objc.ll
@@ -1,4 +1,4 @@
-; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump -debug-info - | 
FileCheck %s
+; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
 
 ; typedef struct __attribute__((aligned (128))) {
 ;   char c;

diff  --git a/llvm/test/DebugInfo/X86/atomic-c11-dwarf-4.ll 
b/llvm/test/DebugInfo/X86/atomic-c11-dwarf-4.ll
index c31b7d168c45..820182d9031f 100644
--- a/llvm/test/DebugInfo/X86/atomic-c11-dwarf-4.ll
+++ b/llvm/test/DebugInfo/X86/atomic-c11-dwarf-4.ll
@@ -1,4 +1,4 @@
-; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump -debug-info - | 
FileCheck %s
+; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
 
 ; Generated by clang -c -g -std=c11 -S -emit-llvm from the following C11 source
 ;

d

[llvm-branch-commits] [llvm] 3d1149c - Make CallInst::updateProfWeight emit i32 weights instead of i64

2020-11-24 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-24T18:13:59-08:00
New Revision: 3d1149c6fe48cdab768b587e5531c31b6f42ee12

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

LOG: Make CallInst::updateProfWeight emit i32 weights instead of i64

Typically branch_weights are i32, not i64.
This fixes entry_counts_cold.ll under NPM.

Reviewed By: asbirlea

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

Added: 


Modified: 
llvm/lib/IR/Instructions.cpp
llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
llvm/test/Transforms/Inline/prof-update-sample.ll
llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
llvm/test/Transforms/SampleProfile/inline-mergeprof.ll
llvm/unittests/IR/InstructionsTest.cpp

Removed: 




diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 91340e2333ad..ee667cfc42e8 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -560,8 +560,9 @@ void CallInst::updateProfWeight(uint64_t S, uint64_t T) {
->getValue()
.getZExtValue());
 Val *= APS;
-Vals.push_back(MDB.createConstant(ConstantInt::get(
-Type::getInt64Ty(getContext()), Val.udiv(APT).getLimitedValue(;
+Vals.push_back(MDB.createConstant(
+ConstantInt::get(Type::getInt32Ty(getContext()),
+ Val.udiv(APT).getLimitedValue(UINT32_MAX;
   } else if (ProfDataName->getString().equals("VP"))
 for (unsigned i = 1; i < ProfileData->getNumOperands(); i += 2) {
   // The first value is the key of the value profile, which will not 
change.

diff  --git a/llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll 
b/llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
index 5bb5834faefd..45d62c4c3c3c 100644
--- a/llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
+++ b/llvm/test/Transforms/Inline/prof-update-sample-alwaysinline.ll
@@ -48,13 +48,13 @@ define void @caller() {
 !13 = !{i32 999000, i64 100, i32 1}
 !14 = !{i32 99, i64 1, i32 2}
 !15 = !{!"function_entry_count", i64 1000}
-!16 = !{!"branch_weights", i64 2000}
-!17 = !{!"branch_weights", i64 400}
+!16 = !{!"branch_weights", i32 2000}
+!17 = !{!"branch_weights", i32 400}
 !18 = !{!"VP", i32 0, i64 140, i64 111, i64 80, i64 222, i64 40, i64 333, i64 
20}
 attributes #0 = { alwaysinline }
 ; CHECK: ![[ENTRY_COUNT]] = !{!"function_entry_count", i64 600}
-; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i64 2000}
-; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i64 1200}
+; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i32 2000}
+; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i32 1200}
 ; CHECK: ![[COUNT_IND_CALLEE]] = !{!"VP", i32 0, i64 84, i64 111, i64 48, i64 
222, i64 24, i64 333, i64 12}
-; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i64 800}
+; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i32 800}
 ; CHECK: ![[COUNT_IND_CALLER]] = !{!"VP", i32 0, i64 56, i64 111, i64 32, i64 
222, i64 16, i64 333, i64 8}

diff  --git a/llvm/test/Transforms/Inline/prof-update-sample.ll 
b/llvm/test/Transforms/Inline/prof-update-sample.ll
index ee475a6f3b2b..76cba190c264 100644
--- a/llvm/test/Transforms/Inline/prof-update-sample.ll
+++ b/llvm/test/Transforms/Inline/prof-update-sample.ll
@@ -49,12 +49,12 @@ define void @caller() {
 !13 = !{i32 999000, i64 100, i32 1}
 !14 = !{i32 99, i64 1, i32 2}
 !15 = !{!"function_entry_count", i64 1000}
-!16 = !{!"branch_weights", i64 2000}
-!17 = !{!"branch_weights", i64 400}
+!16 = !{!"branch_weights", i32 2000}
+!17 = !{!"branch_weights", i32 400}
 !18 = !{!"VP", i32 0, i64 140, i64 111, i64 80, i64 222, i64 40, i64 333, i64 
20}
 ; CHECK: ![[ENTRY_COUNT]] = !{!"function_entry_count", i64 600}
-; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i64 2000}
-; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i64 1200}
+; CHECK: ![[COUNT_CALLEE1]] = !{!"branch_weights", i32 2000}
+; CHECK: ![[COUNT_CALLEE]] = !{!"branch_weights", i32 1200}
 ; CHECK: ![[COUNT_IND_CALLEE]] = !{!"VP", i32 0, i64 84, i64 111, i64 48, i64 
222, i64 24, i64 333, i64 12}
-; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i64 800}
+; CHECK: ![[COUNT_CALLER]] = !{!"branch_weights", i32 800}
 ; CHECK: ![[COUNT_IND_CALLER]] = !{!"VP", i32 0, i64 56, i64 111, i64 32, i64 
222, i64 16, i64 333, i64 8}

diff  --git a/llvm/test/Transforms/SampleProfile/entry_counts_cold.ll 
b/llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
index 95dda320b1fd..73b4fadaa90c 100644
--- a/llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
+++ b/llvm/test/Transforms/SampleProfile/entry_counts_cold.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -sample-profile 
-sample-profile-file=%S/Inputs/entry_counts_cold.prof -S | FileCheck %s
+; RUN: opt < %s -pass

[llvm-branch-commits] [llvm] 3e8d980 - [X86] Don't produce bad x86andp nodes for i1 vectors

2020-11-24 Thread Tom Stellard via llvm-branch-commits

Author: Keno Fischer
Date: 2020-11-24T21:47:48-05:00
New Revision: 3e8d9807d663d3180ba5093879f8f570f8c280bb

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

LOG: [X86] Don't produce bad x86andp nodes for i1 vectors

In D85499, I attempted to fix this same issue by canonicalizing
andnp for i1 vectors, but since there was some opposition to such
a change, this commit just fixes the bug by using two different
forms depending on which kind of vector type is in use. We can
then always decide to switch the canonical forms later.

Description of the original bug:
We have a DAG combine that tries to fold (vselect cond, ..., X) -> (andnp 
cond, x).
However, it does so by attempting to create an i64 vector with the number
of elements obtained by truncating division by 64 from the bitwidth. This is
bad for mask vectors like v8i1, since that division is just zero. Besides,
we don't want i64 vectors anyway. For i1 vectors, switch the pattern
to (andnp (not cond), x), which is the canonical form for `kandn`
on mask registers.

Fixes https://github.com/JuliaLang/julia/issues/36955.

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

(cherry picked from commit c58674df147ac0e2777208376bfd2b0d9acbef48)

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx512-select.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 1671917157f4..fd1e6517dfac 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -39588,10 +39588,14 @@ combineVSelectWithAllOnesOrZeros(SDNode *N, 
SelectionDAG &DAG,
 
   // vselect Cond, 000..., X -> andn Cond, X
   if (TValIsAllZeros) {
-MVT AndNVT = MVT::getVectorVT(MVT::i64, CondVT.getSizeInBits() / 64);
-SDValue CastCond = DAG.getBitcast(AndNVT, Cond);
-SDValue CastRHS = DAG.getBitcast(AndNVT, RHS);
-SDValue AndN = DAG.getNode(X86ISD::ANDNP, DL, AndNVT, CastCond, CastRHS);
+SDValue CastRHS = DAG.getBitcast(CondVT, RHS);
+SDValue AndN;
+// The canonical form 
diff ers for i1 vectors - x86andnp is not used
+if (CondVT.getScalarType() == MVT::i1)
+  AndN = DAG.getNode(ISD::AND, DL, CondVT, DAG.getNOT(DL, Cond, CondVT),
+ CastRHS);
+else
+  AndN = DAG.getNode(X86ISD::ANDNP, DL, CondVT, Cond, CastRHS);
 return DAG.getBitcast(VT, AndN);
   }
 

diff  --git a/llvm/test/CodeGen/X86/avx512-select.ll 
b/llvm/test/CodeGen/X86/avx512-select.ll
index 634757ddbf9d..a60f6ee06e73 100644
--- a/llvm/test/CodeGen/X86/avx512-select.ll
+++ b/llvm/test/CodeGen/X86/avx512-select.ll
@@ -705,3 +705,64 @@ define void @select_v1i1(<1 x i1>* %w, <1 x i1>* %x, <1 x 
i1>* %y, i1 %z) nounwi
   store <1 x i1> %c, <1 x i1>* %x
   ret void
 }
+
+; Regression test from https://github.com/JuliaLang/julia/issues/36955
+define i8 @julia_issue36955(<8 x i1> %mask, <8 x double> %a) {
+; X86-AVX512F-LABEL: julia_issue36955:
+; X86-AVX512F:   # %bb.0:
+; X86-AVX512F-NEXT:vpmovsxwq %xmm0, %zmm0
+; X86-AVX512F-NEXT:vpsllq $63, %zmm0, %zmm0
+; X86-AVX512F-NEXT:vxorpd %xmm2, %xmm2, %xmm2
+; X86-AVX512F-NEXT:vcmplepd %zmm2, %zmm1, %k1
+; X86-AVX512F-NEXT:vptestmq %zmm0, %zmm0, %k0 {%k1}
+; X86-AVX512F-NEXT:korw %k0, %k1, %k0
+; X86-AVX512F-NEXT:kmovw %k0, %eax
+; X86-AVX512F-NEXT:# kill: def $al killed $al killed $eax
+; X86-AVX512F-NEXT:vzeroupper
+; X86-AVX512F-NEXT:retl
+;
+; X64-AVX512F-LABEL: julia_issue36955:
+; X64-AVX512F:   # %bb.0:
+; X64-AVX512F-NEXT:vpmovsxwq %xmm0, %zmm0
+; X64-AVX512F-NEXT:vpsllq $63, %zmm0, %zmm0
+; X64-AVX512F-NEXT:vxorpd %xmm2, %xmm2, %xmm2
+; X64-AVX512F-NEXT:vcmplepd %zmm2, %zmm1, %k1
+; X64-AVX512F-NEXT:vptestmq %zmm0, %zmm0, %k0 {%k1}
+; X64-AVX512F-NEXT:korw %k0, %k1, %k0
+; X64-AVX512F-NEXT:kmovw %k0, %eax
+; X64-AVX512F-NEXT:# kill: def $al killed $al killed $eax
+; X64-AVX512F-NEXT:vzeroupper
+; X64-AVX512F-NEXT:retq
+;
+; X86-AVX512BW-LABEL: julia_issue36955:
+; X86-AVX512BW:   # %bb.0:
+; X86-AVX512BW-NEXT:vpsllw $15, %xmm0, %xmm0
+; X86-AVX512BW-NEXT:vpxor %xmm2, %xmm2, %xmm2
+; X86-AVX512BW-NEXT:vxorpd %xmm3, %xmm3, %xmm3
+; X86-AVX512BW-NEXT:vcmplepd %zmm3, %zmm1, %k1
+; X86-AVX512BW-NEXT:vpcmpgtw %zmm0, %zmm2, %k0 {%k1}
+; X86-AVX512BW-NEXT:korw %k0, %k1, %k0
+; X86-AVX512BW-NEXT:kmovd %k0, %eax
+; X86-AVX512BW-NEXT:# kill: def $al killed $al killed $eax
+; X86-AVX512BW-NEXT:vzeroupper
+; X86-AVX512BW-NEXT:retl
+;
+; X64-AVX512BW-LABEL: julia_issue36955:
+; X64-AVX512BW:   # %bb.0:
+; X64-AVX512BW-NEXT:vpsllw $15, %xmm0, %xmm0
+; X64-AVX512BW-NEXT:vpxor %xmm2, %xmm2, %xmm2
+; X64-AVX512BW-NEXT:vxo

[llvm-branch-commits] [llvm] 10ddb92 - [SCEV] Use isa<> pattern for testing for CouldNotCompute [NFC]

2020-11-24 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-11-24T18:47:49-08:00
New Revision: 10ddb927c1c3ee6af0436c23f93fe1da6de7b99a

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

LOG: [SCEV] Use isa<> pattern for testing for CouldNotCompute [NFC]

Some older code - and code copied from older code - still directly tested 
against the singelton result of SE::getCouldNotCompute.  Using the 
isa form is both shorter, and more readable.

Added: 


Modified: 
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Transforms/Scalar/LoopInterchange.cpp
llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp 
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 0bffa7dbddec..78f63c63cb40 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1803,7 +1803,7 @@ bool LoopAccessInfo::canAnalyzeLoop() {
 
   // ScalarEvolution needs to be able to find the exit count.
   const SCEV *ExitCount = PSE->getBackedgeTakenCount();
-  if (ExitCount == PSE->getSE()->getCouldNotCompute()) {
+  if (isa(ExitCount)) {
 recordAnalysis("CantComputeNumberOfIterations")
 << "could not determine number of loop iterations";
 LLVM_DEBUG(dbgs() << "LAA: SCEV could not compute the loop exit count.\n");

diff  --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp 
b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 81b7c3a8338a..f676ffc18e2d 100644
--- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -452,7 +452,7 @@ struct LoopInterchange {
   bool isComputableLoopNest(LoopVector LoopList) {
 for (Loop *L : LoopList) {
   const SCEV *ExitCountOuter = SE->getBackedgeTakenCount(L);
-  if (ExitCountOuter == SE->getCouldNotCompute()) {
+  if (isa(ExitCountOuter)) {
 LLVM_DEBUG(dbgs() << "Couldn't compute backedge count\n");
 return false;
   }

diff  --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp 
b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
index 3d0ce87047ad..2ff1e8480749 100644
--- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
@@ -267,7 +267,7 @@ bool LoopVersioningLICM::legalLoopStructure() {
   // We need to be able to compute the loop trip count in order
   // to generate the bound checks.
   const SCEV *ExitCount = SE->getBackedgeTakenCount(CurLoop);
-  if (ExitCount == SE->getCouldNotCompute()) {
+  if (isa(ExitCount)) {
 LLVM_DEBUG(dbgs() << "loop does not has trip count\n");
 return false;
   }

diff  --git a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp 
b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
index 4553b23532f2..ca114581a515 100644
--- a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
+++ b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
@@ -243,7 +243,7 @@ static bool mustBeFiniteCountedLoop(Loop *L, 
ScalarEvolution *SE,
 BasicBlock *Pred) {
   // A conservative bound on the loop as a whole.
   const SCEV *MaxTrips = SE->getConstantMaxBackedgeTakenCount(L);
-  if (MaxTrips != SE->getCouldNotCompute() &&
+  if (!isa(MaxTrips) &&
   SE->getUnsignedRange(MaxTrips).getUnsignedMax().isIntN(
   CountedLoopTripWidth))
 return true;
@@ -255,7 +255,7 @@ static bool mustBeFiniteCountedLoop(Loop *L, 
ScalarEvolution *SE,
 // This returns an exact expression only.  TODO: We really only need an
 // upper bound here, but SE doesn't expose that.
 const SCEV *MaxExec = SE->getExitCount(L, Pred);
-if (MaxExec != SE->getCouldNotCompute() &&
+if (!isa(MaxExec) &&
 SE->getUnsignedRange(MaxExec).getUnsignedMax().isIntN(
 CountedLoopTripWidth))
 return true;

diff  --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp 
b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 877495be2dcd..c7e37fe0d1b3 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2468,7 +2468,7 @@ Value *SCEVExpander::generateOverflowCheck(const 
SCEVAddRecExpr *AR,
   const SCEV *ExitCount =
   SE.getPredicatedBackedgeTakenCount(AR->getLoop(), Pred);
 
-  assert(ExitCount != SE.getCouldNotCompute() && "Invalid loop count");
+  assert(!isa(ExitCount) && "Invalid loop count");
 
   const SCEV *Step = AR->getStepRecurrence(SE);
   const SCEV *Start = AR->getStart();

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index af314ae4b27b..e29a0a8b

[llvm-branch-commits] [clang] e0f4dea - Don't assume the clang binary name contains the string "clang".

2020-11-24 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-11-24T18:52:46-08:00
New Revision: e0f4dea0d0f1766eef1591d77b5673ce264e8fff

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

LOG: Don't assume the clang binary name contains the string "clang".

Also ensure the -cc1 argument is actually part of the clang -cc1 command
line rather than some unrelated command line.

Added: 


Modified: 
clang/test/Driver/aix-vec-extabi.c

Removed: 




diff  --git a/clang/test/Driver/aix-vec-extabi.c 
b/clang/test/Driver/aix-vec-extabi.c
index d5e4548c87fa..ccc3b0732e4b 100644
--- a/clang/test/Driver/aix-vec-extabi.c
+++ b/clang/test/Driver/aix-vec-extabi.c
@@ -1,8 +1,8 @@
 // RUN:  %clang -### -target powerpc-unknown-aix -S -maltivec -mabi=vec-extabi 
%s 2>&1 | \
 // RUN:  FileCheck %s
 
-// CHECK: {{.*}}clang{{.*}}" "-cc1"
-// CHECK: "-mabi=vec-extabi"
+// CHECK: "-cc1"
+// CHECK-SAME: "-mabi=vec-extabi"
 
 // RUN:  %clang -### -target powerpc-unknown-aix -S -maltivec 
-mabi=vec-default %s 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=ERROR



___
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] a1e0363 - Fix limit behavior of dynamic alloca

2020-11-24 Thread Tom Stellard via llvm-branch-commits

Author: serge-sans-paille
Date: 2020-11-24T21:57:55-05:00
New Revision: a1e0363c7402f7aa58e24e0e6dfa447ebabc1910

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

LOG: Fix limit behavior of dynamic alloca

When the allocation size is 0, we shouldn't probe. Within [1,  PAGE_SIZE], we
should probe once etc.

This fixes https://bugs.llvm.org/show_bug.cgi?id=47657

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

(cherry picked from commit 9573c9f2a363da71b2c07a3add4e52721e6028a0)

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index fd1e6517dfac..f68ae4461fe3 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -31876,7 +31876,7 @@ X86TargetLowering::EmitLoweredProbedAlloca(MachineInstr 
&MI,
 
   BuildMI(testMBB, DL, TII->get(X86::JCC_1))
   .addMBB(tailMBB)
-  .addImm(X86::COND_L);
+  .addImm(X86::COND_LE);
   testMBB->addSuccessor(blockMBB);
   testMBB->addSuccessor(tailMBB);
 

diff  --git a/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll 
b/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
index bc4678564083..82fd67842c8a 100644
--- a/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
+++ b/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
@@ -24,12 +24,12 @@ attributes #0 =  {"probe-stack"="inline-asm"}
 ; CHECK-X86-64-NEXT:   andq$-16, %rcx
 ; CHECK-X86-64-NEXT:   subq%rcx, %rax
 ; CHECK-X86-64-NEXT:   cmpq%rsp, %rax
-; CHECK-X86-64-NEXT:   jl  .LBB0_3
+; CHECK-X86-64-NEXT:   jle .LBB0_3
 ; CHECK-X86-64-NEXT:  .LBB0_2: # =>This Inner Loop Header: Depth=1
 ; CHECK-X86-64-NEXT:   movq$0, (%rsp)
 ; CHECK-X86-64-NEXT:   subq$4096, %rsp # imm = 0x1000
 ; CHECK-X86-64-NEXT:   cmpq%rsp, %rax
-; CHECK-X86-64-NEXT:   jge .LBB0_2
+; CHECK-X86-64-NEXT:   jg  .LBB0_2
 ; CHECK-X86-64-NEXT:  .LBB0_3:
 ; CHECK-X86-64-NEXT:   movq%rax, %rsp
 ; CHECK-X86-64-NEXT:   movl$1, 4792(%rax)
@@ -54,12 +54,12 @@ attributes #0 =  {"probe-stack"="inline-asm"}
 ; CHECK-X86-32-NEXT:andl$-16, %ecx
 ; CHECK-X86-32-NEXT:subl%ecx, %eax
 ; CHECK-X86-32-NEXT:cmpl%esp, %eax
-; CHECK-X86-32-NEXT:jl  .LBB0_3
+; CHECK-X86-32-NEXT:jle  .LBB0_3
 ; CHECK-X86-32-NEXT:  .LBB0_2: # =>This Inner Loop Header: Depth=1
 ; CHECK-X86-32-NEXT:movl$0, (%esp)
 ; CHECK-X86-32-NEXT:subl$4096, %esp # imm = 0x1000
 ; CHECK-X86-32-NEXT:cmpl%esp, %eax
-; CHECK-X86-32-NEXT:jge .LBB0_2
+; CHECK-X86-32-NEXT:jg .LBB0_2
 ; CHECK-X86-32-NEXT:  .LBB0_3:
 ; CHECK-X86-32-NEXT:movl%eax, %esp
 ; CHECK-X86-32-NEXT:movl$1, 4792(%eax)



___
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] aac3668 - Fix interaction between stack alignment and inline-asm stack clash protection

2020-11-24 Thread Tom Stellard via llvm-branch-commits

Author: serge-sans-paille
Date: 2020-11-24T21:57:55-05:00
New Revision: aac36687f7978f33751daf2870b5c812124ebfaf

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

LOG: Fix interaction between stack alignment and inline-asm stack clash 
protection

As reported in https://github.com/rust-lang/rust/issues/70143 alignment is not
taken into account when doing the probing. Fix that by adjusting the first probe
if the stack align is small, or by extending the dynamic probing if the
alignment is large.

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

(cherry picked from commit f2c6bfa350de142e4d63808d03335f69bd136d6a)

Added: 
llvm/test/CodeGen/X86/stack-clash-large-large-align.ll
llvm/test/CodeGen/X86/stack-clash-small-alloc-medium-align.ll
llvm/test/CodeGen/X86/stack-clash-small-large-align.ll

Modified: 
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86FrameLowering.h

Removed: 
llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll



diff  --git a/llvm/lib/Target/X86/X86FrameLowering.cpp 
b/llvm/lib/Target/X86/X86FrameLowering.cpp
index c7ca6fb2a4fc..db6b68659493 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -586,29 +586,55 @@ void X86FrameLowering::emitStackProbeInlineGeneric(
   const uint64_t StackProbeSize = TLI.getStackProbeSize(MF);
   uint64_t ProbeChunk = StackProbeSize * 8;
 
+  uint64_t MaxAlign =
+  TRI->needsStackRealignment(MF) ? calculateMaxStackAlign(MF) : 0;
+
   // Synthesize a loop or unroll it, depending on the number of iterations.
+  // BuildStackAlignAND ensures that only MaxAlign % StackProbeSize bits left
+  // between the unaligned rsp and current rsp.
   if (Offset > ProbeChunk) {
-emitStackProbeInlineGenericLoop(MF, MBB, MBBI, DL, Offset);
+emitStackProbeInlineGenericLoop(MF, MBB, MBBI, DL, Offset,
+MaxAlign % StackProbeSize);
   } else {
-emitStackProbeInlineGenericBlock(MF, MBB, MBBI, DL, Offset);
+emitStackProbeInlineGenericBlock(MF, MBB, MBBI, DL, Offset,
+ MaxAlign % StackProbeSize);
   }
 }
 
 void X86FrameLowering::emitStackProbeInlineGenericBlock(
 MachineFunction &MF, MachineBasicBlock &MBB,
-MachineBasicBlock::iterator MBBI, const DebugLoc &DL,
-uint64_t Offset) const {
+MachineBasicBlock::iterator MBBI, const DebugLoc &DL, uint64_t Offset,
+uint64_t AlignOffset) const {
 
   const X86Subtarget &STI = MF.getSubtarget();
   const X86TargetLowering &TLI = *STI.getTargetLowering();
   const unsigned Opc = getSUBriOpcode(Uses64BitFramePtr, Offset);
   const unsigned MovMIOpc = Is64Bit ? X86::MOV64mi32 : X86::MOV32mi;
   const uint64_t StackProbeSize = TLI.getStackProbeSize(MF);
+
   uint64_t CurrentOffset = 0;
-  // 0 Thanks to return address being saved on the stack
-  uint64_t CurrentProbeOffset = 0;
 
-  // For the first N - 1 pages, just probe. I tried to take advantage of
+  assert(AlignOffset < StackProbeSize);
+
+  // If the offset is so small it fits within a page, there's nothing to do.
+  if (StackProbeSize < Offset + AlignOffset) {
+
+MachineInstr *MI = BuildMI(MBB, MBBI, DL, TII.get(Opc), StackPtr)
+   .addReg(StackPtr)
+   .addImm(StackProbeSize - AlignOffset)
+   .setMIFlag(MachineInstr::FrameSetup);
+MI->getOperand(3).setIsDead(); // The EFLAGS implicit def is dead.
+
+addRegOffset(BuildMI(MBB, MBBI, DL, TII.get(MovMIOpc))
+ .setMIFlag(MachineInstr::FrameSetup),
+ StackPtr, false, 0)
+.addImm(0)
+.setMIFlag(MachineInstr::FrameSetup);
+NumFrameExtraProbe++;
+CurrentOffset = StackProbeSize - AlignOffset;
+  }
+
+  // For the next N - 1 pages, just probe. I tried to take advantage of
   // natural probes but it implies much more logic and there was very few
   // interesting natural probes to interleave.
   while (CurrentOffset + StackProbeSize < Offset) {
@@ -626,9 +652,9 @@ void X86FrameLowering::emitStackProbeInlineGenericBlock(
 .setMIFlag(MachineInstr::FrameSetup);
 NumFrameExtraProbe++;
 CurrentOffset += StackProbeSize;
-CurrentProbeOffset += StackProbeSize;
   }
 
+  // No need to probe the tail, it is smaller than a Page.
   uint64_t ChunkSize = Offset - CurrentOffset;
   MachineInstr *MI = BuildMI(MBB, MBBI, DL, TII.get(Opc), StackPtr)
  .addReg(StackPtr)
@@ -639,8 +665,8 @@ void X86FrameLowering::emitStackProbeInlineGenericBlock(
 
 void X86FrameLowering::emitStackProbeInlineGenericLoop(
 MachineFunction &MF, MachineBasicBlock &MBB,
-MachineBasicBlock::iterator MBBI, const DebugLoc &DL,
-uint64_t Offset) const {
+MachineBasicBloc

[llvm-branch-commits] [llvm] bbe6cbb - [stack-clash] Fix probing of dynamic alloca

2020-11-24 Thread Tom Stellard via llvm-branch-commits

Author: serge-sans-paille
Date: 2020-11-24T21:57:55-05:00
New Revision: bbe6cbbed8c7460a7e8477373b9250543362e771

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

LOG: [stack-clash] Fix probing of dynamic alloca

- Perform the probing in the correct direction.
  Related to https://github.com/rust-lang/rust/pull/77885#issuecomment-711062924

- The first touch on a dynamic alloca cannot use a mov because it clobbers
  existing space. Use a xor 0 instead

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

(cherry picked from commit 0f60bcc36c34522618bd1425a45f8c6006568fb6)

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
llvm/test/CodeGen/X86/stack-clash-small-alloc-medium-align.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f68ae4461fe3..afe470cc6e0b 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -31876,7 +31876,7 @@ X86TargetLowering::EmitLoweredProbedAlloca(MachineInstr 
&MI,
 
   BuildMI(testMBB, DL, TII->get(X86::JCC_1))
   .addMBB(tailMBB)
-  .addImm(X86::COND_LE);
+  .addImm(X86::COND_GE);
   testMBB->addSuccessor(blockMBB);
   testMBB->addSuccessor(tailMBB);
 
@@ -31892,9 +31892,9 @@ X86TargetLowering::EmitLoweredProbedAlloca(MachineInstr 
&MI,
   //
   // The property we want to enforce is to never have more than [page alloc] 
between two probes.
 
-  const unsigned MovMIOpc =
-  TFI.Uses64BitFramePtr ? X86::MOV64mi32 : X86::MOV32mi;
-  addRegOffset(BuildMI(blockMBB, DL, TII->get(MovMIOpc)), physSPReg, false, 0)
+  const unsigned XORMIOpc =
+  TFI.Uses64BitFramePtr ? X86::XOR64mi8 : X86::XOR32mi8;
+  addRegOffset(BuildMI(blockMBB, DL, TII->get(XORMIOpc)), physSPReg, false, 0)
   .addImm(0);
 
   BuildMI(blockMBB, DL,

diff  --git a/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll 
b/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
index 82fd67842c8a..6dd8b6ab5897 100644
--- a/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
+++ b/llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
@@ -24,12 +24,12 @@ attributes #0 =  {"probe-stack"="inline-asm"}
 ; CHECK-X86-64-NEXT:   andq$-16, %rcx
 ; CHECK-X86-64-NEXT:   subq%rcx, %rax
 ; CHECK-X86-64-NEXT:   cmpq%rsp, %rax
-; CHECK-X86-64-NEXT:   jle .LBB0_3
+; CHECK-X86-64-NEXT:   jge .LBB0_3
 ; CHECK-X86-64-NEXT:  .LBB0_2: # =>This Inner Loop Header: Depth=1
-; CHECK-X86-64-NEXT:   movq$0, (%rsp)
+; CHECK-X86-64-NEXT:   xorq$0, (%rsp)
 ; CHECK-X86-64-NEXT:   subq$4096, %rsp # imm = 0x1000
 ; CHECK-X86-64-NEXT:   cmpq%rsp, %rax
-; CHECK-X86-64-NEXT:   jg  .LBB0_2
+; CHECK-X86-64-NEXT:   jl  .LBB0_2
 ; CHECK-X86-64-NEXT:  .LBB0_3:
 ; CHECK-X86-64-NEXT:   movq%rax, %rsp
 ; CHECK-X86-64-NEXT:   movl$1, 4792(%rax)
@@ -54,12 +54,12 @@ attributes #0 =  {"probe-stack"="inline-asm"}
 ; CHECK-X86-32-NEXT:andl$-16, %ecx
 ; CHECK-X86-32-NEXT:subl%ecx, %eax
 ; CHECK-X86-32-NEXT:cmpl%esp, %eax
-; CHECK-X86-32-NEXT:jle  .LBB0_3
+; CHECK-X86-32-NEXT:jge  .LBB0_3
 ; CHECK-X86-32-NEXT:  .LBB0_2: # =>This Inner Loop Header: Depth=1
-; CHECK-X86-32-NEXT:movl$0, (%esp)
+; CHECK-X86-32-NEXT:xorl$0, (%esp)
 ; CHECK-X86-32-NEXT:subl$4096, %esp # imm = 0x1000
 ; CHECK-X86-32-NEXT:cmpl%esp, %eax
-; CHECK-X86-32-NEXT:jg .LBB0_2
+; CHECK-X86-32-NEXT:jl .LBB0_2
 ; CHECK-X86-32-NEXT:  .LBB0_3:
 ; CHECK-X86-32-NEXT:movl%eax, %esp
 ; CHECK-X86-32-NEXT:movl$1, 4792(%eax)

diff  --git a/llvm/test/CodeGen/X86/stack-clash-small-alloc-medium-align.ll 
b/llvm/test/CodeGen/X86/stack-clash-small-alloc-medium-align.ll
index eafa86f1eba9..39b6c3640a60 100644
--- a/llvm/test/CodeGen/X86/stack-clash-small-alloc-medium-align.ll
+++ b/llvm/test/CodeGen/X86/stack-clash-small-alloc-medium-align.ll
@@ -106,12 +106,12 @@ define i32 @foo4(i64 %i) local_unnamed_addr #0 {
 ; CHECK-NEXT:  andq$-16, %rcx
 ; CHECK-NEXT:  subq%rcx, %rax
 ; CHECK-NEXT:  cmpq%rsp, %rax
-; CHECK-NEXT:  jle .LBB3_3
+; CHECK-NEXT:  jge .LBB3_3
 ; CHECK-NEXT:.LBB3_2:# =>This Inner Loop 
Header: Depth=1
-; CHECK-NEXT:  movq$0, (%rsp)
+; CHECK-NEXT:  xorq$0, (%rsp)
 ; CHECK-NEXT:  subq$4096, %rsp # imm = 0x1000
 ; CHECK-NEXT:  cmpq%rsp, %rax
-; CHECK-NEXT:  jg  .LBB3_2
+; CHECK-NEXT:  jl  .LBB3_2
 ; CHECK-NEXT:.LBB3_3:
 ; CHECK-NEXT:  andq$-64, %rax
 ; CHECK-NEXT:  movq%rax, %rsp



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

[llvm-branch-commits] [llvm] 60c28a5 - [NFC][Test] Format the test for IEEE Long double

2020-11-24 Thread QingShan Zhang via llvm-branch-commits

Author: QingShan Zhang
Date: 2020-11-25T03:00:24Z
New Revision: 60c28a5a2b76ebf9c8bac9ebf20ac8fe69c788ee

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

LOG: [NFC][Test] Format the test for IEEE Long double

Added: 


Modified: 
llvm/test/CodeGen/PowerPC/fp-to-int-to-fp.ll
llvm/test/CodeGen/PowerPC/store_fptoi.ll

Removed: 




diff  --git a/llvm/test/CodeGen/PowerPC/fp-to-int-to-fp.ll 
b/llvm/test/CodeGen/PowerPC/fp-to-int-to-fp.ll
index ffc626be2dea..26832efb3f4c 100644
--- a/llvm/test/CodeGen/PowerPC/fp-to-int-to-fp.ll
+++ b/llvm/test/CodeGen/PowerPC/fp-to-int-to-fp.ll
@@ -1,65 +1,197 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mcpu=a2 < %s | FileCheck %s 
-check-prefix=FPCVT
 ; RUN: llc -verify-machineinstrs -mcpu=ppc64 < %s | FileCheck %s 
-check-prefix=PPC64
+; RUN: llc -verify-machineinstrs -mcpu=pwr9 < %s | FileCheck %s 
-check-prefix=PWR9
 target datalayout = "E-m:e-i64:64-n32:64"
 target triple = "powerpc64-unknown-linux-gnu"
 
 ; Function Attrs: nounwind readnone
 define float @fool(float %X) #0 {
+; FPCVT-LABEL: fool:
+; FPCVT:   # %bb.0: # %entry
+; FPCVT-NEXT:friz 1, 1
+; FPCVT-NEXT:blr
+;
+; PPC64-LABEL: fool:
+; PPC64:   # %bb.0: # %entry
+; PPC64-NEXT:fctidz 0, 1
+; PPC64-NEXT:fcfid 0, 0
+; PPC64-NEXT:frsp 1, 0
+; PPC64-NEXT:blr
+;
+; PWR9-LABEL: fool:
+; PWR9:   # %bb.0: # %entry
+; PWR9-NEXT:xsrdpiz 1, 1
+; PWR9-NEXT:blr
 entry:
   %conv = fptosi float %X to i64
   %conv1 = sitofp i64 %conv to float
   ret float %conv1
 
-; FPCVT-LABEL: @fool
-; FPCVT: friz 1, 1
-; FPCVT: blr
 
-; PPC64-LABEL: @fool
-; PPC64: fctidz [[REG1:[0-9]+]], 1
-; PPC64: fcfid [[REG2:[0-9]+]], [[REG1]]
-; PPC64: frsp 1, [[REG2]]
-; PPC64: blr
 }
 
 ; Function Attrs: nounwind readnone
 define double @foodl(double %X) #0 {
+; FPCVT-LABEL: foodl:
+; FPCVT:   # %bb.0: # %entry
+; FPCVT-NEXT:friz 1, 1
+; FPCVT-NEXT:blr
+;
+; PPC64-LABEL: foodl:
+; PPC64:   # %bb.0: # %entry
+; PPC64-NEXT:fctidz 0, 1
+; PPC64-NEXT:fcfid 1, 0
+; PPC64-NEXT:blr
+;
+; PWR9-LABEL: foodl:
+; PWR9:   # %bb.0: # %entry
+; PWR9-NEXT:xsrdpiz 1, 1
+; PWR9-NEXT:blr
 entry:
   %conv = fptosi double %X to i64
   %conv1 = sitofp i64 %conv to double
   ret double %conv1
 
-; FPCVT-LABEL: @foodl
-; FPCVT: friz 1, 1
-; FPCVT: blr
 
-; PPC64-LABEL: @foodl
-; PPC64: fctidz [[REG1:[0-9]+]], 1
-; PPC64: fcfid 1, [[REG1]]
-; PPC64: blr
 }
 
 ; Function Attrs: nounwind readnone
 define float @fooul(float %X) #0 {
+; FPCVT-LABEL: fooul:
+; FPCVT:   # %bb.0: # %entry
+; FPCVT-NEXT:friz 1, 1
+; FPCVT-NEXT:blr
+;
+; PPC64-LABEL: fooul:
+; PPC64:   # %bb.0: # %entry
+; PPC64-NEXT:addis 3, 2, .LCPI2_0@toc@ha
+; PPC64-NEXT:li 4, 1
+; PPC64-NEXT:lfs 0, .LCPI2_0@toc@l(3)
+; PPC64-NEXT:sldi 4, 4, 63
+; PPC64-NEXT:fsubs 2, 1, 0
+; PPC64-NEXT:fcmpu 0, 1, 0
+; PPC64-NEXT:fctidz 2, 2
+; PPC64-NEXT:stfd 2, -8(1)
+; PPC64-NEXT:fctidz 2, 1
+; PPC64-NEXT:stfd 2, -16(1)
+; PPC64-NEXT:ld 3, -8(1)
+; PPC64-NEXT:ld 5, -16(1)
+; PPC64-NEXT:xor 3, 3, 4
+; PPC64-NEXT:bc 12, 0, .LBB2_1
+; PPC64-NEXT:b .LBB2_2
+; PPC64-NEXT:  .LBB2_1: # %entry
+; PPC64-NEXT:addi 3, 5, 0
+; PPC64-NEXT:  .LBB2_2: # %entry
+; PPC64-NEXT:sradi 4, 3, 53
+; PPC64-NEXT:clrldi 5, 3, 63
+; PPC64-NEXT:addi 4, 4, 1
+; PPC64-NEXT:cmpldi 4, 1
+; PPC64-NEXT:rldicl 4, 3, 63, 1
+; PPC64-NEXT:or 5, 5, 4
+; PPC64-NEXT:rldicl 6, 5, 11, 53
+; PPC64-NEXT:addi 6, 6, 1
+; PPC64-NEXT:clrldi 7, 5, 53
+; PPC64-NEXT:cmpldi 1, 6, 1
+; PPC64-NEXT:clrldi 6, 3, 53
+; PPC64-NEXT:addi 7, 7, 2047
+; PPC64-NEXT:addi 6, 6, 2047
+; PPC64-NEXT:or 4, 7, 4
+; PPC64-NEXT:or 6, 6, 3
+; PPC64-NEXT:rldicl 4, 4, 53, 11
+; PPC64-NEXT:rldicr 6, 6, 0, 52
+; PPC64-NEXT:bc 12, 1, .LBB2_4
+; PPC64-NEXT:  # %bb.3: # %entry
+; PPC64-NEXT:ori 6, 3, 0
+; PPC64-NEXT:b .LBB2_4
+; PPC64-NEXT:  .LBB2_4: # %entry
+; PPC64-NEXT:rldicl 4, 4, 11, 1
+; PPC64-NEXT:cmpdi 3, 0
+; PPC64-NEXT:std 6, -32(1)
+; PPC64-NEXT:bc 12, 5, .LBB2_6
+; PPC64-NEXT:  # %bb.5: # %entry
+; PPC64-NEXT:ori 4, 5, 0
+; PPC64-NEXT:b .LBB2_6
+; PPC64-NEXT:  .LBB2_6: # %entry
+; PPC64-NEXT:std 4, -24(1)
+; PPC64-NEXT:bc 12, 0, .LBB2_8
+; PPC64-NEXT:  # %bb.7: # %entry
+; PPC64-NEXT:lfd 0, -32(1)
+; PPC64-NEXT:fcfid 0, 0
+; PPC64-NEXT:frsp 1, 0
+; PPC64-NEXT:blr
+; PPC64-NEXT:  .LBB2_8:
+; PPC64-NEXT:lfd 0, -24(1)
+; PPC64-NEXT:fcfid 0, 0
+; PPC64-NEXT:frsp 0, 0
+; PPC64-NEXT:fadds 1, 0, 0
+; PPC64-NEXT:blr
+;
+; PWR9-LABEL: fooul:
+; PWR9:   # %bb.0: # %entry
+; PWR9-NEXT:

[llvm-branch-commits] [clang] a9eaf84 - Try to fix tests after e16c0a9a68971 with CLANG_DEFAULT_LINKER=lld

2020-11-24 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-24T22:34:12-05:00
New Revision: a9eaf8435d9204f5d71a08cfd7c574e92d434871

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

LOG: Try to fix tests after e16c0a9a68971 with CLANG_DEFAULT_LINKER=lld

Tests that pass -mlinker-version=old version and that then don't
expect new flags to be passed need to explicitly request the system
linker now.

Added: 


Modified: 
clang/test/Driver/darwin-ld-platform-version-ios.c
clang/test/Driver/darwin-ld-platform-version-macos.c
clang/test/Driver/darwin-ld-platform-version-tvos.c
clang/test/Driver/darwin-ld-platform-version-watchos.c
clang/test/Driver/darwin-ld.c

Removed: 




diff  --git a/clang/test/Driver/darwin-ld-platform-version-ios.c 
b/clang/test/Driver/darwin-ld-platform-version-ios.c
index 28e9dceb84413..d03e46b5776de 100644
--- a/clang/test/Driver/darwin-ld-platform-version-ios.c
+++ b/clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -1,14 +1,14 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-ios12.3 \
+// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64-apple-ios12.3 \
+// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64-apple-ios12.3 \
+// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
@@ -16,7 +16,7 @@
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW  %s
-// RUN: %clang -target x86_64-apple-ios13-simulator \
+// RUN: %clang -target x86_64-apple-ios13-simulator -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s

diff  --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index 97df44d3bb0fd..1954deea7b93d 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,6 +1,6 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target x86_64-apple-macos10.13 \
+// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
@@ -8,7 +8,7 @@
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
-// RUN: %clang -target x86_64-apple-macos10.13 \
+// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
@@ -17,7 +17,7 @@
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 
-// RUN: %clang -target arm64-apple-macos10.13 \
+// RUN: %clang -target arm64-apple-macos10.13 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_OLD %s
@@ -25,15 +25,15 @@
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_NEW %s
-// RUN: %clang -target arm64-apple-macos10.13 \
+// RUN: %clang -target arm64-apple-macos10.13 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_NEW %s
-// RUN: %clang -target arm64-apple-darwin19 \
+// RUN: %clang -target arm64-apple-darwin19 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_NEW %s
-// RUN: %clang -target arm64-apple-macos11.1 \
+// RUN: %clang -target arm64-apple-macos11.1 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_NEW_1 %s

diff  --git a/clang/test/Driver/darwin-ld-platform-version-tvos.c 
b/clang/test/Driver/darwin-ld-platform-version-tvos.c
index f11fde349fa7f..beaa46b32f6f2 100644
--- a/clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ b/clang/test/Driver/d

[llvm-branch-commits] [llvm] be7d425 - [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

2020-11-24 Thread Zarko Todorovski via llvm-branch-commits

Author: Zarko Todorovski
Date: 2020-11-24T23:01:51-05:00
New Revision: be7d425edc64714564a079657ed4230e39c2cc90

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

LOG: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

This patch is the initial patch for support of the AIX extended vector ABI.  
The extended ABI treats vector registers V20-V31 as non-volatile and we add 
them as callee saved registers in this patch.

Reviewed By: sfertile

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

Added: 
llvm/test/CodeGen/PowerPC/aix-csr-vector.ll

Modified: 
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/Target/PowerPC/PPCCallingConv.td
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll
llvm/test/CodeGen/PowerPC/aix-func-align.ll
llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll
llvm/test/CodeGen/PowerPC/aix-internal.ll
llvm/test/CodeGen/PowerPC/aix-lower-block-address.ll
llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
llvm/test/CodeGen/PowerPC/aix-return55.ll
llvm/test/CodeGen/PowerPC/aix-space.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-explicit-section.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-reloc-large.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-textdisassembly.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
llvm/test/CodeGen/PowerPC/aix32-crsave.mir
llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
llvm/test/CodeGen/PowerPC/ppc64-crsave.mir

Removed: 




diff  --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 3b41b97e0c89..14ec0a37b3fe 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -243,6 +243,10 @@ class TargetMachine {
 Options.SupportsDebugEntryValues = Enable;
   }
 
+  bool getAIXExtendedAltivecABI() const {
+return Options.EnableAIXExtendedAltivecABI;
+  }
+
   bool getUniqueSectionNames() const { return Options.UniqueSectionNames; }
 
   /// Return true if unique basic block section names must be generated.

diff  --git a/llvm/lib/Target/PowerPC/PPCCallingConv.td 
b/llvm/lib/Target/PowerPC/PPCCallingConv.td
index 64de7353c516..cc3486718179 100644
--- a/llvm/lib/Target/PowerPC/PPCCallingConv.td
+++ b/llvm/lib/Target/PowerPC/PPCCallingConv.td
@@ -291,6 +291,8 @@ def CSR_AIX32 : CalleeSavedRegs<(add R13, R14, R15, R16, 
R17, R18, R19, R20,
  F27, F28, F29, F30, F31, CR2, CR3, CR4
 )>;
 
+def CSR_AIX32_Altivec : CalleeSavedRegs<(add CSR_AIX32, CSR_Altivec)>;
+
 // Common CalleeSavedRegs for SVR4 and AIX.
 def CSR_PPC64   : CalleeSavedRegs<(add X14, X15, X16, X17, X18, X19, X20,
 X21, X22, X23, X24, X25, X26, X27, X28,

diff  --git a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
index 6f1fe4e113bd..95bcace21f81 100644
--- a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
@@ -218,19 +218,14 @@ const PPCFrameLowering::SpillSlot 
*PPCFrameLowering::getCalleeSavedSpillSlots(
   CALLEE_SAVED_VRS
   };
 
-  static const SpillSlot AIXOffsets32[] = {
-  CALLEE_SAVED_FPRS,
-  CALLEE_SAVED_GPRS32,
-  // Add AIX's extra CSR.
-  {PPC::R13, -76},
-  // TODO: Update when we add vector support for AIX.
-  };
+  static const SpillSlot AIXOffsets32[] = {CALLEE_SAVED_FPRS,
+   CALLEE_SAVED_GPRS32,
+   // Add AIX's extra CSR.
+   {PPC::R13, -76},
+   CALLEE_SAVED_VRS};
 
   static const SpillSlot AIXOffsets64[] = {
-  CALLEE_SAVED_FPRS,
-  CALLEE_SAVED_GPRS64,
-  // TODO: Update when we add vector support for AIX.
-  };
+  CALLEE_SAVED_FPRS, CALLEE_SAVED_GPRS64, CALLEE_SAVED_VRS};
 
   if (Subtarget.is64BitELFABI()) {
 NumEntries = array_lengthof(ELFOffsets64);

diff  --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 7dd495c1f0f8..9ff6bdd6e51c 100644
--- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo

[llvm-branch-commits] [llvm] 8e6d920 - [DAG][PowerPC] Fix dropped `nsw` flag in `SimplifySetCC` by adding `doesNodeExist` helper

2020-11-24 Thread Kai Luo via llvm-branch-commits

Author: Kai Luo
Date: 2020-11-25T04:39:03Z
New Revision: 8e6d92026c624386b85675a4664e2666225fcfac

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

LOG: [DAG][PowerPC] Fix dropped `nsw` flag in `SimplifySetCC` by adding 
`doesNodeExist` helper

`SimplifySetCC` invokes `getNodeIfExists` without passing `Flags` argument and 
`getNodeIfExists` uses a default `SDNodeFlags` to intersect the original flags, 
as a consequence, flags like `nsw` is dropped. Added a new helper function 
`doesNodeExist` to check if a node exists without modifying its flags.

Reviewed By: #powerpc, nemanjai

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/PowerPC/setcc-sub-flag.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/SelectionDAG.h 
b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 8966e7f51dd9..cbd2e8b043a0 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1520,6 +1520,9 @@ class SelectionDAG {
   SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList,
   ArrayRef Ops);
 
+  /// Check if a node exists without modifying its flags.
+  bool doesNodeExist(unsigned Opcode, SDVTList VTList, ArrayRef Ops);
+
   /// Creates a SDDbgValue node.
   SDDbgValue *getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N,
   unsigned R, bool IsIndirect, const DebugLoc &DL,

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 489651e987ac..eee80cc4bc70 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -8326,6 +8326,19 @@ SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, 
SDVTList VTList,
   return nullptr;
 }
 
+/// doesNodeExist - Check if a node exists without modifying its flags.
+bool SelectionDAG::doesNodeExist(unsigned Opcode, SDVTList VTList,
+ ArrayRef Ops) {
+  if (VTList.VTs[VTList.NumVTs - 1] != MVT::Glue) {
+FoldingSetNodeID ID;
+AddNodeIDNode(ID, Opcode, VTList, Ops);
+void *IP = nullptr;
+if (FindNodeOrInsertPos(ID, SDLoc(), IP))
+  return true;
+  }
+  return false;
+}
+
 /// getDbgValue - Creates a SDDbgValue node.
 ///
 /// SDNode

diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 1d51773dc2d8..93df88b3f6d7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -3476,8 +3476,8 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, 
SDValue N1,
   if (!isConstOrConstSplat(N0) && !isConstOrConstSplat(N1) &&
   (DCI.isBeforeLegalizeOps() ||
isCondCodeLegal(SwappedCC, N0.getSimpleValueType())) &&
-  DAG.getNodeIfExists(ISD::SUB, DAG.getVTList(OpVT), { N1, N0 } ) &&
-  !DAG.getNodeIfExists(ISD::SUB, DAG.getVTList(OpVT), { N0, N1 } ))
+  DAG.doesNodeExist(ISD::SUB, DAG.getVTList(OpVT), {N1, N0}) &&
+  !DAG.doesNodeExist(ISD::SUB, DAG.getVTList(OpVT), {N0, N1}))
 return DAG.getSetCC(dl, VT, N1, N0, SwappedCC);
 
   if (auto *N1C = isConstOrConstSplat(N1)) {

diff  --git a/llvm/test/CodeGen/PowerPC/setcc-sub-flag.ll 
b/llvm/test/CodeGen/PowerPC/setcc-sub-flag.ll
index ee4697b874e2..3d89fea12216 100644
--- a/llvm/test/CodeGen/PowerPC/setcc-sub-flag.ll
+++ b/llvm/test/CodeGen/PowerPC/setcc-sub-flag.ll
@@ -10,7 +10,7 @@ define void @f(i64 %a, i64 %b) {
   ; CHECK:   liveins: $x3, $x4
   ; CHECK:   [[COPY:%[0-9]+]]:g8rc = COPY $x4
   ; CHECK:   [[COPY1:%[0-9]+]]:g8rc = COPY $x3
-  ; CHECK:   [[SUBF8_:%[0-9]+]]:g8rc = SUBF8 [[COPY1]], [[COPY]]
+  ; CHECK:   [[SUBF8_:%[0-9]+]]:g8rc = nsw SUBF8 [[COPY1]], [[COPY]]
   %c = sub nsw i64 %b, %a
   call void @foo(i64 %c)
   %d = icmp slt i64 %a, %b



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


[llvm-branch-commits] [llvm] 28d7ba1 - [IndVars] Use more precise context when eliminating narrowing

2020-11-24 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2020-11-25T11:47:39+07:00
New Revision: 28d7ba15435f055562d18ee7111db4adbaf28fae

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

LOG: [IndVars] Use more precise context when eliminating narrowing

When deciding to widen narrow use, we may need to prove some facts
about it. For proof, the context is used. Currently we take the instruction
being widened as the context.

However, we may be more precise here if we take as context the point that
dominates all users of instruction being widened.

Differential Revision: https://reviews.llvm.org/D90456
Reviewed By: skatkov

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp 
b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 2693f451ebde..290f3671afca 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1561,6 +1561,21 @@ bool 
WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
 return true;
   }
 
+  // We'll prove some facts that should be true in the context of ext users. If
+  // there is no users, we are done now. If there are some, pick their common
+  // dominator as context.
+  Instruction *Context = nullptr;
+  for (auto *Ext : ExtUsers) {
+if (!Context || DT->dominates(Ext, Context))
+  Context = Ext;
+else if (!DT->dominates(Context, Ext))
+  // For users that don't have dominance relation, use common dominator.
+  Context =
+  DT->findNearestCommonDominator(Context->getParent(), 
Ext->getParent())
+  ->getTerminator();
+  }
+  assert(Context && "Context not found?");
+
   if (!CanSignExtend && !CanZeroExtend) {
 // Because InstCombine turns 'sub nuw' to 'add' losing the no-wrap flag, we
 // will most likely not see it. Let's try to prove it.
@@ -1573,7 +1588,7 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse 
DU) {
 if (!SE->isKnownNegative(RHS))
   return false;
 bool ProvedSubNUW = SE->isKnownPredicateAt(
-ICmpInst::ICMP_UGE, LHS, SE->getNegativeSCEV(RHS), NarrowUse);
+ICmpInst::ICMP_UGE, LHS, SE->getNegativeSCEV(RHS), Context);
 if (!ProvedSubNUW)
   return false;
 // In fact, our 'add' is 'sub nuw'. We will need to widen the 2nd operand 
as

diff  --git a/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll 
b/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
index cad5d3c66eca..2bb37d23866e 100644
--- a/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
+++ b/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
@@ -554,16 +554,13 @@ define i32 @test11(i32 %start, i32* %p, i32* %q) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], 
[[BACKEDGE:%.*]] ], [ [[TMP0]], [[ENTRY:%.*]] ]
-; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
-; CHECK-NEXT:[[IV_NEXT:%.*]] = add i32 [[TMP1]], -1
+; CHECK-NEXT:[[TMP1:%.*]] = add nsw i64 [[INDVARS_IV]], -1
 ; CHECK-NEXT:[[COND:%.*]] = icmp eq i64 [[INDVARS_IV]], 0
 ; CHECK-NEXT:br i1 [[COND]], label [[EXIT:%.*]], label [[BACKEDGE]]
 ; CHECK:   backedge:
-; CHECK-NEXT:[[INDEX:%.*]] = zext i32 [[IV_NEXT]] to i64
-; CHECK-NEXT:[[STORE_ADDR:%.*]] = getelementptr i32, i32* [[P:%.*]], i64 
[[INDEX]]
+; CHECK-NEXT:[[STORE_ADDR:%.*]] = getelementptr i32, i32* [[P:%.*]], i64 
[[TMP1]]
 ; CHECK-NEXT:store i32 1, i32* [[STORE_ADDR]], align 4
-; CHECK-NEXT:[[LOAD_ADDR:%.*]] = getelementptr i32, i32* [[Q:%.*]], i64 
[[INDEX]]
-; CHECK-NEXT:[[STOP:%.*]] = load i32, i32* [[Q]], align 4
+; CHECK-NEXT:[[STOP:%.*]] = load i32, i32* [[Q:%.*]], align 4
 ; CHECK-NEXT:[[LOOP_COND:%.*]] = icmp eq i32 [[STOP]], 0
 ; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
 ; CHECK-NEXT:br i1 [[LOOP_COND]], label [[LOOP]], label [[FAILURE:%.*]]



___
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] 2c7870d - [NewPM] Add pipeline EP callback after initial frontend cleanup

2020-11-24 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-24T21:14:36-08:00
New Revision: 2c7870dccaf31167b7d7b422ed51d1f0b3e343d3

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

LOG: [NewPM] Add pipeline EP callback after initial frontend cleanup

This matches the legacy PM's EP_ModuleOptimizerEarly. Some backends use
this extension point and adding the pass somewhere else like
PipelineStartEPCallback doesn't work.

Reviewed By: ychen

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

Added: 


Modified: 
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pm-O0-ep-callbacks.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/pass-pipeline-parsing.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index 97e0b19ed07f..fb1a83306f55 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -597,6 +597,15 @@ class PassBuilder {
 PipelineStartEPCallbacks.push_back(C);
   }
 
+  /// Register a callback for a default optimizer pipeline extension point.
+  ///
+  /// This extension point allows adding optimization right after passes that 
do
+  /// basic simplification of the input IR.
+  void registerPipelineEarlySimplificationEPCallback(
+  const std::function &C) {
+PipelineEarlySimplificationEPCallbacks.push_back(C);
+  }
+
   /// Register a callback for a default optimizer pipeline extension point
   ///
   /// This extension point allows adding optimizations at the very end of the
@@ -729,6 +738,9 @@ class PassBuilder {
   // Module callbacks
   SmallVector, 2>
   PipelineStartEPCallbacks;
+  SmallVector, 2>
+  PipelineEarlySimplificationEPCallbacks;
+
   SmallVector, 2>
   ModuleAnalysisRegistrationCallbacks;
   SmallVector&1 < %s | 
FileCheck %s
 ; RUN: opt -disable-output -debug-pass-manager 
-passes-ep-vectorizer-start=no-op-function -passes='default' 2>&1 < %s | 
FileCheck %s
 ; RUN: opt -disable-output -debug-pass-manager 
-passes-ep-pipeline-start=no-op-module -passes='default' 2>&1 < %s | 
FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager 
-passes-ep-pipeline-early-simplification=no-op-module -passes='default' 
2>&1 < %s | FileCheck %s
 ; RUN: opt -disable-output -debug-pass-manager 
-passes-ep-optimizer-last=no-op-function -passes='default' 2>&1 < %s | 
FileCheck %s
 
 ; CHECK: Running pass: NoOp

diff  --git a/llvm/test/Other/new-pm-defaults.ll 
b/llvm/test/Other/new-pm-defaults.ll
index 1f2142c5bcd1..9e27486e981b 100644
--- a/llvm/test/Other/new-pm-defaults.ll
+++ b/llvm/test/Other/new-pm-defaults.ll
@@ -55,6 +55,10 @@
 ; RUN: -passes='default' -S  %s 2>&1 \
 ; RUN: | FileCheck %s 
--check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-START,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager \
+; RUN: -passes-ep-pipeline-early-simplification='no-op-module' \
+; RUN: -passes='default' -S  %s 2>&1 \
+; RUN: | FileCheck %s 
--check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-EARLY-SIMPLIFICATION,CHECK-O23SZ
+; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -passes-ep-pipeline-start='no-op-module' \
 ; RUN: -passes='lto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s 
--check-prefixes=CHECK-O,CHECK-LTO,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-START,CHECK-O23SZ
@@ -84,6 +88,7 @@
 ; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass
 ; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass
 ; CHECK-O-NEXT: Finished llvm::Function pass manager run.
+; CHECK-EP-PIPELINE-EARLY-SIMPLIFICATION-NEXT: Running pass: NoOpModulePass
 ; CHECK-O-NEXT: Running pass: IPSCCPPass
 ; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
 ; CHECK-O-NEXT: Running pass: GlobalOptPass

diff  --git a/llvm/test/Other/pass-pipeline-parsing.ll 
b/llvm/test/Other/pass-pipeline-parsing.ll
index adf7554ac503..4cff050f52df 100644
--- a/llvm/test/Other/pass-pipeline-parsing.ll
+++ b/llvm/test/Other/pass-pipeline-parsing.ll
@@ -276,6 +276,9 @@
 ; RUN: opt -passes-ep-pipeline-start=bad -passes=no-op-function \
 ; RUN:   /dev/null -disable-output 2>&1 | FileCheck %s 
-check-prefix=PASSES-EP-PIPELINESTART-ERR
 ; PASSES-EP-PIPELINESTART-ERR: Could not parse -passes-ep-pipeline-start 
pipeline: unknown pass name 'bad'
+; RUN: opt -passes-ep-pipeline-early-simplification=bad -passes=no-op-function 
\
+; RUN:   /dev/null -disable-output 2>&1 | FileCheck %s 
-check-prefix=PASSES-EP-PIPELINEEARLYSIMPLIFICATION-ERR
+; PASSES-EP-PIPELINEEARLYSIMPLIFICATION-ERR: Could not parse 
-passes-ep-pipeline-early-simplification pipeline: unknown pass name 'bad'
 
 define void @f() {
 entry:

diff  --git a

[llvm-branch-commits] [llvm] 9c588f5 - [DAGCombine] Add hook to allow target specific test for sqrt input

2020-11-24 Thread QingShan Zhang via llvm-branch-commits

Author: QingShan Zhang
Date: 2020-11-25T05:37:15Z
New Revision: 9c588f53fc423dd0ed69250fbc93b37b40c0ef44

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

LOG: [DAGCombine] Add hook to allow target specific test for sqrt input

PowerPC has instruction ftsqrt/xstsqrtdp etc to do the input test for software 
square root.
LLVM now tests it with smallest normalized value using abs + setcc. We should 
add hook to
target that has test instructions.

Reviewed By: Spatel, Chen Zheng, Qiu Chao Fang

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/lib/Target/PowerPC/PPCInstrFormats.td
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/lib/Target/PowerPC/PPCInstrVSX.td
llvm/test/CodeGen/PowerPC/fma-mutate.ll
llvm/test/CodeGen/PowerPC/recipest.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 164cbd710713..16580a9160b9 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -4277,6 +4277,15 @@ class TargetLowering : public TargetLoweringBase {
 return SDValue();
   }
 
+  /// Return a target-dependent comparison result if the input operand is
+  /// suitable for use with a square root estimate calculation. For example, 
the
+  /// comparison may check if the operand is NAN, INF, zero, normal, etc. The
+  /// result should be used as the condition operand for a select or branch.
+  virtual SDValue getSqrtInputTest(SDValue Operand, SelectionDAG &DAG,
+   const DenormalMode &Mode) const {
+return SDValue();
+  }
+
   
//======//
   // Legalization utility functions
   //

diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index cae602d166d1..4ac1743d2d34 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -22056,26 +22056,31 @@ SDValue DAGCombiner::buildSqrtEstimateImpl(SDValue 
Op, SDNodeFlags Flags,
 // possibly a denormal. Force the answer to 0.0 for those cases.
 SDLoc DL(Op);
 EVT CCVT = getSetCCResultType(VT);
-ISD::NodeType SelOpcode = VT.isVector() ? ISD::VSELECT : ISD::SELECT;
+SDValue FPZero = DAG.getConstantFP(0.0, DL, VT);
 DenormalMode DenormMode = DAG.getDenormalMode(VT);
-if (DenormMode.Input == DenormalMode::IEEE) {
-  // This is specifically a check for the handling of denormal inputs,
-  // not the result.
-
-  // fabs(X) < SmallestNormal ? 0.0 : Est
-  const fltSemantics &FltSem = DAG.EVTToAPFloatSemantics(VT);
-  APFloat SmallestNorm = APFloat::getSmallestNormalized(FltSem);
-  SDValue NormC = DAG.getConstantFP(SmallestNorm, DL, VT);
-  SDValue FPZero = DAG.getConstantFP(0.0, DL, VT);
-  SDValue Fabs = DAG.getNode(ISD::FABS, DL, VT, Op);
-  SDValue IsDenorm = DAG.getSetCC(DL, CCVT, Fabs, NormC, ISD::SETLT);
-  Est = DAG.getNode(SelOpcode, DL, VT, IsDenorm, FPZero, Est);
-} else {
-  // X == 0.0 ? 0.0 : Est
-  SDValue FPZero = DAG.getConstantFP(0.0, DL, VT);
-  SDValue IsZero = DAG.getSetCC(DL, CCVT, Op, FPZero, ISD::SETEQ);
-  Est = DAG.getNode(SelOpcode, DL, VT, IsZero, FPZero, Est);
+// Try the target specific test first.
+SDValue Test = TLI.getSqrtInputTest(Op, DAG, DenormMode);
+if (!Test) {
+  // If no test provided by target, testing it with denormal inputs to
+  // avoid wrong estimate.
+  if (DenormMode.Input == DenormalMode::IEEE) {
+// This is specifically a check for the handling of denormal 
inputs,
+// not the result.
+
+// Test = fabs(X) < SmallestNormal
+const fltSemantics &FltSem = DAG.EVTToAPFloatSemantics(VT);
+APFloat SmallestNorm = APFloat::getSmallestNormalized(FltSem);
+SDValue NormC = DAG.getConstantFP(SmallestNorm, DL, VT);
+SDValue Fabs = DAG.getNode(ISD::FABS, DL, VT, Op);
+Test = DAG.getSetCC(DL, CCVT, Fabs, NormC, ISD::SETLT);
+  } else
+// Test = X == 0.0
+Test = DAG.getSetCC(DL, CCVT, Op, FPZero, ISD::SETEQ);
 }
+// Test ? 0.0 : Est
+Est = DAG.getNode(Test.getValueType().isVector() ? ISD::VSELECT
+ : ISD::SELECT,
+ 

[llvm-branch-commits] [llvm] 9130651 - Revert "[SCEV] Generalize no-self-wrap check in isLoopInvariantExitCondDuringFirstIterations"

2020-11-24 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2020-11-25T13:26:17+07:00
New Revision: 9130651126b745b18138b816487cdeb8a689a27f

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

LOG: Revert "[SCEV] Generalize no-self-wrap check in 
isLoopInvariantExitCondDuringFirstIterations"

This reverts commit 7dcc8899174f44b7447bc48a9f2ff27f5458f8b7.

This patch introduced a logical error that breaks whole logic of this analysis.
All checks we are making are supposed to be loop-independent, so that we could
safely remove the range check. The 'nw' fact is loop-dependent, so we can remove
the check basing on facts from this very check.

Motivating examples will follow-up.

Added: 


Modified: 
llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp 
b/llvm/lib/Analysis/ScalarEvolution.cpp
index 08ed363918a9..5f77f4aa05c2 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -9643,19 +9643,17 @@ 
ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations(
   if (!ICmpInst::isRelational(Pred))
 return None;
 
+  // TODO: Support steps other than +/- 1.
   const SCEV *Step = AR->getStepRecurrence(*this);
-  bool IsStepNonPositive = isKnownNonPositive(Step);
-  if (!IsStepNonPositive && !isKnownNonNegative(Step))
+  auto *One = getOne(Step->getType());
+  auto *MinusOne = getNegativeSCEV(One);
+  if (Step != One && Step != MinusOne)
 return None;
-  bool HasNoSelfWrap = AR->hasNoSelfWrap();
-  if (!HasNoSelfWrap)
-// If num iter has same type as the AddRec, and step is +/- 1, even max
-// possible number of iterations is not enough to self-wrap.
-if (MaxIter->getType() == AR->getType())
-  if (Step == getOne(AR->getType()) || Step == getMinusOne(AR->getType()))
-HasNoSelfWrap = true;
-  // Only proceed with non-self-wrapping ARs.
-  if (!HasNoSelfWrap)
+
+  // Type mismatch here means that MaxIter is potentially larger than max
+  // unsigned value in start type, which mean we cannot prove no wrap for the
+  // indvar.
+  if (AR->getType() != MaxIter->getType())
 return None;
 
   // Value of IV on suggested last iteration.
@@ -9663,13 +9661,14 @@ 
ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations(
   // Does it still meet the requirement?
   if (!isKnownPredicateAt(Pred, Last, RHS, Context))
 return None;
-  // We know that the addrec does not have a self-wrap. To prove that there is
-  // no signed/unsigned wrap, we need to check that
-  // Start <= Last for positive step or Start >= Last for negative step. Either
-  // works for zero step.
+  // Because step is +/- 1 and MaxIter has same type as Start (i.e. it does
+  // not exceed max unsigned value of this type), this effectively proves
+  // that there is no wrap during the iteration. To prove that there is no
+  // signed/unsigned wrap, we need to check that
+  // Start <= Last for step = 1 or Start >= Last for step = -1.
   ICmpInst::Predicate NoOverflowPred =
   CmpInst::isSigned(Pred) ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE;
-  if (IsStepNonPositive)
+  if (Step == MinusOne)
 NoOverflowPred = CmpInst::getSwappedPredicate(NoOverflowPred);
   const SCEV *Start = AR->getStart();
   if (!isKnownPredicateAt(NoOverflowPred, Start, Last, Context))



___
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] 1c82d32 - [CHR] Use pred_size (NFC)

2020-11-24 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-11-24T22:52:30-08:00
New Revision: 1c82d320893c9e93d8bd1d4a2aded7e4df4bdf30

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

LOG: [CHR] Use pred_size (NFC)

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp 
b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index a99c58b74fb1..9bfb176dcd7f 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -1609,9 +1609,7 @@ static void insertTrivialPHIs(CHRScope *Scope,
 // Insert a trivial phi for I (phi [&I, P0], [&I, P1], ...) at
 // ExitBlock. Replace I with the new phi in UI unless UI is another
 // phi at ExitBlock.
-unsigned PredCount = std::distance(pred_begin(ExitBlock),
-   pred_end(ExitBlock));
-PHINode *PN = PHINode::Create(I.getType(), PredCount, "",
+PHINode *PN = PHINode::Create(I.getType(), pred_size(ExitBlock), "",
   &ExitBlock->front());
 for (BasicBlock *Pred : predecessors(ExitBlock)) {
   PN->addIncoming(&I, Pred);



___
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] 97e7ce3 - [PowerPC] Probe the gap between stackptr and realigned stackptr

2020-11-24 Thread Kai Luo via llvm-branch-commits

Author: Kai Luo
Date: 2020-11-25T07:01:45Z
New Revision: 97e7ce3b15ccaf3e121a666122a5b282a5a6607d

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

LOG: [PowerPC] Probe the gap between stackptr and realigned stackptr

During reviewing https://reviews.llvm.org/D84419, @efriedma mentioned the gap 
between realigned stack pointer and origin stack pointer should be probed too 
whatever the alignment is. This patch fixes the issue for PPC64.

Reviewed By: jsji

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
llvm/test/CodeGen/PowerPC/pr46759.ll
llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
index 95bcace21f81..7df2f6dc9252 100644
--- a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
@@ -525,6 +525,8 @@ PPCFrameLowering::findScratchRegister(MachineBasicBlock 
*MBB,
 // register is available, we can adjust for that by not overlapping the spill
 // code. However, if we need to realign the stack (i.e. have a base pointer)
 // and the stack frame is large, we need two scratch registers.
+// Also, stack probe requires two scratch registers, one for old sp, one for
+// large frame and large probe size.
 bool
 PPCFrameLowering::twoUniqueScratchRegsRequired(MachineBasicBlock *MBB) const {
   const PPCRegisterInfo *RegInfo = Subtarget.getRegisterInfo();
@@ -536,8 +538,10 @@ 
PPCFrameLowering::twoUniqueScratchRegsRequired(MachineBasicBlock *MBB) const {
   MachineFrameInfo &MFI = MF.getFrameInfo();
   Align MaxAlign = MFI.getMaxAlign();
   bool HasRedZone = Subtarget.isPPC64() || !Subtarget.isSVR4ABI();
+  const PPCTargetLowering &TLI = *Subtarget.getTargetLowering();
 
-  return (IsLargeFrame || !HasRedZone) && HasBP && MaxAlign > 1;
+  return ((IsLargeFrame || !HasRedZone) && HasBP && MaxAlign > 1) ||
+ TLI.hasInlineStackProbe(MF);
 }
 
 bool PPCFrameLowering::canUseAsPrologue(const MachineBasicBlock &MBB) const {
@@ -676,12 +680,8 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF,
  "FrameSize must be >0 to save/restore the FP or LR for 32-bit SVR4.");
 
   // Using the same bool variable as below to suppress compiler warnings.
-  // Stack probe requires two scratch registers, one for old sp, one for large
-  // frame and large probe size.
   bool SingleScratchReg = findScratchRegister(
-  &MBB, false,
-  twoUniqueScratchRegsRequired(&MBB) || TLI.hasInlineStackProbe(MF),
-  &ScratchReg, &TempReg);
+  &MBB, false, twoUniqueScratchRegsRequired(&MBB), &ScratchReg, &TempReg);
   assert(SingleScratchReg &&
  "Required number of registers not available in this block");
 
@@ -1202,10 +1202,12 @@ void PPCFrameLowering::inlineStackProbe(MachineFunction 
&MF,
   if (StackAllocMIPos == PrologMBB.end())
 return;
   const BasicBlock *ProbedBB = PrologMBB.getBasicBlock();
+  MachineBasicBlock *CurrentMBB = &PrologMBB;
   DebugLoc DL = PrologMBB.findDebugLoc(StackAllocMIPos);
   MachineInstr &MI = *StackAllocMIPos;
   int64_t NegFrameSize = MI.getOperand(2).getImm();
-  int64_t NegProbeSize = -(int64_t)TLI.getStackProbeSize(MF);
+  unsigned ProbeSize = TLI.getStackProbeSize(MF);
+  int64_t NegProbeSize = -(int64_t)ProbeSize;
   assert(isInt<32>(NegProbeSize) && "Unhandled probe size");
   int64_t NumBlocks = NegFrameSize / NegProbeSize;
   int64_t NegResidualSize = NegFrameSize % NegProbeSize;
@@ -1214,10 +1216,9 @@ void PPCFrameLowering::inlineStackProbe(MachineFunction 
&MF,
   Register FPReg = MI.getOperand(1).getReg();
   const PPCRegisterInfo *RegInfo = Subtarget.getRegisterInfo();
   bool HasBP = RegInfo->hasBasePointer(MF);
+  Register BPReg = RegInfo->getBaseRegister(MF);
   Align MaxAlign = MFI.getMaxAlign();
-  // Initialize current frame pointer.
   const MCInstrDesc &CopyInst = TII.get(isPPC64 ? PPC::OR8 : PPC::OR);
-  BuildMI(PrologMBB, {MI}, DL, CopyInst, FPReg).addReg(SPReg).addReg(SPReg);
   // Subroutines to generate .cfi_* directives.
   auto buildDefCFAReg = [&](MachineBasicBlock &MBB,
 MachineBasicBlock::iterator MBBI, Register Reg) {
@@ -1257,89 +1258,218 @@ void 
PPCFrameLowering::inlineStackProbe(MachineFunction &MF,
   // Subroutine to store frame pointer and decrease stack pointer by probe 
size.
   auto allocateAndProbe = [&](MachineBasicBlock &MBB,
   MachineBasicBlock::iterator MBBI, int64_t 
NegSize,
-  Register NegSizeReg, bool UseDForm) {
+  Register NegSizeReg, bool UseDForm,
+  Register StoreReg) {
 if (UseDForm)
   BuildMI(M