[llvm-branch-commits] [llvm] e987fbd - [BasicAA] Generalize recursive phi alias analysis

2020-11-29 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-11-29T10:25:23+01:00
New Revision: e987fbdd85d6bb5964d9db7a729d6ec8b1dc2322

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

LOG: [BasicAA] Generalize recursive phi alias analysis

For recursive phis, we skip the recursive operands and check that
the remaining operands are NoAlias with an unknown size. Currently,
this is limited to inbounds GEPs with positive offsets, to
guarantee that the recursion only ever increases the pointer.

Make this more general by only requiring that the underlying object
of the phi operand is the phi itself, i.e. it it based on itself in
some way. To compensate, we need to use a beforeOrAfterPointer()
location size, as we no longer have the guarantee that the pointer
is strictly increasing.

This allows us to handle some additional cases like negative geps,
geps with dynamic offsets or geps that aren't inbounds.

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

Added: 


Modified: 
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/recphi.ll
llvm/test/CodeGen/Thumb2/mve-float32regloops.ll

Removed: 




diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp 
b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 2e4ee1c429dd..2fb353eabb6e 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1516,27 +1516,16 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, 
LocationSize PNSize,
 }
 
   SmallVector V1Srcs;
-  // For a recursive phi, that recurses through a contant gep, we can perform
-  // aliasing calculations using the other phi operands with an unknown size to
-  // specify that an unknown number of elements after the initial value are
-  // potentially accessed.
+  // If a phi operand recurses back to the phi, we can still determine NoAlias
+  // if we don't alias the underlying objects of the other phi operands, as we
+  // know that the recursive phi needs to be based on them in some way.
   bool isRecursive = false;
   auto CheckForRecPhi = [&](Value *PV) {
 if (!EnableRecPhiAnalysis)
   return false;
-if (GEPOperator *PVGEP = dyn_cast(PV)) {
-  // Check whether the incoming value is a GEP that advances the pointer
-  // result of this PHI node (e.g. in a loop). If this is the case, we
-  // would recurse and always get a MayAlias. Handle this case specially
-  // below. We need to ensure that the phi is inbounds and has a constant
-  // positive operand so that we can check for alias with the initial value
-  // and an unknown but positive size.
-  if (PVGEP->getPointerOperand() == PN && PVGEP->isInBounds() &&
-  PVGEP->getNumIndices() == 1 && isa(PVGEP->idx_begin()) 
&&
-  !cast(PVGEP->idx_begin())->isNegative()) {
-isRecursive = true;
-return true;
-  }
+if (getUnderlyingObject(PV) == PN) {
+  isRecursive = true;
+  return true;
 }
 return false;
   };
@@ -1582,15 +1571,11 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, 
LocationSize PNSize,
   if (V1Srcs.empty())
 return MayAlias;
 
-  // If this PHI node is recursive, set the size of the accessed memory to
-  // unknown to represent all the possible values the GEP could advance the
-  // pointer to.
+  // If this PHI node is recursive, indicate that the pointer may be moved
+  // across iterations. We can only prove NoAlias if 
diff erent underlying
+  // objects are involved.
   if (isRecursive)
-// TODO: We are checking above that the addrec GEP has a positive offset
-// and can thus assume that all accesses happen after the base pointer.
-// It might be better to drop the offset requirement and use
-// beforeOrAfterPointer().
-PNSize = LocationSize::afterPointer();
+PNSize = LocationSize::beforeOrAfterPointer();
 
   // In the recursive alias queries below, we may compare values from two
   // 
diff erent loop iterations. Keep track of visited phi blocks, which will

diff  --git a/llvm/test/Analysis/BasicAA/recphi.ll 
b/llvm/test/Analysis/BasicAA/recphi.ll
index 26114fc60e1c..13a58fbcf118 100644
--- a/llvm/test/Analysis/BasicAA/recphi.ll
+++ b/llvm/test/Analysis/BasicAA/recphi.ll
@@ -141,10 +141,10 @@ if.end: ; preds = %f.exit
 ; CHECK: NoAlias:  [3 x i16]* %int_arr.10, i16** %argv.6.par
 ; CHECK: NoAlias:  i16* %_tmp1, i16** %argv.6.par
 ; CHECK: PartialAlias: [3 x i16]* %int_arr.10, i16* %_tmp1
-; CHECK: MayAlias: i16* %ls1.9.0, i16** %argv.6.par
+; CHECK: NoAlias:  i16* %ls1.9.0, i16** %argv.6.par
 ; CHECK: MayAlias: [3 x i16]* %int_arr.10, i16* %ls1.9.0
 ; CHECK: MayAlias: i16* %_tmp1, i16* %ls1.9.0
-; CHECK: MayAlias: i16* %_tmp7, i16** %

[llvm-branch-commits] [llvm] 1856e22 - [LangRef] minor fixes to poison examples and well-defined values section (NFC)

2020-11-29 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2020-11-29T20:51:25+09:00
New Revision: 1856e22eeb2de6e6d4325e3eed1e718abd89ea4b

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

LOG: [LangRef] minor fixes to poison examples and well-defined values section 
(NFC)

Added: 


Modified: 
llvm/docs/LangRef.rst

Removed: 




diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2cd3f93cffef..e359fc730515 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -3743,8 +3743,8 @@ Here are some examples:
 
   %narrowaddr = bitcast i32* @g to i16*
   %wideaddr = bitcast i32* @g to i64*
-  %poison3 = load i16, i16* %narrowaddr ; Returns a poison value.
-  %poison4 = load i64, i64* %wideaddr   ; Returns a poison value.
+  %poison4 = load i16, i16* %narrowaddr ; Returns a poison value.
+  %poison5 = load i64, i64* %wideaddr   ; Returns a poison value.
 
   %cmp = icmp slt i32 %poison, 0   ; Returns a poison value.
   br i1 %cmp, label %end, label %end   ; undefined behavior
@@ -3763,8 +3763,7 @@ The padding of an aggregate isn't considered, since it 
isn't visible
 without storing it into memory and loading it with a 
diff erent type.
 
 A constant of a :ref:`single value `, non-vector type is well
-defined if it is a non-undef constant. Note that there is no poison constant
-in LLVM.
+defined if it is neither '``undef``' constant nor '``poison``' constant.
 The result of :ref:`freeze instruction ` is well defined regardless
 of its operand.
 



___
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] 53040a9 - [ConstantFold] Fold more operations to poison

2020-11-29 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2020-11-29T21:19:48+09:00
New Revision: 53040a968dc2ff20931661e55f05da2ef8b964a0

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

LOG: [ConstantFold] Fold more operations to poison

This patch folds more operations to poison.

Alive2 proof: https://alive2.llvm.org/ce/z/mxcb9G (it does not contain tests 
about div/rem because they fold to poison when raising UB)

Reviewed By: nikic

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

Added: 


Modified: 
clang/test/Frontend/fixed_point_unary.c
llvm/lib/IR/ConstantFold.cpp
llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-fold-binop-select.ll
llvm/test/Transforms/InstCombine/apint-shift.ll
llvm/test/Transforms/InstCombine/canonicalize-ashr-shl-to-masking.ll
llvm/test/Transforms/InstCombine/canonicalize-lshr-shl-to-masking.ll
llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll
llvm/test/Transforms/InstCombine/icmp.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-b.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-c.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll
llvm/test/Transforms/InstCombine/select-of-bittest.ll
llvm/test/Transforms/InstCombine/shift-add.ll
llvm/test/Transforms/InstSimplify/ConstProp/InsertElement.ll
llvm/test/Transforms/InstSimplify/ConstProp/cast.ll
llvm/test/Transforms/InstSimplify/ConstProp/poison.ll
llvm/test/Transforms/InstSimplify/ConstProp/shift.ll
llvm/test/Transforms/InstSimplify/ConstProp/vector-undef-elts.ll
llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll
llvm/test/Transforms/InstSimplify/div.ll
llvm/test/Transforms/InstSimplify/rem.ll
llvm/test/Transforms/InstSimplify/undef.ll
llvm/test/Transforms/SROA/phi-gep.ll
llvm/test/Transforms/SROA/select-gep.ll
llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll
llvm/test/Transforms/VectorCombine/X86/insert-binop.ll
llvm/unittests/IR/ConstantsTest.cpp

Removed: 




diff  --git a/clang/test/Frontend/fixed_point_unary.c 
b/clang/test/Frontend/fixed_point_unary.c
index 849e38a94bc4..6ce760daba11 100644
--- a/clang/test/Frontend/fixed_point_unary.c
+++ b/clang/test/Frontend/fixed_point_unary.c
@@ -90,7 +90,7 @@ void inc_usa() {
 // SIGNED-LABEL: @inc_uf(
 // SIGNED-NEXT:  entry:
 // SIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @uf, align 2
-// SIGNED-NEXT:[[TMP1:%.*]] = add i16 [[TMP0]], undef
+// SIGNED-NEXT:[[TMP1:%.*]] = add i16 [[TMP0]], poison
 // SIGNED-NEXT:store i16 [[TMP1]], i16* @uf, align 2
 // SIGNED-NEXT:ret void
 //
@@ -271,7 +271,7 @@ void dec_usa() {
 // SIGNED-LABEL: @dec_uf(
 // SIGNED-NEXT:  entry:
 // SIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @uf, align 2
-// SIGNED-NEXT:[[TMP1:%.*]] = sub i16 [[TMP0]], undef
+// SIGNED-NEXT:[[TMP1:%.*]] = sub i16 [[TMP0]], poison
 // SIGNED-NEXT:store i16 [[TMP1]], i16* @uf, align 2
 // SIGNED-NEXT:ret void
 //

diff  --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index a52cd725d530..3243ddd604ee 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -630,7 +630,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, 
Constant *V,
   V.convertToInteger(IntVal, APFloat::rmTowardZero, &ignored)) {
 // Undefined behavior invoked - the destination type can't represent
 // the input constant.
-return UndefValue::get(DestTy);
+return PoisonValue::get(DestTy);
   }
   return ConstantInt::get(FPC->getContext(), IntVal);
 }
