[llvm-branch-commits] [llvm] 31eeac9 - [llvm-readelf/obj] - Move unique warning handling logic to the `ObjDumper`.

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

Author: Georgii Rymar
Date: 2020-12-01T10:53:00+03:00
New Revision: 31eeac915a0a25c2690b956931c77684bc34da0b

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

LOG: [llvm-readelf/obj] - Move unique warning handling logic to the `ObjDumper`.

This moves the `reportUniqueWarning` method to the base class.

My motivation is the following:
I've experimented with replacing `reportWarning` calls with 
`reportUniqueWarning`
in ELF dumper. I've found that for example for removing them from 
`DynRegionInfo` helper
class, it is worth to pass a dumper instance to it (to be able to call 
dumper()->reportUniqueWarning()).
The problem was that `ELFDumper` is a template class. I had to make 
`DynRegionInfo` to be templated
and do lots of minor changes everywhere what did not look reasonable/nice.

At the same time I guess one day other dumpers like COFF/MachO/Wasm etc might 
want to
start using `reportUniqueWarning` API too. Then it looks reasonable to move the 
logic to the
base class.

With that the problem of passing the dumper instance will be gone.

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

Added: 


Modified: 
llvm/tools/llvm-readobj/COFFDumper.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/tools/llvm-readobj/MachODumper.cpp
llvm/tools/llvm-readobj/ObjDumper.cpp
llvm/tools/llvm-readobj/ObjDumper.h
llvm/tools/llvm-readobj/WasmDumper.cpp
llvm/tools/llvm-readobj/XCOFFDumper.cpp

Removed: 




diff  --git a/llvm/tools/llvm-readobj/COFFDumper.cpp 
b/llvm/tools/llvm-readobj/COFFDumper.cpp
index b1ac1d9d0f39..144ecf56d50a 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -77,7 +77,8 @@ class COFFDumper : public ObjDumper {
 public:
   friend class COFFObjectDumpDelegate;
   COFFDumper(const llvm::object::COFFObjectFile *Obj, ScopedPrinter &Writer)
-  : ObjDumper(Writer), Obj(Obj), Writer(Writer), Types(100) {}
+  : ObjDumper(Writer, Obj->getFileName()), Obj(Obj), Writer(Writer),
+Types(100) {}
 
   void printFileHeaders() override;
   void printSectionHeaders() override;

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 890bb2a21e82..f89d88724a9a 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -64,7 +64,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 using namespace llvm;
@@ -355,8 +354,6 @@ template  class ELFDumper : public ObjDumper 
{
   };
   mutable SmallVector, 16> VersionMap;
 
-  std::unordered_set Warnings;
-
   std::string describe(const Elf_Shdr &Sec) const;
 
 public:
@@ -435,9 +432,6 @@ template  class ELFDumper : public ObjDumper 
{
 
   Expected> getRelocationTarget(const Relocation &R,
 const Elf_Shdr *SymTab) const;
-
-  std::function WarningHandler;
-  void reportUniqueWarning(Error Err) const;
 };
 
 template 
@@ -956,14 +950,6 @@ template  class GNUStyle : public 
DumpStyle {
 const Twine &Label, unsigned EntriesNum);
 };
 
-template 
-void ELFDumper::reportUniqueWarning(Error Err) const {
-  handleAllErrors(std::move(Err), [&](const ErrorInfoBase &EI) {
-cantFail(WarningHandler(EI.message()),
- "WarningHandler should always return ErrorSuccess");
-  });
-}
-
 template 
 void DumpStyle::reportUniqueWarning(Error Err) const {
   this->dumper().reportUniqueWarning(std::move(Err));
@@ -2020,16 +2006,9 @@ void ELFDumper::loadDynamicTable() {
 template 
 ELFDumper::ELFDumper(const object::ELFObjectFile &O,
ScopedPrinter &Writer)
-: ObjDumper(Writer), ObjF(O), Obj(*O.getELFFile()), DynRelRegion(O),
-  DynRelaRegion(O), DynRelrRegion(O), DynPLTRelRegion(O), DynamicTable(O) {
-  // Dumper reports all non-critical errors as warnings.
-  // It does not print the same warning more than once.
-  WarningHandler = [this](const Twine &Msg) {
-if (Warnings.insert(Msg.str()).second)
-  reportWarning(createError(Msg), ObjF.getFileName());
-return Error::success();
-  };
-
+: ObjDumper(Writer, O.getFileName()), ObjF(O), Obj(*O.getELFFile()),
+  DynRelRegion(O), DynRelaRegion(O), DynRelrRegion(O), DynPLTRelRegion(O),
+  DynamicTable(O) {
   if (opts::Output == opts::GNU)
 ELFDumperStyle.reset(new GNUStyle(Writer, *this));
   else

diff  --git a/llvm/tools/llvm-readobj/MachODumper.cpp 
b/llvm/tools/llvm-readobj/MachODumper.cpp
index 5c4960804e8f..c13b1f3bf2a0 100644
--- a/llvm/tools/llvm-readobj/MachODumper.cpp
+++ b/llvm/tools/llvm-readobj/MachODumper.cpp
@@ -27,7 +27,7 @@ namespace {
 class MachODumper : public ObjDumper {
 public:
   MachODumper(const MachOObjectFile *Obj, ScopedPrinter &Writer)
-  : ObjDumper(W

[llvm-branch-commits] [compiler-rt] 2e5aaf6 - [compiler-rt] [emutls] Handle unused parameters in a compiler agnostic way

2020-12-01 Thread Martin Storsjö via llvm-branch-commits

Author: Martin Storsjö
Date: 2020-12-01T10:07:53+02:00
New Revision: 2e5aaf65a344ae804343bfed6326ef33f61586b0

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

LOG: [compiler-rt] [emutls] Handle unused parameters in a compiler agnostic way

The MSVC specific pragmas disable this warning, but the pragmas themselves
(when not guarded by any _MSC_VER ifdef) cause warnings for other targets,
e.g. when targeting mingw.

Instead silence the MSVC warnings about unused parameters by casting
the parameters to void.

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

Added: 


Modified: 
compiler-rt/lib/builtins/emutls.c

Removed: 




diff  --git a/compiler-rt/lib/builtins/emutls.c 
b/compiler-rt/lib/builtins/emutls.c
index e0aa19155f7d..98cabd917d6c 100644
--- a/compiler-rt/lib/builtins/emutls.c
+++ b/compiler-rt/lib/builtins/emutls.c
@@ -182,9 +182,10 @@ static void emutls_exit(void) {
   }
 }
 
-#pragma warning(push)
-#pragma warning(disable : 4100)
 static BOOL CALLBACK emutls_init(PINIT_ONCE p0, PVOID p1, PVOID *p2) {
+  (void)p0;
+  (void)p1;
+  (void)p2;
   emutls_mutex =
   (LPCRITICAL_SECTION)_aligned_malloc(sizeof(CRITICAL_SECTION), 16);
   if (!emutls_mutex) {
@@ -251,8 +252,6 @@ static __inline void __atomic_store_n(void *ptr, uintptr_t 
val, unsigned type) {
 
 #endif // __ATOMIC_RELEASE
 
-#pragma warning(pop)
-
 #endif // _WIN32
 
 static size_t emutls_num_object = 0; // number of allocated TLS objects



___
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] 8748106 - [llvm-readelf] - Switch to using from `reportWarning` to `reportUniqueWarning` in `DynRegionInfo`.

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

Author: Georgii Rymar
Date: 2020-12-01T11:09:30+03:00
New Revision: 87481068fddf29e913b129b9c962ba761ae478c8

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

LOG: [llvm-readelf] - Switch to using from `reportWarning` to 
`reportUniqueWarning` in `DynRegionInfo`.

This is a part of the plan we had previously to convert all calls to
`reportUniqueWarning` and then rename it to just `reportWarning`.

I was a bit unsure about this particular change at first, because it doesn't 
add a
new functionality: seems it is impossible to trigger a warning duplication 
currently.

At the same time I find the idea of the plan mentioned very reasonable.
And with that we will be sure that `DynRegionInfo` can't report duplicate
warnings, what looks like a nice feature for possible refactorings and further 
tool development.

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

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 f89d88724a9a..d4f716ac97ad 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -125,9 +125,11 @@ template  struct RelSymbol {
 /// the size, entity size and virtual address are 
diff erent entries in arbitrary
 /// order (DT_REL, DT_RELSZ, DT_RELENT for example).
 struct DynRegionInfo {
-  DynRegionInfo(const Binary &Owner) : Obj(&Owner) {}
-  DynRegionInfo(const Binary &Owner, const uint8_t *A, uint64_t S, uint64_t ES)
-  : Addr(A), Size(S), EntSize(ES), Obj(&Owner) {}
+  DynRegionInfo(const Binary &Owner, const ObjDumper &D)
+  : Obj(&Owner), Dumper(&D) {}
+  DynRegionInfo(const Binary &Owner, const ObjDumper &D, const uint8_t *A,
+uint64_t S, uint64_t ES)
+  : Addr(A), Size(S), EntSize(ES), Obj(&Owner), Dumper(&D) {}
 
   /// Address in current address space.
   const uint8_t *Addr = nullptr;
@@ -138,6 +140,8 @@ struct DynRegionInfo {
 
   /// Owner object. Used for error reporting.
   const Binary *Obj;
+  /// Dumper used for error reporting.
+  const ObjDumper *Dumper;
   /// Error prefix. Used for error reporting to provide more information.
   std::string Context;
   /// Region size name. Used for error reporting.
@@ -156,13 +160,11 @@ struct DynRegionInfo {
 const uint64_t ObjSize = Obj->getMemoryBufferRef().getBufferSize();
 
 if (Size > ObjSize - Offset) {
-  reportWarning(
-  createError("unable to read data at 0x" + Twine::utohexstr(Offset) +
-  " of size 0x" + Twine::utohexstr(Size) + " (" +
-  SizePrintName +
-  "): it goes past the end of the file of size 0x" +
-  Twine::utohexstr(ObjSize)),
-  Obj->getFileName());
+  Dumper->reportUniqueWarning(createError(
+  "unable to read data at 0x" + Twine::utohexstr(Offset) +
+  " of size 0x" + Twine::utohexstr(Size) + " (" + SizePrintName +
+  "): it goes past the end of the file of size 0x" +
+  Twine::utohexstr(ObjSize)));
   return {Start, Start};
 }
 
@@ -180,7 +182,7 @@ struct DynRegionInfo {
   (" or " + EntSizePrintName + " (0x" + Twine::utohexstr(EntSize) + 
")")
   .str();
 
-reportWarning(createError(Msg.c_str()), Obj->getFileName());
+Dumper->reportUniqueWarning(createError(Msg.c_str()));
 return {Start, Start};
   }
 };
@@ -311,7 +313,7 @@ template  class ELFDumper : public ObjDumper 
{
  ") + size (0x" + Twine::utohexstr(Size) +
  ") is greater than the file size (0x" +
  Twine::utohexstr(Obj.getBufSize()) + ")");
-return DynRegionInfo(ObjF, Obj.base() + Offset, Size, EntSize);
+return DynRegionInfo(ObjF, *this, Obj.base() + Offset, Size, EntSize);
   }
 
   void printAttributes();
@@ -1928,7 +1930,7 @@ void ELFDumper::loadDynamicTable() {
   if (!DynamicPhdr && !DynamicSec)
 return;
 
-  DynRegionInfo FromPhdr(ObjF);
+  DynRegionInfo FromPhdr(ObjF, *this);
   bool IsPhdrTableValid = false;
   if (DynamicPhdr) {
 // Use cantFail(), because p_offset/p_filesz fields of a PT_DYNAMIC are
@@ -1944,7 +1946,7 @@ void ELFDumper::loadDynamicTable() {
   // Ignore sh_entsize and use the expected value for entry size explicitly.
   // This allows us to dump dynamic sections with a broken sh_entsize
   // field.
-  DynRegionInfo FromSec(ObjF);
+  DynRegionInfo FromSec(ObjF, *this);
   bool IsSecTableValid = false;
   if (DynamicSec) {
 Expected RegOrErr =
@@ -2007,8 +2009,8 @@ template 
 ELFDumper::ELFDumper(const object::ELFObjectFile &O,
ScopedPrinter &Writer)
 : ObjDumper(Writer, O.getFileName()), ObjF(O), Obj(*O.ge

[llvm-branch-commits] [llvm] 424fdbc - collect_and_build_with_pgo.py: adapt to monorepo

2020-12-01 Thread Kristof Beyls via llvm-branch-commits

Author: Kristof Beyls
Date: 2020-12-01T09:16:12+01:00
New Revision: 424fdbc3dedadf882fda107aa5638b39e7036c4d

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

LOG: collect_and_build_with_pgo.py: adapt to monorepo

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

Added: 


Modified: 
llvm/utils/collect_and_build_with_pgo.py

Removed: 




diff  --git a/llvm/utils/collect_and_build_with_pgo.py 
b/llvm/utils/collect_and_build_with_pgo.py
index 5a8686a88b4f..e9f82617f4e9 100755
--- a/llvm/utils/collect_and_build_with_pgo.py
+++ b/llvm/utils/collect_and_build_with_pgo.py
@@ -146,9 +146,9 @@ def output_subdir(self, name):
 
 def has_llvm_subproject(self, name):
 if name == 'compiler-rt':
-subdir = 'projects/compiler-rt'
+subdir = '../compiler-rt'
 elif name == 'clang':
-subdir = 'tools/clang'
+subdir = '../clang'
 else:
 raise ValueError('Unknown subproject: %s' % name)
 
@@ -161,9 +161,8 @@ def run_command(self,
 cwd=None,
 check=False,
 silent_unless_error=False):
-cmd_str = ' '.join(shlex.quote(s) for s in cmd)
 print(
-'Running `%s` in %s' % (cmd_str, shlex.quote(cwd or os.getcwd(
+'Running `%s` in %s' % (cmd, shlex.quote(cwd or os.getcwd(
 
 if self.dry_run:
 return
@@ -372,7 +371,8 @@ def _parse_args():
 else:
 output_dir = os.path.abspath(args.out_dir)
 
-extra_args = {'CMAKE_BUILD_TYPE': 'Release'}
+extra_args = {'CMAKE_BUILD_TYPE': 'Release',
+  'LLVM_ENABLE_PROJECTS': 'clang;compiler-rt;lld'}
 for arg in args.cmake_extra_arg:
 if arg.startswith('-D'):
 arg = arg[2:]



___
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] 9738436 - [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)

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

Author: Jan Svoboda
Date: 2020-12-01T09:24:04+01:00
New Revision: 973843681b9df4ba9303e98f7b4531ba31c2b1bf

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

LOG: [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)

Reviewed By: Bigcheese, dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a2dec66692bb..35cd1a4f949e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4062,13 +4062,17 @@ std::string CompilerInvocation::getModuleHash() const {
 
 void CompilerInvocation::generateCC1CommandLine(
 SmallVectorImpl &Args, StringAllocator SA) const {
+  // Capture the extracted value as a lambda argument to avoid potential issues
+  // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
-  if (((FLAGS) & options::CC1Option) &&
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != (DEFAULT_VALUE))) {  
\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
+  if ((FLAGS)&options::CC1Option) {
\
+[&](const auto &Extracted) {   
\
+  if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE)) 
\
+DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);  
\
+}(EXTRACTOR(this->KEYPATH));   
\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
@@ -4076,10 +4080,10 @@ void CompilerInvocation::generateCC1CommandLine(
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  
\
 NEG_SPELLING)  
\
-  if (((FLAGS)&options::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,
\
- EXTRACTOR(this->KEYPATH));
\
+  if ((FLAGS)&options::CC1Option) {
\
+bool Extracted = EXTRACTOR(this->KEYPATH); 
\
+if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))   
\
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  
\
   }
 
 #include "clang/Driver/Options.inc"



___
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] 88ab384 - [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

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

Author: Jan Svoboda
Date: 2020-12-01T09:50:11+01:00
New Revision: 88ab38449b49bf002ed7794d1b81d362aa9f9df2

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

LOG: [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

This makes the options API composable, allows boolean flags to imply 
non-boolean values and makes the code more logical (IMO).

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/unittests/Option/Opts.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 48d9607e734a..09c02989a6a8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -246,10 +246,11 @@ def clang_ignored_gcc_optimization_f_Group : OptionGroup<
 // This is useful if the option is usually disabled.
 multiclass OptInFFlag flags=[], code 
keypath="",
-  DefaultAnyOf defaults = DefaultAnyOf<[]>> {
+  list enablers = []> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText,
-   MarshallingInfoFlag;
+   MarshallingInfoFlag,
+   ImpliedByAnyOf;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
Group, HelpText;
 }
@@ -258,12 +259,13 @@ multiclass OptInFFlag flags=[], code 
keypath="",
-   DefaultAnyOf defaults = DefaultAnyOf<[]>> {
+   list disablers = []> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
Group, HelpText,
-   MarshallingInfoFlag;
+   MarshallingInfoFlag,
+   ImpliedByAnyOf;
 }
 
 multiclass BooleanMarshalledFFlag {
@@ -606,7 +608,8 @@ def cl_fast_relaxed_math : Flag<["-"], 
"cl-fast-relaxed-math">, GroupFastRelaxedMath">;
 def cl_mad_enable : Flag<["-"], "cl-mad-enable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise MAD computations in the 
generated binary.">,
-  MarshallingInfoFlag<"CodeGenOpts.LessPreciseFPMAD", 
DefaultAnyOf<[cl_unsafe_math_optimizations, cl_fast_relaxed_math]>>;
+  MarshallingInfoFlag<"CodeGenOpts.LessPreciseFPMAD">,
+  ImpliedByAnyOf<[cl_unsafe_math_optimizations, cl_fast_relaxed_math]>;
 def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, 
Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">,
   MarshallingInfoFlag<"LangOpts->CLNoSignedZero">;
@@ -1048,10 +1051,11 @@ def ffp_model_EQ : Joined<["-"], "ffp-model=">, 
Group, Flags<[NoXarchOp
 def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Specifies the exception behavior of floating-point operations.">;
 defm fast_math : OptInFFlag<"fast-math", "Allow aggressive, lossy 
floating-point optimizations", "", "", [],
-  "LangOpts->FastMath", DefaultAnyOf<[cl_fast_relaxed_math]>>;
+  "LangOpts->FastMath", [cl_fast_relaxed_math]>;
 def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, 
Flags<[CC1Option]>,
   HelpText<"Allow unsafe floating-point math optimizations which may decrease 
precision">,
-  MarshallingInfoFlag<"LangOpts->UnsafeFPMath", 
DefaultAnyOf<[cl_unsafe_math_optimizations, ffast_math]>>;
+  MarshallingInfoFlag<"LangOpts->UnsafeFPMath">,
+  ImpliedByAnyOf<[cl_unsafe_math_optimizations, ffast_math]>;
 defm math_errno : OptInFFlag<"math-errno", "Require math functions to indicate 
errors by setting errno">;
 def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group, 
Flags<[CoreOption]>;
 def fsignaling_math : Flag<["-"], "fsignaling-math">, Group;
@@ -1265,13 +1269,13 @@ def fno_unsafe_math_optimizations : Flag<["-"], 
"fno-unsafe-math-optimizations">
 def fassociative_math : Flag<["-"], "fassociative-math">, Group;
 def fno_associative_math : Flag<["-"], "fno-associative-math">, Group;
 defm reciprocal_math : OptInFFlag<"reciprocal-math", "Allow division 
operations to be reassociated", "", "", [],
-  "LangOpts->AllowRecip", DefaultAnyOf<[menable_unsafe_fp_math]>>;
+  "LangOpts->AllowRecip", [menable_unsafe_fp_math]>;
 def fapprox_func : Flag<["-"], "fapprox-func">, Group, 
Flags<[CC1Option, NoDriverOption]>,
-  MarshallingInfoFlag<"LangOpts->ApproxFunc", 
DefaultAnyOf<[menable_unsafe_fp_math]>>;
+  MarshallingInfoFlag<"LangOpts->ApproxFunc">, 
ImpliedByAnyOf<[menable_unsafe_fp_mat

[llvm-branch-commits] [clang] 2b84efa - [clang][cli] Port Frontend option flags to new option parsing system

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

Author: Jan Svoboda
Date: 2020-12-01T10:02:08+01:00
New Revision: 2b84efa00040410d97aff403788ee5d96b1046e2

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

LOG: [clang][cli] Port Frontend option flags to new option parsing system

Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 09c02989a6a8..a8ab5cc2494c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -335,8 +335,8 @@ def ccc_arcmt_migrate : Separate<["-"], 
"ccc-arcmt-migrate">, InternalDriverOpt,
 def arcmt_migrate_report_output : Separate<["-"], 
"arcmt-migrate-report-output">,
   HelpText<"Output path for the plist report">,  Flags<[CC1Option]>;
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
-  HelpText<"Emit ARC errors even if the migrator can fix them">,
-  Flags<[CC1Option]>;
+  HelpText<"Emit ARC errors even if the migrator can fix them">, 
Flags<[CC1Option]>,
+  MarshallingInfoFlag<"FrontendOpts.ARCMTMigrateEmitARCErrors">;
 def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
   HelpText<"Auto-generates preprocessed source files and a reproduction 
script">;
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, 
InternalDebugOpt,
@@ -1577,7 +1577,8 @@ def fmodule_name : Separate<["-"], "fmodule-name">, 
Alias;
 def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
   Flags<[CC1Option]>, Alias;
 def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>,
-  HelpText<"Build this module as a system module. Only used with 
-emit-module">;
+  HelpText<"Build this module as a system module. Only used with 
-emit-module">,
+  MarshallingInfoFlag<"FrontendOpts.IsSystemModule">;
 def fmodule_map_file : Joined<["-"], "fmodule-map-file=">,
   Group, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
   HelpText<"Load this module map file">;
@@ -1702,7 +1703,8 @@ def fno_strict_vtable_pointers: Flag<["-"], 
"fno-strict-vtable-pointers">,
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
 def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
   Flags<[CC1Option, CoreOption]>, HelpText<
-  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">;
+  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">,
+  MarshallingInfoFlag<"FrontendOpts.UseTemporary", "true">, IsNegative;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,
@@ -1990,14 +1992,16 @@ def Wframe_larger_than_EQ : Joined<["-"], 
"Wframe-larger-than=">, Group
 
 def : Flag<["-"], "fterminated-vtables">, Alias;
 def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group;
-def ftime_report : Flag<["-"], "ftime-report">, Group, 
Flags<[CC1Option]>;
+def ftime_report : Flag<["-"], "ftime-report">, Group, 
Flags<[CC1Option]>,
+  MarshallingInfoFlag<"FrontendOpts.ShowTimers">;
 def ftime_trace : Flag<["-"], "ftime-trace">, Group,
   HelpText<"Turn on time profiler. Generates JSON file based on output 
filename.">,
   DocBrief<[{
 Turn on time profiler. Generates JSON file based on output filename. Results
 can be analyzed with chrome://tracing or `Speedscope App
 `_ for flamegraph visualization.}]>,
-  Flags<[CC1Option, CoreOption]>;
+  Flags<[CC1Option, CoreOption]>,
+  MarshallingInfoFlag<"FrontendOpts.TimeTrace">;
 def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, 
Group,
   HelpText<"Minimum time granularity (in microseconds) traced by time 
profiler">,
   Flags<[CC1Option, CoreOption]>;
@@ -2210,7 +2214,8 @@ def gno_embed_source : Flag<["-"], "gno-embed-source">, 
Group,
 HelpText<"Restore the default behavior of not embedding source text in 
DWARF debug sections">;
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
 def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option,
-FlangOption]>, HelpText<"Display available options">;
+FlangOption]>, HelpText<"Display available options">,
+MarshallingInfoFlag<"FrontendOpts.ShowHelp">;
 def ibu

[llvm-branch-commits] [mlir] 9edcedf - [mlir] AsyncRuntime: disable threading until test flakiness is fixed

2020-12-01 Thread Eugene Zhulenev via llvm-branch-commits

Author: Eugene Zhulenev
Date: 2020-12-01T01:12:16-08:00
New Revision: 9edcedf7f222ce7c893d1e3bf19b3a7a1f0f2218

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

LOG: [mlir] AsyncRuntime: disable threading until test flakiness is fixed

ExecutionEngine/LLJIT do not run globals destructors in loaded dynamic 
libraries when destroyed, and threads managed by ThreadPool can race with 
program termination, and it leads to segfaults.

TODO: Re-enable threading after fixing a problem with destructors, or removing 
static globals from dynamic library.

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

Added: 


Modified: 
mlir/lib/ExecutionEngine/AsyncRuntime.cpp

Removed: 




diff  --git a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp 
b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
index 6bf59f86208d..3b90b9c694f3 100644
--- a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
+++ b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
@@ -24,8 +24,6 @@
 #include 
 #include 
 
-#include "llvm/Support/ThreadPool.h"
-
 
//===--===//
 // Async runtime API.
 
//===--===//
@@ -45,7 +43,6 @@ class AsyncRuntime {
   AsyncRuntime() : numRefCountedObjects(0) {}
 
   ~AsyncRuntime() {
-threadPool.wait(); // wait for the completion of all async tasks
 assert(getNumRefCountedObjects() == 0 &&
"all ref counted objects must be destroyed");
   }
@@ -54,8 +51,6 @@ class AsyncRuntime {
 return numRefCountedObjects.load(std::memory_order_relaxed);
   }
 
-  llvm::ThreadPool &getThreadPool() { return threadPool; }
-
 private:
   friend class RefCounted;
 
@@ -69,8 +64,6 @@ class AsyncRuntime {
   }
 
   std::atomic numRefCountedObjects;
-
-  llvm::ThreadPool threadPool;
 };
 
 // Returns the default per-process instance of an async runtime.
@@ -241,8 +234,7 @@ extern "C" void mlirAsyncRuntimeAwaitAllInGroup(AsyncGroup 
*group) {
 }
 
 extern "C" void mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) {
-  auto *runtime = getDefaultAsyncRuntimeInstance();
-  runtime->getThreadPool().async([handle, resume]() { (*resume)(handle); });
+  (*resume)(handle);
 }
 
 extern "C" void mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *token,



___
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] 8e41a68 - [clang][cli] Port DependencyOutput option flags to new option parsing system

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

Author: Jan Svoboda
Date: 2020-12-01T10:36:12+01:00
New Revision: 8e41a688a5b1000b51c61b9d103545791c54af17

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

LOG: [clang][cli] Port DependencyOutput option flags to new option parsing 
system

Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a8ab5cc2494c..24662f15539d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -429,7 +429,8 @@ def G : JoinedOrSeparate<["-"], "G">, 
Flags<[NoXarchOption]>, Group,
 "into small data section (MIPS / Hexagon)">;
 def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group, 
Alias;
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
-HelpText<"Show header includes and nesting depth">;
+HelpText<"Show header includes and nesting depth">,
+MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes">;
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -455,17 +456,21 @@ def MF : JoinedOrSeparate<["-"], "MF">, Group,
 HelpText<"Write depfile output from -MMD, -MD, -MM, or -M to ">,
 MetaVarName<"">;
 def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>,
-HelpText<"Add missing headers to depfile">;
+HelpText<"Add missing headers to depfile">,
+MarshallingInfoFlag<"DependencyOutputOpts.AddMissingHeaderDeps">;
 def MJ : JoinedOrSeparate<["-"], "MJ">, Group,
 HelpText<"Write a compilation database entry per input">;
 def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>,
-HelpText<"Create phony target for each dependency (other than main file)">;
+HelpText<"Create phony target for each dependency (other than main file)">,
+MarshallingInfoFlag<"DependencyOutputOpts.UsePhonyTargets">;
 def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output to quote in depfile">;
 def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output in depfile">;
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
-HelpText<"Use NMake/Jom format for the depfile">;
+HelpText<"Use NMake/Jom format for the depfile">,
+MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", 
"DependencyOutputFormat::Make">,
+Normalizer<"makeFlagToValueNormalizer(DependencyOutputFormat::NMake)">;
 def Mach : Flag<["-"], "Mach">, Group;
 def O0 : Flag<["-"], "O0">, Group, Flags<[CC1Option, HelpHidden]>;
 def O4 : Flag<["-"], "O4">, Group, Flags<[CC1Option, HelpHidden]>;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f23d1e398a4a..761f9ebd2381 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -144,20 +144,44 @@ static Optional 
normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
   return None;
 }
 
-void denormalizeSimpleFlag(SmallVectorImpl &Args,
-   const char *Spelling,
-   CompilerInvocation::StringAllocator SA,
-   unsigned TableIndex, unsigned Value) {
+/// The tblgen-erated code passes in a fifth parameter of an arbitrary type, 
but
+/// denormalizeSimpleFlags never looks at it. Avoid bloating compile-time with
+/// unnecessary template instantiations and just ignore it with a variadic
+/// argument.
+static void denormalizeSimpleFlag(SmallVectorImpl &Args,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator, 
unsigned,
+  /*T*/...) {
   Args.push_back(Spelling);
 }
 
-template 
-static llvm::Optional
-normalizeFlagToValue(OptSpecifier Opt, unsigned TableIndex, const ArgList 
&Args,
- DiagnosticsEngine &Diags) {
-  if (Args.hasArg(Opt))
-return Value;
-  return None;
+namespace {
+template  struct FlagToValueNormalizer {
+  T Value;
+
+  Optional operator()(OptSpecifier Opt, unsigned, const ArgList &Args,
+ DiagnosticsEngine &) {
+if (Args.hasArg(Opt))
+  return Value;
+return None;
+  }
+};
+} // namespace
+
+template  static constexpr bool is_int_convertible() {
+  return sizeof(T) <= sizeof(uint64_t) &&
+ std::is_trivially_constructible::value &&
+ std::is_trivially_constr

llvm-branch-commits@lists.llvm.org

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

Author: Georgii Rymar
Date: 2020-12-01T12:36:44+03:00
New Revision: 82d9fb0ac19e6909a957d346a815d993774b2e98

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

LOG: [llvm-readobj] - Introduce `ObjDumper::reportUniqueWarning(const Twine 
&Msg)`.

This introduces the overload for `reportUniqueWarning` which allows
to avoid using `createError` in many places.

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

Added: 


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

Removed: 




diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index d4f716ac97ad..2167fc3e3dff 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -160,11 +160,11 @@ struct DynRegionInfo {
 const uint64_t ObjSize = Obj->getMemoryBufferRef().getBufferSize();
 
 if (Size > ObjSize - Offset) {
-  Dumper->reportUniqueWarning(createError(
+  Dumper->reportUniqueWarning(
   "unable to read data at 0x" + Twine::utohexstr(Offset) +
   " of size 0x" + Twine::utohexstr(Size) + " (" + SizePrintName +
   "): it goes past the end of the file of size 0x" +
-  Twine::utohexstr(ObjSize)));
+  Twine::utohexstr(ObjSize));
   return {Start, Start};
 }
 
@@ -182,7 +182,7 @@ struct DynRegionInfo {
   (" or " + EntSizePrintName + " (0x" + Twine::utohexstr(EntSize) + 
")")
   .str();
 
-Dumper->reportUniqueWarning(createError(Msg.c_str()));
+Dumper->reportUniqueWarning(Msg);
 return {Start, Start};
   }
 };
@@ -522,12 +522,12 @@ ELFDumper::getVersionTable(const Elf_Shdr &Sec, 
ArrayRef *SymTab,
   }
 
   if (SymTabOrErr->first.size() != VersionsOrErr->size())
-reportUniqueWarning(
-createError(describe(Sec) + ": the number of entries (" +
-Twine(VersionsOrErr->size()) +
-") does not match the number of symbols (" +
-Twine(SymTabOrErr->first.size()) +
-") in the symbol table with index " + Twine(Sec.sh_link)));
+reportUniqueWarning(describe(Sec) + ": the number of entries (" +
+Twine(VersionsOrErr->size()) +
+") does not match the number of symbols (" +
+Twine(SymTabOrErr->first.size()) +
+") in the symbol table with index " +
+Twine(Sec.sh_link));
 
   if (SymTab)
 std::tie(*SymTab, *StrTab) = *SymTabOrErr;
@@ -717,16 +717,16 @@ void ELFDumper::printSymbolsHelper(bool IsDynamic) 
const {
 Obj.getStringTableForSymtab(*DotSymtabSec))
   StrTable = *StrTableOrErr;
 else
-  reportUniqueWarning(createError(
+  reportUniqueWarning(
   "unable to get the string table for the SHT_SYMTAB section: " +
-  toString(StrTableOrErr.takeError(;
+  toString(StrTableOrErr.takeError()));
 
 if (Expected SymsOrErr = Obj.symbols(DotSymtabSec))
   Syms = *SymsOrErr;
 else
   reportUniqueWarning(
-  createError("unable to read symbols from the SHT_SYMTAB section: " +
-  toString(SymsOrErr.takeError(;
+  "unable to read symbols from the SHT_SYMTAB section: " +
+  toString(SymsOrErr.takeError()));
 Entries = DotSymtabSec->getEntityCount();
   }
   if (Syms.begin() == Syms.end())
@@ -800,6 +800,7 @@ template  class DumpStyle {
   virtual void printMipsABIFlags() = 0;
   const ELFDumper &dumper() const { return Dumper; }
   void reportUniqueWarning(Error Err) const;
+  void reportUniqueWarning(const Twine &Msg) const;
 
 protected:
   std::vector getGroups();
@@ -957,6 +958,11 @@ void DumpStyle::reportUniqueWarning(Error Err) const 
{
   this->dumper().reportUniqueWarning(std::move(Err));
 }
 
+template 
+void DumpStyle::reportUniqueWarning(const Twine &Msg) const {
+  this->dumper().reportUniqueWarning(Msg);
+}
+
 template  class LLVMStyle : public DumpStyle {
 public:
   TYPEDEF_ELF_TYPES(ELFT)
@@ -1136,9 +1142,8 @@ static std::string maybeDemangle(StringRef Name) {
 template 
 std::string ELFDumper::getStaticSymbolName(uint32_t Index) const {
   auto Warn = [&](Error E) -> std::string {
-this->reportUniqueWarning(
-createError("unable to read the name of symbol with index " +
-Twine(Index) + ": " + toString(std::move(E;
+this->reportUniqueWarning("unable to read the name of symbol with index " +
+  Twine(Index) + ": " + toString(std::move(E)));
 return "";
   };
 
@@ -1877,9 +1882,9 @@ ELFDumper::findDynamic() {
   break;
 }
   } else {
-this->reportUniqueWarning(createError

[llvm-branch-commits] [clang] d1ed670 - [GNU ObjC] Fix a regression listing methods twice.

2020-12-01 Thread David Chisnall via llvm-branch-commits

Author: David Chisnall
Date: 2020-12-01T09:50:18Z
New Revision: d1ed67037de6f3f44dc446784f74f0e02adec9b5

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

LOG: [GNU ObjC] Fix a regression listing methods twice.

Methods synthesized from declared properties were being added to the
method lists twice.  This came from the change to list them in the
class's method list, which missed removing the place in CGObjCGNU that
added them again.

Reviewed By: lanza

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

Added: 
clang/test/CodeGenObjC/gnu-method-only-once.m

Modified: 
clang/lib/CodeGen/CGObjCGNU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index c6500c0230c4..9825d7bca18c 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -3512,19 +3512,6 @@ void CGObjCGNU::GenerateClass(const 
ObjCImplementationDecl *OID) {
   ClassMethods.insert(ClassMethods.begin(), OID->classmeth_begin(),
   OID->classmeth_end());
 
-  // Collect the same information about synthesized properties, which don't
-  // show up in the instance method lists.
-  for (auto *propertyImpl : OID->property_impls())
-if (propertyImpl->getPropertyImplementation() ==
-ObjCPropertyImplDecl::Synthesize) {
-  auto addPropertyMethod = [&](const ObjCMethodDecl *accessor) {
-if (accessor)
-  InstanceMethods.push_back(accessor);
-  };
-  addPropertyMethod(propertyImpl->getGetterMethodDecl());
-  addPropertyMethod(propertyImpl->getSetterMethodDecl());
-}
-
   llvm::Constant *Properties = GeneratePropertyList(OID, ClassDecl);
 
   // Collect the names of referenced protocols

diff  --git a/clang/test/CodeGenObjC/gnu-method-only-once.m 
b/clang/test/CodeGenObjC/gnu-method-only-once.m
new file mode 100644
index ..67d873ccc0aa
--- /dev/null
+++ b/clang/test/CodeGenObjC/gnu-method-only-once.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s -check-prefix=CHECK-NEW
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-1.8 -o - %s | FileCheck %s -check-prefix=CHECK-OLD
+
+// Clang 9 or 10 changed the handling of method lists so that methods provided
+// from synthesised properties showed up in the method list, where previously
+// CGObjCGNU had to collect them and merge them.  One of the places where this
+// merging happened was missed in the move and so we ended up emitting two
+// copies of method metadata for declared properties.
+
+// This class has only instance properties and only one pair of synthesized
+// methods from the property and so we should synthesize only one method list,
+// with precisely two methods on it.
+@interface X
+@property (retain) id iProp;
+@end
+
+@implementation X
+@synthesize iProp;
+@end
+
+// Check that the method list has precisely 2 methods.
+// CHECK-NEW: @.objc_method_list = internal global { i8*, i32, i64, [2 x
+// CHECK-OLD: @.objc_method_list = internal global { i8*, i32, [2 x



___
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] ade2fbb - [llvm-readobj][test] - Merge 2 test cases together.

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

Author: Georgii Rymar
Date: 2020-12-01T12:51:07+03:00
New Revision: ade2fbbfb09c03ed665271247542774ecd540344

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

LOG: [llvm-readobj][test] - Merge 2 test cases together.

This merges `invalid-attr-section-size.test` and `invalid-attr-version.test`
into `invalid-attributes-sec.test`.

This allows to have a single place where other related test cases can be added.

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

Added: 
llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test

Modified: 


Removed: 
llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-section-size.test
llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-version.test



diff  --git a/llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test 
b/llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test
new file mode 100644
index ..547ed93bcd10
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test
@@ -0,0 +1,32 @@
+## Check how we dump invalid SHT_RISCV_ATTRIBUTES sections.
+
+## This test case is used to ensure llvm-readobj checks the version of
+## attribute sections correctly. The only supported format is 'A' (41),
+## here we use 'B' (42).
+
+# RUN: yaml2obj %s -D BITS=32 -DCONTENT=42 -o %t1.32.o
+# RUN: llvm-readobj -A %t1.32.o 2>&1 | FileCheck -DFILE=%t1 %s 
--check-prefix=ERR-FORMAT
+# RUN: yaml2obj %s -D BITS=64 -DCONTENT=42 -o %t1.64.o
+# RUN: llvm-readobj -A %t1.64.o 2>&1 | FileCheck -DFILE=%t1 %s 
--check-prefix=ERR-FORMAT
+
+# ERR-FORMAT: warning: '[[FILE]].{{32|64}}.o': unrecognised FormatVersion: 0x42
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS[[BITS=64]]
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_RISCV
+Sections:
+  - Name:.riscv.attributes
+Type:SHT_RISCV_ATTRIBUTES
+Content: [[CONTENT]]
+
+## Check we report a warning when we are unable to parse the attribute section 
data.
+
+# RUN: yaml2obj %s -D BITS=32 -DCONTENT=41 -o %t2.32.o
+# RUN: llvm-readobj -A %t2.32.o 2>&1 | FileCheck -DFILE=%t2 %s 
--check-prefix=ERR-LENGTH
+# RUN: yaml2obj %s -D BITS=64 -DCONTENT=41 -o %t2.64.o
+# RUN: llvm-readobj -A %t2.64.o 2>&1 | FileCheck -DFILE=%t2 %s 
--check-prefix=ERR-LENGTH
+
+# ERR-LENGTH: warning: '[[FILE]].{{32|64}}.o': invalid section length 0 at 
offset 0x1

diff  --git 
a/llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-section-size.test 
b/llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-section-size.test
deleted file mode 100644
index 524134e1579b..
--- a/llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-section-size.test
+++ /dev/null
@@ -1,20 +0,0 @@
-## This test case is used to ensure the error code is caught by llvm-readobj.
-
-# RUN: yaml2obj %s -D BITS=32 -o %t.32.o
-# RUN: llvm-readobj -A %t.32.o 2>&1 | FileCheck -DFILE=%t %s
-# RUN: yaml2obj %s -D BITS=64 -o %t.64.o
-# RUN: llvm-readobj -A %t.64.o 2>&1 | FileCheck -DFILE=%t %s
-
-# CHECK: warning: '[[FILE]].{{32|64}}.o': invalid section length 0 at offset 
0x1
-
 !ELF
-FileHeader:
-  Class:   ELFCLASS[[BITS]]
-  Data:ELFDATA2LSB
-  Type:ET_REL
-  Machine: EM_RISCV
-Sections:
-  - Name:.riscv.attributes
-Type:SHT_RISCV_ATTRIBUTES
-## Version: 'A'(0x41), section length: 0
-Content: 41

diff  --git a/llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-version.test 
b/llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-version.test
deleted file mode 100644
index 9a4d81bcc4f1..
--- a/llvm/test/tools/llvm-readobj/ELF/RISCV/invalid-attr-version.test
+++ /dev/null
@@ -1,21 +0,0 @@
-## This test case is used to ensure llvm-readobj checks the version of
-## attribute sections correctly.
-
-# RUN: yaml2obj %s -D BITS=32 -o %t.32.o
-# RUN: llvm-readobj -A %t.32.o 2>&1 | FileCheck -DFILE=%t %s
-# RUN: yaml2obj %s -D BITS=64 -o %t.64.o
-# RUN: llvm-readobj -A %t.64.o 2>&1 | FileCheck -DFILE=%t %s
-
-# CHECK: warning: '[[FILE]].{{32|64}}.o': unrecognised FormatVersion: 0x42
-
 !ELF
-FileHeader:
-  Class:   ELFCLASS[[BITS]]
-  Data:ELFDATA2LSB
-  Type:ET_REL
-  Machine: EM_RISCV
-Sections:
-  - Name:.riscv.attributes
-Type:SHT_RISCV_ATTRIBUTES
-## Version: 'B'
-Content: 42



___
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] 398b729 - [clang][cli] Port HeaderSearch option flags to new option parsing system

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

Author: Jan Svoboda
Date: 2020-12-01T10:52:00+01:00
New Revision: 398b729243b12bdfbc7a75b46d39b547545cbd2d

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

LOG: [clang][cli] Port HeaderSearch option flags to new option parsing system

Depends on D83697.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 24662f15539d..48d0e2d6235b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1501,11 +1501,9 @@ def fmodules_user_build_path : Separate<["-"], 
"fmodules-user-build-path">, Grou
 def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, 
Group,
   Flags<[NoXarchOption, CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the prebuilt module path">;
-def fprebuilt_implicit_modules : Flag<["-"], "fprebuilt-implicit-modules">, 
Group,
-  Flags<[NoXarchOption, CC1Option]>,
-  HelpText<"Look up implicit modules in the prebuilt module path">;
-def fno_prebuilt_implicit_modules : Flag<["-"], 
"fno_prebuilt-implicit-modules">, Group,
-  Flags<[NoXarchOption, CC1Option]>;
+defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules",
+  "Look up implicit modules in the prebuilt module path", "", "",
+  [NoXarchOption, CC1Option], 
"HeaderSearchOpts->EnablePrebuiltImplicitModules">;
 def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, 
Group,
   Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the interval (in seconds) between attempts to prune the 
module cache">;
@@ -1524,13 +1522,17 @@ def fbuild_session_file : Joined<["-"], 
"fbuild-session-file=">,
 def fmodules_validate_once_per_build_session : Flag<["-"], 
"fmodules-validate-once-per-build-session">,
   Group, Flags<[CC1Option]>,
   HelpText<"Don't verify input files for the modules if the module has been "
-   "successfully validated or loaded during this build session">;
+   "successfully validated or loaded during this build session">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateOncePerBuildSession">;
 def fmodules_disable_diagnostic_validation : Flag<["-"], 
"fmodules-disable-diagnostic-validation">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Disable validation of the diagnostic options when loading the 
module">;
+  HelpText<"Disable validation of the diagnostic options when loading the 
module">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateDiagnosticOptions", 
"true">, IsNegative;
+// todo: simplify these into a version of OptInFFlag that accepts 
diff erent flags for each record and does not imply group
 def fmodules_validate_system_headers : Flag<["-"], 
"fmodules-validate-system-headers">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Validate the system headers that a module depends on when loading 
the module">;
+  HelpText<"Validate the system headers that a module depends on when loading 
the module">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateSystemHeaders">;
 def fno_modules_validate_system_headers : Flag<["-"], 
"fno-modules-validate-system-headers">,
   Group, Flags<[NoXarchOption]>;
 
@@ -1539,7 +1541,8 @@ def fvalidate_ast_input_files_content:
   Group, Flags<[CC1Option]>,
   HelpText<"Compute and store the hash of input files used to build an AST."
" Files with mismatching mtime's are considered valid"
-   " if both contents is identical">;
+   " if both contents is identical">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ValidateASTInputFilesContent">;
 def fmodules_validate_input_files_content:
   Flag <["-"], "fmodules-validate-input-files-content">,
   Group, Flags<[NoXarchOption]>,
@@ -1571,7 +1574,8 @@ def fmodules : Flag <["-"], "fmodules">, Group,
   HelpText<"Enable the 'modules' language feature">;
 def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, 
Group,
   Flags<[NoXarchOption, CC1Option]>,
-  HelpText<"Implicitly search the file system for module map files.">;
+  HelpText<"Implicitly search the file system for module map files.">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ImplicitModuleMaps">;
 def fmodules_ts : Flag <["-"], "fmodules-ts">, Group,
   Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">;
 def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias;
@@ -2888,7 +2892,8 @@ def no_integrated_cpp : Flag<["-", "--"], 
"no-integrated-cpp">, Flags<[NoXarchOp
 def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group;
 def no__dead__strip__inits__and__terms : Flag<["-"], 
"no_dead_strip_inits_and_terms">;

[llvm-branch-commits] [llvm] ea8c8a5 - [obj2yaml] - Teach tool to emit the "SectionHeaderTable" key and sort sections by file offset.

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

Author: Georgii Rymar
Date: 2020-12-01T12:59:15+03:00
New Revision: ea8c8a50976fd5b9ca9799414bd3c412fce37f03

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

LOG: [obj2yaml] - Teach tool to emit the "SectionHeaderTable" key and sort 
sections by file offset.

Currently when we dump sections, we dump them in the order,
which is specified in the sections header table.

With that the order in the output might not match the order in the file.
This patch starts sorting them by by file offsets when dumping.

When the order in the section header table doesn't match the order
in the file, we should emit the "SectionHeaderTable" key. This patch does it.

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

Added: 


Modified: 
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/test/Object/X86/obj2yaml-dup-section-name.s
llvm/test/Object/obj2yaml.test
llvm/test/tools/obj2yaml/ELF/offset.yaml
llvm/tools/obj2yaml/elf2yaml.cpp

Removed: 




diff  --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 5c60705e291e..92b9c284e064 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1648,12 +1648,12 @@ void MappingTraits::mapping(IO &IO, 
ELFYAML::Object &Object) {
   IO.setContext(&Object);
   IO.mapTag("!ELF", true);
   IO.mapRequired("FileHeader", Object.Header);
-  IO.mapOptional("SectionHeaderTable", Object.SectionHeaders);
   IO.mapOptional("ProgramHeaders", Object.ProgramHeaders);
   IO.mapOptional("Sections", Object.Chunks);
   IO.mapOptional("Symbols", Object.Symbols);
   IO.mapOptional("DynamicSymbols", Object.DynamicSymbols);
   IO.mapOptional("DWARF", Object.DWARF);
+  IO.mapOptional("SectionHeaderTable", Object.SectionHeaders);
   if (Object.DWARF) {
 Object.DWARF->IsLittleEndian =
 Object.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);

diff  --git a/llvm/test/Object/X86/obj2yaml-dup-section-name.s 
b/llvm/test/Object/X86/obj2yaml-dup-section-name.s
index 17fc7a4d9003..9c0a2bef6ac6 100644
--- a/llvm/test/Object/X86/obj2yaml-dup-section-name.s
+++ b/llvm/test/Object/X86/obj2yaml-dup-section-name.s
@@ -2,18 +2,18 @@
 # RUN: obj2yaml %t.o | FileCheck %s
 
 # CHECK: Sections:
+# CHECK: - Name:.text.foo{{$}}
+# CHECK: - Name:'.text.foo (1)'
 # CHECK: - Name:.group{{$}}
 # CHECK:   Members:
 # CHECK: - SectionOrType:   .text.foo{{$}}
 # CHECK: - SectionOrType:   .rela.text.foo{{$}}
-# CHECK: - Name:.text.foo{{$}}
-# CHECK: - Name:.rela.text.foo{{$}}
-# CHECK:   Info:.text.foo{{$}}
 # CHECK: - Name:'.group (1)'
 # CHECK:   Members:
 # CHECK: - SectionOrType:   '.text.foo (1)'
 # CHECK: - SectionOrType:   '.rela.text.foo (1)'
-# CHECK: - Name:'.text.foo (1)'
+# CHECK: - Name:.rela.text.foo{{$}}
+# CHECK:   Info:.text.foo{{$}}
 # CHECK: - Name:'.rela.text.foo (1)'
 # CHECK:   Info:'.text.foo (1)'
 # CHECK: Symbols:

diff  --git a/llvm/test/Object/obj2yaml.test b/llvm/test/Object/obj2yaml.test
index 840440406456..ea538a16782c 100644
--- a/llvm/test/Object/obj2yaml.test
+++ b/llvm/test/Object/obj2yaml.test
@@ -358,35 +358,10 @@
 # ELF-MIPSEL-NEXT: Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
 # ELF-MIPSEL-NEXT: AddressAlign:0x4
 # ELF-MIPSEL-NEXT: Content: 
023C4224E8FFBD271400BFAF1000B0AF21805900018E2424198E09F8200321E2198E09F8200321E202241000B08F1400BF8F0800E0031800BD27
-# ELF-MIPSEL-NEXT:   - Name:.rel.text
-# ELF-MIPSEL-NEXT: Type:SHT_REL
-# ELF-MIPSEL-NEXT: Link:.symtab
-# ELF-MIPSEL-NEXT: AddressAlign:0x4
-# ELF-MIPSEL-NEXT: Offset:  0x434
-# ELF-MIPSEL-NEXT: Info:.text
-# ELF-MIPSEL-NEXT: Relocations:
-# ELF-MIPSEL-NEXT:   - Symbol:  _gp_disp
-# ELF-MIPSEL-NEXT: Type:R_MIPS_HI16
-# ELF-MIPSEL-NEXT:   - Offset:  0x4
-# ELF-MIPSEL-NEXT: Symbol:  _gp_disp
-# ELF-MIPSEL-NEXT: Type:R_MIPS_LO16
-# ELF-MIPSEL-NEXT:   - Offset:  0x18
-# ELF-MIPSEL-NEXT: Symbol:  '$.str'
-# ELF-MIPSEL-NEXT: Type:R_MIPS_GOT16
-# ELF-MIPSEL-NEXT:   - Offset:  0x1C
-# ELF-MIPSEL-NEXT: Symbol:  '$.str'
-# ELF-MIPSEL-NEXT: Type:R_MIPS_LO16
-# ELF-MIPSEL-NEXT:   - Offset:  0x20
-# ELF-MIPSEL-NEXT: Symbol:  puts
-# ELF-MIPSEL-NEXT: Type:R_MIPS_CALL16
-# ELF-MIPSEL-NEXT:   - Offset:  0x2C
-# ELF-MIPSEL-NEXT: Symbol:  SomeOtherFunction
-# ELF-MIPSEL-NEXT: Type:R_MIPS_CA

[llvm-branch-commits] [llvm] 52f3fac - [gn build] Manually merge 40659cd

2020-12-01 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2020-12-01T11:15:05+01:00
New Revision: 52f3fac2245474b90c61e92a5c9bb4df2ae158da

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

LOG: [gn build] Manually merge 40659cd

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/Target/RISCV/Utils/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/Target/RISCV/Utils/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/Target/RISCV/Utils/BUILD.gn
index 2b5a2c2fd875..5bce835f1dd2 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Target/RISCV/Utils/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Target/RISCV/Utils/BUILD.gn
@@ -1,7 +1,7 @@
 import("//llvm/utils/TableGen/tablegen.gni")
 
-# Generates RISCVGenSystemOperands.inc
-tablegen("RISCVGenSystemOperands") {
+# Generates RISCVGenSearchableTables.inc
+tablegen("RISCVGenSearchableTables") {
   visibility = [ ":Utils" ]
   args = [ "-gen-searchable-tables" ]
   td_file = "../RISCV.td"
@@ -9,7 +9,7 @@ tablegen("RISCVGenSystemOperands") {
 
 static_library("Utils") {
   output_name = "LLVMRISCVUtils"
-  public_deps = [ ":RISCVGenSystemOperands" ]
+  public_deps = [ ":RISCVGenSearchableTables" ]
   deps = [
 "//llvm/lib/MC",
 "//llvm/lib/Support",



___
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] 839c963 - [AMDGPU] Simplify some generation checks. NFC.

2020-12-01 Thread Jay Foad via llvm-branch-commits

Author: Jay Foad
Date: 2020-12-01T10:15:32Z
New Revision: 839c9635edce4f6ed348b154a4e755ff8263d366

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

LOG: [AMDGPU] Simplify some generation checks. NFC.

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index b8b747ea8f99..d1e5fe59e910 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -4866,7 +4866,7 @@ bool AMDGPUAsmParser::subtargetHasRegister(const 
MCRegisterInfo &MRI,
   case AMDGPU::SRC_PRIVATE_BASE:
   case AMDGPU::SRC_PRIVATE_LIMIT:
   case AMDGPU::SRC_POPS_EXITING_WAVE_ID:
-return !isCI() && !isSI() && !isVI();
+return isGFX9Plus();
   case AMDGPU::TBA:
   case AMDGPU::TBA_LO:
   case AMDGPU::TBA_HI:
@@ -4877,7 +4877,7 @@ bool AMDGPUAsmParser::subtargetHasRegister(const 
MCRegisterInfo &MRI,
   case AMDGPU::XNACK_MASK:
   case AMDGPU::XNACK_MASK_LO:
   case AMDGPU::XNACK_MASK_HI:
-return !isCI() && !isSI() && !isGFX10Plus() && hasXNACK();
+return (isVI() || isGFX9()) && hasXNACK();
   case AMDGPU::SGPR_NULL:
 return isGFX10Plus();
   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] 7923d71 - [ARM] PREDICATE_CAST demanded bits

2020-12-01 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-01T10:32:24Z
New Revision: 7923d71b4a7a88f97c8a3efe1eb1473a4b2f5bf3

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

LOG: [ARM] PREDICATE_CAST demanded bits

The PREDICATE_CAST node is used to model moves between MVE predicate
registers and gpr's, and eventually become a VMSR p0, rn. When moving to
a predicate only the bottom 16 bits of the sources register are
demanded. This adds a simple fold for that, allowing it to potentially
remove instructions like uxth.

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

Added: 


Modified: 
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/test/CodeGen/Thumb2/mve-pred-bitcast.ll
llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index c94b9e64632f..0426a560805a 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -13844,6 +13844,13 @@ PerformPREDICATE_CASTCombine(SDNode *N, 
TargetLowering::DAGCombinerInfo &DCI) {
 return DCI.DAG.getNode(ARMISD::PREDICATE_CAST, dl, VT, Op->getOperand(0));
   }
 
+  // Only the bottom 16 bits of the source register are used.
+  if (Op.getValueType() == MVT::i32) {
+APInt DemandedMask = APInt::getLowBitsSet(32, 16);
+const TargetLowering &TLI = DCI.DAG.getTargetLoweringInfo();
+if (TLI.SimplifyDemandedBits(Op, DemandedMask, DCI))
+  return SDValue(N, 0);
+  }
   return SDValue();
 }
 

diff  --git a/llvm/test/CodeGen/Thumb2/mve-pred-bitcast.ll 
b/llvm/test/CodeGen/Thumb2/mve-pred-bitcast.ll
index fff9ad871027..c7e553fa3510 100644
--- a/llvm/test/CodeGen/Thumb2/mve-pred-bitcast.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-pred-bitcast.ll
@@ -139,10 +139,9 @@ define arm_aapcs_vfpcc <16 x i8> @bitcast_to_v16i1(i16 %b, 
<16 x i8> %a) {
 ; CHECK-LE-NEXT:mov r4, sp
 ; CHECK-LE-NEXT:bfc r4, #0, #4
 ; CHECK-LE-NEXT:mov sp, r4
-; CHECK-LE-NEXT:uxth r0, r0
 ; CHECK-LE-NEXT:sub.w r4, r7, #8
-; CHECK-LE-NEXT:vmov.i32 q1, #0x0
 ; CHECK-LE-NEXT:vmsr p0, r0
+; CHECK-LE-NEXT:vmov.i32 q1, #0x0
 ; CHECK-LE-NEXT:vpsel q0, q0, q1
 ; CHECK-LE-NEXT:mov sp, r4
 ; CHECK-LE-NEXT:pop {r4, r6, r7, pc}
@@ -160,7 +159,6 @@ define arm_aapcs_vfpcc <16 x i8> @bitcast_to_v16i1(i16 %b, 
<16 x i8> %a) {
 ; CHECK-BE-NEXT:mov sp, r4
 ; CHECK-BE-NEXT:vrev64.8 q1, q0
 ; CHECK-BE-NEXT:vmov.i32 q0, #0x0
-; CHECK-BE-NEXT:uxth r0, r0
 ; CHECK-BE-NEXT:sub.w r4, r7, #8
 ; CHECK-BE-NEXT:vrev32.8 q0, q0
 ; CHECK-BE-NEXT:vmsr p0, r0

diff  --git a/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll 
b/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
index afad0077bbe7..17f57743c301 100644
--- a/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
@@ -51,10 +51,8 @@ define arm_aapcs_vfpcc void @const(<8 x i16> %acc0, <8 x 
i16> %acc1, i32* nocapt
 ; CHECK:   @ %bb.0: @ %entry
 ; CHECK-NEXT:.save {r4, r6, r7, lr}
 ; CHECK-NEXT:push {r4, r6, r7, lr}
-; CHECK-NEXT:uxth r2, r1
+; CHECK-NEXT:vmsr p0, r1
 ; CHECK-NEXT:mvns r1, r1
-; CHECK-NEXT:vmsr p0, r2
-; CHECK-NEXT:uxth r1, r1
 ; CHECK-NEXT:vpstt
 ; CHECK-NEXT:vaddvt.s16 r12, q1
 ; CHECK-NEXT:vaddvt.s16 r2, q0
@@ -92,7 +90,6 @@ define arm_aapcs_vfpcc <4 x i32> @xorvpnot_i32(<4 x i32> 
%acc0, i16 signext %p0)
 ; CHECK:   @ %bb.0: @ %entry
 ; CHECK-NEXT:mvns r0, r0
 ; CHECK-NEXT:vmov.i32 q1, #0x0
-; CHECK-NEXT:uxth r0, r0
 ; CHECK-NEXT:vmsr p0, r0
 ; CHECK-NEXT:vpsel q0, q0, q1
 ; CHECK-NEXT:bx lr
@@ -109,7 +106,6 @@ define arm_aapcs_vfpcc <8 x i16> @xorvpnot_i16(<8 x i16> 
%acc0, i16 signext %p0)
 ; CHECK:   @ %bb.0: @ %entry
 ; CHECK-NEXT:mvns r0, r0
 ; CHECK-NEXT:vmov.i32 q1, #0x0
-; CHECK-NEXT:uxth r0, r0
 ; CHECK-NEXT:vmsr p0, r0
 ; CHECK-NEXT:vpsel q0, q0, q1
 ; CHECK-NEXT:bx lr
@@ -126,7 +122,6 @@ define arm_aapcs_vfpcc <16 x i8> @xorvpnot_i8(<16 x i8> 
%acc0, i16 signext %p0)
 ; CHECK:   @ %bb.0: @ %entry
 ; CHECK-NEXT:mvns r0, r0
 ; CHECK-NEXT:vmov.i32 q1, #0x0
-; CHECK-NEXT:uxth r0, r0
 ; CHECK-NEXT:vmsr p0, r0
 ; CHECK-NEXT:vpsel q0, q0, q1
 ; CHECK-NEXT:bx lr



___
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] 09d82fa - [AArch64] Update pass pipeline test. NFC

2020-12-01 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-01T10:40:04Z
New Revision: 09d82fa95f4561a6a2ce80bce00209018ba70c24

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

LOG: [AArch64] Update pass pipeline test. NFC

Added: 


Modified: 
llvm/test/CodeGen/AArch64/O3-pipeline.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AArch64/O3-pipeline.ll 
b/llvm/test/CodeGen/AArch64/O3-pipeline.ll
index 364c58f4acdf..28753d646b85 100644
--- a/llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ b/llvm/test/CodeGen/AArch64/O3-pipeline.ll
@@ -9,9 +9,9 @@
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
 ; CHECK-NEXT: Assumption Cache Tracker
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager



___
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] f44ba25 - ExtractValue instruction costs

2020-12-01 Thread Sjoerd Meijer via llvm-branch-commits

Author: Sjoerd Meijer
Date: 2020-12-01T10:42:23Z
New Revision: f44ba251354f98d771cd0a4268db94db4315945b

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

LOG: ExtractValue instruction costs

Instruction ExtractValue wasn't handled in
LoopVectorizationCostModel::getInstructionCost(). As a result, it was modeled
as a mul which is not really accurate. Since it is free (most of the times),
this now gets a cost of 0 using getInstructionCost.

This is a follow-up of D92208, that required changing this regression test.
In a follow up I will look at InsertValue which also isn't handled yet.

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

Added: 


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

llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index ce4f57fb3945..d389e03e9c04 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6853,6 +6853,8 @@ unsigned 
LoopVectorizationCostModel::getInstructionCost(Instruction *I,
   return std::min(CallCost, getVectorIntrinsicCost(CI, VF));
 return CallCost;
   }
+  case Instruction::ExtractValue:
+return TTI.getInstructionCost(I, TTI::TCK_RecipThroughput);
   default:
 // The cost of executing VF copies of the scalar instruction. This opcode
 // is unknown. Assume that it is the same as 'mul'.

diff  --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
 
b/llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
index 37c1f4eec32a..35c2ddbf3b65 100644
--- 
a/llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
+++ 
b/llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
@@ -8,9 +8,9 @@
 ; Check scalar cost for extractvalue. The constant and loop invariant operands 
are free,
 ; leaving cost 3 for scalarizing the result + 2 for executing the op with VF 2.
 
-; CM: LV: Scalar loop costs: 7.
-; CM: LV: Found an estimated cost of 19 for VF 2 For instruction:   %a = 
extractvalue { i64, i64 } %sv, 0
-; CM-NEXT: LV: Found an estimated cost of 19 for VF 2 For instruction:   %b = 
extractvalue { i64, i64 } %sv, 1
+; CM: LV: Scalar loop costs: 5.
+; CM: LV: Found an estimated cost of 0 for VF 2 For instruction:   %a = 
extractvalue { i64, i64 } %sv, 0
+; CM-NEXT: LV: Found an estimated cost of 0 for VF 2 For instruction:   %b = 
extractvalue { i64, i64 } %sv, 1
 
 ; Check that the extractvalue operands are actually free in vector code.
 
@@ -57,9 +57,9 @@ exit:
 ; Similar to the test case above, but checks getVectorCallCost as well.
 declare float @pow(float, float) readnone nounwind
 
-; CM: LV: Scalar loop costs: 16.
-; CM: LV: Found an estimated cost of 5 for VF 2 For instruction:   %a = 
extractvalue { float, float } %sv, 0
-; CM-NEXT: LV: Found an estimated cost of 5 for VF 2 For instruction:   %b = 
extractvalue { float, float } %sv, 1
+; CM: LV: Scalar loop costs: 14.
+; CM: LV: Found an estimated cost of 0 for VF 2 For instruction:   %a = 
extractvalue { float, float } %sv, 0
+; CM-NEXT: LV: Found an estimated cost of 0 for VF 2 For instruction:   %b = 
extractvalue { float, float } %sv, 1
 
 ; FORCED-LABEL: define void @test_getVectorCallCost
 
@@ -101,6 +101,3 @@ loop.body:
 exit:
   ret void
 }
-
-
-



___
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] 551a20b - [InstCombine][X86] Add test coverage showing failure to simplify addsub intrinsics to fadd/fsub

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

Author: Simon Pilgrim
Date: 2020-12-01T10:49:43Z
New Revision: 551a20bad987272fa61c821205bfdc0cd2cd0bd0

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

LOG: [InstCombine][X86] Add test coverage showing failure to simplify addsub 
intrinsics to fadd/fsub

If we only use odd/even lanes then we just need fadd/fsub ops

Added: 


Modified: 
llvm/test/Transforms/InstCombine/X86/x86-addsub.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll 
b/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
index 8ce578db2dd6..acf26c58faff 100644
--- a/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
+++ b/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
@@ -10,9 +10,22 @@ declare <8 x float> @llvm.x86.avx.addsub.ps.256(<8 x float>, 
<8 x float>)
 ; Demanded Elts
 ;
 
-
 define double @elts_addsub_v2f64(<2 x double> %0, <2 x double> %1) {
 ; CHECK-LABEL: @elts_addsub_v2f64(
+; CHECK-NEXT:[[TMP3:%.*]] = shufflevector <2 x double> [[TMP1:%.*]], <2 x 
double> undef, <2 x i32> 
+; CHECK-NEXT:[[TMP4:%.*]] = tail call <2 x double> 
@llvm.x86.sse3.addsub.pd(<2 x double> [[TMP0:%.*]], <2 x double> [[TMP3]])
+; CHECK-NEXT:[[TMP5:%.*]] = extractelement <2 x double> [[TMP4]], i32 0
+; CHECK-NEXT:ret double [[TMP5]]
+;
+  %3 = shufflevector <2 x double> %0, <2 x double> undef, <2 x i32> 
+  %4 = shufflevector <2 x double> %1, <2 x double> undef, <2 x i32> 
+  %5 = tail call <2 x double> @llvm.x86.sse3.addsub.pd(<2 x double> %3, <2 x 
double> %4)
+  %6 = extractelement <2 x double> %5, i32 0
+  ret double %6
+}
+
+define double @elts_addsub_v2f64_sub(<2 x double> %0, <2 x double> %1) {
+; CHECK-LABEL: @elts_addsub_v2f64_sub(
 ; CHECK-NEXT:[[TMP3:%.*]] = tail call <2 x double> 
@llvm.x86.sse3.addsub.pd(<2 x double> [[TMP0:%.*]], <2 x double> [[TMP1:%.*]])
 ; CHECK-NEXT:[[TMP4:%.*]] = extractelement <2 x double> [[TMP3]], i32 0
 ; CHECK-NEXT:ret double [[TMP4]]
@@ -41,6 +54,25 @@ define float @elts_addsub_v4f32(<4 x float> %0, <4 x float> 
%1) {
   ret float %8
 }
 
+define float @elts_addsub_v4f32_add(<4 x float> %0, <4 x float> %1) {
+; CHECK-LABEL: @elts_addsub_v4f32_add(
+; CHECK-NEXT:[[TMP3:%.*]] = shufflevector <4 x float> [[TMP0:%.*]], <4 x 
float> undef, <4 x i32> 
+; CHECK-NEXT:[[TMP4:%.*]] = shufflevector <4 x float> [[TMP1:%.*]], <4 x 
float> undef, <4 x i32> 
+; CHECK-NEXT:[[TMP5:%.*]] = tail call <4 x float> 
@llvm.x86.sse3.addsub.ps(<4 x float> [[TMP3]], <4 x float> [[TMP4]])
+; CHECK-NEXT:[[TMP6:%.*]] = extractelement <4 x float> [[TMP5]], i32 1
+; CHECK-NEXT:[[TMP7:%.*]] = extractelement <4 x float> [[TMP5]], i32 3
+; CHECK-NEXT:[[TMP8:%.*]] = fadd float [[TMP6]], [[TMP7]]
+; CHECK-NEXT:ret float [[TMP8]]
+;
+  %3 = shufflevector <4 x float> %0, <4 x float> undef, <4 x i32> 
+  %4 = shufflevector <4 x float> %1, <4 x float> undef, <4 x i32> 
+  %5 = tail call <4 x float> @llvm.x86.sse3.addsub.ps(<4 x float> %3, <4 x 
float> %4)
+  %6 = extractelement <4 x float> %5, i32 1
+  %7 = extractelement <4 x float> %5, i32 3
+  %8 = fadd float %6, %7
+  ret float %8
+}
+
 define double @elts_addsub_v4f64(<4 x double> %0, <4 x double> %1) {
 ; CHECK-LABEL: @elts_addsub_v4f64(
 ; CHECK-NEXT:[[TMP3:%.*]] = tail call <4 x double> 
@llvm.x86.avx.addsub.pd.256(<4 x double> [[TMP0:%.*]], <4 x double> 
[[TMP1:%.*]])
@@ -58,6 +90,23 @@ define double @elts_addsub_v4f64(<4 x double> %0, <4 x 
double> %1) {
   ret double %8
 }
 
+define double @elts_addsub_v4f64_add(<4 x double> %0, <4 x double> %1) {
+; CHECK-LABEL: @elts_addsub_v4f64_add(
+; CHECK-NEXT:[[TMP3:%.*]] = tail call <4 x double> 
@llvm.x86.avx.addsub.pd.256(<4 x double> [[TMP0:%.*]], <4 x double> 
[[TMP1:%.*]])
+; CHECK-NEXT:[[TMP4:%.*]] = extractelement <4 x double> [[TMP3]], i32 1
+; CHECK-NEXT:[[TMP5:%.*]] = extractelement <4 x double> [[TMP3]], i32 3
+; CHECK-NEXT:[[TMP6:%.*]] = fadd double [[TMP4]], [[TMP5]]
+; CHECK-NEXT:ret double [[TMP6]]
+;
+  %3 = shufflevector <4 x double> %0, <4 x double> undef, <4 x i32> 
+  %4 = shufflevector <4 x double> %1, <4 x double> undef, <4 x i32> 
+  %5 = tail call <4 x double> @llvm.x86.avx.addsub.pd.256(<4 x double> %3, <4 
x double> %4)
+  %6 = extractelement <4 x double> %5, i32 1
+  %7 = extractelement <4 x double> %5, i32 3
+  %8 = fadd double %6, %7
+  ret double %8
+}
+
 define float @elts_addsub_v8f32(<8 x float> %0, <8 x float> %1) {
 ; CHECK-LABEL: @elts_addsub_v8f32(
 ; CHECK-NEXT:[[TMP3:%.*]] = tail call <8 x float> 
@llvm.x86.avx.addsub.ps.256(<8 x float> [[TMP0:%.*]], <8 x float> [[TMP1:%.*]])
@@ -75,6 +124,23 @@ define float @elts_addsub_v8f32(<8 x float> %0, <8 x float> 
%1) {
   ret float %8
 }
 
+define float @elts_addsub_v8f32_sub(<8 x float> %0, <8 x float> %1) {
+; CHECK-LAB

[llvm-branch-commits] [llvm] efa9728 - [ConstraintElimination] Decompose GEP %ptr, SHL().

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

Author: Florian Hahn
Date: 2020-12-01T10:58:36Z
New Revision: efa9728a50012c9ead2b0110620e8865b36bef73

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

LOG: [ConstraintElimination] Decompose GEP %ptr, SHL().

Add support the decompose a GEP with an SHL operand.

Added: 


Modified: 
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/geps.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 608ef5337842..5c806b6e5486 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -57,6 +57,14 @@ static SmallVector, 4> 
decompose(Value *V) {
nullptr},
   {1, GEP->getPointerOperand()}};
 }
+Value *Op0;
+ConstantInt *CI;
+if (match(GEP->getOperand(GEP->getNumOperands() - 1),
+  m_NUWShl(m_Value(Op0), m_ConstantInt(CI
+  return {{0, nullptr},
+  {1, GEP->getPointerOperand()},
+  {pow(2, CI->getSExtValue()), Op0}};
+
 return {{0, nullptr},
 {1, GEP->getPointerOperand()},
 {1, GEP->getOperand(GEP->getNumOperands() - 1)}};

diff  --git a/llvm/test/Transforms/ConstraintElimination/geps.ll 
b/llvm/test/Transforms/ConstraintElimination/geps.ll
index ed013ed2c961..52aea974294b 100644
--- a/llvm/test/Transforms/ConstraintElimination/geps.ll
+++ b/llvm/test/Transforms/ConstraintElimination/geps.ll
@@ -387,7 +387,7 @@ define void @test.ult.gep.shl(i32* readonly %src, i32* 
readnone %max, i32 %idx,
 ; CHECK-NEXT:[[IDX_SHL_1:%.*]] = shl nuw i32 [[IDX]], 1
 ; CHECK-NEXT:[[ADD_PTR_SHL_1:%.*]] = getelementptr inbounds i32, i32* 
[[SRC]], i32 [[IDX_SHL_1]]
 ; CHECK-NEXT:[[C_MAX_0:%.*]] = icmp ult i32* [[ADD_PTR_SHL_1]], [[MAX]]
-; CHECK-NEXT:call void @use(i1 [[C_MAX_0]])
+; CHECK-NEXT:call void @use(i1 true)
 ; CHECK-NEXT:[[IDX_SHL_2:%.*]] = shl nuw i32 [[IDX]], 2
 ; CHECK-NEXT:[[ADD_PTR_SHL_2:%.*]] = getelementptr inbounds i32, i32* 
[[SRC]], i32 [[IDX_SHL_2]]
 ; CHECK-NEXT:[[C_MAX_1:%.*]] = icmp ult i32* [[ADD_PTR_SHL_2]], [[MAX]]



___
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] e98d3be - [clang] Enable code completion of designated initializers in Compound Literal Expressions

2020-12-01 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-12-01T12:06:48+01:00
New Revision: e98d3be11c2991c7d446d5c7c714d0384f3b7432

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

LOG: [clang] Enable code completion of designated initializers in Compound 
Literal Expressions

PreferedType were not set when parsing compound literals, hence
designated initializers were not available as code completion suggestions.

This patch sets the preferedtype to parsed type for the following initializer
list.

Fixes https://github.com/clangd/clangd/issues/142.

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

Added: 


Modified: 
clang/lib/Parse/ParseExpr.cpp
clang/test/CodeCompletion/desig-init.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index b3dae626fb0f..d993d9ce4bdb 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3111,6 +3111,7 @@ Parser::ParseCompoundLiteralExpression(ParsedType Ty,
   assert(Tok.is(tok::l_brace) && "Not a compound literal!");
   if (!getLangOpts().C99)   // Compound literals don't exist in C90.
 Diag(LParenLoc, diag::ext_c99_compound_literal);
+  PreferredType.enterTypeCast(Tok.getLocation(), Ty.get());
   ExprResult Result = ParseInitializer();
   if (!Result.isInvalid() && Ty)
 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, 
Result.get());

diff  --git a/clang/test/CodeCompletion/desig-init.cpp 
b/clang/test/CodeCompletion/desig-init.cpp
index ebfd63266397..fbcaeb303e50 100644
--- a/clang/test/CodeCompletion/desig-init.cpp
+++ b/clang/test/CodeCompletion/desig-init.cpp
@@ -23,9 +23,11 @@ void foo() {
   auto z = [](Base B) {};
   z({.t = 1});
   z(Base{.t = 2});
+  z((Base){.t = 2});
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:26:13 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: t : [#int#]t
 }
 
@@ -39,10 +41,10 @@ struct Test {
 };
 void bar() {
   Test T{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:43:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
   // CHECK-CC3: COMPLETION: x : [#T#]x
   Test X{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:46:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
   // CHECK-CC4: COMPLETION: x : [#int#]x
   // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
 }
@@ -50,5 +52,5 @@ void bar() {
 template 
 void aux() {
   Test X{.x = T(2)};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:52:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:54:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
 }



___
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] 4b0ef2b - [NFC][CostModel]Extend class IntrinsicCostAttributes to use ElementCount Type

2020-12-01 Thread Caroline Concatto via llvm-branch-commits

Author: Caroline Concatto
Date: 2020-12-01T11:12:51Z
New Revision: 4b0ef2b075002f94e37dc2f28caf6b167052f93f

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

LOG: [NFC][CostModel]Extend class IntrinsicCostAttributes to use ElementCount 
Type

This patch replaces the attribute  `unsigned VF`  in the class
IntrinsicCostAttributes by `ElementCount VF`.
This is a non-functional change to help upcoming patches to compute the cost
model for scalable vector inside this class.

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

Added: 


Modified: 
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h 
b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 9cb5fe78f418..af57176401b4 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -117,7 +117,7 @@ class IntrinsicCostAttributes {
   SmallVector ParamTys;
   SmallVector Arguments;
   FastMathFlags FMF;
-  unsigned VF = 1;
+  ElementCount VF = ElementCount::getFixed(1);
   // If ScalarizationCost is UINT_MAX, the cost of scalarizing the
   // arguments and the return value will be computed based on types.
   unsigned ScalarizationCost = std::numeric_limits::max();
@@ -128,15 +128,10 @@ class IntrinsicCostAttributes {
   IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI);
 
   IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI,
-  unsigned Factor);
-  IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI,
-  ElementCount Factor)
-  : IntrinsicCostAttributes(Id, CI, Factor.getKnownMinValue()) {
-assert(!Factor.isScalable());
-  }
+  ElementCount Factor);
 
   IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI,
-  unsigned Factor, unsigned ScalarCost);
+  ElementCount Factor, unsigned ScalarCost);
 
   IntrinsicCostAttributes(Intrinsic::ID Id, Type *RTy,
   ArrayRef Tys, FastMathFlags Flags);
@@ -159,7 +154,7 @@ class IntrinsicCostAttributes {
   Intrinsic::ID getID() const { return IID; }
   const IntrinsicInst *getInst() const { return II; }
   Type *getReturnType() const { return RetTy; }
-  unsigned getVectorFactor() const { return VF; }
+  ElementCount getVectorFactor() const { return VF; }
   FastMathFlags getFlags() const { return FMF; }
   unsigned getScalarizationCost() const { return ScalarizationCost; }
   const SmallVectorImpl &getArgs() const { return Arguments; }

diff  --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h 
b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 0b6b2655e0d5..05c5c835d74a 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1207,11 +1207,12 @@ class BasicTTIImplBase : public 
TargetTransformInfoImplCRTPBase {
 if (isa(RetTy))
   return BaseT::getIntrinsicInstrCost(ICA, CostKind);
 
-unsigned VF = ICA.getVectorFactor();
-unsigned RetVF =
-(RetTy->isVectorTy() ? cast(RetTy)->getNumElements()
- : 1);
-assert((RetVF == 1 || VF == 1) && "VF > 1 and RetVF is a vector type");
+ElementCount VF = ICA.getVectorFactor();
+ElementCount RetVF =
+(RetTy->isVectorTy() ? cast(RetTy)->getElementCount()
+ : ElementCount::getFixed(1));
+assert((RetVF.isScalar() || VF.isScalar()) &&
+   "VF > 1 and RetVF is a vector type");
 const IntrinsicInst *I = ICA.getInst();
 const SmallVectorImpl &Args = ICA.getArgs();
 FastMathFlags FMF = ICA.getFlags();
@@ -1221,13 +1222,15 @@ class BasicTTIImplBase : public 
TargetTransformInfoImplCRTPBase {
 
 case Intrinsic::cttz:
   // FIXME: If necessary, this should go in target-specific overrides.
-  if (VF == 1 && RetVF == 1 && getTLI()->isCheapToSpeculateCttz())
+  if (VF.isScalar() && RetVF.isScalar() &&
+  getTLI()->isCheapToSpeculateCttz())
 return TargetTransformInfo::TCC_Basic;
   break;
 
 case Intrinsic::ctlz:
   // FIXME: If necessary, this should go in target-specific overrides.
-  if (VF == 1 && RetVF == 1 && getTLI()->isCheapToSpeculateCtlz())
+  if (VF.isScalar() && RetVF.isScalar() &&
+  getTLI()->isCheapToSpeculateCtlz())
 return TargetTransformInfo::TCC_Basic;
   break;
 
@@ -1235,7 +1238,7 @@ class BasicTTIImplBase : public 
TargetTransformInfoImplCRTPBase {
   return thisT()->getMemcpyCost(ICA.get

[llvm-branch-commits] [llvm] c63799f - [InstCombine][X86] Fold addsub intrinsic to fadd/fsub depending on demanded elts (PR46277)

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

Author: Simon Pilgrim
Date: 2020-12-01T11:27:40Z
New Revision: c63799fc52ff2473dc64cdbc343cefb8bb786b6b

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

LOG: [InstCombine][X86] Fold addsub intrinsic to fadd/fsub depending on 
demanded elts (PR46277)

Added: 


Modified: 
llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
llvm/test/Transforms/InstCombine/X86/x86-addsub.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp 
b/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
index 9ae2c1f2053f..3b05dba57a33 100644
--- a/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
@@ -1915,11 +1915,20 @@ Optional 
X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(
   case Intrinsic::x86_sse3_addsub_pd:
   case Intrinsic::x86_sse3_addsub_ps:
   case Intrinsic::x86_avx_addsub_pd_256:
-  case Intrinsic::x86_avx_addsub_ps_256:
+  case Intrinsic::x86_avx_addsub_ps_256: {
+APInt SubMask = APInt::getSplat(VWidth, APInt(2, 0x1));
+if (DemandedElts.isSubsetOf(SubMask))
+  return IC.Builder.CreateFSub(II.getArgOperand(0), II.getArgOperand(1));
+
+APInt AddMask = APInt::getSplat(VWidth, APInt(2, 0x2));
+if (DemandedElts.isSubsetOf(AddMask))
+  return IC.Builder.CreateFAdd(II.getArgOperand(0), II.getArgOperand(1));
+
 simplifyAndSetOp(&II, 0, DemandedElts, UndefElts);
 simplifyAndSetOp(&II, 1, DemandedElts, UndefElts2);
 UndefElts &= UndefElts2;
 break;
+  }
 
   case Intrinsic::x86_sse2_packssdw_128:
   case Intrinsic::x86_sse2_packsswb_128:

diff  --git a/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll 
b/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
index acf26c58faff..d051732ee819 100644
--- a/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
+++ b/llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
@@ -13,7 +13,7 @@ declare <8 x float> @llvm.x86.avx.addsub.ps.256(<8 x float>, 
<8 x float>)
 define double @elts_addsub_v2f64(<2 x double> %0, <2 x double> %1) {
 ; CHECK-LABEL: @elts_addsub_v2f64(
 ; CHECK-NEXT:[[TMP3:%.*]] = shufflevector <2 x double> [[TMP1:%.*]], <2 x 
double> undef, <2 x i32> 
-; CHECK-NEXT:[[TMP4:%.*]] = tail call <2 x double> 
@llvm.x86.sse3.addsub.pd(<2 x double> [[TMP0:%.*]], <2 x double> [[TMP3]])
+; CHECK-NEXT:[[TMP4:%.*]] = fsub <2 x double> [[TMP0:%.*]], [[TMP3]]
 ; CHECK-NEXT:[[TMP5:%.*]] = extractelement <2 x double> [[TMP4]], i32 0
 ; CHECK-NEXT:ret double [[TMP5]]
 ;
@@ -26,7 +26,7 @@ define double @elts_addsub_v2f64(<2 x double> %0, <2 x 
double> %1) {
 
 define double @elts_addsub_v2f64_sub(<2 x double> %0, <2 x double> %1) {
 ; CHECK-LABEL: @elts_addsub_v2f64_sub(
-; CHECK-NEXT:[[TMP3:%.*]] = tail call <2 x double> 
@llvm.x86.sse3.addsub.pd(<2 x double> [[TMP0:%.*]], <2 x double> [[TMP1:%.*]])
+; CHECK-NEXT:[[TMP3:%.*]] = fsub <2 x double> [[TMP0:%.*]], [[TMP1:%.*]]
 ; CHECK-NEXT:[[TMP4:%.*]] = extractelement <2 x double> [[TMP3]], i32 0
 ; CHECK-NEXT:ret double [[TMP4]]
 ;
@@ -56,13 +56,11 @@ define float @elts_addsub_v4f32(<4 x float> %0, <4 x float> 
%1) {
 
 define float @elts_addsub_v4f32_add(<4 x float> %0, <4 x float> %1) {
 ; CHECK-LABEL: @elts_addsub_v4f32_add(
-; CHECK-NEXT:[[TMP3:%.*]] = shufflevector <4 x float> [[TMP0:%.*]], <4 x 
float> undef, <4 x i32> 
-; CHECK-NEXT:[[TMP4:%.*]] = shufflevector <4 x float> [[TMP1:%.*]], <4 x 
float> undef, <4 x i32> 
-; CHECK-NEXT:[[TMP5:%.*]] = tail call <4 x float> 
@llvm.x86.sse3.addsub.ps(<4 x float> [[TMP3]], <4 x float> [[TMP4]])
-; CHECK-NEXT:[[TMP6:%.*]] = extractelement <4 x float> [[TMP5]], i32 1
-; CHECK-NEXT:[[TMP7:%.*]] = extractelement <4 x float> [[TMP5]], i32 3
-; CHECK-NEXT:[[TMP8:%.*]] = fadd float [[TMP6]], [[TMP7]]
-; CHECK-NEXT:ret float [[TMP8]]
+; CHECK-NEXT:[[TMP3:%.*]] = fadd <4 x float> [[TMP0:%.*]], [[TMP1:%.*]]
+; CHECK-NEXT:[[TMP4:%.*]] = extractelement <4 x float> [[TMP3]], i32 1
+; CHECK-NEXT:[[TMP5:%.*]] = extractelement <4 x float> [[TMP3]], i32 1
+; CHECK-NEXT:[[TMP6:%.*]] = fadd float [[TMP4]], [[TMP5]]
+; CHECK-NEXT:ret float [[TMP6]]
 ;
   %3 = shufflevector <4 x float> %0, <4 x float> undef, <4 x i32> 
   %4 = shufflevector <4 x float> %1, <4 x float> undef, <4 x i32> 
@@ -92,7 +90,7 @@ define double @elts_addsub_v4f64(<4 x double> %0, <4 x 
double> %1) {
 
 define double @elts_addsub_v4f64_add(<4 x double> %0, <4 x double> %1) {
 ; CHECK-LABEL: @elts_addsub_v4f64_add(
-; CHECK-NEXT:[[TMP3:%.*]] = tail call <4 x double> 
@llvm.x86.avx.addsub.pd.256(<4 x double> [[TMP0:%.*]], <4 x double> 
[[TMP1:%.*]])
+; CHECK-NEXT:[[TMP3:%.*]] = fadd <4 x double> [[TMP0:%.*]], [[TMP1:%.*]]
 ; CHECK-NEXT:[[TMP4:%.*]] = extractelement <4 x double> [[TMP3]], i32 1
 ; CHECK-NEXT:

[llvm-branch-commits] [llvm] cba4acc - [LV] Clamp VF hint when unsafe

2020-12-01 Thread Cullen Rhodes via llvm-branch-commits

Author: Cullen Rhodes
Date: 2020-12-01T11:30:34Z
New Revision: cba4accda08f90bbc96d7662ef6b1bb12a7733f2

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

LOG: [LV] Clamp VF hint when unsafe

In the following loop the dependence distance is 2 and can only be
vectorized if the vector length is no larger than this.

  void foo(int *a, int *b, int N) {
#pragma clang loop vectorize(enable) vectorize_width(4)
for (int i=0; ihttps://llvm.org/docs/LangRef.html#llvm-loop-vectorize-and-llvm-loop-interleave
[2] 
https://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations

Reviewed By: sdesmalen, fhahn, Meinersbur

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

Added: 
llvm/test/Transforms/LoopVectorize/AArch64/unsafe-vf-hint-remark.ll
llvm/test/Transforms/LoopVectorize/unsafe-vf-hint-remark.ll

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 d389e03e9c04..d87938bb1464 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1443,7 +1443,8 @@ class LoopVectorizationCostModel {
   /// \return An upper bound for the vectorization factor, a power-of-2 larger
   /// than zero. One is returned if vectorization should best be avoided due
   /// to cost.
-  ElementCount computeFeasibleMaxVF(unsigned ConstTripCount);
+  ElementCount computeFeasibleMaxVF(unsigned ConstTripCount,
+ElementCount UserVF);
 
   /// The vectorization cost is a combination of the cost itself and a boolean
   /// indicating whether any of the contributing operations will actually
@@ -5270,9 +5271,11 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount 
UserVF, unsigned UserIC) {
 return None;
   }
 
+  ElementCount MaxVF = computeFeasibleMaxVF(TC, UserVF);
+
   switch (ScalarEpilogueStatus) {
   case CM_ScalarEpilogueAllowed:
-return UserVF ? UserVF : computeFeasibleMaxVF(TC);
+return MaxVF;
   case CM_ScalarEpilogueNotNeededUsePredicate:
 LLVM_DEBUG(
 dbgs() << "LV: vector predicate hint/switch found.\n"
@@ -5308,7 +5311,6 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount 
UserVF, unsigned UserIC) {
 InterleaveInfo.invalidateGroupsRequiringScalarEpilogue();
   }
 
-  ElementCount MaxVF = UserVF ? UserVF : computeFeasibleMaxVF(TC);
   assert(!MaxVF.isScalable() &&
  "Scalable vectors do not yet support tail folding");
   assert((UserVF.isNonZero() || isPowerOf2_32(MaxVF.getFixedValue())) &&
@@ -5361,7 +5363,9 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount 
UserVF, unsigned UserIC) {
 }
 
 ElementCount
-LoopVectorizationCostModel::computeFeasibleMaxVF(unsigned ConstTripCount) {
+LoopVectorizationCostModel::computeFeasibleMaxVF(unsigned ConstTripCount,
+ ElementCount UserVF) {
+  assert(!UserVF.isScalable() && "scalable vectorization not yet handled");
   MinBWs = computeMinimumValueSizes(TheLoop->getBlocks(), *DB, &TTI);
   unsigned SmallestType, WidestType;
   std::tie(SmallestType, WidestType) = getSmallestAndWidestTypes();
@@ -5373,6 +5377,27 @@ 
LoopVectorizationCostModel::computeFeasibleMaxVF(unsigned ConstTripCount) {
   // dependence distance).
   unsigned MaxSafeVectorWidthInBits = Legal->getMaxSafeVectorWidthInBits();
 
+  if (UserVF.isNonZero()) {
+// If legally unsafe, clamp the user vectorization factor to a safe value.
+unsigned MaxSafeVF = PowerOf2Floor(MaxSafeVectorWidthInBits / WidestType);
+if (UserVF.getFixedValue() <= MaxSafeVF)
+  return UserVF;
+
+LLVM_DEBUG(dbgs() << "LV: User VF=" << UserVF
+  << " is unsafe, clamping to max safe VF=" << MaxSafeVF
+  << ".\n");
+ORE->emit([&]() {
+  return OptimizationRemarkAnalysis(DEBUG_TYPE, "VectorizationFactor",
+TheLoop->getStartLoc(),
+TheLoop->getHeader())
+ << "User-specified vectorization factor "
+ << ore::NV("UserVectorizationFactor", UserVF)
+ << " is unsafe, clamping to maximum safe vectorization factor "
+ << ore::NV("VectorizationFactor", MaxSafeVF);
+});
+return ElementCount::getFixed(MaxSafeVF);
+  }
+
   WidestRegister = std::min(WidestRegister, MaxSafeVectorWidthInBits);
 
   // Ensure MaxVF is a power of 2; the dependence distance bound may not be.
@@ -7031,9 +7056,12 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, 
unsigned UserIC) {
   CM.invalidateCostModelingDecisions();
   }
 
-  if (!UserVF.isZero()) {
+  ElementCount MaxVF = MaybeMaxVF.g

[llvm-branch-commits] [clang] 523775f - [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

2020-12-01 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2020-12-01T11:33:10Z
New Revision: 523775f96742e6f099b3498b6606b7250c0af841

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

LOG: [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

The restriction on pointer-to-pointer kernel arguments has been
relaxed in OpenCL 2.0.  Apply the same address space restrictions for
pointer argument types to the inner pointer types.

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCL/invalid-kernel-parameters.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9c282a73e0ed..2116b3f7b78e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8591,12 +8591,21 @@ static bool isOpenCLSizeDependentType(ASTContext &C, 
QualType Ty) {
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
-if (PointeeType->isPointerType())
-  return PtrPtrKernelParam;
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
 PointeeType.getAddressSpace() == LangAS::Default)
   return InvalidAddrSpacePtrKernelParam;
+
+if (PointeeType->isPointerType()) {
+  // This is a pointer to pointer parameter.
+  // Recursively check inner type.
+  OpenCLParamType ParamKind = getOpenCLKernelParameterType(S, PointeeType);
+  if (ParamKind == InvalidAddrSpacePtrKernelParam ||
+  ParamKind == InvalidKernelParam)
+return ParamKind;
+
+  return PtrPtrKernelParam;
+}
 return PtrKernelParam;
   }
 
@@ -8649,11 +8658,17 @@ static void checkIsValidOpenCLKernelParameter(
 
   switch (getOpenCLKernelParameterType(S, PT)) {
   case PtrPtrKernelParam:
-// OpenCL v1.2 s6.9.a:
-// A kernel function argument cannot be declared as a
-// pointer to a pointer type.
-S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
-D.setInvalidType();
+// OpenCL v3.0 s6.11.a:
+// A kernel function argument cannot be declared as a pointer to a pointer
+// type. [...] This restriction only applies to OpenCL C 1.2 or below.
+if (S.getLangOpts().OpenCLVersion < 120 &&
+!S.getLangOpts().OpenCLCPlusPlus) {
+  S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
+  D.setInvalidType();
+  return;
+}
+
+ValidTypes.insert(PT.getTypePtr());
 return;
 
   case InvalidAddrSpacePtrKernelParam:

diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 26859ee62cae..9fce92dbd6c3 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -5,8 +5,14 @@ kernel void half_arg(half x) { } // expected-error{{declaring 
function parameter
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#endif
 kernel void no_ptrptr(global int * global *i) { }
+kernel void no_lptrcptr(constant int * local *i) { }
+kernel void no_ptrptrptr(global int * global * global *i) { }
 
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_privateptr(__private int *i) { }
@@ -17,6 +23,15 @@ __kernel void no_privatearray(__private int i[]) { }
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_ptr_private_ptr(private int * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_private_ptr_ptr(global int * private * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+#endif
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptr

[llvm-branch-commits] [llvm] 6dbd0d3 - [DAG] Move vselect(icmp_ult, -1, add(x, y)) -> uaddsat(x, y) to DAGCombine (PR40111)

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

Author: Simon Pilgrim
Date: 2020-12-01T11:56:26Z
New Revision: 6dbd0d36a1729e129bb11647b91bdb615d42c98c

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

LOG: [DAG] Move vselect(icmp_ult, -1, add(x,y)) -> uaddsat(x,y) to DAGCombine 
(PR40111)

Move the X86 VSELECT->UADDSAT fold to DAGCombiner - there's nothing target 
specific about these folds.

The SSE42 test diffs are relatively benign - its avoiding an extra constant 
load in exchange for an extra xor operation - there are extra register moves, 
which is annoying as all those operations should commute them away.

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/AArch64/sat-add.ll
llvm/test/CodeGen/PowerPC/sat-add.ll
llvm/test/CodeGen/X86/sat-add.ll
llvm/test/CodeGen/X86/uadd_sat_vec.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 1b5debfe602e..7a87521ae344 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9698,6 +9698,51 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
 return DAG.getSelect(DL, N1.getValueType(), WideSetCC, N1, N2);
   }
 }
+
+// Match VSELECTs into add with unsigned saturation.
+if (hasOperation(ISD::UADDSAT, VT)) {
+  // Check if one of the arms of the VSELECT is vector with all bits set.
+  // If it's on the left side invert the predicate to simplify logic below.
+  SDValue Other;
+  ISD::CondCode SatCC = CC;
+  if (ISD::isBuildVectorAllOnes(N1.getNode())) {
+Other = N2;
+SatCC = ISD::getSetCCInverse(SatCC, VT.getScalarType());
+  } else if (ISD::isBuildVectorAllOnes(N2.getNode())) {
+Other = N1;
+  }
+
+  if (Other && Other.getOpcode() == ISD::ADD) {
+SDValue CondLHS = LHS, CondRHS = RHS;
+SDValue OpLHS = Other.getOperand(0), OpRHS = Other.getOperand(1);
+
+// Canonicalize condition operands.
+if (SatCC == ISD::SETUGE) {
+  std::swap(CondLHS, CondRHS);
+  SatCC = ISD::SETULE;
+}
+
+// We can test against either of the addition operands.
+// x <= x+y ? x+y : ~0 --> uaddsat x, y
+// x+y >= x ? x+y : ~0 --> uaddsat x, y
+if (SatCC == ISD::SETULE && Other == CondRHS &&
+(OpLHS == CondLHS || OpRHS == CondLHS))
+  return DAG.getNode(ISD::UADDSAT, DL, VT, OpLHS, OpRHS);
+
+if (isa(OpRHS) && isa(CondRHS) &&
+CondLHS == OpLHS) {
+  // If the RHS is a constant we have to reverse the const
+  // canonicalization.
+  // x >= ~C ? x+C : ~0 --> uaddsat x, C
+  auto MatchUADDSAT = [](ConstantSDNode *Op, ConstantSDNode *Cond) {
+return Cond->getAPIntValue() == ~Op->getAPIntValue();
+  };
+  if (SatCC == ISD::SETULE &&
+  ISD::matchBinaryPredicate(OpRHS, CondRHS, MatchUADDSAT))
+return DAG.getNode(ISD::UADDSAT, DL, VT, OpLHS, OpRHS);
+}
+  }
+}
   }
 
   if (SimplifySelectOps(N, N1, N2))

diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index e45a311f84a4..d27ada4c4b38 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -7525,13 +7525,13 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, 
SelectionDAG &DAG) const {
   assert(VT.isInteger() && "Expected operands to be integers");
 
   // usub.sat(a, b) -> umax(a, b) - b
-  if (Opcode == ISD::USUBSAT && isOperationLegalOrCustom(ISD::UMAX, VT)) {
+  if (Opcode == ISD::USUBSAT && isOperationLegal(ISD::UMAX, VT)) {
 SDValue Max = DAG.getNode(ISD::UMAX, dl, VT, LHS, RHS);
 return DAG.getNode(ISD::SUB, dl, VT, Max, RHS);
   }
 
   // uadd.sat(a, b) -> umin(a, ~b) + b
-  if (Opcode == ISD::UADDSAT && isOperationLegalOrCustom(ISD::UMIN, VT)) {
+  if (Opcode == ISD::UADDSAT && isOperationLegal(ISD::UMIN, VT)) {
 SDValue InvRHS = DAG.getNOT(dl, RHS, VT);
 SDValue Min = DAG.getNode(ISD::UMIN, dl, VT, LHS, InvRHS);
 return DAG.getNode(ISD::ADD, dl, VT, Min, RHS);

diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 1274582614ed..ce3497934a07 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -922,9 +922,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine 
&TM,
 setOperationAction(ISD::SADDSAT,MVT::v8i16, Legal);
 setOperationAction(ISD::USUBS

[llvm-branch-commits] [llvm] b520292 - [NFC][SimplifyCFG] fold-branch-to-common-dest: add tests with cond of br not being the last op

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

Author: Roman Lebedev
Date: 2020-12-01T15:13:05+03:00
New Revision: b52029224c183d33c5a3bd9b14f3375e25f15fa5

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

LOG: [NFC][SimplifyCFG] fold-branch-to-common-dest: add tests with cond of br 
not being the last op

Added: 


Modified: 
llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

Removed: 




diff  --git a/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll 
b/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
index 22f2ed147b64..3d3c3bbf630d 100644
--- a/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
+++ b/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
@@ -628,3 +628,99 @@ final_right:
   call void @sideeffect1()
   ret void
 }
+
+; The liveout instruction can be located after the branch condition.
+define void 
@one_pred_with_extra_op_externally_used_only_after_cond_distant_phi(i8 %v0, i8 
%v1, i8 %v3, i8 %v4, i8 %v5) {
+; CHECK-LABEL: 
@one_pred_with_extra_op_externally_used_only_after_cond_distant_phi(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
+; CHECK-NEXT:br i1 [[C0]], label [[PRED:%.*]], label [[LEFT_END:%.*]]
+; CHECK:   pred:
+; CHECK-NEXT:[[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
+; CHECK-NEXT:br i1 [[C1]], label [[DISPATCH:%.*]], label 
[[FINAL_RIGHT:%.*]]
+; CHECK:   dispatch:
+; CHECK-NEXT:[[C3:%.*]] = icmp eq i8 [[V3:%.*]], 0
+; CHECK-NEXT:[[V2_ADJ:%.*]] = add i8 [[V4:%.*]], [[V5:%.*]]
+; CHECK-NEXT:br i1 [[C3]], label [[FINAL_LEFT:%.*]], label [[FINAL_RIGHT]]
+; CHECK:   final_left:
+; CHECK-NEXT:call void @sideeffect0()
+; CHECK-NEXT:call void @use8(i8 [[V2_ADJ]])
+; CHECK-NEXT:br label [[LEFT_END]]
+; CHECK:   left_end:
+; CHECK-NEXT:[[MERGE_LEFT:%.*]] = phi i8 [ [[V2_ADJ]], [[FINAL_LEFT]] ], [ 
0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:call void @sideeffect1()
+; CHECK-NEXT:call void @use8(i8 [[MERGE_LEFT]])
+; CHECK-NEXT:ret void
+; CHECK:   final_right:
+; CHECK-NEXT:call void @sideeffect2()
+; CHECK-NEXT:ret void
+;
+entry:
+  %c0 = icmp eq i8 %v0, 0
+  br i1 %c0, label %pred, label %left_end
+pred:
+  %c1 = icmp eq i8 %v1, 0
+  br i1 %c1, label %dispatch, label %final_right
+dispatch:
+  %c3 = icmp eq i8 %v3, 0
+  %v2_adj = add i8 %v4, %v5
+  br i1 %c3, label %final_left, label %final_right
+final_left:
+  call void @sideeffect0()
+  call void @use8(i8 %v2_adj)
+  br label %left_end
+left_end:
+  %merge_left = phi i8 [ %v2_adj, %final_left ], [ 0, %entry ]
+  call void @sideeffect1()
+  call void @use8(i8 %merge_left)
+  ret void
+final_right:
+  call void @sideeffect2()
+  ret void
+}
+define void @two_preds_with_extra_op_externally_used_only_after_cond(i8 %v0, 
i8 %v1, i8 %v2, i8 %v3, i8 %v4, i8 %v5) {
+; CHECK-LABEL: @two_preds_with_extra_op_externally_used_only_after_cond(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
+; CHECK-NEXT:br i1 [[C0]], label [[PRED0:%.*]], label [[PRED1:%.*]]
+; CHECK:   pred0:
+; CHECK-NEXT:[[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
+; CHECK-NEXT:br i1 [[C1]], label [[FINAL_LEFT:%.*]], label [[DISPATCH:%.*]]
+; CHECK:   pred1:
+; CHECK-NEXT:[[C2:%.*]] = icmp eq i8 [[V2:%.*]], 0
+; CHECK-NEXT:br i1 [[C2]], label [[DISPATCH]], label [[FINAL_RIGHT:%.*]]
+; CHECK:   dispatch:
+; CHECK-NEXT:[[C3:%.*]] = icmp eq i8 [[V3:%.*]], 0
+; CHECK-NEXT:[[V3_ADJ:%.*]] = add i8 [[V4:%.*]], [[V5:%.*]]
+; CHECK-NEXT:br i1 [[C3]], label [[FINAL_LEFT]], label [[FINAL_RIGHT]]
+; CHECK:   final_left:
+; CHECK-NEXT:[[MERGE_LEFT:%.*]] = phi i8 [ [[V3_ADJ]], [[DISPATCH]] ], [ 
0, [[PRED0]] ]
+; CHECK-NEXT:call void @use8(i8 [[MERGE_LEFT]])
+; CHECK-NEXT:call void @sideeffect0()
+; CHECK-NEXT:ret void
+; CHECK:   final_right:
+; CHECK-NEXT:call void @sideeffect1()
+; CHECK-NEXT:ret void
+;
+entry:
+  %c0 = icmp eq i8 %v0, 0
+  br i1 %c0, label %pred0, label %pred1
+pred0:
+  %c1 = icmp eq i8 %v1, 0
+  br i1 %c1, label %final_left, label %dispatch
+pred1:
+  %c2 = icmp eq i8 %v2, 0
+  br i1 %c2, label %dispatch, label %final_right
+dispatch:
+  %c3 = icmp eq i8 %v3, 0
+  %v3_adj = add i8 %v4, %v5
+  br i1 %c3, label %final_left, label %final_right
+final_left:
+  %merge_left = phi i8 [ %v3_adj, %dispatch ], [ 0, %pred0 ]
+  call void @use8(i8 %merge_left)
+  call void @sideeffect0()
+  ret void
+final_right:
+  call void @sideeffect1()
+  ret void
+}



___
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] 15f8060 - [SimplifyCFG] FoldBranchToCommonDest: don't require that cmp of br is last instruction

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

Author: Roman Lebedev
Date: 2020-12-01T15:13:06+03:00
New Revision: 15f8060f6f2388d503fcd400e1226c69554c1924

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

LOG: [SimplifyCFG] FoldBranchToCommonDest: don't require that cmp of br is last 
instruction

There is no correctness need for that, and since we allow live-out
uses, this could theoretically happen, because currently nothing
will move the cond to right before the branch in those tests.
But regardless, lifting that restriction even makes the transform
easier to understand.

This makes the transform happen in 81 more cases (+0.55%)
)

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 35bef13ffaae..3083b6929307 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2766,16 +2766,6 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSSAU,
   Cond->getParent() != BB || !Cond->hasOneUse())
 return Changed;
 
-  // Make sure the instruction after the condition is the cond branch.
-  BasicBlock::iterator CondIt = ++Cond->getIterator();
-
-  // Ignore dbg intrinsics.
-  while (isa(CondIt))
-++CondIt;
-
-  if (&*CondIt != BI)
-return Changed;
-
   // Only allow this transformation if computing the condition doesn't involve
   // too many instructions and these involved instructions can be executed
   // unconditionally. We denote all involved instructions except the condition
@@ -2783,12 +2773,15 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSSAU,
   // number of the bonus instructions we'll need to create when cloning into
   // each predecessor does not exceed a certain threshold.
   unsigned NumBonusInsts = 0;
-  for (auto I = BB->begin(); Cond != &*I; ++I) {
-// Ignore dbg intrinsics.
-if (isa(I))
+  for (Instruction &I : *BB) {
+// Don't check the branch condition comparison itself.
+if (&I == Cond)
+  continue;
+// Ignore dbg intrinsics, and the terminator.
+if (isa(I) || isa(I))
   continue;
 // I must be safe to execute unconditionally.
-if (!isSafeToSpeculativelyExecute(&*I))
+if (!isSafeToSpeculativelyExecute(&I))
   return Changed;
 
 // Account for the cost of duplicating this instruction into each
@@ -2896,13 +2889,15 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSSAU,
 // Note that there may be multiple predecessor blocks, so we cannot move
 // bonus instructions to a predecessor block.
 ValueToValueMapTy VMap; // maps original values to cloned values
-// We already make sure Cond is the last instruction before BI. Therefore,
-// all instructions before Cond other than DbgInfoIntrinsic are bonus
-// instructions.
-for (auto BonusInst = BB->begin(); Cond != &*BonusInst; ++BonusInst) {
-  if (isa(BonusInst))
+Instruction *CondInPred;
+for (Instruction &BonusInst : *BB) {
+  if (isa(BonusInst) || isa(BonusInst))
 continue;
-  Instruction *NewBonusInst = BonusInst->clone();
+
+  Instruction *NewBonusInst = BonusInst.clone();
+
+  if (&BonusInst == Cond)
+CondInPred = NewBonusInst;
 
   // When we fold the bonus instructions we want to make sure we
   // reset their debug locations in order to avoid stepping on dead
@@ -2911,7 +2906,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSSAU,
 
   RemapInstruction(NewBonusInst, VMap,
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
-  VMap[&*BonusInst] = NewBonusInst;
+  VMap[&BonusInst] = NewBonusInst;
 
   // If we moved a load, we cannot any longer claim any knowledge about
   // its potential value. The previous information might have been valid
@@ -2921,9 +2916,9 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSSAU,
   NewBonusInst->dropUnknownNonDebugMetadata();
 
   PredBlock->getInstList().insert(PBI->getIterator(), NewBonusInst);
-  NewBonusInst->takeName(&*BonusInst);
-  BonusInst->setName(BonusInst->getName() + ".old");
-  BonusInst->replaceUsesWithIf(NewBonusInst, [BB](Use &U) {
+  NewBonusInst->takeName(&BonusInst);
+  BonusInst.setName(BonusInst.getName() + ".old");
+  BonusInst.replaceUsesWithIf(NewBonusInst, [BB](Use &U) {
 auto *User = cast(U.getUser());
 // Ignore uses in the same block as the bonus instruction itself.
 if (User->getParent() == BB)
@@ -2937,20 +2932,8 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSS

[llvm-branch-commits] [llvm] 0e11f3a - [NFC][InstCombine] Autogenerate sext.ll test checklines

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

Author: Roman Lebedev
Date: 2020-12-01T15:13:06+03:00
New Revision: 0e11f3ade5eaa5ef7fe87014edd3abc708807aba

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

LOG: [NFC][InstCombine] Autogenerate sext.ll test checklines

Added: 


Modified: 
llvm/test/Transforms/InstCombine/sext.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index a85c2ece15b0..55f8217e903e 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -9,7 +9,7 @@ declare i32 @llvm.cttz.i32(i32, i1)
 
 define i64 @test1(i32 %x) {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:[[T:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range !0
+; CHECK-NEXT:[[T:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), 
[[RNG0:!range !.*]]
 ; CHECK-NEXT:[[S:%.*]] = zext i32 [[T]] to i64
 ; CHECK-NEXT:ret i64 [[S]]
 ;
@@ -20,7 +20,7 @@ define i64 @test1(i32 %x) {
 
 define i64 @test2(i32 %x) {
 ; CHECK-LABEL: @test2(
-; CHECK-NEXT:[[T:%.*]] = call i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 true), 
!range !0
+; CHECK-NEXT:[[T:%.*]] = call i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 true), 
[[RNG0]]
 ; CHECK-NEXT:[[S:%.*]] = zext i32 [[T]] to i64
 ; CHECK-NEXT:ret i64 [[S]]
 ;
@@ -31,7 +31,7 @@ define i64 @test2(i32 %x) {
 
 define i64 @test3(i32 %x) {
 ; CHECK-LABEL: @test3(
-; CHECK-NEXT:[[T:%.*]] = call i32 @llvm.cttz.i32(i32 [[X:%.*]], i1 true), 
!range !0
+; CHECK-NEXT:[[T:%.*]] = call i32 @llvm.cttz.i32(i32 [[X:%.*]], i1 true), 
[[RNG0]]
 ; CHECK-NEXT:[[S:%.*]] = zext i32 [[T]] to i64
 ; CHECK-NEXT:ret i64 [[S]]
 ;
@@ -105,11 +105,11 @@ define i32 @test8(i8 %a, i32 %f, i1 %p, i32* %z) {
 define i16 @test9(i16 %t, i1 %cond) {
 ; CHECK-LABEL: @test9(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:br i1 %cond, label %T, label %F
+; CHECK-NEXT:br i1 [[COND:%.*]], label [[T:%.*]], label [[F:%.*]]
 ; CHECK:   T:
-; CHECK-NEXT:br label %F
+; CHECK-NEXT:br label [[F]]
 ; CHECK:   F:
-; CHECK-NEXT:[[V_OFF0:%.*]] = phi i16 [ %t, %T ], [ 42, %entry ]
+; CHECK-NEXT:[[V_OFF0:%.*]] = phi i16 [ [[T:%.*]], [[T]] ], [ 42, 
[[ENTRY:%.*]] ]
 ; CHECK-NEXT:ret i16 [[V_OFF0]]
 ;
 entry:



___
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] 8e29e20 - [InstCombine] Evaluate new shift amount for sext(ashr(shl(trunc()))) fold in wide type (PR48343)

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

Author: Roman Lebedev
Date: 2020-12-01T15:13:07+03:00
New Revision: 8e29e20e0d84719e1ad24f28be458db1d9c858db

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

LOG: [InstCombine] Evaluate new shift amount for sext(ashr(shl(trunc( fold 
in wide type (PR48343)

It is not correct to compute that new shift amount in it's narrow type
and only then extend it into the wide type:


Optimization: PR48343 good
Precondition: (width(%X) == width(%r))
  %o0 = trunc %X
  %o1 = shl %o0, %Y
  %o2 = ashr %o1, %Y
  %r = sext %o2
=>
  %n0 = sext %Y
  %n1 = sub width(%o0), %n0
  %n2 = sub width(%X), %n1
  %n3 = shl %X, %n2
  %r = ashr %n3, %n2

Done: 2016
Optimization is correct!


Optimization: PR48343 bad
Precondition: (width(%X) == width(%r))
  %o0 = trunc %X
  %o1 = shl %o0, %Y
  %o2 = ashr %o1, %Y
  %r = sext %o2
=>
  %n0 = sub width(%o0), %Y
  %n1 = sub width(%X), %n0
  %n2 = sext %n1
  %n3 = shl %X, %n2
  %r = ashr %n3, %n2

Done: 1
ERROR: Domain of definedness of Target is smaller than Source's for i9 %r

Example:
%X i9 = 0x000 (0)
%Y i4 = 0x3 (3)
%o0 i4 = 0x0 (0)
%o1 i4 = 0x0 (0)
%o2 i4 = 0x0 (0)
%n0 i4 = 0x1 (1)
%n1 i4 = 0x8 (8, -8)
%n2 i9 = 0x1F8 (504, -8)
%n3 i9 = 0x000 (0)
Source value: 0x000 (0)
Target value: undef


I.e. we should be computing it in the wide type from the beginning.

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 9bfaa3156edf..59dae932ae49 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1509,25 +1509,26 @@ Instruction *InstCombinerImpl::visitSExt(SExtInst &CI) {
   // for a truncate.  If the source and dest are the same type, eliminate the
   // trunc and extend and just do shifts.  For example, turn:
   //   %a = trunc i32 %i to i8
-  //   %b = shl i8 %a, 6
-  //   %c = ashr i8 %b, 6
+  //   %b = shl i8 %a, C
+  //   %c = ashr i8 %b, C
   //   %d = sext i8 %c to i32
   // into:
-  //   %a = shl i32 %i, 30
-  //   %d = ashr i32 %a, 30
+  //   %a = shl i32 %i, 32-(8-C)
+  //   %d = ashr i32 %a, 32-(8-C)
   Value *A = nullptr;
   // TODO: Eventually this could be subsumed by EvaluateInDifferentType.
   Constant *BA = nullptr, *CA = nullptr;
   if (match(Src, m_AShr(m_Shl(m_Trunc(m_Value(A)), m_Constant(BA)),
 m_Constant(CA))) &&
-  BA == CA && A->getType() == CI.getType()) {
-unsigned MidSize = Src->getType()->getScalarSizeInBits();
-unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
-Constant *SizeDiff = ConstantInt::get(CA->getType(), SrcDstSize - MidSize);
-Constant *ShAmt = ConstantExpr::getAdd(CA, SizeDiff);
-Constant *ShAmtExt = ConstantExpr::getSExt(ShAmt, CI.getType());
-A = Builder.CreateShl(A, ShAmtExt, CI.getName());
-return BinaryOperator::CreateAShr(A, ShAmtExt);
+  BA == CA && A->getType() == DestTy) {
+Constant *WideCurrShAmt = ConstantExpr::getSExt(CA, DestTy);
+Constant *NumLowbitsLeft = ConstantExpr::getSub(
+ConstantInt::get(DestTy, SrcTy->getScalarSizeInBits()), WideCurrShAmt);
+Constant *NewShAmt = ConstantExpr::getSub(
+ConstantInt::get(DestTy, DestTy->getScalarSizeInBits()),
+NumLowbitsLeft);
+A = Builder.CreateShl(A, NewShAmt, CI.getName());
+return BinaryOperator::CreateAShr(A, NewShAmt);
   }
 
   return nullptr;

diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index b2feea73b62c..cf2c44f23810 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -166,8 +166,8 @@ define <2 x i32> @test10_vec_nonuniform(<2 x i32> %i) {
 
 define <2 x i32> @test10_vec_undef(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef(
-; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
-; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>
@@ -281,8 +281,8 @@ define i32 @test18(i16 %x) {
 
 define i10 @test19(i10 %i) {
 ; CHECK-LABEL: @test19(
-; CHECK-NEXT:[[D1:%.*]] = shl i10 [[I:%.*]], 1
-; CHECK-NEXT:[[D:%.*]] = ashr exact i10 [[D1]], 1
+; CHECK-NEXT:[[D1:%.*]] = shl i10 [[I:%.*]], 9
+; CHECK-NEXT:[[D:%.*]] = ashr exact i10 [[D1]], 9
 ; CHECK-NEXT:ret i10 [[D]]
 ;
   %a = trunc i10 %i to i3




[llvm-branch-commits] [llvm] 075faa8 - [NFC][InstCombine] Improve vector undef test coverage for sext(ashr(shl(trunc()))) fold

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

Author: Roman Lebedev
Date: 2020-12-01T15:13:07+03:00
New Revision: 075faa8d40b113d19c3643b3bf2cc74f146612b0

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

LOG: [NFC][InstCombine] Improve vector undef test coverage for 
sext(ashr(shl(trunc( fold

Added: 


Modified: 
llvm/test/Transforms/InstCombine/sext.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index cf2c44f23810..23639e9d9bf6 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -164,8 +164,36 @@ define <2 x i32> @test10_vec_nonuniform(<2 x i32> %i) {
   ret <2 x i32> %D
 }
 
-define <2 x i32> @test10_vec_undef(<2 x i32> %i) {
-; CHECK-LABEL: @test10_vec_undef(
+define <2 x i32> @test10_vec_undef0(<2 x i32> %i) {
+; CHECK-LABEL: @test10_vec_undef0(
+; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
+; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
+; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
+; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
+; CHECK-NEXT:ret <2 x i32> [[D]]
+;
+  %A = trunc <2 x i32> %i to <2 x i8>
+  %B = shl <2 x i8> %A, 
+  %C = ashr <2 x i8> %B, 
+  %D = sext <2 x i8> %C to <2 x i32>
+  ret <2 x i32> %D
+}
+define <2 x i32> @test10_vec_undef1(<2 x i32> %i) {
+; CHECK-LABEL: @test10_vec_undef1(
+; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
+; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
+; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
+; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
+; CHECK-NEXT:ret <2 x i32> [[D]]
+;
+  %A = trunc <2 x i32> %i to <2 x i8>
+  %B = shl <2 x i8> %A, 
+  %C = ashr <2 x i8> %B, 
+  %D = sext <2 x i8> %C to <2 x i32>
+  ret <2 x i32> %D
+}
+define <2 x i32> @test10_vec_undef2(<2 x i32> %i) {
+; CHECK-LABEL: @test10_vec_undef2(
 ; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
 ; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]



___
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] 799626b - [NFC][InstCombine] Add PR48343 miscompiled testcase

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

Author: Roman Lebedev
Date: 2020-12-01T15:13:07+03:00
New Revision: 799626b1117c4cecba7c2c67c1ed7c5f1856fb24

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

LOG: [NFC][InstCombine] Add PR48343 miscompiled testcase

Added: 


Modified: 
llvm/test/Transforms/InstCombine/sext.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index 55f8217e903e..b2feea73b62c 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -279,3 +279,15 @@ define i32 @test18(i16 %x) {
   ret i32 %ext
 }
 
+define i10 @test19(i10 %i) {
+; CHECK-LABEL: @test19(
+; CHECK-NEXT:[[D1:%.*]] = shl i10 [[I:%.*]], 1
+; CHECK-NEXT:[[D:%.*]] = ashr exact i10 [[D1]], 1
+; CHECK-NEXT:ret i10 [[D]]
+;
+  %a = trunc i10 %i to i3
+  %b = shl i3 %a, 2
+  %c = ashr i3 %b, 2
+  %d = sext i3 %c to i10
+  ret i10 %d
+}



___
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] aa1aa13 - [InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold

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

Author: Roman Lebedev
Date: 2020-12-01T15:13:08+03:00
New Revision: aa1aa135097ecfab6d9917a435142030eff0a226

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

LOG: [InstCombine] Improve vector undef handling for sext(ashr(shl(trunc( 
fold

If the shift amount was undef for some lane, the shift amount in opposite
shift is irrelevant for that lane, and the new shift amount for that lane
can be undef.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 59dae932ae49..6e94e5823433 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1520,13 +1520,15 @@ Instruction *InstCombinerImpl::visitSExt(SExtInst &CI) {
   Constant *BA = nullptr, *CA = nullptr;
   if (match(Src, m_AShr(m_Shl(m_Trunc(m_Value(A)), m_Constant(BA)),
 m_Constant(CA))) &&
-  BA == CA && A->getType() == DestTy) {
+  BA->isElementWiseEqual(CA) && A->getType() == DestTy) {
 Constant *WideCurrShAmt = ConstantExpr::getSExt(CA, DestTy);
 Constant *NumLowbitsLeft = ConstantExpr::getSub(
 ConstantInt::get(DestTy, SrcTy->getScalarSizeInBits()), WideCurrShAmt);
 Constant *NewShAmt = ConstantExpr::getSub(
 ConstantInt::get(DestTy, DestTy->getScalarSizeInBits()),
 NumLowbitsLeft);
+NewShAmt =
+Constant::mergeUndefsWith(Constant::mergeUndefsWith(NewShAmt, BA), CA);
 A = Builder.CreateShl(A, NewShAmt, CI.getName());
 return BinaryOperator::CreateAShr(A, NewShAmt);
   }

diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index 23639e9d9bf6..31923fd70597 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -166,10 +166,8 @@ define <2 x i32> @test10_vec_nonuniform(<2 x i32> %i) {
 
 define <2 x i32> @test10_vec_undef0(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef0(
-; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
-; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
-; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
-; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>
@@ -180,10 +178,8 @@ define <2 x i32> @test10_vec_undef0(<2 x i32> %i) {
 }
 define <2 x i32> @test10_vec_undef1(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef1(
-; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
-; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
-; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
-; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>
@@ -194,8 +190,8 @@ define <2 x i32> @test10_vec_undef1(<2 x i32> %i) {
 }
 define <2 x i32> @test10_vec_undef2(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef2(
-; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
-; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>



___
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] 55c06a3 - [NFC][InstCombine] sext.ll: @test9: avoid only differently-cased names for values and block names

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

Author: Roman Lebedev
Date: 2020-12-01T15:33:12+03:00
New Revision: 55c06a3070340124a726d1d030559856ed2da168

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

LOG: [NFC][InstCombine] sext.ll: @test9: avoid only differently-cased names for 
values and block names

Added: 


Modified: 
llvm/test/Transforms/InstCombine/sext.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index 31923fd70597..ebab23a19525 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -105,21 +105,22 @@ define i32 @test8(i8 %a, i32 %f, i1 %p, i32* %z) {
 define i16 @test9(i16 %t, i1 %cond) {
 ; CHECK-LABEL: @test9(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:br i1 [[COND:%.*]], label [[T:%.*]], label [[F:%.*]]
-; CHECK:   T:
-; CHECK-NEXT:br label [[F]]
-; CHECK:   F:
-; CHECK-NEXT:[[V_OFF0:%.*]] = phi i16 [ [[T:%.*]], [[T]] ], [ 42, 
[[ENTRY:%.*]] ]
+; CHECK-NEXT:br i1 [[COND:%.*]], label [[TBB:%.*]], label [[FBB:%.*]]
+; CHECK:   TBB:
+; CHECK-NEXT:br label [[FBB]]
+; CHECK:   FBB:
+; CHECK-NEXT:[[V_OFF0:%.*]] = phi i16 [ [[T:%.*]], [[TBB]] ], [ 42, 
[[ENTRY:%.*]] ]
 ; CHECK-NEXT:ret i16 [[V_OFF0]]
 ;
 entry:
-  br i1 %cond, label %T, label %F
-T:
+  br i1 %cond, label %TBB, label %FBB
+
+TBB:
   %t2 = sext i16 %t to i32
-  br label %F
+  br label %FBB
 
-F:
-  %V = phi i32 [%t2, %T], [42, %entry]
+FBB:
+  %V = phi i32 [%t2, %TBB], [42, %entry]
   %W = trunc i32 %V to i16
   ret i16 %W
 }



___
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] 52533b5 - Revert "[InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold"

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

Author: Roman Lebedev
Date: 2020-12-01T15:47:04+03:00
New Revision: 52533b52b868e055fe86061cf71a49601d0cbeb9

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

LOG: Revert "[InstCombine] Improve vector undef handling for 
sext(ashr(shl(trunc( fold"

It seems i have missed checklines, temporairly reverting,
will reland momentairly..

This reverts commit aa1aa135097ecfab6d9917a435142030eff0a226.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 6e94e5823433..59dae932ae49 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1520,15 +1520,13 @@ Instruction *InstCombinerImpl::visitSExt(SExtInst &CI) {
   Constant *BA = nullptr, *CA = nullptr;
   if (match(Src, m_AShr(m_Shl(m_Trunc(m_Value(A)), m_Constant(BA)),
 m_Constant(CA))) &&
-  BA->isElementWiseEqual(CA) && A->getType() == DestTy) {
+  BA == CA && A->getType() == DestTy) {
 Constant *WideCurrShAmt = ConstantExpr::getSExt(CA, DestTy);
 Constant *NumLowbitsLeft = ConstantExpr::getSub(
 ConstantInt::get(DestTy, SrcTy->getScalarSizeInBits()), WideCurrShAmt);
 Constant *NewShAmt = ConstantExpr::getSub(
 ConstantInt::get(DestTy, DestTy->getScalarSizeInBits()),
 NumLowbitsLeft);
-NewShAmt =
-Constant::mergeUndefsWith(Constant::mergeUndefsWith(NewShAmt, BA), CA);
 A = Builder.CreateShl(A, NewShAmt, CI.getName());
 return BinaryOperator::CreateAShr(A, NewShAmt);
   }

diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index ebab23a19525..319c07d9f8a9 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -167,8 +167,10 @@ define <2 x i32> @test10_vec_nonuniform(<2 x i32> %i) {
 
 define <2 x i32> @test10_vec_undef0(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef0(
-; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
-; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
+; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
+; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
+; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
+; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>
@@ -179,8 +181,10 @@ define <2 x i32> @test10_vec_undef0(<2 x i32> %i) {
 }
 define <2 x i32> @test10_vec_undef1(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef1(
-; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
-; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
+; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
+; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
+; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
+; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>
@@ -191,8 +195,8 @@ define <2 x i32> @test10_vec_undef1(<2 x i32> %i) {
 }
 define <2 x i32> @test10_vec_undef2(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef2(
-; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
-; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>



___
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] 2ca4785 - Remove rm -f cortex-a57-misched-mla.s; hopefully the bots have all cycled past it now

2020-12-01 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2020-12-01T13:50:49+01:00
New Revision: 2ca4785ac7001204f2c63a6f5764c4294ff4891d

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

LOG: Remove rm -f cortex-a57-misched-mla.s; hopefully the bots have all cycled 
past it now

Added: 


Modified: 
llvm/test/CodeGen/ARM/cortex-a57-misched-mla.mir

Removed: 




diff  --git a/llvm/test/CodeGen/ARM/cortex-a57-misched-mla.mir 
b/llvm/test/CodeGen/ARM/cortex-a57-misched-mla.mir
index ffb0c98055e35..1b40a0b8effb1 100644
--- a/llvm/test/CodeGen/ARM/cortex-a57-misched-mla.mir
+++ b/llvm/test/CodeGen/ARM/cortex-a57-misched-mla.mir
@@ -1,9 +1,6 @@
 # REQUIRES: asserts
 # RUN: llc -mcpu=cortex-a57 -mtriple=thumb -enable-misched 
-run-pass=machine-scheduler -debug-only=machine-scheduler %s -o - 2>&1 | 
FileCheck %s
 
-# TODO: Remove once bots have removed the output file left by 112b3cb
-# RUN: rm -f %S/cortex-a57-misched-mla.s
-
 # CHECK-LABEL: ** MI Scheduling **
 # CHECK:   %[[RES:[0-9]+]]:rgpr = t2MLA
 # CHECK-NEXT:  # preds left



___
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] b2cdd77 - [InstCombine] add tests for sign-bit-shift-of-sub; NFC

2020-12-01 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-01T08:01:00-05:00
New Revision: b2cdd776e3e5a709d5904633956d3e9eaad78020

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

LOG: [InstCombine] add tests for sign-bit-shift-of-sub; NFC

Added: 


Modified: 
llvm/test/Transforms/InstCombine/ashr-lshr.ll
llvm/test/Transforms/InstCombine/lshr.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/ashr-lshr.ll 
b/llvm/test/Transforms/InstCombine/ashr-lshr.ll
index ee90dd5170c3..dc1deb043428 100644
--- a/llvm/test/Transforms/InstCombine/ashr-lshr.ll
+++ b/llvm/test/Transforms/InstCombine/ashr-lshr.ll
@@ -434,3 +434,139 @@ define <2 x i32> @ashr_lshr_inv_vec_wrong_pred(<2 x i32> 
%x, <2 x i32> %y) {
   %ret = select <2 x i1> %cmp, <2 x i32> %r, <2 x i32> %l
   ret <2 x i32> %ret
 }
+
+define i32 @lshr_sub_nsw(i32 %x, i32 %y) {
+; CHECK-LABEL: @lshr_sub_nsw(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = lshr i32 [[SUB]], 31
+; CHECK-NEXT:ret i32 [[SHR]]
+;
+  %sub = sub nsw i32 %x, %y
+  %shr = lshr i32 %sub, 31
+  ret i32 %shr
+}
+
+define i32 @lshr_sub_wrong_amount(i32 %x, i32 %y) {
+; CHECK-LABEL: @lshr_sub_wrong_amount(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = lshr i32 [[SUB]], 30
+; CHECK-NEXT:ret i32 [[SHR]]
+;
+  %sub = sub nsw i32 %x, %y
+  %shr = lshr i32 %sub, 30
+  ret i32 %shr
+}
+
+define i32 @lshr_sub(i32 %x, i32 %y) {
+; CHECK-LABEL: @lshr_sub(
+; CHECK-NEXT:[[SUB:%.*]] = sub i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = lshr i32 [[SUB]], 31
+; CHECK-NEXT:ret i32 [[SHR]]
+;
+  %sub = sub i32 %x, %y
+  %shr = lshr i32 %sub, 31
+  ret i32 %shr
+}
+
+define i32 @lshr_sub_nsw_extra_use(i32 %x, i32 %y, i32* %p) {
+; CHECK-LABEL: @lshr_sub_nsw_extra_use(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:store i32 [[SUB]], i32* [[P:%.*]], align 4
+; CHECK-NEXT:[[SHR:%.*]] = lshr i32 [[SUB]], 31
+; CHECK-NEXT:ret i32 [[SHR]]
+;
+  %sub = sub nsw i32 %x, %y
+  store i32 %sub, i32* %p
+  %shr = lshr i32 %sub, 31
+  ret i32 %shr
+}
+
+define <3 x i42> @lshr_sub_nsw_splat(<3 x i42> %x, <3 x i42> %y) {
+; CHECK-LABEL: @lshr_sub_nsw_splat(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw <3 x i42> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = lshr <3 x i42> [[SUB]], 
+; CHECK-NEXT:ret <3 x i42> [[SHR]]
+;
+  %sub = sub nsw <3 x i42> %x, %y
+  %shr = lshr <3 x i42> %sub, 
+  ret <3 x i42> %shr
+}
+
+define <3 x i42> @lshr_sub_nsw_splat_undef(<3 x i42> %x, <3 x i42> %y) {
+; CHECK-LABEL: @lshr_sub_nsw_splat_undef(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw <3 x i42> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = lshr <3 x i42> [[SUB]], 
+; CHECK-NEXT:ret <3 x i42> [[SHR]]
+;
+  %sub = sub nsw <3 x i42> %x, %y
+  %shr = lshr <3 x i42> %sub, 
+  ret <3 x i42> %shr
+}
+
+define i17 @ashr_sub_nsw(i17 %x, i17 %y) {
+; CHECK-LABEL: @ashr_sub_nsw(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw i17 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = ashr i17 [[SUB]], 16
+; CHECK-NEXT:ret i17 [[SHR]]
+;
+  %sub = sub nsw i17 %x, %y
+  %shr = ashr i17 %sub, 16
+  ret i17 %shr
+}
+
+define i17 @ashr_sub_wrong_amount(i17 %x, i17 %y) {
+; CHECK-LABEL: @ashr_sub_wrong_amount(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw i17 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = ashr i17 [[SUB]], 15
+; CHECK-NEXT:ret i17 [[SHR]]
+;
+  %sub = sub nsw i17 %x, %y
+  %shr = ashr i17 %sub, 15
+  ret i17 %shr
+}
+
+define i32 @ashr_sub(i32 %x, i32 %y) {
+; CHECK-LABEL: @ashr_sub(
+; CHECK-NEXT:[[SUB:%.*]] = sub i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SUB]], 31
+; CHECK-NEXT:ret i32 [[SHR]]
+;
+  %sub = sub i32 %x, %y
+  %shr = ashr i32 %sub, 31
+  ret i32 %shr
+}
+
+define i32 @ashr_sub_nsw_extra_use(i32 %x, i32 %y, i32* %p) {
+; CHECK-LABEL: @ashr_sub_nsw_extra_use(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:store i32 [[SUB]], i32* [[P:%.*]], align 4
+; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SUB]], 31
+; CHECK-NEXT:ret i32 [[SHR]]
+;
+  %sub = sub nsw i32 %x, %y
+  store i32 %sub, i32* %p
+  %shr = ashr i32 %sub, 31
+  ret i32 %shr
+}
+
+define <3 x i43> @ashr_sub_nsw_splat(<3 x i43> %x, <3 x i43> %y) {
+; CHECK-LABEL: @ashr_sub_nsw_splat(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw <3 x i43> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = ashr <3 x i43> [[SUB]], 
+; CHECK-NEXT:ret <3 x i43> [[SHR]]
+;
+  %sub = sub nsw <3 x i43> %x, %y
+  %shr = ashr <3 x i43> %sub, 
+  ret <3 x i43> %shr
+}
+
+define <3 x i43> @ashr_sub_nsw_splat_undef(<3 x i43> %x, <3 x i43> %y) {
+; CHECK-LABEL: @ashr_sub_nsw_splat_undef(
+; CHECK-NEXT:[[SUB:%.*]] = sub nsw 

[llvm-branch-commits] [openmp] 6bf8487 - [OpenMP] libomp: add UNLIKELY hints to rarely executed branches

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

Author: AndreyChurbanov
Date: 2020-12-01T16:53:21+03:00
New Revision: 6bf84871e9382fe7bde1117194bc15abb2b09f68

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

LOG: [OpenMP] libomp: add UNLIKELY hints to rarely executed branches

Added UNLIKELY hint to one-time or rarely executed branches.
This improves performance of the library on some tasking benchmarks.

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

Added: 


Modified: 
openmp/runtime/src/kmp_itt.inl
openmp/runtime/src/kmp_tasking.cpp

Removed: 




diff  --git a/openmp/runtime/src/kmp_itt.inl b/openmp/runtime/src/kmp_itt.inl
index 29a05cb86a3f..6257cea4faf3 100644
--- a/openmp/runtime/src/kmp_itt.inl
+++ b/openmp/runtime/src/kmp_itt.inl
@@ -630,7 +630,7 @@ void __kmp_itt_barrier_finished(int gtid, void *object) {
 void *__kmp_itt_taskwait_object(int gtid) {
   void *object = NULL;
 #if USE_ITT_NOTIFY
-  if (__itt_sync_create_ptr) {
+  if (UNLIKELY(__itt_sync_create_ptr)) {
 kmp_info_t *thread = __kmp_thread_from_gtid(gtid);
 kmp_taskdata_t *taskdata = thread->th.th_current_task;
 object = reinterpret_cast(kmp_uintptr_t(taskdata) +
@@ -677,7 +677,7 @@ void __kmp_itt_task_starting(
 void *object // ITT sync object: barrier or taskwait.
 ) {
 #if USE_ITT_NOTIFY
-  if (object != NULL) {
+  if (UNLIKELY(object != NULL)) {
 KMP_ITT_DEBUG_LOCK();
 __itt_sync_cancel(object);
 KMP_ITT_DEBUG_PRINT("[tsk sta] scan( %p )\n", object);

diff  --git a/openmp/runtime/src/kmp_tasking.cpp 
b/openmp/runtime/src/kmp_tasking.cpp
index 283bb934cd8f..41421d6765e0 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -275,7 +275,7 @@ static bool __kmp_task_is_allowed(int gtid, const kmp_int32 
is_constrained,
   }
   // Check mutexinoutset dependencies, acquire locks
   kmp_depnode_t *node = tasknew->td_depnode;
-  if (node && (node->dn.mtx_num_locks > 0)) {
+  if (UNLIKELY(node && (node->dn.mtx_num_locks > 0))) {
 for (int i = 0; i < node->dn.mtx_num_locks; ++i) {
   KMP_DEBUG_ASSERT(node->dn.mtx_locks[i] != NULL);
   if (__kmp_test_lock(node->dn.mtx_locks[i], gtid))
@@ -332,7 +332,7 @@ static kmp_int32 __kmp_push_task(kmp_int32 gtid, kmp_task_t 
*task) {
   KA_TRACE(20,
("__kmp_push_task: T#%d trying to push task %p.\n", gtid, 
taskdata));
 
-  if (taskdata->td_flags.tiedness == TASK_UNTIED) {
+  if (UNLIKELY(taskdata->td_flags.tiedness == TASK_UNTIED)) {
 // untied task needs to increment counter so that the task structure is not
 // freed prematurely
 kmp_int32 counter = 1 + KMP_ATOMIC_INC(&taskdata->td_untied_count);
@@ -344,7 +344,7 @@ static kmp_int32 __kmp_push_task(kmp_int32 gtid, kmp_task_t 
*task) {
   }
 
   // The first check avoids building task_team thread data if serialized
-  if (taskdata->td_flags.task_serial) {
+  if (UNLIKELY(taskdata->td_flags.task_serial)) {
 KA_TRACE(20, ("__kmp_push_task: T#%d team serialized; returning "
   "TASK_NOT_PUSHED for task %p\n",
   gtid, taskdata));
@@ -354,7 +354,7 @@ static kmp_int32 __kmp_push_task(kmp_int32 gtid, kmp_task_t 
*task) {
   // Now that serialized tasks have returned, we can assume that we are not in
   // immediate exec mode
   KMP_DEBUG_ASSERT(__kmp_tasking_mode != tskm_immediate_exec);
-  if (!KMP_TASKING_ENABLED(task_team)) {
+  if (UNLIKELY(!KMP_TASKING_ENABLED(task_team))) {
 __kmp_enable_tasking(task_team, thread);
   }
   KMP_DEBUG_ASSERT(TCR_4(task_team->tt.tt_found_tasks) == TRUE);
@@ -364,7 +364,7 @@ static kmp_int32 __kmp_push_task(kmp_int32 gtid, kmp_task_t 
*task) {
   thread_data = &task_team->tt.tt_threads_data[tid];
 
   // No lock needed since only owner can allocate
-  if (thread_data->td.td_deque == NULL) {
+  if (UNLIKELY(thread_data->td.td_deque == NULL)) {
 __kmp_alloc_task_deque(thread, thread_data);
   }
 
@@ -824,7 +824,7 @@ static void __kmp_task_finish(kmp_int32 gtid, kmp_task_t 
*task,
   }
 #endif /* BUILD_TIED_TASK_STACK */
 
-  if (taskdata->td_flags.tiedness == TASK_UNTIED) {
+  if (UNLIKELY(taskdata->td_flags.tiedness == TASK_UNTIED)) {
 // untied task needs to check the counter so that the task structure is not
 // freed prematurely
 kmp_int32 counter = KMP_ATOMIC_DEC(&taskdata->td_untied_count) - 1;
@@ -1175,7 +1175,7 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 
gtid,
   kmp_taskdata_t *parent_task = thread->th.th_current_task;
   size_t shareds_offset;
 
-  if (!TCR_4(__kmp_init_middle))
+  if (UNLIKELY(!TCR_4(__kmp_init_middle)))
 __kmp_middle_initialize();
 
   KA_TRACE(10, ("__kmp_task_alloc(enter): T#%d loc=%p, flags=(0x%x) "
@@ -1433,8 +1433,8 @@ static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t 
*task,
   30, ("__kmp_invoke_task(ent

[llvm-branch-commits] [llvm] 94ead01 - [InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold, 2

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

Author: Roman Lebedev
Date: 2020-12-01T16:54:00+03:00
New Revision: 94ead0190ff18be337c5c84abccc315fd68f41fc

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

LOG: [InstCombine] Improve vector undef handling for sext(ashr(shl(trunc( 
fold, 2

If the shift amount was undef for some lane, the shift amount in opposite
shift is irrelevant for that lane, and the new shift amount for that lane
can be undef.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/sext.ll
llvm/test/Transforms/InstCombine/trunc.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 59dae932ae49..6e94e5823433 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1520,13 +1520,15 @@ Instruction *InstCombinerImpl::visitSExt(SExtInst &CI) {
   Constant *BA = nullptr, *CA = nullptr;
   if (match(Src, m_AShr(m_Shl(m_Trunc(m_Value(A)), m_Constant(BA)),
 m_Constant(CA))) &&
-  BA == CA && A->getType() == DestTy) {
+  BA->isElementWiseEqual(CA) && A->getType() == DestTy) {
 Constant *WideCurrShAmt = ConstantExpr::getSExt(CA, DestTy);
 Constant *NumLowbitsLeft = ConstantExpr::getSub(
 ConstantInt::get(DestTy, SrcTy->getScalarSizeInBits()), WideCurrShAmt);
 Constant *NewShAmt = ConstantExpr::getSub(
 ConstantInt::get(DestTy, DestTy->getScalarSizeInBits()),
 NumLowbitsLeft);
+NewShAmt =
+Constant::mergeUndefsWith(Constant::mergeUndefsWith(NewShAmt, BA), CA);
 A = Builder.CreateShl(A, NewShAmt, CI.getName());
 return BinaryOperator::CreateAShr(A, NewShAmt);
   }

diff  --git a/llvm/test/Transforms/InstCombine/sext.ll 
b/llvm/test/Transforms/InstCombine/sext.ll
index 319c07d9f8a9..ebab23a19525 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -167,10 +167,8 @@ define <2 x i32> @test10_vec_nonuniform(<2 x i32> %i) {
 
 define <2 x i32> @test10_vec_undef0(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef0(
-; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
-; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
-; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
-; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>
@@ -181,10 +179,8 @@ define <2 x i32> @test10_vec_undef0(<2 x i32> %i) {
 }
 define <2 x i32> @test10_vec_undef1(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef1(
-; CHECK-NEXT:[[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8>
-; CHECK-NEXT:[[B:%.*]] = shl <2 x i8> [[A]], 
-; CHECK-NEXT:[[C:%.*]] = ashr <2 x i8> [[B]], 
-; CHECK-NEXT:[[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32>
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>
@@ -195,8 +191,8 @@ define <2 x i32> @test10_vec_undef1(<2 x i32> %i) {
 }
 define <2 x i32> @test10_vec_undef2(<2 x i32> %i) {
 ; CHECK-LABEL: @test10_vec_undef2(
-; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
-; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i32> [[I:%.*]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i32> [[D1]], 
 ; CHECK-NEXT:ret <2 x i32> [[D]]
 ;
   %A = trunc <2 x i32> %i to <2 x i8>

diff  --git a/llvm/test/Transforms/InstCombine/trunc.ll 
b/llvm/test/Transforms/InstCombine/trunc.ll
index d9b02eaa1698..fc13d86bcfc3 100644
--- a/llvm/test/Transforms/InstCombine/trunc.ll
+++ b/llvm/test/Transforms/InstCombine/trunc.ll
@@ -114,8 +114,8 @@ define <2 x i64> @test2_vec_nonuniform(<2 x i64> %a) {
 define <2 x i64> @test2_vec_undef(<2 x i64> %a) {
 ; CHECK-LABEL: @test2_vec_undef(
 ; CHECK-NEXT:[[B:%.*]] = trunc <2 x i64> [[A:%.*]] to <2 x i32>
-; CHECK-NEXT:[[D1:%.*]] = shl <2 x i64> [[A]], 
-; CHECK-NEXT:[[D:%.*]] = ashr <2 x i64> [[D1]], 
+; CHECK-NEXT:[[D1:%.*]] = shl <2 x i64> [[A]], 
+; CHECK-NEXT:[[D:%.*]] = ashr <2 x i64> [[D1]], 
 ; CHECK-NEXT:call void @use_vec(<2 x i32> [[B]])
 ; CHECK-NEXT:ret <2 x i64> [[D]]
 ;



___
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] fd67910 - [InstCombine] Optimize away the unnecessary multi-use sign-extend

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

Author: Bhramar Vatsa
Date: 2020-12-01T16:54:00+03:00
New Revision: fd679107d670d8fd31b62245b433187b4d72a9d0

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

LOG: [InstCombine] Optimize away the unnecessary multi-use sign-extend

C.f. https://bugs.llvm.org/show_bug.cgi?id=47765

Added a case for handling the sign-extend (Shl+AShr) for multiple uses,
to optimize it away for an individual use,
when the demanded bits aren't affected by sign-extend.

https://rise4fun.com/Alive/lgf

Reviewed By: lebedev.ri

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

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/test/Transforms/InstCombine/and.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 3f2a6f8eb2ea..5b0a4857f33d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -899,6 +899,33 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
 
 break;
   }
+  case Instruction::AShr: {
+// Compute the Known bits to simplify things downstream.
+computeKnownBits(I, Known, Depth, CxtI);
+
+// If this user is only demanding bits that we know, return the known
+// constant.
+if (DemandedMask.isSubsetOf(Known.Zero | Known.One))
+  return Constant::getIntegerValue(ITy, Known.One);
+
+// If the right shift operand 0 is a result of a left shift by the same
+// amount, this is probably a zero/sign extension, which may be 
unnecessary,
+// if we do not demand any of the new sign bits. So, return the original
+// operand instead.
+const APInt *ShiftRC;
+const APInt *ShiftLC;
+Value *X;
+unsigned BitWidth = DemandedMask.getBitWidth();
+if (match(I,
+  m_AShr(m_Shl(m_Value(X), m_APInt(ShiftLC)), m_APInt(ShiftRC))) &&
+ShiftLC == ShiftRC &&
+DemandedMask.isSubsetOf(APInt::getLowBitsSet(
+BitWidth, BitWidth - ShiftRC->getZExtValue( {
+  return X;
+}
+
+break;
+  }
   default:
 // Compute the Known bits to simplify things downstream.
 computeKnownBits(I, Known, Depth, CxtI);

diff  --git a/llvm/test/Transforms/InstCombine/and.ll 
b/llvm/test/Transforms/InstCombine/and.ll
index ed50ae16350d..020dbc483d9d 100644
--- a/llvm/test/Transforms/InstCombine/and.ll
+++ b/llvm/test/Transforms/InstCombine/and.ll
@@ -979,7 +979,7 @@ define i32 @lowmask_sext_in_reg(i32 %x) {
 ; CHECK-NEXT:[[L:%.*]] = shl i32 [[X:%.*]], 20
 ; CHECK-NEXT:[[R:%.*]] = ashr exact i32 [[L]], 20
 ; CHECK-NEXT:call void @use32(i32 [[R]])
-; CHECK-NEXT:[[AND:%.*]] = and i32 [[R]], 4095
+; CHECK-NEXT:[[AND:%.*]] = and i32 [[X]], 4095
 ; CHECK-NEXT:ret i32 [[AND]]
 ;
   %l = shl i32 %x, 20
@@ -989,6 +989,8 @@ define i32 @lowmask_sext_in_reg(i32 %x) {
   ret i32 %and
 }
 
+; Negative test - mismatched shift amounts
+
 define i32 @lowmask_not_sext_in_reg(i32 %x) {
 ; CHECK-LABEL: @lowmask_not_sext_in_reg(
 ; CHECK-NEXT:[[L:%.*]] = shl i32 [[X:%.*]], 19
@@ -1004,6 +1006,8 @@ define i32 @lowmask_not_sext_in_reg(i32 %x) {
   ret i32 %and
 }
 
+; Negative test - too much shift for mask
+
 define i32 @not_lowmask_sext_in_reg(i32 %x) {
 ; CHECK-LABEL: @not_lowmask_sext_in_reg(
 ; CHECK-NEXT:[[L:%.*]] = shl i32 [[X:%.*]], 20
@@ -1019,6 +1023,8 @@ define i32 @not_lowmask_sext_in_reg(i32 %x) {
   ret i32 %and
 }
 
+; Negative test - too much shift for mask
+
 define i32 @not_lowmask_sext_in_reg2(i32 %x) {
 ; CHECK-LABEL: @not_lowmask_sext_in_reg2(
 ; CHECK-NEXT:[[L:%.*]] = shl i32 [[X:%.*]], 21
@@ -1039,7 +1045,7 @@ define <2 x i32> @lowmask_sext_in_reg_splat(<2 x i32> %x, 
<2 x i32>* %p) {
 ; CHECK-NEXT:[[L:%.*]] = shl <2 x i32> [[X:%.*]], 
 ; CHECK-NEXT:[[R:%.*]] = ashr exact <2 x i32> [[L]], 
 ; CHECK-NEXT:store <2 x i32> [[R]], <2 x i32>* [[P:%.*]], align 8
-; CHECK-NEXT:[[AND:%.*]] = and <2 x i32> [[R]], 
+; CHECK-NEXT:[[AND:%.*]] = and <2 x i32> [[X]], 
 ; CHECK-NEXT:ret <2 x i32> [[AND]]
 ;
   %l = shl <2 x i32> %x, 



___
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] 00f4269 - [X86] Add PR48223 usubsat test case

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

Author: Simon Pilgrim
Date: 2020-12-01T13:57:08Z
New Revision: 00f4269cef3773df932158728de9fe07d2f7ff41

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

LOG: [X86] Add PR48223 usubsat test case

Added: 


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

Removed: 




diff  --git a/llvm/test/CodeGen/X86/usub_sat_vec.ll 
b/llvm/test/CodeGen/X86/usub_sat_vec.ll
index 6d54503f8509..63482cff994c 100644
--- a/llvm/test/CodeGen/X86/usub_sat_vec.ll
+++ b/llvm/test/CodeGen/X86/usub_sat_vec.ll
@@ -1108,3 +1108,84 @@ define <2 x i128> @v2i128(<2 x i128> %x, <2 x i128> %y) 
nounwind {
   %z = call <2 x i128> @llvm.usub.sat.v2i128(<2 x i128> %x, <2 x i128> %y)
   ret <2 x i128> %z
 }
+
+define void @PR48223(<32 x i16>* %p0) {
+; SSE-LABEL: PR48223:
+; SSE:   # %bb.0:
+; SSE-NEXT:movdqa (%rdi), %xmm0
+; SSE-NEXT:movdqa 16(%rdi), %xmm1
+; SSE-NEXT:movdqa 32(%rdi), %xmm2
+; SSE-NEXT:movdqa 48(%rdi), %xmm3
+; SSE-NEXT:movdqa {{.*#+}} xmm4 = [64,64,64,64,64,64,64,64]
+; SSE-NEXT:psubusw %xmm4, %xmm1
+; SSE-NEXT:psubusw %xmm4, %xmm0
+; SSE-NEXT:psubusw %xmm4, %xmm3
+; SSE-NEXT:psubusw %xmm4, %xmm2
+; SSE-NEXT:movdqa %xmm2, 32(%rdi)
+; SSE-NEXT:movdqa %xmm3, 48(%rdi)
+; SSE-NEXT:movdqa %xmm0, (%rdi)
+; SSE-NEXT:movdqa %xmm1, 16(%rdi)
+; SSE-NEXT:retq
+;
+; AVX1-LABEL: PR48223:
+; AVX1:   # %bb.0:
+; AVX1-NEXT:vmovdqa (%rdi), %xmm0
+; AVX1-NEXT:vmovdqa 16(%rdi), %xmm1
+; AVX1-NEXT:vmovdqa 32(%rdi), %xmm2
+; AVX1-NEXT:vmovdqa 48(%rdi), %xmm3
+; AVX1-NEXT:vmovdqa {{.*#+}} xmm4 = [64,64,64,64,64,64,64,64]
+; AVX1-NEXT:vpsubusw %xmm4, %xmm3, %xmm3
+; AVX1-NEXT:vpsubusw %xmm4, %xmm2, %xmm2
+; AVX1-NEXT:vpsubusw %xmm4, %xmm1, %xmm1
+; AVX1-NEXT:vpsubusw %xmm4, %xmm0, %xmm0
+; AVX1-NEXT:vmovdqa %xmm0, (%rdi)
+; AVX1-NEXT:vmovdqa %xmm1, 16(%rdi)
+; AVX1-NEXT:vmovdqa %xmm2, 32(%rdi)
+; AVX1-NEXT:vmovdqa %xmm3, 48(%rdi)
+; AVX1-NEXT:retq
+;
+; AVX2-LABEL: PR48223:
+; AVX2:   # %bb.0:
+; AVX2-NEXT:vmovdqa (%rdi), %ymm0
+; AVX2-NEXT:vmovdqa 32(%rdi), %ymm1
+; AVX2-NEXT:vmovdqa {{.*#+}} ymm2 = 
[64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64]
+; AVX2-NEXT:vpsubusw %ymm2, %ymm1, %ymm1
+; AVX2-NEXT:vpsubusw %ymm2, %ymm0, %ymm0
+; AVX2-NEXT:vmovdqa %ymm0, (%rdi)
+; AVX2-NEXT:vmovdqa %ymm1, 32(%rdi)
+; AVX2-NEXT:vzeroupper
+; AVX2-NEXT:retq
+;
+; AVX512F-LABEL: PR48223:
+; AVX512F:   # %bb.0:
+; AVX512F-NEXT:vmovdqa (%rdi), %ymm0
+; AVX512F-NEXT:vmovdqa 32(%rdi), %ymm1
+; AVX512F-NEXT:vmovdqa {{.*#+}} ymm2 = 
[64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64]
+; AVX512F-NEXT:vpmaxuw %ymm2, %ymm1, %ymm3
+; AVX512F-NEXT:vpcmpeqw %ymm3, %ymm1, %ymm3
+; AVX512F-NEXT:vpmaxuw %ymm2, %ymm0, %ymm2
+; AVX512F-NEXT:vpcmpeqw %ymm2, %ymm0, %ymm2
+; AVX512F-NEXT:vinserti64x4 $1, %ymm3, %zmm2, %zmm2
+; AVX512F-NEXT:vmovdqa {{.*#+}} ymm3 = 
[65472,65472,65472,65472,65472,65472,65472,65472,65472,65472,65472,65472,65472,65472,65472,65472]
+; AVX512F-NEXT:vpaddw %ymm3, %ymm1, %ymm1
+; AVX512F-NEXT:vpaddw %ymm3, %ymm0, %ymm0
+; AVX512F-NEXT:vinserti64x4 $1, %ymm1, %zmm0, %zmm0
+; AVX512F-NEXT:vpandq %zmm0, %zmm2, %zmm0
+; AVX512F-NEXT:vmovdqa64 %zmm0, (%rdi)
+; AVX512F-NEXT:vzeroupper
+; AVX512F-NEXT:retq
+;
+; AVX512BW-LABEL: PR48223:
+; AVX512BW:   # %bb.0:
+; AVX512BW-NEXT:vmovdqa64 (%rdi), %zmm0
+; AVX512BW-NEXT:vpsubusw {{.*}}(%rip), %zmm0, %zmm0
+; AVX512BW-NEXT:vmovdqa64 %zmm0, (%rdi)
+; AVX512BW-NEXT:vzeroupper
+; AVX512BW-NEXT:retq
+  %1 = load <32 x i16>, <32 x i16>* %p0, align 64
+  %2 = icmp ugt <32 x i16> %1, 
+  %3 = add <32 x i16> %1, 
+  %4 = select <32 x i1> %2, <32 x i16> %3, <32 x i16> zeroinitializer
+  store <32 x i16> %4, <32 x i16>* %p0, align 64
+  ret void
+}



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


[llvm-branch-commits] [compiler-rt] 17427ec - [RISCV][crt] support building without init_array

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

Author: Alexey Baturo
Date: 2020-12-01T17:17:50+03:00
New Revision: 17427ec3f31c2a95c106dbaa98c43b72a7c06a31

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

LOG: [RISCV][crt] support building without init_array

Reviewed By: luismarques, phosek, kito-cheng

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

Added: 


Modified: 
compiler-rt/lib/crt/crtbegin.c

Removed: 




diff  --git a/compiler-rt/lib/crt/crtbegin.c b/compiler-rt/lib/crt/crtbegin.c
index 24bea1a2c3a7..481c158ac777 100644
--- a/compiler-rt/lib/crt/crtbegin.c
+++ b/compiler-rt/lib/crt/crtbegin.c
@@ -52,6 +52,10 @@ __attribute__((section(".init_array"),
 __asm__(".pushsection .init,\"ax\",@progbits\n\t"
 "call " __USER_LABEL_PREFIX__ "__do_init\n\t"
 ".popsection");
+#elif defined(__riscv)
+__asm__(".pushsection .init,\"ax\",%progbits\n\t"
+"call " __USER_LABEL_PREFIX__ "__do_init\n\t"
+".popsection");
 #elif defined(__arm__) || defined(__aarch64__)
 __asm__(".pushsection .init,\"ax\",%progbits\n\t"
 "bl " __USER_LABEL_PREFIX__ "__do_init\n\t"
@@ -110,6 +114,10 @@ __asm__(".pushsection .fini,\"ax\",@progbits\n\t"
 "bl " __USER_LABEL_PREFIX__ "__do_fini\n\t"
 "nop\n\t"
 ".popsection");
+#elif defined(__riscv)
+__asm__(".pushsection .fini,\"ax\",@progbits\n\t"
+"call " __USER_LABEL_PREFIX__ "__do_fini\n\t"
+".popsection");
 #elif defined(__sparc__)
 __asm__(".pushsection .fini,\"ax\",@progbits\n\t"
 "call " __USER_LABEL_PREFIX__ "__do_fini\n\t"



___
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] 4431c21 - lld/ELF: Make three rarely-used flags work with --reproduce

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

Author: Nico Weber
Date: 2020-12-01T09:20:29-05:00
New Revision: 4431c212a0a08c2b6552e6a476a15b142d7c6bb9

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

LOG: lld/ELF: Make three rarely-used flags work with --reproduce

All three use readFile() for their argument so their argument file is
already copied to the tar, but we weren't rewriting the argument to
point to the path used in the tar file.

No test because the change is trivial (several other flags in
createResponseFile() also aren't tested, likely for the same reason.)

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

Added: 


Modified: 
lld/ELF/DriverUtils.cpp

Removed: 




diff  --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 2efd92a3df76..fd649808c060 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -186,8 +186,11 @@ std::string elf::createResponseFile(const 
opt::InputArgList &args) {
   // Strip directories to prevent the issue.
   os << "-o " << quote(path::filename(arg->getValue())) << "\n";
   break;
+case OPT_call_graph_ordering_file:
 case OPT_dynamic_list:
+case OPT_just_symbols:
 case OPT_library_path:
+case OPT_retain_symbols_file:
 case OPT_rpath:
 case OPT_script:
 case OPT_symbol_ordering_file:



___
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] 7a4f1d5 - [ConstraintElimination] Decompose GEP %ptr, ZEXT(SHL()).

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

Author: Florian Hahn
Date: 2020-12-01T14:23:21Z
New Revision: 7a4f1d59b82e5defbce4498347291e6ef9f1281c

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

LOG: [ConstraintElimination] Decompose GEP %ptr, ZEXT(SHL()).

Add support to decompose a GEP with a ZEXT(SHL()) operand.

Added: 


Modified: 
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/geps.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 5c806b6e5486..8e7480bea284 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -64,6 +64,11 @@ static SmallVector, 4> 
decompose(Value *V) {
   return {{0, nullptr},
   {1, GEP->getPointerOperand()},
   {pow(2, CI->getSExtValue()), Op0}};
+if (match(GEP->getOperand(GEP->getNumOperands() - 1),
+  m_ZExt(m_NUWShl(m_Value(Op0), m_ConstantInt(CI)
+  return {{0, nullptr},
+  {1, GEP->getPointerOperand()},
+  {pow(2, CI->getSExtValue()), Op0}};
 
 return {{0, nullptr},
 {1, GEP->getPointerOperand()},

diff  --git a/llvm/test/Transforms/ConstraintElimination/geps.ll 
b/llvm/test/Transforms/ConstraintElimination/geps.ll
index 52aea974294b..a380d5211342 100644
--- a/llvm/test/Transforms/ConstraintElimination/geps.ll
+++ b/llvm/test/Transforms/ConstraintElimination/geps.ll
@@ -455,7 +455,7 @@ define void @test.ult.gep.shl.zext(i32* readonly %src, i32* 
readnone %max, i32 %
 ; CHECK-NEXT:[[EXT_1:%.*]] = zext i32 [[IDX_SHL]] to i64
 ; CHECK-NEXT:[[ADD_PTR_SHL:%.*]] = getelementptr inbounds i32, i32* 
[[SRC]], i64 [[EXT_1]]
 ; CHECK-NEXT:[[C_MAX_0:%.*]] = icmp ult i32* [[ADD_PTR_SHL]], [[MAX]]
-; CHECK-NEXT:call void @use(i1 [[C_MAX_0]])
+; CHECK-NEXT:call void @use(i1 true)
 ; CHECK-NEXT:[[IDX_SHL_NOT_NUW:%.*]] = shl i32 [[IDX]], 1
 ; CHECK-NEXT:[[EXT_2:%.*]] = zext i32 [[IDX_SHL_NOT_NUW]] to i64
 ; CHECK-NEXT:[[ADD_PTR_SHL_NOT_NUW:%.*]] = getelementptr inbounds i32, 
i32* [[SRC]], i64 [[EXT_2]]



___
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] 1b209ff - [DAG] Move vselect(icmp_ult, 0, sub(x, y)) -> usubsat(x, y) to DAGCombine (PR40111)

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

Author: Simon Pilgrim
Date: 2020-12-01T14:25:29Z
New Revision: 1b209ff9e3e13492fd56ae6662989ef47510db4d

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

LOG: [DAG] Move vselect(icmp_ult, 0, sub(x,y)) -> usubsat(x,y) to DAGCombine 
(PR40111)

Move the X86 VSELECT->USUBSAT fold to DAGCombiner - there's nothing target 
specific about these folds.

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/usub_sat_vec.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 7a87521ae344..1684ec90f676 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9743,6 +9743,68 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
 }
   }
 }
+
+// Match VSELECTs into sub with unsigned saturation.
+if (hasOperation(ISD::USUBSAT, VT)) {
+  // Check if one of the arms of the VSELECT is a zero vector. If it's on
+  // the left side invert the predicate to simplify logic below.
+  SDValue Other;
+  ISD::CondCode SatCC = CC;
+  if (ISD::isBuildVectorAllZeros(N1.getNode())) {
+Other = N2;
+SatCC = ISD::getSetCCInverse(SatCC, VT.getScalarType());
+  } else if (ISD::isBuildVectorAllZeros(N2.getNode())) {
+Other = N1;
+  }
+
+  if (Other && Other.getNumOperands() == 2 && Other.getOperand(0) == LHS) {
+SDValue CondLHS = LHS, CondRHS = RHS;
+SDValue OpLHS = Other.getOperand(0), OpRHS = Other.getOperand(1);
+
+// Look for a general sub with unsigned saturation first.
+// x >= y ? x-y : 0 --> usubsat x, y
+// x >  y ? x-y : 0 --> usubsat x, y
+if ((SatCC == ISD::SETUGE || SatCC == ISD::SETUGT) &&
+Other.getOpcode() == ISD::SUB && OpRHS == CondRHS)
+  return DAG.getNode(ISD::USUBSAT, DL, VT, OpLHS, OpRHS);
+
+if (auto *OpRHSBV = dyn_cast(OpRHS)) {
+  if (isa(CondRHS)) {
+// If the RHS is a constant we have to reverse the const
+// canonicalization.
+// x > C-1 ? x+-C : 0 --> usubsat x, C
+auto MatchUSUBSAT = [](ConstantSDNode *Op, ConstantSDNode *Cond) {
+  return (!Op && !Cond) ||
+ (Op && Cond &&
+  Cond->getAPIntValue() == (-Op->getAPIntValue() - 1));
+};
+if (SatCC == ISD::SETUGT && Other.getOpcode() == ISD::ADD &&
+ISD::matchBinaryPredicate(OpRHS, CondRHS, MatchUSUBSAT,
+  /*AllowUndefs*/ true)) {
+  OpRHS = DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT),
+  OpRHS);
+  return DAG.getNode(ISD::USUBSAT, DL, VT, OpLHS, OpRHS);
+}
+
+// Another special case: If C was a sign bit, the sub has been
+// canonicalized into a xor.
+// FIXME: Would it be better to use computeKnownBits to determine
+//whether it's safe to decanonicalize the xor?
+// x s< 0 ? x^C : 0 --> usubsat x, C
+if (auto *OpRHSConst = OpRHSBV->getConstantSplatNode()) {
+  if (SatCC == ISD::SETLT && Other.getOpcode() == ISD::XOR &&
+  ISD::isBuildVectorAllZeros(CondRHS.getNode()) &&
+  OpRHSConst->getAPIntValue().isSignMask()) {
+// Note that we have to rebuild the RHS constant here to ensure
+// we don't rely on particular values of undef lanes.
+OpRHS = DAG.getConstant(OpRHSConst->getAPIntValue(), DL, VT);
+return DAG.getNode(ISD::USUBSAT, DL, VT, OpLHS, OpRHS);
+  }
+}
+  }
+}
+  }
+}
   }
 
   if (SimplifySelectOps(N, N1, N2))

diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index ce3497934a07..3020354ca499 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -40912,75 +40912,6 @@ static SDValue combineSelect(SDNode *N, SelectionDAG 
&DAG,
 }
   }
 
-  // Match VSELECTs into subs with unsigned saturation.
-  if (N->getOpcode() == ISD::VSELECT && Cond.getOpcode() == ISD::SETCC &&
-  // psubus is available in SSE2 for i8 and i16 vectors.
-  Subtarget.hasSSE2() && VT.getVectorNumElements() >= 2 &&
-  isPowerOf2_32(VT.getVectorNumElements()) &&
-  (VT.getVectorElementType() == MVT::i8 ||
-   VT.getVectorElementType() == MVT::i16)) {
-ISD::CondCode CC = cast(Cond.getOperand(2))->get();
-
-// Check if one of the arms of the VSELECT is a zero vector. If it's on t

[llvm-branch-commits] [lldb] 64f0462 - [lldb][NFC] Modernize and cleanup TestClassTemplateParameterPack

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

Author: Raphael Isemann
Date: 2020-12-01T15:53:40+01:00
New Revision: 64f04629aa7a4cf9d2deb725683959faa4a857fe

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

LOG: [lldb][NFC] Modernize and cleanup TestClassTemplateParameterPack

* Un-inline the test.
* Use expect_expr everywhere and also check all involved types.
* Clang-format the test sources.
* Explain what we're actually testing with the 'C' and 'D' templates.
* Split out the non-template-parameter-pack part of the test into its own small 
test.

Added: 
lldb/test/API/lang/cpp/class-template-parameter-pack/Makefile
lldb/test/API/lang/cpp/non-type-template-param/Makefile
lldb/test/API/lang/cpp/non-type-template-param/TestAlignAsBaseClass.py
lldb/test/API/lang/cpp/non-type-template-param/main.cpp

Modified: 

lldb/test/API/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py
lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp

Removed: 




diff  --git a/lldb/test/API/lang/cpp/class-template-parameter-pack/Makefile 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/class-template-parameter-pack/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py
 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py
index 7e67f73b7092..e0497b62f55c 100644
--- 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py
+++ 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py
@@ -1,7 +1,38 @@
-from lldbsuite.test import lldbinline
-from lldbsuite.test import decorators
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
 
-lldbinline.MakeInlineTest(
-__file__, globals(), [
-decorators.expectedFailureAll(
-compiler="gcc")])
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@expectedFailureAll(compiler="gcc")
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))
+
+# Test non-type template parameter packs.
+self.expect_expr("myC", result_type="C", result_children=[
+ValueCheck(name="C", children=[
+ValueCheck(name="member", value="64")
+])
+])
+self.expect_expr("myLesserC.argsAre_16_32()", result_value="false")
+self.expect_expr("myC.argsAre_16_32()", result_value="true")
+
+# Test type template parameter packs.
+self.expect_expr("myD", result_type="D", 
result_children=[
+ValueCheck(name="D", children=[
+ValueCheck(name="member", value="64")
+])
+])
+self.expect_expr("myLesserD.argsAre_Int_bool()", result_value="false")
+self.expect_expr("myD.argsAre_Int_bool()", result_value="true")
+
+# Disabling until we do template lookup correctly: 
http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180507/040689.html
+# FIXME: Rewrite this with expect_expr
+# self.expect("expression -- C().isSixteenThirtyTwo()", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
+# self.expect("expression -- C().isSixteenThirtyTwo()", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
+# self.expect("expression -- D().isIntBool()", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
+# self.expect("expression -- D().isIntBool()", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])

diff  --git a/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp
index 82f09a1f268c..8bb0a42b58a3 100644
--- a/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp
+++ b/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp
@@ -1,64 +1,43 @@
 template  struct C {
   T member;
-  bool isSixteenThirtyTwo() { return false; }
+  bool argsAre_16_32() { return false; }
 };
 
 template <> struct C {
   int member;
-  bool isSixteenThirtyTwo() { return false; }
+  bool argsAre_16_32() { return false; }
 };
 
 template <> struct C : C {
-  bool isSixteenThirtyTwo() { return true; }
+  bool argsAre_16_32() { return true; }
 };
 
 template  struct D {
   T member;
-  bool isIntBool() { return false; }
+  bool argsAre_Int_bool() { return false; }
 };
 
 template <> struct D {
   int member;
-  bool isIntBool() { return false; }
+  bool argsAre_Int_bool() { return false; }
 };
 
 template <> struct D

[llvm-branch-commits] [llvm] 9f60b8b - [InstCombine] canonicalize sign-bit-shift of difference to ext(icmp)

2020-12-01 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-01T09:58:11-05:00
New Revision: 9f60b8b3d2e2cd38b9ae45da7e36a77b3c9dd258

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

LOG: [InstCombine] canonicalize sign-bit-shift of difference to ext(icmp)

icmp is the preferred spelling in IR because icmp analysis is
expected to be better than any other analysis. This should
lead to more follow-on folding potential.

It's difficult to say exactly what we should do in codegen to
compensate. For example on AArch64, which of these is preferred:
sub w8, w0, w1
lsr w0, w8, #31

vs:
cmp w0, w1
csetw0, lt

If there are perf regressions, then we should deal with those in
codegen on a case-by-case basis.

A possible motivating example for better optimization is shown in:
https://llvm.org/PR43198 but that will require other transforms
before anything changes there.

Alive proof:
https://rise4fun.com/Alive/o4E

  Name: sign-bit splat
  Pre: C1 == (width(%x) - 1)
  %s = sub nsw %x, %y
  %r = ashr %s, C1
  =>
  %c = icmp slt %x, %y
  %r = sext %c

  Name: sign-bit LSB
  Pre: C1 == (width(%x) - 1)
  %s = sub nsw %x, %y
  %r = lshr %s, C1
  =>
  %c = icmp slt %x, %y
  %r = zext %c

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/ashr-lshr.ll
llvm/test/Transforms/InstCombine/sub-ashr-and-to-icmp-select.ll
llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 4eaf1bcc22fe..7295369365c4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -1131,6 +1131,12 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator 
&I) {
   }
 }
 
+// lshr i32 (X -nsw Y), 31 --> zext (X < Y)
+Value *Y;
+if (ShAmt == BitWidth - 1 &&
+match(Op0, m_OneUse(m_NSWSub(m_Value(X), m_Value(Y)
+  return new ZExtInst(Builder.CreateICmpSLT(X, Y), Ty);
+
 if (match(Op0, m_LShr(m_Value(X), m_APInt(ShOp1 {
   unsigned AmtSum = ShAmt + ShOp1->getZExtValue();
   // Oversized shifts are simplified to zero in InstSimplify.
@@ -1293,6 +1299,12 @@ Instruction *InstCombinerImpl::visitAShr(BinaryOperator 
&I) {
   return new SExtInst(NewSh, Ty);
 }
 
+// ashr i32 (X -nsw Y), 31 --> sext (X < Y)
+Value *Y;
+if (ShAmt == BitWidth - 1 &&
+match(Op0, m_OneUse(m_NSWSub(m_Value(X), m_Value(Y)
+  return new SExtInst(Builder.CreateICmpSLT(X, Y), Ty);
+
 // If the shifted-out value is known-zero, then this is an exact shift.
 if (!I.isExact() &&
 MaskedValueIsZero(Op0, APInt::getLowBitsSet(BitWidth, ShAmt), 0, &I)) {

diff  --git a/llvm/test/Transforms/InstCombine/ashr-lshr.ll 
b/llvm/test/Transforms/InstCombine/ashr-lshr.ll
index dc1deb043428..72fa0252d839 100644
--- a/llvm/test/Transforms/InstCombine/ashr-lshr.ll
+++ b/llvm/test/Transforms/InstCombine/ashr-lshr.ll
@@ -437,8 +437,8 @@ define <2 x i32> @ashr_lshr_inv_vec_wrong_pred(<2 x i32> 
%x, <2 x i32> %y) {
 
 define i32 @lshr_sub_nsw(i32 %x, i32 %y) {
 ; CHECK-LABEL: @lshr_sub_nsw(
-; CHECK-NEXT:[[SUB:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:[[SHR:%.*]] = lshr i32 [[SUB]], 31
+; CHECK-NEXT:[[TMP1:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[SHR:%.*]] = zext i1 [[TMP1]] to i32
 ; CHECK-NEXT:ret i32 [[SHR]]
 ;
   %sub = sub nsw i32 %x, %y
@@ -446,6 +446,8 @@ define i32 @lshr_sub_nsw(i32 %x, i32 %y) {
   ret i32 %shr
 }
 
+; negative test - must shift sign-bit
+
 define i32 @lshr_sub_wrong_amount(i32 %x, i32 %y) {
 ; CHECK-LABEL: @lshr_sub_wrong_amount(
 ; CHECK-NEXT:[[SUB:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
@@ -457,6 +459,8 @@ define i32 @lshr_sub_wrong_amount(i32 %x, i32 %y) {
   ret i32 %shr
 }
 
+; negative test - must have nsw
+
 define i32 @lshr_sub(i32 %x, i32 %y) {
 ; CHECK-LABEL: @lshr_sub(
 ; CHECK-NEXT:[[SUB:%.*]] = sub i32 [[X:%.*]], [[Y:%.*]]
@@ -468,6 +472,8 @@ define i32 @lshr_sub(i32 %x, i32 %y) {
   ret i32 %shr
 }
 
+; negative test - one-use
+
 define i32 @lshr_sub_nsw_extra_use(i32 %x, i32 %y, i32* %p) {
 ; CHECK-LABEL: @lshr_sub_nsw_extra_use(
 ; CHECK-NEXT:[[SUB:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
@@ -483,8 +489,8 @@ define i32 @lshr_sub_nsw_extra_use(i32 %x, i32 %y, i32* %p) 
{
 
 define <3 x i42> @lshr_sub_nsw_splat(<3 x i42> %x, <3 x i42> %y) {
 ; CHECK-LABEL: @lshr_sub_nsw_splat(
-; CHECK-NEXT:[[SUB:%.*]] = sub nsw <3 x i42> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:[[SHR:%.*]] = lshr <3 x i42> [[SUB]], 
+; CHECK-NEXT:[[TMP1:%.*]] = icmp slt <3 x i42> [[X:%.*]], [[Y:%.*

[llvm-branch-commits] [llvm] eedf0ed - [ARM] Mark select and selectcc of MVE vector operations as expand.

2020-12-01 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-01T15:05:55Z
New Revision: eedf0ed63e82ba2f8d2cbc12d6dae61035ed4f9a

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

LOG: [ARM] Mark select and selectcc of MVE vector operations as expand.

We already expand select and select_cc in codegenprepare, but they can
still be generated under some situations. Explicitly mark them as expand
to ensure they are not produced, leading to a failure to select the
nodes.

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

Added: 


Modified: 
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/test/CodeGen/Thumb2/mve-selectcc.ll

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 0426a560805a..bc9222151899 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -289,6 +289,8 @@ void ARMTargetLowering::addMVEVectorTypes(bool HasMVEFP) {
 setOperationAction(ISD::UDIVREM, VT, Expand);
 setOperationAction(ISD::SDIVREM, VT, Expand);
 setOperationAction(ISD::CTPOP, VT, Expand);
+setOperationAction(ISD::SELECT, VT, Expand);
+setOperationAction(ISD::SELECT_CC, VT, Expand);
 
 // Vector reductions
 setOperationAction(ISD::VECREDUCE_ADD, VT, Legal);
@@ -335,6 +337,8 @@ void ARMTargetLowering::addMVEVectorTypes(bool HasMVEFP) {
 setOperationAction(ISD::SETCC, VT, Custom);
 setOperationAction(ISD::MLOAD, VT, Custom);
 setOperationAction(ISD::MSTORE, VT, Legal);
+setOperationAction(ISD::SELECT, VT, Expand);
+setOperationAction(ISD::SELECT_CC, VT, Expand);
 
 // Pre and Post inc are supported on loads and stores
 for (unsigned im = (unsigned)ISD::PRE_INC;

diff  --git a/llvm/test/CodeGen/Thumb2/mve-selectcc.ll 
b/llvm/test/CodeGen/Thumb2/mve-selectcc.ll
index 2633d2a3b2f5..b4f5d8d8fa3f 100644
--- a/llvm/test/CodeGen/Thumb2/mve-selectcc.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-selectcc.ll
@@ -203,3 +203,53 @@ entry:
   %s = select i1 %c,  <2 x double> %s0, <2 x double> %s1
   ret <2 x double> %s
 }
+
+define i32 @e() {
+; CHECK-LABEL: e:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:adr r0, .LCPI14_0
+; CHECK-NEXT:vmov.i32 q1, #0x4
+; CHECK-NEXT:vldrw.u32 q0, [r0]
+; CHECK-NEXT:movs r0, #0
+; CHECK-NEXT:vmov q2, q0
+; CHECK-NEXT:  .LBB14_1: @ %vector.body
+; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:adds r0, #4
+; CHECK-NEXT:vadd.i32 q2, q2, q1
+; CHECK-NEXT:cmp r0, #8
+; CHECK-NEXT:cset r1, eq
+; CHECK-NEXT:tst.w r1, #1
+; CHECK-NEXT:csetm r1, ne
+; CHECK-NEXT:subs.w r2, r0, #8
+; CHECK-NEXT:vdup.32 q3, r1
+; CHECK-NEXT:csel r0, r0, r2, ne
+; CHECK-NEXT:vbic q2, q2, q3
+; CHECK-NEXT:vand q3, q3, q0
+; CHECK-NEXT:vorr q2, q3, q2
+; CHECK-NEXT:b .LBB14_1
+; CHECK-NEXT:.p2align 4
+; CHECK-NEXT:  @ %bb.2:
+; CHECK-NEXT:  .LCPI14_0:
+; CHECK-NEXT:.long 0 @ 0x0
+; CHECK-NEXT:.long 1 @ 0x1
+; CHECK-NEXT:.long 2 @ 0x2
+; CHECK-NEXT:.long 3 @ 0x3
+entry:
+  br label %vector.body
+
+vector.body:  ; preds = 
%pred.store.continue73, %entry
+  %index = phi i32 [ 0, %entry ], [ %spec.select, %pred.store.continue73 ]
+  %vec.ind = phi <4 x i32> [ , %entry ], [ 
%spec.select74, %pred.store.continue73 ]
+  %l3 = icmp ult <4 x i32> %vec.ind, 
+  %l4 = extractelement <4 x i1> %l3, i32 0
+  br label %pred.store.continue73
+
+pred.store.continue73:; preds = %pred.store.if72, 
%pred.store.continue71
+  %index.next = add i32 %index, 4
+  %vec.ind.next = add <4 x i32> %vec.ind, 
+  %l60 = icmp eq i32 %index.next, 8
+  %spec.select = select i1 %l60, i32 0, i32 %index.next
+  %spec.select74 = select i1 %l60, <4 x i32> , <4 
x i32> %vec.ind.next
+  br label %vector.body
+}
+



___
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] 107e92d - [DAG] Remove unused variable. NFC.

2020-12-01 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-01T16:29:02+01:00
New Revision: 107e92dff8ca3c27478baccc50e183d81da7ea17

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

LOG: [DAG] Remove unused variable. NFC.

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 1684ec90f676..9505204732c8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9758,7 +9758,7 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
   }
 
   if (Other && Other.getNumOperands() == 2 && Other.getOperand(0) == LHS) {
-SDValue CondLHS = LHS, CondRHS = RHS;
+SDValue CondRHS = RHS;
 SDValue OpLHS = Other.getOperand(0), OpRHS = Other.getOperand(1);
 
 // Look for a general sub with unsigned saturation first.



___
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] 136f98e - [x86] adjust cost model values for minnum/maxnum with fast-math-flags

2020-12-01 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-01T10:45:53-05:00
New Revision: 136f98e5236522f55693b8b2d23e87692987f734

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

LOG: [x86] adjust cost model values for minnum/maxnum with fast-math-flags

Without FMF, we lower these intrinsics into something like this:

vmaxsd  %xmm0, %xmm1, %xmm2
vcmpunordsd %xmm0, %xmm0, %xmm0
vblendvpd   %xmm0, %xmm1, %xmm2, %xmm0

But if we can ignore NANs, the single min/max instruction is enough
because there is no need to fix up the x86 logic that corresponds to
X > Y ? X : Y.

We probably want to make other adjustments for FP intrinsics with FMF
to account for specialized codegen (for example, FSQRT).

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

Added: 


Modified: 
llvm/lib/Target/X86/X86TargetTransformInfo.cpp
llvm/test/Analysis/CostModel/X86/fmaxnum.ll
llvm/test/Analysis/CostModel/X86/fminnum.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp 
b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 770317a9a8b5..36a04a850110 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -2802,93 +2802,105 @@ int X86TTIImpl::getTypeBasedIntrinsicInstrCost(
   return LT.first * Cost;
 }
 
+auto adjustTableCost = [](const CostTblEntry &Entry, int LegalizationCost,
+  FastMathFlags FMF) {
+  // If there are no NANs to deal with, then these are reduced to a
+  // single MIN** or MAX** instruction instead of the MIN/CMP/SELECT that 
we
+  // assume is used in the non-fast case.
+  if (Entry.ISD == ISD::FMAXNUM || Entry.ISD == ISD::FMINNUM) {
+if (FMF.noNaNs())
+  return LegalizationCost * 1;
+  }
+  return LegalizationCost * (int)Entry.Cost;
+};
+
 if (ST->useGLMDivSqrtCosts())
   if (const auto *Entry = CostTableLookup(GLMCostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->isSLM())
   if (const auto *Entry = CostTableLookup(SLMCostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasCDI())
   if (const auto *Entry = CostTableLookup(AVX512CDCostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasBWI())
   if (const auto *Entry = CostTableLookup(AVX512BWCostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasAVX512())
   if (const auto *Entry = CostTableLookup(AVX512CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasXOP())
   if (const auto *Entry = CostTableLookup(XOPCostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasAVX2())
   if (const auto *Entry = CostTableLookup(AVX2CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasAVX())
   if (const auto *Entry = CostTableLookup(AVX1CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasSSE42())
   if (const auto *Entry = CostTableLookup(SSE42CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasSSE41())
   if (const auto *Entry = CostTableLookup(SSE41CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasSSSE3())
   if (const auto *Entry = CostTableLookup(SSSE3CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasSSE2())
   if (const auto *Entry = CostTableLookup(SSE2CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasSSE1())
   if (const auto *Entry = CostTableLookup(SSE1CostTbl, ISD, MTy))
-return LT.first * Entry->Cost;
+return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
 if (ST->hasBMI()) {
   if (ST->is64Bit())
 if (const auto *Entry = CostTableLookup(BMI64CostTbl, ISD, MTy))
-  return LT.first * Entry->Cost;
+  return adjustTableCost(*Entry, LT.first, ICA.getFlags());
 
   if (const auto 

[llvm-branch-commits] [clang] cd5897d - [HIP] Fix static-lib test CHECK bug

2020-12-01 Thread Aaron En Ye Shi via llvm-branch-commits

Author: Aaron En Ye Shi
Date: 2020-12-01T15:49:39Z
New Revision: cd5897d55908827faf3e16c505bd79732a8f6eb6

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

LOG: [HIP] Fix static-lib test CHECK bug

Fix hip test failures that were introduced by
previous changes to hip-toolchain-rdc-static-lib.hip
test. The .*lld.* is matching a longer string than
expected.

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

Added: 


Modified: 
clang/test/Driver/hip-toolchain-rdc-static-lib.hip

Removed: 




diff  --git a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip 
b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
index 533d3457d5b4..b698ec763249 100644
--- a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -47,7 +47,9 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] 
[[B_BC1]]
+// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// CHECK-SAME: "-plugin-opt=mcpu=gfx803"
+// CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -71,7 +73,9 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: [[LLD]] {{.*}} "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+// CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// CHECK-SAME: "-plugin-opt=mcpu=gfx900"
+// CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"



___
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] 735e6c8 - [MergeICmps] Fix missing split.

2020-12-01 Thread Clement Courbet via llvm-branch-commits

Author: Clement Courbet
Date: 2020-12-01T16:50:55+01:00
New Revision: 735e6c888ec8d647609d242a165e3631423a709d

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

LOG: [MergeICmps] Fix missing split.

We were not correctly splitting a blocks for chains of length 1.

Before that change, additional instructions for blocks in chains of
length 1 were not split off from the block before removing (this was
done correctly for chains of longer size).
If this first block contained an instruction referenced elsewhere,
deleting the block, would result in invalidation of the produced value.

This caused a miscompile which motivated D92297 (before D17993,
nonnull and dereferenceable attributed were not added so MergeICmps were
not triggered.) The new test gep-references-bb.ll demonstrate the issue.

The regression was introduced in
rG0efadbbcdeb82f5c14f38fbc2826107063ca48b2.

This supersedes D92364.

Test case by MaskRay (Fangrui Song).

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

Added: 
llvm/test/Transforms/MergeICmps/X86/gep-references-bb.ll

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

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp 
b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
index e3058af73c11..1559e7a41a7c 100644
--- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp
+++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
@@ -624,6 +624,18 @@ static BasicBlock *mergeComparisons(ArrayRef 
Comparisons,
   Value *IsEqual = nullptr;
   LLVM_DEBUG(dbgs() << "Merging " << Comparisons.size() << " comparisons -> "
 << BB->getName() << "\n");
+
+  // If there is one block that requires splitting, we do it now, i.e.
+  // just before we know we will collapse the chain. The instructions
+  // can be executed before any of the instructions in the chain.
+  const auto ToSplit =
+  std::find_if(Comparisons.begin(), Comparisons.end(),
+   [](const BCECmpBlock &B) { return B.RequireSplit; });
+  if (ToSplit != Comparisons.end()) {
+LLVM_DEBUG(dbgs() << "Splitting non_BCE work to header\n");
+ToSplit->split(BB, AA);
+  }
+
   if (Comparisons.size() == 1) {
 LLVM_DEBUG(dbgs() << "Only one comparison, updating branches\n");
 Value *const LhsLoad =
@@ -633,17 +645,6 @@ static BasicBlock *mergeComparisons(ArrayRef 
Comparisons,
 // There are no blocks to merge, just do the comparison.
 IsEqual = Builder.CreateICmpEQ(LhsLoad, RhsLoad);
   } else {
-// If there is one block that requires splitting, we do it now, i.e.
-// just before we know we will collapse the chain. The instructions
-// can be executed before any of the instructions in the chain.
-const auto ToSplit =
-std::find_if(Comparisons.begin(), Comparisons.end(),
- [](const BCECmpBlock &B) { return B.RequireSplit; });
-if (ToSplit != Comparisons.end()) {
-  LLVM_DEBUG(dbgs() << "Splitting non_BCE work to header\n");
-  ToSplit->split(BB, AA);
-}
-
 const unsigned TotalSizeBits = std::accumulate(
 Comparisons.begin(), Comparisons.end(), 0u,
 [](int Size, const BCECmpBlock &C) { return Size + C.SizeBits(); });

diff  --git a/llvm/test/Transforms/MergeICmps/X86/gep-references-bb.ll 
b/llvm/test/Transforms/MergeICmps/X86/gep-references-bb.ll
new file mode 100644
index ..c42667da1df8
--- /dev/null
+++ b/llvm/test/Transforms/MergeICmps/X86/gep-references-bb.ll
@@ -0,0 +1,64 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -S -mergeicmps -verify-dom-info | FileCheck %s
+target triple = "x86_64"
+
+%Triple = type { i32, i32, i32, i32 }
+
+@g = external global i32
+
+; bb1 references a gep introduced in bb0. The gep must remain available after
+; the merge.
+define i1 @bug(%Triple* nonnull dereferenceable(16) %lhs, %Triple* nonnull 
dereferenceable(16) %rhs) {
+; CHECK-LABEL: @bug(
+; CHECK-NEXT:  bb0:
+; CHECK-NEXT:store i32 1, i32* @g, align 4
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr [[TRIPLE:%.*]], %Triple* 
[[RHS:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[L0_ADDR:%.*]] = getelementptr inbounds [[TRIPLE]], %Triple* 
[[LHS:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[L0:%.*]] = load i32, i32* [[L0_ADDR]], align 4
+; CHECK-NEXT:[[R0_ADDR:%.*]] = getelementptr inbounds [[TRIPLE]], %Triple* 
[[RHS]], i64 0, i32 0
+; CHECK-NEXT:[[R0:%.*]] = load i32, i32* [[R0_ADDR]], align 4
+; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[L0]], [[R0]]
+; CHECK-NEXT:br i1 [[CMP0]], label %"bb1+bb2", label [[FINAL:%.*]]
+; CHECK:   "bb1+bb2":
+; CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[TRIPLE]], %Triple* 
[[LHS]], i64 0, i32 2
+; CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds i32, i32* [[GEP]], i64 2
+; CHECK-NEXT: 

[llvm-branch-commits] [llvm] 864dda5 - [InstSimplify] Add tests that fold instructions with poison operands (NFC)

2020-12-01 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2020-12-02T01:01:59+09:00
New Revision: 864dda5fd50471acaee335c1643cbd424ef319ce

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

LOG: [InstSimplify] Add tests that fold instructions with poison operands (NFC)

Added: 
llvm/test/Transforms/InstSimplify/and.ll
llvm/test/Transforms/InstSimplify/fcmp.ll
llvm/test/Transforms/InstSimplify/fp-undef-poison.ll
llvm/test/Transforms/InstSimplify/insertvalue.ll
llvm/test/Transforms/InstSimplify/xor.ll

Modified: 
llvm/test/Transforms/InstSimplify/add.ll
llvm/test/Transforms/InstSimplify/call.ll
llvm/test/Transforms/InstSimplify/div.ll
llvm/test/Transforms/InstSimplify/extract-element.ll
llvm/test/Transforms/InstSimplify/fminmax-folds.ll
llvm/test/Transforms/InstSimplify/gep.ll
llvm/test/Transforms/InstSimplify/icmp.ll
llvm/test/Transforms/InstSimplify/insertelement.ll
llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
llvm/test/Transforms/InstSimplify/mul.ll
llvm/test/Transforms/InstSimplify/or.ll
llvm/test/Transforms/InstSimplify/phi.ll
llvm/test/Transforms/InstSimplify/rem.ll
llvm/test/Transforms/InstSimplify/saturating-add-sub.ll
llvm/test/Transforms/InstSimplify/select.ll
llvm/test/Transforms/InstSimplify/shift.ll
llvm/test/Transforms/InstSimplify/shufflevector.ll
llvm/test/Transforms/InstSimplify/sub.ll

Removed: 
llvm/test/Transforms/InstSimplify/fp-undef.ll



diff  --git a/llvm/test/Transforms/InstSimplify/add.ll 
b/llvm/test/Transforms/InstSimplify/add.ll
index 21cc905688b2..b271c87d188f 100644
--- a/llvm/test/Transforms/InstSimplify/add.ll
+++ b/llvm/test/Transforms/InstSimplify/add.ll
@@ -30,7 +30,7 @@ define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) {
 
 define i8 @knownnegation(i8 %x, i8 %y) {
 ; CHECK-LABEL: @knownnegation(
-; CHECK-NEXT:ret i8 0 
+; CHECK-NEXT:ret i8 0
 ;
   %xy = sub i8 %x, %y
   %yx = sub i8 %y, %x
@@ -48,4 +48,10 @@ define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x 
i8> %y) {
   ret <2 x i8> %r
 }
 
-
+define i32 @poison(i32 %x) {
+; CHECK-LABEL: @poison(
+; CHECK-NEXT:ret i32 poison
+;
+  %y = add i32 %x, poison
+  ret i32 %y
+}

diff  --git a/llvm/test/Transforms/InstSimplify/and.ll 
b/llvm/test/Transforms/InstSimplify/and.ll
new file mode 100644
index ..f199bd14f644
--- /dev/null
+++ b/llvm/test/Transforms/InstSimplify/and.ll
@@ -0,0 +1,12 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+; TODO: this should be poison
+
+define i32 @poison(i32 %x) {
+; CHECK-LABEL: @poison(
+; CHECK-NEXT:ret i32 0
+;
+  %v = and i32 %x, poison
+  ret i32 %v
+}

diff  --git a/llvm/test/Transforms/InstSimplify/call.ll 
b/llvm/test/Transforms/InstSimplify/call.ll
index 6579bda52795..bfbd101b046c 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -35,6 +35,14 @@ define {i8, i1} @test_uadd3(i8 %v) {
   ret {i8, i1} %result
 }
 
+define {i8, i1} @test_uadd3_poison(i8 %v) {
+; CHECK-LABEL: @test_uadd3_poison(
+; CHECK-NEXT:ret { i8, i1 } { i8 undef, i1 false }
+;
+  %result = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 %v, i8 poison)
+  ret {i8, i1} %result
+}
+
 define {i8, i1} @test_uadd4(i8 %v) {
 ; CHECK-LABEL: @test_uadd4(
 ; CHECK-NEXT:ret { i8, i1 } { i8 undef, i1 false }
@@ -43,6 +51,14 @@ define {i8, i1} @test_uadd4(i8 %v) {
   ret {i8, i1} %result
 }
 
+define {i8, i1} @test_uadd4_poison(i8 %v) {
+; CHECK-LABEL: @test_uadd4_poison(
+; CHECK-NEXT:ret { i8, i1 } { i8 undef, i1 false }
+;
+  %result = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 poison, i8 %v)
+  ret {i8, i1} %result
+}
+
 define i1 @test_sadd1() {
 ; CHECK-LABEL: @test_sadd1(
 ; CHECK-NEXT:ret i1 true
@@ -69,6 +85,14 @@ define {i8, i1} @test_sadd3(i8 %v) {
   ret {i8, i1} %result
 }
 
+define {i8, i1} @test_sadd3_poison(i8 %v) {
+; CHECK-LABEL: @test_sadd3_poison(
+; CHECK-NEXT:ret { i8, i1 } { i8 undef, i1 false }
+;
+  %result = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 %v, i8 poison)
+  ret {i8, i1} %result
+}
+
 define {i8, i1} @test_sadd4(i8 %v) {
 ; CHECK-LABEL: @test_sadd4(
 ; CHECK-NEXT:ret { i8, i1 } { i8 undef, i1 false }
@@ -77,6 +101,14 @@ define {i8, i1} @test_sadd4(i8 %v) {
   ret {i8, i1} %result
 }
 
+define {i8, i1} @test_sadd4_poison(i8 %v) {
+; CHECK-LABEL: @test_sadd4_poison(
+; CHECK-NEXT:ret { i8, i1 } { i8 undef, i1 false }
+;
+  %result = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 poison, i8 %v)
+  ret {i8, i1} %result
+}
+
 define {i8, i1} @test_usub1(i8 %V) {
 ; CHECK-LABEL: @test_usub1(
 ; CHECK-NEXT:ret { i8, i1 } zeroinitializer
@@ -93,6 +125,14 @@ define {i8, i1} @test_usub2(i8 %V) {
   

[llvm-branch-commits] [llvm] f0659c0 - [X86] Support modifier @PLTOFF for R_X86_64_PLTOFF64

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

Author: Fangrui Song
Date: 2020-12-01T08:39:01-08:00
New Revision: f0659c0673417582038aa4a3c13edbfa0abb6b9a

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

LOG: [X86] Support modifier @PLTOFF for R_X86_64_PLTOFF64

`gcc -mcmodel=large` can emit @PLTOFF.

Reviewed By: grimar

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

Added: 
llvm/test/MC/X86/pltoff.s

Modified: 
llvm/include/llvm/MC/MCExpr.h
llvm/lib/MC/MCExpr.cpp
llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp

Removed: 




diff  --git a/llvm/include/llvm/MC/MCExpr.h b/llvm/include/llvm/MC/MCExpr.h
index a2c0aea464e4..3ffc845e75c0 100644
--- a/llvm/include/llvm/MC/MCExpr.h
+++ b/llvm/include/llvm/MC/MCExpr.h
@@ -224,6 +224,7 @@ class MCSymbolRefExpr : public MCExpr {
 VK_WEAKREF, // The link between the symbols in .weakref foo, bar
 
 VK_X86_ABS8,
+VK_X86_PLTOFF,
 
 VK_ARM_NONE,
 VK_ARM_GOT_PREL,

diff  --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index 6f1ac656cec0..3b123a46d9dc 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -253,6 +253,7 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind 
Kind) {
   case VK_SIZE: return "SIZE";
   case VK_WEAKREF: return "WEAKREF";
   case VK_X86_ABS8: return "ABS8";
+  case VK_X86_PLTOFF: return "PLTOFF";
   case VK_ARM_NONE: return "none";
   case VK_ARM_GOT_PREL: return "GOT_PREL";
   case VK_ARM_TARGET1: return "target1";
@@ -410,6 +411,7 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
 .Case("secrel32", VK_SECREL)
 .Case("size", VK_SIZE)
 .Case("abs8", VK_X86_ABS8)
+.Case("pltoff", VK_X86_PLTOFF)
 .Case("l", VK_PPC_LO)
 .Case("h", VK_PPC_HI)
 .Case("ha", VK_PPC_HA)

diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp 
b/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
index 292dd17e2f51..fa937d381613 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
@@ -94,6 +94,12 @@ static void checkIs32(MCContext &Ctx, SMLoc Loc, 
X86_64RelType Type) {
 "32 bit reloc applied to a field with a 
diff erent size");
 }
 
+static void checkIs64(MCContext &Ctx, SMLoc Loc, X86_64RelType Type) {
+  if (Type != RT64_64)
+Ctx.reportError(Loc,
+"64 bit reloc applied to a field with a 
diff erent size");
+}
+
 static unsigned getRelocType64(MCContext &Ctx, SMLoc Loc,
MCSymbolRefExpr::VariantKind Modifier,
X86_64RelType Type, bool IsPCRel,
@@ -212,6 +218,9 @@ static unsigned getRelocType64(MCContext &Ctx, SMLoc Loc,
   return ELF::R_X86_64_REX_GOTPCRELX;
 }
 llvm_unreachable("unexpected relocation type!");
+  case MCSymbolRefExpr::VK_X86_PLTOFF:
+checkIs64(Ctx, Loc, Type);
+return ELF::R_X86_64_PLTOFF64;
   }
 }
 

diff  --git a/llvm/test/MC/X86/pltoff.s b/llvm/test/MC/X86/pltoff.s
new file mode 100644
index ..3dd79ed1f2a2
--- /dev/null
+++ b/llvm/test/MC/X86/pltoff.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc -triple=x86_64 %s | FileCheck %s --check-prefix=ASM
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
+# RUN: llvm-objdump -d -r %t | FileCheck %s --check-prefix=OBJ
+
+# RUN: not llvm-mc -filetype=obj -triple=x86_64 --defsym ERR=1 %s -o /dev/null 
2>&1 | FileCheck %s --check-prefix=ERR
+
+# ASM:  movabsq $puts@PLTOFF, %rax
+# OBJ:  movabsq $0, %rax
+# OBJ-NEXT:   0002: R_X86_64_PLTOFF64 puts{{$}}
+
+movabsq $puts@PLTOFF, %rax
+
+.ifdef ERR
+# ERR: {{.*}}.s:[[#@LINE+1]]:1: error: 64 bit reloc applied to a field with a 
diff erent size
+movl $puts@PLTOFF, %eax
+.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] [lld] a5f9588 - [ELF][test] Add some tests for versioned symbols in object files

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

Author: Fangrui Song
Date: 2020-12-01T08:49:14-08:00
New Revision: a5f95887d0f8d27f1c33f19944d0c1da66aef606

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

LOG: [ELF][test] Add some tests for versioned symbols in object files

Test the symbol resolution related to

* defined foo@@v1 and foo@v1 in object files/shared objects
* undefined foo@v1
* weak foo@@v1 and foo@v1
* visibility
* interaction with --wrap.

Reviewed By: grimar

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

Added: 
lld/test/ELF/symver.s

Modified: 


Removed: 




diff  --git a/lld/test/ELF/symver.s b/lld/test/ELF/symver.s
new file mode 100644
index ..7495805bfe4d
--- /dev/null
+++ b/lld/test/ELF/symver.s
@@ -0,0 +1,222 @@
+# REQUIRES: x86
+## Test symbol resolution related to .symver produced symbols in object files.
+
+# RUN: split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref.s -o %t/ref.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref1.s -o %t/ref1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref1p.s -o %t/ref1p.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def1.s -o %t/def1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def1w.s -o %t/def1w.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/hid1.s -o %t/hid1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/hid1w.s -o %t/hid1w.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def2.s -o %t/def2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/wrap.s -o %t/wrap.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/wrap1.s -o %t/wrap1.o
+# RUN: ld.lld -shared --soname=def1.so --version-script=%t/ver %t/def1.o -o 
%t/def1.so
+# RUN: ld.lld -shared --soname=hid1.so --version-script=%t/ver %t/hid1.o -o 
%t/hid1.so
+
+## TODO Report a duplicate definition error for foo@v1 and foo@@v1.
+# RUN: ld.lld -shared --version-script=%t/ver %t/def1.o %t/hid1.o -o /dev/null
+
+# RUN: ld.lld -shared --version-script=%t/ver %t/def1w.o %t/hid1.o -o /dev/null
+# RUN: ld.lld -shared --version-script=%t/ver %t/def1.o %t/hid1w.o -o /dev/null
+# RUN: ld.lld -shared --version-script=%t/ver %t/def1w.o %t/hid1w.o -o 
/dev/null
+
+## TODO foo@@v1 should resolve undefined foo@v1.
+# RUN: not ld.lld -shared --version-script=%t/ver %t/ref1p.o %t/def1.o -o 
/dev/null
+
+## TODO
+## foo@@v1 resolves both undefined foo and foo@v1. There is one single 
definition.
+## Note: set soname so that the name string referenced by .gnu.version_d is 
fixed.
+# RUN: ld.lld -shared --soname=t --version-script=%t/ver %t/ref.o %t/ref1.o 
%t/def1.o -o %t1
+# RUN: llvm-readelf -r --dyn-syms %t1 | FileCheck %s
+
+# CHECK:   Relocation section '.rela.plt' at offset {{.*}} contains 2 
entries:
+# CHECK-NEXT:  {{.*}} Type   {{.*}}
+# CHECK-NEXT:  {{.*}} R_X86_64_JUMP_SLOT {{.*}} foo@@v1 + 0
+# CHECK-NEXT:  {{.*}} R_X86_64_JUMP_SLOT {{.*}} foo + 0
+
+# CHECK:   1: {{.*}} NOTYPE GLOBAL DEFAULT UND   foo{{$}}
+# CHECK-NEXT:  2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@@v1
+# CHECK-EMPTY:
+
+## foo@@v2 does not resolve undefined foo@v1.
+## TODO Undefined 'foo@v1' should be errored.
+# RUN: ld.lld -shared --soname=t --version-script=%t/ver %t/ref.o %t/ref1.o 
%t/def2.o -o %t2
+# RUN: llvm-readelf --dyn-syms %t2 | FileCheck %s --check-prefix=CHECK2
+
+# CHECK2:   1: {{.*}} NOTYPE GLOBAL DEFAULT UND   foo{{$}}
+# CHECK2-NEXT:  2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@@v2
+# CHECK2-EMPTY:
+
+## foo@@v2 resolves undefined foo while foo@v1 resolves undefined foo@v1.
+# RUN: ld.lld -shared --soname=t --version-script=%t/ver %t/ref.o %t/ref1.o 
%t/hid1.o %t/def2.o -o %t3
+# RUN: llvm-readelf -r --dyn-syms %t3 | FileCheck %s --check-prefix=CHECK3
+# RUN: llvm-objdump -d --no-show-raw-insn %t3 | FileCheck %s 
--check-prefix=DIS3
+
+# CHECK3:   34a8 {{.*}} R_X86_64_JUMP_SLOT {{.*}} foo@@v2 + 0
+# CHECK3-NEXT:  34b0 {{.*}} R_X86_64_JUMP_SLOT {{.*}} foo@v1 + 0
+
+# CHECK3:   1: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@@v2
+# CHECK3-NEXT:  2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@v1
+# CHECK3-NEXT:  3: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo_v1
+# CHECK3-EMPTY:
+
+# DIS3-LABEL: <.text>:
+# DIS3-NEXT:callq 0x1380 
+# DIS3-COUNT-3: int3
+# DIS3-NEXT:callq 0x1390 
+# DIS3-LABEL: :
+# DIS3-NEXT:jmpq *{{.*}}(%rip) # 34a8
+# DIS3-LABEL: :
+# DIS3-NEXT:jmpq *{{.*}}(%rip) # 34b0
+
+## Then, test the interaction with versioned definitions in shared objects.
+
+## TODO Both foo and foo@v1 are undefined. Ideally we should not create two 
.dynsym entries.
+# RUN: ld.lld -shared --soname=t --version-script=%t/ver %t/ref.o %t/ref1.o 
%t/def1.so -o %t4
+# RUN: llvm-readelf --dyn-syms %t4 | FileCheck %s --check-prefix=CHECK4
+
+# CHECK4:   1: {{.*}} NOTYPE GLOBAL DEFAULT UND   foo@v1
+# CHECK4-NEXT:  2: {{.*}} NOTYPE GLO

[llvm-branch-commits] [lld] 843c2b2 - [ELF] Error for undefined foo@v1

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

Author: Fangrui Song
Date: 2020-12-01T08:59:54-08:00
New Revision: 843c2b2303004c1a7e4fa8037905fbc70601b155

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

LOG: [ELF] Error for undefined foo@v1

If an object file has an undefined foo@v1, we emit a dynamic symbol foo.
This is incorrect if at runtime a shared object provides the non-default 
version foo@v1
(the undefined foo may bind to foo@@v2, for example).

GNU ld issues an error for this case, even if foo@v1 is undefined weak
(https://sourceware.org/bugzilla/show_bug.cgi?id=3351). This behavior makes
sense because to represent an undefined foo@v1, we have to construct a Verneed
entry. However, without knowing the defining filename, we cannot construct a
Verneed entry (Verneed::vn_file is unavailable).

This patch implements the error.

Depends on D92258

Reviewed By: grimar

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

Added: 


Modified: 
lld/ELF/Relocations.cpp
lld/ELF/Symbols.h
lld/test/ELF/lto/version-script2.ll
lld/test/ELF/symver.s

Removed: 




diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 7860aeeefcc3..c545f1c81918 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -945,7 +945,15 @@ template  void elf::reportUndefinedSymbols() {
 // Returns true if the undefined symbol will produce an error message.
 static bool maybeReportUndefined(Symbol &sym, InputSectionBase &sec,
  uint64_t offset) {
-  if (!sym.isUndefined() || sym.isWeak())
+  if (!sym.isUndefined())
+return false;
+  // If versioned, issue an error (even if the symbol is weak) because we don't
+  // know the defining filename which is required to construct a Verneed entry.
+  if (*sym.getVersionSuffix() == '@') {
+undefs.push_back({&sym, {{&sec, offset}}, false});
+return true;
+  }
+  if (sym.isWeak())
 return false;
 
   bool canBeExternal = !sym.isLocal() && sym.visibility == STV_DEFAULT;

diff  --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index 48428c24f9c8..bb87ac75f9c6 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -183,7 +183,7 @@ class Symbol {
   // For @@, the name has been truncated by insert(). For @, the name has been
   // truncated by Symbol::parseSymbolVersion().
   const char *getVersionSuffix() const {
-assert(nameSize != (uint32_t)-1);
+(void)getName();
 return nameData + nameSize;
   }
 

diff  --git a/lld/test/ELF/lto/version-script2.ll 
b/lld/test/ELF/lto/version-script2.ll
index b8c8b56b4317..154e9facd450 100644
--- a/lld/test/ELF/lto/version-script2.ll
+++ b/lld/test/ELF/lto/version-script2.ll
@@ -4,13 +4,21 @@
 ;; otherwise we may get a symbol named "foo@@VER1", but not "foo" with the
 ;; version VER1.
 
-; RUN: llvm-as %s -o %t.o
+; RUN: split-file %s %t
+; RUN: llvm-as %t/ir -o %t.o
+; RUN: llvm-mc -filetype=obj -triple=x86_64 %t/asm -o %tbar.o
+; RUN: ld.lld %tbar.o -shared --soname=tbar --version-script %t.script -o 
%tbar.so
 ; RUN: echo "VER1 {};" > %t.script
-; RUN: ld.lld %t.o -o %t.so -shared --version-script %t.script
+
+;; Emit an error if bar@VER1 is not defined.
+; RUN: not ld.lld %t.o -o /dev/null -shared --version-script %t.script 2>&1 | 
FileCheck %s --check-prefix=UNDEF
+
+; UNDEF: error: undefined symbol: bar@VER1
+
+; RUN: ld.lld %t.o %tbar.so -o %t.so -shared --version-script %t.script
 ; RUN: llvm-readelf --dyn-syms %t.so | FileCheck %s
 
-;; For non-relocatable output, @ in symbol names has no effect on undefined 
symbols.
-; CHECK:  UND   bar{{$}}
+; CHECK:  UND   bar@VER1
 ; CHECK-NEXT: {{[1-9]}} foo@@VER1
 
 ;; For relocatable output, @ should be retained in the symbol name.
@@ -21,6 +29,7 @@
 ; RELOCATABLE:  {{[1-9]}} foo@@VER1
 ; RELOCATABLE-NEXT: UND   bar@VER1
 
+;--- ir
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -28,3 +37,9 @@ module asm ".global foo"
 module asm "foo: call bar"
 module asm ".symver foo,foo@@@VER1"
 module asm ".symver bar,bar@@@VER1"
+
+;--- asm
+.globl bar
+.symver bar,bar@@@VER1
+bar:
+  ret

diff  --git a/lld/test/ELF/symver.s b/lld/test/ELF/symver.s
index 2858e835622a..7111f4264f3d 100644
--- a/lld/test/ELF/symver.s
+++ b/lld/test/ELF/symver.s
@@ -5,6 +5,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref.s -o %t/ref.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref1.s -o %t/ref1.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref1p.s -o %t/ref1p.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref1w.s -o %t/ref1w.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def1.s -o %t/def1.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def1w.s -o %t/def1w.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/hid1.s -o %t/

[llvm-branch-commits] [lld] 941e933 - [ELF] Make foo@@v1 resolve undefined foo@v1

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

Author: Fangrui Song
Date: 2020-12-01T08:54:01-08:00
New Revision: 941e9336d092f0ccef35e0f425d97f7def5ed1b0

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

LOG: [ELF] Make foo@@v1 resolve undefined foo@v1

The symbol resolution rules for versioned symbols are:

* foo@@v1 (default version) resolves both undefined foo and foo@v1
* foo@v1 (non-default version) resolves undefined foo@v1

Note, foo@@v1 must be defined (the assembler errors if attempting to
create an undefined foo@@v1).

For defined foo@@v1 in a shared object, we call `SymbolTable::addSymbol` twice,
one for foo and the other for foo@v1. We don't do the same for object files, so
foo@@v1 defined in one object file incorrectly does not resolve a foo@v1
reference in another object file.

This patch fixes the issue by reusing the --wrap code to redirect symbols in
object files. This has to be done after processing input files because
foo and foo@v1 are two separate symbols if we haven't seen foo@@v1.

Add a helper `Symbol::getVersionSuffix` to retrieve the optional trailing
`@...` or `@@...` from the possibly truncated symbol name.

Depends on D92258

Reviewed By: jhenderson

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

Added: 


Modified: 
lld/ELF/Driver.cpp
lld/ELF/Symbols.cpp
lld/ELF/Symbols.h
lld/test/ELF/symver.s

Removed: 




diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index aa6fed652a93..860c74fa0d20 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1919,17 +1919,46 @@ static std::vector 
addWrappedSymbols(opt::InputArgList &args) {
   return v;
 }
 
-// Do renaming for -wrap by updating pointers to symbols.
+// Do renaming for -wrap and foo@v1 by updating pointers to symbols.
 //
 // When this function is executed, only InputFiles and symbol table
 // contain pointers to symbol objects. We visit them to replace pointers,
 // so that wrapped symbols are swapped as instructed by the command line.
-static void wrapSymbols(ArrayRef wrapped) {
+static void redirectSymbols(ArrayRef wrapped) {
+  llvm::TimeTraceScope timeScope("Redirect symbols");
   DenseMap map;
   for (const WrappedSymbol &w : wrapped) {
 map[w.sym] = w.wrap;
 map[w.real] = w.sym;
   }
+  for (Symbol *sym : symtab->symbols()) {
+// Enumerate symbols with a non-default version (foo@v1).
+StringRef name = sym->getName();
+const char *suffix1 = sym->getVersionSuffix();
+if (suffix1[0] != '@' || suffix1[1] == '@')
+  continue;
+
+// Check whether the default version foo@@v1 exists. If it exists, the
+// symbol can be found by the name "foo" in the symbol table.
+Symbol *maybeDefault = symtab->find(name);
+if (!maybeDefault)
+  continue;
+const char *suffix2 = maybeDefault->getVersionSuffix();
+if (suffix2[0] != '@' || suffix2[1] != '@' ||
+strcmp(suffix1 + 1, suffix2 + 2) != 0)
+  continue;
+
+// foo@v1 and foo@@v1 should be merged, so redirect foo@v1 to foo@@v1.
+map.try_emplace(sym, maybeDefault);
+// If both foo@v1 and foo@@v1 are defined and non-weak, report a duplicate
+// definition error.
+maybeDefault->resolve(*sym);
+// Eliminate foo@v1 from the symbol table.
+sym->symbolKind = Symbol::PlaceholderKind;
+  }
+
+  if (map.empty())
+return;
 
   // Update pointers in input files.
   parallelForEach(objectFiles, [&](InputFile *file) {
@@ -2158,9 +2187,8 @@ template  void 
LinkerDriver::link(opt::InputArgList &args) {
   !config->thinLTOModulesToCompile.empty())
 return;
 
-  // Apply symbol renames for -wrap.
-  if (!wrapped.empty())
-wrapSymbols(wrapped);
+  // Apply symbol renames for -wrap and combine foo@v1 and foo@@v1.
+  redirectSymbols(wrapped);
 
   {
 llvm::TimeTraceScope timeScope("Aggregate sections");

diff  --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index f38d9fab4500..a2153da2e8d8 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -37,11 +37,9 @@ std::string lld::toString(const elf::Symbol &sym) {
   StringRef name = sym.getName();
   std::string ret = demangle(name);
 
-  // If sym has a non-default version, its name may have been truncated at '@'
-  // by Symbol::parseSymbolVersion(). Add the trailing part. This check is safe
-  // because every symbol name ends with '\0'.
-  if (name.data()[name.size()] == '@')
-ret += name.data() + name.size();
+  const char *suffix = sym.getVersionSuffix();
+  if (*suffix == '@')
+ret += suffix;
   return ret;
 }
 

diff  --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index a8d056a32f98..48428c24f9c8 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -178,6 +178,15 @@ class Symbol {
 
   void parseSymbolVersion();
 
+  // Get the NUL-terminated version suffix ("", "@...", or "@@...").
+  //
+  // For @@, th

[llvm-branch-commits] [llvm] 54eab29 - [BasicAA] Add test for suboptimal result with unknown sizes (NFC)

2020-12-01 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-01T18:20:34+01:00
New Revision: 54eab293f523956bdc4b1a98b6cf5abc0bd1ef3f

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

LOG: [BasicAA] Add test for suboptimal result with unknown sizes (NFC)

Added: 


Modified: 
llvm/test/Analysis/BasicAA/phi-aa.ll

Removed: 




diff  --git a/llvm/test/Analysis/BasicAA/phi-aa.ll 
b/llvm/test/Analysis/BasicAA/phi-aa.ll
index aa2e078000a7..f5492e6fb00f 100644
--- a/llvm/test/Analysis/BasicAA/phi-aa.ll
+++ b/llvm/test/Analysis/BasicAA/phi-aa.ll
@@ -150,3 +150,26 @@ loop:
   store i32 0, i32* %p2
   br label %loop
 }
+
+; CHECK-LABEL: phi_and_gep_unknown_size
+; CHECK: Just Mod:   call void @llvm.memset.p0i8.i32(i8* %g, i8 0, i32 %size, 
i1 false) <->   call void @llvm.memset.p0i8.i32(i8* %z, i8 0, i32 %size, i1 
false)
+; TODO: This should be NoModRef.
+define void @phi_and_gep_unknown_size(i1 %c, i8* %x, i8* %y, i8* noalias %z, 
i32 %size) {
+entry:
+  br i1 %c, label %true, label %false
+
+true:
+  br label %exit
+
+false:
+  br label %exit
+
+exit:
+  %p = phi i8* [ %x, %true ], [ %y, %false ]
+  %g = getelementptr inbounds i8, i8* %p, i64 1
+  call void @llvm.memset.p0i8.i32(i8* %g, i8 0, i32 %size, i1 false)
+  call void @llvm.memset.p0i8.i32(i8* %z, i8 0, i32 %size, i1 false)
+  ret void
+}
+
+declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i1)



___
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] c30d510 - [libc++] Optimize the number of assignments in std::exclusive_scan

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

Author: Louis Dionne
Date: 2020-12-01T12:49:45-05:00
New Revision: c30d5101f14f7e8a1c0f80c8663b54de2a7640fd

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

LOG: [libc++] Optimize the number of assignments in std::exclusive_scan

Reported in https://twitter.com/blelbach/status/1169807347142676480

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

Added: 


Modified: 
libcxx/include/numeric

Removed: 




diff  --git a/libcxx/include/numeric b/libcxx/include/numeric
index 5c10dd3c1e67..ed06fcc49d5b 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -335,14 +335,17 @@ exclusive_scan(_InputIterator __first, _InputIterator 
__last,
 {
 if (__first != __last)
 {
-_Tp __saved = __init;
-do
+_Tp __tmp(__b(__init, *__first));
+while (true)
 {
-__init = __b(__init, *__first);
-*__result = __saved;
-__saved = __init;
+*__result = _VSTD::move(__init);
 ++__result;
-} while (++__first != __last);
+++__first;
+if (__first == __last)
+break;
+__init = _VSTD::move(__tmp);
+__tmp = __b(__init, *__first);
+}
 }
 return __result;
 }



___
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] b99e2b8 - clang/darwin: Use response files with ld64.lld.darwinnew

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

Author: Nico Weber
Date: 2020-12-01T12:07:56-05:00
New Revision: b99e2b8b14f4ba50f9eb80bd5a2c1824099a7f96

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

LOG: clang/darwin: Use response files with ld64.lld.darwinnew

The new MachO lld just grew support for response files in D92149, so let
the clang driver use it.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index db3d57a48098..f1846a573914 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method 
instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};



___
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] 26d3aae - [LTO][NewPM] Run verifier when doing LTO

2020-12-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-01T10:14:53-08:00
New Revision: 26d3aaeb3aac39329dd845bd0012ad961653dbc6

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

LOG: [LTO][NewPM] Run verifier when doing LTO

This matches the legacy PM.

Reviewed By: ychen

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

Added: 


Modified: 
lld/test/ELF/lto/verify-invalid.ll
llvm/lib/LTO/LTOBackend.cpp

Removed: 




diff  --git a/lld/test/ELF/lto/verify-invalid.ll 
b/lld/test/ELF/lto/verify-invalid.ll
index d44c483dbcbb..c18c264ef632 100644
--- a/lld/test/ELF/lto/verify-invalid.ll
+++ b/lld/test/ELF/lto/verify-invalid.ll
@@ -1,11 +1,17 @@
 ; REQUIRES: x86
 ; RUN: llvm-as %s -o %t.o
 ; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments \
-; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT %s
+; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT-LPM %s
 ; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments \
-; RUN:   -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE %s
+; RUN:   -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE-LPM %s
 ; RUN: ld.lld %t.o -o %t2 -mllvm -debug-pass=Arguments \
-; RUN:   --plugin-opt=disable-verify 2>&1 | FileCheck -check-prefix=DISABLE %s
+; RUN:   --plugin-opt=disable-verify 2>&1 | FileCheck 
-check-prefix=DISABLE-LPM %s
+; RUN: ld.lld %t.o -o %t2 --lto-new-pass-manager --lto-debug-pass-manager \
+; RUN:   2>&1 | FileCheck -check-prefix=DEFAULT-NPM %s
+; RUN: ld.lld %t.o -o %t2 --lto-new-pass-manager --lto-debug-pass-manager \
+; RUN:   -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE-NPM %s
+; RUN: ld.lld %t.o -o %t2 --lto-new-pass-manager --lto-debug-pass-manager \
+; RUN:   --plugin-opt=disable-verify 2>&1 | FileCheck 
-check-prefix=DISABLE-NPM %s
 
 target triple = "x86_64-unknown-linux-gnu"
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
@@ -15,5 +21,9 @@ define void @_start() {
 }
 
 ; -disable-verify should disable the verification of bitcode.
-; DEFAULT: Pass Arguments: {{.*}} -verify {{.*}} -verify
-; DISABLE-NOT: Pass Arguments: {{.*}} -verify {{.*}} -verify
+; DEFAULT-LPM: Pass Arguments: {{.*}} -verify {{.*}} -verify
+; DISABLE-LPM-NOT: Pass Arguments: {{.*}} -verify {{.*}} -verify
+; DEFAULT-NPM: Running pass: VerifierPass
+; DEFAULT-NPM: Running pass: VerifierPass
+; DEFAULT-NPM-NOT: Running pass: VerifierPass
+; DISABLE-NPM-NOT: Running pass: VerifierPass

diff  --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 3f082fdeea5b..65aaa8d21bfc 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -250,7 +250,9 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, 
TargetMachine *TM,
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
   ModulePassManager MPM(Conf.DebugPassManager);
-  // FIXME (davide): verify the input.
+
+  if (!Conf.DisableVerify)
+MPM.addPass(VerifierPass());
 
   PassBuilder::OptimizationLevel OL;
 
@@ -272,12 +274,14 @@ static void runNewPMPasses(const Config &Conf, Module 
&Mod, TargetMachine *TM,
   }
 
   if (IsThinLTO)
-MPM = PB.buildThinLTODefaultPipeline(OL, ImportSummary);
+MPM.addPass(PB.buildThinLTODefaultPipeline(OL, ImportSummary));
   else
-MPM = PB.buildLTODefaultPipeline(OL, ExportSummary);
-  MPM.run(Mod, MAM);
+MPM.addPass(PB.buildLTODefaultPipeline(OL, ExportSummary));
 
-  // FIXME (davide): verify the output.
+  if (!Conf.DisableVerify)
+MPM.addPass(VerifierPass());
+
+  MPM.run(Mod, MAM);
 }
 
 static void runNewPMCustomPasses(const Config &Conf, Module &Mod,



___
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] 624af93 - [MemCpyOpt] Port to MemorySSA

2020-12-01 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-01T17:57:41+01:00
New Revision: 624af932a808b363a888139beca49f57313d9a3b

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

LOG: [MemCpyOpt] Port to MemorySSA

This is a straightforward port of MemCpyOpt to MemorySSA following
the approach of D26739. MemDep queries are replaced with MSSA queries
without changing the overall structure of the pass. Some care has
to be taken to account for differences between these APIs
(MemDep also returns reads, MSSA doesn't).

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

Added: 


Modified: 
llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/callslot.ll
llvm/test/Transforms/MemCpyOpt/invariant.start.ll
llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll
llvm/test/Transforms/MemCpyOpt/memcpy.ll
llvm/test/Transforms/MemCpyOpt/merge-into-memset.ll
llvm/test/Transforms/MemCpyOpt/mixed-sizes.ll
llvm/test/Transforms/MemCpyOpt/nonlocal-memcpy-memcpy.ll
llvm/test/Transforms/MemCpyOpt/stackrestore.ll

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h 
b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
index 877aa40e1a3a..81a59c3d7772 100644
--- a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
+++ b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
@@ -43,6 +43,7 @@ class MemCpyOptPass : public PassInfoMixin {
   AliasAnalysis *AA = nullptr;
   AssumptionCache *AC = nullptr;
   DominatorTree *DT = nullptr;
+  MemorySSA *MSSA = nullptr;
   MemorySSAUpdater *MSSAU = nullptr;
 
 public:

diff  --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp 
b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index a08a1a7f515e..977cc740ab44 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -67,7 +67,6 @@ using namespace llvm;
 
 #define DEBUG_TYPE "memcpyopt"
 
-// TODO: Actually implement MemorySSA-based MemCpyOpt.
 static cl::opt
 EnableMemorySSA("enable-memcpyopt-memoryssa", cl::init(false), cl::Hidden,
 cl::desc("Use MemorySSA-backed MemCpyOpt."));
@@ -283,7 +282,8 @@ class MemCpyOptLegacyPass : public FunctionPass {
 AU.addPreserved();
 AU.addPreserved();
 AU.addRequired();
-AU.addRequired();
+if (!EnableMemorySSA)
+  AU.addRequired();
 AU.addPreserved();
 AU.addRequired();
 AU.addPreserved();
@@ -330,10 +330,37 @@ static bool mayBeVisibleThroughUnwinding(Value *V, 
Instruction *Start,
 void MemCpyOptPass::eraseInstruction(Instruction *I) {
   if (MSSAU)
 MSSAU->removeMemoryAccess(I);
-  MD->removeInstruction(I);
+  if (MD)
+MD->removeInstruction(I);
   I->eraseFromParent();
 }
 
+// Check for mod or ref of Loc between Start and End, excluding both 
boundaries.
+// Start and End must be in the same block
+static bool accessedBetween(AliasAnalysis &AA, MemoryLocation Loc,
+const MemoryUseOrDef *Start,
+const MemoryUseOrDef *End) {
+  assert(Start->getBlock() == End->getBlock() && "Only local supported");
+  for (const MemoryAccess &MA :
+   make_range(++Start->getIterator(), End->getIterator())) {
+if 
(isModOrRefSet(AA.getModRefInfo(cast(MA).getMemoryInst(),
+   Loc)))
+  return true;
+  }
+  return false;
+}
+
+// Check for mod of Loc between Start and End, excluding both boundaries.
+// Start and End can be in 
diff erent blocks.
+static bool writtenBetween(MemorySSA *MSSA, MemoryLocation Loc,
+   const MemoryUseOrDef *Start,
+   const MemoryUseOrDef *End) {
+  // TODO: Only walk until we hit Start.
+  MemoryAccess *Clobber = MSSA->getWalker()->getClobberingMemoryAccess(
+  End->getDefiningAccess(), Loc);
+  return !MSSA->dominates(Clobber, Start);
+}
+
 /// When scanning forward over instructions, we look for some other patterns to
 /// fold away. In particular, this looks for stores to neighboring locations of
 /// memory. If it sees enough consecutive ones, it attempts to merge them
@@ -645,6 +672,7 @@ bool MemCpyOptPass::processStore(StoreInst *SI, 
BasicBlock::iterator &BBI) {
 // the memory we load from in between the load and the store. If
 // such an instruction is found, we try to promote there instead
 // of at the store position.
+// TODO: Can use MSSA for this.
 Instruction *P = SI;
 for (auto &I : make_range(++LI->getIterator(), SI->getIterator())) {
   if (isModSet(AA->getModRefInfo(&I, LoadLoc))) {
@@ -709,20 +737,37 @@ bool MemCpyOptPass::processStore(StoreInst *SI, 
BasicBlock::iterator &BBI) {
  

[llvm-branch-commits] [clang-tools-extra] ae7ec47 - [NFC][clang-tidy] Port rename_check.py to Python3

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

Author: Roman Lebedev
Date: 2020-12-01T20:10:19+03:00
New Revision: ae7ec47fc655537ce82c0bfee0b587921663eaff

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

LOG: [NFC][clang-tidy] Port rename_check.py to Python3

Added: 


Modified: 
clang-tools-extra/clang-tidy/rename_check.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/rename_check.py 
b/clang-tools-extra/clang-tidy/rename_check.py
index 4d5311c9a293..2410041fd5d2 100755
--- a/clang-tools-extra/clang-tidy/rename_check.py
+++ b/clang-tools-extra/clang-tidy/rename_check.py
@@ -120,16 +120,15 @@ def adapt_cmake(module_path, check_name_camel):
   if (not file_added) and (cpp_line or cpp_found):
 cpp_found = True
 if (line.strip() > cpp_file) or (not cpp_line):
-  f.write('  ' + cpp_file + '\n')
+  f.write(('  ' + cpp_file + '\n').encode())
   file_added = True
-  f.write(line)
+  f.write(line.encode())
 
   return True
 
 # Modifies the module to include the new check.
 def adapt_module(module_path, module, check_name, check_name_camel):
-  modulecpp = filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
- os.listdir(module_path))[0]
+  modulecpp = next(filter(lambda p: p.lower() == module.lower() + 
'tidymodule.cpp', os.listdir(module_path)))
   filename = os.path.join(module_path, modulecpp)
   with open(filename, 'r') as f:
 lines = f.readlines()
@@ -149,21 +148,21 @@ def adapt_module(module_path, module, check_name, 
check_name_camel):
   header_found = True
   if match.group(1) > check_name_camel:
 header_added = True
-f.write('#include "' + check_name_camel + '.h"\n')
+f.write(('#include "' + check_name_camel + '.h"\n').encode())
 elif header_found:
   header_added = True
-  f.write('#include "' + check_name_camel + '.h"\n')
+  f.write(('#include "' + check_name_camel + '.h"\n').encode())
 
   if not check_added:
 if line.strip() == '}':
   check_added = True
-  f.write(check_decl)
+  f.write(check_decl.encode())
 else:
   match = re.search('registerCheck<(.*)>', line)
   if match and match.group(1) > check_name_camel:
 check_added = True
-f.write(check_decl)
-  f.write(line)
+f.write(check_decl.encode())
+  f.write(line.encode())
 
 
 # Adds a release notes entry.
@@ -198,22 +197,22 @@ def add_release_notes(clang_tidy_path, old_check_name, 
new_check_name):
 
 if match:
   header_found = True
-  f.write(line)
+  f.write(line.encode())
   continue
 
 if line.startswith(''):
-  f.write(line)
+  f.write(line.encode())
   continue
 
 if header_found and add_note_here:
   if not line.startswith(''):
-f.write("""- The '%s' check was renamed to :doc:`%s
+f.write(("""- The '%s' check was renamed to :doc:`%s
   `
 
-""" % (old_check_name, new_check_name, new_check_name))
+""" % (old_check_name, new_check_name, new_check_name)).encode())
 note_added = True
 
-  f.write(line)
+  f.write(line.encode())
 
 def main():
   parser = argparse.ArgumentParser(description='Rename clang-tidy check.')
@@ -259,9 +258,9 @@ def main():
 (check_name_camel, cmake_lists))
   return 1
 
-modulecpp = filter(
+modulecpp = next(filter(
 lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
-os.listdir(old_module_path))[0]
+os.listdir(old_module_path)))
 deleteMatchingLines(os.path.join(old_module_path, modulecpp),
   '\\b' + check_name_camel + '|\\b' + args.old_check_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] e0bf234 - Let .llvm_bb_addr_map section use the same unique id as its associated .text section.

2020-12-01 Thread Rahman Lavaee via llvm-branch-commits

Author: Rahman Lavaee
Date: 2020-12-01T09:21:00-08:00
New Revision: e0bf2349303f6b40e3ddd5377ea08a5c0867ece4

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

LOG: Let .llvm_bb_addr_map section use the same unique id as its associated 
.text section.

Currently, `llvm_bb_addr_map` sections are generated per section names because 
we use
the `LinkedToSymbol` argument of getELFSection. This will cause the address map 
tables of functions
grouped into the same section when `-function-sections=true 
-unique-section-names=false` which is not
the intended behaviour. This patch lets the unique id of every `.text` section 
propagate to the associated
`.llvm_bb_addr_map` section.

Reviewed By: MaskRay

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

Added: 


Modified: 
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/test/CodeGen/X86/basic-block-sections-labels.ll

Removed: 




diff  --git a/llvm/lib/MC/MCObjectFileInfo.cpp 
b/llvm/lib/MC/MCObjectFileInfo.cpp
index 75e65e3f10f47..fbc7cf1efcdb6 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -1014,7 +1014,9 @@ MCObjectFileInfo::getBBAddrMapSection(const MCSection 
&TextSec) const {
 Flags |= ELF::SHF_GROUP;
   }
 
+  // Use the text section's begin symbol and unique ID to create a separate
+  // .llvm_bb_addr_map section associated with every unique text section.
   return Ctx->getELFSection(".llvm_bb_addr_map", ELF::SHT_LLVM_BB_ADDR_MAP,
-Flags, 0, GroupName, MCSection::NonUniqueID,
+Flags, 0, GroupName, ElfSec.getUniqueID(),
 cast(TextSec.getBeginSymbol()));
 }

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-labels.ll 
b/llvm/test/CodeGen/X86/basic-block-sections-labels.ll
index 026667bc32c7e..8a76fef672eb1 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-labels.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-labels.ll
@@ -1,5 +1,6 @@
 ; Check the basic block sections labels option
-; RUN: llc < %s -mtriple=x86_64 -function-sections 
-basic-block-sections=labels | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true 
-basic-block-sections=labels | FileCheck %s --check-prefix=UNIQ
+; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=false 
-basic-block-sections=labels | FileCheck %s --check-prefix=NOUNIQ
 
 define void @_Z3bazb(i1 zeroext) personality i32 (...)* @__gxx_personality_v0 {
   br i1 %0, label %2, label %7
@@ -28,6 +29,8 @@ declare i32 @_Z3foov() #1
 
 declare i32 @__gxx_personality_v0(...)
 
+; UNIQ:.section .text._Z3bazb,"ax",@progbits{{$}}
+; NOUNIQ:  .section .text,"ax",@progbits,unique,1
 ; CHECK-LABEL: _Z3bazb:
 ; CHECK-LABEL: .Lfunc_begin0:
 ; CHECK-LABEL: .LBB_END0_0:
@@ -39,7 +42,9 @@ declare i32 @__gxx_personality_v0(...)
 ; CHECK-LABEL: .LBB_END0_3:
 ; CHECK-LABEL: .Lfunc_end0:
 
-; CHECK:   .section.llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text
+; UNIQ:.section
.llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text._Z3bazb{{$}}
+;; Verify that with -unique-section-names=false, the unique id of the text 
section gets assigned to the llvm_bb_addr_map section.
+; NOUNIQ:  .section
.llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text,unique,1
 ; CHECK-NEXT:  .quad   .Lfunc_begin0
 ; CHECK-NEXT:  .byte   4
 ; CHECK-NEXT:  .uleb128 .Lfunc_begin0-.Lfunc_begin0



___
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] 2074fec - [MLIR][LLVM] Fix a tiny typo in the dialect docs.

2020-12-01 Thread Mehdi Amini via llvm-branch-commits

Author: ergawy
Date: 2020-12-01T20:06:41Z
New Revision: 2074fec5beb4eca9d438acd3b37c2c6d20b891b1

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

LOG: [MLIR][LLVM] Fix a tiny typo in the dialect docs.

Reviewed By: rriddle

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

Added: 


Modified: 
mlir/docs/Dialects/LLVM.md

Removed: 




diff  --git a/mlir/docs/Dialects/LLVM.md b/mlir/docs/Dialects/LLVM.md
index 57c32a3fc74b..9f423c0b3323 100644
--- a/mlir/docs/Dialects/LLVM.md
+++ b/mlir/docs/Dialects/LLVM.md
@@ -474,8 +474,8 @@ llvm.mlir.global @glob(0 : f32) : !llvm.float
 
 Unlike LLVM IR, MLIR does not have first-class null pointers. They must be
 explicitly created as SSA values using `llvm.mlir.null`. This operation has
-operands or attributes, and returns a null value of a wrapped LLVM IR pointer
-type.
+no operands or attributes, and returns a null value of a wrapped LLVM IR
+pointer type.
 
 Examples:
 



___
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] 1314a49 - [LTO][wasm][NewPM] Allow using new pass manager for wasm LTO

2020-12-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-01T12:22:40-08:00
New Revision: 1314a4938fba865412598b7227cb4657d59cd8bc

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

LOG: [LTO][wasm][NewPM] Allow using new pass manager for wasm LTO

Reviewed By: sbc100

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

Added: 
lld/test/wasm/lto/new-pass-manager.ll

Modified: 
lld/wasm/Config.h
lld/wasm/Driver.cpp
lld/wasm/LTO.cpp
lld/wasm/Options.td

Removed: 




diff  --git a/lld/test/wasm/lto/new-pass-manager.ll 
b/lld/test/wasm/lto/new-pass-manager.ll
new file mode 100644
index ..2f49c4d55df8
--- /dev/null
+++ b/lld/test/wasm/lto/new-pass-manager.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as -o %t.bc %s
+; RUN: wasm-ld --lto-new-pass-manager --lto-debug-pass-manager -o /dev/null 
%t.bc 2>&1 | FileCheck %s
+; RUN: wasm-ld --lto-new-pass-manager --lto-debug-pass-manager 
--lto-no-new-pass-manager -o /dev/null %t.bc 2>&1 | FileCheck %s --allow-empty 
--check-prefix=LPM
+
+; CHECK: Starting llvm::Module pass manager run
+; CHECK: Finished llvm::Module pass manager run
+; LPM-NOT: Starting llvm::Module pass manager run
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+define void @_start() local_unnamed_addr {
+entry:
+  ret void
+}

diff  --git a/lld/wasm/Config.h b/lld/wasm/Config.h
index 68b09a653d40..f18debfb1f83 100644
--- a/lld/wasm/Config.h
+++ b/lld/wasm/Config.h
@@ -62,6 +62,8 @@ struct Configuration {
   unsigned ltoo;
   unsigned optimize;
   llvm::StringRef thinLTOJobs;
+  bool ltoNewPassManager;
+  bool ltoDebugPassManager;
   UnresolvedPolicy unresolvedSymbols;
 
   llvm::StringRef entry;

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index f26b190b6058..d15cf40f6e5f 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -379,6 +379,9 @@ static void readConfigs(opt::InputArgList &args) {
   config->importTable = args.hasArg(OPT_import_table);
   config->ltoo = args::getInteger(args, OPT_lto_O, 2);
   config->ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1);
+  config->ltoNewPassManager = args.hasFlag(OPT_lto_new_pass_manager,
+   OPT_lto_no_new_pass_manager, false);
+  config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager);
   config->mapFile = args.getLastArgValue(OPT_Map);
   config->optimize = args::getInteger(args, OPT_O, 0);
   config->outputFile = args.getLastArgValue(OPT_o);

diff  --git a/lld/wasm/LTO.cpp b/lld/wasm/LTO.cpp
index 28b62022f29f..4f76fc0dccdb 100644
--- a/lld/wasm/LTO.cpp
+++ b/lld/wasm/LTO.cpp
@@ -52,6 +52,8 @@ static std::unique_ptr createLTO() {
   c.OptLevel = config->ltoo;
   c.MAttrs = getMAttrs();
   c.CGOptLevel = args::getCGOptLevel(config->ltoo);
+  c.UseNewPM = config->ltoNewPassManager;
+  c.DebugPassManager = config->ltoDebugPassManager;
 
   if (config->relocatable)
 c.RelocModel = None;

diff  --git a/lld/wasm/Options.td b/lld/wasm/Options.td
index 620b3bd10550..283fe3fc2931 100644
--- a/lld/wasm/Options.td
+++ b/lld/wasm/Options.td
@@ -215,6 +215,12 @@ def thinlto_cache_dir: J<"thinlto-cache-dir=">,
 defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the 
ThinLTO cache">;
 def thinlto_jobs: J<"thinlto-jobs=">,
   HelpText<"Number of ThinLTO jobs. Default to --threads=">;
+def lto_new_pass_manager: F<"lto-new-pass-manager">,
+  HelpText<"Use new pass manager">;
+def lto_no_new_pass_manager: F<"lto-no-new-pass-manager">,
+  HelpText<"Use legacy pass manager">;
+def lto_debug_pass_manager: F<"lto-debug-pass-manager">,
+  HelpText<"Debug new pass manager">;
 
 // Experimental PIC mode.
 def experimental_pic: F<"experimental-pic">,



___
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] e0665a9 - [OpenMP] Add support for Intel's umonitor/umwait

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

Author: Terry Wilmarth
Date: 2020-12-01T14:07:46-06:00
New Revision: e0665a9050840650809fa4eb6ef23bd8f5adfbf0

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

LOG: [OpenMP] Add support for Intel's umonitor/umwait

These changes add support for Intel's umonitor/umwait usage in wait
code, for architectures that support those intrinsic functions. Usage of
umonitor/umwait is off by default, but can be turned on by setting the
KMP_USER_LEVEL_MWAIT environment variable.

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

Added: 


Modified: 
openmp/runtime/cmake/config-ix.cmake
openmp/runtime/src/i18n/en_US.txt
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_barrier.cpp
openmp/runtime/src/kmp_config.h.cmake
openmp/runtime/src/kmp_global.cpp
openmp/runtime/src/kmp_lock.cpp
openmp/runtime/src/kmp_os.h
openmp/runtime/src/kmp_runtime.cpp
openmp/runtime/src/kmp_settings.cpp
openmp/runtime/src/kmp_stats.h
openmp/runtime/src/kmp_taskdeps.cpp
openmp/runtime/src/kmp_tasking.cpp
openmp/runtime/src/kmp_wait_release.cpp
openmp/runtime/src/kmp_wait_release.h
openmp/runtime/src/z_Linux_util.cpp
openmp/runtime/src/z_Windows_NT_util.cpp

Removed: 




diff  --git a/openmp/runtime/cmake/config-ix.cmake 
b/openmp/runtime/cmake/config-ix.cmake
index f13290a9bc4a..b5bf39b07728 100644
--- a/openmp/runtime/cmake/config-ix.cmake
+++ b/openmp/runtime/cmake/config-ix.cmake
@@ -10,6 +10,7 @@
 
 include(CheckCCompilerFlag)
 include(CheckCSourceCompiles)
+include(CheckCXXSourceCompiles)
 include(CheckCXXCompilerFlag)
 include(CheckIncludeFile)
 include(CheckLibraryExists)
@@ -141,6 +142,53 @@ else()
   endif()
 endif()
 
+# Checking for x86-specific waitpkg and rtm attribute and intrinsics
+if (IA32 OR INTEL64)
+  check_include_file(immintrin.h LIBOMP_HAVE_IMMINTRIN_H)
+  if (NOT LIBOMP_HAVE_IMMINTRIN_H)
+check_include_file(intrin.h LIBOMP_HAVE_INTRIN_H)
+  endif()
+  check_cxx_source_compiles("__attribute__((target(\"rtm\")))
+ int main() {return 0;}" LIBOMP_HAVE_ATTRIBUTE_RTM)
+  check_cxx_source_compiles("__attribute__((target(\"waitpkg\")))
+int main() {return 0;}" 
LIBOMP_HAVE_ATTRIBUTE_WAITPKG)
+  libomp_append(CMAKE_REQUIRED_DEFINITIONS -DIMMINTRIN_H 
LIBOMP_HAVE_IMMINTRIN_H)
+  libomp_append(CMAKE_REQUIRED_DEFINITIONS -DINTRIN_H LIBOMP_HAVE_INTRIN_H)
+  libomp_append(CMAKE_REQUIRED_DEFINITIONS -DATTRIBUTE_WAITPKG 
LIBOMP_HAVE_ATTRIBUTE_WAITPKG)
+  libomp_append(CMAKE_REQUIRED_DEFINITIONS -DATTRIBUTE_RTM 
LIBOMP_HAVE_ATTRIBUTE_RTM)
+  set(source_code "// check for attribute and wait pkg intrinsics
+  #ifdef IMMINTRIN_H
+  #include 
+  #endif
+  #ifdef INTRIN_H
+  #include 
+  #endif
+  #ifdef ATTRIBUTE_WAITPKG
+  __attribute__((target(\"waitpkg\")))
+  #endif
+  static inline int __kmp_umwait(unsigned hint, unsigned long long 
counter) {
+return _umwait(hint, counter);
+  }
+  int main() { int a = __kmp_umwait(0, 1000); return a; }")
+  check_cxx_source_compiles("${source_code}" LIBOMP_HAVE_WAITPKG_INTRINSICS)
+  set(source_code "// check for attribute rtm and rtm intrinsics
+  #ifdef IMMINTRIN_H
+  #include 
+  #endif
+  #ifdef INTRIN_H
+  #include 
+  #endif
+  #ifdef ATTRIBUTE_RTM
+  __attribute__((target(\"rtm\")))
+  #endif
+  static inline int __kmp_xbegin() {
+return _xbegin();
+  }
+  int main() { int a = __kmp_xbegin(); return a; }")
+  check_cxx_source_compiles("${source_code}" LIBOMP_HAVE_RTM_INTRINSICS)
+  set(CMAKE_REQUIRED_DEFINITIONS)
+endif()
+
 # Find perl executable
 # Perl is used to create omp.h (and other headers) along with kmp_i18n_id.inc 
and kmp_i18n_default.inc
 find_package(Perl REQUIRED)

diff  --git a/openmp/runtime/src/i18n/en_US.txt 
b/openmp/runtime/src/i18n/en_US.txt
index 0b084426fb41..26f4cf572dab 100644
--- a/openmp/runtime/src/i18n/en_US.txt
+++ b/openmp/runtime/src/i18n/en_US.txt
@@ -417,6 +417,8 @@ AffUsingHwloc"%1$s: Affinity capable, using 
hwloc."
 AffIgnoringHwloc "%1$s: Ignoring hwloc mechanism."
 AffHwlocErrorOccurred"%1$s: Hwloc failed in %2$s. Relying on internal 
affinity mechanisms."
 EnvSerialWarn"%1$s must be set prior to OpenMP runtime library 
initialization; ignored."
+EnvMwaitWarn "You have enabled the use of umonitor/umwait. If 
the CPU doesn't have that enabled "
+ "you'll get an illegal instruction exception."
 EnvVarDeprecated "%1$s variable deprecated, please use %2$s 
instead."
 RedMethodNotSupported"KMP_FORCE_REDUCTION: %1$s method is not 
supported; using critical."
 AffHWSubsetNoHWLOC  

[llvm-branch-commits] [clang] f9eaa46 - Fix erroneous edit in https://github.com/llvm/llvm-project/actions/runs/394499364

2020-12-01 Thread Zahira Ammarguellat via llvm-branch-commits

Author: Zahira Ammarguellat
Date: 2020-12-01T12:34:18-08:00
New Revision: f9eaa4650f5d5948af7050efef9d4098ff7f0ae8

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

LOG: Fix erroneous edit in 
https://github.com/llvm/llvm-project/actions/runs/394499364

Added: 


Modified: 
clang/lib/Sema/SemaLookup.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 34065a5a212a..16dd8f510596 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2576,8 +2576,6 @@ namespace {
 
 bool addClassTransitive(CXXRecordDecl *RD) {
   Classes.insert(RD);
-  if (InstantiationLoc.isInvalid())
-InstantiationLoc = RD->getLocation();
   return ClassesTransitive.insert(RD);
 }
 



___
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] 806a76c - Revert "[CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into llvm/"

2020-12-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-01T13:12:12-08:00
New Revision: 806a76c001233f2c70bf93c73fb955c64c1c080f

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

LOG: Revert "[CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into 
llvm/"

The new pass manager was accidentally enabled by default with this change.

This reverts commit a36bd4c90dcca82be9b64f65dbd22e921b6485ef.

Added: 


Modified: 
clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
llvm/CMakeLists.txt
llvm/include/llvm/Config/llvm-config.h.cmake
llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f947b820bdac..8c539e80946d 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -242,6 +242,9 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id 
to ld")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
 "enable x86 relax relocations by default")
 
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
+  "Enable the experimental new pass manager by default.")
+
 set(CLANG_SPAWN_CC1 OFF CACHE BOOL
 "Whether clang should use a new process for the CC1 invocation")
 

diff  --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index a240862c5289..26e9d5c4eb4d 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -75,6 +75,9 @@
 /* enable x86 relax relocations by default */
 #cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS
 
+/* Enable the experimental new pass manager by default */
+#cmakedefine01 ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
+
 /* Enable each functionality of modules */
 #cmakedefine01 CLANG_ENABLE_ARCMT
 #cmakedefine01 CLANG_ENABLE_OBJC_REWRITER

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6e37a3154bdf..48d0e2d6235b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1349,7 +1349,7 @@ def fglobal_isel : Flag<["-"], "fglobal-isel">, 
Group,
 def fexperimental_isel : Flag<["-"], "fexperimental-isel">, 
Group,
   Alias;
 defm experimental_new_pass_manager : 
BooleanMarshalledFFlag<"experimental-new-pass-manager", 
"CodeGenOpts.ExperimentalNewPassManager",
-  "static_cast(LLVM_ENABLE_NEW_PASS_MANAGER)", "Enables an 
experimental new pass manager in LLVM.",
+  "static_cast(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER)", "Enables an 
experimental new pass manager in LLVM.",
   "Disables an experimental new pass manager in LLVM.">, Group, 
Flags<[CC1Option]>;
 def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
   Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 034fab229ef6..d765b4cb598d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -37,7 +37,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
-#include "llvm/Config/llvm-config.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
@@ -598,7 +597,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const 
ArgList &Args,
   // Need this flag to turn on new pass manager via Gold plugin.
   if (Args.hasFlag(options::OPT_fexperimental_new_pass_manager,
options::OPT_fno_experimental_new_pass_manager,
-   /* Default */ LLVM_ENABLE_NEW_PASS_MANAGER)) {
+   /* Default */ ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER)) {
 CmdArgs.push_back("-plugin-opt=new-pass-manager");
   }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 068c8608ca65..f72e0fc10a32 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -58,7 +58,6 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
-#include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/MC/MCTargetOptions.h"

diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index a913b35ed567..2aff029cfbf1 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -15,7 +15,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_ENABLE_STAT

[llvm-branch-commits] [llvm] a082c73 - [WebAssembly] Fix FastISel address calculation bug

2020-12-01 Thread Tom Stellard via llvm-branch-commits

Author: Thomas Lively
Date: 2020-12-01T13:29:33-08:00
New Revision: a082c730b89fe5e544136ebe6370f452fd2772ee

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

LOG: [WebAssembly] Fix FastISel address calculation bug

Fixes PR47040, in which an assertion was improperly triggered during
FastISel's address computation. The issue was that an `Address` set to
be relative to the FrameIndex with offset zero was incorrectly
considered to have an unset base. When the left hand side of an add
set the Address to be 0 off the FrameIndex, the right side would not
detect that the Address base had already been set and could try to set
the Address to be relative to a register instead, triggering an
assertion.

This patch fixes the issue by explicitly tracking whether an `Address`
has been set rather than interpreting an offset of zero to mean the
`Address` has not been set.

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

(cherry picked from commit cc612c29084e907900ce63ad9031ab573a64e942)

Added: 
llvm/test/CodeGen/WebAssembly/fast-isel-pr47040.ll

Modified: 
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp

Removed: 




diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
index 8a0092a3f298..c2a0d3e01740 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
@@ -58,6 +58,9 @@ class WebAssemblyFastISel final : public FastISel {
   int FI;
 } Base;
 
+// Whether the base has been determined yet
+bool IsBaseSet = false;
+
 int64_t Offset = 0;
 
 const GlobalValue *GV = nullptr;
@@ -74,8 +77,9 @@ class WebAssemblyFastISel final : public FastISel {
 bool isFIBase() const { return Kind == FrameIndexBase; }
 void setReg(unsigned Reg) {
   assert(isRegBase() && "Invalid base register access!");
-  assert(Base.Reg == 0 && "Overwriting non-zero register");
+  assert(!IsBaseSet && "Base cannot be reset");
   Base.Reg = Reg;
+  IsBaseSet = true;
 }
 unsigned getReg() const {
   assert(isRegBase() && "Invalid base register access!");
@@ -83,8 +87,9 @@ class WebAssemblyFastISel final : public FastISel {
 }
 void setFI(unsigned FI) {
   assert(isFIBase() && "Invalid base frame index access!");
-  assert(Base.FI == 0 && "Overwriting non-zero frame index");
+  assert(!IsBaseSet && "Base cannot be reset");
   Base.FI = FI;
+  IsBaseSet = true;
 }
 unsigned getFI() const {
   assert(isFIBase() && "Invalid base frame index access!");
@@ -98,13 +103,7 @@ class WebAssemblyFastISel final : public FastISel {
 int64_t getOffset() const { return Offset; }
 void setGlobalValue(const GlobalValue *G) { GV = G; }
 const GlobalValue *getGlobalValue() const { return GV; }
-bool isSet() const {
-  if (isRegBase()) {
-return Base.Reg != 0;
-  } else {
-return Base.FI != 0;
-  }
-}
+bool isSet() const { return IsBaseSet; }
   };
 
   /// Keep a pointer to the WebAssemblySubtarget around so that we can make the

diff  --git a/llvm/test/CodeGen/WebAssembly/fast-isel-pr47040.ll 
b/llvm/test/CodeGen/WebAssembly/fast-isel-pr47040.ll
new file mode 100644
index ..616ce295d7f2
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/fast-isel-pr47040.ll
@@ -0,0 +1,22 @@
+; RUN: llc < %s -fast-isel -fast-isel-abort=1 -verify-machineinstrs
+
+; Regression test for PR47040, in which an assertion was improperly
+; triggered during FastISel's address computation. The issue was that
+; an `Address` set to be relative to FrameIndex zero was incorrectly
+; considered to have an unset base. When the left hand side of an add
+; set the Address to have a FrameIndex base of 0, the right side would
+; not detect that the Address base had already been set and could try
+; to set the Address to be relative to a register instead, triggering
+; an assertion.
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+define i32 @foo() {
+  %stack_addr = alloca i32
+  %stack_i = ptrtoint i32* %stack_addr to i32
+  %added = add i32 %stack_i, undef
+  %added_addr = inttoptr i32 %added to i32*
+  %ret = load i32, i32* %added_addr
+  ret i32 %ret
+}



___
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] 6b043ec - [MLIR] Fix genTypeInterfaceMethods() to work correctly with InferTypeOpInterface

2020-12-01 Thread Rahul Joshi via llvm-branch-commits

Author: Rahul Joshi
Date: 2020-12-01T13:36:25-08:00
New Revision: 6b043ecdb71bb0354cbd64d766cc21b7d20dca84

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

LOG: [MLIR] Fix genTypeInterfaceMethods() to work correctly with 
InferTypeOpInterface

- Change InferTypeOpInterface::inferResultTypes to use fully qualified types 
matching
  the ones generated by genTypeInterfaceMethods, so the redundancy can be 
detected.
- Move genTypeInterfaceMethods() before genOpInterfaceMethods() so that the
  inferResultTypes method generated by genTypeInterfaceMethods() takes 
precedence
  over the declaration that might be generated by genOpInterfaceMethods()
- Modified an op in the test dialect to exercise this (the modified op would 
fail to
  generate valid C++ code due to duplicate inferResultTypes methods).

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

Added: 


Modified: 
mlir/include/mlir/Interfaces/InferTypeOpInterface.td
mlir/test/lib/Dialect/Test/TestOps.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 




diff  --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td 
b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
index c5132986ec97..ed62e9015bde 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
@@ -38,19 +38,20 @@ def InferTypeOpInterface : 
OpInterface<"InferTypeOpInterface"> {
   }],
   /*retTy=*/"LogicalResult",
   /*methodName=*/"inferReturnTypes",
-  /*args=*/(ins "MLIRContext*":$context,
-"Optional":$location,
-"ValueRange":$operands,
-"DictionaryAttr":$attributes,
-"RegionRange":$regions,
-"SmallVectorImpl&":$inferredReturnTypes)
+  /*args=*/(ins "::mlir::MLIRContext *":$context,
+"::llvm::Optional<::mlir::Location>":$location,
+"::mlir::ValueRange":$operands,
+"::mlir::DictionaryAttr":$attributes,
+"::mlir::RegionRange":$regions,
+
"::llvm::SmallVectorImpl<::mlir::Type>&":$inferredReturnTypes)
 >,
 StaticInterfaceMethod<
   /*desc=*/"Returns whether two array of types are compatible result types"
" for an op.",
   /*retTy=*/"bool",
   /*methodName=*/"isCompatibleReturnTypes",
-  /*args=*/(ins "ArrayRef":$lhs, "ArrayRef":$rhs),
+  /*args=*/(ins "::llvm::ArrayRef<::mlir::Type>":$lhs,
+"::llvm::ArrayRef<::mlir::Type>":$rhs),
   /*methodBody=*/[{
 return ConcreteOp::isCompatibleReturnTypes(lhs, rhs);
   }],

diff  --git a/mlir/test/lib/Dialect/Test/TestOps.td 
b/mlir/test/lib/Dialect/Test/TestOps.td
index 5a17eebfd32c..995022ab2115 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -1000,7 +1000,7 @@ def ThreeResultOp : TEST_Op<"three_result"> {
   let results = (outs I32:$result1, F32:$result2, F32:$result3);
 }
 
-def AnotherThreeResultOp : TEST_Op<"another_three_result"> {
+def AnotherThreeResultOp : TEST_Op<"another_three_result", 
[DeclareOpInterfaceMethods]> {
   let arguments = (ins MultiResultOpEnum:$kind);
   let results = (outs I32:$result1, F32:$result2, F32:$result3);
 }

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp 
b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 65ae32f4f5a4..eabdd06fad5d 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -453,10 +453,10 @@ OpEmitter::OpEmitter(const Operator &op)
   genVerifier();
   genCanonicalizerDecls();
   genFolderDecls();
+  genTypeInterfaceMethods();
   genOpInterfaceMethods();
   generateOpFormat(op, opClass);
   genSideEffectInterfaceMethods();
-  genTypeInterfaceMethods();
 }
 
 void OpEmitter::emitDecl(const Operator &op, raw_ostream &os) {
@@ -1739,7 +1739,6 @@ void OpEmitter::genTypeInterfaceMethods() {
   auto *method =
   opClass.addMethodAndPrune("::mlir::LogicalResult", "inferReturnTypes",
 OpMethod::MP_Static, std::move(paramList));
-
   auto &body = method->body();
   body << "  inferredReturnTypes.resize(" << op.getNumResults() << ");\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] 99d8241 - [LLD][ELF][NewPM] Add option to force legacy PM

2020-12-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-01T13:41:17-08:00
New Revision: 99d82412f822190a6caa3e3a5b9f87b71f56de47

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

LOG: [LLD][ELF][NewPM] Add option to force legacy PM

In preparation for the NPM switch.

Reviewed By: MaskRay

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

Added: 


Modified: 
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/test/ELF/lto/new-pass-manager.ll

Removed: 




diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 860c74fa0d20..395b6200aa08 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -988,7 +988,8 @@ static void readConfigs(opt::InputArgList &args) {
   config->ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file);
   config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager);
   config->ltoEmitAsm = args.hasArg(OPT_lto_emit_asm);
-  config->ltoNewPassManager = args.hasArg(OPT_lto_new_pass_manager);
+  config->ltoNewPassManager = args.hasFlag(OPT_lto_new_pass_manager,
+   OPT_no_lto_new_pass_manager, false);
   config->ltoNewPmPasses = args.getLastArgValue(OPT_lto_newpm_passes);
   config->ltoWholeProgramVisibility =
   args.hasFlag(OPT_lto_whole_program_visibility,

diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index fc7089f63229..c3490b6f9d7a 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -526,8 +526,9 @@ def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
   HelpText<"Debug new pass manager">;
 def lto_emit_asm: FF<"lto-emit-asm">,
   HelpText<"Emit assembly code">;
-def lto_new_pass_manager: FF<"lto-new-pass-manager">,
-  HelpText<"Use new pass manager">;
+defm lto_new_pass_manager: BB<"lto-new-pass-manager",
+  "Use new pass manager",
+  "Use legacy pass manager">;
 def lto_newpm_passes: JJ<"lto-newpm-passes=">,
   HelpText<"Passes to run during LTO">;
 def lto_O: JJ<"lto-O">, MetaVarName<"">,

diff  --git a/lld/test/ELF/lto/new-pass-manager.ll 
b/lld/test/ELF/lto/new-pass-manager.ll
index 84f4ad1856e4..941235b48630 100644
--- a/lld/test/ELF/lto/new-pass-manager.ll
+++ b/lld/test/ELF/lto/new-pass-manager.ll
@@ -2,13 +2,15 @@
 ; RUN: opt -module-summary %s -o %t.o
 
 ; Test new-pass-manager and debug-pass-manager option
-; RUN: ld.lld --plugin-opt=new-pass-manager --plugin-opt=debug-pass-manager -o 
%t2.o %t.o 2>&1 | FileCheck %s
-; RUN: ld.lld --plugin-opt=new-pass-manager --lto-debug-pass-manager -o %t2.o 
%t.o 2>&1 | FileCheck %s
-; RUN: ld.lld --lto-new-pass-manager --plugin-opt=debug-pass-manager -o %t2.o 
%t.o 2>&1 | FileCheck %s
-; RUN: ld.lld --lto-new-pass-manager --lto-debug-pass-manager -o %t2.o %t.o 
2>&1 | FileCheck %s
+; RUN: ld.lld --plugin-opt=new-pass-manager --plugin-opt=debug-pass-manager -o 
/dev/null %t.o 2>&1 | FileCheck %s
+; RUN: ld.lld --plugin-opt=new-pass-manager --lto-debug-pass-manager -o 
/dev/null %t.o 2>&1 | FileCheck %s
+; RUN: ld.lld --lto-new-pass-manager --plugin-opt=debug-pass-manager -o 
/dev/null %t.o 2>&1 | FileCheck %s
+; RUN: ld.lld --lto-new-pass-manager --lto-debug-pass-manager -o /dev/null 
%t.o 2>&1 | FileCheck %s
+; RUN: ld.lld --lto-new-pass-manager --no-lto-new-pass-manager 
--lto-debug-pass-manager -o /dev/null %t.o 2>&1 | FileCheck %s 
--check-prefix=LEGACY
 
 ; CHECK: Starting llvm::Module pass manager run
 ; CHECK: Finished llvm::Module pass manager run
+; LEGACY-NOT: Starting llvm::Module pass manager run
 
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"



___
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] 2671fcc - [libc++] NFC: Remove unused macros in <__config>

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

Author: Louis Dionne
Date: 2020-12-01T16:51:25-05:00
New Revision: 2671fccf0381769276ca8246ec0499adcb9b0355

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

LOG: [libc++] NFC: Remove unused macros in <__config>

Added: 


Modified: 
libcxx/include/__config

Removed: 




diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 0b850f192d54..1a206680ecdc 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -442,10 +442,6 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_NORETURN __attribute__ ((noreturn))
 #endif
 
-#if !(__has_feature(cxx_lambdas))
-#define _LIBCPP_HAS_NO_LAMBDAS
-#endif
-
 #if !(__has_feature(cxx_nullptr))
 #  if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && 
defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
 #define nullptr __nullptr
@@ -454,10 +450,6 @@ typedef __char32_t char32_t;
 #  endif
 #endif
 
-#if !(__has_feature(cxx_auto_type))
-#define _LIBCPP_HAS_NO_AUTO_TYPE
-#endif
-
 // Objective-C++ features (opt-in)
 #if __has_feature(objc_arc)
 #define _LIBCPP_HAS_OBJC_ARC



___
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] 8b89bc0 - [WebAssembly] Don't fold frame offset for global addresses

2020-12-01 Thread Tom Stellard via llvm-branch-commits

Author: Julien Jorge
Date: 2020-12-01T13:56:00-08:00
New Revision: 8b89bc0de0e190be04991a9622c5866a2e93ef6d

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

LOG: [WebAssembly] Don't fold frame offset for global addresses

When machine instructions are in the form of
```
%0 = CONST_I32 @str
%1 = ADD_I32 %stack.0, %0
%2 = LOAD 0, 0, %1
```

In the `ADD_I32` instruction, it is possible to fold it if `%0` is a
`CONST_I32` from an immediate number. But in this case it is a global
address, so we shouldn't do that. But we haven't checked if the operand
of `ADD` is an immediate so far. This fixes the problem. (The case
applies the same for `ADD_I64` and `CONST_I64` instructions.)

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

Patch by Julien Jorge (jjo...@quarkslab.com)

Reviewed By: dschuff

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

(cherry picked from commit 0fca6517118d435f9c2d7afe6135fd5f357509b5)

Added: 


Modified: 
llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
llvm/test/CodeGen/WebAssembly/userstack.ll

Removed: 




diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
index 5ff0d73534a6..085910f01ee6 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
@@ -328,7 +328,9 @@ defm CONST_F64 : I<(outs F64:$res), (ins f64imm_op:$imm),
 } // isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1
 
 def : Pat<(i32 (WebAssemblywrapper tglobaladdr:$addr)),
-  (CONST_I32 tglobaladdr:$addr)>, Requires<[IsNotPIC]>;
+  (CONST_I32 tglobaladdr:$addr)>, Requires<[IsNotPIC, HasAddr32]>;
+def : Pat<(i64 (WebAssemblywrapper tglobaladdr:$addr)),
+  (CONST_I64 tglobaladdr:$addr)>, Requires<[IsNotPIC, HasAddr64]>;
 
 def : Pat<(i32 (WebAssemblywrapper tglobaladdr:$addr)),
   (GLOBAL_GET_I32 tglobaladdr:$addr)>, Requires<[IsPIC]>;

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
index 130589c9df8c..6b6394a58339 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
@@ -101,10 +101,12 @@ void WebAssemblyRegisterInfo::eliminateFrameIndex(
   WebAssemblyFrameLowering::getOpcConst(MF) &&
 MRI.hasOneNonDBGUse(Def->getOperand(0).getReg())) {
   MachineOperand &ImmMO = Def->getOperand(1);
-  ImmMO.setImm(ImmMO.getImm() + uint32_t(FrameOffset));
-  MI.getOperand(FIOperandNum)
-  .ChangeToRegister(FrameRegister, /*isDef=*/false);
-  return;
+  if (ImmMO.isImm()) {
+ImmMO.setImm(ImmMO.getImm() + uint32_t(FrameOffset));
+MI.getOperand(FIOperandNum)
+.ChangeToRegister(FrameRegister, /*isDef=*/false);
+return;
+  }
 }
   }
 }

diff  --git a/llvm/test/CodeGen/WebAssembly/userstack.ll 
b/llvm/test/CodeGen/WebAssembly/userstack.ll
index dec202ea6af9..3d0e0d8c86a0 100644
--- a/llvm/test/CodeGen/WebAssembly/userstack.ll
+++ b/llvm/test/CodeGen/WebAssembly/userstack.ll
@@ -328,6 +328,22 @@ define void @inline_asm() {
   ret void
 }
 
+; We optimize the format of "frame offset + operand" by folding it, but this is
+; only possible when that operand is an immediate. In this example it is a
+; global address, so we should not fold it.
+; CHECK-LABEL: frame_offset_with_global_address
+; CHECK: i[[PTR]].const ${{.*}}=, str
+@str = local_unnamed_addr global [3 x i8] c"abc", align 16
+define i8 @frame_offset_with_global_address() {
+  %1 = alloca i8, align 4
+  %2 = ptrtoint i8* %1 to i32
+  ;; Here @str is a global address and not an immediate, so cannot be folded
+  %3 = getelementptr [3 x i8], [3 x i8]* @str, i32 0, i32 %2
+  %4 = load i8, i8* %3, align 8
+  %5 = and i8 %4, 67
+  ret i8 %5
+}
+
 ; CHECK: .globaltype   __stack_pointer, i[[PTR]]{{$}}
 
 ; TODO: test over-aligned alloca



___
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] aafb366 - Reland [CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into llvm/

2020-12-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-01T14:00:32-08:00
New Revision: aafb3662103f4b3df315967c0cf4f6eec6bff0c4

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

LOG: Reland [CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into llvm/

This allows us to use its value everywhere, rather than just clang. Some
other places, like opt and lld, will use its value soon.

Rename it internally to LLVM_ENABLE_NEW_PASS_MANAGER.

The #define for it is now in llvm-config.h.

The initial land accidentally set the value of
LLVM_ENABLE_NEW_PASS_MANAGER to the string
ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER instead of its value.

Reviewed By: rnk, hans

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
llvm/CMakeLists.txt
llvm/include/llvm/Config/llvm-config.h.cmake
llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 8c539e80946d..f947b820bdac 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -242,9 +242,6 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id 
to ld")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
 "enable x86 relax relocations by default")
 
-set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
-  "Enable the experimental new pass manager by default.")
-
 set(CLANG_SPAWN_CC1 OFF CACHE BOOL
 "Whether clang should use a new process for the CC1 invocation")
 

diff  --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 26e9d5c4eb4d..a240862c5289 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -75,9 +75,6 @@
 /* enable x86 relax relocations by default */
 #cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS
 
-/* Enable the experimental new pass manager by default */
-#cmakedefine01 ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
-
 /* Enable each functionality of modules */
 #cmakedefine01 CLANG_ENABLE_ARCMT
 #cmakedefine01 CLANG_ENABLE_OBJC_REWRITER

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 48d0e2d6235b..6e37a3154bdf 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1349,7 +1349,7 @@ def fglobal_isel : Flag<["-"], "fglobal-isel">, 
Group,
 def fexperimental_isel : Flag<["-"], "fexperimental-isel">, 
Group,
   Alias;
 defm experimental_new_pass_manager : 
BooleanMarshalledFFlag<"experimental-new-pass-manager", 
"CodeGenOpts.ExperimentalNewPassManager",
-  "static_cast(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER)", "Enables an 
experimental new pass manager in LLVM.",
+  "static_cast(LLVM_ENABLE_NEW_PASS_MANAGER)", "Enables an 
experimental new pass manager in LLVM.",
   "Disables an experimental new pass manager in LLVM.">, Group, 
Flags<[CC1Option]>;
 def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
   Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index d765b4cb598d..034fab229ef6 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -37,6 +37,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Config/llvm-config.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
@@ -597,7 +598,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const 
ArgList &Args,
   // Need this flag to turn on new pass manager via Gold plugin.
   if (Args.hasFlag(options::OPT_fexperimental_new_pass_manager,
options::OPT_fno_experimental_new_pass_manager,
-   /* Default */ ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER)) {
+   /* Default */ LLVM_ENABLE_NEW_PASS_MANAGER)) {
 CmdArgs.push_back("-plugin-opt=new-pass-manager");
   }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f72e0fc10a32..068c8608ca65 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -58,6 +58,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DebugInfoMetadata.

[llvm-branch-commits] [clang] 1b8ed1d - [OpenMP51][DOCS] Claim "add present modifier in defaultmap clause", NFC.

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

Author: cchen
Date: 2020-12-01T16:07:00-06:00
New Revision: 1b8ed1d03dee63fd0b787ab52d0b195df9c35b9c

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

LOG: [OpenMP51][DOCS] Claim "add present modifier in defaultmap clause", NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 227b373957ea..afa357a4d873 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -272,7 +272,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+
-| device extension | 'present' in defaultmap clause
   | :none:`unclaimed`| 
  |
+| device extension | 'present' in defaultmap clause
   | :part:`worked on`| D92427  
  |
 
+--+--+--+---+
 | device extension | map clause reordering reordering based on 
'present' modifier | :none:`unclaimed`| 
  |
 
+--+--+--+---+



___
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] 26b8ea2 - RegisterInfoPOSIX_arm64 remove unused bytes from g/G packet

2020-12-01 Thread Muhammad Omair Javaid via llvm-branch-commits

Author: Muhammad Omair Javaid
Date: 2020-12-02T03:19:39+05:00
New Revision: 26b8ea2e3782890be96612701866d8ccec616bdc

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

LOG: RegisterInfoPOSIX_arm64 remove unused bytes from g/G packet

This came up while putting together our new strategy to create g/G packets
in compliance with GDB RSP protocol where register offsets are calculated in
increasing order of register numbers without any unused spacing.

RegisterInfoPOSIX_arm64::GPR size was being calculated after alignment
correction to 8 bytes which meant there was a 4 bytes unused space between
last gpr (cpsr) and first vector register V. We have put LLVM_PACKED_START
decorator on RegisterInfoPOSIX_arm64::GPR to make sure single byte
alignment is enforced. Moreover we are now doing to use arm64 user_pt_regs
struct defined in ptrace.h for accessing ptrace user registers.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index 49badd8ef940..6b2dd25ba44d 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -936,9 +936,9 @@ Status NativeRegisterContextLinux_arm64::ReadGPR() {
 
   struct iovec ioVec;
   ioVec.iov_base = GetGPRBuffer();
-  ioVec.iov_len = GetGPRSize();
+  ioVec.iov_len = GetGPRBufferSize();
 
-  error = ReadRegisterSet(&ioVec, GetGPRSize(), NT_PRSTATUS);
+  error = ReadRegisterSet(&ioVec, GetGPRBufferSize(), NT_PRSTATUS);
 
   if (error.Success())
 m_gpr_is_valid = true;
@@ -953,11 +953,11 @@ Status NativeRegisterContextLinux_arm64::WriteGPR() {
 
   struct iovec ioVec;
   ioVec.iov_base = GetGPRBuffer();
-  ioVec.iov_len = GetGPRSize();
+  ioVec.iov_len = GetGPRBufferSize();
 
   m_gpr_is_valid = false;
 
-  return WriteRegisterSet(&ioVec, GetGPRSize(), NT_PRSTATUS);
+  return WriteRegisterSet(&ioVec, GetGPRBufferSize(), NT_PRSTATUS);
 }
 
 Status NativeRegisterContextLinux_arm64::ReadFPR() {

diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
index 3d0656dceb62..9ba8c7699a56 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -95,6 +95,10 @@ class NativeRegisterContextLinux_arm64 : public 
NativeRegisterContextLinux {
 
   void *GetGPRBuffer() override { return &m_gpr_arm64; }
 
+  // GetGPRBufferSize returns sizeof arm64 GPR ptrace buffer, it is 
diff erent
+  // from GetGPRSize which returns sizeof RegisterInfoPOSIX_arm64::GPR.
+  size_t GetGPRBufferSize() { return sizeof(m_gpr_arm64); }
+
   void *GetFPRBuffer() override { return &m_fpr; }
 
   size_t GetFPRSize() override { return sizeof(m_fpr); }
@@ -106,7 +110,7 @@ class NativeRegisterContextLinux_arm64 : public 
NativeRegisterContextLinux {
 
   bool m_sve_header_is_valid;
 
-  RegisterInfoPOSIX_arm64::GPR m_gpr_arm64; // 64-bit general purpose 
registers.
+  struct user_pt_regs m_gpr_arm64; // 64-bit general purpose registers.
 
   RegisterInfoPOSIX_arm64::FPU
   m_fpr; // floating-point registers including extended register sets.

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
index 37f7c23b62c5..1cbed5acb41c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -29,6 +29,7 @@ class RegisterInfoPOSIX_arm64
   };
 
   // based on RegisterContextDarwin_arm64.h
+  LLVM_PACKED_START
   struct GPR {
 uint64_t x[29]; // x0-x28
 uint64_t fp;// x29
@@ -37,6 +38,7 @@ class RegisterInfoPOSIX_arm64
 uint64_t pc;// pc
 uint32_t cpsr;  // cpsr
   };
+  LLVM_PACKED_END
 
   // based on RegisterContextDarwin_arm64.h
   struct VReg {



___
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] 78cb456 - Make offset field optional in RegisterInfo packet for Arm64

2020-12-01 Thread Muhammad Omair Javaid via llvm-branch-commits

Author: Muhammad Omair Javaid
Date: 2020-12-02T03:19:43+05:00
New Revision: 78cb4562faa7315fff030593bc6bca4dc033f803

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

LOG: Make offset field optional in RegisterInfo packet for Arm64

This patch carries forward our aim to remove offset field from qRegisterInfo
packets and XML register description. I have created a new function which
returns if offset fields are dynamic meaning client can calculate offset on
its own based on register number sequence and register size. For now this
function only returns true for NativeRegisterContextLinux_arm64 but we can
test this for other architectures and make it standard later.

As a consequence we do not send offset field from lldb-server (arm64 for now)
while other stubs dont have an offset field so it wont effect them for now.
On the client side we have replaced previous offset calculation algorithm
with a new scheme, where we sort all primary registers in increasing
order of remote regnum and then calculate offset incrementally.

This committ also includes a test to verify all of above functionality
on Arm64.

Reviewed By: labath

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

Added: 
lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py

Modified: 
lldb/include/lldb/Host/common/NativeRegisterContext.h
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp
lldb/unittests/tools/lldb-server/tests/TestClient.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/common/NativeRegisterContext.h 
b/lldb/include/lldb/Host/common/NativeRegisterContext.h
index a8c74358c718..f7568fe31b80 100644
--- a/lldb/include/lldb/Host/common/NativeRegisterContext.h
+++ b/lldb/include/lldb/Host/common/NativeRegisterContext.h
@@ -121,6 +121,8 @@ class NativeRegisterContext
   virtual std::vector
   GetExpeditedRegisters(ExpeditedRegs expType) const;
 
+  virtual bool RegisterOffsetIsDynamic() const { return false; }
+
   const RegisterInfo *GetRegisterInfoByName(llvm::StringRef reg_name,
 uint32_t start_idx = 0);
 

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index a1c420d1fa03..2f278289988c 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -664,7 +664,10 @@ def assert_valid_reg_info(self, reg_info):
 # Check the bare-minimum expected set of register info keys.
 self.assertTrue("name" in reg_info)
 self.assertTrue("bitsize" in reg_info)
-self.assertTrue("offset" in reg_info)
+
+if not self.getArchitecture() == 'aarch64':
+self.assertTrue("offset" in reg_info)
+
 self.assertTrue("encoding" in reg_info)
 self.assertTrue("format" in reg_info)
 

diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
index 9ba8c7699a56..344eae247e91 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -47,6 +47,8 @@ class NativeRegisterContextLinux_arm64 : public 
NativeRegisterContextLinux {
   std::vector
   GetExpeditedRegisters(ExpeditedRegs expType) const override;
 
+  bool RegisterOffsetIsDynamic() const override { return true; }
+
   // Hardware breakpoints/watchpoint management functions
 
   uint32_t NumSupportedHardwareBreakpoints() override;

diff  --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp 
b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index fd9e1923104d..71e9b5ea4b2a 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -428,9 +428,6 @@ void DynamicRegisterInfo::AddRegister(RegisterInfo 
®_info,
   assert(set < m_set_reg_nums.size());
   assert(set < m_set_names.size());
   m_set_reg_nums[set].push_back(reg_num);
-  size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_siz

[llvm-branch-commits] [lldb] e1f613c - [lldb] [test] Reenable two passing tests on FreeBSD

2020-12-01 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-12-01T23:25:45+01:00
New Revision: e1f613ce3c61d0664fd3cff663f290cf1c2b9696

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

LOG: [lldb] [test] Reenable two passing tests on FreeBSD

[Reenable TestReproducerAttach and TestThreadSpecificBpPlusCondition
on FreeBSD -- both seem to pass correctly now.

Added: 


Modified: 
lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py

lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py 
b/lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py
index e6bb9c6a1672..a1cfcd20013e 100644
--- a/lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py
+++ b/lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py
@@ -15,7 +15,6 @@ class ReproducerAttachTestCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 NO_DEBUG_INFO_TESTCASE = True
 
-@skipIfFreeBSD
 @skipIfNetBSD
 @skipIfWindows
 @skipIfRemote

diff  --git 
a/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
 
b/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
index 126ad9e97ee5..ee7398ae5dfc 100644
--- 
a/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
+++ 
b/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
@@ -16,10 +16,8 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 # test frequently times out or hangs
-@skipIf(oslist=['windows', 'freebsd'])
 @skipIfDarwin
 # hits break in another thread in testrun
-@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522')
 @add_test_categories(['pyapi'])
 @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], 
archs=['armv7', 'armv7k'], bugnumber='rdar://problem/34563348') # Two threads 
seem to end up with the same my_value when built for armv7.
 @expectedFailureNetBSD



___
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] 6b3eecd - [lld-macho] Extend PIE option handling

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

Author: Jez Ng
Date: 2020-12-01T14:35:51-08:00
New Revision: 6b3eecd22ab2afd16be412d19eed0e01f10e6cc8

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

LOG: [lld-macho] Extend PIE option handling

* Enable PIE by default if targeting 10.6 or above on x86-64. (The
  manpage says 10.7, but that actually applies only to i386, and in
  general varies based on the target platform. I didn't update the
  manpage because listing all the different behaviors would make for a
  pretty long description.)
* Add support for `-no_pie`
* Remove `HelpHidden` from `-pie`

Reviewed By: thakis

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

Added: 


Modified: 
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/x86-64-reloc-unsigned.s

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 58a41c2b3af1..141082985b4e 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -555,6 +555,21 @@ static const char *getReproduceOption(opt::InputArgList 
&args) {
   return getenv("LLD_REPRODUCE");
 }
 
+static bool isPie(opt::InputArgList &args) {
+  if (config->outputType != MH_EXECUTE || args.hasArg(OPT_no_pie))
+return false;
+
+  // TODO: add logic here as we support more archs. E.g. i386 should default
+  // to PIE from 10.7, arm64 should always be PIE, etc
+  assert(config->arch == AK_x86_64 || config->arch == AK_x86_64h);
+
+  if (config->platform.kind == MachO::PlatformKind::macOS &&
+  config->platform.minimum >= VersionTuple(10, 6))
+return true;
+
+  return args.hasArg(OPT_pie);
+}
+
 bool macho::link(llvm::ArrayRef argsArr, bool canExitEarly,
  raw_ostream &stdoutOS, raw_ostream &stderrOS) {
   lld::stdoutOS = &stdoutOS;
@@ -690,8 +705,7 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
   }
 
   config->isPic = config->outputType == MH_DYLIB ||
-  config->outputType == MH_BUNDLE ||
-  (config->outputType == MH_EXECUTE && args.hasArg(OPT_pie));
+  config->outputType == MH_BUNDLE || isPie(args);
 
   // Now that all dylibs have been loaded, search for those that should be
   // re-exported.

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index de7cbf7faf3e..399928e8d9ae 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -315,11 +315,9 @@ def grp_main : OptionGroup<"main">, HelpText<"MAIN 
EXECUTABLE">;
 
 def pie : Flag<["-"], "pie">,
  HelpText<"Build a position independent executable (default for macOS 10.7 
and later)">,
- Flags<[HelpHidden]>,
  Group;
 def no_pie : Flag<["-"], "no_pie">,
  HelpText<"Do not build a position independent executable (default for 
macOS 10.6 and earlier)">,
- Flags<[HelpHidden]>,
  Group;
 def pagezero_size : Separate<["-"], "pagezero_size">,
  MetaVarName<"">,

diff  --git a/lld/test/MachO/x86-64-reloc-unsigned.s 
b/lld/test/MachO/x86-64-reloc-unsigned.s
index e3608f318d22..c6e5eb665739 100644
--- a/lld/test/MachO/x86-64-reloc-unsigned.s
+++ b/lld/test/MachO/x86-64-reloc-unsigned.s
@@ -3,8 +3,17 @@
 # RUN: %lld -o %t %t.o
 # RUN: llvm-objdump --macho --rebase --full-contents %t | FileCheck %s
 
-# RUN: %lld -pie -o %t-pie %t.o
+# RUN: %lld -fatal_warnings -pie -o %t-pie %t.o
 # RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
+# RUN: %lld -fatal_warnings -pie -no_pie -o %t-no-pie %t.o
+# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s 
--check-prefix=NO-PIE
+# RUN: %lld -fatal_warnings -no_pie -pie -o %t-no-pie %t.o
+# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s 
--check-prefix=NO-PIE
+
+# RUN: %lld -platform_version macos 10.6.0 11.0 -o %t-pie %t.o
+# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
+# RUN: %lld -platform_version macos 10.5.0 11.0 -o %t-no-pie %t.o
+# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s 
--check-prefix=NO-PIE
 
 # CHECK:   Contents of section __DATA,foo:
 # CHECK-NEXT:  11000 0810 0100
@@ -21,6 +30,10 @@
 # PIE-DAG:  __DATA   bar0x[[#ADDR + 12]]  pointer
 # PIE-DAG:  __DATA   baz0x[[#ADDR + 20]]  pointer
 
+# NO-PIE:  Rebase table:
+# NO-PIE-NEXT: segment  sectionaddress   type
+# NO-PIE-EMPTY:
+
 .globl _main, _foo, _bar
 
 .section __DATA,foo



___
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] 78b0ec3 - Avoid redundant inline with LLVM_ATTRIBUTE_ALWAYS_INLINE

2020-12-01 Thread David Blaikie via llvm-branch-commits

Author: James Park
Date: 2020-12-01T14:43:16-08:00
New Revision: 78b0ec3d1c5cc198093bb03ecb86bca25fe570ca

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

LOG: Avoid redundant inline with LLVM_ATTRIBUTE_ALWAYS_INLINE

Fix MSVC warning when __forceinline is paired with inline.

Reviewed By: dblaikie

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

Added: 


Modified: 
llvm/include/llvm/IR/User.h
llvm/include/llvm/Support/Compiler.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h
index ebfae1db2980..221bb5b2cb1c 100644
--- a/llvm/include/llvm/IR/User.h
+++ b/llvm/include/llvm/IR/User.h
@@ -45,7 +45,7 @@ class User : public Value {
   template 
   friend struct HungoffOperandTraits;
 
-  LLVM_ATTRIBUTE_ALWAYS_INLINE inline static void *
+  LLVM_ATTRIBUTE_ALWAYS_INLINE static void *
   allocateFixedOperandUser(size_t, unsigned, unsigned);
 
 protected:

diff  --git a/llvm/include/llvm/Support/Compiler.h 
b/llvm/include/llvm/Support/Compiler.h
index d7001a5c289a..a9e4f7f8353d 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -234,11 +234,11 @@
 /// 3.4 supported this but is buggy in various cases and produces unimplemented
 /// errors, just use it in GCC 4.0 and later.
 #if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0)
-#define LLVM_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
+#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline))
 #elif defined(_MSC_VER)
 #define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline
 #else
-#define LLVM_ATTRIBUTE_ALWAYS_INLINE
+#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
 #endif
 
 #ifdef __GNUC__

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 6c73842414cb..43dbc3df16df 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -2294,7 +2294,7 @@ void SelectionDAGISel::Select_FREEZE(SDNode *N) {
 }
 
 /// GetVBR - decode a vbr encoding whose top bit is set.
-LLVM_ATTRIBUTE_ALWAYS_INLINE static inline uint64_t
+LLVM_ATTRIBUTE_ALWAYS_INLINE static uint64_t
 GetVBR(uint64_t Val, const unsigned char *MatcherTable, unsigned &Idx) {
   assert(Val >= 128 && "Not a VBR");
   Val &= 127;  // Remove first vbr bit.
@@ -2491,10 +2491,9 @@ MorphNode(SDNode *Node, unsigned TargetOpc, SDVTList 
VTList,
 }
 
 /// CheckSame - Implements OP_CheckSame.
-LLVM_ATTRIBUTE_ALWAYS_INLINE static inline bool
-CheckSame(const unsigned char *MatcherTable, unsigned &MatcherIndex,
-  SDValue N,
-  const SmallVectorImpl> &RecordedNodes) {
+LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
+CheckSame(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N,
+  const SmallVectorImpl> &RecordedNodes) {
   // Accept if it is exactly the same as a previously recorded node.
   unsigned RecNo = MatcherTable[MatcherIndex++];
   assert(RecNo < RecordedNodes.size() && "Invalid CheckSame");
@@ -2502,11 +2501,10 @@ CheckSame(const unsigned char *MatcherTable, unsigned 
&MatcherIndex,
 }
 
 /// CheckChildSame - Implements OP_CheckChildXSame.
-LLVM_ATTRIBUTE_ALWAYS_INLINE static inline bool
-CheckChildSame(const unsigned char *MatcherTable, unsigned &MatcherIndex,
-  SDValue N,
-  const SmallVectorImpl> 
&RecordedNodes,
-  unsigned ChildNo) {
+LLVM_ATTRIBUTE_ALWAYS_INLINE static bool CheckChildSame(
+const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N,
+const SmallVectorImpl> &RecordedNodes,
+unsigned ChildNo) {
   if (ChildNo >= N.getNumOperands())
 return false;  // Match fails if out of range child #.
   return ::CheckSame(MatcherTable, MatcherIndex, N.getOperand(ChildNo),
@@ -2514,20 +2512,20 @@ CheckChildSame(const unsigned char *MatcherTable, 
unsigned &MatcherIndex,
 }
 
 /// CheckPatternPredicate - Implements OP_CheckPatternPredicate.
-LLVM_ATTRIBUTE_ALWAYS_INLINE static inline bool
+LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
 CheckPatternPredicate(const unsigned char *MatcherTable, unsigned 
&MatcherIndex,
   const SelectionDAGISel &SDISel) {
   return SDISel.CheckPatternPredicate(MatcherTable[MatcherIndex++]);
 }
 
 /// CheckNodePredicate - Implements OP_CheckNodePredicate.
-LLVM_ATTRIBUTE_ALWAYS_INLINE static inline bool
+LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
 CheckNodePredicate(const unsigned char *MatcherTable, unsigned &MatcherIndex,
const SelectionDAGISel &SDISel, SDNode *N) {
   return SDISel.CheckNodePredicate(N, MatcherTable[MatcherIndex++]);
 }
 
-LLVM_ATTRIBUTE_ALWAYS_INLINE static inline bool
+LLVM_ATTRIBUTE_ALWAY

[llvm-branch-commits] [llvm] 8fee2ee - [ms] [llvm-ml] Introduce command-line compatibility for ml.exe and ml64.exe

2020-12-01 Thread Eric Astor via llvm-branch-commits

Author: Eric Astor
Date: 2020-12-01T17:43:44-05:00
New Revision: 8fee2ee9a689276eaea61d4c3f124aa80a81b6f7

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

LOG: [ms] [llvm-ml] Introduce command-line compatibility for ml.exe and ml64.exe

Switch to OptParser for command-line handling

Reviewed By: thakis

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

Added: 
llvm/test/tools/llvm-ml/alias.asm
llvm/test/tools/llvm-ml/alias_errors.asm
llvm/test/tools/llvm-ml/basic_data.asm
llvm/test/tools/llvm-ml/builtin_types.asm
llvm/test/tools/llvm-ml/dot_operator.asm
llvm/test/tools/llvm-ml/expansion.asm
llvm/test/tools/llvm-ml/feat00.asm
llvm/test/tools/llvm-ml/feat00_override.asm
llvm/test/tools/llvm-ml/line_continuations.asm
llvm/test/tools/llvm-ml/macro.asm
llvm/test/tools/llvm-ml/macro_errors.asm
llvm/test/tools/llvm-ml/macro_function.asm
llvm/test/tools/llvm-ml/named_operators.asm
llvm/test/tools/llvm-ml/proc.asm
llvm/test/tools/llvm-ml/proc_frame.asm
llvm/test/tools/llvm-ml/radix.asm
llvm/test/tools/llvm-ml/radix_errors.asm
llvm/test/tools/llvm-ml/repeat_directives.asm
llvm/test/tools/llvm-ml/rip-relative-addressing.asm
llvm/test/tools/llvm-ml/run.asm
llvm/test/tools/llvm-ml/size_inference.asm
llvm/test/tools/llvm-ml/strings.asm
llvm/test/tools/llvm-ml/strings_errors.asm
llvm/test/tools/llvm-ml/struct.asm
llvm/test/tools/llvm-ml/struct_alignment.asm
llvm/test/tools/llvm-ml/struct_errors.asm
llvm/test/tools/llvm-ml/type_operators.asm
llvm/test/tools/llvm-ml/variable.asm
llvm/tools/llvm-ml/Opts.td

Modified: 
llvm/test/tools/llvm-ml/basic.test
llvm/test/tools/llvm-ml/lit.local.cfg
llvm/tools/llvm-ml/CMakeLists.txt
llvm/tools/llvm-ml/llvm-ml.cpp

Removed: 
llvm/test/tools/llvm-ml/alias.test
llvm/test/tools/llvm-ml/alias_errors.test
llvm/test/tools/llvm-ml/basic_data.test
llvm/test/tools/llvm-ml/builtin_types.test
llvm/test/tools/llvm-ml/dot_operator.test
llvm/test/tools/llvm-ml/expansion.test
llvm/test/tools/llvm-ml/feat00.test
llvm/test/tools/llvm-ml/feat00_override.test
llvm/test/tools/llvm-ml/line_continuations.test
llvm/test/tools/llvm-ml/macro.test
llvm/test/tools/llvm-ml/macro_errors.test
llvm/test/tools/llvm-ml/macro_function.test
llvm/test/tools/llvm-ml/named_operators.test
llvm/test/tools/llvm-ml/proc.test
llvm/test/tools/llvm-ml/proc_frame.test
llvm/test/tools/llvm-ml/radix.test
llvm/test/tools/llvm-ml/radix_errors.test
llvm/test/tools/llvm-ml/repeat_directives.test
llvm/test/tools/llvm-ml/rip-relative-addressing.test
llvm/test/tools/llvm-ml/run.test
llvm/test/tools/llvm-ml/size_inference.test
llvm/test/tools/llvm-ml/strings.test
llvm/test/tools/llvm-ml/strings_errors.test
llvm/test/tools/llvm-ml/struct.test
llvm/test/tools/llvm-ml/struct_alignment.test
llvm/test/tools/llvm-ml/struct_errors.test
llvm/test/tools/llvm-ml/type_operators.test
llvm/test/tools/llvm-ml/variable.test



diff  --git a/llvm/test/tools/llvm-ml/alias.test 
b/llvm/test/tools/llvm-ml/alias.asm
similarity index 96%
rename from llvm/test/tools/llvm-ml/alias.test
rename to llvm/test/tools/llvm-ml/alias.asm
index 2daaecdbbcc0..bd21f2b01c01 100644
--- a/llvm/test/tools/llvm-ml/alias.test
+++ b/llvm/test/tools/llvm-ml/alias.asm
@@ -1,4 +1,4 @@
-; RUN: llvm-ml -filetype=obj %s | llvm-readobj --syms - | FileCheck %s
+; RUN: llvm-ml %s /Fo - | llvm-readobj --syms - | FileCheck %s
 
 .code
 

diff  --git a/llvm/test/tools/llvm-ml/alias_errors.test 
b/llvm/test/tools/llvm-ml/alias_errors.asm
similarity index 87%
rename from llvm/test/tools/llvm-ml/alias_errors.test
rename to llvm/test/tools/llvm-ml/alias_errors.asm
index 9d51b2a993ac..7c30b8e261a2 100644
--- a/llvm/test/tools/llvm-ml/alias_errors.test
+++ b/llvm/test/tools/llvm-ml/alias_errors.asm
@@ -1,4 +1,4 @@
-; RUN: not llvm-ml -filetype=asm %s 2>&1 | FileCheck %s
+; RUN: not llvm-ml -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s
 
 .code
 

diff  --git a/llvm/test/tools/llvm-ml/basic.test 
b/llvm/test/tools/llvm-ml/basic.test
index 30aa860f2b90..960eb47f6cc5 100644
--- a/llvm/test/tools/llvm-ml/basic.test
+++ b/llvm/test/tools/llvm-ml/basic.test
@@ -1,3 +1,3 @@
-# RUN: not llvm-ml %t.blah -o /dev/null 2>&1 | FileCheck --check-prefix=ENOENT 
%s
+# RUN: not llvm-ml %t.blah.asm /Fo /dev/null 2>&1 | FileCheck 
--check-prefix=ENOENT %s
 
-# ENOENT: {{.*}}.blah: {{[Nn]}}o such file or directory
+# ENOENT: {{.*}}.blah.asm: {{[Nn]}}o such file or directory

diff  --git a/llvm/test/tools/llvm-ml/basic_data.test 
b/llvm/test/tools/llvm-ml/basic_data.asm
similarity index 92%
rename from llvm/test/tools/llvm-ml/basic_data.test
rename to l

[llvm-branch-commits] [libcxxabi] d67e58f - [libc++abi] Don't try calling __libcpp_aligned_free when aligned allocation is disabled

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

Author: Louis Dionne
Date: 2020-12-01T17:45:14-05:00
New Revision: d67e58f23a8232ee17dba3cd8c5b4c1378ddbc59

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

LOG: [libc++abi] Don't try calling __libcpp_aligned_free when aligned 
allocation is disabled

See https://reviews.llvm.org/rGa78aaa1ad512#962077 for details.

Added: 


Modified: 
libcxxabi/src/fallback_malloc.cpp

Removed: 




diff  --git a/libcxxabi/src/fallback_malloc.cpp 
b/libcxxabi/src/fallback_malloc.cpp
index 78720187affc..f3d7937793ce 100644
--- a/libcxxabi/src/fallback_malloc.cpp
+++ b/libcxxabi/src/fallback_malloc.cpp
@@ -234,7 +234,11 @@ void __aligned_free_with_fallback(void* ptr) {
   if (is_fallback_ptr(ptr))
 fallback_free(ptr);
   else {
+#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
+::free(ptr);
+#else
 std::__libcpp_aligned_free(ptr);
+#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] [lld] a38ed62 - [lld][WebAssembly] Feedback from D92038. NFC

2020-12-01 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2020-12-01T14:53:59-08:00
New Revision: a38ed62ea803a41c2e1f3fa12edbc176e474056f

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

LOG: [lld][WebAssembly] Feedback from D92038. NFC

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

Added: 


Modified: 
lld/test/wasm/weak-undefined-pic.s
lld/wasm/Symbols.h

Removed: 




diff  --git a/lld/test/wasm/weak-undefined-pic.s 
b/lld/test/wasm/weak-undefined-pic.s
index c12ef235d85f..a169fd315f08 100644
--- a/lld/test/wasm/weak-undefined-pic.s
+++ b/lld/test/wasm/weak-undefined-pic.s
@@ -27,7 +27,7 @@ _start:
 .weak foo
 .functype foo () -> (i32)
 
-# Verify that we do not generate dynamnic relocations for the GOT entry.
+# Verify that we do not generate dynamic relocations for the GOT entry.
 
 # CHECK-NOT: __wasm_apply_relocs
 
@@ -68,7 +68,7 @@ _start:
 # CHECK-NEXT:  - Index:   1
 # CHECK-NEXT:Name:'undefined_weak:foo'
 
-# With `-pie` or `-shared` the resolution should is defered to the dynamic
+# With `-pie` or `-shared` the resolution should be deferred to the dynamic
 # linker and the function address should be imported as GOT.func.foo.
 #
 # RUN: wasm-ld --experimental-pic -pie %t.o -o %t3.wasm

diff  --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h
index 90fb5194edcd..cfa686998de4 100644
--- a/lld/wasm/Symbols.h
+++ b/lld/wasm/Symbols.h
@@ -160,6 +160,9 @@ class Symbol {
   // True if this symbol is a linker-synthesized stub function (traps when
   // called) and should otherwise be treated as missing/undefined.  See
   // SymbolTable::replaceWithUndefined.
+  // These stubs never appear in the table and any table index relocations
+  // against them will produce address 0 (The table index representing
+  // the null function pointer).
   bool isStub : 1;
 
   uint32_t flags;



___
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] 1e4d6d1 - [clang-format] Add new option PenaltyIndentedWhitespace

2020-12-01 Thread Mark Nauwelaerts via llvm-branch-commits

Author: Mark Nauwelaerts
Date: 2020-12-01T23:59:44+01:00
New Revision: 1e4d6d1c1ff3f5a4d6e7dda053386ff411fd7de4

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

LOG: [clang-format] Add new option PenaltyIndentedWhitespace

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ccc59cd6fc19..6c5556a94391 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2301,6 +2301,10 @@ the configuration (without a prefix: ``Auto``).
 **PenaltyExcessCharacter** (``unsigned``)
   The penalty for each character outside of the column limit.
 
+**PenaltyIndentedWhitespace** (``unsigned``)
+  Penalty for each character of whitespace indentation
+  (counted relative to leading non-whitespace column).
+
 **PenaltyReturnTypeOnItsOwnLine** (``unsigned``)
   Penalty for putting the return type of a function onto its own
   line.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 587e588525df..dab4cbbbdfe1 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1913,6 +1913,10 @@ struct FormatStyle {
   /// line.
   unsigned PenaltyReturnTypeOnItsOwnLine;
 
+  /// Penalty for each character of whitespace indentation
+  /// (counted relative to leading non-whitespace column).
+  unsigned PenaltyIndentedWhitespace;
+
   /// The ``&`` and ``*`` alignment style.
   enum PointerAlignmentStyle {
 /// Align pointer to the left.

diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index d811f0f9e531..9db42b6c4a70 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -785,6 +785,22 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState 
&State,
 
   State.Column = getNewLineColumn(State);
 
+  // Add Penalty proportional to amount of whitespace away from FirstColumn
+  // This tends to penalize several lines that are far-right indented,
+  // and prefers a line-break prior to such a block, e.g:
+  //
+  // Constructor() :
+  //   member(value), long_member(
+  //  looong_call(param_1, param_2, param_3))
+  // would then become
+  // Constructor() :
+  //   member(value),
+  //   long_member(
+  //   looong_call(param_1, param_2, param_3))
+  if (State.Column > State.FirstIndent)
+Penalty +=
+Style.PenaltyIndentedWhitespace * (State.Column - State.FirstIndent);
+
   // Indent nested blocks relative to this column, unless in a very specific
   // JavaScript special case where:
   //

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1c566c9ea49d..235621c4f9aa 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -590,6 +590,8 @@ template <> struct MappingTraits {
 IO.mapOptional("PenaltyExcessCharacter", Style.PenaltyExcessCharacter);
 IO.mapOptional("PenaltyReturnTypeOnItsOwnLine",
Style.PenaltyReturnTypeOnItsOwnLine);
+IO.mapOptional("PenaltyIndentedWhitespace",
+   Style.PenaltyIndentedWhitespace);
 IO.mapOptional("PointerAlignment", Style.PointerAlignment);
 IO.mapOptional("RawStringFormats", Style.RawStringFormats);
 IO.mapOptional("ReflowComments", Style.ReflowComments);
@@ -968,6 +970,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 60;
   LLVMStyle.PenaltyBreakBeforeFirstCallParameter = 19;
   LLVMStyle.PenaltyBreakTemplateDeclaration = prec::Relational;
+  LLVMStyle.PenaltyIndentedWhitespace = 0;
 
   LLVMStyle.DisableFormat = false;
   LLVMStyle.SortIncludes = true;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 3d4e3e445c78..7addb5220ae7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -17214,6 +17214,28 @@ TEST_F(FormatTest, LikelyUnlikely) {
Style);
 }
 
+TEST_F(FormatTest, PenaltyIndentedWhitespace) {
+  verifyFormat("Constructor()\n"
+   ": aa(aa), aa(\n"
+   "  (aa, "
+   "aat))");
+  verifyFormat("Constructor()\n"
+   ": a(aa), "
+   "a

[llvm-branch-commits] [llvm] ba4e45a - [gn build] (manually) port 8fee2ee9a68

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

Author: Nico Weber
Date: 2020-12-01T18:02:27-05:00
New Revision: ba4e45a0aa6596e156b27a620281d7befc5297fc

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

LOG: [gn build] (manually) port 8fee2ee9a68

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn
index 5a8aed018390..01c909025905 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn
@@ -1,5 +1,13 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("Opts") {
+  visibility = [ ":llvm-ml" ]
+  args = [ "-gen-opt-parser-defs" ]
+}
+
 executable("llvm-ml") {
   deps = [
+":Opts",
 "//llvm/lib/MC",
 "//llvm/lib/MC/MCParser",
 "//llvm/lib/Support",



___
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] 3fcb0ee - [lld-macho] Emit STABS symbols for debugging, and drop debug sections

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

Author: Jez Ng
Date: 2020-12-01T15:05:20-08:00
New Revision: 3fcb0eeb152beb4320c7632bcfa2b1e7c2e5ca00

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

LOG: [lld-macho] Emit STABS symbols for debugging, and drop debug sections

Debug sections contain a large amount of data. In order not to bloat the size
of the final binary, we remove them and instead emit STABS symbols for
`dsymutil` and the debugger to locate their contents in the object files.

With this diff, `dsymutil` is able to locate the debug info. However, we need
a few more features before `lldb` is able to work well with our binaries --
e.g. having `LC_DYSYMTAB` accurately reflect the number of local symbols,
emitting `LC_UUID`, and more. Those will be handled in follow-up diffs.

Note also that the STABS we emit differ slightly from what ld64 does. First, we
emit the path to the source file as one `N_SO` symbol instead of two. (`ld64`
emits one `N_SO` for the dirname and one of the basename.) Second, we do not
emit `N_BNSYM` and `N_ENSYM` STABS to mark the start and end of functions,
because the `N_FUN` STABS already serve that purpose. @clayborg recommended
these changes based on his knowledge of what the debugging tools look for.

Additionally, this current implementation doesn't accurately reflect the size
of function symbols. It uses the size of their containing sectioins as a proxy,
but that is only accurate if `.subsections_with_symbols` is set, and if there
isn't an `N_ALT_ENTRY` in that particular subsection. I think we have two
options to solve this:

1. We can split up subsections by symbol even if `.subsections_with_symbols`
   is not set, but include constraints to ensure those subsections retain
   their order in the final output. This is `ld64`'s approach.
2. We could just add a `size` field to our `Symbol` class. This seems simpler,
   and I'm more inclined toward it, but I'm not sure if there are use cases
   that it doesn't handle well. As such I'm punting on the decision for now.

Reviewed By: clayborg

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

Added: 
lld/MachO/Dwarf.cpp
lld/MachO/Dwarf.h
lld/test/MachO/stabs.s

Modified: 
lld/MachO/CMakeLists.txt
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/InputSection.h
lld/MachO/OutputSegment.h
lld/MachO/SyntheticSections.cpp
lld/MachO/SyntheticSections.h
lld/MachO/Writer.cpp

Removed: 




diff  --git a/lld/MachO/CMakeLists.txt b/lld/MachO/CMakeLists.txt
index 6ddc88fb8618..6a8b5d336583 100644
--- a/lld/MachO/CMakeLists.txt
+++ b/lld/MachO/CMakeLists.txt
@@ -9,6 +9,7 @@ add_lld_library(lldMachO2
   UnwindInfoSection.cpp
   Driver.cpp
   DriverUtils.cpp
+  Dwarf.cpp
   ExportTrie.cpp
   InputFiles.cpp
   InputSection.cpp

diff  --git a/lld/MachO/Dwarf.cpp b/lld/MachO/Dwarf.cpp
new file mode 100644
index ..121f54fb1f79
--- /dev/null
+++ b/lld/MachO/Dwarf.cpp
@@ -0,0 +1,49 @@
+//===- DWARF.cpp 
--===//
+//
+// 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
+//
+//===--===//
+
+#include "Dwarf.h"
+#include "InputFiles.h"
+#include "InputSection.h"
+#include "OutputSegment.h"
+
+#include 
+
+using namespace lld;
+using namespace lld::macho;
+using namespace llvm;
+
+std::unique_ptr DwarfObject::create(ObjFile *obj) {
+  auto dObj = std::make_unique();
+  bool hasDwarfInfo = false;
+  for (SubsectionMap subsecMap : obj->subsections) {
+for (auto it : subsecMap) {
+  InputSection *isec = it.second;
+  if (!(isDebugSection(isec->flags) &&
+isec->segname == segment_names::dwarf))
+continue;
+
+  if (isec->name == "__debug_info") {
+dObj->infoSection.Data = toStringRef(isec->data);
+hasDwarfInfo = true;
+continue;
+  }
+
+  if (StringRef *s = StringSwitch(isec->name)
+ .Case("__debug_abbrev", &dObj->abbrevSection)
+ .Case("__debug_str", &dObj->strSection)
+ .Default(nullptr)) {
+*s = toStringRef(isec->data);
+hasDwarfInfo = true;
+  }
+}
+  }
+
+  if (hasDwarfInfo)
+return dObj;
+  return nullptr;
+}

diff  --git a/lld/MachO/Dwarf.h b/lld/MachO/Dwarf.h
new file mode 100644
index ..119f2778fc6b
--- /dev/null
+++ b/lld/MachO/Dwarf.h
@@ -0,0 +1,53 @@
+//===- DWARF.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.or

[llvm-branch-commits] [lld] 51629ab - [lld-macho] Emit local symbols in symtab; record metadata in LC_DYSYMTAB

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

Author: Jez Ng
Date: 2020-12-01T15:05:20-08:00
New Revision: 51629abce0e2f9d1376eb0b5070532a2bbec6766

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

LOG: [lld-macho] Emit local symbols in symtab; record metadata in LC_DYSYMTAB

Symbols of the same type must be laid out contiguously: following ld64's
lead, we choose to emit all local symbols first, then external symbols,
and finally undefined symbols. For each symbol type, the LC_DYSYMTAB
load command will record the range (start index and total number) of
those symbols in the symbol table.

This work was motivated by the fact that LLDB won't search for debug
info if LC_DYSYMTAB says there are no local symbols (since STABS symbols
are all local symbols). With this change, LLDB is now able to display
the source lines at a given breakpoint when debugging our binaries.

Some tests had to be updated due to local symbol names now appearing in
`llvm-objdump`'s output.

Reviewed By: #lld-macho, smeenai, clayborg

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

Added: 


Modified: 
lld/MachO/SyntheticSections.cpp
lld/MachO/SyntheticSections.h
lld/MachO/Writer.cpp
lld/test/MachO/stabs.s
lld/test/MachO/subsections-symbol-relocs.s
lld/test/MachO/symtab.s
lld/test/MachO/tlv.s

Removed: 




diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index feaa4b5d3e22..56a095c4a7e4 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -19,6 +19,7 @@
 
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Memory.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/LEB128.h"
@@ -630,14 +631,35 @@ void SymtabSection::emitFunStabs(Defined *defined) {
 }
 
 void SymtabSection::finalizeContents() {
-  InputFile *lastFile = nullptr;
+  // Local symbols aren't in the SymbolTable, so we walk the list of object
+  // files to gather them.
+  for (InputFile *file : inputFiles) {
+if (auto *objFile = dyn_cast(file)) {
+  for (Symbol *sym : objFile->symbols) {
+// TODO: when we implement -dead_strip, we should filter out symbols
+// that belong to dead sections.
+if (auto *defined = dyn_cast(sym)) {
+  if (!defined->isExternal()) {
+uint32_t strx = stringTableSection.addString(sym->getName());
+localSymbols.push_back({sym, strx});
+  }
+}
+  }
+}
+  }
+
   for (Symbol *sym : symtab->getSymbols()) {
-// TODO support other symbol types
-if (isa(sym) || sym->isInGot() || sym->isInStubs()) {
-  sym->symtabIndex = symbols.size();
-  symbols.push_back({sym, stringTableSection.addString(sym->getName())});
+uint32_t strx = stringTableSection.addString(sym->getName());
+if (auto *defined = dyn_cast(sym)) {
+  assert(defined->isExternal());
+  externalSymbols.push_back({sym, strx});
+} else if (sym->isInGot() || sym->isInStubs()) {
+  undefinedSymbols.push_back({sym, strx});
 }
+  }
 
+  InputFile *lastFile = nullptr;
+  for (Symbol *sym : symtab->getSymbols()) {
 // Emit STABS symbols so that dsymutil and/or the debugger can map address
 // regions in the final binary to the source and object files from which
 // they originated.
@@ -670,13 +692,35 @@ void SymtabSection::finalizeContents() {
 
   if (!stabs.empty())
 emitEndSourceStab();
+
+  uint32_t symtabIndex = stabs.size();
+  for (const SymtabEntry &entry :
+   concat(localSymbols, externalSymbols, undefinedSymbols)) {
+entry.sym->symtabIndex = symtabIndex++;
+  }
+}
+
+uint32_t SymtabSection::getNumSymbols() const {
+  return stabs.size() + localSymbols.size() + externalSymbols.size() +
+ undefinedSymbols.size();
 }
 
 void SymtabSection::writeTo(uint8_t *buf) const {
   auto *nList = reinterpret_cast(buf);
-  for (const SymtabEntry &entry : symbols) {
+  // Emit the stabs entries before the "real" symbols. We cannot emit them
+  // after as that would render Symbol::symtabIndex inaccurate.
+  for (const StabsEntry &entry : stabs) {
+nList->n_strx = entry.strx;
+nList->n_type = entry.type;
+nList->n_sect = entry.sect;
+nList->n_desc = entry.desc;
+nList->n_value = entry.value;
+++nList;
+  }
+
+  for (const SymtabEntry &entry : concat(
+   localSymbols, externalSymbols, undefinedSymbols)) {
 nList->n_strx = entry.strx;
-// TODO support other symbol types
 // TODO populate n_desc with more flags
 if (auto *defined = dyn_cast(entry.sym)) {
   if (defined->isAbsolute()) {
@@ -684,7 +728,8 @@ void SymtabSection::writeTo(uint8_t *buf) const {
 nList->n_sect = MachO::NO_SECT;
 nList->n_value = defined->value;

[llvm-branch-commits] [lld] d0c4be4 - [lld-macho] Emit empty string as first entry of string table

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

Author: Jez Ng
Date: 2020-12-01T15:05:20-08:00
New Revision: d0c4be42e35d8cff069f91a45b76ea24187c233d

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

LOG: [lld-macho] Emit empty string as first entry of string table

ld64 emits string tables which start with a space and a zero byte. We
match its behavior here since some tools depend on it.

Similar rationale as {D89561}.

Reviewed By: #lld-macho, smeenai

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

Added: 


Modified: 
lld/MachO/SyntheticSections.h
lld/test/MachO/symtab.s

Removed: 




diff  --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h
index e52bc480e9aa..56f4bf66ce23 100644
--- a/lld/MachO/SyntheticSections.h
+++ b/lld/MachO/SyntheticSections.h
@@ -398,11 +398,10 @@ class StringTableSection : public LinkEditSection {
   void writeTo(uint8_t *buf) const override;
 
 private:
-  // An n_strx value of 0 always indicates the empty string, so we must locate
-  // our non-empty string values at positive offsets in the string table.
-  // Therefore we insert a dummy value at position zero.
-  std::vector strings{"\0"};
-  size_t size = 1;
+  // ld64 emits string tables which start with a space and a zero byte. We
+  // match its behavior here since some tools depend on it.
+  std::vector strings{" "};
+  size_t size = 2;
 };
 
 struct SymtabEntry {

diff  --git a/lld/test/MachO/symtab.s b/lld/test/MachO/symtab.s
index 22dc80ad62f3..a4dce665acb4 100644
--- a/lld/test/MachO/symtab.s
+++ b/lld/test/MachO/symtab.s
@@ -4,11 +4,11 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o 
%t/libfoo.o
 # RUN: %lld -dylib %t/libfoo.o -o %t/libfoo.dylib
 # RUN: %lld -lSystem %t/test.o %t/libfoo.dylib -o %t/test
-# RUN: llvm-readobj --syms --macho-dysymtab %t/test | FileCheck %s
 
+# RUN: llvm-readobj --syms --macho-dysymtab %t/test | FileCheck %s
 # CHECK:  Symbols [
 # CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name: _local (1)
+# CHECK-NEXT: Name: _local (2)
 # CHECK-NEXT: Type: Section (0xE)
 # CHECK-NEXT: Section: __data (0x4)
 # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
@@ -17,7 +17,7 @@
 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name: _main (8)
+# CHECK-NEXT: Name: _main (9)
 # CHECK-NEXT: Extern
 # CHECK-NEXT: Type: Section (0xE)
 # CHECK-NEXT: Section: __text (0x1)
@@ -27,7 +27,7 @@
 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name: _external (54)
+# CHECK-NEXT: Name: _external (55)
 # CHECK-NEXT: Extern
 # CHECK-NEXT: Type: Section (0xE)
 # CHECK-NEXT: Section: __data (0x4)
@@ -37,7 +37,7 @@
 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name: _external_weak (64)
+# CHECK-NEXT: Name: _external_weak (65)
 # CHECK-NEXT: Extern
 # CHECK-NEXT: Type: Section (0xE)
 # CHECK-NEXT: Section: __text (0x1)
@@ -48,7 +48,7 @@
 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name: __dyld_private (102)
+# CHECK-NEXT: Name: __dyld_private (103)
 # CHECK-NEXT: Extern
 # CHECK-NEXT: Type: Section (0xE)
 # CHECK-NEXT: Section: __data (0x4)
@@ -58,7 +58,7 @@
 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name: dyld_stub_binder (14)
+# CHECK-NEXT: Name: dyld_stub_binder (15)
 # CHECK-NEXT: Type: Undef (0x0)
 # CHECK-NEXT: Section:  (0x0)
 # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
@@ -67,7 +67,7 @@
 # CHECK-NEXT: Value: 0x0
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name: _dynamic (79)
+# CHECK-NEXT: Name: _dynamic (80)
 # CHECK-NEXT: Type: Undef (0x0)
 # CHECK-NEXT: Section:  (0x0)
 # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
@@ -84,6 +84,11 @@
 # CHECK-NEXT:   iundefsym: 5
 # CHECK-NEXT:   nundefsym: 2
 
+## Verify that the first entry in the StringTable is a space.
+# RUN: obj2yaml %t/test | FileCheck %s --check-prefix=YAML
+# YAML:  StringTable:
+# YAML-NEXT: ' '
+
 #--- libfoo.s
 .globl _dynamic
 _dynamic:



___
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] c7dbaec - [lld-macho] Add isCodeSection()

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

Author: Jez Ng
Date: 2020-12-01T15:05:21-08:00
New Revision: c7dbaec396ef98b8bc6acb7631d2919449986add

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

LOG: [lld-macho] Add isCodeSection()

This is the same logic that ld64 uses to determine which sections
contain functions. This was added so that we could determine which
STABS entries should be N_FUN.

Reviewed By: clayborg

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

Added: 


Modified: 
lld/MachO/InputSection.cpp
lld/MachO/InputSection.h
lld/MachO/SyntheticSections.cpp
lld/test/MachO/stabs.s

Removed: 




diff  --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp
index e164630159e2..80c263301f41 100644
--- a/lld/MachO/InputSection.cpp
+++ b/lld/MachO/InputSection.cpp
@@ -58,6 +58,23 @@ void InputSection::writeTo(uint8_t *buf) {
   }
 }
 
+bool macho::isCodeSection(InputSection *isec) {
+  uint32_t type = isec->flags & MachO::SECTION_TYPE;
+  if (type != S_REGULAR && type != S_COALESCED)
+return false;
+
+  uint32_t attr = isec->flags & MachO::SECTION_ATTRIBUTES_USR;
+  if (attr == S_ATTR_PURE_INSTRUCTIONS)
+return true;
+
+  if (isec->segname == segment_names::text)
+return StringSwitch(isec->name)
+.Cases("__textcoal_nt", "__StaticInit", true)
+.Default(false);
+
+  return false;
+}
+
 std::string lld::toString(const InputSection *isec) {
   return (toString(isec->file) + ":(" + isec->name + ")").str();
 }

diff  --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h
index 4ef8d84bc8a0..f405fd6cf6d3 100644
--- a/lld/MachO/InputSection.h
+++ b/lld/MachO/InputSection.h
@@ -76,6 +76,8 @@ class InputSection {
   std::vector relocs;
 };
 
+bool isCodeSection(InputSection *);
+
 extern std::vector inputSections;
 
 } // namespace macho

diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 6ba067bbc9e5..808d3594bfad 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -668,9 +668,7 @@ void SymtabSection::emitStabs() {
 symStab.strx = stringTableSection.addString(defined->getName());
 symStab.value = defined->getVA();
 
-// XXX is it right to assume that all symbols in __text are function
-// symbols?
-if (isec->name == "__text") {
+if (isCodeSection(isec)) {
   symStab.type = MachO::N_FUN;
   stabs.emplace_back(std::move(symStab));
   emitEndFunStab(defined);

diff  --git a/lld/test/MachO/stabs.s b/lld/test/MachO/stabs.s
index a3f1e2906d2b..445783269d11 100644
--- a/lld/test/MachO/stabs.s
+++ b/lld/test/MachO/stabs.s
@@ -36,12 +36,15 @@
 # CHECK-NEXT:  [[#DATA_ID:]]  __data
 # CHECK-NEXT:  [[#MORE_DATA_ID:]] more_data
 # CHECK-NEXT:  [[#COMM_ID:]]  __common
+# CHECK-NEXT:  [[#MORE_TEXT_ID:]] more_text
 
 # CHECK:    - 00 SO 
/tmp/test.cpp
 # CHECK-NEXT:  0010 - 03 0001   OSO 
[[DIR]]/test.o
 # CHECK-NEXT:  [[#%x, STATIC:]] - 0[[#MORE_DATA_ID + 1]]  STSYM _static_var
 # CHECK-NEXT:  [[#%x, MAIN:]]   - 0[[#TEXT_ID + 1]]     FUN _main
 # CHECK-NEXT:  0006 - 00    FUN
+# CHECK-NEXT:  [[#%x, FUN:]]- 0[[#MORE_TEXT_ID + 1]]    FUN _fun
+# CHECK-NEXT:  0001 - 00    FUN
 # CHECK-NEXT:  [[#%x, GLOB:]]   - 0[[#DATA_ID + 1]]    GSYM _global_var
 # CHECK-NEXT:  [[#%x, ZERO:]]   - 0[[#COMM_ID + 1]]    GSYM _zero
 # CHECK-NEXT:   - 01 SO
@@ -53,6 +56,7 @@
 # CHECK-NEXT:  [[#STATIC]]  s _static_var
 # CHECK-NEXT:  [[#MAIN]]T _main
 # CHECK-NEXT:  {{[0-9af]+}} A _abs
+# CHECK-NEXT:  [[#FUN]] S _fun
 # CHECK-NEXT:  [[#GLOB]]D _global_var
 # CHECK-NEXT:  [[#ZERO]]S _zero
 # CHECK-NEXT:  [[#FOO]] T _foo
@@ -121,6 +125,11 @@ Ldebug_info_end0:
 .subsections_via_symbols
 .section  __DWARF,__debug_line,regular,debug
 
+.section OTHER,more_text,regular,pure_instructions
+.globl _fun
+_fun:
+  ret
+
 #--- foo.s
 .text
 .globl  _foo



___
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] b768d57 - [lld-macho] Add archive name and file modtime to STABS output

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

Author: Jez Ng
Date: 2020-12-01T15:05:21-08:00
New Revision: b768d57b368781e6737c403e425bd835850f3a0a

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

LOG: [lld-macho] Add archive name and file modtime to STABS output

We should also set the modtime when running LTO. That will be done in a
future diff, together with support for the `-object_path_lto` flag.

Reviewed By: clayborg

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

Added: 


Modified: 
lld/MachO/Driver.cpp
lld/MachO/Driver.h
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/LTO.cpp
lld/MachO/SyntheticSections.cpp
lld/test/MachO/stabs.s

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 141082985b4e..295f2c412a7f 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -212,21 +212,32 @@ getFrameworkSearchPaths(opt::InputArgList &args,
 {"/Library/Frameworks", "/System/Library/Frameworks"});
 }
 
+namespace {
+struct ArchiveMember {
+  MemoryBufferRef mbref;
+  uint32_t modTime;
+};
+} // namespace
+
 // Returns slices of MB by parsing MB as an archive file.
 // Each slice consists of a member file in the archive.
-static std::vector getArchiveMembers(MemoryBufferRef mb) {
+static std::vector getArchiveMembers(MemoryBufferRef mb) {
   std::unique_ptr file =
   CHECK(Archive::create(mb),
 mb.getBufferIdentifier() + ": failed to parse archive");
 
-  std::vector v;
+  std::vector v;
   Error err = Error::success();
   for (const Archive::Child &c : file->children(err)) {
 MemoryBufferRef mbref =
 CHECK(c.getMemoryBufferRef(),
   mb.getBufferIdentifier() +
   ": could not get the buffer for a child of the archive");
-v.push_back(mbref);
+uint32_t modTime = toTimeT(
+CHECK(c.getLastModified(), mb.getBufferIdentifier() +
+   ": could not get the modification "
+   "time for a child of the archive"));
+v.push_back({mbref, modTime});
   }
   if (err)
 fatal(mb.getBufferIdentifier() +
@@ -235,6 +246,16 @@ static std::vector 
getArchiveMembers(MemoryBufferRef mb) {
   return v;
 }
 
+static void forceLoadArchive(StringRef path) {
+  if (Optional buffer = readFile(path)) {
+for (const ArchiveMember &member : getArchiveMembers(*buffer)) {
+  auto file = make(member.mbref, member.modTime);
+  file->archiveName = buffer->getBufferIdentifier();
+  inputFiles.push_back(file);
+}
+  }
+}
+
 static InputFile *addFile(StringRef path) {
   Optional buffer = readFile(path);
   if (!buffer)
@@ -251,9 +272,7 @@ static InputFile *addFile(StringRef path) {
   error(path + ": archive has no index; run ranlib to add one");
 
 if (config->allLoad) {
-  if (Optional buffer = readFile(path))
-for (MemoryBufferRef member : getArchiveMembers(*buffer))
-  inputFiles.push_back(make(member));
+  forceLoadArchive(path);
 } else if (config->forceLoadObjC) {
   for (const object::Archive::Symbol &sym : file->symbols())
 if (sym.getName().startswith(objc::klass))
@@ -264,16 +283,16 @@ static InputFile *addFile(StringRef path) {
   // consider creating a LazyObjFile class in order to avoid double-loading
   // these files here and below (as part of the ArchiveFile).
   if (Optional buffer = readFile(path))
-for (MemoryBufferRef member : getArchiveMembers(*buffer))
-  if (hasObjCSection(member))
-inputFiles.push_back(make(member));
+for (const ArchiveMember &member : getArchiveMembers(*buffer))
+  if (hasObjCSection(member.mbref))
+inputFiles.push_back(make(member.mbref, member.modTime));
 }
 
 newFile = make(std::move(file));
 break;
   }
   case file_magic::macho_object:
-newFile = make(mbref);
+newFile = make(mbref, getModTime(path));
 break;
   case file_magic::macho_dynamically_linked_shared_lib:
   case file_magic::macho_dynamically_linked_shared_lib_stub:
@@ -304,12 +323,6 @@ static void addFileList(StringRef path) {
 addFile(path);
 }
 
-static void forceLoadArchive(StringRef path) {
-  if (Optional buffer = readFile(path))
-for (MemoryBufferRef member : getArchiveMembers(*buffer))
-  inputFiles.push_back(make(member));
-}
-
 static std::array archNames{"arm","arm64", "i386",
   "x86_64", "ppc",   "ppc64"};
 static bool isArchString(StringRef s) {

diff  --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h
index c06d2f9d1b3d..d5625fd3873e 100644
--- a/lld/MachO/Driver.h
+++ b/lld/MachO/Driver.h
@@ -43,6 +43,8 @@ llvm::Optional resolveDylibPath(llvm::StringRef 
path

[llvm-branch-commits] [lld] 78f6498 - [lld-macho] Flesh out STABS implementation

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

Author: Jez Ng
Date: 2020-12-01T15:05:21-08:00
New Revision: 78f6498cdcdb5a7644b1c32615cfe2fdfd9c2545

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

LOG: [lld-macho] Flesh out STABS implementation

This addresses a lot of the comments in {D89257}. Ideally it'd have been
done in the same diff, but the commits in between make that difficult.

This diff implements:
* N_GSYM and N_STSYM, the STABS for global and static symbols
* Has the STABS reflect the section IDs of their referent symbols
* Ensures we don't fail when encountering absolute symbols or files with
  no debug info
* Sorts STABS symbols by file to minimize the number of N_OSO entries

Reviewed By: clayborg

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

Added: 


Modified: 
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/SyntheticSections.cpp
lld/MachO/SyntheticSections.h
lld/test/MachO/stabs.s

Removed: 




diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 19d531cc5028..8a451d0dc217 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -76,6 +76,7 @@ using namespace lld::macho;
 
 std::vector macho::inputFiles;
 std::unique_ptr macho::tar;
+int InputFile::idCount = 0;
 
 // Open a given file path and return it as a memory-mapped file.
 Optional macho::readFile(StringRef path) {

diff  --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h
index f7fd77dacff5..6ca9a40a49b0 100644
--- a/lld/MachO/InputFiles.h
+++ b/lld/MachO/InputFiles.h
@@ -65,13 +65,15 @@ class InputFile {
   std::vector symbols;
   ArrayRef sectionHeaders;
   std::vector subsections;
+  // Provides an easy way to sort InputFiles deterministically.
+  const int id;
 
 protected:
   InputFile(Kind kind, MemoryBufferRef mb)
-  : mb(mb), fileKind(kind), name(mb.getBufferIdentifier()) {}
+  : mb(mb), id(idCount++), fileKind(kind), name(mb.getBufferIdentifier()) 
{}
 
   InputFile(Kind kind, const llvm::MachO::InterfaceFile &interface)
-  : fileKind(kind), name(saver.save(interface.getPath())) {}
+  : id(idCount++), fileKind(kind), name(saver.save(interface.getPath())) {}
 
   void parseSections(ArrayRef);
 
@@ -85,6 +87,8 @@ class InputFile {
 private:
   const Kind fileKind;
   const StringRef name;
+
+  static int idCount;
 };
 
 // .o file

diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index ae66961310c5..6ba067bbc9e5 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -617,22 +617,71 @@ void SymtabSection::emitObjectFileStab(ObjFile *file) {
   stabs.emplace_back(std::move(stab));
 }
 
-void SymtabSection::emitFunStabs(Defined *defined) {
-  {
-StabsEntry stab(MachO::N_FUN);
-stab.sect = 1;
-stab.strx = stringTableSection.addString(defined->getName());
-stab.value = defined->getVA();
-stabs.emplace_back(std::move(stab));
+void SymtabSection::emitEndFunStab(Defined *defined) {
+  StabsEntry stab(MachO::N_FUN);
+  // FIXME this should be the size of the symbol. Using the section size in
+  // lieu is only correct if .subsections_via_symbols is set.
+  stab.value = defined->isec->getSize();
+  stabs.emplace_back(std::move(stab));
+}
+
+void SymtabSection::emitStabs() {
+  std::vector symbolsNeedingStabs;
+  for (const SymtabEntry &entry :
+   concat(localSymbols, externalSymbols)) {
+Symbol *sym = entry.sym;
+if (auto *defined = dyn_cast(sym)) {
+  if (defined->isAbsolute())
+continue;
+  InputSection *isec = defined->isec;
+  ObjFile *file = dyn_cast_or_null(isec->file);
+  if (!file || !file->compileUnit)
+continue;
+  symbolsNeedingStabs.push_back(defined);
+}
   }
 
-  {
-StabsEntry stab(MachO::N_FUN);
-// FIXME this should be the size of the symbol. Using the section size in
-// lieu is only correct if .subsections_via_symbols is set.
-stab.value = defined->isec->getSize();
-stabs.emplace_back(std::move(stab));
+  llvm::stable_sort(symbolsNeedingStabs, [&](Defined *a, Defined *b) {
+return a->isec->file->id < b->isec->file->id;
+  });
+
+  // Emit STABS symbols so that dsymutil and/or the debugger can map address
+  // regions in the final binary to the source and object files from which they
+  // originated.
+  InputFile *lastFile = nullptr;
+  for (Defined *defined : symbolsNeedingStabs) {
+InputSection *isec = defined->isec;
+ObjFile *file = dyn_cast(isec->file);
+assert(file);
+
+if (lastFile == nullptr || lastFile != file) {
+  if (lastFile != nullptr)
+emitEndSourceStab();
+  lastFile = file;
+
+  emitBeginSourceStab(file->compileUnit);
+  emitObjectFileStab(file);
+}
+
+StabsEntry symStab;
+symStab.sect = defined->isec->parent->index;

[llvm-branch-commits] [llvm] c64037b - [ms] [llvm-ml] Support command-line defines

2020-12-01 Thread Eric Astor via llvm-branch-commits

Author: Eric Astor
Date: 2020-12-01T18:06:05-05:00
New Revision: c64037b784aeae63b1863ee1abd5601c2c6a8102

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

LOG: [ms] [llvm-ml] Support command-line defines

Enable command-line defines as textmacros

Reviewed By: thakis

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

Added: 
llvm/test/tools/llvm-ml/command_line_defines.asm

Modified: 
llvm/include/llvm/MC/MCParser/MCAsmParser.h
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/tools/llvm-ml/Opts.td
llvm/tools/llvm-ml/llvm-ml.cpp

Removed: 




diff  --git a/llvm/include/llvm/MC/MCParser/MCAsmParser.h 
b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
index 2040810eac14..391a6b0b575e 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -184,6 +184,8 @@ class MCAsmParser {
 
   virtual bool isParsingMasm() const { return false; }
 
+  virtual bool defineMacro(StringRef Name, StringRef Value) { return true; }
+
   virtual bool lookUpField(StringRef Name, AsmFieldInfo &Info) const {
 return true;
   }

diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp 
b/llvm/lib/MC/MCParser/MasmParser.cpp
index 709f1ea1173d..63aebbc5a7ba 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -501,6 +501,8 @@ class MasmParser : public MCAsmParser {
 
   bool isParsingMasm() const override { return true; }
 
+  bool defineMacro(StringRef Name, StringRef Value) override;
+
   bool lookUpField(StringRef Name, AsmFieldInfo &Info) const override;
   bool lookUpField(StringRef Base, StringRef Member,
AsmFieldInfo &Info) const override;
@@ -6905,6 +6907,19 @@ static int rewritesSort(const AsmRewrite *AsmRewriteA,
   llvm_unreachable("Unstable rewrite sort.");
 }
 
+bool MasmParser::defineMacro(StringRef Name, StringRef Value) {
+  Variable &Var = Variables[Name.lower()];
+  if (Var.Name.empty()) {
+Var.Name = Name;
+  } else if (!Var.Redefinable) {
+return TokError("invalid variable redefinition");
+  }
+  Var.Redefinable = true;
+  Var.IsText = true;
+  Var.TextValue = Value.str();
+  return false;
+}
+
 bool MasmParser::lookUpField(StringRef Name, AsmFieldInfo &Info) const {
   const std::pair BaseMember = Name.split('.');
   const StringRef Base = BaseMember.first, Member = BaseMember.second;

diff  --git a/llvm/test/tools/llvm-ml/command_line_defines.asm 
b/llvm/test/tools/llvm-ml/command_line_defines.asm
new file mode 100644
index ..51b02e6ebb4a
--- /dev/null
+++ b/llvm/test/tools/llvm-ml/command_line_defines.asm
@@ -0,0 +1,38 @@
+; RUN: llvm-ml -filetype=s %s /Fo - /DT1=test1 /D T2=test2 | FileCheck %s
+
+.code
+
+t1:
+  ret
+; CHECK-NOT: t1:
+; CHECK-LABEL: test1:
+; CHECK-NOT: t1:
+
+t2:
+  ret
+; CHECK-NOT: t2:
+; CHECK-LABEL: test2:
+; CHECK-NOT: t2:
+
+t3:
+ifdef t1
+  xor eax, eax
+endif
+  ret
+; CHECK-LABEL: t3:
+; CHECK: xor eax, eax
+; CHECK: ret
+
+t4:
+ifdef undefined
+  xor eax, eax
+elseifdef t2
+  xor ebx, ebx
+endif
+  ret
+; CHECK-LABEL: t4:
+; CHECK-NOT: xor eax, eax
+; CHECK: xor ebx, ebx
+; CHECK: ret
+
+end

diff  --git a/llvm/tools/llvm-ml/Opts.td b/llvm/tools/llvm-ml/Opts.td
index ed52bb4771ba..4c2757b05722 100644
--- a/llvm/tools/llvm-ml/Opts.td
+++ b/llvm/tools/llvm-ml/Opts.td
@@ -31,6 +31,9 @@ def help : MLFlag<"?">,
HelpText<"Display available options">;
 def help_long : MLFlag<"help">, Alias;
 def assemble_only : MLFlag<"c">, HelpText<"Assemble only; do not link">;
+def define : MLJoinedOrSeparate<"D">, MetaVarName<"=">,
+ HelpText<"Define  to  (or blank if  "
+  "omitted)">;
 def output_file : MLJoinedOrSeparate<"Fo">, HelpText<"Names the output file">;
 def include_path : MLJoinedOrSeparate<"I">,
HelpText<"Sets path for include files">;
@@ -72,7 +75,6 @@ def coff_object_file : UnsupportedFlag<"coff">, HelpText<"">;
 def preserve_identifier_case : UnsupportedFlag<"Cp">, HelpText<"">;
 def uppercase_identifiers : UnsupportedFlag<"Cu">, HelpText<"">;
 def preserve_extern_case : UnsupportedFlag<"Cx">, HelpText<"">;
-def define : UnsupportedJoinedOrSeparate<"D">, HelpText<"">;
 def output_preprocessed : UnsupportedFlag<"EP">, HelpText<"">;
 def errorreport : UnsupportedJoined<"ERRORREPORT">, HelpText<"">;
 def stacksize : UnsupportedSeparate<"F">, HelpText<"">;

diff  --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp
index ac03ef826c58..1733dcd47281 100644
--- a/llvm/tools/llvm-ml/llvm-ml.cpp
+++ b/llvm/tools/llvm-ml/llvm-ml.cpp
@@ -147,6 +147,17 @@ static int AssembleInput(StringRef ProgName, const Target 
*TheTarget,
   Parser->getLexer().setLexMasmHexFloats(true);
   Parser->getLexer().setLexMasmStrings(true);
 
+  auto Defines = InputArgs.getA

[llvm-branch-commits] [llvm] ea7b071 - [gn build] Manually port 8fee2ee9

2020-12-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-01T15:06:49-08:00
New Revision: ea7b07187b273059d503b3b35539668d3c1f5412

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

LOG: [gn build] Manually port 8fee2ee9

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn
index 01c909025905..df29a8d74a3b 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-ml/BUILD.gn
@@ -10,6 +10,7 @@ executable("llvm-ml") {
 ":Opts",
 "//llvm/lib/MC",
 "//llvm/lib/MC/MCParser",
+"//llvm/lib/Option",
 "//llvm/lib/Support",
 "//llvm/lib/Target:TargetsToBuild",
   ]



___
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] ec13b39 - [gn build] Format all gn files

2020-12-01 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-01T15:07:16-08:00
New Revision: ec13b391170e5984894e1c8635a6964e79572205

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

LOG: [gn build] Format all gn files

$ git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format

Added: 


Modified: 
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/concurrency/BUILD.gn
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/concurrency/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/concurrency/BUILD.gn
index ccded31b2732..09c61f346139 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/concurrency/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/concurrency/BUILD.gn
@@ -4,9 +4,9 @@ static_library("concurrency") {
   deps = [
 "//clang-tools-extra/clang-tidy",
 "//clang-tools-extra/clang-tidy/utils",
-"//clang/lib/Analysis",
 "//clang/lib/AST",
 "//clang/lib/ASTMatchers",
+"//clang/lib/Analysis",
 "//clang/lib/Basic",
 "//clang/lib/Lex",
 "//clang/lib/Serialization",

diff  --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn 
b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index e8781bec188a..bda694b3f0bc 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -164,11 +164,11 @@ group("test") {
 "//llvm/tools/llvm-symbolizer:symlinks",
 "//llvm/tools/opt",
 "//llvm/tools/split-file",
+"//llvm/tools/yaml2obj",
 "//llvm/utils/FileCheck",
 "//llvm/utils/count",
 "//llvm/utils/llvm-lit",
 "//llvm/utils/not",
-"//llvm/tools/yaml2obj",
   ]
   if (clang_enable_arcmt) {
 deps += [

diff  --git a/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn
index 29482bc428fe..35f392b6d646 100644
--- a/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn
@@ -32,11 +32,11 @@ static_library("PDB") {
 "Native/NativeEnumInjectedSources.cpp",
 "Native/NativeEnumLineNumbers.cpp",
 "Native/NativeEnumModules.cpp",
-"Native/NativeEnumTypes.cpp",
 "Native/NativeEnumSymbols.cpp",
+"Native/NativeEnumTypes.cpp",
 "Native/NativeExeSymbol.cpp",
-"Native/NativeInlineSiteSymbol.cpp",
 "Native/NativeFunctionSymbol.cpp",
+"Native/NativeInlineSiteSymbol.cpp",
 "Native/NativeLineNumber.cpp",
 "Native/NativePublicSymbol.cpp",
 "Native/NativeRawSymbol.cpp",



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


[llvm-branch-commits] [llvm] e8b816a - [gn build] Port 3fcb0eeb152

2020-12-01 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-01T23:11:06Z
New Revision: e8b816ad19c728e1c8393df92d7e87b4bc9a38cc

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

LOG: [gn build] Port 3fcb0eeb152

Added: 


Modified: 
llvm/utils/gn/secondary/lld/MachO/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/lld/MachO/BUILD.gn 
b/llvm/utils/gn/secondary/lld/MachO/BUILD.gn
index 5e163d1a132d..a55b5775ad70 100644
--- a/llvm/utils/gn/secondary/lld/MachO/BUILD.gn
+++ b/llvm/utils/gn/secondary/lld/MachO/BUILD.gn
@@ -25,6 +25,7 @@ static_library("MachO2") {
 "Arch/X86_64.cpp",
 "Driver.cpp",
 "DriverUtils.cpp",
+"Dwarf.cpp",
 "ExportTrie.cpp",
 "InputFiles.cpp",
 "InputSection.cpp",



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


[llvm-branch-commits] [llvm] 6c3fa97 - [AArch64][GlobalISel] Select Bcc when it's better than TB(N)Z

2020-12-01 Thread Jessica Paquette via llvm-branch-commits

Author: Jessica Paquette
Date: 2020-12-01T15:45:14-08:00
New Revision: 6c3fa97d8a628541c82d8981aabefcb2dcb29f17

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

LOG: [AArch64][GlobalISel] Select Bcc when it's better than TB(N)Z

Instead of falling back to selecting TB(N)Z when we fail to select an
optimized compare against 0, select Bcc instead.

Also simplify selectCompareBranch a little while we're here, because the logic
was kind of hard to follow.

At -O0, this is a 0.1% geomean code size improvement for CTMark.

A simple example of where this can kick in is here:
https://godbolt.org/z/4rra6P

In the example above, GlobalISel currently produces a subs, cset, and tbnz.
SelectionDAG, on the other hand, just emits a compare and b.le.

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

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/opt-and-tbnz-tbz.mir
llvm/test/CodeGen/AArch64/GlobalISel/tbnz-slt.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 6691bf068042..3dba92eea3d3 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -257,6 +257,11 @@ class AArch64InstructionSelector : public 
InstructionSelector {
 MachineBasicBlock *DstMBB,
 MachineIRBuilder &MIB) const;
 
+  /// Emit a CB(N)Z instruction which branches to \p DestMBB.
+  MachineInstr *emitCBZ(Register CompareReg, bool IsNegative,
+MachineBasicBlock *DestMBB,
+MachineIRBuilder &MIB) const;
+
   // Equivalent to the i32shift_a and friends from AArch64InstrInfo.td.
   // We use these manually instead of using the importer since it doesn't
   // support SDNodeXForm.
@@ -1394,9 +1399,7 @@ bool 
AArch64InstructionSelector::tryOptAndIntoCompareBranch(
   // Only support EQ and NE. If we have LT, then it *is* possible to fold, but
   // we don't want to do this. When we have an AND and LT, we need a TST/ANDS,
   // so folding would be redundant.
-  if (Pred != CmpInst::Predicate::ICMP_EQ &&
-  Pred != CmpInst::Predicate::ICMP_NE)
-return false;
+  assert(ICmpInst::isEquality(Pred) && "Expected only eq/ne?");
 
   // Check if the AND has a constant on its RHS which we can use as a mask.
   // If it's a power of 2, then it's the same as checking a specific bit.
@@ -1415,6 +1418,27 @@ bool 
AArch64InstructionSelector::tryOptAndIntoCompareBranch(
   return true;
 }
 
+MachineInstr *AArch64InstructionSelector::emitCBZ(Register CompareReg,
+  bool IsNegative,
+  MachineBasicBlock *DestMBB,
+  MachineIRBuilder &MIB) const 
{
+  assert(ProduceNonFlagSettingCondBr && "CBZ does not set flags!");
+  MachineRegisterInfo &MRI = *MIB.getMRI();
+  assert(RBI.getRegBank(CompareReg, MRI, TRI)->getID() ==
+ AArch64::GPRRegBankID &&
+ "Expected GPRs only?");
+  auto Ty = MRI.getType(CompareReg);
+  unsigned Width = Ty.getSizeInBits();
+  assert(!Ty.isVector() && "Expected scalar only?");
+  assert(Width <= 64 && "Expected width to be at most 64?");
+  static const unsigned OpcTable[2][2] = {{AArch64::CBZW, AArch64::CBZX},
+  {AArch64::CBNZW, AArch64::CBNZX}};
+  unsigned Opc = OpcTable[IsNegative][Width == 64];
+  auto BranchMI = MIB.buildInstr(Opc, {}, {CompareReg}).addMBB(DestMBB);
+  constrainSelectedInstRegOperands(*BranchMI, TII, TRI, RBI);
+  return &*BranchMI;
+}
+
 bool AArch64InstructionSelector::selectCompareBranch(
 MachineInstr &I, MachineFunction &MF, MachineRegisterInfo &MRI) const {
 
@@ -1477,51 +1501,39 @@ bool AArch64InstructionSelector::selectCompareBranch(
 }
   }
 
-  if (!VRegAndVal) {
-std::swap(RHS, LHS);
-VRegAndVal = getConstantVRegValWithLookThrough(RHS, MRI);
-LHSMI = getDefIgnoringCopies(LHS, MRI);
-  }
+  // Attempt to handle commutative condition codes. Right now, that's only
+  // eq/ne.
+  if (ICmpInst::isEquality(Pred)) {
+if (!VRegAndVal) {
+  std::swap(RHS, LHS);
+  VRegAndVal = getConstantVRegValWithLookThrough(RHS, MRI);
+  LHSMI = getDefIgnoringCopies(LHS, MRI);
+}
 
-  if (!VRegAndVal || VRegAndVal->Value != 0) {
-// If we can't select a CBZ then emit a cmp + Bcc.
-auto Pred =
-static_cast(CCMI->getOperand(1).getPredicate());
-emitIntegerCompare(CCMI->getOperand(2), CCMI->getOperand(3),
-   CCMI->getOperand(1), MIB);
-const AAr

[llvm-branch-commits] [llvm] 19bdc8e - [llvm] Fix for failing test from fdbd84c6c819d4462546961f6086c1524d5d5ae8

2020-12-01 Thread Leonard Chan via llvm-branch-commits

Author: Leonard Chan
Date: 2020-12-01T15:47:55-08:00
New Revision: 19bdc8e5a307f6eb209d4f91620d70bd2f80219e

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

LOG: [llvm] Fix for failing test from fdbd84c6c819d4462546961f6086c1524d5d5ae8

When handling a DSOLocalEquivalent operand change:

- Remove assertion checking that the `To` type and current type are the
  same type. This is not always a requirement.
- Add a missing bitcast from an old DSOLocalEquivalent to the type of
  the new one.

Added: 


Modified: 
llvm/lib/IR/Constants.cpp

Removed: 




diff  --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index eba8c8eeaa87..64b58559e787 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -1851,7 +1851,6 @@ void DSOLocalEquivalent::destroyConstantImpl() {
 
 Value *DSOLocalEquivalent::handleOperandChangeImpl(Value *From, Value *To) {
   assert(From == getGlobalValue() && "Changing value does not match operand.");
-  assert(To->getType() == getType() && "Mismatched types");
   assert(isa(To) && "Can only replace the operands with a constant");
 
   // The replacement is with another global value.
@@ -1859,7 +1858,7 @@ Value *DSOLocalEquivalent::handleOperandChangeImpl(Value 
*From, Value *To) {
 DSOLocalEquivalent *&NewEquiv =
 getContext().pImpl->DSOLocalEquivalents[ToObj];
 if (NewEquiv)
-  return NewEquiv;
+  return llvm::ConstantExpr::getBitCast(NewEquiv, getType());
   }
 
   // If the argument is replaced with a null value, just replace this constant



___
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] 07ab597 - [lld/mac] Fix issues around thin archives

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

Author: Nico Weber
Date: 2020-12-01T18:48:29-05:00
New Revision: 07ab597bb0356ceae0195e4d66205e7eb2d07b7e

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

LOG: [lld/mac] Fix issues around thin archives

- most importantly, fix a use-after-free when using thin archives,
  by putting the archive unique_ptr to the arena allocator. This
  ports D65565 to MachO

- correctly demangle symbol namess from archives in diagnostics

- add a test for thin archives -- it finds this UaF, but only when
  running it under asan (it also finds the demangling fix)

- make forceLoadArchive() use addFile() with a bool to have the archive
  loading code in fewer places. no behavior change; matches COFF port a
  bit better

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

Added: 
lld/test/MachO/thin-archive.s

Modified: 
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/Symbols.cpp
lld/MachO/Symbols.h

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 295f2c412a7f..a02be0c9a67c 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -225,10 +225,12 @@ static std::vector 
getArchiveMembers(MemoryBufferRef mb) {
   std::unique_ptr file =
   CHECK(Archive::create(mb),
 mb.getBufferIdentifier() + ": failed to parse archive");
+  Archive *archive = file.get();
+  make>(std::move(file)); // take ownership
 
   std::vector v;
   Error err = Error::success();
-  for (const Archive::Child &c : file->children(err)) {
+  for (const Archive::Child &c : archive->children(err)) {
 MemoryBufferRef mbref =
 CHECK(c.getMemoryBufferRef(),
   mb.getBufferIdentifier() +
@@ -246,17 +248,7 @@ static std::vector 
getArchiveMembers(MemoryBufferRef mb) {
   return v;
 }
 
-static void forceLoadArchive(StringRef path) {
-  if (Optional buffer = readFile(path)) {
-for (const ArchiveMember &member : getArchiveMembers(*buffer)) {
-  auto file = make(member.mbref, member.modTime);
-  file->archiveName = buffer->getBufferIdentifier();
-  inputFiles.push_back(file);
-}
-  }
-}
-
-static InputFile *addFile(StringRef path) {
+static InputFile *addFile(StringRef path, bool forceLoadArchive) {
   Optional buffer = readFile(path);
   if (!buffer)
 return nullptr;
@@ -271,8 +263,14 @@ static InputFile *addFile(StringRef path) {
 if (!file->isEmpty() && !file->hasSymbolTable())
   error(path + ": archive has no index; run ranlib to add one");
 
-if (config->allLoad) {
-  forceLoadArchive(path);
+if (config->allLoad || forceLoadArchive) {
+  if (Optional buffer = readFile(path)) {
+for (const ArchiveMember &member : getArchiveMembers(*buffer)) {
+  auto file = make(member.mbref, member.modTime);
+  file->archiveName = buffer->getBufferIdentifier();
+  inputFiles.push_back(file);
+}
+  }
 } else if (config->forceLoadObjC) {
   for (const object::Archive::Symbol &sym : file->symbols())
 if (sym.getName().startswith(objc::klass))
@@ -320,7 +318,7 @@ static void addFileList(StringRef path) {
 return;
   MemoryBufferRef mbref = *buffer;
   for (StringRef path : args::getLines(mbref))
-addFile(path);
+addFile(path, false);
 }
 
 static std::array archNames{"arm","arm64", "i386",
@@ -671,10 +669,11 @@ bool macho::link(llvm::ArrayRef argsArr, 
bool canExitEarly,
 // TODO: are any of these better handled via filtered() or getLastArg()?
 switch (opt.getID()) {
 case OPT_INPUT:
-  addFile(arg->getValue());
+  addFile(arg->getValue(), false);
   break;
 case OPT_weak_library: {
-  auto *dylibFile = dyn_cast_or_null(addFile(arg->getValue()));
+  auto *dylibFile =
+  dyn_cast_or_null(addFile(arg->getValue(), false));
   if (dylibFile)
 dylibFile->forceWeakImport = true;
   break;
@@ -683,13 +682,13 @@ bool macho::link(llvm::ArrayRef argsArr, 
bool canExitEarly,
   addFileList(arg->getValue());
   break;
 case OPT_force_load:
-  forceLoadArchive(arg->getValue());
+  addFile(arg->getValue(), true);
   break;
 case OPT_l:
 case OPT_weak_l: {
   StringRef name = arg->getValue();
   if (Optional path = findLibrary(name)) {
-auto *dylibFile = dyn_cast_or_null(addFile(*path));
+auto *dylibFile = dyn_cast_or_null(addFile(*path, false));
 if (opt.getID() == OPT_weak_l && dylibFile)
   dylibFile->forceWeakImport = true;
 break;
@@ -701,7 +700,7 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
 case OPT_weak_framework: {
   StringRef name = arg->getValue();
   if (Optional path = findFramework(name)) {
-auto *dylibFile = dyn_cast_or_null(addFile(*path));
+auto *dy

  1   2   >