[llvm-branch-commits] [llvm] 83aea14 - [llvm-readelf] - Don't print OS/Processor specific prefix for known ELF file types.

2020-12-15 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-12-15T10:56:25+03:00
New Revision: 83aea14ed6118c810e4ed2966bc34db9b42cb049

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

LOG: [llvm-readelf] - Don't print OS/Processor specific prefix for known ELF 
file types.

This is a change suggested in post commit comments for
D93096 (https://reviews.llvm.org/D93096#2451796).

Imagine we want to add a custom OS specific ELF file type.
For that we can update the `ElfObjectFileType` array:

```
static const EnumEntry ElfObjectFileType[] = {
...
  {"Core", "CORE (Core file)", ELF::ET_CORE},
  {"MyType",   "MyType (my description)", 0xfe01},
};
```

The current code then might print:
```
OS Specific: (MyType (my description))
```

Though instead we probably would like to see a nicer output, e.g:
```
Type: MyType (my description)
```

To achieve that we can reorder the code slightly.

It is impossible to add a test I think, because we have no custom values in
the `ElfObjectFileType` array in LLVM.

Differential revision: https://reviews.llvm.org/D93217

Added: 


Modified: 
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 27222c5639e6..c9ca2215d2c6 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3528,16 +3528,17 @@ template  void 
GNUStyle::printFileHeaders() {
   "ABI Version:", std::to_string(e.e_ident[ELF::EI_ABIVERSION]));
 
   Str = printEnum(e.e_type, makeArrayRef(ElfObjectFileType));
-  if (e.e_type >= ET_LOPROC) {
-Str = "Processor Specific: (" + Str + ")";
-  } else if (e.e_type >= ET_LOOS) {
-Str = "OS Specific: (" + Str + ")";
-  } else if (makeArrayRef(ElfObjectFileType).end() ==
- llvm::find_if(ElfObjectFileType,
-   [&](const EnumEntry &E) {
- return E.Value == e.e_type;
-   }))
-Str = ": " + Str;
+  if (makeArrayRef(ElfObjectFileType).end() ==
+  llvm::find_if(ElfObjectFileType, [&](const EnumEntry &E) {
+return E.Value == e.e_type;
+  })) {
+if (e.e_type >= ET_LOPROC)
+  Str = "Processor Specific: (" + Str + ")";
+else if (e.e_type >= ET_LOOS)
+  Str = "OS Specific: (" + Str + ")";
+else
+  Str = ": " + Str;
+  }
   printFields(OS, "Type:", Str);
 
   Str = printEnum(e.e_machine, makeArrayRef(ElfMachineType));



___
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] 14a91d6 - [RISCV][NFC] Define scalable vectors for half types.

2020-12-15 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2020-12-15T16:23:22+08:00
New Revision: 14a91d676b794db09c14abecf363650a8fc90c61

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

LOG: [RISCV][NFC] Define scalable vectors for half types.

This is a preperation work for vfadd intrinsics.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index a6aa81be1e40..529a5bf784f4 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -124,6 +124,13 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
 addRegisterClass(RISCVVMVTs::vint64m4_t, &RISCV::VRM4RegClass);
 addRegisterClass(RISCVVMVTs::vint64m8_t, &RISCV::VRM8RegClass);
 
+addRegisterClass(RISCVVMVTs::vfloat16mf4_t, &RISCV::VRRegClass);
+addRegisterClass(RISCVVMVTs::vfloat16mf2_t, &RISCV::VRRegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m1_t, &RISCV::VRRegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m2_t, &RISCV::VRM2RegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m4_t, &RISCV::VRM4RegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m8_t, &RISCV::VRM8RegClass);
+
 addRegisterClass(RISCVVMVTs::vfloat32mf2_t, &RISCV::VRRegClass);
 addRegisterClass(RISCVVMVTs::vfloat32m1_t, &RISCV::VRRegClass);
 addRegisterClass(RISCVVMVTs::vfloat32m2_t, &RISCV::VRM2RegClass);

diff  --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index ea7357c9c073..b69cdde6c532 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -314,6 +314,13 @@ defvar vint64m2_t = nxv2i64;
 defvar vint64m4_t = nxv4i64;
 defvar vint64m8_t = nxv8i64;
 
+defvar vfloat16mf4_t = nxv1f16;
+defvar vfloat16mf2_t = nxv2f16;
+defvar vfloat16m1_t  = nxv4f16;
+defvar vfloat16m2_t  = nxv8f16;
+defvar vfloat16m4_t  = nxv16f16;
+defvar vfloat16m8_t  = nxv32f16;
+
 defvar vfloat32mf2_t = nxv1f32;
 defvar vfloat32m1_t  = nxv2f32;
 defvar vfloat32m2_t  = nxv4f32;
@@ -391,6 +398,7 @@ class VReg regTypes, dag regList, int Vlmul>
 def VR : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
vint16mf2_t, vint16mf4_t, vint32mf2_t,
vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t,
+   vfloat16mf4_t, vfloat16mf2_t, vfloat16m1_t,
vfloat32mf2_t, vfloat32m1_t, vfloat64m1_t,
vbool64_t, vbool32_t, vbool16_t, vbool8_t, vbool4_t,
vbool2_t, vbool1_t],
@@ -401,6 +409,7 @@ def VR : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
 def VRNoV0 : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
vint16mf2_t, vint16mf4_t, vint32mf2_t,
vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t,
+   vfloat16mf4_t, vfloat16mf2_t, vfloat16m1_t,
vfloat32mf2_t, vfloat32m1_t, vfloat64m1_t,
vbool64_t, vbool32_t, vbool16_t, vbool8_t, vbool4_t,
vbool2_t, vbool1_t],
@@ -409,29 +418,29 @@ def VRNoV0 : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
 (sequence "V%u", 1, 7)), 1>;
 
 def VRM2 : VReg<[vint8m2_t, vint16m2_t, vint32m2_t, vint64m2_t,
- vfloat32m2_t, vfloat64m2_t],
+ vfloat16m2_t, vfloat32m2_t, vfloat64m2_t],
  (add V26M2, V28M2, V30M2, V8M2, V10M2, V12M2, V14M2, V16M2,
   V18M2, V20M2, V22M2, V24M2, V0M2, V2M2, V4M2, V6M2), 2>;
 
 def VRM2NoV0 : VReg<[vint8m2_t, vint16m2_t, vint32m2_t, vint64m2_t,
- vfloat32m2_t, vfloat64m2_t],
+ vfloat16m2_t, vfloat32m2_t, vfloat64m2_t],
  (add V26M2, V28M2, V30M2, V8M2, V10M2, V12M2, V14M2, V16M2,
   V18M2, V20M2, V22M2, V24M2, V2M2, V4M2, V6M2), 2>;
 
 def VRM4 : VReg<[vint8m4_t, vint16m4_t, vint32m4_t, vint64m4_t,
- vfloat32m4_t, vfloat64m4_t],
+ vfloat16m4_t, vfloat32m4_t, vfloat64m4_t],
  (add V28M4, V8M4, V12M4, V16M4, V20M4, V24M4, V0M4, V4M4), 4>;
 
 def VRM4NoV0 : VReg<[vint8m4_t, vint16m4_t, vint32m4_t, vint64m4_t,
- vfloat32m4_t, vfloat64m4_t],
+ vfloat16m4_t, vfloat32m4_t, vfloat64m4_t],
  (add V28M4, V8M4, V12M4, V16M4, V20M4, V24M4, V4M4), 4>;
 
 def VRM8 : VReg<[vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_t,
- vfloat32m8_t, vfloat64m8_t],
+ vfloat16m8_t, vfloat32m8_t, vfloat64m8_t],
  (add V8M8, V16M8, V24M8, V0M8), 8>;
 
 def VRM8NoV0 : VReg<[vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_

[llvm-branch-commits] [clang-tools-extra] 9c328e7 - [clangd] Add hover info for `this` expr

2020-12-15 Thread Sam McCall via llvm-branch-commits

Author: xndcn
Date: 2020-12-15T09:47:29+01:00
New Revision: 9c328e7afafd15795fed54e3b0c1c5bd4fa97dfa

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

LOG: [clangd] Add hover info for `this` expr

How about add hover information for `this` expr?
It seems useful to show related information about the class for `this` expr 
sometimes.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index d599ccb557c28..e461c7c433645 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -552,7 +552,8 @@ HoverInfo getHoverContents(const NamedDecl *D, const 
SymbolIndex *Index) {
 
 /// Generate a \p Hover object given the type \p T.
 HoverInfo getHoverContents(QualType T, ASTContext &ASTCtx,
-   const SymbolIndex *Index) {
+   const SymbolIndex *Index,
+   bool SuppressScope = false) {
   HoverInfo HI;
 
   if (const auto *D = T->getAsTagDecl()) {
@@ -566,6 +567,7 @@ HoverInfo getHoverContents(QualType T, ASTContext &ASTCtx,
 // Builtin types
 auto Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy());
 Policy.SuppressTagKeyword = true;
+Policy.SuppressScope = SuppressScope;
 HI.Name = T.getAsString(Policy);
   }
   return HI;
@@ -628,15 +630,29 @@ llvm::StringLiteral getNameForExpr(const Expr *E) {
   return llvm::StringLiteral("expression");
 }
 
-// Generates hover info for evaluatable expressions.
+// Generates hover info for `this` and evaluatable expressions.
 // FIXME: Support hover for literals (esp user-defined)
-llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST) {
+llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST,
+   const SymbolIndex *Index) {
   // There's not much value in hovering over "42" and getting a hover card
   // saying "42 is an int", similar for other literals.
   if (isLiteral(E))
 return llvm::None;
 
   HoverInfo HI;
+  // For `this` expr we currently generate hover with pointee type.
+  if (const CXXThisExpr *CTE = dyn_cast(E)) {
+QualType OriginThisType = CTE->getType()->getPointeeType();
+QualType ClassType = declaredType(OriginThisType->getAsTagDecl());
+// For partial specialization class, origin `this` pointee type will be
+// parsed as `InjectedClassNameType`, which will ouput template arguments
+// like "type-parameter-0-0". So we retrieve user written class type in 
this
+// case.
+QualType PrettyThisType = AST.getASTContext().getPointerType(
+QualType(ClassType.getTypePtr(), OriginThisType.getCVRQualifiers()));
+return getHoverContents(PrettyThisType, AST.getASTContext(), Index,
+/*SuppressScope=*/true);
+  }
   // For expressions we currently print the type and the value, iff it is
   // evaluatable.
   if (auto Val = printExprValue(E, AST.getASTContext())) {
@@ -861,7 +877,7 @@ llvm::Optional getHover(ParsedAST &AST, Position 
Pos,
   HI->Value = printExprValue(N, AST.getASTContext());
 maybeAddCalleeArgInfo(N, *HI, AST.getASTContext().getPrintingPolicy());
   } else if (const Expr *E = N->ASTNode.get()) {
-HI = getHoverContents(E, AST);
+HI = getHoverContents(E, AST, Index);
   }
   // FIXME: support hovers for other nodes?
   //  - built-in types

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index fdebf0da67103..bac0e525664b2 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2019,6 +2019,56 @@ TEST(Hover, All) {
 HI.NamespaceScope = "";
 HI.Definition = "@interface MYObject\n@end";
   }},
+  {
+  R"cpp(// this expr
+  // comment
+  namespace ns {
+class Foo {
+  Foo* bar() {
+return [[t^his]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "Foo *"; }},
+  {
+  R"cpp(// this expr for template class
+  namespace ns {
+template 
+class Foo {
+  Foo* bar() const {
+return [[t^his]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "const Foo *"; }},
+  {
+  R"cpp(// this expr for specialization class
+  namespace ns {
+template  class Foo {};
+ 

[llvm-branch-commits] [clang] f24e58d - [clang][cli] Create accessors for exception models in LangOptions

2020-12-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-15T10:15:58+01:00
New Revision: f24e58df7ddf2dc9f13c8f8fc259f0374f04aca3

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

LOG: [clang][cli] Create accessors for exception models in LangOptions

This abstracts away the members that are being replaced in a follow-up patch.

Depends on D83979.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGException.cpp
clang/lib/Frontend/InitPreprocessor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 203c45fdd9a7..d4791650ec6b 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -380,6 +380,11 @@ class LangOptions : public LangOptionsBase {
   bool isSignReturnAddressScopeAll() const {
 return getSignReturnAddressScope() == SignReturnAddressScopeKind::All;
   }
+
+  bool hasSjLjExceptions() const { return SjLjExceptions; }
+  bool hasSEHExceptions() const { return SEHExceptions; }
+  bool hasDWARFExceptions() const { return DWARFExceptions; }
+  bool hasWasmExceptions() const { return WasmExceptions; }
 };
 
 /// Floating point control options

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 554688ac987b..2dbf30ef171f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -497,13 +497,13 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   // Set EABI version.
   Options.EABIVersion = TargetOpts.EABIVersion;
 
-  if (LangOpts.SjLjExceptions)
+  if (LangOpts.hasSjLjExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::SjLj;
-  if (LangOpts.SEHExceptions)
+  if (LangOpts.hasSEHExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::WinEH;
-  if (LangOpts.DWARFExceptions)
+  if (LangOpts.hasDWARFExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::DwarfCFI;
-  if (LangOpts.WasmExceptions)
+  if (LangOpts.hasWasmExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::Wasm;
 
   Options.NoInfsFPMath = LangOpts.NoHonorInfs;

diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index 85604cf5e611..f8a486909e41 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -121,11 +121,11 @@ static const EHPersonality &getCPersonality(const 
TargetInfo &Target,
   const llvm::Triple &T = Target.getTriple();
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
-  if (L.SjLjExceptions)
+  if (L.hasSjLjExceptions())
 return EHPersonality::GNU_C_SJLJ;
-  if (L.DWARFExceptions)
+  if (L.hasDWARFExceptions())
 return EHPersonality::GNU_C;
-  if (L.SEHExceptions)
+  if (L.hasSEHExceptions())
 return EHPersonality::GNU_C_SEH;
   return EHPersonality::GNU_C;
 }
@@ -149,9 +149,9 @@ static const EHPersonality &getObjCPersonality(const 
TargetInfo &Target,
 LLVM_FALLTHROUGH;
   case ObjCRuntime::GCC:
   case ObjCRuntime::ObjFW:
-if (L.SjLjExceptions)
+if (L.hasSjLjExceptions())
   return EHPersonality::GNU_ObjC_SJLJ;
-if (L.SEHExceptions)
+if (L.hasSEHExceptions())
   return EHPersonality::GNU_ObjC_SEH;
 return EHPersonality::GNU_ObjC;
   }
@@ -165,13 +165,13 @@ static const EHPersonality &getCXXPersonality(const 
TargetInfo &Target,
 return EHPersonality::MSVC_CxxFrameHandler3;
   if (T.isOSAIX())
 return EHPersonality::XL_CPlusPlus;
-  if (L.SjLjExceptions)
+  if (L.hasSjLjExceptions())
 return EHPersonality::GNU_CPlusPlus_SJLJ;
-  if (L.DWARFExceptions)
+  if (L.hasDWARFExceptions())
 return EHPersonality::GNU_CPlusPlus;
-  if (L.SEHExceptions)
+  if (L.hasSEHExceptions())
 return EHPersonality::GNU_CPlusPlus_SEH;
-  if (L.WasmExceptions)
+  if (L.hasWasmExceptions())
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
@@ -476,7 +476,7 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
 // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
 // case of throw with types, we ignore it and print a warning for now.
 // TODO Correctly handle exception specification in wasm
-if (CGM.getLangOpts().WasmExceptions) {
+if (CGM.getLangOpts().hasWasmExceptions()) {
   if (EST == EST_DynamicNone)
 EHStack.pushTerminate();
   else
@@ -564,7 +564,7 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
 // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
 // case of throw with types, we ignore it and print a warning for now.
 // TO

[llvm-branch-commits] [clang] 573255b - [clang][cli] Squash exception model in LangOptions into one member

2020-12-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-15T10:15:58+01:00
New Revision: 573255b47eb9b210e74a1c620fee363dfaa52794

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

LOG: [clang][cli] Squash exception model in LangOptions into one member

This squashes multiple members in LangOptions into one. This is leveraged in a 
follow-up patch that implements marshalling of related command-line options.

Depends on D93214.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 19fb4ae82b89..251fd68f4df8 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -129,10 +129,8 @@ LANGOPT(ZVector   , 1, 0, "System z vector 
extensions")
 LANGOPT(Exceptions, 1, 0, "exception handling")
 LANGOPT(ObjCExceptions, 1, 0, "Objective-C exceptions")
 LANGOPT(CXXExceptions , 1, 0, "C++ exceptions")
-LANGOPT(DWARFExceptions   , 1, 0, "dwarf exception handling")
-LANGOPT(SjLjExceptions, 1, 0, "setjmp-longjump exception handling")
-LANGOPT(SEHExceptions , 1, 0, "SEH .xdata exception handling")
-LANGOPT(WasmExceptions, 1, 0, "WebAssembly exception handling")
+ENUM_LANGOPT(ExceptionHandling, ExceptionHandlingKind, 3,
+ ExceptionHandlingKind::None, "exception handling")
 LANGOPT(IgnoreExceptions  , 1, 0, "ignore exceptions")
 LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")
 LANGOPT(TraditionalCPP, 1, 0, "traditional CPP emulation")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d4791650ec6b..2780e4bf35fd 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -22,6 +22,7 @@
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCTargetOptions.h"
 #include 
 #include 
 
@@ -209,6 +210,9 @@ class LangOptions : public LangOptionsBase {
 FPE_Strict
   };
 
+  /// Possible exception handling behavior.
+  using ExceptionHandlingKind = llvm::ExceptionHandling;
+
   enum class LaxVectorConversionKind {
 /// Permit no implicit vector bitcasts.
 None,
@@ -381,10 +385,21 @@ class LangOptions : public LangOptionsBase {
 return getSignReturnAddressScope() == SignReturnAddressScopeKind::All;
   }
 
-  bool hasSjLjExceptions() const { return SjLjExceptions; }
-  bool hasSEHExceptions() const { return SEHExceptions; }
-  bool hasDWARFExceptions() const { return DWARFExceptions; }
-  bool hasWasmExceptions() const { return WasmExceptions; }
+  bool hasSjLjExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::SjLj;
+  }
+
+  bool hasSEHExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::WinEH;
+  }
+
+  bool hasDWARFExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::DwarfCFI;
+  }
+
+  bool hasWasmExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::Wasm;
+  }
 };
 
 /// Floating point control options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index c1d5364d72ea..e4058cfc1915 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2981,10 +2981,14 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   Diags.Report(diag::err_fe_invalid_exception_model)
   << Opt.getName() << T.str();
 
-Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
-Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
-Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
-Opts.WasmExceptions = Opt.matches(options::OPT_fwasm_exceptions);
+if (Opt.matches(options::OPT_fsjlj_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::SjLj);
+else if (Opt.matches(options::OPT_fseh_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::WinEH);
+else if (Opt.matches(options::OPT_fdwarf_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::DwarfCFI);
+else if (Opt.matches(options::OPT_fwasm_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::Wasm);
   }
 
   Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.or

[llvm-branch-commits] [clang] 56c5548 - [clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single -exception-model=xxx option

2020-12-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-15T10:15:58+01:00
New Revision: 56c5548d7f07f5853a2e40562db08dc2e56ece03

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

LOG: [clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single 
-exception-model=xxx option

This patch enables marshalling of the exception model options while enforcing 
their mutual exclusivity. The clang driver interface remains the same, this 
only affects the cc1 command line.

Depends on D93215.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/exceptions.c
clang/test/CodeGen/personality.c
clang/test/CodeGenCXX/mingw-w64-exceptions.c
clang/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
clang/test/CodeGenCXX/personality.cpp
clang/test/CodeGenCXX/wasm-eh.cpp
clang/test/CodeGenObjC/personality.m
clang/test/CodeGenObjCXX/objfw-exceptions.mm
clang/test/CodeGenObjCXX/personality.mm
clang/test/Driver/arch-armv7k.c
clang/test/Driver/freebsd.c
clang/test/Driver/fsjlj-exceptions.c
clang/test/Driver/ve-toolchain.c
clang/test/Driver/ve-toolchain.cpp
clang/test/Driver/windows-exceptions.cpp
clang/test/Frontend/windows-exceptions.cpp
clang/test/Preprocessor/init-arm.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 0f1b68bd0e7d..def189f65994 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -111,7 +111,7 @@ def err_fe_invalid_alignment : Error<
 def err_fe_invalid_wchar_type
 : Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 
'int'">;
 def err_fe_invalid_exception_model
-   : Error<"invalid exception model '%0' for target '%1'">;
+   : Error<"invalid exception model 
'%select{none|dwarf|sjlj|arm|seh|wasm|aix}0' for target '%1'">;
 def warn_fe_concepts_ts_flag : Warning<
   "-fconcepts-ts is deprecated - use '-std=c++20' for Concepts support">,
   InGroup;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 2780e4bf35fd..be2c7a004e0b 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -31,6 +31,8 @@ namespace clang {
 /// Bitfields of LangOptions, split out from LangOptions in order to ensure 
that
 /// this large collection of bitfields is a trivial class type.
 class LangOptionsBase {
+  friend class CompilerInvocation;
+
 public:
   // Define simple language options (with no accessors).
 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 67d41c3711f5..f3aa6750b794 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1265,13 +1265,22 @@ def fencoding_EQ : Joined<["-"], "fencoding=">, 
Group;
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, 
Flags<[CoreOption]>;
 defm exceptions : OptInFFlag<"exceptions", "Enable", "Disable", " support for 
exception handling">;
 def fdwarf_exceptions : Flag<["-"], "fdwarf-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use DWARF style exceptions">;
+  HelpText<"Use DWARF style exceptions">;
 def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use SjLj style exceptions">;
+  HelpText<"Use SjLj style exceptions">;
 def fseh_exceptions : Flag<["-"], "fseh-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use SEH style exceptions">;
+  HelpText<"Use SEH style exceptions">;
 def fwasm_exceptions : Flag<["-"], "fwasm-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use WebAssembly style exceptions">;
+  HelpText<"Use WebAssembly style exceptions">;
+def exception_model : Separate<["-"], "exception-model">,
+  Flags<[CC1Option, NoDriverOption]>, HelpText<"The exception model: 
dwarf|sjlj|seh|wasm">,
+  Values<"dwarf,sjlj,seh,wasm">,
+  NormalizedValuesScope<"llvm::ExceptionHandling">,
+  NormalizedValues<["DwarfCFI", "SjLj", "WinEH", "Wasm"]>,
+  MarshallingInfoString<"LangOpts->ExceptionHandling", "None">,
+  AutoNormalizeEnum;
+def exception_model_EQ : Joined<["-"], "exception-model=">,
+  Flags<[CC1Option, NoDriverOption]>, Alias;
 def fignore_exceptions : Flag<["-"], "fignore-exceptions">, Group, 
Flags<[CC1Option]>,
   HelpText<"Enable support for ignoring exception handling constructs">;
 def fexcess_pr

[llvm-branch-commits] [llvm] ad1161f - [VPlan] Use VPdef for VPWidenCall.

2020-12-15 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-15T09:20:07Z
New Revision: ad1161f9b5ff251b80788033e4db82b5a11b187b

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

LOG: [VPlan] Use VPdef for VPWidenCall.

This patch turns updates VPWidenREcipe to manage the value it defines
using VPDef.

Reviewed By: gilr

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 1d85e9243a59..3c42f47ff9f6 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -858,13 +858,16 @@ class VPWidenRecipe : public VPRecipeBase, public 
VPValue, public VPUser {
 };
 
 /// A recipe for widening Call instructions.
-class VPWidenCallRecipe : public VPRecipeBase, public VPValue, public VPUser {
+class VPWidenCallRecipe : public VPRecipeBase,
+  public VPDef,
+  public VPUser,
+  public VPValue {
 
 public:
   template 
   VPWidenCallRecipe(CallInst &I, iterator_range CallArguments)
-  : VPRecipeBase(VPRecipeBase::VPWidenCallSC),
-VPValue(VPValue::VPVWidenCallSC, &I), VPUser(CallArguments) {}
+  : VPRecipeBase(VPRecipeBase::VPWidenCallSC), VPUser(CallArguments),
+VPValue(VPValue::VPVWidenCallSC, &I, this) {}
 
   ~VPWidenCallRecipe() override = default;
 



___
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] 318f579 - [VPlan] Use VPDef for VPWidenGEPRecipe.

2020-12-15 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-15T09:30:14Z
New Revision: 318f5798d8cb375e5af07812cede2f041ef839fe

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

LOG: [VPlan] Use VPDef for VPWidenGEPRecipe.

This patch turns updates VPWidenGEPRecipe to manage the value it defines
using VPDef. The VPValue is used  during VPlan construction and
codegeneration instead of the plain IR reference where possible.

Reviewed By: gilr

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 3c42f47ff9f6..2b3808b74b74 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -914,21 +914,25 @@ class VPWidenSelectRecipe : public VPRecipeBase, public 
VPValue, public VPUser {
 };
 
 /// A recipe for handling GEP instructions.
-class VPWidenGEPRecipe : public VPRecipeBase, public VPValue, public VPUser {
+class VPWidenGEPRecipe : public VPRecipeBase,
+ public VPDef,
+ public VPUser,
+ public VPValue {
   bool IsPtrLoopInvariant;
   SmallBitVector IsIndexLoopInvariant;
 
 public:
   template 
   VPWidenGEPRecipe(GetElementPtrInst *GEP, iterator_range Operands)
-  : VPRecipeBase(VPRecipeBase::VPWidenGEPSC), VPValue(VPWidenGEPSC, GEP),
-VPUser(Operands), IsIndexLoopInvariant(GEP->getNumIndices(), false) {}
+  : VPRecipeBase(VPRecipeBase::VPWidenGEPSC), VPUser(Operands),
+VPValue(VPWidenGEPSC, GEP, this),
+IsIndexLoopInvariant(GEP->getNumIndices(), false) {}
 
   template 
   VPWidenGEPRecipe(GetElementPtrInst *GEP, iterator_range Operands,
Loop *OrigLoop)
-  : VPRecipeBase(VPRecipeBase::VPWidenGEPSC),
-VPValue(VPValue::VPVWidenGEPSC, GEP), VPUser(Operands),
+  : VPRecipeBase(VPRecipeBase::VPWidenGEPSC), VPUser(Operands),
+VPValue(VPValue::VPVWidenGEPSC, GEP, this),
 IsIndexLoopInvariant(GEP->getNumIndices(), false) {
 IsPtrLoopInvariant = OrigLoop->isLoopInvariant(GEP->getPointerOperand());
 for (auto Index : enumerate(GEP->indices()))



___
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] 8a7e770 - [LV] Add reduction test, which exposed a crash in a pending patch.

2020-12-15 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-15T09:42:00Z
New Revision: 8a7e770638f00c5c8657044b44ca34f471d29511

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

LOG: [LV] Add reduction test, which exposed a crash in a pending patch.

Added: 
llvm/test/Transforms/LoopVectorize/select-reduction.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/LoopVectorize/select-reduction.ll 
b/llvm/test/Transforms/LoopVectorize/select-reduction.ll
new file mode 100644
index ..579cf5df2860
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/select-reduction.ll
@@ -0,0 +1,86 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -loop-vectorize -S %s | FileCheck %s
+
+target datalayout = 
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.15.0"
+
+define i32 @test(i64 %N, i32 %x) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[EXTRA_ITER:%.*]] = and i64 [[N:%.*]], 7
+; CHECK-NEXT:br label [[CHECK:%.*]]
+; CHECK:   check:
+; CHECK-NEXT:[[EXTRA_ITER_CHECK:%.*]] = icmp eq i64 [[EXTRA_ITER]], 0
+; CHECK-NEXT:br i1 [[EXTRA_ITER_CHECK]], label [[EXIT:%.*]], label 
[[LOOP_PREHEADER:%.*]]
+; CHECK:   loop.preheader:
+; CHECK-NEXT:br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
+; CHECK:   vector.ph:
+; CHECK-NEXT:[[N_RND_UP:%.*]] = add i64 [[EXTRA_ITER]], 3
+; CHECK-NEXT:[[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], 4
+; CHECK-NEXT:[[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
+; CHECK-NEXT:[[IND_END:%.*]] = sub i64 [[EXTRA_ITER]], [[N_VEC]]
+; CHECK-NEXT:[[TRIP_COUNT_MINUS_1:%.*]] = sub i64 [[EXTRA_ITER]], 1
+; CHECK-NEXT:[[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i64> 
undef, i64 [[TRIP_COUNT_MINUS_1]], i32 0
+; CHECK-NEXT:[[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i64> 
[[BROADCAST_SPLATINSERT]], <4 x i64> undef, <4 x i32> zeroinitializer
+; CHECK-NEXT:br label [[VECTOR_BODY:%.*]]
+; CHECK:   vector.body:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[VEC_PHI:%.*]] = phi <4 x i32> [ zeroinitializer, 
[[VECTOR_PH]] ], [ [[TMP3:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[OFFSET_IDX:%.*]] = sub i64 [[EXTRA_ITER]], [[INDEX]]
+; CHECK-NEXT:[[BROADCAST_SPLATINSERT1:%.*]] = insertelement <4 x i64> 
undef, i64 [[OFFSET_IDX]], i32 0
+; CHECK-NEXT:[[BROADCAST_SPLAT2:%.*]] = shufflevector <4 x i64> 
[[BROADCAST_SPLATINSERT1]], <4 x i64> undef, <4 x i32> zeroinitializer
+; CHECK-NEXT:[[INDUCTION:%.*]] = add <4 x i64> [[BROADCAST_SPLAT2]], 
+; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[OFFSET_IDX]], 0
+; CHECK-NEXT:[[BROADCAST_SPLATINSERT3:%.*]] = insertelement <4 x i64> 
undef, i64 [[INDEX]], i32 0
+; CHECK-NEXT:[[BROADCAST_SPLAT4:%.*]] = shufflevector <4 x i64> 
[[BROADCAST_SPLATINSERT3]], <4 x i64> undef, <4 x i32> zeroinitializer
+; CHECK-NEXT:[[VEC_IV:%.*]] = add <4 x i64> [[BROADCAST_SPLAT4]], 
+; CHECK-NEXT:[[TMP1:%.*]] = icmp ule <4 x i64> [[VEC_IV]], 
[[BROADCAST_SPLAT]]
+; CHECK-NEXT:[[TMP2:%.*]] = icmp sgt <4 x i32> [[VEC_PHI]], 
+; CHECK-NEXT:[[TMP3]] = select <4 x i1> [[TMP2]], <4 x i32> [[VEC_PHI]], 
<4 x i32> 
+; CHECK-NEXT:[[TMP4:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[TMP3]], 
<4 x i32> [[VEC_PHI]]
+; CHECK-NEXT:[[INDEX_NEXT]] = add i64 [[INDEX]], 4
+; CHECK-NEXT:[[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
+; CHECK-NEXT:br i1 [[TMP5]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]]
+; CHECK:   middle.block:
+; CHECK-NEXT:[[TMP6:%.*]] = call i32 @llvm.vector.reduce.smax.v4i32(<4 x 
i32> [[TMP4]])
+; CHECK-NEXT:br i1 true, label [[EXIT_LOOPEXIT:%.*]], label [[SCALAR_PH]]
+; CHECK:   scalar.ph:
+; CHECK-NEXT:[[BC_RESUME_VAL:%.*]] = phi i64 [ [[IND_END]], 
[[MIDDLE_BLOCK]] ], [ [[EXTRA_ITER]], [[LOOP_PREHEADER]] ]
+; CHECK-NEXT:[[BC_MERGE_RDX:%.*]] = phi i32 [ 0, [[LOOP_PREHEADER]] ], [ 
[[TMP6]], [[MIDDLE_BLOCK]] ]
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:[[NEXT:%.*]] = phi i32 [ [[SEL:%.*]], [[LOOP]] ], [ 
[[BC_MERGE_RDX]], [[SCALAR_PH]] ]
+; CHECK-NEXT:[[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP]] ], [ 
[[BC_RESUME_VAL]], [[SCALAR_PH]] ]
+; CHECK-NEXT:[[SEL_COND:%.*]] = icmp sgt i32 [[NEXT]], 10
+; CHECK-NEXT:[[SEL]] = select i1 [[SEL_COND]], i32 [[NEXT]], i32 10
+; CHECK-NEXT:[[IV_NEXT]] = add nsw i64 [[IV]], -1
+; CHECK-NEXT:[[EC:%.*]] = icmp eq i64 [[IV_NEXT]], 0
+; CHECK-NEXT:br i1 [[EC]], label [[EXIT_LOOPEXIT]], label [[LOOP]], 
[[LOOP2:!llvm.loop !.*]]
+; CHECK:   exit.loopexit:
+; CHECK-NEXT:[[SEL_L

[llvm-branch-commits] [llvm] 15a3138 - [X86][AVX] LowerBUILD_VECTOR - reduce 256/512-bit build vectors with zero/undef upper elements + pad.

2020-12-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-15T10:11:38Z
New Revision: 15a31389b2ead8fa7052a4378b76b5d686d29ad7

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

LOG: [X86][AVX] LowerBUILD_VECTOR - reduce 256/512-bit build vectors with 
zero/undef upper elements + pad.

As discussed on D92645, we don't do a good job of recognising when we don't 
require the full width of a ymm/zmm build vector because the upper elements are 
undef/zero.

This commit allows us to make use of implicit zeroing of upper elements with 
AVX instructions, which we emulate in DAG with a INSERT_SUBVECTOR into the 
bottom of a undef/zero vector of the original type.

This exposed a limitation in getTargetConstantBitsFromNode which didn't extract 
bits from INSERT_SUBVECTORs of different element widths which I've included as 
well to prevent a couple of regressions.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx512-shuffles/partial_permute.ll
llvm/test/CodeGen/X86/pr29112.ll
llvm/test/CodeGen/X86/pr46532.ll
llvm/test/CodeGen/X86/shuffle-vs-trunc-512.ll
llvm/test/CodeGen/X86/trunc-subvector.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v16.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v32.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll
llvm/test/CodeGen/X86/vector-shuffle-512-v16.ll
llvm/test/CodeGen/X86/vector-shuffle-512-v8.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 21af1a5aad00..78d08b36f8bf 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -6673,23 +6673,26 @@ static bool getTargetConstantBitsFromNode(SDValue Op, 
unsigned EltSizeInBits,
 
   // Insert constant bits from a base and sub vector sources.
   if (Op.getOpcode() == ISD::INSERT_SUBVECTOR) {
-// TODO - support insert_subvector through bitcasts.
-if (EltSizeInBits != VT.getScalarSizeInBits())
-  return false;
+// If bitcasts to larger elements we might lose track of undefs - don't
+// allow any to be safe.
+unsigned SrcEltSizeInBits = VT.getScalarSizeInBits();
+bool AllowUndefs = EltSizeInBits >= SrcEltSizeInBits;
 
-APInt UndefSubElts;
-SmallVector EltSubBits;
-if (getTargetConstantBitsFromNode(Op.getOperand(1), EltSizeInBits,
+APInt UndefSrcElts, UndefSubElts;
+SmallVector EltSrcBits, EltSubBits;
+if (getTargetConstantBitsFromNode(Op.getOperand(1), SrcEltSizeInBits,
   UndefSubElts, EltSubBits,
-  AllowWholeUndefs, AllowPartialUndefs) &&
-getTargetConstantBitsFromNode(Op.getOperand(0), EltSizeInBits,
-  UndefElts, EltBits, AllowWholeUndefs,
-  AllowPartialUndefs)) {
+  AllowWholeUndefs && AllowUndefs,
+  AllowPartialUndefs && AllowUndefs) &&
+getTargetConstantBitsFromNode(Op.getOperand(0), SrcEltSizeInBits,
+  UndefSrcElts, EltSrcBits,
+  AllowWholeUndefs && AllowUndefs,
+  AllowPartialUndefs && AllowUndefs)) {
   unsigned BaseIdx = Op.getConstantOperandVal(2);
-  UndefElts.insertBits(UndefSubElts, BaseIdx);
+  UndefSrcElts.insertBits(UndefSubElts, BaseIdx);
   for (unsigned i = 0, e = EltSubBits.size(); i != e; ++i)
-EltBits[BaseIdx + i] = EltSubBits[i];
-  return true;
+EltSrcBits[BaseIdx + i] = EltSubBits[i];
+  return CastBitData(UndefSrcElts, EltSrcBits);
 }
   }
 
@@ -10165,17 +10168,8 @@ X86TargetLowering::LowerBUILD_VECTOR(SDValue Op, 
SelectionDAG &DAG) const {
   if (SDValue VectorConstant = materializeVectorConstant(Op, DAG, Subtarget))
 return VectorConstant;
 
-  BuildVectorSDNode *BV = cast(Op.getNode());
-  if (SDValue AddSub = lowerToAddSubOrFMAddSub(BV, Subtarget, DAG))
-return AddSub;
-  if (SDValue HorizontalOp = LowerToHorizontalOp(BV, Subtarget, DAG))
-return HorizontalOp;
-  if (SDValue Broadcast = lowerBuildVectorAsBroadcast(BV, Subtarget, DAG))
-return Broadcast;
-  if (SDValue BitOp = lowerBuildVectorToBitOp(BV, Subtarget, DAG))
-return BitOp;
-
   unsigned EVTBits = EltVT.getSizeInBits();
+  APInt UndefMask = APInt::getNullValue(NumElems);
   APInt ZeroMask = APInt::getNullValue(NumElems);
   APInt NonZeroMask = APInt::getNullValue(NumElems);
   bool IsAllConstants = true;
@@ -10183,8 +10177,10 @@ X86TargetLowering::LowerBUILD_VECTOR(SDValue Op, 
SelectionDAG &DAG) const {
   unsigned NumConstants = NumElems;
   for (unsigned i = 0; i < NumElems; ++i) {
 SDValue Elt = 

[llvm-branch-commits] [llvm] bd07092 - [X86] Remove trailing whitespace. NFC.

2020-12-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-15T10:11:38Z
New Revision: bd0709266911bce2f1e8a875f9ed49d56953f323

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

LOG: [X86] Remove trailing whitespace. NFC.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 78d08b36f8bf..bd904327f8e7 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -5172,7 +5172,7 @@ bool X86TargetLowering::shouldReduceLoadWidth(SDNode 
*Load,
   ISD::LoadExtType ExtTy,
   EVT NewVT) const {
   assert(cast(Load)->isSimple() && "illegal to narrow");
-  
+
   // "ELF Handling for Thread-Local Storage" specifies that R_X86_64_GOTTPOFF
   // relocation target a movq or addq instruction: don't let the load shrink.
   SDValue BasePtr = cast(Load)->getBasePtr();



___
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] 6d35bd1 - [CodeGenPrepare] Update optimizeGatherScatterInst for scalable vectors.

2020-12-15 Thread Paul Walker via llvm-branch-commits

Author: Paul Walker
Date: 2020-12-15T10:57:51Z
New Revision: 6d35bd1d48e9fdde38483e6b22a900daa7e3d46a

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

LOG: [CodeGenPrepare] Update optimizeGatherScatterInst for scalable vectors.

optimizeGatherScatterInst does nothing specific to fixed length vectors
but uses FixedVectorType to extract the number of elements.  This patch
simply updates the code to use VectorType and getElementCount instead.

For testing I just copied Transforms/CodeGenPrepare/X86/gather-scatter-opt.ll
replacing `<4 x ` with `https://reviews.llvm.org/D92572

Added: 
llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt.ll

Modified: 
llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp 
b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 9b44b30e7a1b..8fe5cb9faba4 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5304,14 +5304,10 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction 
*MemoryInst, Value *Addr,
 ///
 /// If the final index isn't a vector or is a splat, we can emit a scalar GEP
 /// followed by a GEP with an all zeroes vector index. This will enable
-/// SelectionDAGBuilder to use a the scalar GEP as the uniform base and have a
+/// SelectionDAGBuilder to use the scalar GEP as the uniform base and have a
 /// zero index.
 bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
Value *Ptr) {
-  // FIXME: Support scalable vectors.
-  if (isa(Ptr->getType()))
-return false;
-
   Value *NewAddr;
 
   if (const auto *GEP = dyn_cast(Ptr)) {
@@ -5370,7 +5366,7 @@ bool 
CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
 if (!RewriteGEP && Ops.size() == 2)
   return false;
 
-unsigned NumElts = cast(Ptr->getType())->getNumElements();
+auto NumElts = cast(Ptr->getType())->getElementCount();
 
 IRBuilder<> Builder(MemoryInst);
 
@@ -5380,7 +5376,7 @@ bool 
CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
 // and a vector GEP with all zeroes final index.
 if (!Ops[FinalIndex]->getType()->isVectorTy()) {
   NewAddr = Builder.CreateGEP(Ops[0], makeArrayRef(Ops).drop_front());
-  auto *IndexTy = FixedVectorType::get(ScalarIndexTy, NumElts);
+  auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
   NewAddr = Builder.CreateGEP(NewAddr, Constant::getNullValue(IndexTy));
 } else {
   Value *Base = Ops[0];
@@ -5403,13 +5399,13 @@ bool 
CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
 if (!V)
   return false;
 
-unsigned NumElts = cast(Ptr->getType())->getNumElements();
+auto NumElts = cast(Ptr->getType())->getElementCount();
 
 IRBuilder<> Builder(MemoryInst);
 
 // Emit a vector GEP with a scalar pointer and all 0s vector index.
 Type *ScalarIndexTy = DL->getIndexType(V->getType()->getScalarType());
-auto *IndexTy = FixedVectorType::get(ScalarIndexTy, NumElts);
+auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
 NewAddr = Builder.CreateGEP(V, Constant::getNullValue(IndexTy));
   } else {
 // Constant, SelectionDAGBuilder knows to check if its a splat.

diff  --git a/llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt.ll 
b/llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt.ll
new file mode 100644
index ..08011b6b5b6a
--- /dev/null
+++ b/llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt.ll
@@ -0,0 +1,113 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -codegenprepare < %s | FileCheck %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+%struct.a = type { i32, i32 }
+@c = external dso_local global %struct.a, align 4
+@glob_array = internal unnamed_addr constant [16 x i32] [i32 1, i32 1, i32 2, 
i32 3, i32 5, i32 8, i32 13, i32 21, i32 34, i32 55, i32 89, i32 144, i32 233, 
i32 377, i32 610, i32 987], align 16
+
+define  @splat_base(i32* %base,  %index, 
 %mask) #0 {
+; CHECK-LABEL: @splat_base(
+; CHECK-NEXT:[[TMP1:%.*]] = getelementptr i32, i32* [[BASE:%.*]],  [[INDEX:%.*]]
+; CHECK-NEXT:[[RES:%.*]] = call  
@llvm.masked.gather.nxv4i32.nxv4p0i32( [[TMP1]], i32 4, 
 [[MASK:%.*]],  undef)
+; CHECK-NEXT:ret  [[RES]]
+;
+  %broadcast.splatinsert = insertelement  undef, i32* 
%base, i32 0
+  %broadcast.splat = shufflevector  %broadcast.splatinsert, 
 undef,  zeroinitializer
+  %gep = getelementptr i32,  %broadcast.splat,  %index
+  %res = call  @llvm.masked.gather.nxv4i32.nxv4p0i32( %gep, i32 4,  %mask,  undef)
+  ret  %res
+}
+
+define  @splat_struct(%struct.a* %base,  
%mask) #0 {
+; CHECK-LABEL: @splat_struct(
+; CHECK-NEXT:[[TMP1:%.*]] = getel

[llvm-branch-commits] [llvm] b74c4db - [SVE] Move INT_TO_FP i1 promotion into custom lowering.

2020-12-15 Thread Paul Walker via llvm-branch-commits

Author: Paul Walker
Date: 2020-12-15T11:57:07Z
New Revision: b74c4dbb9634f6210c6539fb4c09b0b68cb3cf0a

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

LOG: [SVE] Move INT_TO_FP i1 promotion into custom lowering.

AddPromotedToType is being used to legalise INT_TO_FP operations
when the source is a predicate. The point where this introduces
vector extends might cause problems in the future so this patch
falls back to manual promotion within custom lowering.

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 0d4dba6dcecf..f7ba135ad946 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -147,7 +147,7 @@ static inline EVT getPackedSVEVectorVT(EVT VT) {
   }
 }
 
-static inline MVT getPromotedVTForPredicate(MVT VT) {
+static inline EVT getPromotedVTForPredicate(EVT VT) {
   assert(VT.isScalableVector() && (VT.getVectorElementType() == MVT::i1) &&
  "Expected scalable predicate vector type!");
   switch (VT.getVectorMinNumElements()) {
@@ -1113,10 +1113,8 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
 
   // There are no legal MVT::nxv16f## based types.
   if (VT != MVT::nxv16i1) {
-setOperationAction(ISD::SINT_TO_FP, VT, Promote);
-AddPromotedToType(ISD::SINT_TO_FP, VT, getPromotedVTForPredicate(VT));
-setOperationAction(ISD::UINT_TO_FP, VT, Promote);
-AddPromotedToType(ISD::UINT_TO_FP, VT, getPromotedVTForPredicate(VT));
+setOperationAction(ISD::SINT_TO_FP, VT, Custom);
+setOperationAction(ISD::UINT_TO_FP, VT, Custom);
   }
 }
 
@@ -3179,11 +3177,20 @@ SDValue 
AArch64TargetLowering::LowerVectorINT_TO_FP(SDValue Op,
   SDLoc dl(Op);
   SDValue In = Op.getOperand(0);
   EVT InVT = In.getValueType();
+  unsigned Opc = Op.getOpcode();
+  bool IsSigned = Opc == ISD::SINT_TO_FP || Opc == ISD::STRICT_SINT_TO_FP;
 
   if (VT.isScalableVector()) {
-unsigned Opcode = Op.getOpcode() == ISD::UINT_TO_FP
-  ? AArch64ISD::UINT_TO_FP_MERGE_PASSTHRU
-  : AArch64ISD::SINT_TO_FP_MERGE_PASSTHRU;
+if (InVT.getVectorElementType() == MVT::i1) {
+  // We can't directly extend an SVE predicate; extend it first.
+  unsigned CastOpc = IsSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
+  EVT CastVT = getPromotedVTForPredicate(InVT);
+  In = DAG.getNode(CastOpc, dl, CastVT, In);
+  return DAG.getNode(Opc, dl, VT, In);
+}
+
+unsigned Opcode = IsSigned ? AArch64ISD::SINT_TO_FP_MERGE_PASSTHRU
+   : AArch64ISD::UINT_TO_FP_MERGE_PASSTHRU;
 return LowerToPredicatedOp(Op, DAG, Opcode);
   }
 
@@ -3193,16 +3200,15 @@ SDValue 
AArch64TargetLowering::LowerVectorINT_TO_FP(SDValue Op,
 MVT CastVT =
 MVT::getVectorVT(MVT::getFloatingPointVT(InVT.getScalarSizeInBits()),
  InVT.getVectorNumElements());
-In = DAG.getNode(Op.getOpcode(), dl, CastVT, In);
+In = DAG.getNode(Opc, dl, CastVT, In);
 return DAG.getNode(ISD::FP_ROUND, dl, VT, In, DAG.getIntPtrConstant(0, 
dl));
   }
 
   if (VTSize > InVTSize) {
-unsigned CastOpc =
-Op.getOpcode() == ISD::SINT_TO_FP ? ISD::SIGN_EXTEND : 
ISD::ZERO_EXTEND;
+unsigned CastOpc = IsSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
 EVT CastVT = VT.changeVectorElementTypeToInteger();
 In = DAG.getNode(CastOpc, dl, CastVT, In);
-return DAG.getNode(Op.getOpcode(), dl, VT, In);
+return DAG.getNode(Opc, dl, VT, In);
   }
 
   return Op;



___
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] e12f584 - [InstCombine] Remove scalable vector restriction in InstCombineCompares

2020-12-15 Thread Jun Ma via llvm-branch-commits

Author: Jun Ma
Date: 2020-12-15T20:36:57+08:00
New Revision: e12f584578006e877cc947cde17c8da86177e9cc

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

LOG: [InstCombine] Remove scalable vector restriction in InstCombineCompares

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

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/vscale_cmp.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d6285dcd387d..139b04bb6a81 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -899,8 +899,8 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator 
*GEPLHS, Value *RHS,
 // For vectors, we apply the same reasoning on a per-lane basis.
 auto *Base = GEPLHS->getPointerOperand();
 if (GEPLHS->getType()->isVectorTy() && Base->getType()->isPointerTy()) {
-  int NumElts = cast(GEPLHS->getType())->getNumElements();
-  Base = Builder.CreateVectorSplat(NumElts, Base);
+  auto EC = cast(GEPLHS->getType())->getElementCount();
+  Base = Builder.CreateVectorSplat(EC, Base);
 }
 return new ICmpInst(Cond, Base,
 ConstantExpr::getPointerBitCastOrAddrSpaceCast(
@@ -1885,8 +1885,7 @@ Instruction 
*InstCombinerImpl::foldICmpAndConstant(ICmpInst &Cmp,
 if (ExactLogBase2 != -1 && DL.isLegalInteger(ExactLogBase2 + 1)) {
   Type *NTy = IntegerType::get(Cmp.getContext(), ExactLogBase2 + 1);
   if (auto *AndVTy = dyn_cast(And->getType()))
-NTy = FixedVectorType::get(
-NTy, cast(AndVTy)->getNumElements());
+NTy = VectorType::get(NTy, AndVTy->getElementCount());
   Value *Trunc = Builder.CreateTrunc(X, NTy);
   auto NewPred = Cmp.getPredicate() == CmpInst::ICMP_EQ ? CmpInst::ICMP_SGE
 : 
CmpInst::ICMP_SLT;
@@ -2192,8 +2191,7 @@ Instruction 
*InstCombinerImpl::foldICmpShlConstant(ICmpInst &Cmp,
   DL.isLegalInteger(TypeBits - Amt)) {
 Type *TruncTy = IntegerType::get(Cmp.getContext(), TypeBits - Amt);
 if (auto *ShVTy = dyn_cast(ShType))
-  TruncTy = FixedVectorType::get(
-  TruncTy, cast(ShVTy)->getNumElements());
+  TruncTy = VectorType::get(TruncTy, ShVTy->getElementCount());
 Constant *NewC =
 ConstantInt::get(TruncTy, C.ashr(*ShiftAmt).trunc(TypeBits - Amt));
 return new ICmpInst(Pred, Builder.CreateTrunc(X, TruncTy), NewC);
@@ -2827,8 +2825,7 @@ static Instruction *foldICmpBitCast(ICmpInst &Cmp,
 
   Type *NewType = Builder.getIntNTy(XType->getScalarSizeInBits());
   if (auto *XVTy = dyn_cast(XType))
-NewType = FixedVectorType::get(
-NewType, cast(XVTy)->getNumElements());
+NewType = VectorType::get(NewType, XVTy->getElementCount());
   Value *NewBitcast = Builder.CreateBitCast(X, NewType);
   if (TrueIfSigned)
 return new ICmpInst(ICmpInst::ICMP_SLT, NewBitcast,
@@ -3411,8 +3408,8 @@ static Value *foldICmpWithLowBitMaskedVal(ICmpInst &I,
   // those elements by copying an existing, defined, and safe scalar constant.
   Type *OpTy = M->getType();
   auto *VecC = dyn_cast(M);
-  if (OpTy->isVectorTy() && VecC && VecC->containsUndefElement()) {
-auto *OpVTy = cast(OpTy);
+  auto *OpVTy = dyn_cast(OpTy);
+  if (OpVTy && VecC && VecC->containsUndefElement()) {
 Constant *SafeReplacementConstant = nullptr;
 for (unsigned i = 0, e = OpVTy->getNumElements(); i != e; ++i) {
   if (!isa(VecC->getAggregateElement(i))) {

diff  --git a/llvm/test/Transforms/InstCombine/vscale_cmp.ll 
b/llvm/test/Transforms/InstCombine/vscale_cmp.ll
index bbceab06e3fc..e7b8a2e3e3f2 100644
--- a/llvm/test/Transforms/InstCombine/vscale_cmp.ll
+++ b/llvm/test/Transforms/InstCombine/vscale_cmp.ll
@@ -9,3 +9,27 @@ define  @sge( %x) {
   %cmp = icmp sge  %x, zeroinitializer
   ret  %cmp
 }
+
+define  @gep_scalevector1(i32* %X) nounwind {
+; CHECK-LABEL: @gep_scalevector1(
+; CHECK-NEXT:[[S:%.*]] = insertelement  undef, i32* 
[[X:%.*]], i32 0
+; CHECK-NEXT:[[C:%.*]] = icmp eq  [[S]], zeroinitializer
+; CHECK-NEXT:[[C1:%.*]] = shufflevector  [[C]],  undef,  zeroinitializer
+; CHECK-NEXT:ret  [[C1]]
+;
+  %A = getelementptr inbounds i32, i32* %X,  zeroinitializer
+  %C = icmp eq  %A, zeroinitializer
+  ret  %C
+}
+
+define  @signbit_bitcast_fpext_scalevec( 
%x) {
+; CHECK-LABEL: @signbit_bitcast_fpext_scalevec(
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast  [[X:%.*]] to 

+; CHECK-NEXT:[[R:%.*]] = icmp slt  [[TMP1]], 
zeroinitializer
+; CHECK-NEXT:ret  [[R]]
+;
+  %f = fpext 

[llvm-branch-commits] [llvm] 2ac58e2 - [InstCombine] Remove scalable vector restriction when fold SelectInst

2020-12-15 Thread Jun Ma via llvm-branch-commits

Author: Jun Ma
Date: 2020-12-15T20:36:57+08:00
New Revision: 2ac58e21a115d16a91578defc4636c43e3608a2e

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

LOG: [InstCombine] Remove scalable vector restriction when fold SelectInst

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

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 6e94e5823433..e9ec8021e466 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -2322,13 +2322,11 @@ static Instruction *foldBitCastSelect(BitCastInst 
&BitCast,
   // A vector select must maintain the same number of elements in its operands.
   Type *CondTy = Cond->getType();
   Type *DestTy = BitCast.getType();
-  if (auto *CondVTy = dyn_cast(CondTy)) {
-if (!DestTy->isVectorTy())
+  if (auto *CondVTy = dyn_cast(CondTy))
+if (!DestTy->isVectorTy() ||
+CondVTy->getElementCount() !=
+cast(DestTy)->getElementCount())
   return nullptr;
-if (cast(DestTy)->getNumElements() !=
-cast(CondVTy)->getNumElements())
-  return nullptr;
-  }
 
   // FIXME: This transform is restricted from changing the select between
   // scalars and vectors to avoid backend problems caused by creating

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 397cb0b0e187..c32f6ace42db 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -283,10 +283,9 @@ Instruction *InstCombinerImpl::foldSelectOpOp(SelectInst 
&SI, Instruction *TI,
 // The select condition may be a vector. We may only change the operand
 // type if the vector width remains the same (and matches the condition).
 if (auto *CondVTy = dyn_cast(CondTy)) {
-  if (!FIOpndTy->isVectorTy())
-return nullptr;
-  if (cast(CondVTy)->getNumElements() !=
-  cast(FIOpndTy)->getNumElements())
+  if (!FIOpndTy->isVectorTy() ||
+  CondVTy->getElementCount() !=
+  cast(FIOpndTy)->getElementCount())
 return nullptr;
 
   // TODO: If the backend knew how to deal with casts better, we could

diff  --git a/llvm/test/Transforms/InstCombine/select.ll 
b/llvm/test/Transforms/InstCombine/select.ll
index 987f34e52ad2..819ac6dd3a82 100644
--- a/llvm/test/Transforms/InstCombine/select.ll
+++ b/llvm/test/Transforms/InstCombine/select.ll
@@ -68,6 +68,15 @@ define <2 x i1> @test8vec(<2 x i1> %C, <2 x i1> %X) {
   ret <2 x i1> %R
 }
 
+define  @test8vvec( %C,  
%X) {
+; CHECK-LABEL: @test8vvec(
+; CHECK-NEXT:[[R:%.*]] = and  [[C:%.*]],  [[X:%.*]]
+; CHECK-NEXT:ret  [[R]]
+;
+  %R = select  %C,  %X,  
zeroinitializer
+  ret  %R
+}
+
 define i1 @test9(i1 %C, i1 %X) {
 ; CHECK-LABEL: @test9(
 ; CHECK-NEXT:[[NOT_C:%.*]] = xor i1 [[C:%.*]], true
@@ -88,6 +97,16 @@ define <2 x i1> @test9vec(<2 x i1> %C, <2 x i1> %X) {
   ret <2 x i1> %R
 }
 
+define  @test9vvec( %C,  
%X) {
+; CHECK-LABEL: @test9vvec(
+; CHECK-NEXT:[[NOT_C:%.*]] = xor  [[C:%.*]], 
shufflevector ( insertelement ( undef, i1 
true, i32 0),  undef,  zeroinitializer)
+; CHECK-NEXT:[[R:%.*]] = and  [[NOT_C]], [[X:%.*]]
+; CHECK-NEXT:ret  [[R]]
+;
+  %R = select  %C,  zeroinitializer,  %X
+  ret  %R
+}
+
 define i1 @test10(i1 %C, i1 %X) {
 ; CHECK-LABEL: @test10(
 ; CHECK-NEXT:[[NOT_C:%.*]] = xor i1 [[C:%.*]], true
@@ -699,6 +718,34 @@ define i48 @test51(<3 x i1> %icmp, <3 x i16> %tmp) {
   ret i48 %tmp2
 }
 
+define  @bitcast_select_bitcast( %icmp, 
 %a,  %b) {
+; CHECK-LABEL: @bitcast_select_bitcast(
+; CHECK-NEXT:[[BC1:%.*]] = bitcast  [[A:%.*]] to 
+; CHECK-NEXT:[[SELECT:%.*]] = select  [[ICMP:%.*]], 
 [[B:%.*]],  [[BC1]]
+; CHECK-NEXT:ret  [[SELECT]]
+;
+  %bc1 = bitcast  %b to 
+  %select = select  %icmp,  %bc1,  %a
+  %bc2 = bitcast  %select to 
+  ret  %bc2
+}
+
+define void @select_oneuse_bitcast( %a,  %b,  %c,  %d, * 
%ptr1) {
+; CHECK-LABEL: @select_oneuse_bitcast(
+; CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[C:%.*]], [[D:%.*]]
+; CHECK-NEXT:[[SEL1_V:%.*]] = select  [[CMP]],  [[A:%.*]],  [[B:%.*]]
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast * [[PTR1:%.*]] to 
*
+; CHECK-NEXT:store  [[SEL1_V]], * 
[[TMP1]], align 16
+; CHECK-NEXT:ret void
+;
+  %cmp = icmp ult  %c, %d
+  %bc1 = bitcast  %a to 
+  %bc2 = bitcast  %b to 
+  %sel1 = select  %cmp,  %bc1,  %bc2
+  store  %sel1, * %ptr1
+  ret void
+}
+
 ; Allow select promotion ev

[llvm-branch-commits] [llvm] ffe84d9 - [InstCombine][NFC] Change cast of FixedVectorType to dyn_cast.

2020-12-15 Thread Jun Ma via llvm-branch-commits

Author: Jun Ma
Date: 2020-12-15T20:36:57+08:00
New Revision: ffe84d90e9a7279fafbdcaf70da03174a522ab62

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

LOG: [InstCombine][NFC] Change cast of FixedVectorType to dyn_cast.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index c32f6ace42db..d6f8d2dcc7ce 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1985,11 +1985,11 @@ Instruction 
*InstCombinerImpl::foldSelectExtConst(SelectInst &Sel) {
 static Instruction *canonicalizeSelectToShuffle(SelectInst &SI) {
   Value *CondVal = SI.getCondition();
   Constant *CondC;
-  if (!CondVal->getType()->isVectorTy() || !match(CondVal, m_Constant(CondC)))
+  auto *CondValTy = dyn_cast(CondVal->getType());
+  if (!CondValTy || !match(CondVal, m_Constant(CondC)))
 return nullptr;
 
-  unsigned NumElts =
-  cast(CondVal->getType())->getNumElements();
+  unsigned NumElts = CondValTy->getNumElements();
   SmallVector Mask;
   Mask.reserve(NumElts);
   for (unsigned i = 0; i != NumElts; ++i) {



___
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] 8b48d24 - [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Chuanqi Xu via llvm-branch-commits

Author: Chuanqi Xu
Date: 2020-12-15T20:50:46+08:00
New Revision: 8b48d24373204fc2fe6aac1f1f850fa3b6c18445

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

LOG: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid 
misleading pointer alignment

Summary: The clang-format may go wrong when handle c++ coroutine keywords and 
pointer.
The default value for PointerAlignment is PAS_Right. So the following format is 
good:
```
co_return *a;
```
But within some code style, the value for PointerAlignment is PAS_Left, the 
behavior goes wrong:
```
co_return* a;
```

test-plan: check-clang

reviewers: MyDeveloperDay

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index b1c9c37a8ed9..821b46b75f6b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1964,6 +1964,7 @@ class AnnotatingParser {
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
+   tok::kw_co_return, tok::kw_co_await, 
tok::kw_co_yield,
tok::equal, tok::kw_delete, tok::kw_sizeof,
tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 1c78b6e2cb1e..a3dbec9a669f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7755,6 +7755,15 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) {
 
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
+
+  // Check that * is not treated as a binary operator when we set 
PointerAlignment
+  // as PAS_Left after a keyword and not a declaration.
+  FormatStyle PASLeftStyle = getLLVMStyle();
+  PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("co_return *a;", PASLeftStyle);
+  verifyFormat("co_await *a;", PASLeftStyle);
+  verifyFormat("co_yield *a", PASLeftStyle);
+  verifyFormat("return *a;", PASLeftStyle);
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {



___
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] 0e0295f - [LV] Pass explicit vector width to not require a X86 target.

2020-12-15 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-15T12:52:22Z
New Revision: 0e0295fd6124163b478603a6cc357867aadf5d70

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

LOG: [LV] Pass explicit vector width to not require a X86 target.

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/select-reduction.ll

Removed: 




diff  --git a/llvm/test/Transforms/LoopVectorize/select-reduction.ll 
b/llvm/test/Transforms/LoopVectorize/select-reduction.ll
index 579cf5df2860..4c3ad8ee8aa9 100644
--- a/llvm/test/Transforms/LoopVectorize/select-reduction.ll
+++ b/llvm/test/Transforms/LoopVectorize/select-reduction.ll
@@ -1,8 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -loop-vectorize -S %s | FileCheck %s
+; RUN: opt -force-vector-width=4 -force-vector-interleave=1 -loop-vectorize -S 
%s | FileCheck %s
 
 target datalayout = 
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.15.0"
 
 define i32 @test(i64 %N, i32 %x) {
 ; CHECK-LABEL: @test(
@@ -42,7 +41,13 @@ define i32 @test(i64 %N, i32 %x) {
 ; CHECK-NEXT:[[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
 ; CHECK-NEXT:br i1 [[TMP5]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]]
 ; CHECK:   middle.block:
-; CHECK-NEXT:[[TMP6:%.*]] = call i32 @llvm.vector.reduce.smax.v4i32(<4 x 
i32> [[TMP4]])
+; CHECK-NEXT:[[RDX_SHUF:%.*]] = shufflevector <4 x i32> [[TMP4]], <4 x 
i32> undef, <4 x i32> 
+; CHECK-NEXT:[[RDX_MINMAX_CMP:%.*]] = icmp sgt <4 x i32> [[TMP4]], 
[[RDX_SHUF]]
+; CHECK-NEXT:[[RDX_MINMAX_SELECT:%.*]] = select <4 x i1> 
[[RDX_MINMAX_CMP]], <4 x i32> [[TMP4]], <4 x i32> [[RDX_SHUF]]
+; CHECK-NEXT:[[RDX_SHUF5:%.*]] = shufflevector <4 x i32> 
[[RDX_MINMAX_SELECT]], <4 x i32> undef, <4 x i32> 
+; CHECK-NEXT:[[RDX_MINMAX_CMP6:%.*]] = icmp sgt <4 x i32> 
[[RDX_MINMAX_SELECT]], [[RDX_SHUF5]]
+; CHECK-NEXT:[[RDX_MINMAX_SELECT7:%.*]] = select <4 x i1> 
[[RDX_MINMAX_CMP6]], <4 x i32> [[RDX_MINMAX_SELECT]], <4 x i32> [[RDX_SHUF5]]
+; CHECK-NEXT:[[TMP6:%.*]] = extractelement <4 x i32> 
[[RDX_MINMAX_SELECT7]], i32 0
 ; CHECK-NEXT:br i1 true, label [[EXIT_LOOPEXIT:%.*]], label [[SCALAR_PH]]
 ; CHECK:   scalar.ph:
 ; CHECK-NEXT:[[BC_RESUME_VAL:%.*]] = phi i64 [ [[IND_END]], 
[[MIDDLE_BLOCK]] ], [ [[EXTRA_ITER]], [[LOOP_PREHEADER]] ]



___
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] 965d71c - [clangd] Avoid traversing C:\ -> C: when looking for CDBs

2020-12-15 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-12-15T13:59:00+01:00
New Revision: 965d71c69acce658e9e3de00b25a351b00937820

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

LOG: [clangd] Avoid traversing C:\ -> C: when looking for CDBs

Boost in its infinite wisdom considers C: a parent of C:\, and we've
inherited that. This breaks the assumption that after canonicalizing a
path, the path parents are the directory's parents.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 23e8c9fe716d..20139c12abed 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -29,13 +29,27 @@ namespace clang {
 namespace clangd {
 namespace {
 
+// Variant of parent_path that operates only on absolute paths.
+PathRef absoluteParent(PathRef Path) {
+  assert(llvm::sys::path::is_absolute(Path));
+#if defined(_WIN32)
+  // llvm::sys says "C:\" is absolute, and its parent is "C:" which is 
relative.
+  // This unhelpful behavior seems to have been inherited from boost.
+  if (llvm::sys::path::relative_path(Path)).empty(); {
+return PathRef();
+  }
+#endif
+  PathRef Result = llvm::sys::path::parent_path(Path);
+  assert(Result.empty() || llvm::sys::path::is_absolute(Result));
+  return Result;
+}
+
 // Runs the given action on all parent directories of filename, starting from
 // deepest directory and going up to root. Stops whenever action succeeds.
 void actOnAllParentDirectories(PathRef FileName,
llvm::function_ref Action) {
-  for (auto Path = llvm::sys::path::parent_path(FileName);
-   !Path.empty() && !Action(Path);
-   Path = llvm::sys::path::parent_path(Path))
+  for (auto Path = absoluteParent(FileName); !Path.empty() && !Action(Path);
+   Path = absoluteParent(Path))
 ;
 }
 



___
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] 92dd077 - Reland [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-15 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-12-15T14:00:03+01:00
New Revision: 92dd077af1ff89929f5502c6c887358f51d5afc1

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

LOG: Reland [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

This reverts commit 4d956af594c5adc9d566d1846d86dd89c70c9c0b.

Assertion failures on windows fixed by
965d71c69acce658e9e3de00b25a351b00937820

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 20139c12abed..bad9c359798e 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -16,11 +16,13 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
+#include 
 #include 
 #include 
 #include 
@@ -72,10 +74,117 @@ GlobalCompilationDatabase::getFallbackCommand(PathRef 
File) const {
   return Cmd;
 }
 
+// Loads and caches the CDB from a single directory.
+//
+// This class is threadsafe, which is to say we have independent locks for each
+// directory we're searching for a CDB.
+// Loading is deferred until first access.
+//
+// The DirectoryBasedCDB keeps a map from path => DirectoryCache.
+// Typical usage is to:
+//  - 1) determine all the paths that might be searched
+//  - 2) acquire the map lock and get-or-create all the DirectoryCache entries
+//  - 3) release the map lock and query the caches as desired
+//
+// FIXME: this should revalidate the cache sometimes
+// FIXME: IO should go through a VFS
+class DirectoryBasedGlobalCompilationDatabase::DirectoryCache {
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  const std::string Path;
+
+  // True if we've looked for a CDB here and found none.
+  // (This makes it possible for get() to return without taking a lock)
+  // FIXME: this should have an expiry time instead of lasting forever.
+  std::atomic FinalizedNoCDB = {false};
+
+  // Guards following cache state.
+  std::mutex Mu;
+  // Has cache been filled from disk? FIXME: this should be an expiry time.
+  bool CachePopulated = false;
+  // Whether a new CDB has been loaded but not broadcast yet.
+  bool NeedsBroadcast = false;
+  // Last loaded CDB, meaningful if CachePopulated is set.
+  // shared_ptr so we can overwrite this when callers are still using the CDB.
+  std::shared_ptr CDB;
+
+public:
+  DirectoryCache(llvm::StringRef Path) : Path(Path) {
+assert(llvm::sys::path::is_absolute(Path));
+  }
+
+  // Get the CDB associated with this directory.
+  // ShouldBroadcast:
+  //  - as input, signals whether the caller is willing to broadcast a
+  //newly-discovered CDB. (e.g. to trigger background indexing)
+  //  - as output, signals whether the caller should do so.
+  // (If a new CDB is discovered and ShouldBroadcast is false, we mark the
+  // CDB as needing broadcast, and broadcast it next time we can).
+  std::shared_ptr
+  get(bool &ShouldBroadcast) {
+// Fast path for common case without taking lock.
+if (FinalizedNoCDB.load()) {
+  ShouldBroadcast = false;
+  return nullptr;
+}
+std::lock_guard Lock(Mu);
+auto RequestBroadcast = llvm::make_scope_exit([&, OldCDB(CDB.get())] {
+  // If we loaded a new CDB, it should be broadcast at some point.
+  if (CDB != nullptr && CDB.get() != OldCDB)
+NeedsBroadcast = true;
+  else if (CDB == nullptr) // nothing to broadcast anymore!
+NeedsBroadcast = false;
+  // If we have something to broadcast, then do so iff allowed.
+  if (!ShouldBroadcast)
+return;
+  ShouldBroadcast = NeedsBroadcast;
+  NeedsBroadcast = false;
+});
+
+// For now, we never actually attempt to revalidate a populated cache.
+if (CachePopulated)
+  return CDB;
+assert(CDB == nullptr);
+
+load();
+CachePopulated = true;
+
+if (!CDB)
+  FinalizedNoCDB.store(true);
+return CDB;
+  }
+
+  llvm::StringRef path() const { return Path; }
+
+private:
+  // Updates `CDB` from disk state.
+  void load() {
+std::string Error; // ignored, because it's often "didn't find anything".
+CDB = tooling::CompilationDatabase::loadFromDirectory(Path, Error);
+if (!CDB) {
+  // Fallback: check for $src/build, the conventional CMake build root.
+  // Probe existence first to avoid each plugin doing IO if it doesn't
+  /

[llvm-branch-commits] [llvm] 52a3267 - [InstCombine] Remove scalable vector restriction in foldVectorBinop

2020-12-15 Thread Jun Ma via llvm-branch-commits

Author: Jun Ma
Date: 2020-12-15T21:14:59+08:00
New Revision: 52a3267ffafc27d2dbe3d419256f18a4a9d8c681

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

LOG: [InstCombine] Remove scalable vector restriction in foldVectorBinop

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

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/fold-bin-operand.ll
llvm/test/Transforms/InstCombine/vec-binop-select.ll
llvm/test/Transforms/InstCombine/vec_shuffle.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index bbc76325a67b..9306e99f5d52 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -959,8 +959,7 @@ Instruction *InstCombinerImpl::FoldOpIntoSelect(Instruction 
&Op,
   return nullptr;
 
 // If vectors, verify that they have the same number of elements.
-if (SrcTy && cast(SrcTy)->getNumElements() !=
- cast(DestTy)->getNumElements())
+if (SrcTy && SrcTy->getElementCount() != DestTy->getElementCount())
   return nullptr;
   }
 
@@ -1515,8 +1514,7 @@ Value *InstCombinerImpl::Descale(Value *Val, APInt Scale, 
bool &NoSignedWrap) {
 }
 
 Instruction *InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
-  // FIXME: some of this is likely fine for scalable vectors
-  if (!isa(Inst.getType()))
+  if (!isa(Inst.getType()))
 return nullptr;
 
   BinaryOperator::BinaryOps Opcode = Inst.getOpcode();
@@ -1605,13 +1603,16 @@ Instruction 
*InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
   // intends to move shuffles closer to other shuffles and binops closer to
   // other binops, so they can be folded. It may also enable demanded elements
   // transforms.
-  unsigned NumElts = cast(Inst.getType())->getNumElements();
   Constant *C;
-  if (match(&Inst,
+  auto *InstVTy = dyn_cast(Inst.getType());
+  if (InstVTy &&
+  match(&Inst,
 m_c_BinOp(m_OneUse(m_Shuffle(m_Value(V1), m_Undef(), 
m_Mask(Mask))),
-  m_Constant(C))) && !isa(C) &&
-  cast(V1->getType())->getNumElements() <= NumElts) {
-assert(Inst.getType()->getScalarType() == V1->getType()->getScalarType() &&
+  m_Constant(C))) &&
+  !isa(C) &&
+  cast(V1->getType())->getNumElements() <=
+  InstVTy->getNumElements()) {
+assert(InstVTy->getScalarType() == V1->getType()->getScalarType() &&
"Shuffle should not change scalar type");
 
 // Find constant NewC that has property:
@@ -1626,6 +1627,7 @@ Instruction 
*InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
 UndefValue *UndefScalar = UndefValue::get(C->getType()->getScalarType());
 SmallVector NewVecC(SrcVecNumElts, UndefScalar);
 bool MayChange = true;
+unsigned NumElts = InstVTy->getNumElements();
 for (unsigned I = 0; I < NumElts; ++I) {
   Constant *CElt = C->getAggregateElement(I);
   if (ShMask[I] >= 0) {
@@ -2379,9 +2381,9 @@ Instruction 
*InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
  DL.getTypeAllocSize(ArrTy) == DL.getTypeAllocSize(VecTy);
 };
 if (GEP.getNumOperands() == 3 &&
-((GEPEltType->isArrayTy() && SrcEltType->isVectorTy() &&
+((GEPEltType->isArrayTy() && isa(SrcEltType) &&
   areMatchingArrayAndVecTypes(GEPEltType, SrcEltType, DL)) ||
- (GEPEltType->isVectorTy() && SrcEltType->isArrayTy() &&
+ (isa(GEPEltType) && SrcEltType->isArrayTy() &&
   areMatchingArrayAndVecTypes(SrcEltType, GEPEltType, DL {
 
   // Create a new GEP here, as using `setOperand()` followed by

diff  --git a/llvm/test/Transforms/InstCombine/fold-bin-operand.ll 
b/llvm/test/Transforms/InstCombine/fold-bin-operand.ll
index d3303262be3f..fc0c13a5f1a7 100644
--- a/llvm/test/Transforms/InstCombine/fold-bin-operand.ll
+++ b/llvm/test/Transforms/InstCombine/fold-bin-operand.ll
@@ -1,17 +1,73 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 target datalayout = 
"E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
 
 define i1 @f(i1 %x) {
 ; CHECK-LABEL: @f(
-; CHECK: ret i1 false
-   %b = and i1 %x, icmp eq (i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 
2 to i8*))
-   ret i1 %b
+; CHECK-NEXT:ret i1 false
+;
+  %b = and i1 %x, icmp eq (i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 2 to 
i8*))
+  ret i1 %b
 }
 
 define i32 @g(i32 %x) {
 ; CHECK-LABEL: @g(
-; CHECK: ret i32 %x
-   %b = add i32 %x, zext (i1 icmp eq (i8* inttoptr (

[llvm-branch-commits] [clang-tools-extra] 5186eda - [clangd] Oops, fix code in #ifdef WIN32

2020-12-15 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-12-15T14:17:54+01:00
New Revision: 5186eda3269333b2fb38800e9ded2a27ae87f99b

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

LOG: [clangd] Oops, fix code in #ifdef WIN32

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index bad9c359798e..add0eec4a2c8 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -37,7 +37,7 @@ PathRef absoluteParent(PathRef Path) {
 #if defined(_WIN32)
   // llvm::sys says "C:\" is absolute, and its parent is "C:" which is 
relative.
   // This unhelpful behavior seems to have been inherited from boost.
-  if (llvm::sys::path::relative_path(Path)).empty(); {
+  if (llvm::sys::path::relative_path(Path).empty()) {
 return PathRef();
   }
 #endif



___
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] [openmp] 171ca93 - [OpenMP] Initialize runtime in the forked child process

2020-12-15 Thread Hansang Bae via llvm-branch-commits

Author: Hansang Bae
Date: 2020-12-15T07:29:28-06:00
New Revision: 171ca93c543098d5e0bef459847de14cf17b5faf

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

LOG: [OpenMP] Initialize runtime in the forked child process

This patch enables serial initialization in the forked child process
to fix unstable runtime behavior when used with Python-based AI tools.

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

Added: 


Modified: 
openmp/runtime/src/z_Linux_util.cpp

Removed: 




diff  --git a/openmp/runtime/src/z_Linux_util.cpp 
b/openmp/runtime/src/z_Linux_util.cpp
index 15237d631958..d039a454f00d 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1272,8 +1272,8 @@ static void __kmp_atfork_prepare(void) {
 }
 
 static void __kmp_atfork_parent(void) {
-  __kmp_release_bootstrap_lock(&__kmp_initz_lock);
   __kmp_release_bootstrap_lock(&__kmp_forkjoin_lock);
+  __kmp_release_bootstrap_lock(&__kmp_initz_lock);
 }
 
 /* Reset the library so execution in the child starts "all over again" with
@@ -1281,6 +1281,7 @@ static void __kmp_atfork_parent(void) {
allocated by parent, just abandon it to be safe. */
 static void __kmp_atfork_child(void) {
   __kmp_release_bootstrap_lock(&__kmp_forkjoin_lock);
+  __kmp_release_bootstrap_lock(&__kmp_initz_lock);
   /* TODO make sure this is done right for nested/sibling */
   // ATT:  Memory leaks are here? TODO: Check it and fix.
   /* KMP_ASSERT( 0 ); */
@@ -1302,7 +1303,6 @@ static void __kmp_atfork_child(void) {
   }
 #endif // KMP_AFFINITY_SUPPORTED
 
-  __kmp_init_runtime = FALSE;
 #if KMP_USE_MONITOR
   __kmp_init_monitor = 0;
 #endif
@@ -1355,6 +1355,8 @@ static void __kmp_atfork_child(void) {
   __kmp_itt_reset(); // reset ITT's global state
 #endif /* USE_ITT_BUILD */
 
+  __kmp_serial_initialize();
+
   /* This is necessary to make sure no stale data is left around */
   /* AC: customers complain that we use unsafe routines in the atfork
  handler. Mathworks: dlsym() is unsafe. We call dlsym and dlopen



___
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] 7898803 - [AMDGPU][NFC] Add more global_atomic_cmpswap tests

2020-12-15 Thread Sebastian Neubauer via llvm-branch-commits

Author: Sebastian Neubauer
Date: 2020-12-15T14:47:33+01:00
New Revision: 7898803c638497ad32e2d4a189d5597d4eb4506e

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

LOG: [AMDGPU][NFC] Add more global_atomic_cmpswap tests

Added: 


Modified: 
llvm/test/MC/AMDGPU/flat-global.s
llvm/test/MC/AMDGPU/gfx9_asm_all.s
llvm/test/MC/Disassembler/AMDGPU/gfx10_dasm_all.txt
llvm/test/MC/Disassembler/AMDGPU/gfx9_dasm_all.txt

Removed: 




diff  --git a/llvm/test/MC/AMDGPU/flat-global.s 
b/llvm/test/MC/AMDGPU/flat-global.s
index e6c25f3f83f6..91c10ae13723 100644
--- a/llvm/test/MC/AMDGPU/flat-global.s
+++ b/llvm/test/MC/AMDGPU/flat-global.s
@@ -232,9 +232,29 @@ global_atomic_cmpswap v[3:4], v[5:6], off
 // GFX9: global_atomic_cmpswap v[3:4], v[5:6], off ; encoding: 
[0x00,0x80,0x04,0xdd,0x03,0x05,0x7f,0x00]
 // VI-ERR: error: instruction not supported on this GPU
 
-global_atomic_cmpswap_x2 v[3:4], v[5:8], off
-// GFX10: encoding: [0x00,0x80,0x44,0xdd,0x03,0x05,0x7d,0x00]
-// GFX9: global_atomic_cmpswap_x2 v[3:4], v[5:8], off ; encoding: 
[0x00,0x80,0x84,0xdd,0x03,0x05,0x7f,0x00]
+global_atomic_cmpswap v1, v[3:4], v[5:6], off glc
+// GFX10: encoding: [0x00,0x80,0xc5,0xdc,0x03,0x05,0x7d,0x01]
+// GFX9: global_atomic_cmpswap v1, v[3:4], v[5:6], off glc ; encoding: 
[0x00,0x80,0x05,0xdd,0x03,0x05,0x7f,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap v1, v3, v[5:6], s[2:3] glc
+// GFX10: encoding: [0x00,0x80,0xc5,0xdc,0x03,0x05,0x02,0x01]
+// GFX9: global_atomic_cmpswap v1, v3, v[5:6], s[2:3] glc ; encoding: 
[0x00,0x80,0x05,0xdd,0x03,0x05,0x02,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[5:6], v[7:10], off
+// GFX10: encoding: [0x00,0x80,0x44,0xdd,0x05,0x07,0x7d,0x00]
+// GFX9: global_atomic_cmpswap_x2 v[5:6], v[7:10], off ; encoding: 
[0x00,0x80,0x84,0xdd,0x05,0x07,0x7f,0x00]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off glc
+// GFX10: encoding: [0x00,0x80,0x45,0xdd,0x05,0x07,0x7d,0x01]
+// GFX9: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off glc ; encoding: 
[0x00,0x80,0x85,0xdd,0x05,0x07,0x7f,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[1:2], v5, v[7:10], s[2:3] glc
+// GFX10: encoding: [0x00,0x80,0x45,0xdd,0x05,0x07,0x02,0x01]
+// GFX9: global_atomic_cmpswap_x2 v[1:2], v5, v[7:10], s[2:3] glc ; encoding: 
[0x00,0x80,0x85,0xdd,0x05,0x07,0x02,0x01]
 // VI-ERR: error: instruction not supported on this GPU
 
 global_atomic_swap v[3:4], v5, off
@@ -362,9 +382,29 @@ global_atomic_cmpswap v[3:4], v[5:6], off offset:-16
 // GFX9: global_atomic_cmpswap v[3:4], v[5:6], off offset:-16 ; encoding: 
[0xf0,0x9f,0x04,0xdd,0x03,0x05,0x7f,0x00]
 // VI-ERR: :1: error: instruction not supported on this GPU
 
-global_atomic_cmpswap_x2 v[3:4], v[5:8], off offset:-16
-// GFX10: encoding: [0xf0,0x8f,0x44,0xdd,0x03,0x05,0x7d,0x00]
-// GFX9: global_atomic_cmpswap_x2 v[3:4], v[5:8], off offset:-16 ; encoding: 
[0xf0,0x9f,0x84,0xdd,0x03,0x05,0x7f,0x00]
+global_atomic_cmpswap v1, v[3:4], v[5:6], off offset:-16 glc
+// GFX10: encoding: [0xf0,0x8f,0xc5,0xdc,0x03,0x05,0x7d,0x01]
+// GFX9: global_atomic_cmpswap v1, v[3:4], v[5:6], off offset:-16 glc ; 
encoding: [0xf0,0x9f,0x05,0xdd,0x03,0x05,0x7f,0x01]
+// VI-ERR: :1: error: instruction not supported on this GPU
+
+global_atomic_cmpswap v1, v3, v[5:6], s[2:3] offset:-16 glc
+// GFX10: encoding: [0xf0,0x8f,0xc5,0xdc,0x03,0x05,0x02,0x01]
+// GFX9: global_atomic_cmpswap v1, v3, v[5:6], s[2:3] offset:-16 glc ; 
encoding: [0xf0,0x9f,0x05,0xdd,0x03,0x05,0x02,0x01]
+// VI-ERR: :1: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[5:6], v[7:10], off offset:-16
+// GFX10: encoding: [0xf0,0x8f,0x44,0xdd,0x05,0x07,0x7d,0x00]
+// GFX9: global_atomic_cmpswap_x2 v[5:6], v[7:10], off offset:-16 ; encoding: 
[0xf0,0x9f,0x84,0xdd,0x05,0x07,0x7f,0x00]
+// VI-ERR: :1: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off offset:-16 glc
+// GFX10: encoding: [0xf0,0x8f,0x45,0xdd,0x05,0x07,0x7d,0x01]
+// GFX9: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off offset:-16 glc 
; encoding: [0xf0,0x9f,0x85,0xdd,0x05,0x07,0x7f,0x01]
+// VI-ERR: :1: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[1:2], v5, v[7:10], s[2:3] offset:-16 glc
+// GFX10: encoding: [0xf0,0x8f,0x45,0xdd,0x05,0x07,0x02,0x01]
+// GFX9: global_atomic_cmpswap_x2 v[1:2], v5, v[7:10], s[2:3] offset:-16 glc ; 
encoding: [0xf0,0x9f,0x85,0xdd,0x05,0x07,0x02,0x01]
 // VI-ERR: :1: error: instruction not supported on this GPU
 
 global_atomic_swap v[3:4], v5, off offset:-16

diff  --git a/llvm/test/MC/AMDGPU/gfx9_asm

[llvm-branch-commits] [llvm] 9144597 - [AMDGPU] Unify flat offset logic

2020-12-15 Thread Sebastian Neubauer via llvm-branch-commits

Author: Sebastian Neubauer
Date: 2020-12-15T14:59:59+01:00
New Revision: 91445979be0a4e6fe4b42005d7fb03fc46c9ee0c

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

LOG: [AMDGPU] Unify flat offset logic

Move getNumFlatOffsetBits from AMDGPUAsmParser and SIInstrInfo into
AMDGPUBaseInfo.

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.h
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
llvm/test/MC/AMDGPU/flat-gfx10.s
llvm/test/MC/AMDGPU/gfx10_err_pos.s

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
index 2ad7fab81427..0a0b993778c7 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
@@ -1928,7 +1928,7 @@ bool AMDGPUDAGToDAGISel::SelectScratchSAddr(SDNode *N,
   if (!TII->isLegalFLATOffset(COffsetVal, AMDGPUAS::PRIVATE_ADDRESS, true)) {
 int64_t RemainderOffset = COffsetVal;
 int64_t ImmField = 0;
-const unsigned NumBits = TII->getNumFlatOffsetBits(true);
+const unsigned NumBits = AMDGPU::getNumFlatOffsetBits(*Subtarget, true);
 // Use signed division by a power of two to truncate towards 0.
 int64_t D = 1LL << (NumBits - 1);
 RemainderOffset = (COffsetVal / D) * D;

diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 22c32400ecbf..1fd6c2cca6df 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -3646,22 +3646,20 @@ bool AMDGPUAsmParser::validateFlatOffset(const MCInst 
&Inst,
 return false;
   }
 
-  // Address offset is 12-bit signed for GFX10, 13-bit for GFX9.
   // For FLAT segment the offset must be positive;
   // MSB is ignored and forced to zero.
-  unsigned OffsetSize = isGFX9() ? 13 : 12;
   if (TSFlags & (SIInstrFlags::IsFlatGlobal | SIInstrFlags::IsFlatScratch)) {
+unsigned OffsetSize = AMDGPU::getNumFlatOffsetBits(getSTI(), true);
 if (!isIntN(OffsetSize, Op.getImm())) {
   Error(getFlatOffsetLoc(Operands),
-isGFX9() ? "expected a 13-bit signed offset" :
-   "expected a 12-bit signed offset");
+Twine("expected a ") + Twine(OffsetSize) + "-bit signed offset");
   return false;
 }
   } else {
-if (!isUIntN(OffsetSize - 1, Op.getImm())) {
+unsigned OffsetSize = AMDGPU::getNumFlatOffsetBits(getSTI(), false);
+if (!isUIntN(OffsetSize, Op.getImm())) {
   Error(getFlatOffsetLoc(Operands),
-isGFX9() ? "expected a 12-bit unsigned offset" :
-   "expected an 11-bit unsigned offset");
+Twine("expected a ") + Twine(OffsetSize) + "-bit unsigned offset");
   return false;
 }
   }

diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 01721595d551..889908bce905 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -7053,13 +7053,6 @@ bool SIInstrInfo::isBufferSMRD(const MachineInstr &MI) 
const {
   return RI.getRegClass(RCID)->hasSubClassEq(&AMDGPU::SGPR_128RegClass);
 }
 
-unsigned SIInstrInfo::getNumFlatOffsetBits(bool Signed) const {
-  if (ST.getGeneration() >= AMDGPUSubtarget::GFX10)
-return Signed ? 12 : 11;
-
-  return Signed ? 13 : 12;
-}
-
 bool SIInstrInfo::isLegalFLATOffset(int64_t Offset, unsigned AddrSpace,
 bool Signed) const {
   // TODO: Should 0 be special cased?
@@ -7069,10 +7062,8 @@ bool SIInstrInfo::isLegalFLATOffset(int64_t Offset, 
unsigned AddrSpace,
   if (ST.hasFlatSegmentOffsetBug() && AddrSpace == AMDGPUAS::FLAT_ADDRESS)
 return false;
 
-  if (ST.getGeneration() >= AMDGPUSubtarget::GFX10)
-return Signed ? isInt<12>(Offset) : isUInt<11>(Offset);
-
-  return Signed ? isInt<13>(Offset) :isUInt<12>(Offset);
+  unsigned N = AMDGPU::getNumFlatOffsetBits(ST, Signed);
+  return Signed ? isIntN(N, Offset) : isUIntN(N, Offset);
 }
 
 std::pair SIInstrInfo::splitFlatOffset(int64_t COffsetVal,
@@ -7080,7 +7071,7 @@ std::pair 
SIInstrInfo::splitFlatOffset(int64_t COffsetVal,
  bool IsSigned) const {
   int64_t RemainderOffset = COffsetVal;
   int64_t ImmField = 0;
-  const unsigned NumBits = getNumFlatOffsetBits(IsSigned);
+  const unsigned NumBits = AMDGPU::getNumFlatOffsetBits(ST, IsSigned);
   if (IsSigned) {
 // Use signed division by a power of two to

[llvm-branch-commits] [llvm] 7186a39 - [VPlan] Use VPDef for VPWidenSelectRecipe.

2020-12-15 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-15T14:15:01Z
New Revision: 7186a3965af20b02d4620a96f078d826b306c63e

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

LOG: [VPlan] Use VPDef for VPWidenSelectRecipe.

This patch turns updates VPWidenSelectRecipe to manage the value
it defines using VPDef.

Reviewed By: gilr

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 2b3808b74b74..02ae60990c63 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -885,7 +885,10 @@ class VPWidenCallRecipe : public VPRecipeBase,
 };
 
 /// A recipe for widening select instructions.
-class VPWidenSelectRecipe : public VPRecipeBase, public VPValue, public VPUser 
{
+class VPWidenSelectRecipe : public VPRecipeBase,
+public VPDef,
+public VPUser,
+public VPValue {
 
   /// Is the condition of the select loop invariant?
   bool InvariantCond;
@@ -894,8 +897,8 @@ class VPWidenSelectRecipe : public VPRecipeBase, public 
VPValue, public VPUser {
   template 
   VPWidenSelectRecipe(SelectInst &I, iterator_range Operands,
   bool InvariantCond)
-  : VPRecipeBase(VPRecipeBase::VPWidenSelectSC),
-VPValue(VPValue::VPVWidenSelectSC, &I), VPUser(Operands),
+  : VPRecipeBase(VPRecipeBase::VPWidenSelectSC), VPUser(Operands),
+VPValue(VPValue::VPVWidenSelectSC, &I, this),
 InvariantCond(InvariantCond) {}
 
   ~VPWidenSelectRecipe() override = default;



___
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] 2a2268a - [VE][NFC] Sort VEISD operations

2020-12-15 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-15T23:29:16+09:00
New Revision: 2a2268a6db17cbbef54c1b80f74a04849831c997

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

LOG: [VE][NFC] Sort VEISD operations

Reviewed By: simoll

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

Added: 


Modified: 
llvm/lib/Target/VE/VEISelLowering.cpp
llvm/lib/Target/VE/VEISelLowering.h

Removed: 




diff  --git a/llvm/lib/Target/VE/VEISelLowering.cpp 
b/llvm/lib/Target/VE/VEISelLowering.cpp
index ca548e056c51..d15158f4f4d2 100644
--- a/llvm/lib/Target/VE/VEISelLowering.cpp
+++ b/llvm/lib/Target/VE/VEISelLowering.cpp
@@ -865,17 +865,17 @@ const char *VETargetLowering::getTargetNodeName(unsigned 
Opcode) const {
   switch ((VEISD::NodeType)Opcode) {
   case VEISD::FIRST_NUMBER:
 break;
-TARGET_NODE_CASE(Lo)
-TARGET_NODE_CASE(Hi)
+TARGET_NODE_CASE(CALL)
 TARGET_NODE_CASE(GETFUNPLT)
 TARGET_NODE_CASE(GETSTACKTOP)
 TARGET_NODE_CASE(GETTLSADDR)
+TARGET_NODE_CASE(GLOBAL_BASE_REG)
+TARGET_NODE_CASE(Hi)
+TARGET_NODE_CASE(Lo)
 TARGET_NODE_CASE(MEMBARRIER)
-TARGET_NODE_CASE(CALL)
+TARGET_NODE_CASE(RET_FLAG)
 TARGET_NODE_CASE(TS1AM)
 TARGET_NODE_CASE(VEC_BROADCAST)
-TARGET_NODE_CASE(RET_FLAG)
-TARGET_NODE_CASE(GLOBAL_BASE_REG)
 
 // Register the VVP_* SDNodes.
 #define ADD_VVP_OP(VVP_NAME, ...) TARGET_NODE_CASE(VVP_NAME)

diff  --git a/llvm/lib/Target/VE/VEISelLowering.h 
b/llvm/lib/Target/VE/VEISelLowering.h
index 0eea838ff55d..b5e2a72887f4 100644
--- a/llvm/lib/Target/VE/VEISelLowering.h
+++ b/llvm/lib/Target/VE/VEISelLowering.h
@@ -24,22 +24,19 @@ namespace VEISD {
 enum NodeType : unsigned {
   FIRST_NUMBER = ISD::BUILTIN_OP_END,
 
-  Hi,
-  Lo, // Hi/Lo operations, typically on a global address.
-
-  GETFUNPLT,   // load function address through %plt insturction
-  GETTLSADDR,  // load address for TLS access
-  GETSTACKTOP, // retrieve address of stack top (first address of
-   // locals and temporaries)
-
-  MEMBARRIER, // Compiler barrier only; generate a no-op.
-  TS1AM,  // A TS1AM instruction used for 1/2 bytes swap.
-
-  VEC_BROADCAST, // 0: scalar value, 1: VL
-
   CALL,// A call instruction.
-  RET_FLAG,// Return with a flag operand.
+  GETFUNPLT,   // Load function address through %plt insturction.
+  GETTLSADDR,  // Load address for TLS access.
+  GETSTACKTOP, // Retrieve address of stack top (first address of
+   // locals and temporaries).
   GLOBAL_BASE_REG, // Global base reg for PIC.
+  Hi,  // Hi/Lo operations, typically on a global address.
+  Lo,  // Hi/Lo operations, typically on a global address.
+  MEMBARRIER,  // Compiler barrier only; generate a no-op.
+  RET_FLAG,// Return with a flag operand.
+  TS1AM,   // A TS1AM instruction used for 1/2 bytes swap.
+  VEC_BROADCAST,   // A vector broadcast instruction.
+   //   0: scalar value, 1: VL
 
 // VVP_* nodes.
 #define ADD_VVP_OP(VVP_NAME, ...) VVP_NAME,



___
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] 6972265 - [VE] Support FRAMEADDR

2020-12-15 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-15T23:31:19+09:00
New Revision: 697226550e369e7e736411508d7d2589a2aff764

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

LOG: [VE] Support FRAMEADDR

Implement FRAMEADDR for VE.  Add a regression test also.

Reviewed By: simoll

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

Added: 
llvm/test/CodeGen/VE/Scalar/frameaddr.ll

Modified: 
llvm/lib/Target/VE/VEISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/VE/VEISelLowering.cpp 
b/llvm/lib/Target/VE/VEISelLowering.cpp
index d15158f4f4d2..408c28205aa2 100644
--- a/llvm/lib/Target/VE/VEISelLowering.cpp
+++ b/llvm/lib/Target/VE/VEISelLowering.cpp
@@ -1489,6 +1489,27 @@ SDValue 
VETargetLowering::lowerDYNAMIC_STACKALLOC(SDValue Op,
   return DAG.getMergeValues(Ops, DL);
 }
 
+static SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG,
+  const VETargetLowering &TLI,
+  const VESubtarget *Subtarget) {
+  SDLoc DL(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = TLI.getPointerTy(MF.getDataLayout());
+
+  MachineFrameInfo &MFI = MF.getFrameInfo();
+  MFI.setFrameAddressIsTaken(true);
+
+  unsigned Depth = Op.getConstantOperandVal(0);
+  const VERegisterInfo *RegInfo = Subtarget->getRegisterInfo();
+  unsigned FrameReg = RegInfo->getFrameRegister(MF);
+  SDValue FrameAddr =
+  DAG.getCopyFromReg(DAG.getEntryNode(), DL, FrameReg, PtrVT);
+  while (Depth--)
+FrameAddr = DAG.getLoad(Op.getValueType(), DL, DAG.getEntryNode(),
+FrameAddr, MachinePointerInfo());
+  return FrameAddr;
+}
+
 static SDValue getSplatValue(SDNode *N) {
   if (auto *BuildVec = dyn_cast(N)) {
 return BuildVec->getSplatValue();
@@ -1529,6 +1550,8 @@ SDValue VETargetLowering::LowerOperation(SDValue Op, 
SelectionDAG &DAG) const {
 return lowerConstantPool(Op, DAG);
   case ISD::DYNAMIC_STACKALLOC:
 return lowerDYNAMIC_STACKALLOC(Op, DAG);
+  case ISD::FRAMEADDR:
+return lowerFRAMEADDR(Op, DAG, *this, Subtarget);
   case ISD::GlobalAddress:
 return lowerGlobalAddress(Op, DAG);
   case ISD::GlobalTLSAddress:

diff  --git a/llvm/test/CodeGen/VE/Scalar/frameaddr.ll 
b/llvm/test/CodeGen/VE/Scalar/frameaddr.ll
new file mode 100644
index ..117ae90b6ccc
--- /dev/null
+++ b/llvm/test/CodeGen/VE/Scalar/frameaddr.ll
@@ -0,0 +1,24 @@
+; RUN: llc < %s -mtriple=ve | FileCheck %s
+
+define i8* @test1() nounwind {
+; CHECK-LABEL: test1:
+; CHECK:   .LBB{{[0-9]+}}_2:
+; CHECK-NEXT:or %s0, 0, %s9
+; CHECK-NEXT:or %s11, 0, %s9
+entry:
+  %ret = tail call i8* @llvm.frameaddress(i32 0)
+  ret i8* %ret
+}
+
+define i8* @test2() nounwind {
+; CHECK-LABEL: test2:
+; CHECK:   .LBB{{[0-9]+}}_2:
+; CHECK-NEXT:ld %s0, (, %s9)
+; CHECK-NEXT:ld %s0, (, %s0)
+; CHECK-NEXT:or %s11, 0, %s9
+entry:
+  %ret = tail call i8* @llvm.frameaddress(i32 2)
+  ret i8* %ret
+}
+
+declare i8* @llvm.frameaddress(i32) nounwind readnone



___
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] 7ea3932 - [AnnotationRemarks] Also generate annotation remarks when using -O0.

2020-12-15 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-15T14:46:52Z
New Revision: 7ea3932ab1def0f5e86ac745bef0d3de09e8845f

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

LOG: [AnnotationRemarks] Also generate annotation remarks when using -O0.

The AnnotationRemarks pass is already run at the end of the module
pipeline. This patch also adds it before bailing out for -O0, so remarks
are also generated with -O0.

Added: 


Modified: 
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/Other/opt-O0-pipeline.ll

Removed: 




diff  --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp 
b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 574527763a9c..8dd30ef82bc3 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -569,6 +569,8 @@ void PassManagerBuilder::populateModulePassManager(
   // new unnamed globals.
   MPM.add(createNameAnonGlobalPass());
 }
+
+MPM.add(createAnnotationRemarksLegacyPass());
 return;
   }
 

diff  --git a/llvm/test/Other/opt-O0-pipeline.ll 
b/llvm/test/Other/opt-O0-pipeline.ll
index 86677c683c42..80ab608b05ce 100644
--- a/llvm/test/Other/opt-O0-pipeline.ll
+++ b/llvm/test/Other/opt-O0-pipeline.ll
@@ -25,6 +25,7 @@
 ; CHECK-NEXT:   Inliner for always_inline functions
 ;   A No-Op Barrier Pass
 ; CHECK:FunctionPass Manager
+; CHECK-NEXT: Annotation Remarks
 ; CHECK-NEXT: Module Verifier
 ; CHECK-NEXT: Bitcode Writer
 



___
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] 2b09ded - [lldb] Fix import-std-module tests after libc++ got a new __memory subdirectory

2020-12-15 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-15T16:16:00+01:00
New Revision: 2b09dedac4c824c51bc0a8934b33c0f50ce0e126

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

LOG: [lldb] Fix import-std-module tests after libc++ got a new __memory 
subdirectory

7ad49aec125b3c1205b164331d0aa954d773f890 added a __memory subdirectory to libc++
but the code we use to find libc++ from the debug info support files wasn't
prepared to encounter unknown subdirectories within libc++. The 
import-std-module
tests automatically fell back to not importing the std module which caused
them to fail.

This patch removes our hardcoded exception for the 'experimental' subdirectory
and instead just ignores all subdirectories of c++/vX/ when searching the
support files.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
index f1272c67d20f..d2162cf4c574 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
@@ -38,9 +38,11 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec &f) {
 
   // Check for /c++/vX/ that is used by libc++.
   static llvm::Regex libcpp_regex(R"regex(/c[+][+]/v[0-9]/)regex");
-  if (libcpp_regex.match(f.GetPath())) {
-// Strip away libc++'s /experimental directory if there is one.
-posix_dir.consume_back("/experimental");
+  // If the path is in the libc++ include directory use it as the found libc++
+  // path. Ignore subdirectories such as /c++/v1/experimental as those don't
+  // need to be specified in the header search.
+  if (libcpp_regex.match(f.GetPath()) &&
+  parent_path(posix_dir, Style::posix).endswith("c++")) {
 return m_std_inc.TrySet(posix_dir);
   }
 



___
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] e2dc306 - [utils] Fix UpdateTestChecks case where 2 runs differ for last label

2020-12-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-15T07:16:54-08:00
New Revision: e2dc306b1ac71258e6ce40a66e778527f282c355

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

LOG: [utils] Fix UpdateTestChecks case where 2 runs differ for last label

Two RUN lines produce outputs that, each, have some common parts and
some different parts. The common parts are checked under label A. The
differing parts are associated to a function and checked under labels B
and C, respectivelly.
When build_function_body_dictionary is called for the first RUN line, it
will attribute the function body to labels A and C. When the second RUN
is passed to build_function_body_dictionary, it sees that the function
body under A is different from what it has. If in this second RUN line,
A were at the end of the prefixes list, A's body is still kept
associated with the first run's function.

When we output the function body (i.e. add_checks), we stop after
emitting for the first prefix matching that function. So we end up with
the wrong function body (first RUN's A-association).

There is no reason to special-case the last label in the prefixes list,
and the fix is to always clear a label association if we find a RUN line
where the body is different.

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
clang/test/utils/update_cc_test_checks/prefix-never-matches.test

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll

llvm/test/tools/UpdateTestChecks/update_test_checks/prefix-never-matches.test

Modified: 
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_test_prefix.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp 
b/clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
new file mode 100644
index ..75bd5b1249a7
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -O0 -o - %s | 
FileCheck %s -check-prefix=A
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -O3 -o - %s | 
FileCheck %s -check-prefix=A
+
+int foo(int i ) {
+return 1;
+}
\ No newline at end of file

diff  --git a/clang/test/utils/update_cc_test_checks/prefix-never-matches.test 
b/clang/test/utils/update_cc_test_checks/prefix-never-matches.test
new file mode 100644
index ..7100377337bc
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/prefix-never-matches.test
@@ -0,0 +1,6 @@
+# RUN: cp -f %S/Inputs/prefix-never-matches.cpp %t.cpp
+# RUN: %update_cc_test_checks %t.cpp 2>&1 | FileCheck %s
+# RUN: FileCheck --input-file=%t.cpp %s --check-prefix=OUTPUT
+
+# CHECK: WARNING: Prefix A had conflicting output
+# OUTPUT-NOT: A:
\ No newline at end of file

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-1.ll 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-1.ll
new file mode 100644
index ..c5f2bc9ba5bc
--- /dev/null
+++ 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-1.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s 
--check-prefixes=A,B
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s 
--allow-unused-prefixes=true --check-prefixes=C,A,UNUSED
+
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+; A: declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+
+define <2 x i64> @fold_v2i64() {
+entry:
+  %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> )
+  ret <2 x i64> %r
+}

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-2.ll 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-2.ll
new file mode 100644
index ..bc1990462d37
--- /dev/null
+++ 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-2.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=

[llvm-branch-commits] [llvm] ebef921 - [SystemZ] Remove most hard-coded R1D instances for sibcalls

2020-12-15 Thread Ulrich Weigand via llvm-branch-commits

Author: Ulrich Weigand
Date: 2020-12-15T16:31:18+01:00
New Revision: ebef92169ca5a50fb8aeec08f35ccb919311acc1

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

LOG: [SystemZ] Remove most hard-coded R1D instances for sibcalls

Indirect sibling calls need to use %r1 to hold the target address.
This is currently hard-coded in many places.  This is not only
unnecessary, but makes future changes in this area difficult.

This patch now encodes the target address as operand without
hard coding a register in most places throughout the MI back-end.
Code generation still always uses %r1, but this is now decided
solely in one place in SystemZTargetLowering::LowerCall.

NFC intended.

Added: 


Modified: 
llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
llvm/lib/Target/SystemZ/SystemZElimCompare.cpp
llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
llvm/lib/Target/SystemZ/SystemZInstrInfo.td

Removed: 




diff  --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp 
b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
index 4109bfc11337..584737e1d940 100644
--- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -236,14 +236,15 @@ void SystemZAsmPrinter::emitInstruction(const 
MachineInstr *MI) {
 break;
 
   case SystemZ::CallBR:
-LoweredMI = MCInstBuilder(SystemZ::BR).addReg(SystemZ::R1D);
+LoweredMI = MCInstBuilder(SystemZ::BR)
+  .addReg(MI->getOperand(0).getReg());
 break;
 
   case SystemZ::CallBCR:
 LoweredMI = MCInstBuilder(SystemZ::BCR)
   .addImm(MI->getOperand(0).getImm())
   .addImm(MI->getOperand(1).getImm())
-  .addReg(SystemZ::R1D);
+  .addReg(MI->getOperand(2).getReg());
 break;
 
   case SystemZ::CRBCall:
@@ -251,7 +252,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addReg(MI->getOperand(1).getReg())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 
@@ -260,7 +261,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addReg(MI->getOperand(1).getReg())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 
@@ -269,7 +270,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addImm(MI->getOperand(1).getImm())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 
@@ -278,7 +279,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addImm(MI->getOperand(1).getImm())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 
@@ -287,7 +288,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addReg(MI->getOperand(1).getReg())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 
@@ -296,7 +297,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addReg(MI->getOperand(1).getReg())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 
@@ -305,7 +306,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addImm(MI->getOperand(1).getImm())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 
@@ -314,7 +315,7 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr 
*MI) {
   .addReg(MI->getOperand(0).getReg())
   .addImm(MI->getOperand(1).getImm())
   .addImm(MI->getOperand(2).getImm())
-  .addReg(SystemZ::R1D)
+  .addReg(MI->getOperand(3).getReg())
   .addImm(0);
 break;
 

diff  --git a/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp 
b/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp
index 2f0cf0317029..19b703bbb226 100644
--- a/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp
@@ -640,18 +640,22 @@ bool SystemZElimCompare::fuseCompareOperations(
   MachineOperand CCMask(MBBI->getOperand(1));
   assert((CCMask.getImm() & ~SystemZ::CCMASK_ICMP) == 0 &&
  "Invalid condition-co

[llvm-branch-commits] [clang-tools-extra] bda7d0a - [clangd] Improve goToDefinition on auto and dectype

2020-12-15 Thread Sam McCall via llvm-branch-commits

Author: Quentin Chateau
Date: 2020-12-15T16:32:22+01:00
New Revision: bda7d0af970718c243d93b22a8449c20156e574f

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

LOG: [clangd] Improve goToDefinition on auto and dectype

locateSymbolAt (used in goToDeclaration) follows the
deduced type instead of failing to locate the declaration.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/ASTTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index ac4543026a9f..c7ec401c6479 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -463,6 +463,42 @@ locateASTReferent(SourceLocation CurLoc, const 
syntax::Token *TouchedIdentifier,
   return Result;
 }
 
+std::vector locateSymbolForType(const ParsedAST &AST,
+   const QualType &Type) {
+  const auto &SM = AST.getSourceManager();
+  auto MainFilePath =
+  getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
+  if (!MainFilePath) {
+elog("Failed to get a path for the main file, so no symbol.");
+return {};
+  }
+
+  auto Decls = targetDecl(DynTypedNode::create(Type.getNonReferenceType()),
+  DeclRelation::TemplatePattern | DeclRelation::Alias);
+  if (Decls.empty())
+return {};
+
+  std::vector Results;
+  const auto &ASTContext = AST.getASTContext();
+
+  for (const NamedDecl *D : Decls) {
+D = getPreferredDecl(D);
+
+auto Loc = makeLocation(ASTContext, nameLocation(*D, SM), *MainFilePath);
+if (!Loc)
+  continue;
+
+Results.emplace_back();
+Results.back().Name = printName(ASTContext, *D);
+Results.back().PreferredDeclaration = *Loc;
+if (const NamedDecl *Def = getDefinition(D))
+  Results.back().Definition =
+  makeLocation(ASTContext, nameLocation(*Def, SM), *MainFilePath);
+  }
+
+  return Results;
+}
+
 bool tokenSpelledAt(SourceLocation SpellingLoc, const syntax::TokenBuffer &TB) 
{
   auto ExpandedTokens = TB.expandedTokens(
   TB.sourceManager().getMacroArgExpandedLocation(SpellingLoc));
@@ -707,15 +743,31 @@ std::vector locateSymbolAt(ParsedAST &AST, 
Position Pos,
 return {};
   }
 
-  const syntax::Token *TouchedIdentifier =
-  syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
-  if (TouchedIdentifier)
-if (auto Macro =
-locateMacroReferent(*TouchedIdentifier, AST, *MainFilePath))
-  // Don't look at the AST or index if we have a macro result.
-  // (We'd just return declarations referenced from the macro's
-  // expansion.)
-  return {*std::move(Macro)};
+  const syntax::Token *TouchedIdentifier = nullptr;
+  auto TokensTouchingCursor =
+  syntax::spelledTokensTouching(*CurLoc, AST.getTokens());
+  for (const syntax::Token &Tok : TokensTouchingCursor) {
+if (Tok.kind() == tok::identifier) {
+  if (auto Macro = locateMacroReferent(Tok, AST, *MainFilePath))
+// Don't look at the AST or index if we have a macro result.
+// (We'd just return declarations referenced from the macro's
+// expansion.)
+return {*std::move(Macro)};
+
+  TouchedIdentifier = &Tok;
+  break;
+}
+
+if (Tok.kind() == tok::kw_auto || Tok.kind() == tok::kw_decltype) {
+  // go-to-definition on auto should find the definition of the deduced
+  // type, if possible
+  if (auto Deduced = getDeducedType(AST.getASTContext(), Tok.location())) {
+auto LocSym = locateSymbolForType(AST, *Deduced);
+if (!LocSym.empty())
+  return LocSym;
+  }
+}
+  }
 
   ASTNodeKind NodeKind;
   auto ASTResults = locateASTReferent(*CurLoc, TouchedIdentifier, AST,

diff  --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp 
b/clang-tools-extra/clangd/unittests/ASTTests.cpp
index 21f70dcc3168..4c52c72d703c 100644
--- a/clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -26,23 +26,168 @@ namespace clang {
 namespace clangd {
 namespace {
 
-TEST(GetDeducedType, KwAutoExpansion) {
+TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
   struct Test {
 StringRef AnnotatedCode;
 const char *DeducedType;
   } Tests[] = {
   {"^auto i = 0;", "int"},
   {"^auto f(){ return 1;};", "int"},
+  {
+  R"cpp( // auto on struct in a namespace
+  namespace ns1 { struct S {}; }
+  ^auto v = ns1::S{};
+  )cpp",
+  "struct ns1::S",
+  },
+  {
+  R"cpp( // decltype on struct
+  namespace ns1 { struct S 

[llvm-branch-commits] [mlir] 73c5804 - [mlir] Add std op for X raised to the power of Y

2020-12-15 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-15T17:06:26+01:00
New Revision: 73c580405ffae0243c113a1db6b77c0b595adf05

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

LOG: [mlir] Add std op for X raised to the power of Y

Proposal:
https://llvm.discourse.group/t/rfc-standard-add-powop-to-std-dialect/2377

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

Added: 


Modified: 
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/test/IR/core-ops.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td 
b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index c218618eb111..481dfaf4b34d 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -2352,6 +2352,39 @@ def OrOp : IntArithmeticOp<"or", [Commutative]> {
   let hasFolder = 1;
 }
 
+//===--===//
+// PowFOp
+//===--===//
+
+def PowFOp : FloatArithmeticOp<"powf"> {
+  let summary = "floating point raised to the power of operation";
+  let description = [{
+Syntax:
+
+```
+operation ::= ssa-id `=` `std.powf` ssa-use `,` ssa-use `:` type
+```
+
+The `powf` operation takes two operands and returns one result, each of
+these is required to be the same type. This type may be a floating point
+scalar type, a vector whose element type is a floating point type, or a
+floating point tensor.
+
+Example:
+
+```mlir
+// Scalar exponentiation.
+%a = powf %b, %c : f64
+
+// SIMD pointwise vector exponentiation
+%f = powf %g, %h : vector<4xf32>
+
+// Tensor pointwise exponentiation.
+%x = powf %y, %z : tensor<4x?xbf16>
+```
+  }];
+}
+
 
//===--===//
 // PrefetchOp
 
//===--===//

diff  --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir
index 9af0c01bf555..502e7fb358fb 100644
--- a/mlir/test/IR/core-ops.mlir
+++ b/mlir/test/IR/core-ops.mlir
@@ -86,6 +86,9 @@ func @standard_instrs(tensor<4x4x?xf32>, f32, i32, index, 
i64, f16) {
   // CHECK: %[[I6:.*]] = muli %[[I2]], %[[I2]] : i32
   %i6 = muli %i2, %i2 : i32
 
+  // CHECK: %[[F7:.*]] = powf %[[F2]], %[[F2]] : f32
+  %f7 = powf %f2, %f2 : f32
+
   // CHECK: %[[C0:.*]] = create_complex %[[F2]], %[[F2]] : complex
   %c0 = "std.create_complex"(%f2, %f2) : (f32, f32) -> complex
 



___
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] 632f4d2 - [NFC] Fix a few SVEInstrInfo related stylistic issues.

2020-12-15 Thread Paul Walker via llvm-branch-commits

Author: Paul Walker
Date: 2020-12-15T16:10:38Z
New Revision: 632f4d2747f0777157d10456dd431d8f4cece845

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

LOG: [NFC] Fix a few SVEInstrInfo related stylistic issues.

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/SVEInstrFormats.td

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index 41abfa32da62f..5bafe430a1b4c 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -437,7 +437,6 @@ def HasV8_5aOps : SubtargetFeature<
 
 def HasV8_6aOps : SubtargetFeature<
   "v8.6a", "HasV8_6aOps", "true", "Support ARM v8.6a instructions",
-
   [HasV8_5aOps, FeatureAMVS, FeatureBF16, FeatureFineGrainedTraps,
FeatureEnhancedCounterVirtualization, FeatureMatMulInt8]>;
 

diff  --git a/llvm/lib/Target/AArch64/AArch64InstrFormats.td 
b/llvm/lib/Target/AArch64/AArch64InstrFormats.td
index 6d17b283231a2..8e01a8cf7beb9 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrFormats.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrFormats.td
@@ -325,7 +325,7 @@ def simm9 : Operand, ImmLeaf= 
-256 && Imm < 256; }]> {
 }
 
 def SImm8Operand : SImmOperand<8>;
-def simm8 : Operand, ImmLeaf= -128 && Imm < 127; }]> 
{
+def simm8 : Operand, ImmLeaf= -128 && Imm < 128; }]> 
{
   let ParserMatchClass = SImm8Operand;
   let DecoderMethod = "DecodeSImm<8>";
 }

diff  --git a/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
index 22f78ce61128f..86cfdf8f7cf97 100644
--- a/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
@@ -558,11 +558,11 @@ void AArch64RegisterInfo::resolveFrameIndex(MachineInstr 
&MI, Register BaseReg,
   StackOffset Off = StackOffset::getFixed(Offset);
 
   unsigned i = 0;
-
   while (!MI.getOperand(i).isFI()) {
 ++i;
 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex 
operand!");
   }
+
   const MachineFunction *MF = MI.getParent()->getParent();
   const AArch64InstrInfo *TII =
   MF->getSubtarget().getInstrInfo();
@@ -604,7 +604,6 @@ void 
AArch64RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
   const AArch64InstrInfo *TII =
   MF.getSubtarget().getInstrInfo();
   const AArch64FrameLowering *TFI = getFrameLowering(MF);
-
   int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
   bool Tagged =
   MI.getOperand(FIOperandNum).getTargetFlags() & AArch64II::MO_TAGGED;

diff  --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index bdf5d1d771c79..adbace24ee6c5 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -575,7 +575,7 @@ let Predicates = [HasSVE] in {
   }
 
   // Select elements from either vector (predicated)
-  defm SEL_ZPZZ: sve_int_sel_vvv<"sel", vselect>;
+  defm SEL_ZPZZ   : sve_int_sel_vvv<"sel", vselect>;
 
   defm SPLICE_ZPZ : sve_int_perm_splice<"splice", int_aarch64_sve_splice>;
 
@@ -1062,7 +1062,7 @@ let Predicates = [HasSVE] in {
   def PRFS_PRR : sve_mem_prfm_ss<0b101, "prfw", GPR64NoXZRshifted32>;
   def PRFD_PRR : sve_mem_prfm_ss<0b111, "prfd", GPR64NoXZRshifted64>;
 
-multiclass sve_prefetch {
+  multiclass sve_prefetch {
 // reg + imm
 let AddedComplexity = 2 in {
   def _reg_imm : Pat<(prefetch (PredTy PPR_3b:$gp), (am_sve_indexed_s6 
GPR64sp:$base, simm6s1:$offset), (i32 sve_prfop:$prfop)),
@@ -1735,7 +1735,6 @@ multiclass sve_prefetch;
 def : Pat<(nxv2f64 (bitconvert (nxv8f16 ZPR:$src))), (nxv2f64 ZPR:$src)>;
 def : Pat<(nxv2f64 (bitconvert (nxv4f32 ZPR:$src))), (nxv2f64 ZPR:$src)>;
-
   }
 
   let Predicates = [IsLE, HasBF16, HasSVE] in {
@@ -2434,6 +2433,7 @@ let Predicates = [HasSVE2] in {
 (UMULH_ZZZ_S $Op1, $Op2)>;
   def : Pat<(nxv2i64 (int_aarch64_sve_umulh (nxv2i1 (AArch64ptrue 31)), 
nxv2i64:$Op1, nxv2i64:$Op2)),
 (UMULH_ZZZ_D $Op1, $Op2)>;
+
   // SVE2 complex integer dot product (indexed)
   defm CDOT_ZZZI : sve2_cintx_dot_by_indexed_elem<"cdot", 
int_aarch64_sve_cdot_lane>;
 

diff  --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td 
b/llvm/lib/Target/AArch64/SVEInstrFormats.td
index c86b425422580..0db00247cd01b 100644
--- a/llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -1012,8 +1012,8 @@ multiclass sve_int_perm_dup_i {
   (!cast(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 
0), 2>;
 }
 
-class sve_int_perm_tbl sz8_64, bits<2> opc, string asm,
-

[llvm-branch-commits] [clang] 8acb5f2 - [clang][driver][NFC] Use StringRef instead of std::string

2020-12-15 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-15T16:19:12Z
New Revision: 8acb5f2723ecaf0f1904a085ad79d0623cec38f6

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

LOG: [clang][driver][NFC] Use StringRef instead of std::string

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5e4eb8c4e6c5..dc9ec1b9c362 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -779,10 +779,9 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation 
&C,
 /// by Dirs.
 ///
 static bool searchForFile(SmallVectorImpl &FilePath,
-  ArrayRef Dirs,
-  StringRef FileName) {
+  ArrayRef Dirs, StringRef FileName) {
   SmallString<128> WPath;
-  for (const std::string &Dir : Dirs) {
+  for (const StringRef &Dir : Dirs) {
 if (Dir.empty())
   continue;
 WPath.clear();
@@ -807,7 +806,7 @@ bool Driver::readConfigFile(StringRef FileName) {
   // Read options from config file.
   llvm::SmallString<128> CfgFileName(FileName);
   llvm::sys::path::native(CfgFileName);
-  ConfigFile = std::string(CfgFileName.str());
+  ConfigFile = std::string(CfgFileName);
   bool ContainErrors;
   CfgOptions = std::make_unique(
   ParseArgStrings(NewCfgArgs, IsCLMode(), ContainErrors));
@@ -864,9 +863,10 @@ bool Driver::loadConfigFile() {
 std::vector ConfigFiles =
 CLOptions->getAllArgValues(options::OPT_config);
 if (ConfigFiles.size() > 1) {
-  if (!std::all_of(
-  ConfigFiles.begin(), ConfigFiles.end(),
-  [ConfigFiles](std::string s) { return s == ConfigFiles[0]; })) {
+  if (!std::all_of(ConfigFiles.begin(), ConfigFiles.end(),
+   [ConfigFiles](const std::string &s) {
+ return s == ConfigFiles[0];
+   })) {
 Diag(diag::err_drv_duplicate_config);
 return true;
   }
@@ -939,10 +939,7 @@ bool Driver::loadConfigFile() {
   }
 
   // Prepare list of directories where config file is searched for.
-  SmallVector CfgFileSearchDirs;
-  CfgFileSearchDirs.push_back(UserConfigDir);
-  CfgFileSearchDirs.push_back(SystemConfigDir);
-  CfgFileSearchDirs.push_back(Dir);
+  StringRef CfgFileSearchDirs[] = {UserConfigDir, SystemConfigDir, Dir};
 
   // Try to find config file. First try file with corrected architecture.
   llvm::SmallString<128> CfgFilePath;
@@ -973,7 +970,7 @@ bool Driver::loadConfigFile() {
   // --config. If it was deduced from executable name, it is not an error.
   if (FileSpecifiedExplicitly) {
 Diag(diag::err_drv_config_file_not_found) << CfgFileName;
-for (const std::string &SearchDir : CfgFileSearchDirs)
+for (const StringRef &SearchDir : CfgFileSearchDirs)
   if (!SearchDir.empty())
 Diag(diag::note_drv_config_file_searched_in) << SearchDir;
 return true;



___
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] 380e1d9 - [utils] The func_dict for a prefix may just be empty

2020-12-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-15T08:48:37-08:00
New Revision: 380e1d918cb4581fae0277ff547d75334f3e7ddd

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

LOG: [utils] The func_dict for a prefix may just be empty

Follow up from D92965 - since we try to find failed prefixes
after each RUN line, it's possible the whole list of functions for a
prefix be non-existent, which is fine - this happens when none of the
RUN lines seen so far used the prefix.

Added: 


Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index 8cd90deefdb9..21878e81b89f 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -261,10 +261,10 @@ def __str__(self):
 def get_failed_prefixes(func_dict):
   # This returns the list of those prefixes that failed to match any function,
   # because there were conflicting bodies produced by 
diff erent RUN lines, in
-  # all instances of the prefix. Effectivelly, this prefix is unused and should
+  # all instances of the prefix. Effectively, this prefix is unused and should
   # be removed.
   for prefix in func_dict:
-if (not [fct for fct in func_dict[prefix] 
+if func_dict[prefix] and (not [fct for fct in func_dict[prefix] 
  if func_dict[prefix][fct] is not None]):
   yield prefix
 



___
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] [libcxx] a00290e - [libc++] Fix allocate_shared when used with an explicitly convertible allocator

2020-12-15 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-15T11:50:06-05:00
New Revision: a00290ed10a6b4e9f6e9be44ceec367562f270c6

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

LOG: [libc++] Fix allocate_shared when used with an explicitly convertible 
allocator

When the allocator is only explicitly convertible from other specializations
of itself, the new version of std::allocate_shared would not work because
it would try to do an implicit conversion. This patch fixes the problem
and adds a test so that we don't fall into the same trap in the future.

Added: 

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.explicit_conversion.pass.cpp

Modified: 
libcxx/include/__memory/utilities.h

Removed: 




diff  --git a/libcxx/include/__memory/utilities.h 
b/libcxx/include/__memory/utilities.h
index ccbfbe78966c..aac3d11cab57 100644
--- a/libcxx/include/__memory/utilities.h
+++ b/libcxx/include/__memory/utilities.h
@@ -48,8 +48,9 @@ struct __allocation_guard {
 using _Pointer = typename allocator_traits<_Alloc>::pointer;
 using _Size = typename allocator_traits<_Alloc>::size_type;
 
+template // we perform the allocator conversion inside the 
constructor
 _LIBCPP_HIDE_FROM_ABI
-explicit __allocation_guard(_Alloc __alloc, _Size __n)
+explicit __allocation_guard(_AllocT __alloc, _Size __n)
 : __alloc_(_VSTD::move(__alloc))
 , __n_(__n)
 , __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // 
initialization order is important

diff  --git 
a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.explicit_conversion.pass.cpp
 
b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.explicit_conversion.pass.cpp
new file mode 100644
index ..446daa1ec9f2
--- /dev/null
+++ 
b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.explicit_conversion.pass.cpp
@@ -0,0 +1,32 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// Make sure that std::allocate_shared works with an allocator type that is
+// only explicitly convertible from another specialization of itself.
+
+#include 
+#include 
+#include 
+
+template 
+struct ExplicitAllocator {
+ExplicitAllocator() = default;
+template 
+explicit ExplicitAllocator(ExplicitAllocator) { }
+
+using value_type = T;
+T* allocate(std::size_t n) { return std::allocator().allocate(n); }
+void deallocate(T* ptr, std::size_t n) { return 
std::allocator().deallocate(ptr, n); }
+};
+
+int main(int, char**) {
+std::shared_ptr ptr = 
std::allocate_shared(ExplicitAllocator(), 0);
+(void)ptr;
+
+return 0;
+}



___
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] b0e5aea - [X86] Remove unnecessary SUBV_BROADCAST combines. NFCI.

2020-12-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-15T16:54:34Z
New Revision: b0e5aea5572bbfaef1ad4a7089b2879d2df4

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

LOG: [X86] Remove unnecessary SUBV_BROADCAST combines. NFCI.

Noticed while dealing with D92645 - these are now handled by getFauxShuffleMask 
+ shuffle combining code.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index bd904327f8e7..bd106f336098 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -35172,23 +35172,6 @@ static SDValue 
combineX86ShuffleChain(ArrayRef Inputs, SDValue Root,
 return CanonicalizeShuffleInput(RootVT, V1);
   }
 
-  // Attempt to match a subvector broadcast.
-  // shuffle(insert_subvector(undef, sub, 0), undef, 0, 0, 0, 0)
-  if (UnaryShuffle &&
-  (BaseMaskEltSizeInBits == 128 || BaseMaskEltSizeInBits == 256)) {
-if (isUndefOrEqual(BaseMask, 0)) {
-  SDValue Src = Inputs[0];
-  if (Src.getOpcode() == ISD::INSERT_SUBVECTOR &&
-  Src.getOperand(0).isUndef() &&
-  Src.getOperand(1).getValueSizeInBits() == BaseMaskEltSizeInBits &&
-  MayFoldLoad(Src.getOperand(1)) && isNullConstant(Src.getOperand(2))) 
{
-return DAG.getBitcast(RootVT, DAG.getNode(X86ISD::SUBV_BROADCAST, DL,
-  Src.getValueType(),
-  Src.getOperand(1)));
-  }
-}
-  }
-
   // Handle 128/256-bit lane shuffles of 512-bit vectors.
   if (RootVT.is512BitVector() &&
   (NumBaseMaskElts == 2 || NumBaseMaskElts == 4)) {
@@ -48846,10 +48829,8 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, 
MVT VT,
 
   // Repeated subvectors.
   if (IsSplat) {
-// If this broadcast/subv_broadcast is inserted into both halves, use a
-// larger broadcast/subv_broadcast.
-if (Op0.getOpcode() == X86ISD::VBROADCAST ||
-Op0.getOpcode() == X86ISD::SUBV_BROADCAST)
+// If this broadcast is inserted into both halves, use a larger broadcast.
+if (Op0.getOpcode() == X86ISD::VBROADCAST)
   return DAG.getNode(Op0.getOpcode(), DL, VT, Op0.getOperand(0));
 
 // If this broadcast_load is inserted into both halves, use a larger



___
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] 95bfd08 - [PGO] Allow overriding -vp-counters-per-site

2020-12-15 Thread Raul Tambre via llvm-branch-commits

Author: Raul Tambre
Date: 2020-12-15T19:03:27+02:00
New Revision: 95bfd0849f7fb8d0fe2c5d971ed97c219e1ccf72

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

LOG: [PGO] Allow overriding -vp-counters-per-site

In some build configurations more than 1.5 might be required.
Paramaterize so it can be changed by the user.

Reviewed By: yamauchi

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

Added: 


Modified: 
llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 




diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index f313492ba978..5d4d692a70ac 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -904,7 +904,8 @@ option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO 
instrumentation (dep
 mark_as_advanced(LLVM_ENABLE_IR_PGO)
 
 set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO 
instrumentation. May be specified as IR or Frontend")
-mark_as_advanced(LLVM_BUILD_INSTRUMENTED)
+set(LLVM_VP_COUNTERS_PER_SITE "1.5" CACHE STRING "Value profile counters to 
use per site for IR PGO with Clang")
+mark_as_advanced(LLVM_BUILD_INSTRUMENTED LLVM_VP_COUNTERS_PER_SITE)
 string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" uppercase_LLVM_BUILD_INSTRUMENTED)
 
 if (LLVM_BUILD_INSTRUMENTED)
@@ -922,7 +923,7 @@ if (LLVM_BUILD_INSTRUMENTED)
 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND
 CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11 AND
 LLVM_LINK_LLVM_DYLIB)
-  append("-Xclang -mllvm -Xclang -vp-counters-per-site=1.5"
+  append("-Xclang -mllvm -Xclang 
-vp-counters-per-site=${LLVM_VP_COUNTERS_PER_SITE}"
 CMAKE_CXX_FLAGS
 CMAKE_C_FLAGS)
 endif()



___
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] 5a2a836 - [AArch64][NEON] Remove undocumented vceqz{, q}_p16, vml{a, s}q_n_f64 intrinsics

2020-12-15 Thread Joe Ellis via llvm-branch-commits

Author: Joe Ellis
Date: 2020-12-15T17:19:16Z
New Revision: 5a2a8369e82cea9689b0ff60f3e9baa7fc79fbcf

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

LOG: [AArch64][NEON] Remove undocumented vceqz{,q}_p16, vml{a,s}q_n_f64 
intrinsics

Prior to this patch, Clang supported the following C/C++ intrinsics:

vceqz_p16
vceqzq_p16
vmlaq_n_f64
vmlsq_n_f64

... exposed through arm_neon.h. However, these intrinsics are not part
of the ACLE, allowing developers to write code that is not compatible
with other toolchains.

This patch removes these intrinsics.

There is a bug report capturing this issue here:

https://bugs.llvm.org/show_bug.cgi?id=47471

Reviewed By: bsmith

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/test/CodeGen/aarch64-neon-fma.c
clang/test/CodeGen/aarch64-neon-misc.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 4d4e42dd514b..6f1380d58c16 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -786,9 +786,6 @@ def VMUL_N_A64 : IOpInst<"vmul_n", "..1", "Qd", OP_MUL_N>;
 def FMLA_N : SOpInst<"vfma_n", "...1", "dQd", OP_FMLA_N>;
 def FMLS_N : SOpInst<"vfms_n", "...1", "fdQfQd", OP_FMLS_N>;
 
-def MLA_N : SOpInst<"vmla_n", "...1", "Qd", OP_MLA_N>;
-def MLS_N : SOpInst<"vmls_n", "...1", "Qd", OP_MLS_N>;
-
 

 // Logical operations
 def BSL : SInst<"vbsl", ".U..", "dPlQdQPl">;
@@ -868,7 +865,7 @@ def CFMGT  : SOpInst<"vcgt", "U..", "lUldQdQlQUl", OP_GT>;
 def CFMLT  : SOpInst<"vclt", "U..", "lUldQdQlQUl", OP_LT>;
 
 def CMEQ  : SInst<"vceqz", "U.",
-  "csilfUcUsUiUlPcPsPlQcQsQiQlQfQUcQUsQUiQUlQPcQPsdQdQPl">;
+  "csilfUcUsUiUlPcPlQcQsQiQlQfQUcQUsQUiQUlQPcdQdQPl">;
 def CMGE  : SInst<"vcgez", "U.", "csilfdQcQsQiQlQfQd">;
 def CMLE  : SInst<"vclez", "U.", "csilfdQcQsQiQlQfQd">;
 def CMGT  : SInst<"vcgtz", "U.", "csilfdQcQsQiQlQfQd">;

diff  --git a/clang/test/CodeGen/aarch64-neon-fma.c 
b/clang/test/CodeGen/aarch64-neon-fma.c
index c2dd315ed9fc..0726218d2e15 100644
--- a/clang/test/CodeGen/aarch64-neon-fma.c
+++ b/clang/test/CodeGen/aarch64-neon-fma.c
@@ -26,16 +26,6 @@ float32x4_t test_vmlaq_n_f32(float32x4_t a, float32x4_t b, 
float32_t c) {
   return vmlaq_n_f32(a, b, c);
 }
 
-// CHECK-LABEL: define <2 x double> @test_vmlaq_n_f64(<2 x double> %a, <2 x 
double> %b, double %c) #1 {
-// CHECK:   [[VECINIT_I:%.*]] = insertelement <2 x double> undef, double %c, 
i32 0
-// CHECK:   [[VECINIT1_I:%.*]] = insertelement <2 x double> [[VECINIT_I]], 
double %c, i32 1
-// CHECK:   [[MUL_I:%.*]] = fmul <2 x double> %b, [[VECINIT1_I]]
-// CHECK:   [[ADD_I:%.*]] = fadd <2 x double> %a, [[MUL_I]]
-// CHECK:   ret <2 x double> [[ADD_I]]
-float64x2_t test_vmlaq_n_f64(float64x2_t a, float64x2_t b, float64_t c) {
-  return vmlaq_n_f64(a, b, c);
-}
-
 // CHECK-LABEL: define <4 x float> @test_vmlsq_n_f32(<4 x float> %a, <4 x 
float> %b, float %c) #1 {
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %c, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %c, i32 1
@@ -58,16 +48,6 @@ float32x2_t test_vmls_n_f32(float32x2_t a, float32x2_t b, 
float32_t c) {
   return vmls_n_f32(a, b, c);
 }
 
-// CHECK-LABEL: define <2 x double> @test_vmlsq_n_f64(<2 x double> %a, <2 x 
double> %b, double %c) #1 {
-// CHECK:   [[VECINIT_I:%.*]] = insertelement <2 x double> undef, double %c, 
i32 0
-// CHECK:   [[VECINIT1_I:%.*]] = insertelement <2 x double> [[VECINIT_I]], 
double %c, i32 1
-// CHECK:   [[MUL_I:%.*]] = fmul <2 x double> %b, [[VECINIT1_I]]
-// CHECK:   [[SUB_I:%.*]] = fsub <2 x double> %a, [[MUL_I]]
-// CHECK:   ret <2 x double> [[SUB_I]]
-float64x2_t test_vmlsq_n_f64(float64x2_t a, float64x2_t b, float64_t c) {
-  return vmlsq_n_f64(a, b, c);
-}
-
 // CHECK-LABEL: define <2 x float> @test_vmla_lane_f32_0(<2 x float> %a, <2 x 
float> %b, <2 x float> %v) #0 {
 // CHECK:[[TMP0:%.*]] = bitcast <2 x float> [[V:%.*]] to <8 x i8>
 // CHECK:[[TMP1:%.*]] = bitcast <8 x i8> [[TMP0]] to <2 x float>

diff  --git a/clang/test/CodeGen/aarch64-neon-misc.c 
b/clang/test/CodeGen/aarch64-neon-misc.c
index 88020a1a69c2..5517fe3dc411 100644
--- a/clang/test/CodeGen/aarch64-neon-misc.c
+++ b/clang/test/CodeGen/aarch64-neon-misc.c
@@ -198,24 +198,6 @@ uint8x16_t test_vceqzq_p8(poly8x16_t a) {
   return vceqzq_p8(a);
 }
 
-// CHECK-LABEL: @test_vceqz_p16(
-// CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
-// CHECK:   [[TMP1:%.*]] = icmp eq <4 x i16> %a, zeroinitializer
-// CHECK:   [[VCEQZ_I:%.*]] = sext <4 x i1> [[TMP1]] to <4

[llvm-branch-commits] [lld] c8da71b - [ELF] Error for out-of-range R_X86_64_[REX_]GOTPCRELX

2020-12-15 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-15T09:20:07-08:00
New Revision: c8da71b53fb239e9a2117e38f9f19590fbd2b9f0

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

LOG: [ELF] Error for out-of-range R_X86_64_[REX_]GOTPCRELX

Reviewed By: grimar

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

Added: 
lld/test/ELF/x86-64-gotpc-err.s

Modified: 
lld/ELF/Arch/X86_64.cpp

Removed: 




diff  --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp
index 086a39f89671..db4428e38d2a 100644
--- a/lld/ELF/Arch/X86_64.cpp
+++ b/lld/ELF/Arch/X86_64.cpp
@@ -828,7 +828,8 @@ static void relaxGotNoPic(uint8_t *loc, uint64_t val, 
uint8_t op,
   write32le(loc, val);
 }
 
-void X86_64::relaxGot(uint8_t *loc, const Relocation &, uint64_t val) const {
+void X86_64::relaxGot(uint8_t *loc, const Relocation &rel, uint64_t val) const 
{
+  checkInt(loc, val, 32, rel);
   const uint8_t op = loc[-2];
   const uint8_t modRm = loc[-1];
 

diff  --git a/lld/test/ELF/x86-64-gotpc-err.s b/lld/test/ELF/x86-64-gotpc-err.s
new file mode 100644
index ..7dcbbc5a3378
--- /dev/null
+++ b/lld/test/ELF/x86-64-gotpc-err.s
@@ -0,0 +1,25 @@
+# REQUIRES: x86
+# RUN: split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
+# RUN: not ld.lld -T %t/lds %t/a.o -o /dev/null 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}:(.text+0x2): relocation R_X86_64_GOTPCRELX out of 
range: 2147483655 is not in [-2147483648, 2147483647]; references data
+# CHECK: error: {{.*}}:(.text+0x9): relocation R_X86_64_REX_GOTPCRELX out 
of range: 2147483648 is not in [-2147483648, 2147483647]; references data
+# CHECK-NOT: error:
+
+#--- a.s
+  movl data@GOTPCREL(%rip), %eax  # out of range
+  movq data@GOTPCREL(%rip), %rax  # out of range
+  movq data@GOTPCREL(%rip), %rax  # in range
+
+.data
+.space 13
+.globl data
+data:
+  .long 0
+
+#--- lds
+SECTIONS {
+  .text 0x20 : { *(.text) }
+  .data 0x8020 : { *(.data) }
+}



___
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] aa7ae25 - [llvm-symbolizer] Add missing include for config.h

2020-12-15 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2020-12-15T09:20:31-08:00
New Revision: aa7ae25613da0322c77a2a19cadd950f21e74ee2

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

LOG: [llvm-symbolizer] Add missing include for config.h

The cmake variable LLVM_ENABLE_DIA_SDK was being used here but
was undefined because config.h wasn't included.

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

Added: 


Modified: 
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp

Removed: 




diff  --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp 
b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 875432bd6705..358e0e284fca 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -16,6 +16,7 @@
 
 #include "Opts.inc"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Config/config.h"
 #include "llvm/DebugInfo/Symbolize/DIPrinter.h"
 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
 #include "llvm/Option/Arg.h"



___
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] a3bd67f - SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs - don't use dyn_cast_or_null. NFCI.

2020-12-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-15T17:27:25Z
New Revision: a3bd67f222ca56d86f4d1da613fca9d0bef34d9b

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

LOG: SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs - don't use 
dyn_cast_or_null. NFCI.

ResultPtr is guaranteed to be non-null - and using dyn_cast_or_null causes 
unnecessary static analyzer warnings.

We can't say the same for FirstResult AFAICT, so keep dyn_cast_or_null for that.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp 
b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
index 558bacedce06..f216956406b6 100644
--- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -902,8 +902,8 @@ void SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs(
   // If we created a GEP with constant index, and the base is loop invariant,
   // then we swap the first one with it, so LICM can move constant GEP out
   // later.
-  GetElementPtrInst *FirstGEP = 
dyn_cast_or_null(FirstResult);
-  GetElementPtrInst *SecondGEP = 
dyn_cast_or_null(ResultPtr);
+  auto *FirstGEP = dyn_cast_or_null(FirstResult);
+  auto *SecondGEP = dyn_cast(ResultPtr);
   if (isSwapCandidate && isLegalToSwapOperand(FirstGEP, SecondGEP, L))
 swapGEPOperand(FirstGEP, SecondGEP);
 



___
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] 7121173 - [X86] Explicitly use SDValue instead of auto. NFCI.

2020-12-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-15T17:27:25Z
New Revision: 712117338ad81e2c661a5a658b795eb1993b841e

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

LOG: [X86] Explicitly use SDValue instead of auto. NFCI.

Fix static analyzer warning about not using a SDValue&

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index bd106f336098..40717e85e27f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -44477,8 +44477,8 @@ static SDValue detectAVGPattern(SDValue In, EVT VT, 
SelectionDAG &DAG,
   };
 
   // Check if each element of the vector is right-shifted by one.
-  auto LHS = In.getOperand(0);
-  auto RHS = In.getOperand(1);
+  SDValue LHS = In.getOperand(0);
+  SDValue RHS = In.getOperand(1);
   if (!IsConstVectorInRange(RHS, 1, 1))
 return SDValue();
   if (LHS.getOpcode() != ISD::ADD)



___
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] e04785b - [mlir] Add NVVM lowering for std.pow

2020-12-15 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-15T18:28:23+01:00
New Revision: e04785b131cda100f1aab38067a36ae60c7d5680

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

LOG: [mlir] Add NVVM lowering for std.pow

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

Added: 


Modified: 
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp 
b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index a8b4d074a08e..cea1cdc7e25f 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -148,7 +148,7 @@ void 
mlir::configureGpuToNVVMConversionLegality(ConversionTarget &target) {
   target.addIllegalDialect();
   target.addIllegalOp();
+  LLVM::PowOp, LLVM::SinOp, LLVM::SqrtOp>();
 
   // TODO: Remove once we support replacing non-root ops.
   target.addLegalOp();
@@ -191,6 +191,8 @@ void mlir::populateGpuToNVVMConversionPatterns(
  "__nv_log10");
   patterns.insert>(converter, "__nv_log2f",
 "__nv_log2");
+  patterns.insert>(converter, "__nv_powf",
+"__nv_pow");
   patterns.insert>(converter, "__nv_rsqrtf",
  "__nv_rsqrt");
   patterns.insert>(converter, "__nv_sinf",

diff  --git a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir 
b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
index d8c4d7e064e5..af6766bba6f4 100644
--- a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
+++ b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
@@ -394,3 +394,17 @@ gpu.module @test_module {
   }) : () -> ()
 }
 
+// -
+
+gpu.module @test_module {
+  // CHECK: llvm.func @__nv_powf(!llvm.float) -> !llvm.float
+  // CHECK: llvm.func @__nv_pow(!llvm.double) -> !llvm.double
+  // CHECK-LABEL: func @gpu_pow
+  func @gpu_pow(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+%result32 = std.pow %arg_f32, %arg_f32 : f32
+// CHECK: llvm.call @__nv_powf(%{{.*}}, %{{.*}}) : (!llvm.float) -> 
!llvm.float
+%result64 = std.pow %arg_f64, %arg_f64 : f64
+// CHECK: llvm.call @__nv_pow(%{{.*}}, %{{.*}}) : (!llvm.double) -> 
!llvm.double
+std.return %result32, %result64 : f32, f64
+  }
+}



___
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] dcdef5b - [clangd] Log remote index connectivity status

2020-12-15 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-12-15T18:29:48+01:00
New Revision: dcdef5b5b3df457566e7faf61e1e5789c42528d1

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

LOG: [clangd] Log remote index connectivity status

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Client.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index 0387e65db7d0..4720b20402e1 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -19,14 +19,40 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
+#include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
+llvm::StringRef toString(const grpc_connectivity_state &State) {
+  switch (State) {
+  case GRPC_CHANNEL_IDLE:
+return "idle";
+  case GRPC_CHANNEL_CONNECTING:
+return "connecting";
+  case GRPC_CHANNEL_READY:
+return "ready";
+  case GRPC_CHANNEL_TRANSIENT_FAILURE:
+return "transient failure";
+  case GRPC_CHANNEL_SHUTDOWN:
+return "shutdown";
+  }
+  llvm_unreachable("Not a valid grpc_connectivity_state.");
+}
+
 class IndexClient : public clangd::SymbolIndex {
+  void updateConnectionStatus() const {
+auto NewStatus = Channel->GetState(/*try_to_connect=*/false);
+auto OldStatus = ConnectionStatus.exchange(NewStatus);
+if (OldStatus != NewStatus)
+  vlog("Remote index connection [{0}]: {1} => {2}", ServerAddress,
+   toString(OldStatus), toString(NewStatus));
+  }
+
   template 
   using StreamingCall = std::unique_ptr> (
   remote::v1::SymbolIndex::Stub::*)(grpc::ClientContext *,
@@ -37,6 +63,7 @@ class IndexClient : public clangd::SymbolIndex {
   bool streamRPC(ClangdRequestT Request,
  StreamingCall RPCCall,
  CallbackT Callback) const {
+updateConnectionStatus();
 bool FinalResult = false;
 trace::Span Tracer(RequestT::descriptor()->name());
 const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
@@ -77,18 +104,21 @@ class IndexClient : public clangd::SymbolIndex {
 SPAN_ATTACH(Tracer, "Status", Reader->Finish().ok());
 SPAN_ATTACH(Tracer, "Successful", Successful);
 SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
+updateConnectionStatus();
 return FinalResult;
   }
 
 public:
   IndexClient(
-  std::shared_ptr Channel, llvm::StringRef ProjectRoot,
-  llvm::StringRef Address,
+  std::shared_ptr Channel, llvm::StringRef Address,
+  llvm::StringRef ProjectRoot,
   std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
-  : Stub(remote::v1::SymbolIndex::NewStub(Channel)),
+  : Stub(remote::v1::SymbolIndex::NewStub(Channel)), Channel(Channel),
+ServerAddress(Address),
+ConnectionStatus(Channel->GetState(/*try_to_connect=*/true)),
 ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"",
   /*LocalIndexRoot=*/ProjectRoot)),
-ServerAddress(Address), DeadlineWaitingTime(DeadlineTime) {
+DeadlineWaitingTime(DeadlineTime) {
 assert(!ProjectRoot.empty());
   }
 
@@ -128,6 +158,9 @@ class IndexClient : public clangd::SymbolIndex {
 
 private:
   std::unique_ptr Stub;
+  std::shared_ptr Channel;
+  llvm::SmallString<256> ServerAddress;
+  mutable std::atomic ConnectionStatus;
   std::unique_ptr ProtobufMarshaller;
   llvm::SmallString<256> ServerAddress;
   // Each request will be terminated if it takes too long.
@@ -140,9 +173,8 @@ std::unique_ptr 
getClient(llvm::StringRef Address,
llvm::StringRef ProjectRoot) {
   const auto Channel =
   grpc::CreateChannel(Address.str(), grpc::InsecureChannelCredentials());
-  Channel->GetState(true);
   return std::unique_ptr(
-  new IndexClient(Channel, ProjectRoot, Address));
+  new IndexClient(Channel, Address, ProjectRoot));
 }
 
 } // namespace remote



___
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] aa63e17 - [X86] Regenerate avxvnni.ll tests - remove unused prefix. NFCI.

2020-12-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-15T17:35:32Z
New Revision: aa63e176268092b9021a3565908b6b4285558254

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

LOG: [X86] Regenerate avxvnni.ll tests - remove unused prefix. NFCI.

Added: 


Modified: 
llvm/test/CodeGen/X86/avxvnni.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/avxvnni.ll 
b/llvm/test/CodeGen/X86/avxvnni.ll
index ff7fd9fc5cc5f..88c8ee425d119 100644
--- a/llvm/test/CodeGen/X86/avxvnni.ll
+++ b/llvm/test/CodeGen/X86/avxvnni.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -disable-peephole -mtriple=x86_64-unknown-unknown 
-mattr=+avxvnni | FileCheck %s --check-prefixes=CHECK,AVX
-; RUN: llc < %s -disable-peephole -mtriple=x86_64-unknown-unknown 
-mattr=+avx512vnni,+avx512vl,+avx512bw | FileCheck %s 
--check-prefixes=CHECK,AVX512
-; RUN: llc < %s -disable-peephole -mtriple=x86_64-unknown-unknown 
-mattr=+avx512vnni,+avx512vl,+avx512bw,+avxvnni | FileCheck %s 
--check-prefixes=CHECK,AVX
+; RUN: llc < %s -disable-peephole -mtriple=x86_64-unknown-unknown 
-mattr=+avxvnni | FileCheck %s --check-prefix=AVX
+; RUN: llc < %s -disable-peephole -mtriple=x86_64-unknown-unknown 
-mattr=+avx512vnni,+avx512vl,+avx512bw | FileCheck %s --check-prefix=AVX512
+; RUN: llc < %s -disable-peephole -mtriple=x86_64-unknown-unknown 
-mattr=+avx512vnni,+avx512vl,+avx512bw,+avxvnni | FileCheck %s 
--check-prefix=AVX
 
 define <4 x i32> @test_pmaddwd_v8i16_add_v4i32(<4 x i32> %a0, <8 x i16> %a1, 
<8 x i16> %a2) {
 ; AVX-LABEL: test_pmaddwd_v8i16_add_v4i32:



___
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] 67a1ffd - [FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute.

2020-12-15 Thread Kevin P. Neal via llvm-branch-commits

Author: Kevin P. Neal
Date: 2020-12-15T12:38:10-05:00
New Revision: 67a1ffd88ac08526bb6cfc7b3f607e6668ba1c70

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

LOG: [FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp 
attribute.

Similar to D69312, and documented in D69839, the IRBuilder needs to add
the strictfp attribute to invoke instructions when constrained floating
point is enabled.

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

Added: 
clang/test/CodeGen/exceptions-strictfp.c

Modified: 
llvm/include/llvm/IR/IRBuilder.h

Removed: 




diff  --git a/clang/test/CodeGen/exceptions-strictfp.c 
b/clang/test/CodeGen/exceptions-strictfp.c
new file mode 100644
index ..f1c279908e45
--- /dev/null
+++ b/clang/test/CodeGen/exceptions-strictfp.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple armv7-apple-unknown -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s -fexceptions 
-fsjlj-exceptions -fblocks | FileCheck %s
+
+// Verify strictfp attributes on invoke calls (and therefore also on
+// function definitions).
+
+// rdar://problem/8621849
+void test1() {
+  extern void test1_helper(void (^)(int));
+
+  // CHECK: define arm_aapcscc void @test1() [[STRICTFP0:#[0-9]+]] personality 
i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*)
+
+  __block int x = 10;
+
+  // CHECK: invoke arm_aapcscc void @test1_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
+  test1_helper(^(int v) { x = v; });
+
+  // CHECK:  landingpad { i8*, i32 }
+  // CHECK-NEXT:   cleanup
+}
+
+void test2_helper();
+void test2() {
+  // CHECK: define arm_aapcscc void @test2() [[STRICTFP0]] personality i8* 
bitcast (i32 (...)* @__gcc_personality_sj0 to i8*) {
+  __block int x = 10;
+  ^{ (void)x; };
+
+  // CHECK: invoke arm_aapcscc void @test2_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
+  test2_helper(5, 6, 7);
+
+  // CHECK:  landingpad { i8*, i32 }
+  // CHECK-NEXT:   cleanup
+}
+void test2_helper(int x, int y) {
+}
+
+// CHECK: attributes [[STRICTFP0]] = { {{.*}}strictfp{{.*}} }
+// CHECK: attributes [[STRICTFP1]] = { strictfp }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index c2b3446d159f..6010f1a706a3 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@ class IRBuilderBase {
 }
   }
 
-  void setConstrainedFPCallAttr(CallInst *I) {
+  void setConstrainedFPCallAttr(CallBase *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1023,16 +1023,21 @@ class IRBuilderBase {
ArrayRef Args,
ArrayRef OpBundles,
const Twine &Name = "") {
-return Insert(
-InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles),
-Name);
+InvokeInst *II =
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles);
+if (IsFPConstrained)
+  setConstrainedFPCallAttr(II);
+return Insert(II, Name);
   }
   InvokeInst *CreateInvoke(FunctionType *Ty, Value *Callee,
BasicBlock *NormalDest, BasicBlock *UnwindDest,
ArrayRef Args = None,
const Twine &Name = "") {
-return Insert(InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args),
-  Name);
+InvokeInst *II =
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
+if (IsFPConstrained)
+  setConstrainedFPCallAttr(II);
+return Insert(II, Name);
   }
 
   InvokeInst *CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest,



___
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] f3e8f27 - [mlir] Fix GPUToNVVM test

2020-12-15 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-15T18:41:16+01:00
New Revision: f3e8f27ca1170c2d74c4f1df51fa66e95588ef1a

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

LOG: [mlir] Fix GPUToNVVM test

Added: 


Modified: 
mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Removed: 




diff  --git a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir 
b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
index af6766bba6f4..21be3b6297e2 100644
--- a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
+++ b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
@@ -397,14 +397,14 @@ gpu.module @test_module {
 // -
 
 gpu.module @test_module {
-  // CHECK: llvm.func @__nv_powf(!llvm.float) -> !llvm.float
-  // CHECK: llvm.func @__nv_pow(!llvm.double) -> !llvm.double
+  // CHECK: llvm.func @__nv_powf(!llvm.float, !llvm.float) -> !llvm.float
+  // CHECK: llvm.func @__nv_pow(!llvm.double, !llvm.double) -> !llvm.double
   // CHECK-LABEL: func @gpu_pow
   func @gpu_pow(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
-%result32 = std.pow %arg_f32, %arg_f32 : f32
-// CHECK: llvm.call @__nv_powf(%{{.*}}, %{{.*}}) : (!llvm.float) -> 
!llvm.float
-%result64 = std.pow %arg_f64, %arg_f64 : f64
-// CHECK: llvm.call @__nv_pow(%{{.*}}, %{{.*}}) : (!llvm.double) -> 
!llvm.double
+%result32 = std.powf %arg_f32, %arg_f32 : f32
+// CHECK: llvm.call @__nv_powf(%{{.*}}, %{{.*}}) : (!llvm.float, 
!llvm.float) -> !llvm.float
+%result64 = std.powf %arg_f64, %arg_f64 : f64
+// CHECK: llvm.call @__nv_pow(%{{.*}}, %{{.*}}) : (!llvm.double, 
!llvm.double) -> !llvm.double
 std.return %result32, %result64 : f32, f64
   }
 }



___
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] 32e7a9c - Revert "[clangd] Log remote index connectivity status"

2020-12-15 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-12-15T18:42:42+01:00
New Revision: 32e7a9cab6412cb4bb5add5cb2d48be82e7d9f11

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

LOG: Revert "[clangd] Log remote index connectivity status"

This reverts commit dcdef5b5b3df457566e7faf61e1e5789c42528d1.

This commit breaks clangd-ubuntu-tsan builds:
http://lab.llvm.org:8011/#builders/131/builds/1392

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Client.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index 4720b20402e1..0387e65db7d0 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -19,40 +19,14 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
-#include 
 #include 
-#include 
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
-llvm::StringRef toString(const grpc_connectivity_state &State) {
-  switch (State) {
-  case GRPC_CHANNEL_IDLE:
-return "idle";
-  case GRPC_CHANNEL_CONNECTING:
-return "connecting";
-  case GRPC_CHANNEL_READY:
-return "ready";
-  case GRPC_CHANNEL_TRANSIENT_FAILURE:
-return "transient failure";
-  case GRPC_CHANNEL_SHUTDOWN:
-return "shutdown";
-  }
-  llvm_unreachable("Not a valid grpc_connectivity_state.");
-}
-
 class IndexClient : public clangd::SymbolIndex {
-  void updateConnectionStatus() const {
-auto NewStatus = Channel->GetState(/*try_to_connect=*/false);
-auto OldStatus = ConnectionStatus.exchange(NewStatus);
-if (OldStatus != NewStatus)
-  vlog("Remote index connection [{0}]: {1} => {2}", ServerAddress,
-   toString(OldStatus), toString(NewStatus));
-  }
-
   template 
   using StreamingCall = std::unique_ptr> (
   remote::v1::SymbolIndex::Stub::*)(grpc::ClientContext *,
@@ -63,7 +37,6 @@ class IndexClient : public clangd::SymbolIndex {
   bool streamRPC(ClangdRequestT Request,
  StreamingCall RPCCall,
  CallbackT Callback) const {
-updateConnectionStatus();
 bool FinalResult = false;
 trace::Span Tracer(RequestT::descriptor()->name());
 const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
@@ -104,21 +77,18 @@ class IndexClient : public clangd::SymbolIndex {
 SPAN_ATTACH(Tracer, "Status", Reader->Finish().ok());
 SPAN_ATTACH(Tracer, "Successful", Successful);
 SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
-updateConnectionStatus();
 return FinalResult;
   }
 
 public:
   IndexClient(
-  std::shared_ptr Channel, llvm::StringRef Address,
-  llvm::StringRef ProjectRoot,
+  std::shared_ptr Channel, llvm::StringRef ProjectRoot,
+  llvm::StringRef Address,
   std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
-  : Stub(remote::v1::SymbolIndex::NewStub(Channel)), Channel(Channel),
-ServerAddress(Address),
-ConnectionStatus(Channel->GetState(/*try_to_connect=*/true)),
+  : Stub(remote::v1::SymbolIndex::NewStub(Channel)),
 ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"",
   /*LocalIndexRoot=*/ProjectRoot)),
-DeadlineWaitingTime(DeadlineTime) {
+ServerAddress(Address), DeadlineWaitingTime(DeadlineTime) {
 assert(!ProjectRoot.empty());
   }
 
@@ -158,9 +128,6 @@ class IndexClient : public clangd::SymbolIndex {
 
 private:
   std::unique_ptr Stub;
-  std::shared_ptr Channel;
-  llvm::SmallString<256> ServerAddress;
-  mutable std::atomic ConnectionStatus;
   std::unique_ptr ProtobufMarshaller;
   llvm::SmallString<256> ServerAddress;
   // Each request will be terminated if it takes too long.
@@ -173,8 +140,9 @@ std::unique_ptr 
getClient(llvm::StringRef Address,
llvm::StringRef ProjectRoot) {
   const auto Channel =
   grpc::CreateChannel(Address.str(), grpc::InsecureChannelCredentials());
+  Channel->GetState(true);
   return std::unique_ptr(
-  new IndexClient(Channel, Address, ProjectRoot));
+  new IndexClient(Channel, ProjectRoot, Address));
 }
 
 } // namespace remote



___
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] 9adc645 - [mlir] Add std.powf to ROCDL lowering.

2020-12-15 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-15T18:47:49+01:00
New Revision: 9adc64539f97e531b865e4864b9965b0a99fd70f

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

LOG: [mlir] Add std.powf to ROCDL lowering.

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

Added: 


Modified: 
mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp 
b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
index b6f4238a4a5e..e87ca62c9b81 100644
--- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -84,7 +84,7 @@ void 
mlir::configureGpuToROCDLConversionLegality(ConversionTarget &target) {
   target.addIllegalDialect();
   target.addIllegalOp();
+  LLVM::PowOp, LLVM::SinOp, LLVM::SqrtOp>();
 
   // TODO: Remove once we support replacing non-root ops.
   target.addLegalOp();
@@ -123,6 +123,8 @@ void mlir::populateGpuToROCDLConversionPatterns(
  "__ocml_log10_f64");
   patterns.insert>(converter, "__ocml_log2_f32",
 "__ocml_log2_f64");
+  patterns.insert>(converter, "__ocml_pow_f32",
+"__ocml_pow_f64");
   patterns.insert>(converter, "__ocml_rsqrt_f32",
  "__ocml_rsqrt_f64");
   patterns.insert>(converter, "__ocml_sin_f32",

diff  --git a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir 
b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
index c57f98571df6..dc23d436cab5 100644
--- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
+++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
@@ -310,3 +310,18 @@ gpu.module @test_module {
 std.return %result32, %result64 : f32, f64
   }
 }
+
+// -
+
+gpu.module @test_module {
+  // CHECK: llvm.func @__ocml_pow_f32(!llvm.float, !llvm.float) -> !llvm.float
+  // CHECK: llvm.func @__ocml_pow_f64(!llvm.double, !llvm.double) -> 
!llvm.double
+  // CHECK-LABEL: func @gpu_pow
+  func @gpu_pow(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+%result32 = std.powf %arg_f32, %arg_f32 : f32
+// CHECK: llvm.call @__ocml_pow_f32(%{{.*}}, %{{.*}}) : (!llvm.float, 
!llvm.float) -> !llvm.float
+%result64 = std.powf %arg_f64, %arg_f64 : f64
+// CHECK: llvm.call @__ocml_pow_f64(%{{.*}}, %{{.*}}) : (!llvm.double, 
!llvm.double) -> !llvm.double
+std.return %result32, %result64 : f32, f64
+  }
+}



___
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] c50f3a8 - [NFC] Update extract-bits.ll

2020-12-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-15T09:52:17-08:00
New Revision: c50f3a8781abe0ff88c6ba70edba6e59bf998706

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

LOG: [NFC] Update extract-bits.ll

Running update_llc_test_checks adds @PLT annotations to a number of
calls.

Added: 


Modified: 
llvm/test/CodeGen/X86/extract-bits.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/extract-bits.ll 
b/llvm/test/CodeGen/X86/extract-bits.ll
index 9825b828eddf..c128a00fc91a 100644
--- a/llvm/test/CodeGen/X86/extract-bits.ll
+++ b/llvm/test/CodeGen/X86/extract-bits.ll
@@ -453,7 +453,7 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 
%numskipbits, i32 %numlowbits
 ; X86-NOBMI-NEXT:decl %esi
 ; X86-NOBMI-NEXT:andl %edi, %esi
 ; X86-NOBMI-NEXT:movl %eax, (%esp)
-; X86-NOBMI-NEXT:calll use32
+; X86-NOBMI-NEXT:calll use32@PLT
 ; X86-NOBMI-NEXT:movl %esi, %eax
 ; X86-NOBMI-NEXT:addl $4, %esp
 ; X86-NOBMI-NEXT:popl %esi
@@ -471,7 +471,7 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 
%numskipbits, i32 %numlowbits
 ; X86-BMI1NOTBM-NEXT:orl %ecx, %edx
 ; X86-BMI1NOTBM-NEXT:bextrl %edx, {{[0-9]+}}(%esp), %esi
 ; X86-BMI1NOTBM-NEXT:movl %eax, (%esp)
-; X86-BMI1NOTBM-NEXT:calll use32
+; X86-BMI1NOTBM-NEXT:calll use32@PLT
 ; X86-BMI1NOTBM-NEXT:movl %esi, %eax
 ; X86-BMI1NOTBM-NEXT:addl $8, %esp
 ; X86-BMI1NOTBM-NEXT:popl %esi
@@ -486,7 +486,7 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 
%numskipbits, i32 %numlowbits
 ; X86-BMI1BMI2-NEXT:shrxl %ecx, {{[0-9]+}}(%esp), %edx
 ; X86-BMI1BMI2-NEXT:bzhil %eax, %edx, %esi
 ; X86-BMI1BMI2-NEXT:movl %ecx, (%esp)
-; X86-BMI1BMI2-NEXT:calll use32
+; X86-BMI1BMI2-NEXT:calll use32@PLT
 ; X86-BMI1BMI2-NEXT:movl %esi, %eax
 ; X86-BMI1BMI2-NEXT:addl $8, %esp
 ; X86-BMI1BMI2-NEXT:popl %esi
@@ -503,7 +503,7 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 
%numskipbits, i32 %numlowbits
 ; X64-NOBMI-NEXT:decl %ebx
 ; X64-NOBMI-NEXT:andl %edi, %ebx
 ; X64-NOBMI-NEXT:movl %esi, %edi
-; X64-NOBMI-NEXT:callq use32
+; X64-NOBMI-NEXT:callq use32@PLT
 ; X64-NOBMI-NEXT:movl %ebx, %eax
 ; X64-NOBMI-NEXT:popq %rbx
 ; X64-NOBMI-NEXT:retq
@@ -516,7 +516,7 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 
%numskipbits, i32 %numlowbits
 ; X64-BMI1NOTBM-NEXT:orl %edx, %eax
 ; X64-BMI1NOTBM-NEXT:bextrl %eax, %edi, %ebx
 ; X64-BMI1NOTBM-NEXT:movl %esi, %edi
-; X64-BMI1NOTBM-NEXT:callq use32
+; X64-BMI1NOTBM-NEXT:callq use32@PLT
 ; X64-BMI1NOTBM-NEXT:movl %ebx, %eax
 ; X64-BMI1NOTBM-NEXT:popq %rbx
 ; X64-BMI1NOTBM-NEXT:retq
@@ -527,7 +527,7 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 
%numskipbits, i32 %numlowbits
 ; X64-BMI1BMI2-NEXT:shrxl %esi, %edi, %eax
 ; X64-BMI1BMI2-NEXT:bzhil %edx, %eax, %ebx
 ; X64-BMI1BMI2-NEXT:movl %esi, %edi
-; X64-BMI1BMI2-NEXT:callq use32
+; X64-BMI1BMI2-NEXT:callq use32@PLT
 ; X64-BMI1BMI2-NEXT:movl %ebx, %eax
 ; X64-BMI1BMI2-NEXT:popq %rbx
 ; X64-BMI1BMI2-NEXT:retq
@@ -1455,7 +1455,7 @@ define i64 @bextr64_a5_skipextrauses(i64 %val, i64 
%numskipbits, i64 %numlowbits
 ; X86-NOBMI-NEXT:subl $8, %esp
 ; X86-NOBMI-NEXT:pushl {{[0-9]+}}(%esp)
 ; X86-NOBMI-NEXT:pushl %eax
-; X86-NOBMI-NEXT:calll use64
+; X86-NOBMI-NEXT:calll use64@PLT
 ; X86-NOBMI-NEXT:addl $16, %esp
 ; X86-NOBMI-NEXT:movl %esi, %eax
 ; X86-NOBMI-NEXT:movl %edi, %edx
@@ -1505,7 +1505,7 @@ define i64 @bextr64_a5_skipextrauses(i64 %val, i64 
%numskipbits, i64 %numlowbits
 ; X86-BMI1NOTBM-NEXT:subl $8, %esp
 ; X86-BMI1NOTBM-NEXT:pushl {{[0-9]+}}(%esp)
 ; X86-BMI1NOTBM-NEXT:pushl %eax
-; X86-BMI1NOTBM-NEXT:calll use64
+; X86-BMI1NOTBM-NEXT:calll use64@PLT
 ; X86-BMI1NOTBM-NEXT:addl $16, %esp
 ; X86-BMI1NOTBM-NEXT:movl %esi, %eax
 ; X86-BMI1NOTBM-NEXT:movl %edi, %edx
@@ -1554,7 +1554,7 @@ define i64 @bextr64_a5_skipextrauses(i64 %val, i64 
%numskipbits, i64 %numlowbits
 ; X86-BMI1BMI2-NEXT:subl $8, %esp
 ; X86-BMI1BMI2-NEXT:pushl {{[0-9]+}}(%esp)
 ; X86-BMI1BMI2-NEXT:pushl %eax
-; X86-BMI1BMI2-NEXT:calll use64
+; X86-BMI1BMI2-NEXT:calll use64@PLT
 ; X86-BMI1BMI2-NEXT:addl $16, %esp
 ; X86-BMI1BMI2-NEXT:movl %edi, %eax
 ; X86-BMI1BMI2-NEXT:movl %esi, %edx
@@ -1576,7 +1576,7 @@ define i64 @bextr64_a5_skipextrauses(i64 %val, i64 
%numskipbits, i64 %numlowbits
 ; X64-NOBMI-NEXT:decq %rbx
 ; X64-NOBMI-NEXT:andq %rdi, %rbx
 ; X64-NOBMI-NEXT:movq %rsi, %rdi
-; X64-NOBMI-NEXT:callq use64
+; X64-NOBMI-NEXT:callq use64@PLT
 ; X64-NOBMI-NEXT:movq %rbx, %rax
 ; X64-NOBMI-NEXT:popq %rbx
 ; X64-NOBMI-NEXT:retq
@@ -1589,7 +1589,7 @@ define i64 @bextr64_a5_s

[llvm-branch-commits] [mlir] c77ea40 - [mlir] Add std.pow lowering to LLVMIR

2020-12-15 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-15T18:54:29+01:00
New Revision: c77ea40528de7d5bf74b19819b82eeb0e5dab89d

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

LOG: [mlir] Add std.pow lowering to LLVMIR

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

Added: 


Modified: 
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp 
b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 939bc7d50e27..f30048186a0b 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1681,6 +1681,7 @@ using MulFOpLowering = VectorConvertToLLVMPattern;
 using MulIOpLowering = VectorConvertToLLVMPattern;
 using NegFOpLowering = VectorConvertToLLVMPattern;
 using OrOpLowering = VectorConvertToLLVMPattern;
+using PowFOpLowering = VectorConvertToLLVMPattern;
 using RemFOpLowering = VectorConvertToLLVMPattern;
 using SelectOpLowering = OneToOneConvertToLLVMPattern;
 using ShiftLeftOpLowering =
@@ -3963,6 +3964,7 @@ void mlir::populateStdToLLVMNonMemoryConversionPatterns(
   MulIOpLowering,
   NegFOpLowering,
   OrOpLowering,
+  PowFOpLowering,
   PrefetchOpLowering,
   ReOpLowering,
   RemFOpLowering,

diff  --git a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir 
b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
index 9c709a653b27..acb894af1f38 100644
--- a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
+++ b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
@@ -213,3 +213,13 @@ func @call_zero_result_func() {
   return
 }
 func private @zero_result_func()
+
+// -
+
+// CHECK-LABEL: func @powf(
+// CHECK-SAME: !llvm.double
+func @powf(%arg0 : f64) {
+  // CHECK: %[[POWF:.*]] = "llvm.intr.pow"(%arg0, %arg0) : (!llvm.double, 
!llvm.double) -> !llvm.double
+  %0 = std.powf %arg0, %arg0 : f64
+  std.return
+}



___
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] 2ec5973 - Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute."

2020-12-15 Thread Kevin P. Neal via llvm-branch-commits

Author: Kevin P. Neal
Date: 2020-12-15T12:58:47-05:00
New Revision: 2ec5973fddb07e66ae0df7d0aac2cda55387b0bd

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

LOG: Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the 
strictfp attribute."

The test is busted on some hosts that aren't the one I'm using.

This reverts commit 67a1ffd88ac08526bb6cfc7b3f607e6668ba1c70.

Added: 


Modified: 
llvm/include/llvm/IR/IRBuilder.h

Removed: 
clang/test/CodeGen/exceptions-strictfp.c



diff  --git a/clang/test/CodeGen/exceptions-strictfp.c 
b/clang/test/CodeGen/exceptions-strictfp.c
deleted file mode 100644
index f1c279908e45..
--- a/clang/test/CodeGen/exceptions-strictfp.c
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clang_cc1 -triple armv7-apple-unknown -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s -fexceptions 
-fsjlj-exceptions -fblocks | FileCheck %s
-
-// Verify strictfp attributes on invoke calls (and therefore also on
-// function definitions).
-
-// rdar://problem/8621849
-void test1() {
-  extern void test1_helper(void (^)(int));
-
-  // CHECK: define arm_aapcscc void @test1() [[STRICTFP0:#[0-9]+]] personality 
i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*)
-
-  __block int x = 10;
-
-  // CHECK: invoke arm_aapcscc void @test1_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
-  test1_helper(^(int v) { x = v; });
-
-  // CHECK:  landingpad { i8*, i32 }
-  // CHECK-NEXT:   cleanup
-}
-
-void test2_helper();
-void test2() {
-  // CHECK: define arm_aapcscc void @test2() [[STRICTFP0]] personality i8* 
bitcast (i32 (...)* @__gcc_personality_sj0 to i8*) {
-  __block int x = 10;
-  ^{ (void)x; };
-
-  // CHECK: invoke arm_aapcscc void @test2_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
-  test2_helper(5, 6, 7);
-
-  // CHECK:  landingpad { i8*, i32 }
-  // CHECK-NEXT:   cleanup
-}
-void test2_helper(int x, int y) {
-}
-
-// CHECK: attributes [[STRICTFP0]] = { {{.*}}strictfp{{.*}} }
-// CHECK: attributes [[STRICTFP1]] = { strictfp }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 6010f1a706a3..c2b3446d159f 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@ class IRBuilderBase {
 }
   }
 
-  void setConstrainedFPCallAttr(CallBase *I) {
+  void setConstrainedFPCallAttr(CallInst *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1023,21 +1023,16 @@ class IRBuilderBase {
ArrayRef Args,
ArrayRef OpBundles,
const Twine &Name = "") {
-InvokeInst *II =
-InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles);
-if (IsFPConstrained)
-  setConstrainedFPCallAttr(II);
-return Insert(II, Name);
+return Insert(
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles),
+Name);
   }
   InvokeInst *CreateInvoke(FunctionType *Ty, Value *Callee,
BasicBlock *NormalDest, BasicBlock *UnwindDest,
ArrayRef Args = None,
const Twine &Name = "") {
-InvokeInst *II =
-InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
-if (IsFPConstrained)
-  setConstrainedFPCallAttr(II);
-return Insert(II, Name);
+return Insert(InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args),
+  Name);
   }
 
   InvokeInst *CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest,



___
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] [libcxx] d1da346 - [libc++] Fix synopsis in string::ends_with test. NFC.

2020-12-15 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-12-15T19:03:11+01:00
New Revision: d1da346296fd19f110975f6f9facdb486d0e0e28

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

LOG: [libc++] Fix synopsis in string::ends_with test. NFC.

Added: 


Modified: 

libcxx/test/std/strings/string.view/string.view.template/ends_with.ptr.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/strings/string.view/string.view.template/ends_with.ptr.pass.cpp
 
b/libcxx/test/std/strings/string.view/string.view.template/ends_with.ptr.pass.cpp
index b10a546c10c7..51339641632e 100644
--- 
a/libcxx/test/std/strings/string.view/string.view.template/ends_with.ptr.pass.cpp
+++ 
b/libcxx/test/std/strings/string.view/string.view.template/ends_with.ptr.pass.cpp
@@ -9,7 +9,7 @@
 
 // 
 
-//   constexpr bool starts_with(const CharT *x) const;
+//   constexpr bool ends_with(const CharT *x) const;
 
 #include 
 #include 



___
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] 1183e55 - [NFC] update extract-lowbits.ll and scalar-pf-to-i64.ll

2020-12-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-15T10:04:45-08:00
New Revision: 1183e55580cad9cae3830c261070c32263aad108

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

LOG: [NFC] update extract-lowbits.ll and scalar-pf-to-i64.ll

Auto-updated with update_llc_test_checks

Added: 


Modified: 
llvm/test/CodeGen/X86/extract-lowbits.ll
llvm/test/CodeGen/X86/scalar-fp-to-i64.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/extract-lowbits.ll 
b/llvm/test/CodeGen/X86/extract-lowbits.ll
index e93638132e7d..4c11d5514022 100644
--- a/llvm/test/CodeGen/X86/extract-lowbits.ll
+++ b/llvm/test/CodeGen/X86/extract-lowbits.ll
@@ -868,7 +868,7 @@ define i32 @bzhi64_32_a1_trunc_extrause(i64 %val, i32 
%numlowbits) nounwind {
 ; X86-NOBMI-NEXT:movb {{[0-9]+}}(%esp), %bl
 ; X86-NOBMI-NEXT:movl {{[0-9]+}}(%esp), %esi
 ; X86-NOBMI-NEXT:movl %esi, (%esp)
-; X86-NOBMI-NEXT:calll use32
+; X86-NOBMI-NEXT:calll use32@PLT
 ; X86-NOBMI-NEXT:movl $1, %eax
 ; X86-NOBMI-NEXT:movl %ebx, %ecx
 ; X86-NOBMI-NEXT:shll %cl, %eax
@@ -887,7 +887,7 @@ define i32 @bzhi64_32_a1_trunc_extrause(i64 %val, i32 
%numlowbits) nounwind {
 ; X86-BMI1NOTBM-NEXT:movb {{[0-9]+}}(%esp), %bl
 ; X86-BMI1NOTBM-NEXT:movl {{[0-9]+}}(%esp), %esi
 ; X86-BMI1NOTBM-NEXT:movl %esi, (%esp)
-; X86-BMI1NOTBM-NEXT:calll use32
+; X86-BMI1NOTBM-NEXT:calll use32@PLT
 ; X86-BMI1NOTBM-NEXT:shll $8, %ebx
 ; X86-BMI1NOTBM-NEXT:bextrl %ebx, %esi, %eax
 ; X86-BMI1NOTBM-NEXT:addl $4, %esp
@@ -903,7 +903,7 @@ define i32 @bzhi64_32_a1_trunc_extrause(i64 %val, i32 
%numlowbits) nounwind {
 ; X86-BMI1BMI2-NEXT:movb {{[0-9]+}}(%esp), %bl
 ; X86-BMI1BMI2-NEXT:movl {{[0-9]+}}(%esp), %esi
 ; X86-BMI1BMI2-NEXT:movl %esi, (%esp)
-; X86-BMI1BMI2-NEXT:calll use32
+; X86-BMI1BMI2-NEXT:calll use32@PLT
 ; X86-BMI1BMI2-NEXT:bzhil %ebx, %esi, %eax
 ; X86-BMI1BMI2-NEXT:addl $4, %esp
 ; X86-BMI1BMI2-NEXT:popl %esi
@@ -917,7 +917,7 @@ define i32 @bzhi64_32_a1_trunc_extrause(i64 %val, i32 
%numlowbits) nounwind {
 ; X64-NOBMI-NEXT:pushq %rax
 ; X64-NOBMI-NEXT:movl %esi, %ebp
 ; X64-NOBMI-NEXT:movq %rdi, %rbx
-; X64-NOBMI-NEXT:callq use32
+; X64-NOBMI-NEXT:callq use32@PLT
 ; X64-NOBMI-NEXT:movl $1, %eax
 ; X64-NOBMI-NEXT:movl %ebp, %ecx
 ; X64-NOBMI-NEXT:shll %cl, %eax
@@ -935,7 +935,7 @@ define i32 @bzhi64_32_a1_trunc_extrause(i64 %val, i32 
%numlowbits) nounwind {
 ; X64-BMI1NOTBM-NEXT:pushq %rax
 ; X64-BMI1NOTBM-NEXT:movl %esi, %ebx
 ; X64-BMI1NOTBM-NEXT:movq %rdi, %r14
-; X64-BMI1NOTBM-NEXT:callq use32
+; X64-BMI1NOTBM-NEXT:callq use32@PLT
 ; X64-BMI1NOTBM-NEXT:shll $8, %ebx
 ; X64-BMI1NOTBM-NEXT:bextrl %ebx, %r14d, %eax
 ; X64-BMI1NOTBM-NEXT:addq $8, %rsp
@@ -950,7 +950,7 @@ define i32 @bzhi64_32_a1_trunc_extrause(i64 %val, i32 
%numlowbits) nounwind {
 ; X64-BMI1BMI2-NEXT:pushq %rax
 ; X64-BMI1BMI2-NEXT:movl %esi, %ebp
 ; X64-BMI1BMI2-NEXT:movq %rdi, %rbx
-; X64-BMI1BMI2-NEXT:callq use32
+; X64-BMI1BMI2-NEXT:callq use32@PLT
 ; X64-BMI1BMI2-NEXT:bzhil %ebp, %ebx, %eax
 ; X64-BMI1BMI2-NEXT:addq $8, %rsp
 ; X64-BMI1BMI2-NEXT:popq %rbx
@@ -2057,7 +2057,7 @@ define i32 @bzhi32_c0(i32 %val, i32 %numlowbits) nounwind 
{
 ; X86-NOBMI-NEXT:# kill: def $cl killed $cl killed $ecx
 ; X86-NOBMI-NEXT:shrl %cl, %esi
 ; X86-NOBMI-NEXT:movl %esi, (%esp)
-; X86-NOBMI-NEXT:calll use32
+; X86-NOBMI-NEXT:calll use32@PLT
 ; X86-NOBMI-NEXT:andl {{[0-9]+}}(%esp), %esi
 ; X86-NOBMI-NEXT:movl %esi, %eax
 ; X86-NOBMI-NEXT:addl $8, %esp
@@ -2074,7 +2074,7 @@ define i32 @bzhi32_c0(i32 %val, i32 %numlowbits) nounwind 
{
 ; X86-BMI1NOTBM-NEXT:# kill: def $cl killed $cl killed $ecx
 ; X86-BMI1NOTBM-NEXT:shrl %cl, %esi
 ; X86-BMI1NOTBM-NEXT:movl %esi, (%esp)
-; X86-BMI1NOTBM-NEXT:calll use32
+; X86-BMI1NOTBM-NEXT:calll use32@PLT
 ; X86-BMI1NOTBM-NEXT:andl {{[0-9]+}}(%esp), %esi
 ; X86-BMI1NOTBM-NEXT:movl %esi, %eax
 ; X86-BMI1NOTBM-NEXT:addl $8, %esp
@@ -2091,7 +2091,7 @@ define i32 @bzhi32_c0(i32 %val, i32 %numlowbits) nounwind 
{
 ; X86-BMI1BMI2-NEXT:movl $-1, %ecx
 ; X86-BMI1BMI2-NEXT:shrxl %eax, %ecx, %eax
 ; X86-BMI1BMI2-NEXT:movl %eax, (%esp)
-; X86-BMI1BMI2-NEXT:calll use32
+; X86-BMI1BMI2-NEXT:calll use32@PLT
 ; X86-BMI1BMI2-NEXT:bzhil %ebx, {{[0-9]+}}(%esp), %eax
 ; X86-BMI1BMI2-NEXT:addl $8, %esp
 ; X86-BMI1BMI2-NEXT:popl %ebx
@@ -2109,7 +2109,7 @@ define i32 @bzhi32_c0(i32 %val, i32 %numlowbits) nounwind 
{
 ; X64-NOBMI-NEXT:# kill: def $cl killed $cl killed $ecx
 ; X64-NOBMI-NEXT:shrl %cl, %ebp
 ; X64-NOBMI-NEXT:movl %ebp, %edi
-; X64-NOBMI-NEXT:callq use32
+; X64-NOBMI-NEXT:callq use32@P

[llvm-branch-commits] [clang-tools-extra] cfa1010 - [clangd] Provide suggestions with invalid config keys

2020-12-15 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-15T18:16:17Z
New Revision: cfa1010c42429f689186125270dfbad7d6a1c01d

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

LOG: [clangd] Provide suggestions with invalid config keys

Update the config file warning when an unknown key is detected which is likely 
a typo by suggesting the likely key.
This won't suggest a key that has already been seen in the block.

Appends the fix to the diag, however right now there is no support for 
presenting that fix to the user.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/test/config.test
clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index 022d890a9687..20cdc0b2c001 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -24,6 +24,29 @@ using llvm::yaml::Node;
 using llvm::yaml::ScalarNode;
 using llvm::yaml::SequenceNode;
 
+llvm::Optional
+bestGuess(llvm::StringRef Search,
+  llvm::ArrayRef AllowedValues) {
+  unsigned MaxEdit = (Search.size() + 1) / 3;
+  if (!MaxEdit)
+return llvm::None;
+  llvm::Optional Result;
+  for (const auto &AllowedValue : AllowedValues) {
+unsigned EditDistance = Search.edit_distance(AllowedValue, true, MaxEdit);
+// We can't do better than an edit distance of 1, so just return this and
+// save computing other values.
+if (EditDistance == 1U)
+  return AllowedValue;
+if (EditDistance == MaxEdit && !Result) {
+  Result = AllowedValue;
+} else if (EditDistance < MaxEdit) {
+  Result = AllowedValue;
+  MaxEdit = EditDistance;
+}
+  }
+  return Result;
+}
+
 class Parser {
   llvm::SourceMgr &SM;
   bool HadError = false;
@@ -167,6 +190,7 @@ class Parser {
 return;
   }
   llvm::SmallSet Seen;
+  llvm::SmallVector, 0> UnknownKeys;
   // We *must* consume all items, even on error, or the parser will assert.
   for (auto &KV : llvm::cast(N)) {
 auto *K = KV.getKey();
@@ -198,9 +222,30 @@ class Parser {
 Warn = UnknownHandler(
 Located(**Key, K->getSourceRange()), *Value);
   if (Warn)
-Outer->warning("Unknown " + Description + " key " + **Key, *K);
+UnknownKeys.push_back(std::move(*Key));
 }
   }
+  if (!UnknownKeys.empty())
+warnUnknownKeys(UnknownKeys, Seen);
+}
+
+  private:
+void warnUnknownKeys(llvm::ArrayRef> UnknownKeys,
+ const llvm::SmallSet &SeenKeys) const 
{
+  llvm::SmallVector UnseenKeys;
+  for (const auto &KeyAndHandler : Keys)
+if (!SeenKeys.count(KeyAndHandler.first.str()))
+  UnseenKeys.push_back(KeyAndHandler.first);
+
+  for (const Located &UnknownKey : UnknownKeys)
+if (auto BestGuess = bestGuess(*UnknownKey, UnseenKeys))
+  Outer->warning("Unknown " + Description + " key '" + *UnknownKey +
+ "'; did you mean '" + *BestGuess + "'?",
+ UnknownKey.Range);
+else
+  Outer->warning("Unknown " + Description + " key '" + *UnknownKey +
+ "'",
+ UnknownKey.Range);
 }
   };
 
@@ -238,16 +283,20 @@ class Parser {
   }
 
   // Report a "hard" error, reflecting a config file that can never be valid.
-  void error(const llvm::Twine &Msg, const Node &N) {
+  void error(const llvm::Twine &Msg, llvm::SMRange Range) {
 HadError = true;
-SM.PrintMessage(N.getSourceRange().Start, llvm::SourceMgr::DK_Error, Msg,
-N.getSourceRange());
+SM.PrintMessage(Range.Start, llvm::SourceMgr::DK_Error, Msg, Range);
+  }
+  void error(const llvm::Twine &Msg, const Node &N) {
+return error(Msg, N.getSourceRange());
   }
 
   // Report a "soft" error that could be caused by e.g. version skew.
+  void warning(const llvm::Twine &Msg, llvm::SMRange Range) {
+SM.PrintMessage(Range.Start, llvm::SourceMgr::DK_Warning, Msg, Range);
+  }
   void warning(const llvm::Twine &Msg, const Node &N) {
-SM.PrintMessage(N.getSourceRange().Start, llvm::SourceMgr::DK_Warning, Msg,
-N.getSourceRange());
+return warning(Msg, N.getSourceRange());
   }
 };
 

diff  --git a/clang-tools-extra/clangd/test/config.test 
b/clang-tools-extra/clangd/test/config.test
index eb556feefd95..3d5e2bbfc0c8 100644
--- a/clang-tools-extra/clangd/test/config.test
+++ b/clang-tools-extra/clangd/test/config.test
@@ -19,7 +19,7 @@
 # CHECK-NEXT:  "params":

[llvm-branch-commits] [llvm] 99ac886 - [tests][LV] precommit tests for D93317

2020-12-15 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-12-15T10:53:34-08:00
New Revision: 99ac8868cfb403aeffe5b3f13e3487eed79e67b9

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

LOG: [tests][LV] precommit tests for D93317

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/loop-form.ll

Removed: 




diff  --git a/llvm/test/Transforms/LoopVectorize/loop-form.ll 
b/llvm/test/Transforms/LoopVectorize/loop-form.ll
index 3bbe8100e34e..cebe7844bb11 100644
--- a/llvm/test/Transforms/LoopVectorize/loop-form.ll
+++ b/llvm/test/Transforms/LoopVectorize/loop-form.ll
@@ -1,16 +1,80 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -loop-vectorize < %s | FileCheck %s
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
-; Check that we vectorize only bottom-tested loops.
-; This is a reduced testcase from PR21302.
+define void @bottom_tested(i16* %p, i32 %n) {
+; CHECK-LABEL: @bottom_tested(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = icmp sgt i32 [[N:%.*]], 0
+; CHECK-NEXT:[[SMAX:%.*]] = select i1 [[TMP0]], i32 [[N]], i32 0
+; CHECK-NEXT:[[TMP1:%.*]] = add nuw i32 [[SMAX]], 1
+; CHECK-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i32 [[TMP1]], 2
+; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label 
[[VECTOR_PH:%.*]]
+; CHECK:   vector.ph:
+; CHECK-NEXT:[[N_MOD_VF:%.*]] = urem i32 [[TMP1]], 2
+; CHECK-NEXT:[[N_VEC:%.*]] = sub i32 [[TMP1]], [[N_MOD_VF]]
+; CHECK-NEXT:br label [[VECTOR_BODY:%.*]]
+; CHECK:   vector.body:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[TMP2:%.*]] = add i32 [[INDEX]], 0
+; CHECK-NEXT:[[TMP3:%.*]] = sext i32 [[TMP2]] to i64
+; CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds i16, i16* [[P:%.*]], 
i64 [[TMP3]]
+; CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds i16, i16* [[TMP4]], i32 0
+; CHECK-NEXT:[[TMP6:%.*]] = bitcast i16* [[TMP5]] to <2 x i16>*
+; CHECK-NEXT:store <2 x i16> zeroinitializer, <2 x i16>* [[TMP6]], align 4
+; CHECK-NEXT:[[INDEX_NEXT]] = add i32 [[INDEX]], 2
+; CHECK-NEXT:[[TMP7:%.*]] = icmp eq i32 [[INDEX_NEXT]], [[N_VEC]]
+; CHECK-NEXT:br i1 [[TMP7]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]]
+; CHECK:   middle.block:
+; CHECK-NEXT:[[CMP_N:%.*]] = icmp eq i32 [[TMP1]], [[N_VEC]]
+; CHECK-NEXT:br i1 [[CMP_N]], label [[IF_END:%.*]], label [[SCALAR_PH]]
+; CHECK:   scalar.ph:
+; CHECK-NEXT:[[BC_RESUME_VAL:%.*]] = phi i32 [ [[N_VEC]], [[MIDDLE_BLOCK]] 
], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:br label [[FOR_COND:%.*]]
+; CHECK:   for.cond:
+; CHECK-NEXT:[[I:%.*]] = phi i32 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ 
[[INC:%.*]], [[FOR_COND]] ]
+; CHECK-NEXT:[[IPROM:%.*]] = sext i32 [[I]] to i64
+; CHECK-NEXT:[[B:%.*]] = getelementptr inbounds i16, i16* [[P]], i64 
[[IPROM]]
+; CHECK-NEXT:store i16 0, i16* [[B]], align 4
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I]], 1
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[I]], [[N]]
+; CHECK-NEXT:br i1 [[CMP]], label [[FOR_COND]], label [[IF_END]], 
[[LOOP2:!llvm.loop !.*]]
+; CHECK:   if.end:
+; CHECK-NEXT:ret void
 ;
-; rdar://problem/18886083
+entry:
+  br label %for.cond
+
+for.cond:
+  %i = phi i32 [ 0, %entry ], [ %inc, %for.cond ]
+  %iprom = sext i32 %i to i64
+  %b = getelementptr inbounds i16, i16* %p, i64 %iprom
+  store i16 0, i16* %b, align 4
+  %inc = add nsw i32 %i, 1
+  %cmp = icmp slt i32 %i, %n
+  br i1 %cmp, label %for.cond, label %if.end
 
-%struct.X = type { i32, i16 }
-; CHECK-LABEL: @foo(
-; CHECK-NOT: vector.body
+if.end:
+  ret void
+}
 
-define void @foo(i32 %n) {
+define void @early_exit(i16* %p, i32 %n) {
+; CHECK-LABEL: @early_exit(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[FOR_COND:%.*]]
+; CHECK:   for.cond:
+; CHECK-NEXT:[[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], 
[[FOR_BODY:%.*]] ]
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[I]], [[N:%.*]]
+; CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY]], label [[IF_END:%.*]]
+; CHECK:   for.body:
+; CHECK-NEXT:[[IPROM:%.*]] = sext i32 [[I]] to i64
+; CHECK-NEXT:[[B:%.*]] = getelementptr inbounds i16, i16* [[P:%.*]], i64 
[[IPROM]]
+; CHECK-NEXT:store i16 0, i16* [[B]], align 4
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I]], 1
+; CHECK-NEXT:br label [[FOR_COND]]
+; CHECK:   if.end:
+; CHECK-NEXT:ret void
+;
 entry:
   br label %for.cond
 
@@ -21,7 +85,7 @@ for.cond:
 
 for.body:
   %iprom = sext i32 %i to i64
-  %b = getelementptr inbounds %struct.X, %struct.X* undef, i64 %iprom, i32 1
+  %b = getelementptr inbounds i16, i16* %p, i64 %iprom
   store i16 0, i16* %b, align 4
   %inc = add

[llvm-branch-commits] [llvm] a048e2f - [tests] fix an accidental target dependence added in 99ac8868

2020-12-15 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-12-15T11:07:30-08:00
New Revision: a048e2fa1d0285a3582bd224d5652dbf1dc91cb4

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

LOG: [tests] fix an accidental target dependence added in 99ac8868

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/loop-form.ll

Removed: 




diff  --git a/llvm/test/Transforms/LoopVectorize/loop-form.ll 
b/llvm/test/Transforms/LoopVectorize/loop-form.ll
index cebe7844bb11..298143ba726c 100644
--- a/llvm/test/Transforms/LoopVectorize/loop-form.ll
+++ b/llvm/test/Transforms/LoopVectorize/loop-form.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -loop-vectorize < %s | FileCheck %s
+; RUN: opt -S -loop-vectorize -force-vector-width=2 < %s | FileCheck %s
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
 define void @bottom_tested(i16* %p, i32 %n) {



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


[llvm-branch-commits] [lld] 601f0fb - [lld/mac] Set ordinal on dynamic undefined symbols in symbol table

2020-12-15 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-15T14:39:36-05:00
New Revision: 601f0fb8465b9a8a22015f959261c66ec98878a4

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

LOG: [lld/mac] Set ordinal on dynamic undefined symbols in symbol table

This lets `nm -m` print "(from libfoo)" in its output, which is more
accessible than dumping the bind table.

See https://reviews.llvm.org/D57190#2455761 for the somewhat
surprising `AltEntry` that appears in symtab.s.

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

Added: 


Modified: 
lld/MachO/SyntheticSections.cpp
lld/test/MachO/dylink.s
lld/test/MachO/symtab.s

Removed: 




diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 808d3594bfad..c2c121005899 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -753,6 +753,10 @@ void SymtabSection::writeTo(uint8_t *buf) const {
 nList->n_value = defined->getVA();
   }
   nList->n_desc |= defined->isWeakDef() ? MachO::N_WEAK_DEF : 0;
+} else if (auto *dysym = dyn_cast(entry.sym)) {
+  uint16_t n_desc = nList->n_desc;
+  MachO::SET_LIBRARY_ORDINAL(n_desc, dysym->file->ordinal);
+  nList->n_desc = n_desc;
 }
 ++nList;
   }

diff  --git a/lld/test/MachO/dylink.s b/lld/test/MachO/dylink.s
index 2a8e19d966d6..a727b7539397 100644
--- a/lld/test/MachO/dylink.s
+++ b/lld/test/MachO/dylink.s
@@ -38,6 +38,12 @@
 # CHECK-DAG: __DATA   __data 0x{{0*}}[[#%x, DATA_ADDR + 8]]
   pointer 8   libhello   _hello_its_me
 # CHECK-DAG: __DATA   __data 0x{{0*}}[[#%x, DATA_ADDR + 16]]   
   pointer -15 libgoodbye _goodbye_world
 
+# RUN: llvm-nm -m %t/dylink | FileCheck --check-prefix=NM %s
+
+# NM-DAG: _goodbye_world (from libgoodbye)
+# NM-DAG: _hello_its_me (from libhello)
+# NM-DAG: _hello_world (from libhello)
+
 # RUN: llvm-objdump --macho --all-headers %t/dylink | FileCheck %s \
 # RUN:   --check-prefix=LOAD --implicit-check-not LC_LOAD_DYLIB
 ## Check that we don't create duplicate LC_LOAD_DYLIBs.

diff  --git a/lld/test/MachO/symtab.s b/lld/test/MachO/symtab.s
index a4dce665acb4..2fe550a330f1 100644
--- a/lld/test/MachO/symtab.s
+++ b/lld/test/MachO/symtab.s
@@ -62,7 +62,7 @@
 # CHECK-NEXT: Type: Undef (0x0)
 # CHECK-NEXT: Section:  (0x0)
 # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
-# CHECK-NEXT: Flags [ (0x0)
+# CHECK-NEXT: Flags [ (0x100)
 # CHECK-NEXT: ]
 # CHECK-NEXT: Value: 0x0
 # CHECK-NEXT:   }
@@ -71,7 +71,8 @@
 # CHECK-NEXT: Type: Undef (0x0)
 # CHECK-NEXT: Section:  (0x0)
 # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
-# CHECK-NEXT: Flags [ (0x0)
+# CHECK-NEXT: Flags [ (0x200)
+# CHECK-NEXT:   AltEntry (0x200)
 # CHECK-NEXT: ]
 # CHECK-NEXT: Value: 0x0
 # CHECK-NEXT:   }



___
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] 0545680 - Reland dcdef5b5b3df457566e7faf61e1e5789c42528d1

2020-12-15 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-12-15T20:54:55+01:00
New Revision: 0545680cb870f1ca81198cd8324814543eb79e64

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

LOG: Reland dcdef5b5b3df457566e7faf61e1e5789c42528d1

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Client.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index 0387e65db7d0..bda3a971f418 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -19,14 +19,40 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
+#include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
+llvm::StringRef toString(const grpc_connectivity_state &State) {
+  switch (State) {
+  case GRPC_CHANNEL_IDLE:
+return "idle";
+  case GRPC_CHANNEL_CONNECTING:
+return "connecting";
+  case GRPC_CHANNEL_READY:
+return "ready";
+  case GRPC_CHANNEL_TRANSIENT_FAILURE:
+return "transient failure";
+  case GRPC_CHANNEL_SHUTDOWN:
+return "shutdown";
+  }
+  llvm_unreachable("Not a valid grpc_connectivity_state.");
+}
+
 class IndexClient : public clangd::SymbolIndex {
+  void updateConnectionStatus() const {
+auto NewStatus = Channel->GetState(/*try_to_connect=*/false);
+auto OldStatus = ConnectionStatus.exchange(NewStatus);
+if (OldStatus != NewStatus)
+  vlog("Remote index connection [{0}]: {1} => {2}", ServerAddress,
+   toString(OldStatus), toString(NewStatus));
+  }
+
   template 
   using StreamingCall = std::unique_ptr> (
   remote::v1::SymbolIndex::Stub::*)(grpc::ClientContext *,
@@ -37,6 +63,7 @@ class IndexClient : public clangd::SymbolIndex {
   bool streamRPC(ClangdRequestT Request,
  StreamingCall RPCCall,
  CallbackT Callback) const {
+updateConnectionStatus();
 bool FinalResult = false;
 trace::Span Tracer(RequestT::descriptor()->name());
 const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
@@ -77,18 +104,21 @@ class IndexClient : public clangd::SymbolIndex {
 SPAN_ATTACH(Tracer, "Status", Reader->Finish().ok());
 SPAN_ATTACH(Tracer, "Successful", Successful);
 SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
+updateConnectionStatus();
 return FinalResult;
   }
 
 public:
   IndexClient(
-  std::shared_ptr Channel, llvm::StringRef ProjectRoot,
-  llvm::StringRef Address,
+  std::shared_ptr Channel, llvm::StringRef Address,
+  llvm::StringRef ProjectRoot,
   std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
-  : Stub(remote::v1::SymbolIndex::NewStub(Channel)),
+  : Stub(remote::v1::SymbolIndex::NewStub(Channel)), Channel(Channel),
+ServerAddress(Address),
+ConnectionStatus(Channel->GetState(/*try_to_connect=*/true)),
 ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"",
   /*LocalIndexRoot=*/ProjectRoot)),
-ServerAddress(Address), DeadlineWaitingTime(DeadlineTime) {
+DeadlineWaitingTime(DeadlineTime) {
 assert(!ProjectRoot.empty());
   }
 
@@ -128,8 +158,10 @@ class IndexClient : public clangd::SymbolIndex {
 
 private:
   std::unique_ptr Stub;
-  std::unique_ptr ProtobufMarshaller;
+  std::shared_ptr Channel;
   llvm::SmallString<256> ServerAddress;
+  mutable std::atomic ConnectionStatus;
+  std::unique_ptr ProtobufMarshaller;
   // Each request will be terminated if it takes too long.
   std::chrono::milliseconds DeadlineWaitingTime;
 };
@@ -140,9 +172,8 @@ std::unique_ptr 
getClient(llvm::StringRef Address,
llvm::StringRef ProjectRoot) {
   const auto Channel =
   grpc::CreateChannel(Address.str(), grpc::InsecureChannelCredentials());
-  Channel->GetState(true);
   return std::unique_ptr(
-  new IndexClient(Channel, ProjectRoot, Address));
+  new IndexClient(Channel, Address, ProjectRoot));
 }
 
 } // namespace remote



___
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] ef40d52 - Adding a test case that I accidentally dropped from 27ea7d0a6e0dc51e0214707bcc265fa6f9dc9bc6

2020-12-15 Thread Aaron Ballman via llvm-branch-commits

Author: Aaron Ballman
Date: 2020-12-15T14:56:44-05:00
New Revision: ef40d5233b8b6f82927128c5b255cdc3aed9021d

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

LOG: Adding a test case that I accidentally dropped from 
27ea7d0a6e0dc51e0214707bcc265fa6f9dc9bc6

Added: 
clang/test/Parser/attr-availability-xcore.c

Modified: 


Removed: 




diff  --git a/clang/test/Parser/attr-availability-xcore.c 
b/clang/test/Parser/attr-availability-xcore.c
new file mode 100644
index ..0b354a3d01e8
--- /dev/null
+++ b/clang/test/Parser/attr-availability-xcore.c
@@ -0,0 +1,11 @@
+// Test availability message string type when wide characters are 1 byte.
+// REQUIRES: xcore-registered-target
+// RUN: %clang_cc1 -triple xcore -fsyntax-only -verify %s
+
+#if !__has_feature(attribute_availability)
+#  error 'availability' attribute is not available
+#endif
+
+void f7() __attribute__((availability(macosx,message=L"wide"))); // 
expected-error {{expected string literal for optional message in 'availability' 
attribute}}
+
+void f8() __attribute__((availability(macosx,message="a" L"b"))); // 
expected-error {{expected string literal for optional message in 'availability' 
attribute}}



___
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] 6c365cd - Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types.

2020-12-15 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-15T12:00:57-08:00
New Revision: 6c365cd31e323d2d075573edd927e4f7fb5ec01c

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

LOG: Consider reference, pointer, and pointer-to-member TemplateArguments to be 
different if they have different types.

For the Itanium ABI, this implements the mangling rule suggested in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47, namely mangling
such template arguments as being cast to the parameter type in the case
where the template name is overloadable. This can cause a mangling
change for rare cases, where

 * the template argument declaration is converted from its declared type
   to the type of the template parameter, and
 * the template parameter either has a deduced type or is a parameter of
   a function template.

However, such changes are necessary to avoid mangling collisions. The
ABI changes can be reversed with -fclang-abi-compat=11 or earlier.

Re-commit with a fix for a couple of regressions.

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGenCXX/clang-abi-compat.cpp
clang/test/CodeGenCXX/mangle-class-nttp.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/SemaTemplate/temp_arg_nontype.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index be2c7a004e0b..ed9f729417af 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -158,8 +158,10 @@ 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, and to not
-/// properly mangle substitutions for template names in some cases.
+/// vector member on the stack instead of using registers, to not properly
+/// mangle substitutions for template names in some cases, and to mangle
+/// declaration template arguments without a cast to the parameter type
+/// even when that can lead to mangling collisions.
 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 f5a4f6708c83..f2e9bc727ac6 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -551,13 +551,15 @@ class CXXNameMangler {
   void mangleCXXCtorType(CXXCtorType T, const CXXRecordDecl *InheritedFrom);
   void mangleCXXDtorType(CXXDtorType T);
 
-  void mangleTemplateArgs(const TemplateArgumentLoc *TemplateArgs,
+  void mangleTemplateArgs(TemplateName TN,
+  const TemplateArgumentLoc *TemplateArgs,
   unsigned NumTemplateArgs);
-  void mangleTemplateArgs(const TemplateArgument *TemplateArgs,
+  void mangleTemplateArgs(TemplateName TN, const TemplateArgument 
*TemplateArgs,
   unsigned NumTemplateArgs);
-  void mangleTemplateArgs(const TemplateArgumentList &AL);
-  void mangleTemplateArg(TemplateArgument A);
-  void mangleValueInTemplateArg(QualType T, const APValue &V);
+  void mangleTemplateArgs(TemplateName TN, const TemplateArgumentList &AL);
+  void mangleTemplateArg(TemplateArgument A, bool NeedExactType);
+  void mangleValueInTemplateArg(QualType T, const APValue &V, bool TopLevel,
+bool NeedExactType = false);
 
   void mangleTemplateParameter(unsigned Depth, unsigned Index);
 
@@ -823,6 +825,11 @@ isTemplate(GlobalDecl GD, const TemplateArgumentList 
*&TemplateArgs) {
   return GlobalDecl();
 }
 
+static TemplateName asTemplateName(GlobalDecl GD) {
+  const TemplateDecl *TD = dyn_cast_or_null(GD.getDecl());
+  return TemplateName(const_cast(TD));
+}
+
 void CXXNameMangler::mangleName(GlobalDecl GD) {
   const NamedDecl *ND = cast(GD.getDecl());
   if (const VarDecl *VD = dyn_cast(ND)) {
@@ -899,7 +906,7 @@ void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD,
 const TemplateArgumentList *TemplateArgs = nullptr;
 if (GlobalDecl TD = isTemplate(GD, TemplateArgs)) {
   mangleUnscopedTemplateName(TD, AdditionalAbiTags);
-  mangleTemplateArgs(*TemplateArgs);
+  mangleTemplateArgs(asTemplateName(TD), *TemplateArgs);
   return;
 }
 
@@ -952,7 +959,7 @@ void CXXNameMangler::mangleTemplateName(const TemplateDecl 
*TD,
 
   if (DC->isTranslationUnit() || isStdNamespace(DC)) {
 mangleUnsco

[llvm-branch-commits] [clang] 76edf98 - Set decl on DeclRefExpr directly during deserialization rather than

2020-12-15 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-15T12:00:57-08:00
New Revision: 76edf98b27c45f1aa26c1972927ce1638cda50fd

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

LOG: Set decl on DeclRefExpr directly during deserialization rather than
relying on a setter that might have additional side-effects. NFC.

Added: 


Modified: 
clang/lib/Serialization/ASTReaderStmt.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderStmt.cpp 
b/clang/lib/Serialization/ASTReaderStmt.cpp
index 8b9d4a127691..0e1af53303b4 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -614,7 +614,7 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
 *E->getTrailingObjects(),
 E->getTrailingObjects(), NumTemplateArgs);
 
-  E->setDecl(readDeclAs());
+  E->D = readDeclAs();
   E->setLocation(readSourceLocation());
   E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
 }



___
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] 922d3d5 - [mlir] Allow nested regions in inlineRegionAndEmitStore

2020-12-15 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-15T21:02:57+01:00
New Revision: 922d3d55220dfcfde1f68d17fddca5680aff9545

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

LOG: [mlir] Allow nested regions in inlineRegionAndEmitStore

This is useful for scalar code that uses for/while loops.
This has also been confirmed to work for representing std.pow as an
scf.for loop on gpus.

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

Added: 


Modified: 
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
index d4529792624c..3a5b79176959 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -71,7 +71,6 @@ static void inlineRegionAndEmitStore(OpType op, 
ArrayRef indexedValues,
   BlockAndValueMapping map;
   map.map(block.getArguments(), indexedValues);
   for (auto &op : block.without_terminator()) {
-assert(op.getNumRegions() == 0 && "expected a non-nested region");
 auto *newOp = b.clone(op, map);
 map.map(op.getResults(), newOp->getResults());
   }



___
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] d5ea8f7 - [AMDGPU] Clarify scratch initialization

2020-12-15 Thread via llvm-branch-commits

Author: Tony
Date: 2020-12-15T20:14:20Z
New Revision: d5ea8f70105ad9802e7d759702830d50e4f16c7b

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

LOG: [AMDGPU] Clarify scratch initialization

- Clarify documentation on initializing scratch.
- Rename compute_pgm_rsrc2 field for enabling scratch from
  ENABLE_SGPR_PRIVATE_SEGMENT_WAVEFRONT_OFFSET to
  ENABLE_PRIVATE_SEGMENT to match hardware definition.

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

Added: 


Modified: 
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/Support/AMDHSAKernelDescriptor.h
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp

Removed: 




diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index e5d081a37500..6d3fa7021a7a 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -3584,8 +3584,8 @@ The fields used by CP for code objects before V3 also 
match those specified in
  configuration
  register. See
  
:ref:`amdgpu-amdhsa-compute_pgm_rsrc2-gfx6-gfx10-table`.
- 448 1 bit   ENABLE_SGPR_PRIVATE_SEGMENT Enable the setup of the
- _BUFFER SGPR user data registers
+ 458:448 7 bits  *See separate bits below.*  Enable the setup of the
+ SGPR user data registers
  (see
  
:ref:`amdgpu-amdhsa-initial-kernel-execution-state`).
 
@@ -3596,12 +3596,15 @@ The fields used by CP for code objects before V3 also 
match those specified in
  
``compute_pgm_rsrc2.user_sgpr.user_sgpr_count``.
  Any requests beyond 16
  will be ignored.
- 449 1 bit   ENABLE_SGPR_DISPATCH_PTR*see above*
- 450 1 bit   ENABLE_SGPR_QUEUE_PTR   *see above*
- 451 1 bit   ENABLE_SGPR_KERNARG_SEGMENT_PTR *see above*
- 452 1 bit   ENABLE_SGPR_DISPATCH_ID *see above*
- 453 1 bit   ENABLE_SGPR_FLAT_SCRATCH_INIT   *see above*
- 454 1 bit   ENABLE_SGPR_PRIVATE_SEGMENT *see above*
+ >4481 bit   ENABLE_SGPR_PRIVATE_SEGMENT
+ _BUFFER
+ >4491 bit   ENABLE_SGPR_DISPATCH_PTR
+ >4501 bit   ENABLE_SGPR_QUEUE_PTR
+ >4511 bit   ENABLE_SGPR_KERNARG_SEGMENT_PTR
+ >4521 bit   ENABLE_SGPR_DISPATCH_ID
+ >4531 bit   ENABLE_SGPR_FLAT_SCRATCH_INIT
+
+ >4541 bit   ENABLE_SGPR_PRIVATE_SEGMENT
  _SIZE
  457:455 3 bits  Reserved, must be 0.
  458 1 bit   ENABLE_WAVEFRONT_SIZE32 GFX6-9
@@ -3915,8 +3918,12 @@ The fields used by CP for code objects before V3 also 
match those specified in
  === === === 
===
  BitsSizeField Name  Description
  === === === 
===
- 0   1 bit   ENABLE_SGPR_PRIVATE_SEGMENT Enable the setup of the
- _WAVEFRONT_OFFSET   SGPR wavefront scratch 
offset
+ 0   1 bit   ENABLE_PRIVATE_SEGMENT  Enable the setup of the
+ private segment.
+
+ In addition, enable the
+ setup of the SGPR
+ wavefront scratch offset
  system register (see
  
:ref:`amdgpu-amdhsa-initial-kernel-execution-state`).
 
@@ -4155,14 +4162,18 @@ SGPR register initial state is defined in
 (kernel descriptor enable  of
 field) SGPRs
  == == == 
==
- First  Private Segment Buffer 4  V# that can be used, together
-(enable_sgpr_private  with Scratch Wavefront Offset
-_segment_buffer)  as an offset, to access the
+ First  Private Segment Buffer 4  This is 

[llvm-branch-commits] [clang] c103f9e - [RISCV] Use default member initializers for the feature flags in RISCVTargetInfo. NFC

2020-12-15 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-15T12:37:47-08:00
New Revision: c103f9ef5a0e3180db8c9e94f9cd0b0e2a65375f

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

LOG: [RISCV] Use default member initializers for the feature flags in 
RISCVTargetInfo. NFC

This avoids having to repeat all the flags in the constructor's
initializer list in the same order. This style is already used by
several other targets.

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index 8430407b041e..8407798eb149 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -25,19 +25,18 @@ namespace targets {
 class RISCVTargetInfo : public TargetInfo {
 protected:
   std::string ABI, CPU;
-  bool HasM;
-  bool HasA;
-  bool HasF;
-  bool HasD;
-  bool HasC;
-  bool HasB;
-  bool HasV;
-  bool HasZfh;
+  bool HasM = false;
+  bool HasA = false;
+  bool HasF = false;
+  bool HasD = false;
+  bool HasC = false;
+  bool HasB = false;
+  bool HasV = false;
+  bool HasZfh = false;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
-  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false), HasD(false),
-HasC(false), HasB(false), HasV(false), HasZfh(false) {
+  : TargetInfo(Triple) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();



___
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] a81db8b - [LV] Restructure handling of -prefer-predicate-over-epilogue option [NFC]

2020-12-15 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-12-15T12:38:13-08:00
New Revision: a81db8b3159e72a6d2ecb2318024316e4aa30933

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

LOG: [LV] Restructure handling of -prefer-predicate-over-epilogue option [NFC]

This should be purely non-functional.  When touching this code for another 
reason, I found the handling of the PredicateOrDontVectorize piece here very 
confusing.  Let's make it an explicit state (instead of an implicit combination 
of two variables), and use early return for options/hint processing.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c96637762658..6e506a4d71a4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1201,7 +1201,10 @@ enum ScalarEpilogueLowering {
   CM_ScalarEpilogueNotAllowedLowTripLoop,
 
   // Loop hint predicate indicating an epilogue is undesired.
-  CM_ScalarEpilogueNotNeededUsePredicate
+  CM_ScalarEpilogueNotNeededUsePredicate,
+
+  // Directive indicating we must either tail fold or not vectorize
+  CM_ScalarEpilogueNotAllowedUsePredicate
 };
 
 /// LoopVectorizationCostModel - estimates the expected speedups due to
@@ -5463,6 +5466,8 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount 
UserVF, unsigned UserIC) {
   switch (ScalarEpilogueStatus) {
   case CM_ScalarEpilogueAllowed:
 return MaxVF;
+  case CM_ScalarEpilogueNotAllowedUsePredicate:
+LLVM_FALLTHROUGH;
   case CM_ScalarEpilogueNotNeededUsePredicate:
 LLVM_DEBUG(
 dbgs() << "LV: vector predicate hint/switch found.\n"
@@ -5522,16 +5527,17 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount 
UserVF, unsigned UserIC) {
   // If there was a tail-folding hint/switch, but we can't fold the tail by
   // masking, fallback to a vectorization with a scalar epilogue.
   if (ScalarEpilogueStatus == CM_ScalarEpilogueNotNeededUsePredicate) {
-if (PreferPredicateOverEpilogue == 
PreferPredicateTy::PredicateOrDontVectorize) {
-  LLVM_DEBUG(dbgs() << "LV: Can't fold tail by masking: don't 
vectorize\n");
-  return None;
-}
 LLVM_DEBUG(dbgs() << "LV: Cannot fold tail by masking: vectorize with a "
  "scalar epilogue instead.\n");
 ScalarEpilogueStatus = CM_ScalarEpilogueAllowed;
 return MaxVF;
   }
 
+  if (ScalarEpilogueStatus == CM_ScalarEpilogueNotAllowedUsePredicate) {
+LLVM_DEBUG(dbgs() << "LV: Can't fold tail by masking: don't vectorize\n");
+return None;
+  }
+  
   if (TC == 0) {
 reportVectorizationFailure(
 "Unable to calculate the loop count due to complex control flow",
@@ -8855,22 +8861,29 @@ static ScalarEpilogueLowering getScalarEpilogueLowering(
   Hints.getForce() != LoopVectorizeHints::FK_Enabled))
 return CM_ScalarEpilogueNotAllowedOptSize;
 
-  bool PredicateOptDisabled = PreferPredicateOverEpilogue.getNumOccurrences() 
&&
-  !PreferPredicateOverEpilogue;
+  // 2) If set, obey the directives
+  if (PreferPredicateOverEpilogue.getNumOccurrences()) {
+switch (PreferPredicateOverEpilogue) {
+case PreferPredicateTy::ScalarEpilogue:
+  return CM_ScalarEpilogueAllowed;
+case PreferPredicateTy::PredicateElseScalarEpilogue:
+  return CM_ScalarEpilogueNotNeededUsePredicate;
+case PreferPredicateTy::PredicateOrDontVectorize:
+  return CM_ScalarEpilogueNotAllowedUsePredicate;
+};
+  }
 
-  // 2) Next, if disabling predication is requested on the command line, honour
-  // this and request a scalar epilogue.
-  if (PredicateOptDisabled)
+  // 3) If set, obey the hints
+  switch (Hints.getPredicate()) {
+  case LoopVectorizeHints::FK_Enabled:
+return CM_ScalarEpilogueNotNeededUsePredicate;
+  case LoopVectorizeHints::FK_Disabled:
 return CM_ScalarEpilogueAllowed;
+  };
 
-  // 3) and 4) look if enabling predication is requested on the command line,
-  // with a loop hint, or if the TTI hook indicates this is profitable, request
-  // predication.
-  if (PreferPredicateOverEpilogue ||
-  Hints.getPredicate() == LoopVectorizeHints::FK_Enabled ||
-  (TTI->preferPredicateOverEpilogue(L, LI, *SE, *AC, TLI, DT,
-LVL.getLAI()) &&
-   Hints.getPredicate() != LoopVectorizeHints::FK_Disabled))
+  // 4) if the TTI hook indicates this is profitable, request predication.
+  if (TTI->preferPredicateOverEpilogue(L, LI, *SE, *AC, TLI, DT,
+   LVL.getLAI()))
 return CM_ScalarEpilogueNotNeededUsePredicate;
 
   return CM_ScalarEpilogueAllowed;



_

[llvm-branch-commits] [openmp] 5aafdd7 - [OpenMP] Introduce new file wrapper class for runtime

2020-12-15 Thread via llvm-branch-commits

Author: Peyton, Jonathan L
Date: 2020-12-15T14:46:30-06:00
New Revision: 5aafdd7b88f5bad06431f34103a771fe681f9213

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

LOG: [OpenMP] Introduce new file wrapper class for runtime

Introduce new kmp_safe_raii_file_t class with RAII semantics for file
open/close. It is essentially a wrapper around the C-style FILE* object.
This also unifies the way we error report if a file can't be opened.

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

Added: 


Modified: 
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_affinity.cpp
openmp/runtime/src/kmp_lock.cpp
openmp/runtime/src/kmp_stats.cpp

Removed: 




diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 64431a60aef3..ece7aa06006a 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -4028,4 +4028,63 @@ int __kmp_execute_tasks_oncore(kmp_info_t *thread, 
kmp_int32 gtid,
 #endif /* USE_ITT_BUILD */
kmp_int32 is_constrained);
 
+/// This class safely opens and closes a C-style FILE* object using RAII
+/// semantics. There are also methods which allow using stdout or stderr as
+/// the underlying FILE* object. With the implicit conversion operator to
+/// FILE*, an object with this type can be used in any function which takes
+/// a FILE* object e.g., fprintf().
+/// No close method is needed at use sites.
+class kmp_safe_raii_file_t {
+  FILE *f;
+
+  void close() {
+if (f && f != stdout && f != stderr) {
+  fclose(f);
+  f = nullptr;
+}
+  }
+
+public:
+  kmp_safe_raii_file_t() : f(nullptr) {}
+  kmp_safe_raii_file_t(const char *filename, const char *mode,
+   const char *env_var = nullptr)
+  : f(nullptr) {
+open(filename, mode, env_var);
+  }
+  ~kmp_safe_raii_file_t() { close(); }
+
+  /// Open filename using mode. This is automatically closed in the destructor.
+  /// The env_var parameter indicates the environment variable the filename
+  /// came from if != nullptr.
+  void open(const char *filename, const char *mode,
+const char *env_var = nullptr) {
+KMP_ASSERT(!f);
+f = fopen(filename, mode);
+if (!f) {
+  int code = errno;
+  if (env_var) {
+__kmp_fatal(KMP_MSG(CantOpenFileForReading, filename), KMP_ERR(code),
+KMP_HNT(CheckEnvVar, env_var, filename), __kmp_msg_null);
+  } else {
+__kmp_fatal(KMP_MSG(CantOpenFileForReading, filename), KMP_ERR(code),
+__kmp_msg_null);
+  }
+}
+  }
+  /// Set the FILE* object to stdout and output there
+  /// No open call should happen before this call.
+  void set_stdout() {
+KMP_ASSERT(!f);
+f = stdout;
+  }
+  /// Set the FILE* object to stderr and output there
+  /// No open call should happen before this call.
+  void set_stderr() {
+KMP_ASSERT(!f);
+f = stderr;
+  }
+  operator bool() { return bool(f); }
+  operator FILE *() { return f; }
+};
+
 #endif /* KMP_H */

diff  --git a/openmp/runtime/src/kmp_affinity.cpp 
b/openmp/runtime/src/kmp_affinity.cpp
index 8f77f36ed5be..e232e301e366 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -4210,17 +4210,10 @@ static void __kmp_aux_affinity_initialize(void) {
 }
   }
 
-  FILE *f = fopen("/proc/cpuinfo", "r");
-  if (f == NULL) {
-msg_id = kmp_i18n_str_CantOpenCpuinfo;
-  } else {
-file_name = "/proc/cpuinfo";
-depth =
-__kmp_affinity_create_cpuinfo_map(&address2os, &line, &msg_id, f);
-fclose(f);
-if (depth == 0) {
-  KMP_EXIT_AFF_NONE;
-}
+  kmp_safe_raii_file_t f("/proc/cpuinfo", "r");
+  depth = __kmp_affinity_create_cpuinfo_map(&address2os, &line, &msg_id, 
f);
+  if (depth == 0) {
+KMP_EXIT_AFF_NONE;
   }
 }
 
@@ -4313,8 +4306,10 @@ static void __kmp_aux_affinity_initialize(void) {
 
   else if (__kmp_affinity_top_method == affinity_top_method_cpuinfo) {
 const char *filename;
+const char *env_var = nullptr;
 if (__kmp_cpuinfo_file != NULL) {
   filename = __kmp_cpuinfo_file;
+  env_var = "KMP_CPUINFO_FILE";
 } else {
   filename = "/proc/cpuinfo";
 }
@@ -4323,20 +4318,9 @@ static void __kmp_aux_affinity_initialize(void) {
   KMP_INFORM(AffParseFilename, "KMP_AFFINITY", filename);
 }
 
-FILE *f = fopen(filename, "r");
-if (f == NULL) {
-  int code = errno;
-  if (__kmp_cpuinfo_file != NULL) {
-__kmp_fatal(KMP_MSG(CantOpenFileForReading, filename), KMP_ERR(code),
-KMP_HNT(NameComesFrom_CPUINFO_FILE), __kmp_msg_null);
-  } else {
-__kmp_fatal(KMP_MSG(CantOpenFileForReading, filename), KMP_ERR(code)

[llvm-branch-commits] [mlir] caf4f2e - [mlir] Handle unknown ops in dynamic_tensor_from_elements bufferization

2020-12-15 Thread Sean Silva via llvm-branch-commits

Author: Sean Silva
Date: 2020-12-15T12:50:56-08:00
New Revision: caf4f2e372a7a4d5d8b5a8733e44f002c6dee0d5

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

LOG: [mlir] Handle unknown ops in dynamic_tensor_from_elements bufferization

Due to how the conversion infra works, the "clone" call that this
pattern was using required all the cloned ops to be immediately
legalized as part of this dialect conversion invocation.

That was previously working due to a couple factors:

- In the test case, there was scf.if, which we happen to mark as legal
  as part of marking the entire SCF dialect as legal for the scf.parallel
  we generate here.

- Originally, this test case had std.extract_element in the body, which
  we happened to have a pattern for in this pass. After I migrated that to
  `tensor.extract` (which removed the tensor.extract bufferization from
  here), I hacked this up to use `std.dim` which we still have patterns
  for in this pass.

This patch updates the test case to use a truly opaque op `test.source`
that properly stresses this aspect of the pattern.

(this also removes a stray dependency on the `tensor` dialect that I
must have left behind as part of my hacking this pass up when migrating
to `tensor.extract`)

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

Added: 


Modified: 
mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp
mlir/test/Dialect/Standard/bufferize.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp 
b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp
index 6691355d232c..a84934b0ebb8 100644
--- a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp
@@ -15,7 +15,6 @@
 #include "mlir/Dialect/SCF/SCF.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/Dialect/StandardOps/Transforms/Passes.h"
-#include "mlir/Dialect/Tensor/IR/Tensor.h"
 #include "mlir/IR/BlockAndValueMapping.h"
 #include "mlir/Transforms/DialectConversion.h"
 
@@ -70,18 +69,29 @@ class BufferizeDynamicTensorFromElementsOp
   upperBounds.push_back(upperBound);
 }
 
-// Generate tensor elements with a parallel loop.
-rewriter.create(
-loc, lowerBounds, upperBounds, steps,
-[&](OpBuilder &b, Location loc, ValueRange ivs) {
-  BlockAndValueMapping mapping;
-  mapping.map(op.body().getArguments(), ivs);
-  for (auto &nestedOp : op.getBody()->without_terminator())
-b.clone(nestedOp, mapping);
-  auto yieldOp = cast(op.getBody()->getTerminator());
-  b.create(loc, mapping.lookup(yieldOp.value()), result, ivs);
-  b.create(loc);
-});
+// Generate tensor elements with a parallel loop that stores into
+// each element of the resulting memref.
+//
+// This is a bit tricky. We cannot simply clone the ops because when an op
+// is cloned, it must be legalized. However, we want to allow arbitrary ops
+// in the body that we don't necessarily have legalization patterns for as
+// part of this dialect conversion invocation.
+//
+// To accomplish this, we use mergeBlockBefore to "move" this op's body
+// into the scf.parallel's body.
+auto parallel =
+rewriter.create(loc, lowerBounds, upperBounds, steps);
+Block *parallelBody = parallel.getBody();
+rewriter.mergeBlockBefore(op.getBody(), parallelBody->getTerminator(),
+  parallelBody->getArguments());
+// Replace the inlined yield op with a store op. The scf.parallel's builder
+// already populated an scf.yield at the end, so we don't need to worry
+// about creating that.
+Operation *elementYield = parallelBody->getTerminator()->getPrevNode();
+rewriter.setInsertionPointAfter(elementYield);
+rewriter.replaceOpWithNewOp(elementYield,
+ elementYield->getOperands()[0], 
result,
+ parallelBody->getArguments());
 
 rewriter.replaceOp(op, {result});
 return success();
@@ -168,7 +178,6 @@ struct StdBufferizePass : public 
StdBufferizeBase {
 
 target.addLegalDialect();
 target.addLegalDialect();
-target.addLegalDialect();
 
 populateStdBufferizePatterns(context, typeConverter, patterns);
 target.addIllegalOp 
tensor<2xindex> {
   return %0 : tensor<2xindex>
 }
 
-// The dynamic_tensor_from_elements op clones each op in its body.
-// Make sure that regions nested within such ops are recursively converted.
-// CHECK-LABEL: func @recursively_convert_cloned_regions
-func @recursively_convert_cloned_regions(%arg0: tensor<*xf32>, %arg1: index, 
%arg2: i1) -> tensor {
-  %tensor = dynamic_tensor_from_elements %arg1 {
+// The dy

[llvm-branch-commits] [lld] 3184519 - [lld-macho] Don't emit rebase opcodes for relocs in TLV sections

2020-12-15 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-15T15:58:26-05:00
New Revision: 31845199094418173a3beadb786767b860bfda03

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

LOG: [lld-macho] Don't emit rebase opcodes for relocs in TLV sections

Their addresses are already encoded as section-relative offsets, so
there's no need to rebase them at runtime. {D85080} has some context
on the weirdness of TLV sections.

Fixes llvm.org/PR48491.

Reviewed By: #lld-macho, thakis

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

Added: 


Modified: 
lld/MachO/Arch/X86_64.cpp
lld/test/MachO/tlv-dylib.s
lld/test/MachO/tlv.s

Removed: 




diff  --git a/lld/MachO/Arch/X86_64.cpp b/lld/MachO/Arch/X86_64.cpp
index 7f4024cc998dd..c776e21d6f5f5 100644
--- a/lld/MachO/Arch/X86_64.cpp
+++ b/lld/MachO/Arch/X86_64.cpp
@@ -248,7 +248,11 @@ void X86_64::prepareSymbolRelocation(lld::macho::Symbol 
*sym,
 return;
   }
 }
-addNonLazyBindingEntries(sym, isec, r.offset, r.addend);
+// References from thread-local variable sections are treated as offsets
+// relative to the start of the referent section, and therefore have no
+// need of rebase opcodes.
+if (!(isThreadLocalVariables(isec->flags) && isa(sym)))
+  addNonLazyBindingEntries(sym, isec, r.offset, r.addend);
 break;
   }
   case X86_64_RELOC_SIGNED:

diff  --git a/lld/test/MachO/tlv-dylib.s b/lld/test/MachO/tlv-dylib.s
index c6f9b9add3a0a..74e27e9e24d1b 100644
--- a/lld/test/MachO/tlv-dylib.s
+++ b/lld/test/MachO/tlv-dylib.s
@@ -4,9 +4,14 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libtlv.s -o 
%t/libtlv.o
 # RUN: %lld -dylib -install_name @executable_path/libtlv.dylib \
 # RUN:   -lSystem -o %t/libtlv.dylib %t/libtlv.o
-# RUN: llvm-objdump --exports-trie -d --no-show-raw-insn %t/libtlv.dylib | 
FileCheck %s --check-prefix=DYLIB
+# RUN: llvm-objdump --macho --exports-trie --rebase %t/libtlv.dylib | \
+# RUN:   FileCheck %s --check-prefix=DYLIB
 # DYLIB-DAG: _foo [per-thread]
 # DYLIB-DAG: _bar [per-thread]
+## Make sure we don't emit rebase opcodes for relocations in __thread_vars.
+# DYLIB:   Rebase table:
+# DYLIB-NEXT:  segment  sectionaddress type
+# DYLIB-EMPTY:
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 # RUN: %lld -lSystem -L%t -ltlv %t/test.o -o %t/test

diff  --git a/lld/test/MachO/tlv.s b/lld/test/MachO/tlv.s
index bf0dfcd02b565..d8d0a950d794c 100644
--- a/lld/test/MachO/tlv.s
+++ b/lld/test/MachO/tlv.s
@@ -1,9 +1,14 @@
 # REQUIRES: x86
 # RUN: mkdir -p %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
+
 # RUN: %lld -lSystem -o %t/test %t/test.o
 # RUN: llvm-readobj --file-headers %t/test | FileCheck %s --check-prefix=HEADER
-# RUN: llvm-objdump -D %t/test | FileCheck %s
+# RUN: llvm-objdump -D --bind --rebase %t/test | FileCheck %s
+
+# RUN: %lld -lSystem -pie -o %t/test %t/test.o
+# RUN: llvm-readobj --file-headers %t/test | FileCheck %s --check-prefix=HEADER
+# RUN: llvm-objdump -D --bind --rebase %t/test | FileCheck %s
 
 # HEADER: MH_HAS_TLV_DESCRIPTORS
 
@@ -36,6 +41,13 @@
 # CHECK-NEXT:  00 00
 # CHECK-NEXT:  00 00
 
+## Make sure we don't emit rebase opcodes for relocations in __thread_vars.
+# CHECK:   Rebase table:
+# CHECK-NEXT:  segment  sectionaddress type
+# CHECK-NEXT:  Bind table:
+# CHECK:   __DATA  __thread_vars   0x{{[0-9a-f]*}}  pointer 0 libSystem 
__tlv_bootstrap
+# CHECK:   __DATA  __thread_vars   0x{{[0-9a-f]*}}  pointer 0 libSystem 
__tlv_bootstrap
+
 .globl _main
 _main:
   mov _foo@TLVP(%rip), %rax



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


[llvm-branch-commits] [lld] 544148a - [lld-macho] -weak_{library, framework} should always take priority

2020-12-15 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-15T15:58:26-05:00
New Revision: 544148ae702ac3e94aa41b656e9f6d11b382f9f6

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

LOG: [lld-macho] -weak_{library,framework} should always take priority

We were not setting forceWeakImport for file paths given by
`-weak_library` if we had already loaded the file. This diff fixes that
by having `loadDylib` return a cached DylibFile instance even if we have
already loaded that file.

We still avoid emitting multiple LC_LOAD_DYLIBs, but we achieve this by
making inputFiles a SetVector instead of relying on the `loadedDylibs`
cache.

Reviewed By: #lld-macho, smeenai

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

Added: 


Modified: 
lld/MachO/Driver.cpp
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/test/MachO/invalid/duplicate-symbol.s
lld/test/MachO/weak-import.s

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index c456d2fb1fd5..96972cb17e6f 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -274,8 +274,7 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
 if (config->allLoad || forceLoadArchive) {
   if (Optional buffer = readFile(path)) {
 for (const ArchiveMember &member : getArchiveMembers(*buffer)) {
-  inputFiles.push_back(
-  make(member.mbref, member.modTime, path));
+  inputFiles.insert(make(member.mbref, member.modTime, path));
   printArchiveMemberLoad(
   (forceLoadArchive ? "-force_load" : "-all_load"),
   inputFiles.back());
@@ -293,7 +292,7 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
   if (Optional buffer = readFile(path)) {
 for (const ArchiveMember &member : getArchiveMembers(*buffer)) {
   if (hasObjCSection(member.mbref)) {
-inputFiles.push_back(
+inputFiles.insert(
 make(member.mbref, member.modTime, path));
 printArchiveMemberLoad("-ObjC", inputFiles.back());
   }
@@ -325,7 +324,7 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
 // print the .a name here.
 if (config->printEachFile && magic != file_magic::archive)
   lld::outs() << toString(newFile) << '\n';
-inputFiles.push_back(newFile);
+inputFiles.insert(newFile);
   }
   return newFile;
 }
@@ -521,7 +520,7 @@ static void compileBitcodeFiles() {
   lto->add(*bitcodeFile);
 
   for (ObjFile *file : lto->compile())
-inputFiles.push_back(file);
+inputFiles.insert(file);
 }
 
 // Replaces common symbols with defined symbols residing in __common sections.
@@ -873,7 +872,7 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
 StringRef fileName = arg->getValue(2);
 Optional buffer = readFile(fileName);
 if (buffer)
-  inputFiles.push_back(make(*buffer, segName, sectName));
+  inputFiles.insert(make(*buffer, segName, sectName));
   }
 
   // Initialize InputSections.

diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 05677a9df78d..5040f634e181 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -15,7 +15,7 @@
 #include "lld/Common/Memory.h"
 #include "lld/Common/Reproduce.h"
 #include "llvm/ADT/CachedHashString.h"
-#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
@@ -168,33 +168,32 @@ Optional macho::resolveDylibPath(StringRef 
path) {
   return {};
 }
 
-static Optional makeDylibFromTapi(MemoryBufferRef mbref,
-   DylibFile *umbrella) {
-  Expected> result = TextAPIReader::get(mbref);
-  if (!result) {
-error("could not load TAPI file at " + mbref.getBufferIdentifier() + ": " +
-  toString(result.takeError()));
-return {};
-  }
-  return make(**result, umbrella);
-}
-
-static DenseSet loadedDylibs;
+// It's not uncommon to have multiple attempts to load a single dylib,
+// especially if it's a commonly re-exported core library.
+static DenseMap loadedDylibs;
 
 Optional macho::loadDylib(MemoryBufferRef mbref,
DylibFile *umbrella) {
   StringRef path = mbref.getBufferIdentifier();
-  if (loadedDylibs.contains(CachedHashStringRef(path)))
-return {};
-  loadedDylibs.insert(CachedHashStringRef(path));
+  DylibFile *&file = loadedDylibs[CachedHashStringRef(path)];
+  if (file)
+return file;
 
   file_magic magic = identify_magic(mbref.getBuffer());
-  if (magic == file_magic::tapi_file)
-return makeDylibFromTapi(mbref, umbrella);
-
-  assert(magic == file_magic::macho_dynamically_linked_shared_lib ||

[llvm-branch-commits] [lld] 8a5e068 - [lld-macho] Support -sub_umbrella

2020-12-15 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-15T15:58:26-05:00
New Revision: 8a5e0688233636ac6f9a27fa57006cba9f67a945

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

LOG: [lld-macho] Support -sub_umbrella

>From what I can tell, it's essentially identical to
`-sub_library`, but it doesn't match files ending in ".dylib".

Reviewed By: #lld-macho, thakis

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

Added: 


Modified: 
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/sub-library.s

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 96972cb17e6f..8bac9b7b877f 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -488,12 +488,13 @@ static void parseOrderFile(StringRef path) {
 // with a path of .*/libfoo.{dylib, tbd}.
 // XXX ld64 seems to ignore the extension entirely when matching sub-libraries;
 // I'm not sure what the use case for that is.
-static bool markSubLibrary(StringRef searchName) {
+static bool markReexport(StringRef searchName, ArrayRef extensions) 
{
   for (InputFile *file : inputFiles) {
 if (auto *dylibFile = dyn_cast(file)) {
   StringRef filename = path::filename(dylibFile->getName());
   if (filename.consume_front(searchName) &&
-  (filename == ".dylib" || filename == ".tbd")) {
+  (filename.empty() ||
+   find(extensions, filename) != extensions.end())) {
 dylibFile->reexport = true;
 return true;
   }
@@ -836,11 +837,17 @@ bool macho::link(llvm::ArrayRef argsArr, 
bool canExitEarly,
 
   // Now that all dylibs have been loaded, search for those that should be
   // re-exported.
-  for (opt::Arg *arg : args.filtered(OPT_sub_library)) {
+  for (opt::Arg *arg : args.filtered(OPT_sub_library, OPT_sub_umbrella)) {
 config->hasReexports = true;
 StringRef searchName = arg->getValue();
-if (!markSubLibrary(searchName))
-  error("-sub_library " + searchName + " does not match a supplied dylib");
+std::vector extensions;
+if (arg->getOption().getID() == OPT_sub_library)
+  extensions = {".dylib", ".tbd"};
+else
+  extensions = {".tbd"};
+if (!markReexport(searchName, extensions))
+  error(arg->getSpelling() + " " + searchName +
+" does not match a supplied dylib");
   }
 
   // Parse LTO options.

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index ca13e3b9..e3ee14a74328 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -672,7 +672,6 @@ def sub_library : Separate<["-"], "sub_library">,
 def sub_umbrella : Separate<["-"], "sub_umbrella">,
  MetaVarName<"">,
  HelpText<"Re-export the framework as ">,
- Flags<[HelpHidden]>,
  Group;
 def allowable_client : Separate<["-"], "allowable_client">,
  MetaVarName<"">,

diff  --git a/lld/test/MachO/sub-library.s b/lld/test/MachO/sub-library.s
index 0e5b596dc04a..7f5e2904e962 100644
--- a/lld/test/MachO/sub-library.s
+++ b/lld/test/MachO/sub-library.s
@@ -22,19 +22,16 @@
 # RUN:   --check-prefix=HELLO-HEADERS
 # HELLO-HEADERS: NO_REEXPORTED_DYLIBS
 
-# RUN: llvm-objdump --macho --all-headers %t/libgoodbye.dylib | FileCheck %s 
-DDIR=%t \
-# RUN:   --check-prefix=GOODBYE-HEADERS
-# GOODBYE-HEADERS-NOT: NO_REEXPORTED_DYLIBS
-# GOODBYE-HEADERS: cmd LC_REEXPORT_DYLIB
-# GOODBYE-HEADERS-NOT: Load command
-# GOODBYE-HEADERS: name[[DIR]]/libhello.dylib
-
-# RUN: llvm-objdump --macho --all-headers %t/libsuper.dylib | FileCheck %s 
-DDIR=%t \
-# RUN:   --check-prefix=SUPER-HEADERS
-# SUPER-HEADERS-NOT: NO_REEXPORTED_DYLIBS
-# SUPER-HEADERS: cmd LC_REEXPORT_DYLIB
-# SUPER-HEADERS-NOT: Load command
-# SUPER-HEADERS: name[[DIR]]/libgoodbye.dylib
+# RUN: llvm-objdump --macho --all-headers %t/libgoodbye.dylib | FileCheck %s \
+# RUN:   --check-prefix=REEXPORT-HEADERS -DPATH=%t/libhello.dylib
+
+# RUN: llvm-objdump --macho --all-headers %t/libsuper.dylib | FileCheck %s \
+# RUN:   --check-prefix=REEXPORT-HEADERS -DPATH=%t/libgoodbye.dylib
+
+# REEXPORT-HEADERS-NOT: NO_REEXPORTED_DYLIBS
+# REEXPORT-HEADERS: cmd LC_REEXPORT_DYLIB
+# REEXPORT-HEADERS-NOT: Load command
+# REEXPORT-HEADERS: name[[PATH]]
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/sub-library.o
 # RUN: %lld -o %t/sub-library -L%t -lsuper %t/sub-library.o
@@ -54,6 +51,24 @@
 # RUN:  | FileCheck %s --check-prefix=MISSING-REEXPORT -DDIR=%t
 # MISSING-REEXPORT: error: unable to locate re-export with install name 
[[DIR]]/libgoodbye.dylib
 
+
+## We can match dylibs without extensions too.
+# RUN: mkdir -p %t/Hello.framework/Versions
+# RUN: %lld -dylib %t/libhello.o -o %t/Hello.framework/Versions/Hello
+# RUN: %lld -dylib -o %t/libgoodbye2.dylib -sub_library Hello 
%t/Hello.framework/Versions/Hello %t/libg

[llvm-branch-commits] [lld] 3aa8e07 - [lld-macho] Add implicit dylib support for frameworks

2020-12-15 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-15T15:58:26-05:00
New Revision: 3aa8e071dd1ae7e9fb9e28fa9fcdb9f9fdb7aa06

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

LOG: [lld-macho] Add implicit dylib support for frameworks

{D93000} applied to frameworks. Partial fix for PR48511.

Reviewed By: #lld-macho, thakis

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

Added: 


Modified: 
lld/MachO/InputFiles.cpp
lld/test/MachO/implicit-dylibs.s

Removed: 




diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 4bf568284c54..78c3dc9b7a52 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -508,9 +508,16 @@ static bool isImplicitlyLinked(StringRef path) {
   if (!config->implicitDylibs)
 return false;
 
-  return path::parent_path(path) == "/usr/lib";
-  // TODO: check for public frameworks too. We'll need to implement
-  // -sub_umbrella first to write a test case.
+  if (path::parent_path(path) == "/usr/lib")
+return true;
+
+  // Match /System/Library/Frameworks/$FOO.framework/**/$FOO
+  if (path.consume_front("/System/Library/Frameworks/")) {
+StringRef frameworkName = path.take_until([](char c) { return c == '.'; });
+return path::filename(path) == frameworkName;
+  }
+
+  return false;
 }
 
 void loadReexport(StringRef path, DylibFile *umbrella) {

diff  --git a/lld/test/MachO/implicit-dylibs.s 
b/lld/test/MachO/implicit-dylibs.s
index 21084b50006b..bd2d6e8d104b 100644
--- a/lld/test/MachO/implicit-dylibs.s
+++ b/lld/test/MachO/implicit-dylibs.s
@@ -3,10 +3,16 @@
 # UNSUPPORTED: system-windows
 # RUN: rm -rf %t; split-file %s %t
 # RUN: mkdir -p %t/usr/lib/system
+# RUN: mkdir -p %t/System/Library/Frameworks/Foo.framework/Versions/A
+# RUN: mkdir -p 
%t/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Versions/A
+# RUN: mkdir -p %t/Baz.framework/Versions/A
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o 
%t/libfoo.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libtoplevel.s -o 
%t/libtoplevel.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libsublevel.s -o 
%t/libsublevel.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/framework-foo.s -o 
%t/framework-foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/framework-bar.s -o 
%t/framework-bar.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/framework-baz.s -o 
%t/framework-baz.o
 ## libunused will be used to verify that we load implicit dylibs even if we
 ## don't use any symbols they contain.
 # RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o 
%t/libunused.o
@@ -16,10 +22,28 @@
 # RUN: %lld -dylib -lSystem %t/libtoplevel.o -o %t/usr/lib/libtoplevel.dylib 
-install_name /usr/lib/libtoplevel.dylib
 # RUN: %lld -dylib -lSystem %t/libsublevel.o -o 
%t/usr/lib/system/libsublevel.dylib -install_name 
/usr/lib/system/libsublevel.dylib
 # RUN: %lld -dylib -lSystem %t/libunused.o -o %t/usr/lib/libunused.dylib 
-install_name /usr/lib/libunused.dylib
-# RUN: %lld -dylib -syslibroot %t \
+
+## Bar.framework is nested within Foo.framework.
+# RUN: %lld -dylib -lSystem %t/framework-baz.o -o 
%t/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Versions/A/Bar
 \
+# RUN:   -install_name 
/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Versions/A/Bar
+# RUN: ln -sf 
%t/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Versions/A/Bar
 \
+# RUN:   
%t/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Bar
+
+## Have Foo re-export Bar.
+# RUN: %lld -dylib -F %t/System/Library/Frameworks/Foo.framework/Frameworks \
+# RUN:   -framework Bar -sub_umbrella Bar -lSystem %t/framework-foo.o -o 
%t/System/Library/Frameworks/Foo.framework/Versions/A/Foo \
+# RUN:   -install_name /System/Library/Frameworks/Foo.framework/Versions/A/Foo
+# RUN: ln -sf %t/System/Library/Frameworks/Foo.framework/Versions/A/Foo 
%t/System/Library/Frameworks/Foo.framework/Foo
+
+# RUN: %lld -dylib -lSystem %t/framework-bar.o -o 
%t/Baz.framework/Versions/A/Baz \
+# RUN:   -install_name %t/Baz.framework/Versions/A/Baz
+# RUN: ln -sf %t/Baz.framework/Versions/A/Baz %t/Baz.framework/Baz
+
+# RUN: %lld -dylib -syslibroot %t -framework Foo -F %t -framework Baz \
 # RUN:   -lc++ -ltoplevel -lunused %t/usr/lib/system/libsublevel.dylib 
%t/libfoo.dylib \
 # RUN:   -sub_library libc++ -sub_library libfoo -sub_library libtoplevel \
 # RUN:   -sub_library libsublevel -sub_library libunused \
+# RUN:   -sub_umbrella Baz -sub_umbrella Foo \
 # RUN:   %t/reexporter.o -o %t/libreexporter.dylib
 
 # RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %t/test.s -o %t/test.o
@@ -29,6 +53,9 @@
 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libreexporter

[llvm-branch-commits] [flang] b1afbce - [flang] Minor fix to list-directed REAL output editing

2020-12-15 Thread peter klausler via llvm-branch-commits

Author: peter klausler
Date: 2020-12-15T13:04:44-08:00
New Revision: b1afbceb9296a9ce14a0bd38f36e93b8c77fa18a

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

LOG: [flang] Minor fix to list-directed REAL output editing

Always emit the letter 'E' in list-directed REAL output;
the library was omitting it for exponents greater than 99,
as should be done for E and D formatting of large exponents
without an Ed exponent digit count.

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

Added: 


Modified: 
flang/runtime/edit-output.cpp

Removed: 




diff  --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp
index 31ba9f152d74..76f24cb07437 100644
--- a/flang/runtime/edit-output.cpp
+++ b/flang/runtime/edit-output.cpp
@@ -116,7 +116,7 @@ const char *RealOutputEditingBase::FormatExponent(
 }
   }
   *--exponent = expo < 0 ? '-' : '+';
-  if (edit.expoDigits || exponent + 3 == eEnd) {
+  if (edit.expoDigits || edit.IsListDirected() || exponent + 3 == eEnd) {
 *--exponent = edit.descriptor == 'D' ? 'D' : 'E'; // not 'G'
   }
   length = eEnd - exponent;



___
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] dfac97d - [clangd] Validate clang-tidy Checks in clangd config.

2020-12-15 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-15T21:10:57Z
New Revision: dfac97d557690dd4b1f2fab798680234b238d11f

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

LOG: [clangd] Validate clang-tidy Checks in clangd config.

Add instrumentation in ConfigCompile to validate that items in 
ClangTidy:[Add|Remove] correspond to actual clang-tidy checks.
If they don't a warning will be presented to the user.

This is especially useful for catching typos in the glob items.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/TidyProvider.cpp
clang-tools-extra/clangd/TidyProvider.h
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index b1189e286826..2040ea4649fe 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -28,6 +28,7 @@
 #include "ConfigFragment.h"
 #include "ConfigProvider.h"
 #include "Features.inc"
+#include "TidyProvider.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
 #include "llvm/ADT/None.h"
@@ -349,13 +350,19 @@ struct FragmentCompiler {
 
   void appendTidyCheckSpec(std::string &CurSpec,
const Located &Arg, bool IsPositive) {
-StringRef Str = *Arg;
+StringRef Str = StringRef(*Arg).trim();
 // Don't support negating here, its handled if the item is in the Add or
 // Remove list.
 if (Str.startswith("-") || Str.contains(',')) {
   diag(Error, "Invalid clang-tidy check name", Arg.Range);
   return;
 }
+if (!Str.contains('*') && !isRegisteredTidyCheck(Str)) {
+  diag(Warning,
+   llvm::formatv("clang-tidy check '{0}' was not found", Str).str(),
+   Arg.Range);
+  return;
+}
 CurSpec += ',';
 if (!IsPositive)
   CurSpec += '-';

diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp 
b/clang-tools-extra/clangd/TidyProvider.cpp
index 730a402b5df1..c6ee09ae16d2 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "TidyProvider.h"
+#include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "Config.h"
 #include "support/FileCache.h"
 #include "support/Logger.h"
@@ -14,6 +15,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -266,5 +269,25 @@ tidy::ClangTidyOptions 
getTidyOptionsForFile(TidyProviderRef Provider,
 Provider(Opts, Filename);
   return Opts;
 }
+
+bool isRegisteredTidyCheck(llvm::StringRef Check) {
+  assert(!Check.empty());
+  assert(!Check.contains('*') && !Check.contains(',') &&
+ "isRegisteredCheck doesn't support globs");
+  assert(Check.ltrim().front() != '-');
+
+  static const llvm::StringSet AllChecks = [] {
+llvm::StringSet Result;
+tidy::ClangTidyCheckFactories Factories;
+for (tidy::ClangTidyModuleRegistry::entry E :
+ tidy::ClangTidyModuleRegistry::entries())
+  E.instantiate()->addCheckFactories(Factories);
+for (const auto &Factory : Factories)
+  Result.insert(Factory.getKey());
+return Result;
+  }();
+
+  return AllChecks.contains(Check);
+}
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/TidyProvider.h 
b/clang-tools-extra/clangd/TidyProvider.h
index f3f679c3f0d5..b295a9b05eff 100644
--- a/clang-tools-extra/clangd/TidyProvider.h
+++ b/clang-tools-extra/clangd/TidyProvider.h
@@ -13,6 +13,7 @@
 #include "support/ThreadsafeFS.h"
 #include "llvm/ADT/FunctionExtras.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace clang {
 namespace clangd {
@@ -56,6 +57,10 @@ TidyProviderRef provideClangdConfig();
 tidy::ClangTidyOptions getTidyOptionsForFile(TidyProviderRef Provider,
  llvm::StringRef Filename);
 
+/// Returns if \p Check is a registered clang-tidy check
+/// \pre \p must not be empty, must not contain '*' or ',' or start with '-'.
+bool isRegisteredTidyCheck(llvm::StringRef Check);
+
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index a2423094b17a..578f69821e4d 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/cla

[llvm-branch-commits] [clang] 57d83c3 - [PowerPC] Enable paired vector type and intrinsics when MMA is disabled

2020-12-15 Thread Baptiste Saleil via llvm-branch-commits

Author: Baptiste Saleil
Date: 2020-12-15T15:14:11-06:00
New Revision: 57d83c3a90c427ad0975803feb5b348d1ad34e29

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

LOG: [PowerPC] Enable paired vector type and intrinsics when MMA is disabled

This patch enables the Clang type __vector_pair and its associated LLVM
intrinsics even when MMA is disabled. With this patch, the type is now 
controlled
by the PPC paired-vector-memops option. The builtins and intrinsics will be
renamed to drop the mma prefix in another patch.

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

Added: 
clang/test/AST/ast-dump-ppc-types.c
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Basic/PPCTypes.def
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReader.cpp
clang/tools/libclang/CIndex.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td

Removed: 
clang/test/AST/ast-dump-ppc-mma-types.c



diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 71f824b69bc8..ff84eb52e96e 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1007,7 +1007,7 @@ class ASTContext : public RefCountedBase {
 #define SVE_TYPE(Name, Id, SingletonId) \
   CanQualType SingletonId;
 #include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
   CanQualType Id##Ty;
 #include "clang/Basic/PPCTypes.def"
 

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 99cfa3ae76f5..945ea7a600c0 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2489,7 +2489,7 @@ class BuiltinType : public Type {
 #define SVE_TYPE(Name, Id, SingletonId) Id,
 #include "clang/Basic/AArch64SVEACLETypes.def"
 // PPC MMA Types
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) Id,
+#define PPC_VECTOR_TYPE(Name, Id, Size) Id,
 #include "clang/Basic/PPCTypes.def"
 // All other builtin types
 #define BUILTIN_TYPE(Id, SingletonId) Id,

diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index b582395c44a6..ffcc8290938f 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -765,7 +765,7 @@ let Class = BuiltinType in {
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/AArch64SVEACLETypes.def"
 
-#define PPC_MMA_VECTOR_TYPE(NAME, ID, SIZE) \
+#define PPC_VECTOR_TYPE(NAME, ID, SIZE) \
   case BuiltinType::ID: return ctx.ID##Ty;
 #include "clang/Basic/PPCTypes.def"
 

diff  --git a/clang/include/clang/Basic/PPCTypes.def 
b/clang/include/clang/Basic/PPCTypes.def
index 86656f3568f8..9e2cb2aedc9f 100644
--- a/clang/include/clang/Basic/PPCTypes.def
+++ b/clang/include/clang/Basic/PPCTypes.def
@@ -7,14 +7,32 @@
 
//===--===//
 //
 //  This file defines PPC types.
-//  Custom code should define this macro:
+//  Custom code should define one of these macros:
 //
-//PPC_MMA_VECTOR_TYPE(Name, Id, Size) - A MMA vector type of a given size
+//PPC_VECTOR_TYPE(Name, Id, Size) - A PPC vector type of a given size
 //(in bits).
 //
+//PPC_VECTOR_MMA_TYPE(Name, Id, Size) - A PPC MMA vector type of a given
+//size (in bits).
+//
+//PPC_VECTOR_VSX_TYPE(Name, Id, Size) - A PPC VSX vector type of a given
+//size (in bits).
+//
 
//===--===//
 
-PPC_MMA_VECTOR_TYPE(__vector_quad, VectorQuad, 512)
-PPC_MMA_VECTOR_TYPE(__vector_pair, VectorPair, 256)
+#if defined(PPC_VECTOR_TYPE)
+  #define PPC_VECTOR_MMA_TYPE(Name, Id, Size) PPC_VECTOR_TYPE(Name, Id, Size)
+  #define PPC_VECTOR_VSX_TYPE(Name, Id, Size) PPC_VECTOR_TYPE(Name, Id, Size)
+#elif defined(PPC_VECTOR_MMA_TYPE)
+  #define PPC_VECTOR_VSX_TYPE(Name, Id, Size)
+#elif defined(PPC_VECTOR_VSX_TYPE)
+  #define PPC_VECTOR_MMA_TYPE(Name, Id, Size)

[llvm-branch-commits] [clang-tools-extra] 68e642c - [clang-tidy] Support all YAML supported spellings for bools in CheckOptions.

2020-12-15 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-15T21:15:16Z
New Revision: 68e642cad02468ce3efb18e7648cf82f2611e7a3

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

LOG: [clang-tidy] Support all YAML supported spellings for bools in 
CheckOptions.

Depends on D92755

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index af19da2419ab..3567aac42c06 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/WithColor.h"
+#include "llvm/Support/YAMLParser.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -108,13 +109,14 @@ ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef 
LocalName) const {
 
 static llvm::Expected getAsBool(StringRef Value,
   const llvm::Twine &LookupName) {
-  if (Value == "true")
-return true;
-  if (Value == "false")
-return false;
-  bool Result;
-  if (!Value.getAsInteger(10, Result))
-return Result;
+
+  if (llvm::Optional Parsed = llvm::yaml::parseBool(Value))
+return *Parsed;
+  // To maintain backwards compatability, we support parsing numbers as
+  // booleans, even though its not supported in YAML.
+  long long Number;
+  if (!Value.getAsInteger(10, Number))
+return Number != 0;
   return llvm::make_error(LookupName.str(),
  Value.str(), true);
 }

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 062216697111..a15ca304070e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -73,6 +73,9 @@ Improvements to clang-tidy
   ` and
   :doc:`modernize-make-unique `.
 
+- CheckOptions that take boolean values now support all spellings supported in 
+  the `YAML format `_.
+
 New modules
 ^^^
 

diff  --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
index 40cd9a5eff15..db9624684dfe 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -195,8 +195,9 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
   CheckOptions["test.BoolIFalseValue"] = "0";
   CheckOptions["test.BoolTrueValue"] = "true";
   CheckOptions["test.BoolFalseValue"] = "false";
+  CheckOptions["test.BoolTrueShort"] = "Y";
+  CheckOptions["test.BoolFalseShort"] = "N";
   CheckOptions["test.BoolUnparseable"] = "Nothing";
-  CheckOptions["test.BoolCaseMismatch"] = "True";
 
   ClangTidyContext Context(std::make_unique(
   ClangTidyGlobalOptions(), Options));
@@ -227,12 +228,11 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
   CHECK_VAL(TestCheck.getIntLocal("BoolIFalseValue"), false);
   CHECK_VAL(TestCheck.getIntLocal("BoolTrueValue"), true);
   CHECK_VAL(TestCheck.getIntLocal("BoolFalseValue"), false);
+  CHECK_VAL(TestCheck.getIntLocal("BoolTrueShort"), true);
+  CHECK_VAL(TestCheck.getIntLocal("BoolFalseShort"), false);
   CHECK_ERROR_INT(TestCheck.getIntLocal("BoolUnparseable"),
   "invalid configuration value 'Nothing' for option "
   "'test.BoolUnparseable'; expected a bool");
-  CHECK_ERROR_INT(TestCheck.getIntLocal("BoolCaseMismatch"),
-  "invalid configuration value 'True' for option "
-  "'test.BoolCaseMismatch'; expected a bool");
 
 #undef CHECK_ERROR_INT
 }



___
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] [flang] 9a883bf - [flang] Clean up TODO comments and fix one (DATA constant ambiguity)

2020-12-15 Thread peter klausler via llvm-branch-commits

Author: peter klausler
Date: 2020-12-15T13:36:07-08:00
New Revision: 9a883bfa11dd77cf2d45a25c5efc364e256e6d9a

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

LOG: [flang] Clean up TODO comments and fix one (DATA constant ambiguity)

Remove resolved & moot TODO comments in Common/, Parser/,
and Evaluate/.  Address a pending one relating to parsing
ambiguity in DATA statement constants, handling it with
symbol table information in Semantics and adding a test.

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

Added: 
flang/test/Semantics/data10.f90

Modified: 
flang/include/flang/Evaluate/real.h
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-state.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Evaluate/check-expression.cpp
flang/lib/Evaluate/type.cpp
flang/lib/Parser/Fortran-parsers.cpp
flang/lib/Parser/program-parsers.cpp
flang/lib/Semantics/data-to-inits.cpp
flang/lib/Semantics/rewrite-parse-tree.cpp
flang/test/Semantics/data01.f90
flang/test/Semantics/data06.f90

Removed: 




diff  --git a/flang/include/flang/Evaluate/real.h 
b/flang/include/flang/Evaluate/real.h
index 8ceb4639aa93..5864bdd7bd3a 100644
--- a/flang/include/flang/Evaluate/real.h
+++ b/flang/include/flang/Evaluate/real.h
@@ -63,10 +63,6 @@ class Real : public common::RealDetails {
 return word_ == that.word_;
   }
 
-  // TODO: DIM, MAX, MIN, DPROD, FRACTION,
-  // INT/NINT, NEAREST, OUT_OF_RANGE,
-  // RRSPACING/SPACING, SCALE, SET_EXPONENT
-
   constexpr bool IsSignBitSet() const { return word_.BTEST(bits - 1); }
   constexpr bool IsNegative() const {
 return !IsNotANumber() && IsSignBitSet();
@@ -118,7 +114,7 @@ class Real : public common::RealDetails {
   const Real &, Rounding rounding = defaultRounding) const;
 
   // SQRT(x**2 + y**2) but computed so as to avoid spurious overflow
-  // TODO: needed for CABS
+  // TODO: not yet implemented; needed for CABS
   ValueWithRealFlags HYPOT(
   const Real &, Rounding rounding = defaultRounding) const;
 

diff  --git a/flang/include/flang/Parser/dump-parse-tree.h 
b/flang/include/flang/Parser/dump-parse-tree.h
index 0d819f861495..8a7d1d1302b2 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -200,7 +200,6 @@ class ParseTreeDumper {
   NODE_ENUM(ConnectSpec::CharExpr, Kind)
   NODE(ConnectSpec, Newunit)
   NODE(ConnectSpec, Recl)
-  NODE(parser, ConstantValue)
   NODE(parser, ContainsStmt)
   NODE(parser, Contiguous)
   NODE(parser, ContiguousStmt)

diff  --git a/flang/include/flang/Parser/parse-state.h 
b/flang/include/flang/Parser/parse-state.h
index 00291bac4dbb..76cbb3470dc0 100644
--- a/flang/include/flang/Parser/parse-state.h
+++ b/flang/include/flang/Parser/parse-state.h
@@ -34,7 +34,6 @@ using common::LanguageFeature;
 
 class ParseState {
 public:
-  // TODO: Add a constructor for parsing a normalized module file.
   ParseState(const CookedSource &cooked)
   : p_{cooked.AsCharBlock().begin()}, limit_{cooked.AsCharBlock().end()} {}
   ParseState(const ParseState &that)

diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 27998c308cc0..a2beac4737f6 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -426,8 +426,9 @@ struct DeclarationConstruct {
 
 // R504 specification-part -> [use-stmt]... [import-stmt]... [implicit-part]
 //[declaration-construct]...
-// TODO: transfer any statements after the last IMPLICIT (if any)
-// from the implicit part to the declaration constructs
+// PARAMETER, FORMAT, and ENTRY statements that appear before any other
+// kind of declaration-construct will be parsed into the implicit-part,
+// even if there are no IMPLICIT statements.
 struct SpecificationPart {
   TUPLE_CLASS_BOILERPLATE(SpecificationPart);
   std::tuple,
@@ -861,13 +862,6 @@ struct LiteralConstant {
   u;
 };
 
-// R604 constant ->  literal-constant | named-constant
-// Renamed to dodge a clash with Constant<> template class.
-struct ConstantValue {
-  UNION_CLASS_BOILERPLATE(ConstantValue);
-  std::variant u;
-};
-
 // R807 access-spec -> PUBLIC | PRIVATE
 struct AccessSpec {
   ENUM_CLASS(Kind, Public, Private)
@@ -1412,14 +1406,15 @@ using TypedExpr = 
common::ForwardOwningPointer;
 //signed-int-literal-constant | signed-real-literal-constant |
 //null-init | initial-data-target |
 //structure-constructor
+// N.B. Parsing ambiguities abound here without recourse to symbols
+// (see comments on R845's parser).
 struct DataStmtConstant {
   UNION_CLASS_BOILERPLATE(DataStmtConstant);
   CharBlock source;
   mutable TypedExpr typedExpr;
-  s

[llvm-branch-commits] [llvm] a7deedc - [NFC][Tests][SimplifyCFG] Trim whitespaces at the end of lines

2020-12-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-16T00:38:00+03:00
New Revision: a7deedc414e2abbe4b9557d46e896a5bdba25f2b

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

LOG: [NFC][Tests][SimplifyCFG] Trim whitespaces at the end of lines

Added: 


Modified: 
llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll
llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll
llvm/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll
llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll
llvm/test/Transforms/SimplifyCFG/PHINode.ll
llvm/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll
llvm/test/Transforms/SimplifyCFG/PhiEliminate.ll
llvm/test/Transforms/SimplifyCFG/PhiNoEliminate.ll
llvm/test/Transforms/SimplifyCFG/X86/empty-cleanuppad.ll
llvm/test/Transforms/SimplifyCFG/common-code-hoisting.ll
llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
llvm/test/Transforms/SimplifyCFG/nomerge.ll
llvm/test/Transforms/SimplifyCFG/preserve-make-implicit-on-switch-to-br.ll
llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll

Removed: 




diff  --git a/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll 
b/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll
index f6b068fd79c3..f1d2dbe0c128 100644
--- a/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll
@@ -1,4 +1,4 @@
-; This test checks to make sure that 'br X, Dest, Dest' is folded into 
+; This test checks to make sure that 'br X, Dest, Dest' is folded into
 ; 'br Dest'
 
 ; RUN: opt < %s -simplifycfg -S | FileCheck %s

diff  --git a/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll 
b/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll
index 78049080a64e..570f15258f07 100644
--- a/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll
@@ -1,6 +1,6 @@
-; This test checks to make sure that 'br X, Dest, Dest' is folded into 
+; This test checks to make sure that 'br X, Dest, Dest' is folded into
 ; 'br Dest'.  This can only happen after the 'Z' block is eliminated.  This is
-; due to the fact that the SimplifyCFG function does not use 
+; due to the fact that the SimplifyCFG function does not use
 ; the ConstantFoldTerminator function.
 
 ; RUN: opt < %s -simplifycfg -S | FileCheck %s

diff  --git a/llvm/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll 
b/llvm/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll
index 21e9bc7b7f4e..161e74c6e098 100644
--- a/llvm/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll
@@ -2,7 +2,7 @@
 ; RUN: not grep "^BB.tomerge" %t
 ; RUN: grep "^BB.nomerge" %t | count 4
 
-; ModuleID = '' 
+; ModuleID = ''
 declare i1 @foo()
 
 declare i1 @bar(i32)
@@ -78,7 +78,7 @@ Pre-Exit:   ; preds = %Succ
 ; not completely trivial
%cond2 = call i1 @foo( );  [#uses=1]
br i1 %cond2, label %Succ, label %Exit
-
+
 Exit:  ; preds = %Pre-Exit
ret void
 }

diff  --git a/llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll 
b/llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll
index d3c7c320cee3..297ebef2766b 100644
--- a/llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll
@@ -3,7 +3,7 @@ define i32 @test() {
 entry:
br label %T
 T:
-   %C = phi i1 [false, %entry] 
+   %C = phi i1 [false, %entry]
br i1 %C, label %X, label %Y
 X:
ret i32 2

diff  --git a/llvm/test/Transforms/SimplifyCFG/PHINode.ll 
b/llvm/test/Transforms/SimplifyCFG/PHINode.ll
index 25a242a55997..a024c9d41dba 100644
--- a/llvm/test/Transforms/SimplifyCFG/PHINode.ll
+++ b/llvm/test/Transforms/SimplifyCFG/PHINode.ll
@@ -1,4 +1,4 @@
-; -simplifycfg is not folding blocks if there is a PHI node involved.  This 
+; -simplifycfg is not folding blocks if there is a PHI node involved.  This
 ; should be fixed eventually
 
 ; RUN: opt < %s -simplifycfg -S | FileCheck %s

diff  --git a/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll 
b/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll
index fb5d600f1148..269c9eefa95a 100644
--- a/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll
+++ b/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll
@@ -1,5 +1,5 @@
 ; Test merging of blocks that only have PHI nodes in them.  This tests the case
-; where the mergedinto block doesn't have any PHI nodes, and is in fact 
+; where the mergedinto block doesn't have any PHI nodes, and is in fact
 ; dominated

[llvm-branch-commits] [llvm] e113317 - [NFCI][SimplifyCFG] Add basic scaffolding for gradually making the pass DomTree-aware

2020-12-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-16T00:38:00+03:00
New Revision: e1133179587dd895962a2fe4d6eb0cb1e63b5ee2

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

LOG: [NFCI][SimplifyCFG] Add basic scaffolding for gradually making the pass 
DomTree-aware

Two observations:
1. Unavailability of DomTree makes it impossible to make
  `FoldBranchToCommonDest()` transform in certain cases,
   where the successor is dominated by predecessor,
   because we then don't have PHI's, and can't recreate them,
   well, without handrolling 'is dominated by' check,
   which doesn't really look like a great solution to me.
2. Avoiding invalidating DomTree in SimplifyCFG will
   decrease the number of `Dominator Tree Construction` by 5
   (from 28 now, i.e. -18%) in `-O3` old-pm pipeline
   (as per `llvm/test/Other/opt-O3-pipeline.ll`)
   This might or might not be beneficial for compile time.

So the plan is to make SimplifyCFG preserve DomTree, and then
eventually make DomTree fully required and preserved by the pass.

Now, SimplifyCFG is ~7KLOC. I don't think it will be nice
to do all this uplifting in a single mega-commit,
nor would it be possible to review it in any meaningful way.

But, i believe, it should be possible to do this in smaller steps,
introducing the new behavior, in an optional way, off-by-default,
opt-in option, and gradually fixing transforms one-by-one
and adding the flag to appropriate test coverage.

Then, eventually, the default should be flipped,
and eventually^2 the flag removed.

And that is what is happening here - when the new off-by-default option
is specified, DomTree is required and is claimed to be preserved,
and SimplifyCFG-internal assertions verify that the DomTree is still OK.

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/Local.h
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/Local.h 
b/llvm/include/llvm/Transforms/Utils/Local.h
index fb6f0269a0ac..5a5fb90be1c7 100644
--- a/llvm/include/llvm/Transforms/Utils/Local.h
+++ b/llvm/include/llvm/Transforms/Utils/Local.h
@@ -30,6 +30,7 @@
 #include "llvm/IR/Value.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
 #include 
 #include 
@@ -186,6 +187,7 @@ bool EliminateDuplicatePHINodes(BasicBlock *BB);
 /// It returns true if a modification was made, possibly deleting the basic
 /// block that was pointed to. LoopHeaders is an optional input parameter
 /// providing the set of loop headers that SimplifyCFG should not eliminate.
+extern cl::opt RequireAndPreserveDomTree;
 bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
  const SimplifyCFGOptions &Options = {},
  SmallPtrSetImpl *LoopHeaders = nullptr);

diff  --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp 
b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index c36619211971..deb6494f6b07 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -31,6 +31,7 @@
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Dominators.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Module.h"
@@ -191,8 +192,9 @@ static bool iterativelySimplifyCFG(Function &F, const 
TargetTransformInfo &TTI,
   return Changed;
 }
 
-static bool simplifyFunctionCFG(Function &F, const TargetTransformInfo &TTI,
-const SimplifyCFGOptions &Options) {
+static bool simplifyFunctionCFGImpl(Function &F, const TargetTransformInfo 
&TTI,
+DominatorTree *DT,
+const SimplifyCFGOptions &Options) {
   bool EverChanged = removeUnreachableBlocks(F);
   EverChanged |= mergeEmptyReturnBlocks(F);
   EverChanged |= iterativelySimplifyCFG(F, TTI, Options);
@@ -216,6 +218,22 @@ static bool simplifyFunctionCFG(Function &F, const 
TargetTransformInfo &TTI,
   return true;
 }
 
+static bool simplifyFunctionCFG(Function &F, const TargetTransformInfo &TTI,
+DominatorTree *DT,
+const SimplifyCFGOptions &Options) {
+  assert((!RequireAndPreserveDomTree ||
+  (DT && DT->verify(DominatorTree::VerificationLevel::Full))) &&
+ "Original domtree is invalid?");
+
+  bool Changed = simplifyFunctionCFGImpl(F, TTI, DT, Options);
+
+  assert((!RequireAndPreserveDomTree ||
+  (DT && DT->verify(DominatorTree::VerificationLevel::Full))) &&
+ "Failed to maintain validity of domtree!");
+
+  return Ch

[llvm-branch-commits] [mlir] 95019de - [mlir][IR] Define the singleton builtin types in ODS instead of C++

2020-12-15 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-15T13:42:19-08:00
New Revision: 95019de8a122619fc038c9fe3c80e625e3456bbf

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

LOG: [mlir][IR] Define the singleton builtin types in ODS instead of C++

This exposes several issues with the current generation that this revision also 
fixes.
 * TypeDef now allows specifying the base class to use when generating.
 * TypeDef now inherits from DialectType, which allows for using it as a 
TypeConstraint
 * Parser/Printers are now no longer generated in the header(removing duplicate 
symbols), and are now only generated when necessary.
- Now that generatedTypeParser/Printer are only generated in the definition 
file,
  existing users will need to manually expose this functionality when 
necessary.
 * ::get() is no longer generated for singleton types, because it isn't 
necessary.

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

Added: 
mlir/include/mlir/IR/BuiltinDialect.td
mlir/include/mlir/IR/BuiltinTypes.td

Modified: 
mlir/docs/OpDefinitions.md
mlir/include/mlir/IR/BuiltinOps.td
mlir/include/mlir/IR/BuiltinTypes.h
mlir/include/mlir/IR/CMakeLists.txt
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/TableGen/TypeDef.h
mlir/lib/IR/BuiltinTypes.cpp
mlir/lib/IR/CMakeLists.txt
mlir/lib/TableGen/Constraint.cpp
mlir/lib/TableGen/TypeDef.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestTypes.cpp
mlir/test/mlir-tblgen/typedefs.td
mlir/tools/mlir-tblgen/TypeDefGen.cpp

Removed: 




diff  --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md
index 189cd0825af7..c5ffe452b927 100644
--- a/mlir/docs/OpDefinitions.md
+++ b/mlir/docs/OpDefinitions.md
@@ -1370,10 +1370,10 @@ llvm::Optional symbolizeMyBitEnum(uint32_t 
value) {
 
 ## Type Definitions
 
-MLIR defines the TypeDef class hierarchy to enable generation of data types
-from their specifications. A type is defined by specializing the TypeDef
-class with concrete contents for all the fields it requires. For example, an
-integer type could be defined as:
+MLIR defines the TypeDef class hierarchy to enable generation of data types 
from
+their specifications. A type is defined by specializing the TypeDef class with
+concrete contents for all the fields it requires. For example, an integer type
+could be defined as:
 
 ```tablegen
 // All of the types will extend this class.
@@ -1414,45 +1414,43 @@ def IntegerType : Test_Type<"TestInteger"> {
 ### Type name
 
 The name of the C++ class which gets generated defaults to
-`Type` (e.g. `TestIntegerType` in the above example). This
-can be overridden via the `cppClassName` field. The field `mnemonic` is
-to specify the asm name for parsing. It is optional and not specifying it
-will imply that no parser or printer methods are attached to this class.
+`Type` (e.g. `TestIntegerType` in the above example). This can
+be overridden via the `cppClassName` field. The field `mnemonic` is to specify
+the asm name for parsing. It is optional and not specifying it will imply that
+no parser or printer methods are attached to this class.
 
 ### Type documentation
 
-The `summary` and `description` fields exist and are to be used the same way
-as in Operations. Namely, the summary should be a one-liner and `description`
+The `summary` and `description` fields exist and are to be used the same way as
+in Operations. Namely, the summary should be a one-liner and `description`
 should be a longer explanation.
 
 ### Type parameters
 
-The `parameters` field is a list of the types parameters. If no parameters
-are specified (the default), this type is considered a singleton type.
-Parameters are in the `"c++Type":$paramName` format.
-To use C++ types as parameters which need allocation in the storage
-constructor, there are two options:
+The `parameters` field is a list of the types parameters. If no parameters are
+specified (the default), this type is considered a singleton type. Parameters
+are in the `"c++Type":$paramName` format. To use C++ types as parameters which
+need allocation in the storage constructor, there are two options:
 
-- Set `hasCustomStorageConstructor` to generate the TypeStorage class with
-a constructor which is just declared -- no definition -- so you can write it
-yourself.
-- Use the `TypeParameter` tablegen class instead of the "c++Type" string.
+-   Set `hasCustomStorageConstructor` to generate the TypeStorage class with a
+constructor which is just declared -- no definition -- so you can write it
+yourself.
+-   Use the `TypeParameter` tablegen class instead of the "c++Type" string.
 
 ### TypeParameter tablegen class
 
-This is used to further specify attributes about each of the types
-

[llvm-branch-commits] [llvm] 028efac - [RISCV] Only custom legalize i32 arguments to vector intrinsics on RV64.

2020-12-15 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-15T13:54:41-08:00
New Revision: 028efac2d7c2a32c35a093e53ea12f527edff7c7

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

LOG: [RISCV] Only custom legalize i32 arguments to vector intrinsics on RV64.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 529a5bf784f4..c0202e3f19e0 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -340,9 +340,12 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
 
   if (Subtarget.hasStdExtV()) {
 setBooleanVectorContents(ZeroOrOneBooleanContent);
+
 // RVV intrinsics may have illegal operands.
-for (auto VT : {MVT::i8, MVT::i16, MVT::i32})
-  setOperationAction(ISD::INTRINSIC_WO_CHAIN, VT, Custom);
+setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i8, Custom);
+setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i16, Custom);
+if (Subtarget.is64Bit())
+  setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i32, Custom);
   }
 
   // Function alignments.



___
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] 59decf8 - [clang] Migrate deprecated DebugInfo::get to DILocation::get

2020-12-15 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-15T13:59:31-08:00
New Revision: 59decf8e9c3d86472073266ad8ee1cc699d94525

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

LOG: [clang] Migrate deprecated DebugInfo::get to DILocation::get

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5d48315223f9..7b20d43b0f17 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -115,8 +115,9 @@ void ApplyDebugLocation::init(SourceLocation 
TemporaryLocation,
 
   // Construct a location that has a valid scope, but no line info.
   assert(!DI->LexicalBlockStack.empty());
-  CGF->Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(
-  0, 0, DI->LexicalBlockStack.back(), DI->getInlinedAt()));
+  CGF->Builder.SetCurrentDebugLocation(
+  llvm::DILocation::get(DI->LexicalBlockStack.back()->getContext(), 0, 0,
+DI->LexicalBlockStack.back(), DI->getInlinedAt()));
 }
 
 ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E)
@@ -4015,8 +4016,9 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, 
SourceLocation Loc) {
 return;
 
   llvm::MDNode *Scope = LexicalBlockStack.back();
-  Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(
-  getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope, CurInlinedAt));
+  Builder.SetCurrentDebugLocation(
+  llvm::DILocation::get(CGM.getLLVMContext(), getLineNumber(CurLoc),
+getColumnNumber(CurLoc), Scope, CurInlinedAt));
 }
 
 void CGDebugInfo::CreateLexicalBlock(SourceLocation Loc) {
@@ -4047,9 +4049,9 @@ void CGDebugInfo::EmitLexicalBlockStart(CGBuilderTy 
&Builder,
   setLocation(Loc);
 
   // Emit a line table change for the current location inside the new scope.
-  Builder.SetCurrentDebugLocation(
-  llvm::DebugLoc::get(getLineNumber(Loc), getColumnNumber(Loc),
-  LexicalBlockStack.back(), CurInlinedAt));
+  Builder.SetCurrentDebugLocation(llvm::DILocation::get(
+  CGM.getLLVMContext(), getLineNumber(Loc), getColumnNumber(Loc),
+  LexicalBlockStack.back(), CurInlinedAt));
 
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
@@ -4260,10 +4262,11 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const 
VarDecl *VD,
 Flags | llvm::DINode::FlagArtificial, FieldAlign);
 
 // Insert an llvm.dbg.declare into the current block.
-DBuilder.insertDeclare(
-Storage, D, DBuilder.createExpression(Expr),
-llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
-Builder.GetInsertBlock());
+DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
+   llvm::DILocation::get(CGM.getLLVMContext(), 
Line,
+ Column, Scope,
+ CurInlinedAt),
+   Builder.GetInsertBlock());
   }
 }
   }
@@ -4288,7 +4291,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const 
VarDecl *VD,
 
   // Insert an llvm.dbg.declare into the current block.
   DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
- llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
+ llvm::DILocation::get(CGM.getLLVMContext(), Line,
+   Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
   return D;
@@ -4324,7 +4328,8 @@ void CGDebugInfo::EmitLabel(const LabelDecl *D, 
CGBuilderTy &Builder) {
 
   // Insert an llvm.dbg.label into the current block.
   DBuilder.insertLabel(L,
-   llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
+   llvm::DILocation::get(CGM.getLLVMContext(), Line, 
Column,
+ Scope, CurInlinedAt),
Builder.GetInsertBlock());
 }
 
@@ -4398,8 +4403,8 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
   Line, Ty, false, llvm::DINode::FlagZero, Align);
 
   // Insert an llvm.dbg.declare into the current block.
-  auto DL =
-  llvm::DebugLoc::get(Line, Column, LexicalBlockStack.back(), 
CurInlinedAt);
+  auto DL = llvm::DILocation::get(CGM.getLLVMContext(), Line, Column,
+  LexicalBlockStack.back(), CurInlinedAt);
   auto *Expr = DBuilder.createExpression(addr);
   if (InsertPoint)
 DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint);
@@ -4584,7 +4589,8 @@ void 
CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
 
   // Insert an llvm.dbg.declare int

[llvm-branch-commits] [llvm] 97f51f0 - AMDGPU: Remove redundant CCAction for i1

2020-12-15 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-15T17:00:27-05:00
New Revision: 97f51f0489e55ec73efd8d1623d19b3455f39878

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

LOG: AMDGPU: Remove redundant CCAction for i1

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td 
b/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td
index 7129c6991f2a..250c42776297 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td
@@ -199,7 +199,7 @@ def CSR_AMDGPU_NoRegs : CalleeSavedRegs<(add)>;
 def CC_AMDGPU_Func : CallingConv<[
   CCIfByVal>,
   CCIfType<[i1], CCPromoteToType>,
-  CCIfType<[i1, i8, i16], CCIfExtend>>,
+  CCIfType<[i8, i16], CCIfExtend>>,
   CCIfType<[i32, f32, i16, f16, v2i16, v2f16, i1], CCAssignToReg<[
 VGPR0, VGPR1, VGPR2, VGPR3, VGPR4, VGPR5, VGPR6, VGPR7,
 VGPR8, VGPR9, VGPR10, VGPR11, VGPR12, VGPR13, VGPR14, VGPR15,



___
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] e7e7d37 - GlobalISel: Fix generic handling of single outgoing call arguments

2020-12-15 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-15T17:00:27-05:00
New Revision: e7e7d371fd871c9976bd2c7bbb9be60fe37c6d28

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

LOG: GlobalISel: Fix generic handling of single outgoing call arguments

Simply call the argument handler like is done for the incoming
case. This will allow removal of hacks in the AMDGPU call lowering in
a future change.

Added: 


Modified: 
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp 
b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 69ed775b6aad..c32811db4e1b 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -241,12 +241,20 @@ bool CallLowering::handleAssignments(CCState &CCInfo,
 // we currently support.
 unsigned NumParts = TLI->getNumRegistersForCallingConv(
 F.getContext(), F.getCallingConv(), CurVT);
-if (NumParts > 1) {
-  // For now only handle exact splits.
-  if (NewVT.getSizeInBits() * NumParts != CurVT.getSizeInBits())
+
+if (NumParts == 1) {
+  // Try to use the register type if we couldn't assign the VT.
+  if (Handler.assignArg(i, NewVT, NewVT, CCValAssign::Full, Args[i],
+Args[i].Flags[0], CCInfo))
 return false;
+  continue;
 }
 
+assert(NumParts > 1);
+// For now only handle exact splits.
+if (NewVT.getSizeInBits() * NumParts != CurVT.getSizeInBits())
+  return false;
+
 // For incoming arguments (physregs to vregs), we could have values in
 // physregs (or memlocs) which we want to extract and copy to vregs.
 // During this, we might have to deal with the LLT being split across
@@ -256,47 +264,36 @@ bool CallLowering::handleAssignments(CCState &CCInfo,
 // vreg with an LLT which we want to assign to a physical location, and
 // we might have to record that the value has to be split later.
 if (Handler.isIncomingArgumentHandler()) {
-  if (NumParts == 1) {
-// Try to use the register type if we couldn't assign the VT.
+  // We're handling an incoming arg which is split over multiple regs.
+  // E.g. passing an s128 on AArch64.
+  ISD::ArgFlagsTy OrigFlags = Args[i].Flags[0];
+  Args[i].OrigRegs.push_back(Args[i].Regs[0]);
+  Args[i].Regs.clear();
+  Args[i].Flags.clear();
+  LLT NewLLT = getLLTForMVT(NewVT);
+  // For each split register, create and assign a vreg that will store
+  // the incoming component of the larger value. These will later be
+  // merged to form the final vreg.
+  for (unsigned Part = 0; Part < NumParts; ++Part) {
+Register Reg =
+MIRBuilder.getMRI()->createGenericVirtualRegister(NewLLT);
+ISD::ArgFlagsTy Flags = OrigFlags;
+if (Part == 0) {
+  Flags.setSplit();
+} else {
+  Flags.setOrigAlign(Align(1));
+  if (Part == NumParts - 1)
+Flags.setSplitEnd();
+}
+Args[i].Regs.push_back(Reg);
+Args[i].Flags.push_back(Flags);
 if (Handler.assignArg(i, NewVT, NewVT, CCValAssign::Full, Args[i],
-  Args[i].Flags[0], CCInfo))
+  Args[i].Flags[Part], CCInfo)) {
+  // Still couldn't assign this smaller part type for some reason.
   return false;
-  } else {
-// We're handling an incoming arg which is split over multiple regs.
-// E.g. passing an s128 on AArch64.
-ISD::ArgFlagsTy OrigFlags = Args[i].Flags[0];
-Args[i].OrigRegs.push_back(Args[i].Regs[0]);
-Args[i].Regs.clear();
-Args[i].Flags.clear();
-LLT NewLLT = getLLTForMVT(NewVT);
-// For each split register, create and assign a vreg that will store
-// the incoming component of the larger value. These will later be
-// merged to form the final vreg.
-for (unsigned Part = 0; Part < NumParts; ++Part) {
-  Register Reg =
-  MIRBuilder.getMRI()->createGenericVirtualRegister(NewLLT);
-  ISD::ArgFlagsTy Flags = OrigFlags;
-  if (Part == 0) {
-Flags.setSplit();
-  } else {
-Flags.setOrigAlign(Align(1));
-if (Part == NumParts - 1)
-  Flags.setSplitEnd();
-  }
-  Args[i].Regs.push_back(Reg);
-  Args[i].Flags.push_back(Flags);
-  if (Handler.assignArg(i, NewVT, NewVT, CCValAssign::Full,
-Args[i], Args[i].Flags[Part], CCInfo)) {
-// Still couldn't assign this smaller part type for some reason.
-return false;
-  }
 }
   }
 } else {
-  // Handling an outgoing 

[llvm-branch-commits] [llvm] 71601d2 - [Hexagon] Fix bitcasting v1i8 -> i8

2020-12-15 Thread Krzysztof Parzyszek via llvm-branch-commits

Author: Krzysztof Parzyszek
Date: 2020-12-15T16:01:24-06:00
New Revision: 71601d2ac9954cb59c443cb3ae442cb106df35d4

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

LOG: [Hexagon] Fix bitcasting v1i8 -> i8

Added: 
llvm/test/CodeGen/Hexagon/isel-bitcast-v1i8-i8.ll

Modified: 
llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp 
b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index b60758a8be8a..c8994a3a28a3 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -3151,10 +3151,12 @@ HexagonTargetLowering::ReplaceNodeResults(SDNode *N,
 case ISD::BITCAST:
   // Handle a bitcast from v8i1 to i8.
   if (N->getValueType(0) == MVT::i8) {
-SDValue P = getInstr(Hexagon::C2_tfrpr, dl, MVT::i32,
- N->getOperand(0), DAG);
-SDValue T = DAG.getAnyExtOrTrunc(P, dl, MVT::i8);
-Results.push_back(T);
+if (N->getOperand(0).getValueType() == MVT::v8i1) {
+  SDValue P = getInstr(Hexagon::C2_tfrpr, dl, MVT::i32,
+   N->getOperand(0), DAG);
+  SDValue T = DAG.getAnyExtOrTrunc(P, dl, MVT::i8);
+  Results.push_back(T);
+}
   }
   break;
   }

diff  --git a/llvm/test/CodeGen/Hexagon/isel-bitcast-v1i8-i8.ll 
b/llvm/test/CodeGen/Hexagon/isel-bitcast-v1i8-i8.ll
new file mode 100644
index ..77696a331a8f
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/isel-bitcast-v1i8-i8.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -march=hexagon  < %s | FileCheck %s
+
+; This shouldn't crash.
+
+define i8 @fred(<4 x i8>* %a0) #0 {
+; CHECK-LABEL: fred:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:{
+; CHECK-NEXT: r0 = memw(r0+#0)
+; CHECK-NEXT:}
+; CHECK-NEXT:{
+; CHECK-NEXT: r0 = extractu(r0,#8,#16)
+; CHECK-NEXT: jumpr r31
+; CHECK-NEXT:}
+  %v0 = load <4 x i8>, <4 x i8>* %a0, align 4
+  %v1 = shufflevector <4 x i8> %v0, <4 x i8> undef, <1 x i32> 
+  %v2 = bitcast <1 x i8> %v1 to i8
+  ret i8 %v2
+}
+
+attributes #0 = { nounwind "target-cpu"="hexagonv66" }



___
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] 8c4e557 - [docs][unittest][Go][StackProtector] Migrate deprecated DebugInfo::get to DILocation::get

2020-12-15 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-15T14:17:04-08:00
New Revision: 8c4e55762d8b7a07546a5db18e33ccc6a9d97002

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

LOG: [docs][unittest][Go][StackProtector] Migrate deprecated DebugInfo::get to 
DILocation::get

Added: 


Modified: 
llvm/bindings/go/llvm/IRBindings.cpp
llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
llvm/lib/CodeGen/StackProtector.cpp
llvm/unittests/CodeGen/LexicalScopesTest.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
llvm/unittests/IR/IRBuilderTest.cpp
llvm/unittests/Transforms/Utils/CloningTest.cpp

Removed: 




diff  --git a/llvm/bindings/go/llvm/IRBindings.cpp 
b/llvm/bindings/go/llvm/IRBindings.cpp
index 5b84f482b16b..5ee841c5fa9b 100644
--- a/llvm/bindings/go/llvm/IRBindings.cpp
+++ b/llvm/bindings/go/llvm/IRBindings.cpp
@@ -53,9 +53,12 @@ void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, 
LLVMMetadataRef MD) {
 void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
   unsigned Col, LLVMMetadataRef Scope,
   LLVMMetadataRef InlinedAt) {
-  unwrap(Bref)->SetCurrentDebugLocation(
-  DebugLoc::get(Line, Col, Scope ? unwrap(Scope) : nullptr,
-InlinedAt ? unwrap(InlinedAt) : nullptr));
+  if (!Scope)
+unwrap(Bref)->SetCurrentDebugLocation(DebugLoc());
+  else
+unwrap(Bref)->SetCurrentDebugLocation(
+DILocation::get(Scope->getContext(), Line, Col, unwrap(Scope),
+InlinedAt ? unwrap(InlinedAt) : nullptr));
 }
 
 LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref) {

diff  --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst 
b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
index 0304c8ec813f..c641999b226b 100644
--- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
+++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
@@ -341,7 +341,7 @@ We use a small helper function for this:
 else
   Scope = LexicalBlocks.back();
 Builder.SetCurrentDebugLocation(
-DebugLoc::get(AST->getLine(), AST->getCol(), Scope));
+DILocation::get(Scope->getContext(), AST->getLine(), AST->getCol(), 
Scope));
   }
 
 This both tells the main ``IRBuilder`` where we are, but also what scope
@@ -400,7 +400,7 @@ argument allocas in ``FunctionAST::codegen``.
   true);
 
   DBuilder->insertDeclare(Alloca, D, DBuilder->createExpression(),
-  DebugLoc::get(LineNo, 0, SP),
+  DILocation::get(SP->getContext(), LineNo, 0, SP),
   Builder.GetInsertBlock());
 
   // Store the initial value into the alloca.

diff  --git a/llvm/lib/CodeGen/StackProtector.cpp 
b/llvm/lib/CodeGen/StackProtector.cpp
index 9e1a29e61a12..0411faabbcc3 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -556,7 +556,9 @@ BasicBlock *StackProtector::CreateFailBB() {
   LLVMContext &Context = F->getContext();
   BasicBlock *FailBB = BasicBlock::Create(Context, "CallStackCheckFailBlk", F);
   IRBuilder<> B(FailBB);
-  B.SetCurrentDebugLocation(DebugLoc::get(0, 0, F->getSubprogram()));
+  if (F->getSubprogram())
+B.SetCurrentDebugLocation(
+DILocation::get(Context, 0, 0, F->getSubprogram()));
   if (Trip.isOSOpenBSD()) {
 FunctionCallee StackChkFail = M->getOrInsertFunction(
 "__stack_smash_handler", Type::getVoidTy(Context),

diff  --git a/llvm/unittests/CodeGen/LexicalScopesTest.cpp 
b/llvm/unittests/CodeGen/LexicalScopesTest.cpp
index 20975a775bf7..14f43bb39430 100644
--- a/llvm/unittests/CodeGen/LexicalScopesTest.cpp
+++ b/llvm/unittests/CodeGen/LexicalScopesTest.cpp
@@ -112,12 +112,12 @@ class LexicalScopesTest : public testing::Test {
DINode::FlagZero, DISubprogram::SPFlagDefinition);
 
 // Make some nested scopes.
-OutermostLoc = DebugLoc::get(3, 1, OurFunc);
-InBlockLoc = DebugLoc::get(4, 1, OurBlock);
-InlinedLoc = DebugLoc::get(10, 1, ToInlineFunc, InBlockLoc.get());
+OutermostLoc = DILocation::get(Ctx, 3, 1, OurFunc);
+InBlockLoc = DILocation::get(Ctx, 4, 1, OurBlock);
+InlinedLoc = DILocation::get(Ctx, 10, 1, ToInlineFunc, InBlockLoc.get());
 
 // Make a scope that isn't nested within the others.
-NotNestedBlockLoc = DebugLoc::get(4, 1, AnotherBlock);
+NotNestedBlockLoc = DILocation::get(Ctx, 4, 1, AnotherBlock);
 
 DIB.finalize();
   }

diff  --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp 
b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index ad58fb837006..508c274b9b65 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Fro

[llvm-branch-commits] [clang] 0eb4378 - Frontend: Fix confusing comment at call to clearOutputFiles, NFC

2020-12-15 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-15T14:21:37-08:00
New Revision: 0eb4378290ffcd5da650217df3ac3b8c473d5ed6

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

LOG: Frontend: Fix confusing comment at call to clearOutputFiles, NFC

Fix the comment in front of `compileModuleImpl`'s call to
`CompilerInstance::clearOutputFiles`. The purpose of this call is to
delete any stray temporary files after the module generation thread
crashes.

The comment is from f545f67de3a1bfdbbfad88acde5b540ce3b82f4f, and
was associated with manually deleting a generated module map. Then
13afbf42d830dd43febbeb0855aa359ca9dbfbf9 added this `clearOutputFiles`
call between the comment and the code it referenced. Finally,
1f76c4e8101b9beaf8f1b10a57faa80256ab2b05 started sending the generated
module map directly to the SourceManager instead of putting it on disk,
deleting the call that the comment referenced.

No functionality change.

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 17875a2ed85b..69e2e554d018 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1182,10 +1182,8 @@ compileModuleImpl(CompilerInstance &ImportingInstance, 
SourceLocation ImportLoc,
 diag::remark_module_build_done)
 << ModuleName;
 
-  // Delete the temporary module map file.
-  // FIXME: Even though we're executing under crash protection, it would still
-  // be nice to do this with RemoveFileOnSignal when we can. However, that
-  // doesn't make sense for all clients, so clean this up manually.
+  // Delete any remaining temporary files related to Instance, in case the
+  // module generation thread crashed.
   Instance.clearOutputFiles(/*EraseFiles=*/true);
 
   return !Instance.getDiagnostics().hasErrorOccurred();



___
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] [libcxx] f2966d1 - [libc++] Use consistent declaration for main() in test

2020-12-15 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-15T17:34:06-05:00
New Revision: f2966d17a2706809308ae768f64c6b4046f6f432

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

LOG: [libc++] Use consistent declaration for main() in test

Added: 


Modified: 

libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp
 
b/libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp
index 9dac2976632e..32d770ed4f91 100644
--- 
a/libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp
+++ 
b/libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp
@@ -20,7 +20,7 @@ struct Intable {
 operator int() const { return 1; }
 };
 
-int main() {
+int main(int, char**) {
 Holder *a[2] = {};
 Holder **p = a;
 #if TEST_STD_VER >= 17
@@ -31,4 +31,6 @@ int main() {
 #endif
 std::advance(p, Intable >());
 (void)std::distance(p, p);
+
+return 0;
 }



___
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] 60eba81 - RegisterCoalescer: Remove phi-only subranges when erasing identity copies

2020-12-15 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-15T17:36:32-05:00
New Revision: 60eba8161bd314eaf02952deaa023c334fcca080

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

LOG: RegisterCoalescer: Remove phi-only subranges when erasing identity copies

Undef subranges are not present in the live range values, except when
they cross block boundaries. In this situation, a identity copy is
inside a loop, and one of the lanes is undefined. It only appears
alive inside the loop due to the copy. Once the copy was erased, it
would leave behind a segment inside the loop body with no
corresponding def anywhere in the program.

When RenameIndependentSubregs processed this dummy interval, it would
introduce a "Multiple connected components in live interval" verifier
error when IMPLICIT_DEFs were added to the other two blocks. I believe
there is a missing verifier check for this type of dummy interval.

I have found additional cases from the same fundamental problem in
other areas I haven't managed to fix yet (e.g. the commented out
prune_subrange_phi_value_* cases).

Added: 
llvm/test/CodeGen/AMDGPU/coalesce-identity-copies-undef-subregs.mir

Modified: 
llvm/lib/CodeGen/RegisterCoalescer.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp 
b/llvm/lib/CodeGen/RegisterCoalescer.cpp
index 7deabe6761d9..5fee663d8978 100644
--- a/llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -211,6 +211,18 @@ namespace {
 /// live interval update is costly.
 void lateLiveIntervalUpdate();
 
+/// Check if the incoming value defined by a COPY at \p SLRQ in the 
subrange
+/// has no value defined in the predecessors. If the incoming value is the
+/// same as defined by the copy itself, the value is considered undefined.
+bool copyValueUndefInPredecessors(LiveRange &S,
+  const MachineBasicBlock *MBB,
+  LiveQueryResult SLRQ);
+
+/// Set necessary undef flags on subregister uses after pruning out undef
+/// lane segments from the subrange.
+void setUndefOnPrunedSubRegUses(LiveInterval &LI, Register Reg,
+LaneBitmask PrunedLanes);
+
 /// Attempt to join intervals corresponding to SrcReg/DstReg, which are the
 /// src/dst of the copy instruction CopyMI.  This returns true if the copy
 /// was successfully coalesced away. If it is not currently possible to
@@ -1809,6 +1821,49 @@ bool RegisterCoalescer::canJoinPhys(const CoalescerPair 
&CP) {
   return false;
 }
 
+bool RegisterCoalescer::copyValueUndefInPredecessors(
+LiveRange &S, const MachineBasicBlock *MBB, LiveQueryResult SLRQ) {
+  for (const MachineBasicBlock *Pred : MBB->predecessors()) {
+SlotIndex PredEnd = LIS->getMBBEndIdx(Pred);
+if (VNInfo *V = S.getVNInfoAt(PredEnd.getPrevSlot())) {
+  // If this is a self loop, we may be reading the same value.
+  if (V->id != SLRQ.valueOutOrDead()->id)
+return false;
+}
+  }
+
+  return true;
+}
+
+void RegisterCoalescer::setUndefOnPrunedSubRegUses(LiveInterval &LI,
+   Register Reg,
+   LaneBitmask PrunedLanes) {
+  // If we had other instructions in the segment reading the undef sublane
+  // value, we need to mark them with undef.
+  for (MachineOperand &MO : MRI->use_nodbg_operands(Reg)) {
+unsigned SubRegIdx = MO.getSubReg();
+if (SubRegIdx == 0 || MO.isUndef())
+  continue;
+
+LaneBitmask SubRegMask = TRI->getSubRegIndexLaneMask(SubRegIdx);
+SlotIndex Pos = LIS->getInstructionIndex(*MO.getParent());
+for (LiveInterval::SubRange &S : LI.subranges()) {
+  if (!S.liveAt(Pos) && (PrunedLanes & SubRegMask).any()) {
+MO.setIsUndef();
+break;
+  }
+}
+  }
+
+  LI.removeEmptySubRanges();
+
+  // A def of a subregister may be a use of other register lanes. Replacing
+  // such a def with a def of a 
diff erent register will eliminate the use,
+  // and may cause the recorded live range to be larger than the actual
+  // liveness in the program IR.
+  LIS->shrinkToUses(&LI);
+}
+
 bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
   Again = false;
   LLVM_DEBUG(dbgs() << LIS->getInstructionIndex(*CopyMI) << '\t' << *CopyMI);
@@ -1868,16 +1923,35 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, 
bool &Again) {
   VNInfo *ReadVNI = LRQ.valueIn();
   assert(ReadVNI && "No value before copy and no  flag.");
   assert(ReadVNI != DefVNI && "Cannot read and define the same value.");
-  LI.MergeValueNumberInto(DefVNI, ReadVNI);
+
+  // Track incoming undef lanes we need to eliminate from the subrange.
+ 

[llvm-branch-commits] [clang] c4736b9 - Don't memcpy from an empty ArrayRef; the base pointer could be null, and

2020-12-15 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-15T14:37:52-08:00
New Revision: c4736b91f87e9163edcdef78891398f32390ffc2

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

LOG: Don't memcpy from an empty ArrayRef; the base pointer could be null, and
the C rules say memcpy can't accept a null pointer.

This should fix a test failure with the ubsan buildbots.

Added: 


Modified: 
clang/lib/AST/APValue.cpp

Removed: 




diff  --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 5b340e6e85bd..c18f8854dc2b 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -952,8 +952,10 @@ void APValue::setLValue(LValueBase B, const CharUnits &O,
 bool IsNullPtr) {
   MutableArrayRef InternalPath =
   setLValueUninit(B, O, Path.size(), IsOnePastTheEnd, IsNullPtr);
-  memcpy(InternalPath.data(), Path.data(),
- Path.size() * sizeof(LValuePathEntry));
+  if (Path.size()) {
+memcpy(InternalPath.data(), Path.data(),
+   Path.size() * sizeof(LValuePathEntry));
+  }
 }
 
 void APValue::setUnion(const FieldDecl *Field, const APValue &Value) {



___
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] 20d0cbd - [mlir] Tighten type verifiers for LLVM dialect ops results

2020-12-15 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-12-15T23:50:02+01:00
New Revision: 20d0cbd3fadf5a6e78373ab5c9d35e9e5d49f172

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

LOG: [mlir] Tighten type verifiers for LLVM dialect ops results

Now that we have predicates for LLVM dialect types in ODS, we can use them to
restrict the types allowed in results of LLVM dialect operations. This also
serves as additional documentation for these operations.

Reviewed By: rriddle

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

Added: 


Modified: 
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/test/Dialect/LLVMIR/invalid.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 807ea8826ef8..da25c0d3f92d 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -94,9 +94,8 @@ class LLVM_ArithmeticOpBase {
   let arguments = (ins LLVM_ScalarOrVectorOf:$lhs,
LLVM_ScalarOrVectorOf:$rhs);
-  let parser =
-  [{ return impl::parseOneResultSameOperandTypeOp(parser, result); }];
-  let printer = [{ mlir::impl::printOneResultOp(this->getOperation(), p); }];
+  let results = (outs LLVM_ScalarOrVectorOf:$res);
+  let assemblyFormat = "$lhs `,` $rhs attr-dict `:` type($res)";
 }
 class LLVM_IntArithmeticOp traits = []> :
@@ -112,9 +111,8 @@ class LLVM_UnaryArithmeticOp,
 LLVM_Builder<"$res = builder." # builderFunc # "($operand);"> {
   let arguments = (ins type:$operand);
-  let parser =
-  [{ return impl::parseOneResultSameOperandTypeOp(parser, result); }];
-  let printer = [{ mlir::impl::printOneResultOp(this->getOperation(), p); }];
+  let results = (outs type:$res);
+  let assemblyFormat = "$operand attr-dict `:` type($res)";
 }
 
 // Integer binary operations.
@@ -157,6 +155,7 @@ def LLVM_ICmpOp : LLVM_OneResultOp<"icmp", [NoSideEffect]> {
   let arguments = (ins ICmpPredicate:$predicate,
LLVM_ScalarOrVectorOf:$lhs,
LLVM_ScalarOrVectorOf:$rhs);
+  let results = (outs LLVM_ScalarOrVectorOf:$res);
   let llvmBuilder = [{
 $res = builder.CreateICmp(getLLVMCmpPredicate($predicate), $lhs, $rhs);
   }];
@@ -204,6 +203,7 @@ def LLVM_FCmpOp : LLVM_OneResultOp<"fcmp", [NoSideEffect]> {
   let arguments = (ins FCmpPredicate:$predicate,
LLVM_ScalarOrVectorOf:$lhs,
LLVM_ScalarOrVectorOf:$rhs);
+  let results = (outs LLVM_ScalarOrVectorOf:$res);
   let llvmBuilder = [{
 $res = builder.CreateFCmp(getLLVMCmpPredicate($predicate), $lhs, $rhs);
   }];
@@ -257,6 +257,7 @@ def LLVM_AllocaOp :
 LLVM_OneResultOp<"alloca"> {
   let arguments = (ins LLVM_AnyInteger:$arraySize,
OptionalAttr:$alignment);
+  let results = (outs LLVM_AnyPointer:$res);
   string llvmBuilder = [{
 auto *inst = builder.CreateAlloca(
   $_resultType->getPointerElementType(), $arraySize);
@@ -280,6 +281,7 @@ def LLVM_GEPOp : LLVM_OneResultOp<"getelementptr", 
[NoSideEffect]>,
  LLVM_Builder<"$res = builder.CreateGEP($base, $indices);"> {
   let arguments = (ins LLVM_ScalarOrVectorOf:$base,
Variadic>:$indices);
+  let results = (outs LLVM_ScalarOrVectorOf:$res);
   let assemblyFormat = [{
 $base `[` $indices `]` attr-dict `:` functional-type(operands, results)
   }];
@@ -291,6 +293,7 @@ def LLVM_LoadOp :
   let arguments = (ins LLVM_PointerTo:$addr,
OptionalAttr:$alignment, UnitAttr:$volatile_,
UnitAttr:$nontemporal);
+  let results = (outs LLVM_Type:$res);
   string llvmBuilder = [{
 auto *inst = builder.CreateLoad($addr, $volatile_);
   }] # setAlignmentCode # setNonTemporalMetadataCode # [{
@@ -330,52 +333,64 @@ def LLVM_StoreOp :
 
 // Casts.
 class LLVM_CastOp traits = []> :
+  Type resultType, list traits = []> :
 LLVM_OneResultOp,
 LLVM_Builder<"$res = builder." # builderFunc # "($arg, $_resultType);"> {
   let arguments = (ins type:$arg);
+  let results = (outs resultType:$res);
   let parser = [{ return mlir::impl::parseCastOp(parser, result); }];
   let printer = [{ mlir::impl::printCastOp(this->getOperation(), p); }];
 }
 def LLVM_BitcastOp : LLVM_CastOp<"bitcast", "CreateBitCast",
- LLVM_AnyNonAggregate>;
+ LLVM_AnyNonAggregate, LLVM_AnyNonAggregate>;
 def LLVM_AddrSpaceCastOp : LLVM_CastOp<"addrspacecast", "CreateAddrSpaceCast",
+   LLVM_ScalarOrVectorOf,
LLVM_ScalarOrVectorOf>;
 def LLVM_IntToPtrOp : LLVM_CastOp<"inttoptr", "CreateIntToPtr",
- 

[llvm-branch-commits] [mlir] 02220f3 - [mlir] NFC: retire LLVM_Zero/OneResultOp from LLVM dialect ODS

2020-12-15 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-12-15T23:50:03+01:00
New Revision: 02220f3204980496c8877abb51ba1fd87a108541

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

LOG: [mlir] NFC: retire LLVM_Zero/OneResultOp from LLVM dialect ODS

These classes were initially introduced to factor out two common parts of LLVM
op definitions: the fact that they have no results or a single result of
LLVM_Type, and the default builders. Neither of the two parts is really
common anymore: many ops have more specific on the result type, and many ops
provide custom builders. The TableGen classes only add conceptual complexity
and make LLVM dialect definition dissimilar to other dialects. Remove them in
favor of explicitly specified builders (results are already specified).

Depends On D93329

Reviewed By: rriddle

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

Added: 


Modified: 
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Removed: 




diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index da25c0d3f92d..59ea92d88330 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -43,16 +43,6 @@ def LLVM_ZeroResultOpBuilder :
 }
   }]>;
 
-class LLVM_TwoBuilders {
-  list builders = [b1, b2];
-}
-
-// Base class for LLVM operations with one result.
-class LLVM_OneResultOp traits = []> :
-LLVM_Op, Results<(outs LLVM_Type:$res)> {
-  let builders = [LLVM_OneResultOpBuilder];
-}
-
 // Compatibility builder that takes an instance of wrapped llvm::VoidType
 // to indicate no result.
 def LLVM_VoidResultTypeOpBuilder :
@@ -66,10 +56,6 @@ def LLVM_VoidResultTypeOpBuilder :
 build($_builder, $_state, operands, attributes);
   }]>;
 
-// Base class for LLVM operations with zero results.
-class LLVM_ZeroResultOp traits = []> :
-LLVM_Op, Results<(outs)>,
-LLVM_TwoBuilders;
 
 // Opaque builder used for terminator operations that contain successors.
 def LLVM_TerminatorPassthroughOpBuilder :
@@ -89,12 +75,13 @@ class LLVM_TerminatorOp 
traits = []> :
 // Class for arithmetic binary operations.
 class LLVM_ArithmeticOpBase traits = []> :
-LLVM_OneResultOp,
 LLVM_Builder<"$res = builder." # builderFunc # "($lhs, $rhs);"> {
   let arguments = (ins LLVM_ScalarOrVectorOf:$lhs,
LLVM_ScalarOrVectorOf:$rhs);
   let results = (outs LLVM_ScalarOrVectorOf:$res);
+  let builders = [LLVM_OneResultOpBuilder];
   let assemblyFormat = "$lhs `,` $rhs attr-dict `:` type($res)";
 }
 class LLVM_IntArithmeticOp traits = []> :
-LLVM_OneResultOp,
 LLVM_Builder<"$res = builder." # builderFunc # "($operand);"> {
   let arguments = (ins type:$operand);
   let results = (outs type:$res);
+  let builders = [LLVM_OneResultOpBuilder];
   let assemblyFormat = "$operand attr-dict `:` type($res)";
 }
 
@@ -151,7 +139,7 @@ def ICmpPredicate : I64EnumAttr<
 }
 
 // Other integer operations.
-def LLVM_ICmpOp : LLVM_OneResultOp<"icmp", [NoSideEffect]> {
+def LLVM_ICmpOp : LLVM_Op<"icmp", [NoSideEffect]> {
   let arguments = (ins ICmpPredicate:$predicate,
LLVM_ScalarOrVectorOf:$lhs,
LLVM_ScalarOrVectorOf:$rhs);
@@ -199,7 +187,7 @@ def FCmpPredicate : I64EnumAttr<
 }
 
 // Other integer operations.
-def LLVM_FCmpOp : LLVM_OneResultOp<"fcmp", [NoSideEffect]> {
+def LLVM_FCmpOp : LLVM_Op<"fcmp", [NoSideEffect]> {
   let arguments = (ins FCmpPredicate:$predicate,
LLVM_ScalarOrVectorOf:$lhs,
LLVM_ScalarOrVectorOf:$rhs);
@@ -252,9 +240,7 @@ class MemoryOpWithAlignmentAndAttributes : 
MemoryOpWithAlignmentBase {
 }
 
 // Memory-related operations.
-def LLVM_AllocaOp :
-MemoryOpWithAlignmentBase,
-LLVM_OneResultOp<"alloca"> {
+def LLVM_AllocaOp : LLVM_Op<"alloca">, MemoryOpWithAlignmentBase {
   let arguments = (ins LLVM_AnyInteger:$arraySize,
OptionalAttr:$alignment);
   let results = (outs LLVM_AnyPointer:$res);
@@ -277,19 +263,18 @@ def LLVM_AllocaOp :
   let printer = [{ printAllocaOp(p, *this); }];
 }
 
-def LLVM_GEPOp : LLVM_OneResultOp<"getelementptr", [NoSideEffect]>,
+def LLVM_GEPOp : LLVM_Op<"getelementptr", [NoSideEffect]>,
  LLVM_Builder<"$res = builder.CreateGEP($base, $indices);"> {
   let arguments = (ins LLVM_ScalarOrVectorOf:$base,
Variadic>:$indices);
   let results = (outs LLVM_ScalarOrVectorOf:$res);
+  let builders = [LLVM_OneResultOpBuilder];
   let assemblyFormat = [{
 $base `[` $indices `]` attr-dict `:` functional-type(operands, results)
   }];
 }
 
-def LLVM_LoadOp :
-MemoryOpWithAlignmentAndAttributes,
-LLVM_OneResultOp<"load"> {
+def LLVM_LoadOp : LLVM_Op<"load">, MemoryOpWithAlignmentAndAttributes {
   let arguments

[llvm-branch-commits] [llvm] d08d490 - [OpenMPOpt][NFC] Clang format

2020-12-15 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-12-15T16:51:34-06:00
New Revision: d08d490a4cb93d05d728b6661f8c34d0064a53c6

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

LOG: [OpenMPOpt][NFC] Clang format

Added: 


Modified: 
llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp 
b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index f1c953afca25..2433b1f0c375 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -55,7 +55,6 @@ static cl::opt HideMemoryTransferLatency(
  " transfers"),
 cl::Hidden, cl::init(false));
 
-
 STATISTIC(NumOpenMPRuntimeCallsDeduplicated,
   "Number of OpenMP runtime calls deduplicated");
 STATISTIC(NumOpenMPParallelRegionsDeleted,
@@ -426,8 +425,7 @@ struct OffloadArray {
   /// instruction \p Before is reached.
   bool getValues(AllocaInst &Array, Instruction &Before) {
 // Initialize container.
-const uint64_t NumValues =
-Array.getAllocatedType()->getArrayNumElements();
+const uint64_t NumValues = Array.getAllocatedType()->getArrayNumElements();
 StoredValues.assign(NumValues, nullptr);
 LastAccesses.assign(NumValues, nullptr);
 
@@ -449,8 +447,8 @@ struct OffloadArray {
 
   auto *S = cast(&I);
   int64_t Offset = -1;
-  auto *Dst = GetPointerBaseWithConstantOffset(S->getPointerOperand(),
-   Offset, DL);
+  auto *Dst =
+  GetPointerBaseWithConstantOffset(S->getPointerOperand(), Offset, DL);
   if (Dst == &Array) {
 int64_t Idx = Offset / PointerSize;
 StoredValues[Idx] = getUnderlyingObject(S->getValueOperand());



___
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] b9c7754 - [Clang][Attr] Introduce the `assume` function attribute

2020-12-15 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-12-15T16:51:34-06:00
New Revision: b9c77542e23756967e77dc42412effc41257a850

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

LOG: [Clang][Attr] Introduce the `assume` function attribute

The `assume` attribute is a way to provide additional, arbitrary
information to the optimizer. For now, assumptions are restricted to
strings which will be accumulated for a function and emitted as comma
separated string function attribute. The key of the LLVM-IR function
attribute is `llvm.assume`. Similar to `llvm.assume` and
`__builtin_assume`, the `assume` attribute provides a user defined
assumption to the compiler.

A follow up patch will introduce an LLVM-core API to query the
assumptions attached to a function. We also expect to add more options,
e.g., expression arguments, to the `assume` attribute later on.

The `omp [begin] asssumes` pragma will leverage this attribute and
expose the functionality in the absence of OpenMP.

Reviewed By: aaron.ballman

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

Added: 
clang/test/CodeGen/assume_attr.c
clang/test/CodeGenCXX/assume_attr.cpp
clang/test/Sema/attr-assume.c
llvm/include/llvm/IR/Assumptions.h
llvm/lib/IR/Assumptions.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/CMakeLists.txt
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
llvm/lib/IR/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c50be9e429ae..6280c486ccbb 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1740,6 +1740,8 @@ implemented directly in terms of :ref:`extended vector 
support
 ` instead of builtins, in order to reduce the number of
 builtins that we need to implement.
 
+.. _langext-__builtin_assume:
+
 ``__builtin_assume``
 --
 

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 61eb86ac81a1..7d566e64c99b 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3527,6 +3527,14 @@ def OMPDeclareVariant : InheritableAttr {
   }];
 }
 
+def Assumption : InheritableAttr {
+  let Spellings = [Clang<"assume">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let InheritEvenIfAlreadyPresent = 1;
+  let Documentation = [AssumptionDocs];
+  let Args = [StringArgument<"Assumption">];
+}
+
 def InternalLinkage : InheritableAttr {
   let Spellings = [Clang<"internal_linkage">];
   let Subjects = SubjectList<[Var, Function, CXXRecord]>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index e70596b5ac28..a65964e94bf1 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3992,6 +3992,41 @@ For more information see
 }];
 }
 
+def AssumptionDocs : Documentation {
+  let Category = DocCatFunction;
+  let Heading = "assume";
+  let Content = [{
+Clang supports the ``__attribute__((assume("assumption")))`` attribute to
+provide additional information to the optimizer. The string-literal, here
+"assumption", will be attached to the function declaration such that later
+analysis and optimization passes can assume the "assumption" to hold.
+This is similar to :ref:`__builtin_assume ` but
+instead of an expression that can be assumed to be non-zero, the assumption is
+expressed as a string and it holds for the entire function.
+
+A function can have multiple assume attributes and they propagate from prior
+declarations to later definitions. Multiple assumptions are aggregated into a
+single comma separated string. Thus, one can provide multiple assumptions via
+a comma separated string, i.a.,
+``__attribute__((assume("assumption1,assumption2")))``.
+
+While LLVM plugins might provide more assumption strings, the default LLVM
+optimization passes are aware of the following assumptions:
+
+  .. code-block:: none
+
+"omp_no_openmp"
+"omp_no_openmp_routines"
+"omp_no_parallelism"
+
+The OpenMP standard defines the meaning of OpenMP assumptions ("omp_XYZ" is
+spelled "XYZ" in the `OpenMP 5.1 Standard`_).
+
+.. _`OpenMP 5.1 Standard`: 
https://www.openmp.org/spec-html/5.1/openmpsu37.html#x56-560002.5.2
+
+}];
+}
+
 def NoStackProtectorDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/cla

[llvm-branch-commits] [llvm] dcaec81 - [OpenMP] Use assumptions during ICV tracking

2020-12-15 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-12-15T16:51:34-06:00
New Revision: dcaec81211be973364cf7830a3db63781e15a474

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

LOG: [OpenMP] Use assumptions during ICV tracking

The OpenMP 5.1 assumptions `no_openmp` and `no_openmp_routines` allow us
to ignore calls that would otherwise prevent ICV tracking.

Once we track more ICVs we might need to distinguish the ones that could
be impacted even with `no_openmp_routines`.

Reviewed By: sstefan1

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

Added: 


Modified: 
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/icv_tracking.ll

Removed: 




diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp 
b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 2433b1f0c375..6053412bae84 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1768,7 +1768,8 @@ struct AAICVTrackerFunction : public AAICVTracker {
 InternalControlVar &ICV) const {
 
 const auto *CB = dyn_cast(I);
-if (!CB)
+if (!CB || CB->hasFnAttr("no_openmp") ||
+CB->hasFnAttr("no_openmp_routines"))
   return None;
 
 auto &OMPInfoCache = static_cast(A.getInfoCache());

diff  --git a/llvm/test/Transforms/OpenMP/icv_tracking.ll 
b/llvm/test/Transforms/OpenMP/icv_tracking.ll
index 560ad2fbcd3d..6cfad365ecbd 100644
--- a/llvm/test/Transforms/OpenMP/icv_tracking.ll
+++ b/llvm/test/Transforms/OpenMP/icv_tracking.ll
@@ -30,6 +30,22 @@ define i32 @bad_use(i32 %0) {
   ret i32 %2
 }
 
+define i32 @ok_use_assume(i32 %0) {
+; CHECK-LABEL: define {{[^@]+}}@ok_use_assume
+; CHECK-SAME: (i32 [[TMP0:%.*]]) {
+; CHECK-NEXT:call void @use(i32 [[TMP0]]) [[ATTR1:#.*]]
+; CHECK-NEXT:call void @use(i32 [[TMP0]]) [[ATTR2:#.*]]
+; CHECK-NEXT:call void @no_openmp_use(i32 [[TMP0]])
+; CHECK-NEXT:[[TMP2:%.*]] = add nsw i32 [[TMP0]], 1
+; CHECK-NEXT:ret i32 [[TMP2]]
+;
+  call void @use(i32 %0) "no_openmp"
+  call void @use(i32 %0) "no_openmp_routines"
+  call void @no_openmp_use(i32 %0)
+  %2 = add nsw i32 %0, 1
+  ret i32 %2
+}
+
 define void @indirect_call(void ()* %0) {
 ; CHECK-LABEL: define {{[^@]+}}@indirect_call
 ; CHECK-SAME: (void ()* [[TMP0:%.*]])
@@ -77,6 +93,7 @@ declare dso_local void @omp_set_num_threads(i32)
 declare dso_local i32 @omp_get_max_threads()
 
 declare dso_local void @use(i32)
+declare dso_local void @no_openmp_use(i32) "no_openmp"
 
 define internal void @.omp_outlined.(i32* %0, i32* %1) {
 ; CHECK-LABEL: define {{[^@]+}}@.omp_outlined.
@@ -266,6 +283,33 @@ define void @bad_use_test(i1 %0) {
   ret void
 }
 
+define void @ok_use_assume_test(i1 %0) {
+; CHECK-LABEL: define {{[^@]+}}@ok_use_assume_test
+; CHECK-SAME: (i1 [[TMP0:%.*]]) {
+; CHECK-NEXT:call void @omp_set_num_threads(i32 2)
+; CHECK-NEXT:[[TMP2:%.*]] = icmp eq i1 [[TMP0]], false
+; CHECK-NEXT:br i1 [[TMP2]], label [[TMP5:%.*]], label [[TMP3:%.*]]
+; CHECK:   3:
+; CHECK-NEXT:[[TMP4:%.*]] = call i32 @ok_use_assume(i32 10)
+; CHECK-NEXT:br label [[TMP5]]
+; CHECK:   5:
+; CHECK-NEXT:call void @use(i32 2)
+; CHECK-NEXT:ret void
+;
+  call void @omp_set_num_threads(i32 2)
+  %2 = icmp eq i1 %0, 0
+  br i1 %2, label %5, label %3
+
+3:; preds = %1
+  %4 = call i32 @ok_use_assume(i32 10)
+  br label %5
+
+5:; preds = %3, %1
+  %6 = call i32 @omp_get_max_threads()
+  call void @use(i32 %6)
+  ret void
+}
+
 define weak void @weak_known_unique_icv(i1 %0) {
 ; CHECK-LABEL: define {{[^@]+}}@weak_known_unique_icv
 ; CHECK-SAME: (i1 [[TMP0:%.*]])



___
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] a5a14cb - [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-12-15 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-12-15T16:51:34-06:00
New Revision: a5a14cbe7f87e01882ecaa14df5d596cbf38823a

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

LOG: [OpenMP] Add initial support for `omp [begin/end] assumes`

The `assumes` directive is an OpenMP 5.1 feature that allows the user to
provide assumptions to the optimizer. Assumptions can refer to
directives (`absent` and `contains` clauses), expressions (`holds`
clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...).

The `assumes` spelling is used for assumptions in the global scope while
`assume` is used for executable contexts with an associated structured
block.

This patch only implements the global spellings. While clauses with
arguments are "accepted" by the parser, they will simply be ignored for
now. The implementation lowers the assumptions directly to the
`AssumptionAttr`.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/assumes_codegen.cpp
clang/test/OpenMP/assumes_include_nvptx.cpp
clang/test/OpenMP/assumes_messages.c
clang/test/OpenMP/assumes_print.cpp
clang/test/OpenMP/assumes_template_print.cpp

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaOpenMP.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c0a5a2b4c144..8f78bbfc4e70 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1291,6 +1291,16 @@ def err_expected_end_declare_target_or_variant : Error<
 def err_expected_begin_declare_variant
 : Error<"'#pragma omp end declare variant' with no matching '#pragma omp "
 "begin declare variant'">;
+def err_expected_begin_assumes
+: Error<"'#pragma omp end assumes' with no matching '#pragma omp begin 
assumes'">;
+def warn_omp_unknown_assumption_clause_missing_id
+: Warning<"valid %0 clauses start with %1; %select{token|tokens}2 will be 
ignored">,
+  InGroup;
+def warn_omp_unknown_assumption_clause_without_args
+: Warning<"%0 clause should not be followed by arguments; tokens will be 
ignored">,
+  InGroup;
+def note_omp_assumption_clause_continue_here
+: Note<"the ignored tokens spans until here">;
 def err_omp_declare_target_unexpected_clause: Error<
   "unexpected '%0' clause, only %select{'to' or 'link'|'to', 'link' or 
'device_type'}1 clauses expected">;
 def err_omp_expected_clause: Error<

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 73943ed5f0a6..02aab3b43be0 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3104,6 +3104,13 @@ class Parser : public CodeCompletionHandler {
   void ParseOMPDeclareVariantClauses(DeclGroupPtrTy Ptr, CachedTokens &Toks,
  SourceLocation Loc);
 
+  /// Parse 'omp [begin] assume[s]' directive.
+  void ParseOpenMPAssumesDirective(OpenMPDirectiveKind DKind,
+   SourceLocation Loc);
+
+  /// Parse 'omp end assumes' directive.
+  void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
+
   /// Parse clauses for '#pragma omp declare target'.
   DeclGroupPtrTy ParseOMPDeclareTargetClauses();
   /// Parse '#pragma omp end declare target'.

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index eb6429912bf6..ff0257634d9d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10128,6 +10128,13 @@ class Sema final {
   /// The current `omp begin/end declare variant` scopes.
   SmallVector OMPDeclareVariantScopes;
 
+  /// The current `omp begin/end assumes` scopes.
+  SmallVector OMPAssumeScoped;
+
+  /// All `omp assumes` we encountered so far.
+  SmallVector OMPAssumeGlobal;
+
+public:
   /// The declarator \p D defines a function in the scope \p S which is nested
   /// in an `omp begin/end declare variant` scope. In this method we create a
   /// declaration for \p D and rename \p D according to the OpenMP context
@@ -10141,10 +10148,11 @@ class Sema final {
   void ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope(
   Decl *D, SmallVectorImpl &Bases);
 
-public:
+  /// Act on \p D, a function definition inside of an `omp [begin/end] 
assumes`.
+  void ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(D

[llvm-branch-commits] [llvm] 41c3b27 - [IR] Delete deprecated DebugLoc::get

2020-12-15 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-15T14:53:12-08:00
New Revision: 41c3b271399229976d9885233db79ebbbe0383c6

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

LOG: [IR] Delete deprecated DebugLoc::get

Added: 


Modified: 
llvm/include/llvm/IR/DebugLoc.h
llvm/lib/IR/DebugLoc.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/DebugLoc.h b/llvm/include/llvm/IR/DebugLoc.h
index 4914d733fe0d..36b5c12f4ba7 100644
--- a/llvm/include/llvm/IR/DebugLoc.h
+++ b/llvm/include/llvm/IR/DebugLoc.h
@@ -68,18 +68,6 @@ namespace llvm {
 /// Check whether this has a trivial destructor.
 bool hasTrivialDestructor() const { return Loc.hasTrivialDestructor(); }
 
-/// Create a new DebugLoc.
-///
-/// Create a new DebugLoc at the specified line/col and scope/inline.  This
-/// forwards to \a DILocation::get().
-///
-/// If \c !Scope, returns a default-constructed \a DebugLoc.
-///
-/// FIXME: Remove this.  Users should use DILocation::get().
-static DebugLoc get(unsigned Line, unsigned Col, const MDNode *Scope,
-const MDNode *InlinedAt = nullptr,
-bool ImplicitCode = false);
-
 enum { ReplaceLastInlinedAt = true };
 /// Rebuild the entire inlined-at chain for this instruction so that the 
top of
 /// the chain now is inlined-at the new call site.

diff  --git a/llvm/lib/IR/DebugLoc.cpp b/llvm/lib/IR/DebugLoc.cpp
index 88f57111ff76..1aba5bf664c4 100644
--- a/llvm/lib/IR/DebugLoc.cpp
+++ b/llvm/lib/IR/DebugLoc.cpp
@@ -68,17 +68,6 @@ void DebugLoc::setImplicitCode(bool ImplicitCode) {
   }
 }
 
-DebugLoc DebugLoc::get(unsigned Line, unsigned Col, const MDNode *Scope,
-   const MDNode *InlinedAt, bool ImplicitCode) {
-  // If no scope is available, this is an unknown location.
-  if (!Scope)
-return DebugLoc();
-
-  return DILocation::get(Scope->getContext(), Line, Col,
- const_cast(Scope),
- const_cast(InlinedAt), ImplicitCode);
-}
-
 DebugLoc DebugLoc::appendInlinedAt(const DebugLoc &DL, DILocation *InlinedAt,
LLVMContext &Ctx,
DenseMap &Cache,



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


  1   2   >