@@ -916,7 +916,7 @@ Constant 
*llvm::ConstantFoldInsertElementInstruction(Constant *Val,
 
   unsigned NumElts = ValTy->getNumElements();
   if (CIdx->uge(NumElts))
-return UndefValue::get(Val->getType());
+return PoisonValue::get(Val->getType());
 
   SmallVector Result;
   Result.reserve(NumElts);
@@ -1144,23 +1144,21

[llvm-branch-commits] [clang-tools-extra] 67d16b6 - [clangd] Cache .clang-tidy files again.

2020-11-29 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-11-29T13:28:53+01:00
New Revision: 67d16b6da4bef1ee174514148854e77151a62605

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

LOG: [clangd] Cache .clang-tidy files again.

This cache went away in 73fdd998701cce3aa6c4d8d2a73ab97351a0313b

This time, the cache is periodically validated against disk, so config
is still mostly "live".

The per-file cache reuses FileCache, but the tree-of-file-caches is
duplicated from ConfigProvider. .clangd, .clang-tidy, .clang-format, and
compile_commands.json all have this pattern, we should extract it at some point.
TODO for now though.

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp 
b/clang-tools-extra/clangd/TidyProvider.cpp
index 1fb79f3abbce3..687ae6501d25f 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -8,7 +8,9 @@
 
 #include "TidyProvider.h"
 #include "Config.h"
+#include "support/FileCache.h"
 #include "support/Logger.h"
+#include "support/ThreadsafeFS.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
@@ -19,53 +21,115 @@
 
 namespace clang {
 namespace clangd {
+namespace {
 
-static void mergeCheckList(llvm::Optional &Checks,
-   llvm::StringRef List) {
-  if (List.empty())
-return;
-  if (!Checks || Checks->empty()) {
-Checks.emplace(List);
-return;
+// Access to config from a .clang-tidy file, caching IO and parsing.
+class DotClangTidyCache : private FileCache {
+  // We cache and expose shared_ptr to avoid copying the value on every lookup
+  // when we're ultimately just going to pass it to mergeWith.
+  mutable std::shared_ptr Value;
+
+public:
+  DotClangTidyCache(PathRef Path) : FileCache(Path) {}
+
+  std::shared_ptr
+  get(const ThreadsafeFS &TFS,
+  std::chrono::steady_clock::time_point FreshTime) const {
+std::shared_ptr Result;
+read(
+TFS, FreshTime,
+[this](llvm::Optional Data) {
+  Value.reset();
+  if (Data && !Data->empty()) {
+if (auto Parsed = tidy::parseConfiguration(*Data))
+  Value = std::make_shared(
+  std::move(*Parsed));
+else
+  elog("Error parsing clang-tidy configuration in {0}: {1}", 
path(),
+   Parsed.getError().message());
+  }
+},
+[&]() { Result = Value; });
+return Result;
   }
-  *Checks = llvm::join_items(",", *Checks, List);
-}
+};
 
-static llvm::Optional
-tryReadConfigFile(llvm::vfs::FileSystem *FS, llvm::StringRef Directory) {
-  assert(!Directory.empty());
-  // We guaranteed that child directories of Directory exist, so this assert
-  // should hopefully never fail.
-  assert(FS->exists(Directory));
+// Access to combined config from .clang-tidy files governing a source file.
+// Each config file is cached and the caches are shared for affected sources.
+//
+// FIXME: largely duplicates config::Provider::fromAncestorRelativeYAMLFiles.
+// Potentially useful for compile_commands.json too. Extract?
+class DotClangTidyTree {
+  const ThreadsafeFS &FS;
+  std::string RelPath;
+  std::chrono::steady_clock::duration MaxStaleness;
 
-  llvm::SmallString<128> ConfigFile(Directory);
-  llvm::sys::path::append(ConfigFile, ".clang-tidy");
+  mutable std::mutex Mu;
+  // Keys are the ancestor directory, not the actual config path within it.
+  // We only insert into this map, so pointers to values are stable forever.
+  // Mutex guards the map itself, not the values (which are threadsafe).
+  mutable llvm::StringMap Cache;
 
-  llvm::ErrorOr FileStatus = FS->status(ConfigFile);
+public:
+  DotClangTidyTree(const ThreadsafeFS &FS)
+  : FS(FS), RelPath(".clang-tidy"), MaxStaleness(std::chrono::seconds(5)) 
{}
 
-  if (!FileStatus || !FileStatus->isRegularFile())
-return llvm::None;
+  void apply(tidy::ClangTidyOptions &Result, PathRef AbsPath) {
+namespace path = llvm::sys::path;
+assert(path::is_absolute(AbsPath));
+
+// Compute absolute paths to all ancestors (substrings of P.Path).
+// Ensure cache entries for each ancestor exist in the map.
+llvm::StringRef Parent = path::parent_path(AbsPath);
+llvm::SmallVector Caches;
+{
+  std::lock_guard Lock(Mu);
+  for (auto I = path::begin(Parent, path::Style::posix),
+E = path::end(Parent);
+   I != E; ++I) {
+assert(I->end() >= Parent.begin() && I->end() <= Parent.end() &&
+   "Canonical path components should be substrings");
+llvm::StringRef Ancestor(Parent.begin(), I->end() - Parent.begin());

[llvm-branch-commits] [clang-tools-extra] d99da80 - [clangd] Fix path edge-case condition.

2020-11-29 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-11-29T13:40:29+01:00
New Revision: d99da80841cb4d9734db4a48cd49e37b623176bc

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

LOG: [clangd] Fix path edge-case condition.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigProvider.cpp 
b/clang-tools-extra/clangd/ConfigProvider.cpp
index e020ec04d1d2..8a3991ed1c1e 100644
--- a/clang-tools-extra/clangd/ConfigProvider.cpp
+++ b/clang-tools-extra/clangd/ConfigProvider.cpp
@@ -103,7 +103,7 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef 
RelPath,
I != E; ++I) {
 // Avoid weird non-substring cases like phantom "." components.
 // In practice, Component is a substring for all "normal" ancestors.
-if (I->end() < Parent.begin() && I->end() > Parent.end())
+if (I->end() < Parent.begin() || I->end() > Parent.end())
   continue;
 Ancestors.emplace_back(Parent.begin(), I->end() - Parent.begin());
   }



___
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] fba0b65 - [libc++] hash: adjust for x86-64 ILP32

2020-11-29 Thread Harald van Dijk via llvm-branch-commits

Author: Harald van Dijk
Date: 2020-11-29T13:52:28Z
New Revision: fba0b65f727134e8d05c785b04b7b574f852d49e

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

LOG: [libc++] hash: adjust for x86-64 ILP32

x86-64 ILP32 mode (x32) uses 32-bit size_t, so share the code with ix86 to zero 
out padding bits, not with x86-64 LP64 mode.

Reviewed By: #libc, ldionne

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

Added: 


Modified: 
libcxx/include/utility

Removed: 




diff  --git a/libcxx/include/utility b/libcxx/include/utility
index 13489de22c95..5c9e2b6ddef2 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -1506,7 +1506,7 @@ struct _LIBCPP_TEMPLATE_VIS hash
 // -0.0 and 0.0 should return same hash
 if (__v == 0.0L)
 return 0;
-#if defined(__i386__)
+#if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__))
 // Zero out padding bits
 union
 {



___
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] 2cebad7 - [IR] remove redundant code comments; NFC

2020-11-29 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-11-29T09:29:59-05:00
New Revision: 2cebad702cdff8c320c8afa748626e8cc1b3b2f3

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

LOG: [IR] remove redundant code comments; NFC

As noted in D92247 (and independent of that patch):

http://llvm.org/docs/CodingStandards.html#doxygen-use-in-documentation-comments

"Don’t duplicate the documentation comment in the header file and in the
implementation file. Put the documentation comments for public APIs into
the header file."

Added: 


Modified: 
llvm/lib/IR/BasicBlock.cpp

Removed: 




diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 23a1184e1246..31666265b504 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -130,15 +130,11 @@ iplist::iterator 
BasicBlock::eraseFromParent() {
   return getParent()->getBasicBlockList().erase(getIterator());
 }
 
-/// Unlink this basic block from its current function and
-/// insert it into the function that MovePos lives in, right before MovePos.
 void BasicBlock::moveBefore(BasicBlock *MovePos) {
   MovePos->getParent()->getBasicBlockList().splice(
   MovePos->getIterator(), getParent()->getBasicBlockList(), getIterator());
 }
 
-/// Unlink this basic block from its current function and
-/// insert it into the function that MovePos lives in, right after MovePos.
 void BasicBlock::moveAfter(BasicBlock *MovePos) {
   MovePos->getParent()->getBasicBlockList().splice(
   ++MovePos->getIterator(), getParent()->getBasicBlockList(),
@@ -265,8 +261,6 @@ void BasicBlock::dropAllReferences() {
 I.dropAllReferences();
 }
 
-/// If this basic block has a single predecessor block,
-/// return the block, otherwise return a null pointer.
 const BasicBlock *BasicBlock::getSinglePredecessor() const {
   const_pred_iterator PI = pred_begin(this), E = pred_end(this);
   if (PI == E) return nullptr; // No preds.
@@ -275,11 +269,6 @@ const BasicBlock *BasicBlock::getSinglePredecessor() const 
{
   return (PI == E) ? ThePred : nullptr /*multiple preds*/;
 }
 
-/// If this basic block has a unique predecessor block,
-/// return the block, otherwise return a null pointer.
-/// Note that unique predecessor doesn't mean single edge, there can be
-/// multiple edges from the unique predecessor to this block (for example
-/// a switch statement with multiple cases having the same destination).
 const BasicBlock *BasicBlock::getUniquePredecessor() const {
   const_pred_iterator PI = pred_begin(this), E = pred_end(this);
   if (PI == E) return nullptr; // No preds.
@@ -329,12 +318,6 @@ iterator_range 
BasicBlock::phis() {
   return make_range(P, nullptr);
 }
 
-/// Update PHI nodes in this BasicBlock before removal of predecessor \p Pred.
-/// Note that this function does not actually remove the predecessor.
-///
-/// If \p KeepOneInputPHIs is true then don't remove PHIs that are left with
-/// zero or one incoming values, and don't simplify PHIs with all incoming
-/// values the same.
 void BasicBlock::removePredecessor(BasicBlock *Pred,
bool KeepOneInputPHIs) {
   // Use hasNUsesOrMore to bound the cost of this assertion for complex CFGs.
@@ -389,17 +372,6 @@ bool BasicBlock::isLegalToHoistInto() const {
   return !Term->isExceptionalTerminator();
 }
 
-/// This splits a basic block into two at the specified
-/// instruction.  Note that all instructions BEFORE the specified iterator stay
-/// as part of the original basic block, an unconditional branch is added to
-/// the new BB, and the rest of the instructions in the BB are moved to the new
-/// BB, including the old terminator.  This invalidates the iterator.
-///
-/// Note that this only works on well formed basic blocks (must have a
-/// terminator), and 'I' must not be the end of instruction list (which would
-/// cause a degenerate basic block to be formed, having a terminator inside of
-/// the basic block).
-///
 BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
   assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
   assert(I != InstList.end() &&
@@ -454,13 +426,10 @@ void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock 
*New) {
   this->replaceSuccessorsPhiUsesWith(this, New);
 }
 
-/// Return true if this basic block is a landing pad. I.e., it's
-/// the destination of the 'unwind' edge of an invoke instruction.
 bool BasicBlock::isLandingPad() const {
   return isa(getFirstNonPHI());
 }
 
-/// Return the landingpad instruction associated with the landing pad.
 const LandingPadInst *BasicBlock::getLandingPadInst() const {
   return dyn_cast(getFirstNonPHI());
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lis

[llvm-branch-commits] [llvm] ce134da - [IR] simplify code in removePredecessor(); NFCI

2020-11-29 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-11-29T09:55:04-05:00
New Revision: ce134da4b18c27bbeba4e32f5813b1a3b043066e

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

LOG: [IR] simplify code in removePredecessor(); NFCI

As suggested in D92247 (and independent of whatever we decide to do there),
this code is confusing as-is. Hopefully, this is at least mildly better.

We might be able to do better still, but we have a function called
"removePredecessor" with this behavior:
"Note that this function does not actually remove the predecessor." (!)

Added: 


Modified: 
llvm/lib/IR/BasicBlock.cpp

Removed: 




diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 31666265b504..3268641ddf19 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -327,21 +327,19 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
   // Return early if there are no PHI nodes to update.
   if (!isa(begin()))
 return;
-  unsigned NumPreds = cast(front()).getNumIncomingValues();
 
-  // Update all PHI nodes.
-  for (iterator II = begin(); isa(II);) {
-PHINode *PN = cast(II++);
-PN->removeIncomingValue(Pred, !KeepOneInputPHIs);
-if (!KeepOneInputPHIs) {
-  // If we have a single predecessor, removeIncomingValue erased the PHI
-  // node itself.
-  if (NumPreds > 1) {
-if (Value *PNV = PN->hasConstantValue()) {
-  // Replace the PHI node with its constant value.
-  PN->replaceAllUsesWith(PNV);
-  PN->eraseFromParent();
-}
+  unsigned NumPreds = cast(front()).getNumIncomingValues();
+  for (PHINode &Phi : make_early_inc_range(phis())) {
+Phi.removeIncomingValue(Pred, !KeepOneInputPHIs);
+if (KeepOneInputPHIs)
+  continue;
+// If we have a single predecessor, removeIncomingValue erased the PHI
+// node itself.
+// Try to replace the PHI node with a constant value.
+if (NumPreds > 1) {
+  if (Value *PhiConstant = Phi.hasConstantValue()) {
+Phi.replaceAllUsesWith(PhiConstant);
+Phi.eraseFromParent();
   }
 }
   }



___
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] a813090 - [VPlan] Manage stored values of interleave groups using VPUser (NFC)

2020-11-29 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-11-29T17:24:36Z
New Revision: a813090072c0527eb6ed51dd2ea4f54cb6bc72a0

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

LOG: [VPlan] Manage stored values of interleave groups using VPUser (NFC)

Interleave groups also depend on the values they store. Manage the
stored values as VPUser operands. This is currently a NFC, but is
required to allow VPlan transforms and to manage generated vector values
exclusively in VPTransformState.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 0f519d136b31..1b716e1051cc 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -550,6 +550,7 @@ class InnerLoopVectorizer {
   /// values in the vectorized loop.
   void vectorizeInterleaveGroup(const InterleaveGroup *Group,
 VPTransformState &State, VPValue *Addr,
+ArrayRef StoredValues,
 VPValue *BlockInMask = nullptr);
 
   /// Vectorize Load and Store instructions with the base address given in \p
@@ -2322,7 +2323,7 @@ static bool useMaskedInterleavedAccesses(const 
TargetTransformInfo &TTI) {
 //   store <12 x i32> %interleaved.vec  ; Write 4 tuples of R,G,B
 void InnerLoopVectorizer::vectorizeInterleaveGroup(
 const InterleaveGroup *Group, VPTransformState &State,
-VPValue *Addr, VPValue *BlockInMask) {
+VPValue *Addr, ArrayRef StoredValues, VPValue *BlockInMask) {
   Instruction *Instr = Group->getInsertPos();
   const DataLayout &DL = Instr->getModule()->getDataLayout();
 
@@ -2467,8 +2468,8 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
   Instruction *Member = Group->getMember(i);
   assert(Member && "Fail to get a member from an interleaved store group");
 
-  Value *StoredVec = getOrCreateVectorValue(
-  cast(Member)->getValueOperand(), Part);
+  Value *StoredVec = State.get(StoredValues[i], Part);
+
   if (Group->isReverse())
 StoredVec = reverseVector(StoredVec);
 
@@ -7828,7 +7829,13 @@ VPlanPtr 
LoopVectorizationPlanner::buildVPlanWithVPRecipes(
   for (auto IG : InterleaveGroups) {
 auto *Recipe = cast(
 RecipeBuilder.getRecipe(IG->getInsertPos()));
-(new VPInterleaveRecipe(IG, Recipe->getAddr(), Recipe->getMask()))
+SmallVector StoredValues;
+for (unsigned i = 0; i < IG->getFactor(); ++i)
+  if (auto *SI = dyn_cast_or_null(IG->getMember(i)))
+StoredValues.push_back(Plan->getOrAddVPValue(SI->getOperand(0)));
+
+(new VPInterleaveRecipe(IG, Recipe->getAddr(), StoredValues,
+Recipe->getMask()))
 ->insertBefore(Recipe);
 
 for (unsigned i = 0; i < IG->getFactor(); ++i)
@@ -8068,7 +8075,8 @@ void VPBlendRecipe::execute(VPTransformState &State) {
 
 void VPInterleaveRecipe::execute(VPTransformState &State) {
   assert(!State.Instance && "Interleave group being replicated.");
-  State.ILV->vectorizeInterleaveGroup(IG, State, getAddr(), getMask());
+  State.ILV->vectorizeInterleaveGroup(IG, State, getAddr(), getStoredValues(),
+  getMask());
 }
 
 void VPReductionRecipe::execute(VPTransformState &State) {

diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index b4d84ed57773..4abb08809da5 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1035,16 +1035,24 @@ class VPBlendRecipe : public VPRecipeBase, public 
VPUser {
 };
 
 /// VPInterleaveRecipe is a recipe for transforming an interleave group of load
-/// or stores into one wide load/store and shuffles.
+/// or stores into one wide load/store and shuffles. The first operand of a
+/// VPInterleave recipe is the address, followed by the stored values, followed
+/// by an optional mask.
 class VPInterleaveRecipe : public VPRecipeBase, public VPUser {
   const InterleaveGroup *IG;
 
+  bool HasMask = false;
+
 public:
   VPInterleaveRecipe(const InterleaveGroup *IG, VPValue *Addr,
- VPValue *Mask)
+ ArrayRef StoredValues, VPValue *Mask)
   : VPRecipeBase(VPInterleaveSC), VPUser({Addr}), IG(IG) {
-if (Mask)
+for (auto *SV : StoredValues)
+  addOperand(SV);
+if (Mask) {
+  HasMask = true;
   addOperand(Mask);
+}
   }
   ~VPInterleaveRecipe() override = default;
 
@@ -1062,7 +1070,16 @@ class VPInterleaveRecipe : public VPRecipeBase, public 
VPUser {
   /// by a nullptr.
  

[llvm-branch-commits] [openmp] cdf9401 - [OpenMP][OMPT][NFC] Fix flaky test

2020-11-29 Thread Joachim Protze via llvm-branch-commits

Author: Joachim Protze
Date: 2020-11-29T19:07:41+01:00
New Revision: cdf9401df84ef382467d1ca1c1c458c11fd6043a

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

LOG: [OpenMP][OMPT][NFC] Fix flaky test

The test had a chance to finish the first task before the second task is
created. In this case, the dependences-pair event would not trigger.

Added: 


Modified: 
openmp/runtime/test/ompt/tasks/dependences.c

Removed: 




diff  --git a/openmp/runtime/test/ompt/tasks/dependences.c 
b/openmp/runtime/test/ompt/tasks/dependences.c
index 9e9349f95610..16732e3fe1f0 100644
--- a/openmp/runtime/test/ompt/tasks/dependences.c
+++ b/openmp/runtime/test/ompt/tasks/dependences.c
@@ -9,6 +9,7 @@
 
 int main() {
   int x = 0;
+  int condition=0;
 #pragma omp parallel num_threads(2)
   {
 #pragma omp master
@@ -16,10 +17,10 @@ int main() {
   print_ids(0);
   printf("%" PRIu64 ": address of x: %p\n", ompt_get_thread_data()->value,
  &x);
-#pragma omp task depend(out : x)
+#pragma omp task depend(out : x) shared(condition)
   {
 x++;
-delay(100);
+OMPT_WAIT(condition,1);
   }
   print_fuzzy_address(1);
   print_ids(0);
@@ -27,6 +28,7 @@ int main() {
 #pragma omp task depend(in : x)
   { x = -1; }
   print_ids(0);
+  OMPT_SIGNAL(condition);
 }
   }
 



___
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] 723be40 - [OpenMP][OMPT][NFC] Fix failing test

2020-11-29 Thread Joachim Protze via llvm-branch-commits

Author: Joachim Protze
Date: 2020-11-29T19:07:42+01:00
New Revision: 723be4042a3aa38523c60b1dd96b20448053c41e

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

LOG: [OpenMP][OMPT][NFC] Fix failing test

The test would fail for gcc, when built with debug flag.

Added: 


Modified: 
openmp/runtime/test/ompt/tasks/serialized.c

Removed: 




diff  --git a/openmp/runtime/test/ompt/tasks/serialized.c 
b/openmp/runtime/test/ompt/tasks/serialized.c
index a2c102ac53c2..1ce0b17a395c 100644
--- a/openmp/runtime/test/ompt/tasks/serialized.c
+++ b/openmp/runtime/test/ompt/tasks/serialized.c
@@ -22,12 +22,15 @@ int main() {
   int t = (int)sin(0.1);
 #pragma omp task if (t)
   {
-void *task_frame = get_frame_address(0);
-if (creator_frame == task_frame) {
-  // Assume this code was inlined which the compiler is allowed to do.
+if (creator_frame == get_frame_address(0)) {
+  printf("Assume this code was inlined which the compiler is allowed 
to do:\n");
   print_frame(0);
+} else if (creator_frame == get_frame_address(1)) {
+  printf("Assume this code was called from the application:\n");
+  print_frame(1);
 } else {
   // The exit frame must be our parent!
+  printf("Assume this code was not inlined, exit frame must be our 
parent:\n");
   print_frame_from_outlined_fn(1);
 }
 print_ids(0);



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


[llvm-branch-commits] [mlir] 7f52131 - Use `const` for array pointers in `StandardTypes.h`

2020-11-29 Thread via llvm-branch-commits

Author: George
Date: 2020-11-29T10:13:35-08:00
New Revision: 7f521318e4f7d9e64907fad8c4bd83ddc037f8c6

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

LOG: Use `const` for array pointers in `StandardTypes.h`

This mirrors the underlying C++ api.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir-c/StandardTypes.h
mlir/lib/CAPI/IR/StandardTypes.cpp

Removed: 




diff  --git a/mlir/include/mlir-c/StandardTypes.h 
b/mlir/include/mlir-c/StandardTypes.h
index 7b51ad8d6a77..9839a1946ad9 100644
--- a/mlir/include/mlir-c/StandardTypes.h
+++ b/mlir/include/mlir-c/StandardTypes.h
@@ -164,13 +164,14 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAVector(MlirType type);
 /** Creates a vector type of the shape identified by its rank and dimensions,
  * with the given element type in the same context as the element type. The 
type
  * is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank, int64_t *shape,
+MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank,
+  const int64_t *shape,
   MlirType elementType);
 
 /** Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on
  * illegal arguments, emitting appropriate diagnostics. */
 MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(intptr_t rank,
- int64_t *shape,
+ const int64_t *shape,
  MlirType elementType,
  MlirLocation loc);
 
@@ -190,13 +191,13 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedTensor(MlirType 
type);
 /** Creates a tensor type of a fixed rank with the given shape and element type
  * in the same context as the element type. The type is owned by the context. 
*/
 MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank,
-int64_t *shape,
+const int64_t *shape,
 MlirType elementType);
 
 /** Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType 
on
  * illegal arguments, emitting appropriate diagnostics. */
 MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(intptr_t rank,
-   int64_t *shape,
+   const int64_t 
*shape,
MlirType 
elementType,
MlirLocation loc);
 
@@ -222,11 +223,9 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedMemRef(MlirType 
type);
 /** Creates a MemRef type with the given rank and shape, a potentially empty
  * list of affine layout maps, the given memory space and element type, in the
  * same context as element type. The type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType,
-  intptr_t rank, int64_t *shape,
-  intptr_t numMaps,
-  MlirAttribute const *affineMaps,
-  unsigned memorySpace);
+MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(
+MlirType elementType, intptr_t rank, const int64_t *shape, intptr_t 
numMaps,
+MlirAttribute const *affineMaps, unsigned memorySpace);
 
 /** Creates a MemRef type with the given rank, shape, memory space and element
  * type in the same context as the element type. The type has no affine maps,
@@ -234,14 +233,14 @@ MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType 
elementType,
  * the context. */
 MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGet(MlirType elementType,
 intptr_t rank,
-int64_t *shape,
+const int64_t *shape,
 unsigned memorySpace);
 
 /** Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping
  * MlirType on illegal arguments, emitting appropriate diagnostics. */
 MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked(
-MlirType elementType, intptr_t rank, int64_t *shape, unsigned memorySpace,
-MlirLocation loc);
+MlirType elementType, intptr_t rank, const int64_t *shape,
+unsigned memorySpace, MlirLocation loc);
 
 /** Creates an Unr

[llvm-branch-commits] [llvm] 4bc9b90 - [VPlan] Use VPValue and VPUser ops to print VPReplicateRecipe.

2020-11-29 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-11-29T18:28:27Z
New Revision: 4bc9b909d715157a2d04f32c32b828c23c1d4359

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

LOG: [VPlan] Use VPValue and VPUser ops to print VPReplicateRecipe.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/test/Transforms/LoopVectorize/vplan-printing.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 3b26d6b52efd..c51ed5e3e7db 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -966,8 +966,15 @@ void VPReductionRecipe::print(raw_ostream &O, const Twine 
&Indent,
 
 void VPReplicateRecipe::print(raw_ostream &O, const Twine &Indent,
   VPSlotTracker &SlotTracker) const {
-  O << "\"" << (IsUniform ? "CLONE " : "REPLICATE ")
-<< VPlanIngredient(getUnderlyingInstr());
+  O << "\"" << (IsUniform ? "CLONE " : "REPLICATE ");
+
+  if (!getUnderlyingInstr()->getType()->isVoidTy()) {
+printAsOperand(O, SlotTracker);
+O << " = ";
+  }
+  O << Instruction::getOpcodeName(getUnderlyingInstr()->getOpcode()) << " ";
+  printOperands(O, SlotTracker);
+
   if (AlsoPack)
 O << " (S->V)";
 }

diff  --git a/llvm/test/Transforms/LoopVectorize/vplan-printing.ll 
b/llvm/test/Transforms/LoopVectorize/vplan-printing.ll
index 21d236ac76b2..370fe8eee0f4 100644
--- a/llvm/test/Transforms/LoopVectorize/vplan-printing.ll
+++ b/llvm/test/Transforms/LoopVectorize/vplan-printing.ll
@@ -10,10 +10,10 @@ define void @print_call_and_memory(i64 %n, float* noalias 
%y, float* noalias %x)
 ; CHECK: N0 [label =
 ; CHECK-NEXT: "for.body:\n" +
 ; CHECK-NEXT:   "WIDEN-INDUCTION %iv = phi %iv.next, 0\l" +
-; CHECK-NEXT:   "CLONE %arrayidx = getelementptr %y, %iv\l" +
+; CHECK-NEXT:   "CLONE ir<%arrayidx> = getelementptr ir<%y>, ir<%iv>\l" +
 ; CHECK-NEXT:   "WIDEN ir<%lv> = load ir<%arrayidx>\l" +
 ; CHECK-NEXT:   "WIDEN-CALL ir<%call> = call @llvm.sqrt.f32(ir<%lv>)\l" +
-; CHECK-NEXT:   "CLONE %arrayidx2 = getelementptr %x, %iv\l" +
+; CHECK-NEXT:   "CLONE ir<%arrayidx2> = getelementptr ir<%x>, ir<%iv>\l" +
 ; CHECK-NEXT:   "WIDEN store ir<%arrayidx2>, ir<%call>\l"
 ; CHECK-NEXT:   ]
 
@@ -45,7 +45,7 @@ define void @print_widen_gep_and_select(i64 %n, float* 
noalias %y, float* noalia
 ; CHECK-NEXT:  "WIDEN ir<%cmp> = icmp ir<%arrayidx>, ir<%z>\l" +
 ; CHECK-NEXT:  "WIDEN-SELECT ir<%sel> = select ir<%cmp>, ir<1.00e+01>, 
ir<2.00e+01>\l" +
 ; CHECK-NEXT:  "WIDEN ir<%add> = fadd ir<%lv>, ir<%sel>\l" +
-; CHECK-NEXT:  "CLONE %arrayidx2 = getelementptr %x, %iv\l" +
+; CHECK-NEXT:  "CLONE ir<%arrayidx2> = getelementptr ir<%x>, ir<%iv>\l" +
 ; CHECK-NEXT:  "WIDEN store ir<%arrayidx2>, ir<%add>\l"
 ; CHECK-NEXT:   ]
 
@@ -75,7 +75,7 @@ define float @print_reduction(i64 %n, float* noalias %y) {
 ; CHECK-NEXT: "for.body:\n" +
 ; CHECK-NEXT:   "WIDEN-INDUCTION %iv = phi %iv.next, 0\l" +
 ; CHECK-NEXT:   "WIDEN-PHI %red = phi %red.next, 0.00e+00\l" +
-; CHECK-NEXT:   "CLONE %arrayidx = getelementptr %y, %iv\l" +
+; CHECK-NEXT:   "CLONE ir<%arrayidx> = getelementptr ir<%y>, ir<%iv>\l" +
 ; CHECK-NEXT:   "WIDEN ir<%lv> = load ir<%arrayidx>\l" +
 ; CHECK-NEXT:   "REDUCE ir<%red.next> = ir<%red> + reduce.fadd (ir<%lv>)\l"
 ; CHECK-NEXT:   ]



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


[llvm-branch-commits] [llvm] 5408fdc - [VPlan] Fix -Wunused-variable after a813090072c0527eb6ed51dd2ea4f54cb6bc72a0

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

Author: Fangrui Song
Date: 2020-11-29T10:38:01-08:00
New Revision: 5408fdcd78ad4783a39c0c18d5a18a7d926514b7

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

LOG: [VPlan] Fix -Wunused-variable after 
a813090072c0527eb6ed51dd2ea4f54cb6bc72a0

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 1b716e1051cc0..517d754b4ea61 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2465,8 +2465,7 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
 SmallVector StoredVecs;
 for (unsigned i = 0; i < InterleaveFactor; i++) {
   // Interleaved store group doesn't allow a gap, so each index has a 
member
-  Instruction *Member = Group->getMember(i);
-  assert(Member && "Fail to get a member from an interleaved store group");
+  assert(Group->getMember(i) && "Fail to get a member from an interleaved 
store group");
 
   Value *StoredVec = State.get(StoredValues[i], Part);
 



___
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] e534cee - [mlir] Add a shape function library op

2020-11-29 Thread Jacques Pienaar via llvm-branch-commits

Author: Jacques Pienaar
Date: 2020-11-29T11:15:30-08:00
New Revision: e534cee26ae3626ced20438ea82e11291cc768e8

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

LOG: [mlir] Add a shape function library op

Op with mapping from ops to corresponding shape functions for those op
in the library and mechanism to associate shape functions to functions.
The mapping of operand to shape function is kept separate from the shape
functions themselves as the operation is associated to the shape
function and not vice versa, and one could have a common library of
shape functions that can be used in different contexts.

Use fully qualified names and require a name for shape fn lib ops for
now and an explicit print/parse (based around the generated one & GPU
module op ones).

This commit reverts d9da4c3e73720badfcac5c0dc63c0285bb690770. Fixes
missing headers (don't know how that was working locally).

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

Added: 
mlir/test/Analysis/test-shape-fn-report.mlir
mlir/test/lib/Dialect/Shape/CMakeLists.txt
mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp

Modified: 
mlir/include/mlir/Dialect/Shape/IR/Shape.h
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/test/lib/Dialect/CMakeLists.txt
mlir/test/lib/Dialect/Test/TestOps.td
mlir/tools/mlir-opt/CMakeLists.txt
mlir/tools/mlir-opt/mlir-opt.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Shape/IR/Shape.h 
b/mlir/include/mlir/Dialect/Shape/IR/Shape.h
index f40d6154544a..eab3c6f67ca0 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/Shape.h
+++ b/mlir/include/mlir/Dialect/Shape/IR/Shape.h
@@ -14,9 +14,11 @@
 #ifndef MLIR_SHAPE_IR_SHAPE_H
 #define MLIR_SHAPE_IR_SHAPE_H
 
+#include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/Dialect.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/IR/OpImplementation.h"
+#include "mlir/IR/SymbolTable.h"
 #include "mlir/Interfaces/ControlFlowInterfaces.h"
 #include "mlir/Interfaces/InferTypeOpInterface.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"

diff  --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td 
b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index a852d900cf69..52768e49001d 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -18,6 +18,7 @@ include "mlir/Interfaces/ControlFlowInterfaces.td"
 include "mlir/Interfaces/InferTypeOpInterface.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 include "mlir/IR/OpAsmInterface.td"
+include "mlir/IR/SymbolInterfaces.td"
 
 
//===--===//
 // Shape op definitions
@@ -492,7 +493,7 @@ def Shape_WithOp : Shape_Op<"with_shape", [NoSideEffect]> {
 }
 
 def Shape_YieldOp : Shape_Op<"yield",
-[HasParent<"ReduceOp">,
+[HasParent<"ReduceOp, FunctionLibraryOp">,
  NoSideEffect,
  ReturnLike,
  Terminator]> {
@@ -780,4 +781,62 @@ def Shape_CstrRequireOp : Shape_Op<"cstr_require", []> {
   let hasFolder = 1;
 }
 
+//===--===//
+// Shape collection ops.
+//===--===//
+
+def Shape_FunctionLibraryOp : Shape_Op<"function_library",
+[AffineScope, IsolatedFromAbove, NoRegionArguments, SymbolTable, Symbol,
+ SingleBlockImplicitTerminator<"ShapeFunctionLibraryTerminatorOp">]> {
+  let summary = "Represents shape functions and corresponding ops";
+  let description = [{
+Represents a list of shape functions and the ops whose shape transfer
+functions they represent.
+
+Example:
+
+```mlir
+shape.function_library {
+  func @same_result_shape(%arg: !shape.value_shape) -> !shape.shape {
+%0 = shape.shape_of %arg : !shape.value_shape -> !shape.shape
+return %0 : !shape.shape
+  }
+} mapping {
+  std.atan = @same_result_shape
+}
+```
+  }];
+
+  let arguments = (ins SymbolNameAttr:$sym_name,
+   OptionalAttr:$sym_visibility);
+  let arguments = (ins DictionaryAttr:$mapping);
+  let regions = (region AnyRegion:$body);
+
+  let extraClassDeclaration = [{
+/// Returns an associated shape function for an operation if defined.
+FuncOp getShapeFunction(Operation *op);
+  }];
+
+  let builders = [OpBuilderDAG<(ins "StringRef":$name)>];
+  let skipDefaultBuilders = 1;
+
+  let printer = [{ ::print(p, *this); }];
+  let parser = [{ return ::parse$cppClass(parser, result); }];
+}
+
+//===--===//
+// ShapeFunctionLibraryTerminatorOp
+//===--===//
+
+de

[llvm-branch-commits] [llvm] 84aad9b - [RISCV] Change predicate on InstAliases for GORCI/GREVI/SHFLI/UNSHFLI to HasStdExtZbp instead of HasStdExtZbbOrZbp.

2020-11-29 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-29T11:23:23-08:00
New Revision: 84aad9b5da96ca2fe47c9db46c3a6b1bb09c070b

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

LOG: [RISCV] Change predicate on InstAliases for GORCI/GREVI/SHFLI/UNSHFLI to 
HasStdExtZbp instead of HasStdExtZbbOrZbp.

This matches the predicate on the instructions. Though I think
some specific encodings are valid in Zbb, but not all of them.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
index af6a367f95fe..3926563f568b 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -452,7 +452,7 @@ def : InstAlias<"zext.h $rd, $rs", (PACKW GPR:$rd, GPR:$rs, 
X0)>;
 def : InstAlias<"zext.w $rd, $rs", (PACK GPR:$rd, GPR:$rs, X0)>;
 } // Predicates = [HasStdExtZbb, IsRV64]
 
-let Predicates = [HasStdExtZbbOrZbp] in {
+let Predicates = [HasStdExtZbp] in {
 def : InstAlias<"rev.p $rd, $rs",  (GREVI GPR:$rd, GPR:$rs, 0b1)>,
   Sched<[]>;
 def : InstAlias<"rev2.n $rd, $rs", (GREVI GPR:$rd, GPR:$rs, 0b00010)>,
@@ -519,9 +519,9 @@ def : InstAlias<"orc2.h $rd, $rs", (GORCI GPR:$rd, GPR:$rs, 
0b01110)>,
   Sched<[]>;
 def : InstAlias<"orc.h $rd, $rs",  (GORCI GPR:$rd, GPR:$rs, 0b0)>,
   Sched<[]>;
-} // Predicates = [HasStdExtZbbOrZbp]
+} // Predicates = [HasStdExtZbp]
 
-let Predicates = [HasStdExtZbbOrZbp, IsRV32] in {
+let Predicates = [HasStdExtZbp, IsRV32] in {
 def : InstAlias<"rev16 $rd, $rs", (GREVI GPR:$rd, GPR:$rs, 0b1)>, 
Sched<[]>;
 def : InstAlias<"rev8 $rd, $rs",  (GREVI GPR:$rd, GPR:$rs, 0b11000)>, 
Sched<[]>;
 def : InstAlias<"rev4 $rd, $rs",  (GREVI GPR:$rd, GPR:$rs, 0b11100)>, 
Sched<[]>;
@@ -550,9 +550,9 @@ def : InstAlias<"orc8 $rd, $rs",  (GORCI GPR:$rd, GPR:$rs, 
0b11000)>, Sched<[]>;
 def : InstAlias<"orc4 $rd, $rs",  (GORCI GPR:$rd, GPR:$rs, 0b11100)>, 
Sched<[]>;
 def : InstAlias<"orc2 $rd, $rs",  (GORCI GPR:$rd, GPR:$rs, 0b0)>, 
Sched<[]>;
 def : InstAlias<"orc $rd, $rs",   (GORCI GPR:$rd, GPR:$rs, 0b1)>, 
Sched<[]>;
-} // Predicates = [HasStdExtZbbOrZbp, IsRV32]
+} // Predicates = [HasStdExtZbp, IsRV32]
 
-let Predicates = [HasStdExtZbbOrZbp, IsRV64] in {
+let Predicates = [HasStdExtZbp, IsRV64] in {
 def : InstAlias<"rev16.w $rd, $rs", (GREVI GPR:$rd, GPR:$rs, 0b01)>,
   Sched<[]>;
 def : InstAlias<"rev8.w $rd, $rs",  (GREVI GPR:$rd, GPR:$rs, 0b011000)>,
@@ -635,7 +635,7 @@ def : InstAlias<"orc2 $rd, $rs",(GORCI GPR:$rd, 
GPR:$rs, 0b10)>,
   Sched<[]>;
 def : InstAlias<"orc $rd, $rs", (GORCI GPR:$rd, GPR:$rs, 0b11)>,
   Sched<[]>;
-} // Predicates = [HasStdExtZbbOrZbp, IsRV64]
+} // Predicates = [HasStdExtZbp, IsRV64]
 
 
//===--===//
 // Compressed Instruction patterns



___
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] 048b16f - [ELF] Check --orphan-handling=place (default value) early

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

Author: Fangrui Song
Date: 2020-11-29T12:36:27-08:00
New Revision: 048b16f7fbb745635b48d31ee957bb8865597606

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

LOG: [ELF] Check --orphan-handling=place (default value) early

The function took 1% (161MiB clang) to 1.7% (an 4.9GiB executable) time.

Added: 


Modified: 
lld/ELF/LinkerScript.cpp

Removed: 




diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index a03e21c55503..5bb977d6882b 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -802,6 +802,8 @@ void LinkerScript::addOrphanSections() {
 
 void LinkerScript::diagnoseOrphanHandling() const {
   llvm::TimeTraceScope timeScope("Diagnose orphan sections");
+  if (config->orphanHandling == OrphanHandlingPolicy::Place)
+return;
   for (const InputSectionBase *sec : orphanSections) {
 // Input SHT_REL[A] retained by --emit-relocs are ignored by
 // computeInputSections(). Don't warn/error.
@@ -812,7 +814,7 @@ void LinkerScript::diagnoseOrphanHandling() const {
 StringRef name = getOutputSectionName(sec);
 if (config->orphanHandling == OrphanHandlingPolicy::Error)
   error(toString(sec) + " is being placed in '" + name + "'");
-else if (config->orphanHandling == OrphanHandlingPolicy::Warn)
+else
   warn(toString(sec) + " is being placed in '" + 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] 891170e - [DL] Optimize address space zero lookup (NFC)

2020-11-29 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-11-29T22:49:55+01:00
New Revision: 891170e8636b312092486dee7c9117db7def8836

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

LOG: [DL] Optimize address space zero lookup (NFC)

Information for pointer size/alignment/etc is queried a lot, but
the binary search based implementation makes this fairly slow.

Add an explicit check for address space zero and skip the search
in that case -- we need to specially handle the zero address space
anyway, as it serves as the fallback for all address spaces that
were not explicitly defined.

I initially wanted to simply replace the binary search with a
linear search, which would handle both address space zero and the
general case efficiently, but I was not sure whether there are
any degenerate targets that use more than a handful of declared
address spaces (in-tree, even AMDGPU only declares six).

Added: 


Modified: 
llvm/include/llvm/IR/DataLayout.h
llvm/lib/IR/DataLayout.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/DataLayout.h 
b/llvm/include/llvm/IR/DataLayout.h
index bf273038c51e..4dbca660d07b 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -161,12 +161,7 @@ class DataLayout {
   using PointersTy = SmallVector;
   PointersTy Pointers;
 
-  PointersTy::const_iterator
-  findPointerLowerBound(uint32_t AddressSpace) const {
-return const_cast(this)->findPointerLowerBound(AddressSpace);
-  }
-
-  PointersTy::iterator findPointerLowerBound(uint32_t AddressSpace);
+  const PointerAlignElem &getPointerAlignElem(uint32_t AddressSpace) const;
 
   // The StructType -> StructLayout map.
   mutable void *LayoutMap = nullptr;

diff  --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 66ae982e5120..3c9325a45395 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -582,12 +582,19 @@ Error DataLayout::setAlignment(AlignTypeEnum align_type, 
Align abi_align,
   return Error::success();
 }
 
-DataLayout::PointersTy::iterator
-DataLayout::findPointerLowerBound(uint32_t AddressSpace) {
-  return std::lower_bound(Pointers.begin(), Pointers.end(), AddressSpace,
-  [](const PointerAlignElem &A, uint32_t AddressSpace) 
{
-return A.AddressSpace < AddressSpace;
-  });
+const PointerAlignElem &
+DataLayout::getPointerAlignElem(uint32_t AddressSpace) const {
+  if (AddressSpace != 0) {
+auto I = lower_bound(Pointers, AddressSpace,
+ [](const PointerAlignElem &A, uint32_t AddressSpace) {
+  return A.AddressSpace < AddressSpace;
+});
+if (I != Pointers.end() && I->AddressSpace == AddressSpace)
+  return *I;
+  }
+
+  assert(Pointers[0].AddressSpace == 0);
+  return Pointers[0];
 }
 
 Error DataLayout::setPointerAlignment(uint32_t AddrSpace, Align ABIAlign,
@@ -597,7 +604,10 @@ Error DataLayout::setPointerAlignment(uint32_t AddrSpace, 
Align ABIAlign,
 return reportError(
 "Preferred alignment cannot be less than the ABI alignment");
 
-  PointersTy::iterator I = findPointerLowerBound(AddrSpace);
+  auto I = lower_bound(Pointers, AddrSpace,
+   [](const PointerAlignElem &A, uint32_t AddressSpace) {
+return A.AddressSpace < AddressSpace;
+  });
   if (I == Pointers.end() || I->AddressSpace != AddrSpace) {
 Pointers.insert(I, PointerAlignElem::get(AddrSpace, ABIAlign, PrefAlign,
  TypeByteWidth, IndexWidth));
@@ -712,30 +722,15 @@ const StructLayout 
*DataLayout::getStructLayout(StructType *Ty) const {
 }
 
 Align DataLayout::getPointerABIAlignment(unsigned AS) const {
-  PointersTy::const_iterator I = findPointerLowerBound(AS);
-  if (I == Pointers.end() || I->AddressSpace != AS) {
-I = findPointerLowerBound(0);
-assert(I->AddressSpace == 0);
-  }
-  return I->ABIAlign;
+  return getPointerAlignElem(AS).ABIAlign;
 }
 
 Align DataLayout::getPointerPrefAlignment(unsigned AS) const {
-  PointersTy::const_iterator I = findPointerLowerBound(AS);
-  if (I == Pointers.end() || I->AddressSpace != AS) {
-I = findPointerLowerBound(0);
-assert(I->AddressSpace == 0);
-  }
-  return I->PrefAlign;
+  return getPointerAlignElem(AS).PrefAlign;
 }
 
 unsigned DataLayout::getPointerSize(unsigned AS) const {
-  PointersTy::const_iterator I = findPointerLowerBound(AS);
-  if (I == Pointers.end() || I->AddressSpace != AS) {
-I = findPointerLowerBound(0);
-assert(I->AddressSpace == 0);
-  }
-  return I->TypeByteWidth;
+  return getPointerAlignElem(AS).TypeByteWidth;
 }
 
 unsigned DataLayout::getMaxPointerSize() const {
@@ -754,12 +749,7 @@ unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) 
const {
 }
 
 unsigned DataLayout::getIndexSize(unsigned AS) const {
-  PointersTy::c

[llvm-branch-commits] [lld] dfcf1ac - [ELF] Improve 2 SmallVector<*, N> usage

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

Author: Fangrui Song
Date: 2020-11-29T14:01:32-08:00
New Revision: dfcf1acf13226be0f599a7ab6b395b66dc9545d6

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

LOG: [ELF] Improve 2 SmallVector<*, N> usage

For --gc-sections, SmallVector -> SmallVector because the code bloat (1296 bytes) is not worthwhile (the saved 
reallocation is negligible).
For OutputSection::compressedData, N=1 is useless (for a compressed .debug_*, 
the size is always larger than 1).

Added: 


Modified: 
lld/ELF/MarkLive.cpp
lld/ELF/OutputSections.h

Removed: 




diff  --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index 2c350e275e6c..35220e168df3 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -65,7 +65,7 @@ template  class MarkLive {
   unsigned partition;
 
   // A list of sections to visit.
-  SmallVector queue;
+  SmallVector queue;
 
   // There are normally few input sections whose names are valid C
   // identifiers, so we just store a std::vector instead of a multimap.

diff  --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index d5686f11ec8e..39bf48c091ca 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -111,7 +111,7 @@ class OutputSection final : public BaseCommand, public 
SectionBase {
 private:
   // Used for implementation of --compress-debug-sections option.
   std::vector zDebugHeader;
-  llvm::SmallVector compressedData;
+  llvm::SmallVector compressedData;
 
   std::array getFiller();
 };



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


[llvm-branch-commits] [clang-tools-extra] f15b786 - [clang-tidy] [clangd] Avoid multi-line diagnostic range for else-after-return diagnostic

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

Author: Nathan Ridge
Date: 2020-11-29T18:32:23-05:00
New Revision: f15b7869e5afbd6c24ef440b0b62593e80fbd24f

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

LOG: [clang-tidy] [clangd] Avoid multi-line diagnostic range for 
else-after-return diagnostic

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

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index 79e3cded45bc..89bb02e78cc6 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -267,7 +267,8 @@ void ElseAfterReturnCheck::check(const 
MatchFinder::MatchResult &Result) {
   // If the if statement is the last statement its enclosing statements
   // scope, we can pull the decl out of the if statement.
   DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage)
-   << ControlFlowInterruptor;
+   << ControlFlowInterruptor
+   << SourceRange(ElseLoc);
   if (checkInitDeclUsageInElse(If) != nullptr) {
 Diag << tooling::fixit::createReplacement(
 SourceRange(If->getIfLoc()),
@@ -302,7 +303,8 @@ void ElseAfterReturnCheck::check(const 
MatchFinder::MatchResult &Result) {
   // If the if statement is the last statement its enclosing statements
   // scope, we can pull the decl out of the if statement.
   DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage)
-   << ControlFlowInterruptor;
+   << ControlFlowInterruptor
+   << SourceRange(ElseLoc);
   Diag << tooling::fixit::createReplacement(
   SourceRange(If->getIfLoc()),
   (tooling::fixit::getText(*If->getInit(), *Result.Context) +
@@ -319,7 +321,7 @@ void ElseAfterReturnCheck::check(const 
MatchFinder::MatchResult &Result) {
   }
 
   DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage)
-   << ControlFlowInterruptor;
+   << ControlFlowInterruptor << SourceRange(ElseLoc);
   removeElseAndBrackets(Diag, *Result.Context, Else, ElseLoc);
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index ba7029e54dbb..c6a14aeeb469 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -474,6 +474,24 @@ TEST(DiagnosticTest, ClangTidyNoLiteralDataInMacroToken) {
   EXPECT_THAT(TU.build().getDiagnostics(), UnorderedElementsAre()); // no-crash
 }
 
+TEST(DiagnosticTest, ElseAfterReturnRange) {
+  Annotations Main(R"cpp(
+int foo(int cond) {
+if (cond == 1) {
+  return 42;
+} [[else]] if (cond == 2) {
+  return 43;
+}
+return 44;
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.ClangTidyProvider = addTidyChecks("llvm-else-after-return");
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(Diag(Main.range(), "do not use 'else' after 'return'")));
+}
+
 TEST(DiagnosticsTest, Preprocessor) {
   // This looks like a preamble, but there's an #else in the middle!
   // Check that:



___
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] 8b6bea9 - Use bool in place of int for boolean things in the C API

2020-11-29 Thread via llvm-branch-commits

Author: George
Date: 2020-11-29T16:40:57-08:00
New Revision: 8b6bea9bff80a80d3cdbceb6d2218e6bac819696

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

LOG: Use bool in place of int for boolean things in the C API

`bool` is pretty well supported by now in C, and using it in place of `int` is 
not only more semantically accurate, but also improves automatic bindings for 
languages like Swift.

There is more discussion here: 
https://llvm.discourse.group/t/adding-mlirbool-to-c-bindings/2280/5

Reviewed By: ftynse, mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir-c/IR.h
mlir/lib/CAPI/IR/IR.cpp

Removed: 




diff  --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index 2ca5b80b825a..902b2b988622 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -18,6 +18,7 @@
 #ifndef MLIR_C_IR_H
 #define MLIR_C_IR_H
 
+#include 
 #include 
 
 #include "mlir-c/Support.h"
@@ -82,10 +83,10 @@ typedef struct MlirNamedAttribute MlirNamedAttribute;
 MLIR_CAPI_EXPORTED MlirContext mlirContextCreate();
 
 /// Checks if two contexts are equal.
-MLIR_CAPI_EXPORTED int mlirContextEqual(MlirContext ctx1, MlirContext ctx2);
+MLIR_CAPI_EXPORTED bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2);
 
 /// Checks whether a context is null.
-static inline int mlirContextIsNull(MlirContext context) {
+static inline bool mlirContextIsNull(MlirContext context) {
   return !context.ptr;
 }
 
@@ -126,14 +127,14 @@ MLIR_CAPI_EXPORTED MlirDialect 
mlirContextGetOrLoadDialect(MlirContext context,
 MLIR_CAPI_EXPORTED MlirContext mlirDialectGetContext(MlirDialect dialect);
 
 /// Checks if the dialect is null.
-static inline int mlirDialectIsNull(MlirDialect dialect) {
+static inline bool mlirDialectIsNull(MlirDialect dialect) {
   return !dialect.ptr;
 }
 
 /** Checks if two dialects that belong to the same context are equal. Dialects
  * from 
diff erent contexts will not compare equal. */
-MLIR_CAPI_EXPORTED int mlirDialectEqual(MlirDialect dialect1,
-MlirDialect dialect2);
+MLIR_CAPI_EXPORTED bool mlirDialectEqual(MlirDialect dialect1,
+ MlirDialect dialect2);
 
 /// Returns the namespace of the given dialect.
 MLIR_CAPI_EXPORTED MlirStringRef mlirDialectGetNamespace(MlirDialect dialect);
@@ -177,7 +178,7 @@ MLIR_CAPI_EXPORTED MlirContext 
mlirModuleGetContext(MlirModule module);
 MLIR_CAPI_EXPORTED MlirBlock mlirModuleGetBody(MlirModule module);
 
 /// Checks whether a module is null.
-static inline int mlirModuleIsNull(MlirModule module) { return !module.ptr; }
+static inline bool mlirModuleIsNull(MlirModule module) { return !module.ptr; }
 
 /// Takes a module owned by the caller and deletes it.
 MLIR_CAPI_EXPORTED void mlirModuleDestroy(MlirModule module);
@@ -287,12 +288,12 @@ mlirOperationCreate(const MlirOperationState *state);
 MLIR_CAPI_EXPORTED void mlirOperationDestroy(MlirOperation op);
 
 /// Checks whether the underlying operation is null.
-static inline int mlirOperationIsNull(MlirOperation op) { return !op.ptr; }
+static inline bool mlirOperationIsNull(MlirOperation op) { return !op.ptr; }
 
 /** Checks whether two operation handles point to the same operation. This does
  * not perform deep comparison. */
-MLIR_CAPI_EXPORTED int mlirOperationEqual(MlirOperation op,
-  MlirOperation other);
+MLIR_CAPI_EXPORTED bool mlirOperationEqual(MlirOperation op,
+   MlirOperation other);
 
 /// Gets the name of the operation as an identifier.
 MLIR_CAPI_EXPORTED MlirIdentifier mlirOperationGetName(MlirOperation op);
@@ -388,7 +389,7 @@ MLIR_CAPI_EXPORTED MlirRegion mlirRegionCreate();
 MLIR_CAPI_EXPORTED void mlirRegionDestroy(MlirRegion region);
 
 /// Checks whether a region is null.
-static inline int mlirRegionIsNull(MlirRegion region) { return !region.ptr; }
+static inline bool mlirRegionIsNull(MlirRegion region) { return !region.ptr; }
 
 /// Gets the first block in the region.
 MLIR_CAPI_EXPORTED MlirBlock mlirRegionGetFirstBlock(MlirRegion region);
@@ -430,11 +431,11 @@ MLIR_CAPI_EXPORTED MlirBlock mlirBlockCreate(intptr_t 
nArgs,
 MLIR_CAPI_EXPORTED void mlirBlockDestroy(MlirBlock block);
 
 /// Checks whether a block is null.
-static inline int mlirBlockIsNull(MlirBlock block) { return !block.ptr; }
+static inline bool mlirBlockIsNull(MlirBlock block) { return !block.ptr; }
 
 /** Checks whether two blocks handles point to the same block. This does not
  * perform deep comparison. */
-MLIR_CAPI_EXPORTED int mlirBlockEqual(MlirBlock block, MlirBlock other);
+MLIR_CAPI_EXPORTED bool mlirBlockEqual(MlirBlock block, MlirBlock other);
 
 /** Returns the

[llvm-branch-commits] [llvm] e6c1777 - [MC] Copy visibility for .symver created symbols

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

Author: Fangrui Song
Date: 2020-11-29T16:51:48-08:00
New Revision: e6c17776858d9ec5c2ce15447b384da2141bbbad

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

LOG: [MC] Copy visibility for .symver created symbols

Added: 
llvm/test/MC/ELF/symver-visibility.s

Modified: 
llvm/lib/MC/ELFObjectWriter.cpp

Removed: 




diff  --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 494f82558d82..10c61fc8b453 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1280,6 +1280,7 @@ void 
ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
 // This is the first place we are able to copy this information.
 Alias->setExternal(Symbol.isExternal());
 Alias->setBinding(Symbol.getBinding());
+Alias->setVisibility(Symbol.getVisibility());
 Alias->setOther(Symbol.getOther());
 
 if (!Symbol.isUndefined() && !Rest.startswith("@@@"))

diff  --git a/llvm/test/MC/ELF/symver-visibility.s 
b/llvm/test/MC/ELF/symver-visibility.s
new file mode 100644
index ..92d1da9cdef1
--- /dev/null
+++ b/llvm/test/MC/ELF/symver-visibility.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
+# RUN: llvm-readelf -s %t | FileCheck %s
+
+# CHECK:  NOTYPE GLOBAL HIDDEN{{[1-9]}} def@@v1
+# CHECK-NEXT: NOTYPE GLOBAL PROTECTED UND   undef@v1
+
+.protected undef
+.symver undef, undef@@@v1
+call undef
+
+.globl def
+.hidden def
+.symver def, def@@@v1
+def:



___
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] bd2083c - [mlir][Python] Python API cleanups and additions found during code audit.

2020-11-29 Thread Stella Laurenzo via llvm-branch-commits

Author: Stella Laurenzo
Date: 2020-11-29T18:09:07-08:00
New Revision: bd2083c2fa7bb8769ca997a0303da54432e08519

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

LOG: [mlir][Python] Python API cleanups and additions found during code audit.

* Add capsule get/create for Attribute and Type, which already had capsule 
interop defined.
* Add capsule interop and get/create for Location.
* Add Location __eq__.
* Use get() and implicit cast to go from PyAttribute, PyType, PyLocation to 
MlirAttribute, MlirType, MlirLocation (bundled with this change because I 
didn't want to continue the pattern one more time).

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

Added: 


Modified: 
mlir/include/mlir-c/Bindings/Python/Interop.h
mlir/include/mlir-c/IR.h
mlir/lib/Bindings/Python/IRModules.cpp
mlir/lib/Bindings/Python/IRModules.h
mlir/lib/Bindings/Python/PybindUtils.h
mlir/lib/CAPI/IR/IR.cpp
mlir/test/Bindings/Python/ir_attributes.py
mlir/test/Bindings/Python/ir_location.py
mlir/test/Bindings/Python/ir_types.py

Removed: 




diff  --git a/mlir/include/mlir-c/Bindings/Python/Interop.h 
b/mlir/include/mlir-c/Bindings/Python/Interop.h
index 05519d804e31..31265edfb550 100644
--- a/mlir/include/mlir-c/Bindings/Python/Interop.h
+++ b/mlir/include/mlir-c/Bindings/Python/Interop.h
@@ -28,6 +28,7 @@
 
 #define MLIR_PYTHON_CAPSULE_ATTRIBUTE "mlir.ir.Attribute._CAPIPtr"
 #define MLIR_PYTHON_CAPSULE_CONTEXT "mlir.ir.Context._CAPIPtr"
+#define MLIR_PYTHON_CAPSULE_LOCATION "mlir.ir.Location._CAPIPtr"
 #define MLIR_PYTHON_CAPSULE_MODULE "mlir.ir.Module._CAPIPtr"
 #define MLIR_PYTHON_CAPSULE_OPERATION "mlir.ir.Operation._CAPIPtr"
 #define MLIR_PYTHON_CAPSULE_TYPE "mlir.ir.Type._CAPIPtr"
@@ -106,6 +107,24 @@ static inline MlirContext 
mlirPythonCapsuleToContext(PyObject *capsule) {
   return context;
 }
 
+/** Creates a capsule object encapsulating the raw C-API MlirLocation.
+ * The returned capsule does not extend or affect ownership of any Python
+ * objects that reference the location in any way. */
+static inline PyObject *mlirPythonLocationToCapsule(MlirLocation loc) {
+  return PyCapsule_New(MLIR_PYTHON_GET_WRAPPED_POINTER(loc),
+   MLIR_PYTHON_CAPSULE_LOCATION, NULL);
+}
+
+/** Extracts an MlirLocation from a capsule as produced from
+ * mlirPythonLocationToCapsule. If the capsule is not of the right type, then
+ * a null module is returned (as checked via mlirLocationIsNull). In such a
+ * case, the Python APIs will have already set an error. */
+static inline MlirLocation mlirPythonCapsuleToLocation(PyObject *capsule) {
+  void *ptr = PyCapsule_GetPointer(capsule, MLIR_PYTHON_CAPSULE_LOCATION);
+  MlirLocation loc = {ptr};
+  return loc;
+}
+
 /** Creates a capsule object encapsulating the raw C-API MlirModule.
  * The returned capsule does not extend or affect ownership of any Python
  * objects that reference the module in any way. */

diff  --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index 902b2b988622..e3bfe76560f1 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -153,6 +153,14 @@ MLIR_CAPI_EXPORTED MlirLocation 
mlirLocationUnknownGet(MlirContext context);
 /// Gets the context that a location was created with.
 MLIR_CAPI_EXPORTED MlirContext mlirLocationGetContext(MlirLocation location);
 
+/// Checks if the location is null.
+static inline int mlirLocationIsNull(MlirLocation location) {
+  return !location.ptr;
+}
+
+/// Checks if two locations are equal.
+MLIR_CAPI_EXPORTED int mlirLocationEqual(MlirLocation l1, MlirLocation l2);
+
 /** Prints a location by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */

diff  --git a/mlir/lib/Bindings/Python/IRModules.cpp 
b/mlir/lib/Bindings/Python/IRModules.cpp
index e145a58d0d27..d34fe998583f 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -289,7 +289,7 @@ class PyBlockList {
 llvm::SmallVector argTypes;
 argTypes.reserve(pyArgTypes.size());
 for (auto &pyArg : pyArgTypes) {
-  argTypes.push_back(pyArg.cast().type);
+  argTypes.push_back(pyArg.cast());
 }
 
 MlirBlock block = mlirBlockCreate(argTypes.size(), argTypes.data());
@@ -640,6 +640,18 @@ MlirDialect PyDialects::getDialectForKey(const std::string 
&key,
 // PyLocation
 
//--
 
+py::object PyLocation::getCapsule() {
+  return py::reinterpret_steal(mlirPythonLocationToCapsule(*this));
+}
+
+PyLocation PyLocation::createFromCapsule(py::object capsule) {
+  MlirLocation rawLoc = mlirPythonCapsuleToLocation(capsu

[llvm-branch-commits] [mlir] ba0fe76 - [mlir][Python] Add an Operation.result property.

2020-11-29 Thread Stella Laurenzo via llvm-branch-commits

Author: Stella Laurenzo
Date: 2020-11-29T18:09:07-08:00
New Revision: ba0fe76b7eb87f91499931e76317ddd1cb493aa1

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

LOG: [mlir][Python] Add an Operation.result property.

* If ODS redefines this, it is fine, but I have found this accessor to be 
universally useful in the old npcomp bindings and I'm closing gaps that will 
let me switch.

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

Added: 


Modified: 
mlir/lib/Bindings/Python/IRModules.cpp
mlir/lib/Bindings/Python/IRModules.h
mlir/test/Bindings/Python/ir_operation.py

Removed: 




diff  --git a/mlir/lib/Bindings/Python/IRModules.cpp 
b/mlir/lib/Bindings/Python/IRModules.cpp
index d34fe998583f..d270e44debae 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -23,6 +23,8 @@ using namespace mlir;
 using namespace mlir::python;
 
 using llvm::SmallVector;
+using llvm::StringRef;
+using llvm::Twine;
 
 
//--
 // Docstrings (trivial, non-duplicated docstrings are included inline).
@@ -631,7 +633,7 @@ MlirDialect PyDialects::getDialectForKey(const std::string 
&key,
   getContext()->get(), {canonKey->data(), canonKey->size()});
   if (mlirDialectIsNull(dialect)) {
 throw SetPyError(attrError ? PyExc_AttributeError : PyExc_IndexError,
- llvm::Twine("Dialect '") + key + "' not found");
+ Twine("Dialect '") + key + "' not found");
   }
   return dialect;
 }
@@ -793,7 +795,7 @@ PyOperationRef PyOperation::createDetached(PyMlirContextRef 
contextRef,
   return created;
 }
 
-void PyOperation::checkValid() {
+void PyOperation::checkValid() const {
   if (!valid) {
 throw SetPyError(PyExc_RuntimeError, "the operation has been invalidated");
   }
@@ -817,7 +819,7 @@ void PyOperationBase::print(py::object fileObject, bool 
binary,
 
   PyFileAccumulator accum(fileObject, binary);
   py::gil_scoped_release();
-  mlirOperationPrintWithFlags(operation.get(), flags, accum.getCallback(),
+  mlirOperationPrintWithFlags(operation, flags, accum.getCallback(),
   accum.getUserData());
   mlirOpPrintingFlagsDestroy(flags);
 }
@@ -975,7 +977,7 @@ py::object PyOperation::createOpView() {
   MlirIdentifier ident = mlirOperationGetName(get());
   MlirStringRef identStr = mlirIdentifierStr(ident);
   auto opViewClass = PyGlobals::get().lookupRawOpViewClass(
-  llvm::StringRef(identStr.data, identStr.length));
+  StringRef(identStr.data, identStr.length));
   if (opViewClass)
 return (*opViewClass)(getRef().getObject());
   return py::cast(PyOpView(getRef().getObject()));
@@ -1044,7 +1046,7 @@ void PyInsertionPoint::insert(PyOperationBase 
&operationBase) {
 (*refOperation)->checkValid();
 beforeOp = (*refOperation)->get();
   }
-  mlirBlockInsertOwnedOperationBefore(block.get(), beforeOp, operation.get());
+  mlirBlockInsertOwnedOperationBefore(block.get(), beforeOp, operation);
   operation.setAttached();
 }
 
@@ -1158,7 +1160,7 @@ class PyConcreteValue : public PyValue {
   static MlirValue castFrom(PyValue &orig) {
 if (!DerivedTy::isaFunction(orig.get())) {
   auto origRepr = py::repr(py::cast(orig)).cast();
-  throw SetPyError(PyExc_ValueError, llvm::Twine("Cannot cast value to ") +
+  throw SetPyError(PyExc_ValueError, Twine("Cannot cast value to ") +
  DerivedTy::pyClassName +
  " (from " + origRepr + ")");
 }
@@ -1416,9 +1418,9 @@ class PyConcreteAttribute : public BaseTy {
   static MlirAttribute castFrom(PyAttribute &orig) {
 if (!DerivedTy::isaFunction(orig)) {
   auto origRepr = py::repr(py::cast(orig)).cast();
-  throw SetPyError(PyExc_ValueError,
-   llvm::Twine("Cannot cast attribute to ") +
-   DerivedTy::pyClassName + " (from " + origRepr + 
")");
+  throw SetPyError(PyExc_ValueError, Twine("Cannot cast attribute to ") +
+ DerivedTy::pyClassName +
+ " (from " + origRepr + ")");
 }
 return orig;
   }
@@ -1449,7 +1451,7 @@ class PyFloatAttribute : public 
PyConcreteAttribute {
   // in C API.
   if (mlirAttributeIsNull(attr)) {
 throw SetPyError(PyExc_ValueError,
- llvm::Twine("invalid '") +
+ Twine("invalid '") +
  py::repr(py::cast(type)).cast() +
  "' and expected floating point type.");
   }
@@ -1943,7 +1945,7 @@ class PyConcreteType : public 

[llvm-branch-commits] [llvm] e6db141 - [RISCV] Remove unused Addend parameter from classifySymbolRef. NFC

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

Author: Fangrui Song
Date: 2020-11-29T19:17:59-08:00
New Revision: e6db1416aebf44bdd33a5aab4db1fec58af79590

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

LOG: [RISCV] Remove unused Addend parameter from classifySymbolRef. NFC

It is confusing as well since in the case of A - B + Cst, the returned Addend 
is not Cst.

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 22ef0829a7ef..cb94d05d9dd4 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -215,8 +215,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
   };
 
   static bool classifySymbolRef(const MCExpr *Expr,
-RISCVMCExpr::VariantKind &Kind,
-int64_t &Addend);
+RISCVMCExpr::VariantKind &Kind);
 
   RISCVAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser,
  const MCInstrInfo &MII, const MCTargetOptions &Options)
@@ -381,7 +380,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
 bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
 bool IsValid;
 if (!IsConstantImm)
-  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
+  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK);
 else
   IsValid = isShiftedInt(Imm);
 return IsValid && VK == RISCVMCExpr::VK_RISCV_None;
@@ -395,7 +394,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
 // Must be of 'immediate' type but not a constant.
 if (!isImm() || evaluateConstantImm(getImm(), Imm, VK))
   return false;
-return RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm) &&
+return RISCVAsmParser::classifySymbolRef(getImm(), VK) &&
VK == RISCVMCExpr::VK_RISCV_None;
   }
 
@@ -405,7 +404,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
 // Must be of 'immediate' type but not a constant.
 if (!isImm() || evaluateConstantImm(getImm(), Imm, VK))
   return false;
-return RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm) &&
+return RISCVAsmParser::classifySymbolRef(getImm(), VK) &&
(VK == RISCVMCExpr::VK_RISCV_CALL ||
 VK == RISCVMCExpr::VK_RISCV_CALL_PLT);
   }
@@ -416,7 +415,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
 // Must be of 'immediate' type but not a constant.
 if (!isImm() || evaluateConstantImm(getImm(), Imm, VK))
   return false;
-return RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm) &&
+return RISCVAsmParser::classifySymbolRef(getImm(), VK) &&
VK == RISCVMCExpr::VK_RISCV_CALL;
   }
 
@@ -426,7 +425,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
 // Must be of 'immediate' type but not a constant.
 if (!isImm() || evaluateConstantImm(getImm(), Imm, VK))
   return false;
-return RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm) &&
+return RISCVAsmParser::classifySymbolRef(getImm(), VK) &&
VK == RISCVMCExpr::VK_RISCV_TPREL_ADD;
   }
 
@@ -641,7 +640,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
   return false;
 bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
 if (!IsConstantImm)
-  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
+  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK);
 else
   IsValid = isInt<12>(Imm);
 return IsValid && ((IsConstantImm && VK == RISCVMCExpr::VK_RISCV_None) ||
@@ -672,7 +671,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
   return false;
 bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
 if (!IsConstantImm) {
-  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
+  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK);
   return IsValid && (VK == RISCVMCExpr::VK_RISCV_HI ||
  VK == RISCVMCExpr::VK_RISCV_TPREL_HI);
 } else {
@@ -690,7 +689,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
   return false;
 bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
 if (!IsConstantImm) {
-  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
+  IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK);
   return IsValid && (VK == RISCVMCExpr::VK_RISCV_PCREL_HI ||
  VK == RISCVMCExpr::VK_RISCV_GOT_HI ||
  VK == RISCVMCExpr::VK_RISCV_TLS_GOT_HI ||
@@ -1849,10 +1848,8 @@ bool 
RISCVAsmParser::ParseInstruction(ParseInstructionInfo &Info,
 }
 
 bool RISCVAsmParser::classifySymbolRef(const MCExpr *Expr,
- 

[llvm-branch-commits] [clang] 1db60c1 - Remove redundant check for access in the conversion from the naming

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

Author: Richard Smith
Date: 2020-11-29T19:21:59-08:00
New Revision: 1db60c1307ac2e24796047c39d09bf400c22e531

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

LOG: Remove redundant check for access in the conversion from the naming
class to the declaring class in a class member access.

This check does not appear to be backed by any rule in the standard (the
rule in question was likely removed over the years), and only ever
produces duplicate diagnostics. (It's also not meaningful because there
isn't a unique declaring class after the resolution of core issue 39.)

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/CXX/class.access/class.access.base/p1.cpp
clang/test/CXX/class.access/class.access.base/p5.cpp
clang/test/CXX/class.access/class.friend/p1.cpp
clang/test/CXX/class.access/class.protected/p1.cpp
clang/test/CXX/class.access/p4.cpp
clang/test/CXX/drs/dr0xx.cpp
clang/test/CXX/drs/dr1xx.cpp
clang/test/CXX/drs/dr2xx.cpp
clang/test/CXX/drs/dr3xx.cpp
clang/test/SemaCXX/anonymous-union.cpp
clang/test/SemaCXX/conversion-function.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d25d91223826..88dab26f2e3b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2818,21 +2818,24 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
 
 /// Cast a base object to a member's actual type.
 ///
-/// Logically this happens in three phases:
+/// There are two relevant checks:
 ///
-/// * First we cast from the base type to the naming class.
-///   The naming class is the class into which we were looking
-///   when we found the member;  it's the qualifier type if a
-///   qualifier was provided, and otherwise it's the base type.
+/// C++ [class.access.base]p7:
 ///
-/// * Next we cast from the naming class to the declaring class.
-///   If the member we found was brought into a class's scope by
-///   a using declaration, this is that class;  otherwise it's
-///   the class declaring the member.
+///   If a class member access operator [...] is used to access a non-static
+///   data member or non-static member function, the reference is ill-formed if
+///   the left operand [...] cannot be implicitly converted to a pointer to the
+///   naming class of the right operand.
 ///
-/// * Finally we cast from the declaring class to the "true"
-///   declaring class of the member.  This conversion does not
-///   obey access control.
+/// C++ [expr.ref]p7:
+///
+///   If E2 is a non-static data member or a non-static member function, the
+///   program is ill-formed if the class of which E2 is directly a member is an
+///   ambiguous base (11.8) of the naming class (11.9.3) of E2.
+///
+/// Note that the latter check does not consider access; the access of the
+/// "real" base class is checked as appropriate when checking the access of the
+/// member name.
 ExprResult
 Sema::PerformObjectMemberConversion(Expr *From,
 NestedNameSpecifier *Qualifier,
@@ -2956,45 +2959,10 @@ Sema::PerformObjectMemberConversion(Expr *From,
 }
   }
 
-  bool IgnoreAccess = false;
-
-  // If we actually found the member through a using declaration, cast
-  // down to the using declaration's type.
-  //
-  // Pointer equality is fine here because only one declaration of a
-  // class ever has member declarations.
-  if (FoundDecl->getDeclContext() != Member->getDeclContext()) {
-assert(isa(FoundDecl));
-QualType URecordType = Context.getTypeDeclType(
-   cast(FoundDecl->getDeclContext()));
-
-// We only need to do this if the naming-class to declaring-class
-// conversion is non-trivial.
-if (!Context.hasSameUnqualifiedType(FromRecordType, URecordType)) {
-  assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
-  CXXCastPath BasePath;
-  if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
-   FromLoc, FromRange, &BasePath))
-return ExprError();
-
-  QualType UType = URecordType;
-  if (PointerConversions)
-UType = Context.getPointerType(UType);
-  From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
-   VK, &BasePath).get();
-  FromType = UType;
-  FromRecordType = URecordType;
-}
-
-// We don't do access control for the conversion from the
-// declaring class to the true declaring class.
-IgnoreAccess = true;
-  }
-
   CXXCastPath BasePath;
   if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
FromLoc, FromRange, &BasePath,
-   IgnoreAccess))
+   

[llvm-branch-commits] [llvm] 0c9c6dd - [IndVars] ICmpInst should not prevent IV widening

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

Author: Max Kazantsev
Date: 2020-11-30T10:51:31+07:00
New Revision: 0c9c6ddf17bb01ae350a899b3395bb078aa0c62e

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

LOG: [IndVars] ICmpInst should not prevent IV widening

If we decided to widen IV with zext, then unsigned comparisons
should not prevent widening (same for sext/sign comparisons).
The result of comparison in wider type does not change in this case.

Differential Revision: https://reviews.llvm.org/D92207
Reviewed By: nikic

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp 
b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index d37fe74a0039..e281c66a4267 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1541,10 +1541,14 @@ bool 
WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
   bool CanZeroExtend = ExtKind == ZeroExtended && OBO->hasNoUnsignedWrap();
   auto AnotherOpExtKind = ExtKind;
 
-  // Check that all uses are either s/zext, or narrow def (in case of we are
-  // widening the IV increment), or single-input LCSSA Phis.
+  // Check that all uses are either:
+  // - narrow def (in case of we are widening the IV increment);
+  // - single-input LCSSA Phis;
+  // - comparison of the chosen type;
+  // - extend of the chosen type (raison d'etre).
   SmallVector ExtUsers;
   SmallVector LCSSAPhiUsers;
+  SmallVector ICmpUsers;
   for (Use &U : NarrowUse->uses()) {
 Instruction *User = cast(U.getUser());
 if (User == NarrowDef)
@@ -1558,6 +1562,19 @@ bool 
WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
   LCSSAPhiUsers.push_back(LCSSAPhi);
   continue;
 }
+if (auto *ICmp = dyn_cast(User)) {
+  auto Pred = ICmp->getPredicate();
+  // We have 3 types of predicates: signed, unsigned and equality
+  // predicates. For equality, it's legal to widen icmp for either sign and
+  // zero extend. For sign extend, we can also do so for signed predicates,
+  // likeweise for zero extend we can widen icmp for unsigned predicates.
+  if (ExtKind == ZeroExtended && ICmpInst::isSigned(Pred))
+return false;
+  if (ExtKind == SignExtended && ICmpInst::isUnsigned(Pred))
+return false;
+  ICmpUsers.push_back(ICmp);
+  continue;
+}
 if (ExtKind == SignExtended)
   User = dyn_cast(User);
 else
@@ -1655,6 +1672,26 @@ bool 
WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
 User->replaceAllUsesWith(TruncPN);
 DeadInsts.emplace_back(User);
   }
+
+  for (ICmpInst *User : ICmpUsers) {
+Builder.SetInsertPoint(User);
+auto ExtendedOp = [&](Value * V)->Value * {
+  if (V == NarrowUse)
+return WideBO;
+  if (ExtKind == ZeroExtended)
+return Builder.CreateZExt(V, WideBO->getType());
+  else
+return Builder.CreateSExt(V, WideBO->getType());
+};
+auto Pred = User->getPredicate();
+auto *LHS = ExtendedOp(User->getOperand(0));
+auto *RHS = ExtendedOp(User->getOperand(1));
+auto *WideCmp =
+Builder.CreateICmp(Pred, LHS, RHS, User->getName() + ".wide");
+User->replaceAllUsesWith(WideCmp);
+DeadInsts.emplace_back(User);
+  }
+
   return true;
 }
 

diff  --git a/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll 
b/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
index dd095c008772..d3b117e73602 100644
--- a/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
+++ b/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
@@ -795,37 +795,36 @@ failure:
   unreachable
 }
 
-; TODO: We can widen here despite the icmp user of %foo in guarded block.
 define i32 @test16_unsigned_pos1(i32 %start, i32* %p, i32* %q, i32 %x) {
 ; CHECK-LABEL: @test16_unsigned_pos1(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TMP0:%.*]] = zext i32 [[START:%.*]] to i64
-; CHECK-NEXT:[[TMP1:%.*]] = add i32 [[START]], -1
+; CHECK-NEXT:[[TMP1:%.*]] = add nsw i64 [[TMP0]], -1
+; CHECK-NEXT:[[TMP2:%.*]] = zext i32 [[X:%.*]] to i64
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], 
[[BACKEDGE:%.*]] ], [ [[TMP0]], [[ENTRY:%.*]] ]
 ; CHECK-NEXT:[[COND:%.*]] = icmp eq i64 [[INDVARS_IV]], 0
-; CHECK-NEXT:[[TMP2:%.*]] = trunc i64 [[INDVARS_IV]] to i32
-; CHECK-NEXT:[[FOO:%.*]] = add i32 [[TMP2]], -1
+; CHECK-NEXT:[[TMP3:%.*]] = add nsw i64 [[INDVARS_IV]], -1
 ; CHECK-NEXT:br i1 [[COND]], label [[EXIT:%.*]], label [[GUARDED:%.*]]
 ; CHECK:   guarded:
-; CHECK-NEXT:[[ICMP_USER3:%.*]] = icmp ult i32 [[TMP1]], [[X:%.*]]
-; CHECK-NEXT:br i1 [[ICMP_USER

[llvm-branch-commits] [mlir] 62195b7 - [mlir][CAPI] Convert the rest of the API int -> bool.

2020-11-29 Thread Stella Laurenzo via llvm-branch-commits

Author: Stella Laurenzo
Date: 2020-11-29T20:36:42-08:00
New Revision: 62195b75481890f3d86422710338a15bfbc57bcf

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

LOG: [mlir][CAPI] Convert the rest of the API int -> bool.

* Follows on https://reviews.llvm.org/D92193
* I had a mid-air collision with some additional occurrences and then noticed 
that there were a lot more. Think I got them all.

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

Added: 


Modified: 
mlir/include/mlir-c/AffineExpr.h
mlir/include/mlir-c/AffineMap.h
mlir/include/mlir-c/IR.h
mlir/include/mlir-c/Pass.h
mlir/include/mlir-c/StandardAttributes.h
mlir/include/mlir-c/StandardTypes.h
mlir/include/mlir-c/Support.h
mlir/lib/Bindings/Python/IRModules.cpp
mlir/lib/CAPI/IR/AffineExpr.cpp
mlir/lib/CAPI/IR/AffineMap.cpp
mlir/lib/CAPI/IR/IR.cpp
mlir/lib/CAPI/IR/StandardAttributes.cpp
mlir/lib/CAPI/IR/StandardTypes.cpp
mlir/test/Bindings/Python/ir_attributes.py

Removed: 




diff  --git a/mlir/include/mlir-c/AffineExpr.h 
b/mlir/include/mlir-c/AffineExpr.h
index 7ddd0289d8a5..93b8e832b44f 100644
--- a/mlir/include/mlir-c/AffineExpr.h
+++ b/mlir/include/mlir-c/AffineExpr.h
@@ -57,12 +57,12 @@ MLIR_CAPI_EXPORTED void mlirAffineExprDump(MlirAffineExpr 
affineExpr);
 
 /** Checks whether the given affine expression is made out of only symbols and
  * constants. */
-MLIR_CAPI_EXPORTED int
+MLIR_CAPI_EXPORTED bool
 mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr);
 
 /** Checks whether the given affine expression is a pure affine expression, 
i.e.
  * mul, floordiv, ceildic, and mod is only allowed w.r.t constants. */
-MLIR_CAPI_EXPORTED int mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr);
+MLIR_CAPI_EXPORTED bool mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr);
 
 /** Returns the greatest known integral divisor of this affine expression. The
  * result is always positive. */
@@ -70,13 +70,13 @@ MLIR_CAPI_EXPORTED int64_t
 mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr);
 
 /// Checks whether the given affine expression is a multiple of 'factor'.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr,
-  int64_t factor);
+MLIR_CAPI_EXPORTED bool mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr,
+   int64_t factor);
 
 /** Checks whether the given affine expression involves AffineDimExpr
  * 'position'. */
-MLIR_CAPI_EXPORTED int mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr,
- intptr_t position);
+MLIR_CAPI_EXPORTED bool mlirAffineExprIsFunctionOfDim(MlirAffineExpr 
affineExpr,
+  intptr_t position);
 
 
//===--===//
 // Affine Dimension Expression.
@@ -119,7 +119,7 @@ mlirAffineConstantExprGetValue(MlirAffineExpr affineExpr);
 
//===--===//
 
 /// Checks whether the given affine expression is an add expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsAAdd(MlirAffineExpr affineExpr);
+MLIR_CAPI_EXPORTED bool mlirAffineExprIsAAdd(MlirAffineExpr affineExpr);
 
 /// Creates an affine add expression with 'lhs' and 'rhs'.
 MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineAddExprGet(MlirAffineExpr lhs,
@@ -130,7 +130,7 @@ MLIR_CAPI_EXPORTED MlirAffineExpr 
mlirAffineAddExprGet(MlirAffineExpr lhs,
 
//===--===//
 
 /// Checks whether the given affine expression is an mul expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsAMul(MlirAffineExpr affineExpr);
+MLIR_CAPI_EXPORTED bool mlirAffineExprIsAMul(MlirAffineExpr affineExpr);
 
 /// Creates an affine mul expression with 'lhs' and 'rhs'.
 MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineMulExprGet(MlirAffineExpr lhs,
@@ -141,7 +141,7 @@ MLIR_CAPI_EXPORTED MlirAffineExpr 
mlirAffineMulExprGet(MlirAffineExpr lhs,
 
//===--===//
 
 /// Checks whether the given affine expression is an mod expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsAMod(MlirAffineExpr affineExpr);
+MLIR_CAPI_EXPORTED bool mlirAffineExprIsAMod(MlirAffineExpr affineExpr);
 
 /// Creates an affine mod expression with 'lhs' and 'rhs'.
 MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineModExprGet(MlirAffineExpr lhs,
@@ -152,7 +152,7 @@ MLIR_CAPI_EXPORTED MlirAffineExpr 
mlirAffineModExprGet(MlirAffineExpr lhs,
 
//===--===//
 
 /// Checks whether the given affine expr