[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-06 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing created this revision.
Herald added subscribers: dexonsmith, dang, pengfei, hiraditya, mgorny.
tianqing requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

d8faf03807ac 
 
implemented general-regs-only for X86 by disabling all features
with vector instructions. But the CRC32 instruction in SSE4.2 ISA, which uses
only GPRs, also becomes unavailable. This patch adds a CRC32 feature for this
instruction and allows it to be used with general-regs-only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105462

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/crc32intrin.h
  clang/lib/Headers/ia32intrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/smmintrin.h
  clang/test/CodeGen/X86/x86-crc-builtins.c
  clang/test/CodeGen/attr-cpuspecific.c
  clang/test/CodeGen/attr-target-crc32-x86.c
  clang/test/CodeGen/attr-target-x86.c
  clang/test/Driver/x86-mgeneral-regs-only-crc32.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrFormats.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/crc32-intrinsics-fast-isel-x86_64.ll
  llvm/test/CodeGen/X86/crc32-intrinsics-x86.ll
  llvm/test/CodeGen/X86/crc32-intrinsics-x86_64.ll
  llvm/test/CodeGen/X86/crc32-target-feature.ll
  llvm/test/CodeGen/X86/sse42-intrinsics-fast-isel-x86_64.ll
  llvm/test/CodeGen/X86/sse42-intrinsics-x86_64.ll

Index: llvm/test/CodeGen/X86/crc32-target-feature.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/crc32-target-feature.ll
@@ -0,0 +1,45 @@
+; RUN: llc < %s -mtriple=i386-apple-darwin | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
+
+define i32 @test1(i32 %a, i8 %b) nounwind #0 {
+; CHECK-LABEL: test1:
+; CHECK: crc32b
+  %tmp = call i32 @llvm.x86.sse42.crc32.32.8(i32 %a, i8 %b)
+  ret i32 %tmp
+}
+
+define i32 @test2(i32 %a, i8 %b) nounwind #1 {
+; CHECK-LABEL: test2:
+; CHECK: crc32b
+  %tmp = call i32 @llvm.x86.sse42.crc32.32.8(i32 %a, i8 %b)
+  ret i32 %tmp
+}
+
+define i32 @test3(i32 %a, i8 %b) nounwind #2 {
+; CHECK-LABEL: test3:
+; CHECK: crc32b
+  %tmp = call i32 @llvm.x86.sse42.crc32.32.8(i32 %a, i8 %b)
+  ret i32 %tmp
+}
+
+define i32 @test4(i32 %a, i8 %b) nounwind #3 {
+; CHECK-LABEL: test4:
+; CHECK: crc32b
+  %tmp = call i32 @llvm.x86.sse42.crc32.32.8(i32 %a, i8 %b)
+  ret i32 %tmp
+}
+
+define i32 @test5(i32 %a, i8 %b) nounwind #4 {
+; CHECK-LABEL: test5:
+; CHECK: crc32b
+  %tmp = call i32 @llvm.x86.sse42.crc32.32.8(i32 %a, i8 %b)
+  ret i32 %tmp
+}
+
+declare i32 @llvm.x86.sse42.crc32.32.8(i32, i8) nounwind
+
+attributes #0 = { "target-features"="+sse,+sse2,+sse4.2" }
+attributes #1 = { "target-features"="+crc32" }
+attributes #2 = { "target-features"="+cx8,+fxsr,-3dnow,-3dnowa,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-f16c,-fma,-fma4,-gfni,-kl,-mmx,-pclmul,-sha,-sse,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-x87,-xop,+crc32" }
+attributes #3 = { "target-features"="+crc32,+cx8,+fxsr,-3dnow,-3dnowa,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-f16c,-fma,-fma4,-gfni,-kl,-mmx,-pclmul,-sha,-sse,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-x87,-xop" }
+attributes #4 = { "target-features"="+avx2" }
Index: llvm/test/CodeGen/X86/crc32-intrinsics-x86_64.ll
===
--- llvm/test/CodeGen/X86/crc32-intrinsics-x86_64.ll
+++ llvm/test/CodeGen/X86/crc32-intrinsics-x86_64.ll
@@ -1,4 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+crc32 -show-mc-encoding | FileCheck %s
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=-avx,+sse4.2 -show-mc-encoding | FileCheck %s
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx -show-mc-encoding | FileCheck %s
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl -show-mc-encoding | FileCheck %s
@@

[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Support/X86TargetParser.cpp:531
 constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3;
-constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1;
+constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1 | FeatureCRC32;
 constexpr FeatureBitset ImpliedFeaturesAVX = FeatureSSE4_2;

Same question.



Comment at: llvm/lib/Target/X86/X86.td:84
   "Enable SSE 4.2 instructions",
-  [FeatureSSE41]>;
+  [FeatureSSE41, FeatureCRC32]>;
 // The MMX subtarget feature is separate from the rest of the SSE features

Doesn't this make -mno-crc32 disable sse4.2? Is that what we want?

Or should we be doing this like popcnt where we loosely enable it at the end of 
X86TargetInfo::initFeatureMap


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105462/new/

https://reviews.llvm.org/D105462

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


[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-06 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:84
   "Enable SSE 4.2 instructions",
-  [FeatureSSE41]>;
+  [FeatureSSE41, FeatureCRC32]>;
 // The MMX subtarget feature is separate from the rest of the SSE features

craig.topper wrote:
> Doesn't this make -mno-crc32 disable sse4.2? Is that what we want?
> 
> Or should we be doing this like popcnt where we loosely enable it at the end 
> of X86TargetInfo::initFeatureMap
It does. But it's not a big deal in this case. The scenario described in the 
commit message doesn't require crc32 capable to be disabled separately.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105462/new/

https://reviews.llvm.org/D105462

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


[PATCH] D105447: [analyzer] Allow cmake options to be passed to satest container

2021-07-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/utils/analyzer/entrypoint.py:12
 settings, rest = parse_arguments()
+cmake_opts = list(filter(lambda cmd: cmd[:2]=='-D', rest))
 if settings.wait:

I think we should still use `argparse` for stuff like this, and we don't want 
any of these flags to sneak into `rest`.
https://stackoverflow.com/a/31141568/11582326


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105447/new/

https://reviews.llvm.org/D105447

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


[PATCH] D21113: Add support for case-insensitive header lookup

2021-07-06 Thread Yoav Derman via Phabricator via cfe-commits
Yoav added a comment.
Herald added a subscriber: dang.

Any progress with this? @hans its been stale for a while now and this feature 
is crucial


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D21113/new/

https://reviews.llvm.org/D21113

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


[clang] 6017cb3 - [analyzer][solver] Use all sources of constraints

2021-07-06 Thread Valeriy Savchenko via cfe-commits
Author: Valeriy Savchenko
Date: 2021-07-06T11:09:08+03:00
New Revision: 6017cb31bb3548641465ea66219e11abc3106d38

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

LOG: [analyzer][solver] Use all sources of constraints

Prior to this patch, we always gave priority to constraints that we
actually know about symbols in question.  However, these can get
outdated and we can get better results if we look at all possible
sources of knowledge, including sub-expressions.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/constant-folding.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 0e57a1a5040fc..bc8c83132c5d7 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -884,26 +884,28 @@ class SymbolicRangeInferrer
   }
 
   RangeSet infer(SymbolRef Sym) {
-if (Optional ConstraintBasedRange = intersect(
-RangeFactory, getConstraint(State, Sym),
-// If Sym is a 
diff erence of symbols A - B, then maybe we have range
-// set stored for B - A.
-//
-// If we have range set stored for both A - B and B - A then
-// calculate the effective range set by intersecting the range set
-// for A - B and the negated range set of B - A.
-getRangeForNegatedSub(Sym), getRangeForEqualities(Sym))) {
-  return *ConstraintBasedRange;
-}
-
-// If Sym is a comparison expression (except <=>),
-// find any other comparisons with the same operands.
-// See function description.
-if (Optional CmpRangeSet = getRangeForComparisonSymbol(Sym)) {
-  return *CmpRangeSet;
-}
-
-return Visit(Sym);
+return intersect(
+RangeFactory,
+// Of course, we should take the constraint directly associated with
+// this symbol into consideration.
+getConstraint(State, Sym),
+// If Sym is a 
diff erence of symbols A - B, then maybe we have range
+// set stored for B - A.
+//
+// If we have range set stored for both A - B and B - A then
+// calculate the effective range set by intersecting the range set
+// for A - B and the negated range set of B - A.
+getRangeForNegatedSub(Sym),
+// If Sym is (dis)equality, we might have some information on that
+// in our equality classes data structure.
+getRangeForEqualities(Sym),
+// If Sym is a comparison expression (except <=>),
+// find any other comparisons with the same operands.
+// See function description.
+getRangeForComparisonSymbol(Sym),
+// Apart from the Sym itself, we can infer quite a lot if we look
+// into subexpressions of Sym.
+Visit(Sym));
   }
 
   RangeSet infer(EquivalenceClass Class) {

diff  --git a/clang/test/Analysis/constant-folding.c 
b/clang/test/Analysis/constant-folding.c
index 08a7accfba641..116e74b746b4e 100644
--- a/clang/test/Analysis/constant-folding.c
+++ b/clang/test/Analysis/constant-folding.c
@@ -179,6 +179,36 @@ void testBitwiseRules(unsigned int a, int b, int c) {
   }
 }
 
+unsigned reset();
+
+void testCombinedSources(unsigned a, unsigned b) {
+  if (b >= 10 && (a | b) <= 30) {
+// Check that we can merge constraints from (a | b), a, and b.
+// Because of the order of assumptions, we already know that (a | b) is 
[10, 30].
+clang_analyzer_eval((a | b) >= 10 && (a | b) <= 30); // 
expected-warning{{TRUE}}
+  }
+
+  a = reset();
+  b = reset();
+
+  if ((a | b) <= 30 && b >= 10) {
+// Check that we can merge constraints from (a | b), a, and b.
+// At this point, we know that (a | b) is [0, 30], but the knowledge
+// of b >= 10 added later can help us to refine it and change it to [10, 
30].
+clang_analyzer_eval(10 <= (a | b) && (a | b) <= 30); // 
expected-warning{{TRUE}}
+  }
+
+  a = reset();
+  b = reset();
+
+  unsigned c = (a | b) & (a != b);
+  if (c <= 40 && a == b) {
+// Even though we have a directo constraint for c [0, 40],
+// we can get a more precise range by looking at the expression itself.
+clang_analyzer_eval(c == 0); // expected-warning{{TRUE}}
+  }
+}
+
 void testRemainderRules(unsigned int a, unsigned int b, int c, int d) {
   // Check that we know that remainder of zero divided by any number is still 
0.
   clang_analyzer_eval((0 % c) == 0); // expected-warning{{TRUE}}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi

[PATCH] D105436: [analyzer][solver] Use all sources of constraints

2021-07-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6017cb31bb35: [analyzer][solver] Use all sources of 
constraints (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105436/new/

https://reviews.llvm.org/D105436

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -179,6 +179,36 @@
   }
 }
 
+unsigned reset();
+
+void testCombinedSources(unsigned a, unsigned b) {
+  if (b >= 10 && (a | b) <= 30) {
+// Check that we can merge constraints from (a | b), a, and b.
+// Because of the order of assumptions, we already know that (a | b) is 
[10, 30].
+clang_analyzer_eval((a | b) >= 10 && (a | b) <= 30); // 
expected-warning{{TRUE}}
+  }
+
+  a = reset();
+  b = reset();
+
+  if ((a | b) <= 30 && b >= 10) {
+// Check that we can merge constraints from (a | b), a, and b.
+// At this point, we know that (a | b) is [0, 30], but the knowledge
+// of b >= 10 added later can help us to refine it and change it to [10, 
30].
+clang_analyzer_eval(10 <= (a | b) && (a | b) <= 30); // 
expected-warning{{TRUE}}
+  }
+
+  a = reset();
+  b = reset();
+
+  unsigned c = (a | b) & (a != b);
+  if (c <= 40 && a == b) {
+// Even though we have a directo constraint for c [0, 40],
+// we can get a more precise range by looking at the expression itself.
+clang_analyzer_eval(c == 0); // expected-warning{{TRUE}}
+  }
+}
+
 void testRemainderRules(unsigned int a, unsigned int b, int c, int d) {
   // Check that we know that remainder of zero divided by any number is still 
0.
   clang_analyzer_eval((0 % c) == 0); // expected-warning{{TRUE}}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -884,26 +884,28 @@
   }
 
   RangeSet infer(SymbolRef Sym) {
-if (Optional ConstraintBasedRange = intersect(
-RangeFactory, getConstraint(State, Sym),
-// If Sym is a difference of symbols A - B, then maybe we have 
range
-// set stored for B - A.
-//
-// If we have range set stored for both A - B and B - A then
-// calculate the effective range set by intersecting the range set
-// for A - B and the negated range set of B - A.
-getRangeForNegatedSub(Sym), getRangeForEqualities(Sym))) {
-  return *ConstraintBasedRange;
-}
-
-// If Sym is a comparison expression (except <=>),
-// find any other comparisons with the same operands.
-// See function description.
-if (Optional CmpRangeSet = getRangeForComparisonSymbol(Sym)) {
-  return *CmpRangeSet;
-}
-
-return Visit(Sym);
+return intersect(
+RangeFactory,
+// Of course, we should take the constraint directly associated with
+// this symbol into consideration.
+getConstraint(State, Sym),
+// If Sym is a difference of symbols A - B, then maybe we have range
+// set stored for B - A.
+//
+// If we have range set stored for both A - B and B - A then
+// calculate the effective range set by intersecting the range set
+// for A - B and the negated range set of B - A.
+getRangeForNegatedSub(Sym),
+// If Sym is (dis)equality, we might have some information on that
+// in our equality classes data structure.
+getRangeForEqualities(Sym),
+// If Sym is a comparison expression (except <=>),
+// find any other comparisons with the same operands.
+// See function description.
+getRangeForComparisonSymbol(Sym),
+// Apart from the Sym itself, we can infer quite a lot if we look
+// into subexpressions of Sym.
+Visit(Sym));
   }
 
   RangeSet infer(EquivalenceClass Class) {


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -179,6 +179,36 @@
   }
 }
 
+unsigned reset();
+
+void testCombinedSources(unsigned a, unsigned b) {
+  if (b >= 10 && (a | b) <= 30) {
+// Check that we can merge constraints from (a | b), a, and b.
+// Because of the order of assumptions, we already know that (a | b) is [10, 30].
+clang_analyzer_eval((a | b) >= 10 && (a | b) <= 30); // expected-warning{{TRUE}}
+  }
+
+  a = reset();
+  b = reset();
+
+  if ((a | b) <= 30 && b >= 10) {
+// Check that we can merge constraints from (a | b), a, and b.
+// At this point, we kno

[clang] cbb09c5 - Revert "[clang] fixes named return of variables with dependent alignment"

2021-07-06 Thread Adrian Kuegel via cfe-commits
Author: Adrian Kuegel
Date: 2021-07-06T10:31:39+02:00
New Revision: cbb09c5b2c2e0558de50355f4cbbbe2d2840073e

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

LOG: Revert "[clang] fixes named return of variables with dependent alignment"

This reverts commit 21106388eb96c87b3f580c42a322c76a61605261.
It causes a segfault in certain cases.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/CodeGen/nrvo-tracking.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index d22594ae8442a..020df62755706 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1494,9 +1494,6 @@ class VarDecl : public DeclaratorDecl, public 
Redeclarable {
 NonParmVarDeclBits.EscapingByref = true;
   }
 
-  /// Determines if this variable's alignment is dependent.
-  bool hasDependentAlignment() const;
-
   /// Retrieve the variable declaration from which this variable could
   /// be instantiated, if it is an instantiation (rather than a non-template).
   VarDecl *getTemplateInstantiationPattern() const;

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index a92d3726e8474..5047dc19b0c6f 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2534,13 +2534,6 @@ bool VarDecl::isNonEscapingByref() const {
   return hasAttr() && !NonParmVarDeclBits.EscapingByref;
 }
 
-bool VarDecl::hasDependentAlignment() const {
-  return getType()->isDependentType() ||
- llvm::any_of(specific_attrs(), [](const AlignedAttr *AA) 
{
-   return AA->isAlignmentDependent();
- });
-}
-
 VarDecl *VarDecl::getTemplateInstantiationPattern() const {
   const VarDecl *VD = this;
 

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9e1f42a15e556..0075464552321 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13310,6 +13310,16 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl 
*var) {
 CheckCompleteDecompositionDeclaration(DD);
 }
 
+/// Determines if a variable's alignment is dependent.
+static bool hasDependentAlignment(VarDecl *VD) {
+  if (VD->getType()->isDependentType())
+return true;
+  for (auto *I : VD->specific_attrs())
+if (I->isAlignmentDependent())
+  return true;
+  return false;
+}
+
 /// Check if VD needs to be dllexport/dllimport due to being in a
 /// dllexport/import function.
 void Sema::CheckStaticLocalForDllExport(VarDecl *VD) {
@@ -13398,7 +13408,7 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) {
   if (unsigned MaxAlign = Context.getTargetInfo().getMaxTLSAlign()) {
 // Protect the check so that it's not performed on dependent types and
 // dependent alignments (we can't determine the alignment in that case).
-if (VD->getTLSKind() && !VD->hasDependentAlignment() &&
+if (VD->getTLSKind() && !hasDependentAlignment(VD) &&
 !VD->isInvalidDecl()) {
   CharUnits MaxAlignChars = Context.toCharUnitsFromBits(MaxAlign);
   if (Context.getDeclAlign(VD) > MaxAlignChars) {

diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 506c06b412b6f..1e86f382f060b 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3395,7 +3395,7 @@ Sema::NamedReturnInfo Sema::getNamedReturnInfo(const 
VarDecl *VD) {
 
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
-  if (!VD->hasDependentAlignment() &&
+  if (!VDType->isDependentType() && VD->hasAttr() &&
   Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 Info.S = NamedReturnInfo::MoveEligible;
 

diff  --git a/clang/test/CodeGen/nrvo-tracking.cpp 
b/clang/test/CodeGen/nrvo-tracking.cpp
index 2d6eb9efeca20..7893140e1010a 100644
--- a/clang/test/CodeGen/nrvo-tracking.cpp
+++ b/clang/test/CodeGen/nrvo-tracking.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -std=c++20 -fblocks -Wno-return-stack-address -triple 
x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - 
%s | FileCheck %s
 
-struct alignas(4) X {
-  X();
-  X(const X &);
-  X(X &&);
+struct X {
+X();
+X(const X&);
+X(X&&);
 };
 
 #define L(A, B, C) void l##A() {\
@@ -210,75 +210,3 @@ void b_attr() {
 };
   }()();
 }
-
-namespace test_alignas {
-
-template  X t1() {
-  X a [[gnu::aligned(A)]];
-  return a;
-}
-
-// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi1EEE1Xv
-// CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  ret void
-template X t1<1>();
-
-// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi4EEE1Xv
-// CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  ret void
-template X t1<4>();
-
-// CHECK-LABEL: 

[PATCH] D105436: [analyzer][solver] Use all sources of constraints

2021-07-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:908
+// into subexpressions of Sym.
+Visit(Sym));
   }

Alright. So, this is correct because `Visit` boils down finally to either 
`infer(Sym->getType)` or to `VisitBinaryOperator`. And both of them do a 
correct over-approximation of the ranges. Please confirm. 

First, I was a bit concerned b/c it is not immediate and not documented here. 
And it is easy to think by the first look that this might be faulty if we take 
the approximation of one operand of a binop that might not be true for the 
whole binop expression. Again, that is not the case because we approximate only 
in case of such ops where we can do a correct over-approximation (i.e. `|`, `&` 
and `%`). 

My point is, I'd like to see more explanatory comments here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105436/new/

https://reviews.llvm.org/D105436

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


[PATCH] D105380: [clang] fixes named return of variables with dependent alignment

2021-07-06 Thread Michael Forster via Phabricator via cfe-commits
MForster added a comment.

Adrian has reverted this commit for me. Here is a reproduction case for the 
issue that is triggered by this change:

  #include 
  
  template
  struct S {};
  
  template  
  S foo() {
for (auto status : { S() }) {
return status;
}
  }
  
  void a() {
foo();
  }

This is the segmentation fault:

  instantiating function definition 'foo'
   #0 0x55807ba49925 SignalHandler(int) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x6649925)
   #1 0x7f18a9d509a0 __restore_rt 
(/usr/grte/v4/lib64/libpthread.so.0+0xf9a0)
   #2 0x55807901a01d clang::ASTContext::getTypeInfoImpl(clang::Type const*) 
const (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3c1a01d)
   #3 0x558078ffcf93 clang::ASTContext::getPreferredTypeAlign(clang::Type 
const*) const 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3bfcf93)
   #4 0x558078ffc4ea clang::ASTContext::getDeclAlign(clang::Decl const*, 
bool) const 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3bfc4ea)
   #5 0x558078029686 clang::Sema::getNamedReturnInfo(clang::VarDecl const*) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2c29686)
   #6 0x558078026e84 
clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool, 
llvm::ArrayRef*) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2c26e84)
   #7 0x558079388ebc clang::Sema::SubstDecl(clang::Decl*, 
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3f88ebc)
   #8 0x558077fd8a2d clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) 
(.llvm.3943398439186356346) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2bd8a2d)
   #9 0x55807823f79f clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformCXXForRangeStmt(clang::CXXForRangeStmt*)
 (.llvm.3943398439186356346) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2e3f79f)
  #10 0x5580794bfa18 clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*) 
(.llvm.3943398439186356346) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x40bfa18)
  #11 0x55807940149f 
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, 
clang::FunctionDecl*, bool, bool, bool) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x400149f)
  #12 0x5580794027a3 clang::Sema::PerformPendingInstantiations(bool) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x40027a3)
  #13 0x5580780f5443 
clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2cf5443)
  #14 0x5580780f461c clang::Sema::ActOnEndOfTranslationUnit() 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2cf461c)
  #15 0x5580785530e3 
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) 
(.cold) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x31530e3)
  #16 0x5580780f224f clang::ParseAST(clang::Sema&, bool, bool) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2cf224f)
  #17 0x5580781fff95 clang::FrontendAction::Execute() 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2dfff95)
  #18 0x5580781ffdc4 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2dffdc4)
  #19 0x5580781ffc98 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2dffc98)
  #20 0x55807974f570 cc1_main(llvm::ArrayRef, char const*, 
void*) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x434f570)
  #21 0x5580782a04b9 ExecuteCC1Tool(llvm::SmallVectorImpl&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2ea04b9)
  #22 0x55807964f49b main 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x424f49b)
  #23 0x7f18a9bbebbd __libc_start_main 
(/usr/grte/v4/lib64/libc.so.6+0x38bbd)
  #24 0x558077fc92c9 _start 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2bc92c9)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105380/new/

https://reviews.llvm.org/D105380

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


[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-07-06 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D97915#2848816 , @ychen wrote:

>> Thanks for clarifying. Let's solve the semantics problem first.
>> With the introduction about 'raw frame', I think it's necessary to introduce 
>> this concept in the section 'Switched-Resume Lowering' or even the section 
>> 'Introduction' in the document. Add a section to tell the terminology is 
>> satisfied too.
>
> Done.
>
>> Then why we defined both 'llvm.coro.raw.frame.ptr.offset' and 
>> 'llvm.coro.raw.frame.ptr.addr' together? It looks like refer to the same 
>> value finally. It looks like 'llvm.coro.raw.frame.ptr.offset' are trying to 
>> solve the problem about memory leak. But I think we could use 
>> llvm.coro.raw.frame.ptr.addr directly instead of traversing the frame (Maybe 
>> we need to add an intrinsic `llvm.coro.raw.size`).  Then we can omit a field 
>> in the frame to save space.
>
> ("llvm.coro.raw.frame.ptr.offset" is an offset from coroutine frame address 
> instead of raw frame pointer)
>
> Apologies for the confusion. I've briefly explained it here 
> https://reviews.llvm.org/D102145#2752445 I think it is not clear. 
> "llvm.coro.raw.frame.ptr.addr" is conceptually "the address of a coroutine 
> frame field storing the `raw frame pointer`" only after `insertSpills` in 
> CoroFrame.cpp. Before that, "llvm.coro.raw.frame.ptr.addr" is actually an 
> alloca storing the `raw frame pointer` (try grepping "alloc.frame.ptr" in 
> this review page). Using  "llvm.coro.raw.frame.ptr.offset" instead of  
> "llvm.coro.raw.frame.ptr.addr" is doable which looks like below, please check 
> line 31. The downside is that the write to coroutine frame is not through an 
> alloca but a direct write. It is unusual because all fields in the frame are 
> stored as 1. special/header fields 2. alloca 3. splills. Doing the write 
> indirectly as Alloca makes me comfortable. The tradeoff is one extra 
> intrinsic "llvm.coro.raw.frame.ptr.addr". What do you think?
>
>   19 coro.alloc.align: ; preds = 
> %coro.alloc.check.align
>   20   %3 = sub nsw i64 64, 16
>   21   %4 = add i64 128, %3
>   22   %call1 = call noalias nonnull i8* @_Znwm(i64 %4) #13
>   23   %mask = sub i64 64, 1
>   24   %intptr = ptrtoint i8* %call1 to i64
>   25   %over_boundary = add i64 %intptr, %mask
>   26   %inverted_mask = xor i64 %mask, -1
>   27   %aligned_intptr = and i64 %over_boundary, %inverted_mask
>   28   %diff = sub i64 %aligned_intptr, %intptr
>   29   %aligned_result = getelementptr inbounds i8, i8* %call1, i64 %diff
>   30   call void @llvm.assume(i1 true) [ "align"(i8* %aligned_result, i64 64) 
> ]
>   31   store i8* %call1, i8** %alloc.frame.ptr, align 8 
>   
>; Replace line 31 with below, and must makes sure line 46~line 48 is 
> skipped.
>; %poff = call i32 @llvm.coro.raw.frame.ptr.offset.i32()
>; %addr = getelementptr inbounds i8, i8* %aligned_result, i32 %poff
>; %addr1 = bitcast i8* %addr to i8**
>; store i8* %call1, i8** %addr1, align 8
>   
>   
>   32   br label %coro.init.from.coro.alloc.align
>   33
>   34 coro.init.from.coro.alloc.align:  ; preds = 
> %coro.alloc.align
>   35   %aligned_result.coro.init = phi i8* [ %aligned_result, 
> %coro.alloc.align ]
>   36   br label %coro.init
>   37
>   38 coro.init:; preds = 
> %coro.init.from.entry, %coro.init.from.coro.alloc.align, %cor
>  o.init.from.coro.alloc
>   39   %5 = phi i8* [ %.coro.init, %coro.init.from.entry ], [ 
> %call.coro.init, %coro.init.from.coro.alloc ], [ %aligned_result
>  .coro.init, %coro.init.from.coro.alloc.align ]
>   40   %FramePtr = bitcast i8* %5 to %f0.Frame*
>   41   %resume.addr = getelementptr inbounds %f0.Frame, %f0.Frame* %FramePtr, 
> i32 0, i32 0
>   42   store void (%f0.Frame*)* @f0.resume, void (%f0.Frame*)** %resume.addr, 
> align 8
>   43   %6 = select i1 true, void (%f0.Frame*)* @f0.destroy, void 
> (%f0.Frame*)* @f0.cleanup
>   44   %destroy.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
> %FramePtr, i32 0, i32 1
>   45   store void (%f0.Frame*)* %6, void (%f0.Frame*)** %destroy.addr, align 8
>   46   %7 = getelementptr inbounds %f0.Frame, %f0.Frame* %FramePtr, i32 0, 
> i32 2
>   47   %8 = load i8*, i8** %alloc.frame.ptr, align 8
>   48   store i8* %8, i8** %7, align 8
>   49   br label %AllocaSpillBB
>   50
>   51 AllocaSpillBB:; preds = %coro.init
>   52   %.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
> %FramePtr, i32 0, i32 4
>   53   %ref.tmp.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
> %FramePtr, i32 0, i32 5
>   54   %agg.tmp.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
> %FramePtr, i32 0, i32 6
>   55   %ref.tmp5.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
> %FramePtr, i32 0, i32 7
>   56   %agg.tmp8.reload.addr = getelementptr inbounds %f0.Frame, %f

[PATCH] D105436: [analyzer][solver] Use all sources of constraints

2021-07-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:908
+// into subexpressions of Sym.
+Visit(Sym));
   }

martong wrote:
> Alright. So, this is correct because `Visit` boils down finally to either 
> `infer(Sym->getType)` or to `VisitBinaryOperator`. And both of them do a 
> correct over-approximation of the ranges. Please confirm. 
> 
> First, I was a bit concerned b/c it is not immediate and not documented here. 
> And it is easy to think by the first look that this might be faulty if we 
> take the approximation of one operand of a binop that might not be true for 
> the whole binop expression. Again, that is not the case because we 
> approximate only in case of such ops where we can do a correct 
> over-approximation (i.e. `|`, `&` and `%`). 
> 
> My point is, I'd like to see more explanatory comments here.
I'm sorry, but I don't really understand your point here.

Everything that this solver provides is conservative ranges, from whatever 
source it comes.  If you intersect two conservative ranges, you get a 
conservative range.
It doesn't matter what we do in `Visit` as long as it is correct.  If `Visit` 
is incorrect then the previous version of this code that gave preference to 
some sources over the other ones was also incorrect.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105436/new/

https://reviews.llvm.org/D105436

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


[PATCH] D105436: [analyzer][solver] Use all sources of constraints

2021-07-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:908
+// into subexpressions of Sym.
+Visit(Sym));
   }

vsavchenko wrote:
> martong wrote:
> > Alright. So, this is correct because `Visit` boils down finally to either 
> > `infer(Sym->getType)` or to `VisitBinaryOperator`. And both of them do a 
> > correct over-approximation of the ranges. Please confirm. 
> > 
> > First, I was a bit concerned b/c it is not immediate and not documented 
> > here. And it is easy to think by the first look that this might be faulty 
> > if we take the approximation of one operand of a binop that might not be 
> > true for the whole binop expression. Again, that is not the case because we 
> > approximate only in case of such ops where we can do a correct 
> > over-approximation (i.e. `|`, `&` and `%`). 
> > 
> > My point is, I'd like to see more explanatory comments here.
> I'm sorry, but I don't really understand your point here.
> 
> Everything that this solver provides is conservative ranges, from whatever 
> source it comes.  If you intersect two conservative ranges, you get a 
> conservative range.
> It doesn't matter what we do in `Visit` as long as it is correct.  If `Visit` 
> is incorrect then the previous version of this code that gave preference to 
> some sources over the other ones was also incorrect.
Thanks for your reply.  So, with other words, I didn't see why it is immediate 
that a range for a sub-expression is a good approximation for the whole 
expression. Maybe it's just me, but that's not obvious until one checks that 
what exactly happens in `Visit`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105436/new/

https://reviews.llvm.org/D105436

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


[PATCH] D105436: [analyzer][solver] Use all sources of constraints

2021-07-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:908
+// into subexpressions of Sym.
+Visit(Sym));
   }

martong wrote:
> vsavchenko wrote:
> > martong wrote:
> > > Alright. So, this is correct because `Visit` boils down finally to either 
> > > `infer(Sym->getType)` or to `VisitBinaryOperator`. And both of them do a 
> > > correct over-approximation of the ranges. Please confirm. 
> > > 
> > > First, I was a bit concerned b/c it is not immediate and not documented 
> > > here. And it is easy to think by the first look that this might be faulty 
> > > if we take the approximation of one operand of a binop that might not be 
> > > true for the whole binop expression. Again, that is not the case because 
> > > we approximate only in case of such ops where we can do a correct 
> > > over-approximation (i.e. `|`, `&` and `%`). 
> > > 
> > > My point is, I'd like to see more explanatory comments here.
> > I'm sorry, but I don't really understand your point here.
> > 
> > Everything that this solver provides is conservative ranges, from whatever 
> > source it comes.  If you intersect two conservative ranges, you get a 
> > conservative range.
> > It doesn't matter what we do in `Visit` as long as it is correct.  If 
> > `Visit` is incorrect then the previous version of this code that gave 
> > preference to some sources over the other ones was also incorrect.
> Thanks for your reply.  So, with other words, I didn't see why it is 
> immediate that a range for a sub-expression is a good approximation for the 
> whole expression. Maybe it's just me, but that's not obvious until one checks 
> that what exactly happens in `Visit`.
Oh, I mean, it's not correct.  Symbolic expressions are N-ary operators, and if 
we know constraints for at least some of these N operands, we can provide a 
conservative range for the whole symbol using some knowledge of the operator.  
It doesn't say anywhere that we use a range for a sub-expression as an 
approximation for the whole range.

Actually I want to move some of these other sources inside of `Visit` as well 
because they trigger only to very specific kinds of symbolic expressions (e.g. 
binary minus, equality/disequality, comparisons).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105436/new/

https://reviews.llvm.org/D105436

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


[PATCH] D21113: Add support for case-insensitive header lookup

2021-07-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D21113#2859165 , @Yoav wrote:

> Any progress with this? @hans its been stale for a while now and this feature 
> is crucial

No progress, I'm afraid. I'm not working on this, so someone would have to take 
over the patch to push it forward.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D21113/new/

https://reviews.llvm.org/D21113

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


[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-06 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 356668.
ASDenysPetrov added a comment.

Splitted this revision and moved `SValBuilder` related changes to separate 
patch D105340 . Added detailed comments. Made 
`NominalTypeList` //static// and as a result removed the forwarding across the 
functions. Spread `handleSymbolCast` logic to three methods: 
`modifySymbolAndConstraints`, `updateExistingConstraints`, 
`getProperSymbolAndConstraint`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/symbol-integral-cast.cpp

Index: clang/test/Analysis/symbol-integral-cast.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-integral-cast.cpp
@@ -0,0 +1,353 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-config eagerly-assume=false -analyzer-config support-symbolic-integer-casts=true -verify %s
+
+template 
+void clang_analyzer_eval(T);
+void clang_analyzer_warnIfReached();
+
+typedef short int16_t;
+typedef int int32_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+
+void test1(int x) {
+  // Even if two lower bytes of `x` equal to zero, it doesn't mean that
+  // the entire `x` is zero. We are not able to know the exact value of x.
+  // It can be one of  65536 possible values like [0, 65536, 131072, ...]
+  // and so on. To avoid huge range sets we still assume `x` in the range
+  // [INT_MIN, INT_MAX].
+  if (!(short)x) {
+if (!x)
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+else
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  }
+}
+
+void test2(int x) {
+  // If two lower bytes of `x` equal to zero, and we know x to be 65537,
+  // which is not truncated to short as zero. Thus the branch is infisible.
+  short s = x;
+  if (!s) {
+if (x == 65537)
+  clang_analyzer_warnIfReached(); // no-warning
+else
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  }
+}
+
+void test3(int x, short s) {
+  s = x;
+  if ((short)x > -10 && s < 10) {
+if (x > 0 && x < 10) {
+  // If the range of the whole variable was constrained then reason again
+  // about truncated bytes to make the ranges more precise.
+  clang_analyzer_eval((short)x <= 0); // expected-warning {{FALSE}}
+}
+  }
+}
+
+void test4(unsigned x) {
+  if ((char)x > 8) {
+// Constraint the range of the lowest byte of `x` to [9, CHAR_MAX].
+// The original range of `x` still remains [0, UINT_MAX].
+clang_analyzer_eval((char)x < 42); // expected-warning {{UNKNOWN}}
+if (x < 42) {
+  // Constraint the original range to [0, 42] and update (re-constraint)
+  // the range of the lowest byte of 'x' to [9, 42].
+  clang_analyzer_eval((char)x < 42); // expected-warning {{TRUE}}
+}
+  }
+}
+
+void test5(unsigned x) {
+  if ((char)x > -10 && (char)x < 10) {
+if ((short)x == 8) {
+  // If the range of higher bytes(short) was constrained then reason again
+  // about smaller truncated ranges(char) to make it more precise.
+  clang_analyzer_eval((char)x == 8);  // expected-warning {{TRUE}}
+  clang_analyzer_eval((short)x == 8); // expected-warning {{TRUE}}
+  // We still assume full version of `x` in the range [INT_MIN, INT_MAX].
+  clang_analyzer_eval(x == 8); // expected-warning {{UNKNOWN}}
+}
+  }
+}
+
+void test6(int x) {
+  // Even if two lower bytes of `x` less than zero, it doesn't mean that `x`
+  // can't be greater than zero. Thence we don't change the native range of
+  // `x` and this branch is feasible.
+  if (x > 0)
+if ((short)x < 0)
+  clang_analyzer_eval(x > 0); // expected-warning {{TRUE}}
+}
+
+void test7(int x) {
+  // The range of two lower bytes of `x` [1, SHORT_MAX] is enough to cover
+  // all possible values of char [CHAR_MIN, CHAR_MAX]. So the lowest byte
+  // can be lower than zero.
+  if ((short)x > 0) {
+if ((char)x < 0)
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+else
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  }
+}
+
+void test8(int x) {
+  // Promotion from `signed int` to `signed long long` also reasoning about the
+  // original range, because we know the fact that even after promotion it
+  // remains in the range [INT_MIN, INT_MAX].
+  if ((long long)x < 0)
+clang_analyzer_eval(x < 0); // expected-warning {{TRUE}}
+}
+
+void test9(signed int x) {
+  // Any cast `signed` to `unsigned` produces an unsigned range, which is
+  // [0, UNSIGNED_MAX] and can not be lower than zero.
+  if ((unsigned long long)x < 0)
+clang_analyz

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

This is a very complicated patch, I think we'll have to iterate on it quite a 
lot.
Additionally, we have to be sure that this doesn't crash our performance.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1131
 
+class NominalTypeList {
+  CanQualType Types[4];

Comments on:
* why do we need it?
* why does it have four types?
* why do we not care about signed/unsigned types?



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2797-2799
+ProgramStateRef
+RangeConstraintManager::updateExistingConstraints(ProgramStateRef State,
+  SymbolRef Sym, RangeSet R) {

OK, but I still don't understand one thing.
Here you go over all "smaller" types and artificially create constraints for 
them, and at the same time in `VisitSymbolCast` you do the opposite operation?  
Why?  Shouldn't the map have constraints for smaller types already because of 
this action?  Why do we need to do both?




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2801-2802
+  // Get a root symbol in case of SymbolCast.
+  while (isa(Sym))
+Sym = cast(Sym)->getOperand();
+

This looks like a pattern and we should probably make into a method of 
`SymbolCast`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096

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


[PATCH] D105380: [clang] fixes named return of variables with dependent alignment

2021-07-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov reopened this revision.
mizvekov added a comment.
This revision is now accepted and ready to land.

Thanks for reporting that one!
Yeah looking if the type is dependent is not enough, a non-deduced auto type is 
not considered dependent.
I will work on a patch for it later today.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105380/new/

https://reviews.llvm.org/D105380

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-07-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D99005#2844365 , @mizvekov wrote:

> But is this example a reduction from a real world code base?
> The committee wants feedback and we are interested how hard you believe this 
> change affects you.

This is an example that also appears to be impacted by this change:

  struct C {
  C();
  C(C &c1);
  };
  
  void foo()
  {
  try {
  C c1;
  throw c1;
  }
  catch (C c2) {
  throw;
  }
  }

https://godbolt.org/z/dvEbv7GKo

I'm not certain if this is as expected of an issue, though. In the original 
example, `C` carried state that was set up after initialization but was relying 
on the fallback to the non-idiomatic copy constructor when doing the `throw`. 
WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99005/new/

https://reviews.llvm.org/D99005

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


[PATCH] D105447: [analyzer] Allow cmake options to be passed to satest container

2021-07-06 Thread Manas Gupta via Phabricator via cfe-commits
manas added inline comments.



Comment at: clang/utils/analyzer/entrypoint.py:12
 settings, rest = parse_arguments()
+cmake_opts = list(filter(lambda cmd: cmd[:2]=='-D', rest))
 if settings.wait:

vsavchenko wrote:
> I think we should still use `argparse` for stuff like this, and we don't want 
> any of these flags to sneak into `rest`.
> https://stackoverflow.com/a/31141568/11582326
Understood! I will rework on this. Thanks for the review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105447/new/

https://reviews.llvm.org/D105447

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


[PATCH] D104858: [OpenCL][ARM] Fix ICE when compiling a kernel

2021-07-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D104858#2857958 , 
@pekka.jaaskelainen wrote:

>> The reason why we would like to fix it is that upstream clang has a crash 
>> currently when OpenCL sources are compiled for any Arm CPU: 
>> https://bugs.llvm.org/show_bug.cgi?id=50841. Do you have any other 
>> suggestions to avoid this problem?
>>
>> FYI clang also emits kernel metadata that can be used to detect kernels...
>
> Unfortunately I cannot look at this in detail right now, but I'll reply 
> quickly for a heads up: The problem was not how to detect kernels, but the 
> ABI/CC mismatch to the
> clSetKerneArg() with (user facing) arguments that get split to multiple args 
> or vice versa. E.g. x86 ABI had a CC where 2xfloat gets to 1xdouble in the 
> generated function
> finger print, thus there was no 1:1 match of the kernel arguments to the 
> OpenCL-facing ones (making clSetKernelArg calls difficult to implement 
> robustly).
>
> IIRC, SPIR_KERNEL CC was used to force the 1:1 mapping and produce a portable 
> way to handle this OpenCL API e.g. with struct args etc.

Ok, thanks for clarification. Does it mean there is something we need to add to 
LLVM somewhere to make it work correctly? Would it be specific to Arm or 
generally for all CPU targets?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104858/new/

https://reviews.llvm.org/D104858

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


[libunwind] f7d8754 - [runtimes] Move enable_32bit to the DSL

2021-07-06 Thread Louis Dionne via cfe-commits
Author: Louis Dionne
Date: 2021-07-06T08:42:07-04:00
New Revision: f7d8754312bf3d10fb902d94f2bc84e3adf12ba4

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

LOG: [runtimes] Move enable_32bit to the DSL

This is necessary for from-scratch configurations to support the 32-bit
mode of the test suite.

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

Added: 


Modified: 
libcxx/test/CMakeLists.txt
libcxx/test/configs/legacy.cfg.in
libcxx/utils/libcxx/test/config.py
libcxx/utils/libcxx/test/params.py
libcxxabi/test/CMakeLists.txt
libcxxabi/test/lit.site.cfg.in
libunwind/test/CMakeLists.txt
libunwind/test/lit.site.cfg.in

Removed: 




diff  --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 71a7d16772d3..f5f652613937 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -113,6 +113,10 @@ if (LLVM_USE_SANITIZER)
   serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
 endif()
 
+if (LIBCXX_BUILD_32_BITS)
+  serialize_lit_param(enable_32bit True)
+endif()
+
 if (NOT DEFINED LIBCXX_TEST_DEPS)
   message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
 endif()

diff  --git a/libcxx/test/configs/legacy.cfg.in 
b/libcxx/test/configs/legacy.cfg.in
index adb813644fec..23aa5051eaea 100644
--- a/libcxx/test/configs/legacy.cfg.in
+++ b/libcxx/test/configs/legacy.cfg.in
@@ -13,7 +13,6 @@ config.libcxx_obj_root  = "@LIBCXX_BINARY_DIR@"
 config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@"
 config.abi_library_root = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
 config.enable_shared= @LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX@
-config.enable_32bit = @LIBCXX_BUILD_32_BITS@
 config.cxx_abi  = "@LIBCXX_CXX_ABI_LIBNAME@"
 config.configuration_variant= "@LIBCXX_LIT_VARIANT@"
 config.host_triple  = "@LLVM_HOST_TRIPLE@"

diff  --git a/libcxx/utils/libcxx/test/config.py 
b/libcxx/utils/libcxx/test/config.py
index 9538ecc6db79..f7117ca57b1e 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -267,10 +267,6 @@ def configure_default_compile_flags(self):
 self.configure_compile_flags_header_includes()
 self.target_info.add_cxx_compile_flags(self.cxx.compile_flags)
 self.target_info.add_cxx_flags(self.cxx.flags)
-# Configure feature flags.
-enable_32bit = self.get_lit_bool('enable_32bit', False)
-if enable_32bit:
-self.cxx.flags += ['-m32']
 # Use verbose output for better errors
 self.cxx.flags += ['-v']
 sysroot = self.get_lit_conf('sysroot')

diff  --git a/libcxx/utils/libcxx/test/params.py 
b/libcxx/utils/libcxx/test/params.py
index 991f51ef902c..21621aedb75c 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -158,6 +158,13 @@ def getStdFlag(cfg, std):
   AddFeature('libcxx-no-debug-mode')
 ]),
 
+  Parameter(name='enable_32bit', choices=[True, False], type=bool, 
default=False,
+help="Whether to build the test suite in 32 bit mode even on a 64 
bit target. This basically controls "
+ "whether -m32 is used when building the test suite.",
+actions=lambda enabled: [] if not enabled else [
+  AddFlag('-m32')
+]),
+
   Parameter(name='additional_features', type=list, default=[],
 help="A comma-delimited list of additional features that will be 
enabled when running the tests. "
  "This should be used sparingly since specifying ad-hoc 
features manually is error-prone and "

diff  --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index b571a2437cc8..385c43eaf2cb 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -90,6 +90,10 @@ if (TARGET_TRIPLE)
   serialize_lit_param(target_triple "\"${TARGET_TRIPLE}\"")
 endif()
 
+if (LIBCXXABI_BUILD_32_BITS)
+  serialize_lit_param(enable_32bit True)
+endif()
+
 configure_lit_site_cfg(
   "${LIBCXXABI_TEST_CONFIG}"
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg

diff  --git a/libcxxabi/test/lit.site.cfg.in b/libcxxabi/test/lit.site.cfg.in
index 4015501de482..049f822b5ed5 100644
--- a/libcxxabi/test/lit.site.cfg.in
+++ b/libcxxabi/test/lit.site.cfg.in
@@ -18,7 +18,6 @@ config.cxx_library_root = 
"@LIBCXXABI_LIBCXX_LIBRARY_PATH@"
 config.llvm_unwinder= @LIBCXXABI_USE_LLVM_UNWINDER@
 config.builtins_library = "@LIBCXXABI_BUILTINS_LIBRARY@"
 config.enable_threads   = @LIBCXXABI_ENABLE_THREADS@
-config.enable_32bit = @LIBCXXABI_BUILD_32_BITS@
 config.target_info  = "@LIBCXXABI_TARGET_INFO@"
 config.executor = "@LIBCXXABI_EXECUTOR@"

[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-07-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This generally looks good now, mostly nits left.

The exception is the remaining complexity around stashing and restoring the 
traversal scope state.
If it's needed, it points to a deeper problem in static analyzer and we should 
understand it a bit (and whether it must be fixed as it will undo the 
performance characteristics of this feature in some circumstances).




Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:310
+struct DeclFilter {
+  DeclFilter(ClangTidyContext &Ctx, SourceManager &SM)
+  : Context(Ctx), Sources(SM) {

Ctx is ultimately unused, just take the regex instead?



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:346
 private:
+  bool handleTopLevelDecl(DeclGroupRef DG);
+  bool hasFilter() { return Filter.get() != nullptr; }

please find a different name for this function or merge the two together, 
having two different functions differing only by case is confusing



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:348
+  bool hasFilter() { return Filter.get() != nullptr; }
+  std::vector &getTraversalScope() { return TopLevelDecls; }
+

this function isn't needed - it's a trivial accessor called once in a place 
where we can access the field directly.
Similarly with hasFilter. The code accessing the fields directly reads just as 
clearly.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:428
 
+bool DeclFilter::skipFileID(SourceLocation Location, FileID FID) {
+  // do not skip the main file

can you move the impl of the members next to the class?



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:514
+  for (auto &Consumer : Consumers) {
+if (hasFilter() && Consumer.get() == FinderASTConsumerPtr) {
+  // Modify AST before calling the Finder's ASTConsumer.

This adds significant conceptual complexity and possible runtime costs to guard 
against the possibility that the static analyzer would not be compatible with 
simply setting the traversal scope.

Please do not do this. It may appear that you're cheaply eliminating a class of 
bugs, but complexity is not cheap, and in the long run can also introduce bugs. 
Instead investigate whether this is a real problem and why.

If it's not then `Context.setTraversalScope()` + 
`MultiplexingASTConsumer::HandleTranslationUnit` is enough here, and 
`FinderASTConsumerPtr` can go away.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:608
   std::move(Consumers), std::move(Profiling), std::move(Finder),
-  std::move(Checks));
+  FinderASTConsumerPtr, SharedDeclFilter, std::move(Checks));
 }

move SharedDeclFilter



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:473
+MatchFinder::matchAST(Context);
+Context.setTraversalScope(SavedScope);
+  } else {

chh wrote:
> sammccall wrote:
> > Is restoring the traversal scope strictly needed by the static analyzer? I 
> > would expect not, but I might be wrong.
> I think it is safer to assume low or acceptable overhead in 
> get/setTraversalScope and keep the impact only to the MatchFinder consumer, 
> rather than depending on static analyzer working now or in the future with 
> the changed AST.
> 
> I think it is safer to assume low or acceptable overhead in 
> get/setTraversalScope
We have reasons to believe this is not cheap. The first usage of getParent() 
after changing traversal scope incurs a full AST traversal.

> rather than depending on static analyzer working now or in the future with 
> the changed AST.

There are a fairly small number of reasons that setTraversalScope could break 
static analyzer at this point, and I think they're all going to cause the 
static analyzer to be slow when used with PCHes. However the static analyzer's 
implementation and comments say that it goes to effort to be fast with PCHes. 
So I do believe this is a more stable assumption, and in the long run we may be 
able to simplify its implementation.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:99
 IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
 IO.mapOptional("UseColor", Options.UseColor);
   }

Maybe an explicit comment that ShowAllHeaders, SkipHeaders are 
runtime/optimization options that are configured at the command-line only, and 
therefore not mapped here



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.h:79
 
+  /// Show all warnings, including warnings from all header files.
+  llvm::Optional ShowAllWarnings;

This overrides (and is therefore grouped with) HeaderFilterRegex, SystemHeaders.
So the order should probably be
HeaderFilterRegex
SystemHeaders
ShowAllWarnings
SkipHeaders

Comment should comment should explicitly say both "This overrides 
HeaderFilt

[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-07-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D99005#2843201 , @mizvekov wrote:

> Thank you again @sberg.
>
> I have talked to the MSVC STL maintainers. They would be open to a pull 
> request for fixing this.
> The repo can be found at https://github.com/microsoft/STL
> Be my guest if you want to submit that fix yourself.
> If not, I can probably do it in the near future.

I'm not certain it's reasonable to wait for MSVC STL to change as that leaves 
every existing user of older MSVC STLs out in the cold. This is causing some 
significant regressions at Intel, to the extent that I wonder if this should be 
temporarily reverted until the MSVC STL headers can be compiled again.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99005/new/

https://reviews.llvm.org/D99005

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


[PATCH] D105477: Define __LONGDOUBLE64 macro

2021-07-06 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan created this revision.
Herald added subscribers: kbarton, nemanjai.
Jake-Egan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105477

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Preprocessor/init-ppc.c


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -512,6 +512,7 @@
 // PPC-AIX:#define __LDBL_MIN_10_EXP__ (-307)
 // PPC-AIX:#define __LDBL_MIN_EXP__ (-1021)
 // PPC-AIX:#define __LDBL_MIN__ 2.2250738585072014e-308L
+// PPC-AIX:#define __LONGDOUBLE64 1
 // PPC-AIX:#define __LONG_LONG_MAX__ 9223372036854775807LL
 // PPC-AIX:#define __LONG_MAX__ 2147483647L
 // PPC-AIX-NOT:#define __LP64__ 1
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -172,6 +172,10 @@
   Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
+  if (getTriple().isOSAIX() && LongDoubleWidth == 64) {
+Builder.defineMacro("__LONGDOUBLE64");
+  }
+
   // Define this for elfv2 (64-bit only) or 64-bit darwin.
   if (ABI == "elfv2" ||
   (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -512,6 +512,7 @@
 // PPC-AIX:#define __LDBL_MIN_10_EXP__ (-307)
 // PPC-AIX:#define __LDBL_MIN_EXP__ (-1021)
 // PPC-AIX:#define __LDBL_MIN__ 2.2250738585072014e-308L
+// PPC-AIX:#define __LONGDOUBLE64 1
 // PPC-AIX:#define __LONG_LONG_MAX__ 9223372036854775807LL
 // PPC-AIX:#define __LONG_MAX__ 2147483647L
 // PPC-AIX-NOT:#define __LP64__ 1
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -172,6 +172,10 @@
   Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
+  if (getTriple().isOSAIX() && LongDoubleWidth == 64) {
+Builder.defineMacro("__LONGDOUBLE64");
+  }
+
   // Define this for elfv2 (64-bit only) or 64-bit darwin.
   if (ABI == "elfv2" ||
   (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102875: [PowerPC] Add PowerPC compare and multiply related builtins and instrinsics for XL compatibility

2021-07-06 Thread Victor Huang via Phabricator via cfe-commits
NeHuang updated this revision to Diff 356701.
NeHuang marked 4 inline comments as done.
NeHuang added a comment.

Address review comments on the test case. Target cpu sema checking covered in 
front end test cases. will keep current coverage in backend test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102875/new/

https://reviews.llvm.org/D102875

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-multiply-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-multiply.c
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr9-64bit.c
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr9-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr9.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-compare-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-compare.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply.ll
@@ -0,0 +1,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+
+define dso_local signext i32 @test_builtin_ppc_mulhw(i32 %a, i32%b) {
+; CHECK-32-LABEL: test_builtin_ppc_mulhw:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:mulhw 3, 3, 4
+; CHECK-32-NEXT:blr
+;
+; CHECK-64-LABEL: test_builtin_ppc_mulhw:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:mulhw 3, 3, 4
+; CHECK-64-NEXT:extsw 3, 3
+; CHECK-64-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mulhw(i32 %a, i32 %b)
+  ret i32 %0
+}
+
+declare i32 @llvm.ppc.mulhw(i32, i32)
+
+define dso_local zeroext i32 @test_builtin_ppc_mulhwu(i32 %a, i32%b) {
+; CHECK-32-LABEL: test_builtin_ppc_mulhwu:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:mulhwu 3, 3, 4
+; CHECK-32-NEXT:blr
+;
+; CHECK-64-LABEL: test_builtin_ppc_mulhwu:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:mulhwu 3, 3, 4
+; CHECK-64-NEXT:clrldi 3, 3, 32
+; CHECK-64-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mulhwu(i32 %a, i32 %b)
+  ret i32 %0
+}
+
+declare i32 @llvm.ppc.mulhwu(i32, i32)
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply-64bit-only.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply-64bit-only.ll
@@ -0,0 +1,68 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+
+define dso_local i64 @test_builtin_ppc_mulhd(i64 %a, i64 %b) {
+; CHECK-LABEL: test_builtin_ppc_mulhd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mulhd 3, 3, 4
+; CHECK-NEXT:blr
+entry:
+  %0 = call i64 @llvm.ppc.mulhd(i64 %a, i64 %b)
+  ret i64 %0
+}
+
+declare i64 @llvm.ppc.mulhd(i64, i64)
+
+define dso_local i64 @test_builtin_ppc_mulhdu(i64 %a, i64 %b) {
+; CHECK-LABEL: test_builtin_ppc_mulhdu:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mulhdu 3, 3, 4
+; CHECK-NEXT:blr
+entry:
+  %0 = call i64 @llvm.ppc.mulhdu(i64 %a, i64 %b)
+  ret i64 %0
+}
+
+declare i64 @llvm.ppc.mulhdu(i64, i64)
+
+define dso_local i64 @test_builtin_ppc_maddhd(i64 %a, i64 %b, i64 %c) {
+; CHECK-LABEL: test_builtin_ppc_maddhd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:maddhd 3, 3, 4, 5
+; CHECK-NEXT:blr
+entry:
+  %0 = call i64 @llvm.ppc.maddhd(i64 %a, i64 %b, i64 %c)
+  ret i64 %0
+}
+
+declare i64 @llvm.ppc.maddhd(i64, i64, i64)
+
+define dso_local i64 @test_builtin_ppc_maddhdu(i64 %a, i64 %b, i64 %c) {
+; CHECK-LABEL: test_builtin_ppc_maddhdu:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:maddhdu 3, 3, 4, 5
+; CHECK-NEXT:blr
+entry:
+  %0 = call i64 @llvm.ppc.maddhd

[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-07-06 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: hokein.
adamcz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Undeduced fields in a valid record cause crashes when trying to obtain
the size and/or layout of the record.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105478

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/cxx11-crashes.cpp


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -104,3 +104,20 @@
   bool baz() { return __has_nothrow_constructor(B); }
   bool qux() { return __has_nothrow_copy(B); }
 }
+
+namespace undeduced_field {
+template
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+  Foo::type B;  // The type of B is also undeduced (wrapped in 
Elaborated).
+};
+
+// This used to crash when trying to get the layout of B.
+Bar x;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17498,8 +17498,13 @@
 Record->setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
 }
 
-if (Record && FD->getType().isVolatileQualified())
-  Record->setHasVolatileMember(true);
+if (Record) {
+  if (FD->getType().isVolatileQualified())
+Record->setHasVolatileMember(true);
+  if (const auto *T = FD->getType()->getUnqualifiedDesugaredType())
+if (T->isUndeducedType())
+  Record->setInvalidDecl();
+}
 // Keep track of the number of named members.
 if (FD->getIdentifier())
   ++NumNamedMembers;


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -104,3 +104,20 @@
   bool baz() { return __has_nothrow_constructor(B); }
   bool qux() { return __has_nothrow_copy(B); }
 }
+
+namespace undeduced_field {
+template
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+  Foo::type B;  // The type of B is also undeduced (wrapped in Elaborated).
+};
+
+// This used to crash when trying to get the layout of B.
+Bar x;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17498,8 +17498,13 @@
 Record->setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
 }
 
-if (Record && FD->getType().isVolatileQualified())
-  Record->setHasVolatileMember(true);
+if (Record) {
+  if (FD->getType().isVolatileQualified())
+Record->setHasVolatileMember(true);
+  if (const auto *T = FD->getType()->getUnqualifiedDesugaredType())
+if (T->isUndeducedType())
+  Record->setInvalidDecl();
+}
 // Keep track of the number of named members.
 if (FD->getIdentifier())
   ++NumNamedMembers;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104420: thread_local support for AIX

2021-07-06 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 356705.
jamieschmeiser added a comment.

Fix formatting problem.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104420/new/

https://reviews.llvm.org/D104420

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-reference.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-visibility.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp

Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -9,11 +9,13 @@
 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -femulated-tls -emit-llvm %s -o - \
 // RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple powerpc64-unknown-aix-xcoff | FileCheck --check-prefix=CHECK --check-prefix=AIX %s
 
 int f();
 int g();
 
 // LINUX-DAG: @a ={{.*}} thread_local global i32 0
+// AIX-DAG: @a ={{.*}} thread_local global i32 0
 // DARWIN-DAG: @a = internal thread_local global i32 0
 thread_local int a = f();
 extern thread_local int b;
@@ -24,6 +26,7 @@
 
 struct U { static thread_local int m; };
 // LINUX-DAG: @_ZN1U1mE ={{.*}} thread_local global i32 0
+// AIX-DAG: @_ZN1U1mE ={{.*}} thread_local global i32 0
 // DARWIN-DAG: @_ZN1U1mE = internal thread_local global i32 0
 thread_local int U::m = f();
 
@@ -90,8 +93,10 @@
 // CHECK-DAG: @llvm.global_ctors = appending global {{.*}} @[[GLOBAL_INIT:[^ ]*]]
 
 // LINUX-DAG: @_ZTH1a ={{.*}} alias void (), void ()* @__tls_init
+// AIX-DAG: @_ZTH1a ={{.*}} alias void (), void ()* @__tls_init
 // DARWIN-DAG: @_ZTH1a = internal alias void (), void ()* @__tls_init
 // LINUX-DAG: @_ZTHN1U1mE ={{.*}} alias void (), void ()* @__tls_init
+// AIX-DAG: @_ZTHN1U1mE ={{.*}} alias void (), void ()* @__tls_init
 // DARWIN-DAG: @_ZTHN1U1mE = internal alias void (), void ()* @__tls_init
 // CHECK-DAG: @_ZTHN1VIiE1mE = linkonce_odr alias void (), void ()* @[[V_M_INIT:[^, ]*]]
 // CHECK-DAG: @_ZTHN1XIiE1mE = linkonce_odr alias void (), void ()* @[[X_M_INIT:[^, ]*]]
@@ -106,16 +111,16 @@
 // Individual variable initialization functions:
 
 // CHECK: define {{.*}} @[[A_INIT:.*]]()
-// CHECK: call i32 @_Z1fv()
+// CHECK: call{{.*}} i32 @_Z1fv()
 // CHECK-NEXT: store i32 {{.*}}, i32* @a, align 4
 
 // CHECK-LABEL: define{{.*}} i32 @_Z1fv()
 int f() {
   // CHECK: %[[GUARD:.*]] = load i8, i8* @_ZGVZ1fvE1n, align 1
   // CHECK: %[[NEED_INIT:.*]] = icmp eq i8 %[[GUARD]], 0
-  // CHECK: br i1 %[[NEED_INIT]]
+  // CHECK: br i1 %[[NEED_INIT]]{{.*}}
 
-  // CHECK: %[[CALL:.*]] = call i32 @_Z1gv()
+  // CHECK: %[[CALL:.*]] = call{{.*}} i32 @_Z1gv()
   // CHECK: store i32 %[[CALL]], i32* @_ZZ1fvE1n, align 4
   // CHECK: store i8 1, i8* @_ZGVZ1fvE1n
   // CHECK: br label
@@ -127,54 +132,67 @@
 
 // CHECK: define {{.*}} @[[C_INIT:.*]]()
 // LINUX: call i32* @_ZTW1b()
+// AIX: call i32* @_ZTW1b()
 // DARWIN: call cxx_fast_tlscc i32* @_ZTW1b()
 // CHECK-NEXT: load i32, i32* %{{.*}}, align 4
 // CHECK-NEXT: store i32 %{{.*}}, i32* @c, align 4
 
 // LINUX-LABEL: define linkonce_odr hidden i32* @_ZTW1b()
+// AIX-LABEL: define linkonce_odr hidden i32* @_ZTW1b()
 // LINUX: br i1 icmp ne (void ()* @_ZTH1b, void ()* null),
 // not null:
 // LINUX: call void @_ZTH1b()
+// AIX-NOT: br i1 icmp ne (void ()* @_ZTH1b, void ()* null),
+// AIX: call void @_ZTH1b()
 // LINUX: br label
 // finally:
 // LINUX: ret i32* @b
+// AIX: ret i32* @b
 // DARWIN-LABEL: declare cxx_fast_tlscc i32* @_ZTW1b()
 // There is no definition of the thread wrapper on Darwin for external TLV.
 
 // CHECK: define {{.*}} @[[D_INIT:.*]]()
-// CHECK: call i32 @_Z1gv()
+// CHECK: call{{.*}} i32 @_Z1gv()
 // CHECK-NEXT: store i32 %{{.*}}, i32* @_ZL1d, align 4
 
 // CHECK: define {{.*}} @[[U_M_INIT:.*]]()
-// CHECK: call i32 @_Z1fv()
+// CHECK: call{{.*}} i32 @_Z1fv()
 // CHECK-NEXT: store i32 %{{.*}}, i32* @_ZN1U1mE, align 4
 
 // CHECK: define {{.*}} @[[E_INIT:.*]]()
 // LINUX: call i32* @_ZTWN1VIiE1mE()
+// AIX: call i32* @_ZTWN1VIiE1mE()
 // DARWIN: call cxx_fast_tlscc i32* @_ZTWN1VIiE1mE()
 // CHECK-NEXT: load i32, i32* %{{.*}}, align 4
 // LINUX: call {{.*}}* @_ZTWN1XIiE1mE()
+// AIX: call {{.*}}* @_ZTWN1XIiE1mE()
 // DARWIN: call cxx_fast_tlscc {{.*}}* @_ZTWN1XIiE1mE()
 // CHECK: store {{.*}} @e
 
 // LINUX-LABEL: define weak_odr hidden i32* @_ZTWN1VIiE1mE()
+// AIX-LABEL: define weak_odr hidden i32* @_ZTWN1VIiE1mE()
 // DARWIN-LABEL: define weak_odr hidden cxx_fast_tlscc i32* @_ZTWN1VIiE1mE()
 // LINUX: call void @_ZTHN1VIiE1mE()
+// AIX: call void @_ZTHN1VIiE1mE()
 // DARWIN: call cxx_fast_tlscc void @_ZTHN1VIiE1mE()
 // CHECK: ret i32* @_ZN1VIiE1mE
 
 // LINUX-LABEL: define weak_odr hidden i32* @_ZTWN1WIiE1mE

[PATCH] D105479: [clang-tidy] [PR50069] readability-braces-around-statements doesn't work well with [[likely]] [[unlikely]]

2021-07-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: alexfh, njames93, aaron.ballman.
MyDeveloperDay added projects: clang-tools-extra, clang.
Herald added subscribers: jdoerfert, xazax.hun.
MyDeveloperDay requested review of this revision.

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

When clang-tidy sees:

  if (true) [[unlikely]] {
  ...
  }

It thinks the braces are missing and add them again.

  if (true)  { [[unlikely]] {
  ...
}
  }

This revision aims to prevent that incorrect code generation


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105479

Files:
  clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy  -std=c++20-or-later %s 
readability-braces-around-statements %t
+
+void test(bool b) {
+  if (b) {
+return;
+  }
+  if (b) [[likely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} {
+return;
+  }
+  if (b) [[unlikely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  }
+}
Index: clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -193,7 +193,7 @@
   // token, the check inserts "\n}" right before that token.
   // 3) Otherwise the check finds the end of line (possibly after some block or
   // line comments) and inserts "\n}" right before that EOL.
-  if (!S || isa(S)) {
+  if (!S || isa(S) || isa(S)) {
 // Already inside braces.
 return false;
   }


Index: clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy  -std=c++20-or-later %s readability-braces-around-statements %t
+
+void test(bool b) {
+  if (b) {
+return;
+  }
+  if (b) [[likely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} {
+return;
+  }
+  if (b) [[unlikely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  }
+}
Index: clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -193,7 +193,7 @@
   // token, the check inserts "\n}" right before that token.
   // 3) Otherwise the check finds the end of line (possibly after some block or
   // line comments) and inserts "\n}" right before that EOL.
-  if (!S || isa(S)) {
+  if (!S || isa(S) || isa(S)) {
 // Already inside braces.
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103587: [AIX] Define __TOS_AIX__ predefined macro

2021-07-06 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm accepted this revision.
cebowleratibm added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103587/new/

https://reviews.llvm.org/D103587

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


[PATCH] D104858: [OpenCL][ARM] Fix ICE when compiling a kernel

2021-07-06 Thread Pekka Jääskeläinen via Phabricator via cfe-commits
pekka.jaaskelainen added a comment.



> Ok, thanks for clarification. Does it mean there is something we need to add 
> to LLVM somewhere to make it work correctly? Would it be specific to Arm or 
> generally for all CPU targets?

To my understanding, what is required is to keep SPIR_KERNEL CC working for Arm 
since that is the generic way for PoCL supports clSetKernelArg for CPU targets 
by default. I have been under impression that it has worked so far for Arm, but 
I haven't tested it personally, and PoCL still lacks an official Arm 
maintainer, so cannot say for sure.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104858/new/

https://reviews.llvm.org/D104858

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


[PATCH] D105375: [OPENMP]Remove const firstprivate allocation as a variable in a constant space.

2021-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 356715.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105375/new/

https://reviews.llvm.org/D105375

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp

Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -55,12 +55,11 @@
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l79]] = internal global [[TTII]] zeroinitializer
 // CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}, i[[SZ:32|64]] 4]
 // CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 49, i64 288]
 // CHECK-DAG:  [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
 // CHECK-DAG:  [[SIZET3:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i{{32|64}} 0, i{{32|64}} 8]
-// CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 37]
+// CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 161]
 // CHECK-DAG:  [[MAPT4:@.+]] = private unnamed_addr constant [5 x i64] [i64 547, i64 288, i64 800, i64 800, i64 161]
 // CHECK-DAG:  [[SIZET5:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ]] 4, i[[SZ]] 1, i[[SZ]] 40]
 // CHECK-DAG:  [[MAPT5:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 288, i64 161]
@@ -92,6 +91,7 @@
   // CHECK:  [[SSTACK:%.+]] = alloca i8*,
   // CHECK:  [[C:%.+]] = alloca [5 x [10 x double]],
   // CHECK:  [[D:%.+]] = alloca [[TT]],
+  // CHECK:  [[FP_E:%.+]] = alloca [[TTII]],
   // CHECK:  [[P:%.+]] = alloca i32*, align 64
   // CHECK:  [[ACAST:%.+]] = alloca i{{[0-9]+}},
   // CHECK:  [[BASE_PTR_ARR:%.+]] = alloca [3 x i8*],
@@ -347,8 +347,6 @@
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
@@ -367,9 +365,8 @@
   // CHECK: {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG3]], i8** [[PTR_GEP_ARG3]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET3]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT3]], i32 0, i32 0), i8** null, i8** null)
 
   // TCHECK:  define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[PTR_ADDR:%.+]] = alloca double*,
-  // TCHECK-NOT: alloca [[TTII]],
+  // TCHECK: alloca [[TTII]],
   // TCHECK-NOT: alloca double*,
   // TCHECK:  store double* [[PTR_IN]], double** [[PTR_ADDR]],
   // TCHECK-NOT: store double* %
Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -18,9 +18,6 @@
 // TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l30 = internal addrspace(4) global [[TTII]] zeroinitializer
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIiiE_t_l143 = internal addrspace(4) global [[TTII]] zeroinitializer
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIccE_t_l143 = internal addrspace(4) global [[TTIC]] zeroinitializer
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;
@@ -37,11 +34,9 @@
   }
 
   // TCHECK:  define {{.*}}void @__omp_offloading_{{.+}}([10 x float] addrspace(1)* noalias [[B_IN:%.+]], i{{[0-9]+}} [[A_IN:%.+]], [[TTII]]* noalias [[E_IN:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
-  // TCHECK-NOT: alloca [[TTII]],
-  // TCHECK-NOT: alloca i{{[0-9]+}},
-  // TCHECK-64:  call void @llvm.dbg.declare(metadata [10 x float] addrspace(1)** %{{.+}}, met

[PATCH] D105360: [PowerPC] Fix popcntb XL Compat Builtin for 32bit

2021-07-06 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 356719.
quinnp added a comment.

Addressing review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105360/new/

https://reviews.llvm.org/D105360

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-sync.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/P9InstrResources.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-32.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.ll
+++ /dev/null
@@ -1,74 +0,0 @@
-; RUN: llc -verify-machineinstrs -mtriple=powerpcle-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-
-define dso_local void @test_builtin_ppc_eieio() #0 {
-; CHECK-LABEL: test_builtin_ppc_eieio
-
-entry:
-  call void @llvm.ppc.eieio()
-; CHECK: ori 2, 2, 0
-; CHECK-NEXT: ori 2, 2, 0
-; CHECK-NEXT: eieio
- 
-  ret void
-}
-
-declare void @llvm.ppc.eieio() #2
-
-define dso_local void @test_builtin_ppc_iospace_eieio() #0 {
-; CHECK-LABEL: test_builtin_ppc_iospace_eieio
-
-entry:
-  call void @llvm.ppc.iospace.eieio()
-; CHECK: ori 2, 2, 0
-; CHECK-NEXT: ori 2, 2, 0
-; CHECK-NEXT: eieio
- 
-  ret void
-}
-
-declare void @llvm.ppc.iospace.eieio() #2
-
-define dso_local void @test_builtin_ppc_iospace_lwsync() #0 {
-; CHECK-LABEL: test_builtin_ppc_iospace_lwsync
-
-entry:
-  call void @llvm.ppc.iospace.lwsync()
-; CHECK: lwsync
-
-  ret void
-}
-
-declare void @llvm.ppc.iospace.lwsync() #2
-
-define dso_local void @test_builtin_ppc_iospace_sync() #0 {
-; CHECK-LABEL: test_builtin_ppc_iospace_sync
-
-entry:
-  call void @llvm.ppc.iospace.sync()
-; CHECK: sync
-
-  ret void
-}
-
-declare void @llvm.ppc.iospace.sync() #2
-
-define dso_local void @test_builtin_ppc_icbt() #0 {
-; CHECK-LABEL: test_builtin_ppc_icbt
-
-entry:
-  %a = alloca i8*, align 8
-  %0 = load i8*, i8** %a, align 8
-  call void @llvm.ppc.icbt(i8* %0)
-; CHECK: icbt 0, 0, 3
-
-  ret void
-}
-
-declare void @llvm.ppc.icbt(i8*) #2
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
@@ -0,0 +1,116 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
+; RUN: --ppc-asm-full-reg-names -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
+; RUN: --ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN: --ppc-asm-full-reg-names -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX
+
+define dso_local i64 @test_builtin_ppc_popcntb_i64(i64 %a) local_unnamed_addr {
+; CHECK-LABEL: test_builtin_ppc_popcntb_i64:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:popcntb r3, r3
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_builtin_ppc_popcntb_i64:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:popcntb 3, 3
+; CHECK-AIX-NEXT:blr
+entry:
+  %popcntb = tail call i64 @llvm.ppc.popcntb.i64.i64(i64 %a)
+  ret i64 %popcntb
+}
+declare i64 @llvm.ppc.popcntb.i64.i64(i64)
+
+define dso_local void @test_builtin_ppc_eieio() {
+; CHECK-LABEL: test_builtin_ppc_eieio:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:ori r2, r2, 0
+; CHECK-NEXT:ori r2, r2, 0
+; CHECK-NEXT:eieio
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_builtin_ppc_eieio:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:ori 2, 2, 0
+; CHECK-AIX-NEXT:ori 2, 2, 0
+; CHECK-AIX-NEXT:eieio
+; CHECK-AIX-NEXT:blr
+entry:
+  call void @llvm.ppc.eieio()
+  ret void
+}
+declare void @llvm.ppc.eieio()
+
+define dso_local void @test_builtin_ppc_iospace_eieio() {
+; CHECK-LABEL: test_builtin_ppc_iospace_eieio:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:ori r2, r2, 0
+; CHECK-NEXT:ori r2, r2, 0
+; CHECK-NEXT:eieio
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_builtin_ppc_iospace_eieio:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:ori 2, 2, 0
+; CHECK-AIX-NEXT:ori 2, 2, 0
+; CHECK-AIX-NEXT:eieio
+; CHECK-AIX-NEXT:blr
+entry:
+  call void @llvm.ppc.

[PATCH] D105135: [Internalize] Preserve variables externally initialized.

2021-07-06 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 356721.
hliao added a comment.

Kindly PING for review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105135/new/

https://reviews.llvm.org/D105135

Files:
  clang/test/CodeGenCUDA/host-used-device-var.cu
  clang/test/CodeGenCUDA/unused-global-var.cu
  llvm/lib/Transforms/IPO/Internalize.cpp
  llvm/test/Transforms/Internalize/externally-initialized.ll


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggests, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast(&GV))
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -17,12 +17,6 @@
 
 // Check unused device/constant variables are eliminated.
 
-// NEGCHK-NOT: @v1
-__device__ int v1;
-
-// NEGCHK-NOT: @v2
-__constant__ int v2;
-
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -17,12 +17,6 @@
 
 // Check device variables used by neither host nor device functioins are not 
kept.
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;
-
-// DEV-NEG-NOT: @v2
-__constant__ int v2;
-
 // DEV-NEG-NOT: @_ZL2v3
 static __device__ int v3;
 


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggests, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast(&GV))
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -17,12 +17,6 @@
 
 // Check unused device/constant variables are eliminated.
 
-// NEGCHK-NOT: @v1
-__device__ int v1;
-
-// NEGCHK-NOT: @v2
-__constant__ int v2;
-
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -17,12 +17,6 @@
 
 // Check device variables used by neither host nor device functioins are not kept.
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;
-
-// DEV-NEG-NOT: @v2
-__constant__ int v2;
-
 // DEV-NEG-NOT: @_ZL2v3
 static __device__ int v3;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:84
   "Enable SSE 4.2 instructions",
-  [FeatureSSE41]>;
+  [FeatureSSE41, FeatureCRC32]>;
 // The MMX subtarget feature is separate from the rest of the SSE features

tianqing wrote:
> craig.topper wrote:
> > Doesn't this make -mno-crc32 disable sse4.2? Is that what we want?
> > 
> > Or should we be doing this like popcnt where we loosely enable it at the 
> > end of X86TargetInfo::initFeatureMap
> It does. But it's not a big deal in this case. The scenario described in the 
> commit message doesn't require crc32 capable to be disabled separately.
What does gcc do?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105462/new/

https://reviews.llvm.org/D105462

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


[PATCH] D99436: [OPENMP]Fix PR49366: crash on VLAs in task untied regions.

2021-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 356726.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99436/new/

https://reviews.llvm.org/D99436

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp

Index: clang/test/OpenMP/taskloop_loop_messages.cpp
===
--- clang/test/OpenMP/taskloop_loop_messages.cpp
+++ clang/test/OpenMP/taskloop_loop_messages.cpp
@@ -691,7 +691,7 @@
 
 void test_loop_eh() {
   const int N = 100;
-  float a[N], b[N], c[N];
+  float a[N], b[N], c[N]; // expected-note {{declared here}}
 #pragma omp parallel
 #pragma omp taskloop
   for (int i = 0; i < 10; i++) {
@@ -729,6 +729,13 @@
   void g() { throw 0; }
 };
   }
+// expected-error@+5 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+4 {{read of non-constexpr variable 'c' is not allowed in a constant expression}}
+#pragma omp taskloop untied
+  {
+  for (int i = 0; i < 10; ++i)
+int array[(int)c[0]];
+  }
 }
 
 void test_loop_firstprivate_lastprivate() {
Index: clang/test/OpenMP/task_messages.cpp
===
--- clang/test/OpenMP/task_messages.cpp
+++ clang/test/OpenMP/task_messages.cpp
@@ -173,7 +173,7 @@
   int &b = a;
   S sa;
   S &sb = sa;
-  int r;
+  int r; // expected-note {{declared here}}
 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
   foo();
 #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
@@ -330,6 +330,12 @@
 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
 #pragma omp task mergeable mergeable
   ++r;
+// expected-error@+4 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+3 {{read of non-const variable 'r' is not allowed in a constant expression}}
+#pragma omp task untied
+  {
+int array[r];
+  }
   volatile omp_event_handle_t evt;
   omp_event_handle_t sevt;
   const omp_event_handle_t cevt = evt;
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2442,6 +2442,9 @@
   } else if (isSFINAEContext()) {
 VLADiag = diag::err_vla_in_sfinae;
 VLAIsError = true;
+  } else if (getLangOpts().OpenMP && isInOpenMPTaskUntiedContext()) {
+VLADiag = diag::err_openmp_vla_in_task_untied;
+VLAIsError = true;
   } else {
 VLADiag = diag::ext_vla;
 VLAIsError = false;
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -174,6 +174,7 @@
 bool HasMutipleLoops = false;
 const Decl *PossiblyLoopCounter = nullptr;
 bool NowaitRegion = false;
+bool UntiedRegion = false;
 bool CancelRegion = false;
 bool LoopStart = false;
 bool BodyComplete = false;
@@ -841,6 +842,15 @@
   return Parent->NowaitRegion;
 return false;
   }
+  /// Marks current region as untied (it has a 'untied' clause).
+  void setUntiedRegion(bool IsUntied = true) {
+getTopOfStack().UntiedRegion = IsUntied;
+  }
+  /// Return true if current region is untied.
+  bool isUntiedRegion() const {
+const SharingMapTy *Top = getTopOfStackOrNull();
+return Top ? Top->UntiedRegion : false;
+  }
   /// Marks parent region as cancel region.
   void setParentCancelRegion(bool Cancel = true) {
 if (SharingMapTy *Parent = getSecondOnStackOrNull())
@@ -2154,6 +2164,11 @@
   return DSAStack->getNestingLevel();
 }
 
+bool Sema::isInOpenMPTaskUntiedContext() const {
+  return isOpenMPTaskingDirective(DSAStack->getCurrentDirective()) &&
+ DSAStack->isUntiedRegion();
+}
+
 bool Sema::isInOpenMPTargetExecutionDirective() const {
   return (isOpenMPTargetExecutionDirective(DSAStack->getCurrentDirective()) &&
   !DSAStack->isClauseParsingMode()) ||
@@ -15046,6 +15061,7 @@
 
 OMPClause *Sema::ActOnOpenMPUntiedClause(SourceLocation StartLoc,
  SourceLocation EndLoc) {
+  DSAStack->setUntiedRegion();
   return new (Context) OMPUntiedClause(StartLoc, EndLoc);
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10532,6 +10532,10 @@
   void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller,
  const FunctionDecl *Callee,
  SourceLocation Loc);
+
+  /// Return tru

[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-07-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D99005#2859476 , @aaron.ballman 
wrote:

> https://godbolt.org/z/dvEbv7GKo
>
> I'm not certain if this is as expected of an issue, though. In the original 
> example, `C` carried state that was set up after initialization but was 
> relying on the fallback to the non-idiomatic copy constructor when doing the 
> `throw`. WDYT?

Yeah that is the equivalent scenario for `throw`, we treat c1 as a temporary 
there. The same workaround applies, you can static cast to non-const lvalue 
reference.

As far as the implementation is concerned, it is following the proposal to the 
letter here.
And as I understand it, although I am not the author of the proposal (which is 
@Quuxplusone), the committee agrees that this breakage is a good thing.

In D99005#2859652 , @aaron.ballman 
wrote:

> I'm not certain it's reasonable to wait for MSVC STL to change as that leaves 
> every existing user of older MSVC STLs out in the cold. This is causing some 
> significant regressions at Intel, to the extent that I wonder if this should 
> be temporarily reverted until the MSVC STL headers can be compiled again.

That does interfere with the wishes of the committee to get implementation 
experience with this.
I am not saying one way or another, but would leaving this effect on by 
default, but providing a command line flag to turn it off, be a reasonable 
option on the table?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99005/new/

https://reviews.llvm.org/D99005

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


[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-06 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:84
   "Enable SSE 4.2 instructions",
-  [FeatureSSE41]>;
+  [FeatureSSE41, FeatureCRC32]>;
 // The MMX subtarget feature is separate from the rest of the SSE features

craig.topper wrote:
> tianqing wrote:
> > craig.topper wrote:
> > > Doesn't this make -mno-crc32 disable sse4.2? Is that what we want?
> > > 
> > > Or should we be doing this like popcnt where we loosely enable it at the 
> > > end of X86TargetInfo::initFeatureMap
> > It does. But it's not a big deal in this case. The scenario described in 
> > the commit message doesn't require crc32 capable to be disabled separately.
> What does gcc do?
```
[hjl@gnu-skx-1 gcc]$ cat /tmp/x.c
#include 

int
foo (int x, char c)
{
  return __crc32b (x, c);
}
[hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S -msse4.2 
[hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S -mcrc32
[hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S -msse4.2 
-mno-crc32
In file included from 
/usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/x86gprintrin.h:27,
 from 
/usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/x86intrin.h:27,
 from /tmp/x.c:1:
/tmp/x.c: In function ??foo??:
/usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/ia32intrin.h:63:1:
 error: inlining failed in call to ??always_inline?? ??__crc32b??: target 
specific option mismatch
   63 | __crc32b (unsigned int __C, unsigned char __V)
  | ^~~~
/tmp/x.c:6:10: note: called from here
6 |   return __crc32b (x, c);
  |  ^~~
[hjl@gnu-skx-1 gcc]$ 
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105462/new/

https://reviews.llvm.org/D105462

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


[PATCH] D105408: [clang-format] Pass a TextDiagnosticPrinter when we can not create tempory file.

2021-07-06 Thread BRAMI Élie via Phabricator via cfe-commits
Et7f3 added a comment.

Mb I just looked in driver how to setup diagnostics (which included frontend).

Ok so I see 2 options:

- move TextDiagnosticsPrinter in clangBasic
- Use SMDiagnostic like clang/tools/clang-format/ClangFormat.cpp:324 but it 
seem to need a SMLoc so not really adapted.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105408/new/

https://reviews.llvm.org/D105408

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


[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:84
   "Enable SSE 4.2 instructions",
-  [FeatureSSE41]>;
+  [FeatureSSE41, FeatureCRC32]>;
 // The MMX subtarget feature is separate from the rest of the SSE features

hjl.tools wrote:
> craig.topper wrote:
> > tianqing wrote:
> > > craig.topper wrote:
> > > > Doesn't this make -mno-crc32 disable sse4.2? Is that what we want?
> > > > 
> > > > Or should we be doing this like popcnt where we loosely enable it at 
> > > > the end of X86TargetInfo::initFeatureMap
> > > It does. But it's not a big deal in this case. The scenario described in 
> > > the commit message doesn't require crc32 capable to be disabled 
> > > separately.
> > What does gcc do?
> ```
> [hjl@gnu-skx-1 gcc]$ cat /tmp/x.c
> #include 
> 
> int
> foo (int x, char c)
> {
>   return __crc32b (x, c);
> }
> [hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S -msse4.2 
> [hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S -mcrc32
> [hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S -msse4.2 
> -mno-crc32
> In file included from 
> /usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/x86gprintrin.h:27,
>  from 
> /usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/x86intrin.h:27,
>  from /tmp/x.c:1:
> /tmp/x.c: In function ??foo??:
> /usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/ia32intrin.h:63:1:
>  error: inlining failed in call to ??always_inline?? ??__crc32b??: target 
> specific option mismatch
>63 | __crc32b (unsigned int __C, unsigned char __V)
>   | ^~~~
> /tmp/x.c:6:10: note: called from here
> 6 |   return __crc32b (x, c);
>   |  ^~~
> [hjl@gnu-skx-1 gcc]$ 
> ```
What does gcc do for an sse4.2 intrinsic that isn't crc32 with "-msse4.2 
-mno-crc32"?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105462/new/

https://reviews.llvm.org/D105462

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


[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-06 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:84
   "Enable SSE 4.2 instructions",
-  [FeatureSSE41]>;
+  [FeatureSSE41, FeatureCRC32]>;
 // The MMX subtarget feature is separate from the rest of the SSE features

craig.topper wrote:
> hjl.tools wrote:
> > craig.topper wrote:
> > > tianqing wrote:
> > > > craig.topper wrote:
> > > > > Doesn't this make -mno-crc32 disable sse4.2? Is that what we want?
> > > > > 
> > > > > Or should we be doing this like popcnt where we loosely enable it at 
> > > > > the end of X86TargetInfo::initFeatureMap
> > > > It does. But it's not a big deal in this case. The scenario described 
> > > > in the commit message doesn't require crc32 capable to be disabled 
> > > > separately.
> > > What does gcc do?
> > ```
> > [hjl@gnu-skx-1 gcc]$ cat /tmp/x.c
> > #include 
> > 
> > int
> > foo (int x, char c)
> > {
> >   return __crc32b (x, c);
> > }
> > [hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S 
> > -msse4.2 
> > [hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S -mcrc32
> > [hjl@gnu-skx-1 gcc]$ /usr/gcc-12.0.0-x32/bin/gcc -S -O2 /tmp/x.c -S 
> > -msse4.2 -mno-crc32
> > In file included from 
> > /usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/x86gprintrin.h:27,
> >  from 
> > /usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/x86intrin.h:27,
> >  from /tmp/x.c:1:
> > /tmp/x.c: In function ??foo??:
> > /usr/gcc-12.0.0-x32/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/ia32intrin.h:63:1:
> >  error: inlining failed in call to ??always_inline?? ??__crc32b??: target 
> > specific option mismatch
> >63 | __crc32b (unsigned int __C, unsigned char __V)
> >   | ^~~~
> > /tmp/x.c:6:10: note: called from here
> > 6 |   return __crc32b (x, c);
> >   |  ^~~
> > [hjl@gnu-skx-1 gcc]$ 
> > ```
> What does gcc do for an sse4.2 intrinsic that isn't crc32 with "-msse4.2 
> -mno-crc32"?
-mno-crc32 has no impact on non-crc32 intrinsics.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105462/new/

https://reviews.llvm.org/D105462

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


[PATCH] D105477: [AIX] Define __LONGDOUBLE64 macro

2021-07-06 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm requested changes to this revision.
cebowleratibm added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Basic/Targets/PPC.cpp:175
 
+  if (getTriple().isOSAIX() && LongDoubleWidth == 64) {
+Builder.defineMacro("__LONGDOUBLE64");

I suggest querying the -mlong-double-64 option and asserting that the 
LongDoubleWidth is 64.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105477/new/

https://reviews.llvm.org/D105477

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


[PATCH] D99350: [OPENMP]Fix PR49649: The introduction of $ref globals is not always valid.

2021-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 356737.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99350/new/

https://reviews.llvm.org/D99350

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_codegen.cpp


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* 
[[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void 
@{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10667,11 +10667,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* [[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10667,11 +10667,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-07-06 Thread Josh Haberman via Phabricator via cfe-commits
haberman added a comment.

@theraven: Can you post a minimal repro of your case? I don't follow your 
distinction between "caller" and "enclosing function."

Regarding `noreturn` and `always_inline`: maybe the rules for `musttail` could 
be relaxed in cases like the one you mention, but it would require changing the 
backend (LLVM). Here I changed the front-end only and used LLVM's existing 
`musttail` support, which meant accepting its existing limitations 
.

I would love to see an exception for `always_inline`: my use case would benefit 
greatly from this. In my own project I had to change a bunch of `always_inline` 
functions to macros to work around this rule. Unfortunately this is complicated 
by the fact that `always_inline` does not actually guarantee that inlining 
occurs 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99517/new/

https://reviews.llvm.org/D99517

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


[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-06 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

I found some issues. Working on improvement.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2797-2799
+ProgramStateRef
+RangeConstraintManager::updateExistingConstraints(ProgramStateRef State,
+  SymbolRef Sym, RangeSet R) {

vsavchenko wrote:
> OK, but I still don't understand one thing.
> Here you go over all "smaller" types and artificially create constraints for 
> them, and at the same time in `VisitSymbolCast` you do the opposite 
> operation?  Why?  Shouldn't the map have constraints for smaller types 
> already because of this action?  Why do we need to do both?
> 
I've been preparing an answer for you, but suddenly you inspired me on some 
impovements. Thanks.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2801-2802
+  // Get a root symbol in case of SymbolCast.
+  while (isa(Sym))
+Sym = cast(Sym)->getOperand();
+

vsavchenko wrote:
> This looks like a pattern and we should probably make into a method of 
> `SymbolCast`
I did it :) but refused. It will just turn into:
```
  if (isa(Sym))
Sym = cast(Sym)->getRootOperand();
```
It looks pretty the same and brings no benefit IMO, does it?
Every time I used `getRootOperand` I also needed some additional traverse 
through the types te get some another information, so I couldn't avoid the 
`while` loop there. So I decided not to introduce a new method in `SymbolCast`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-07-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D99005#2859886 , @mizvekov wrote:

> In D99005#2859476 , @aaron.ballman 
> wrote:
>
>> https://godbolt.org/z/dvEbv7GKo
>>
>> I'm not certain if this is as expected of an issue, though. In the original 
>> example, `C` carried state that was set up after initialization but was 
>> relying on the fallback to the non-idiomatic copy constructor when doing the 
>> `throw`. WDYT?
>
> Yeah that is the equivalent scenario for `throw`, we treat c1 as a temporary 
> there. The same workaround applies, you can static cast to non-const lvalue 
> reference.

Thanks for verifying!

> As far as the implementation is concerned, it is following the proposal to 
> the letter here.
> And as I understand it, although I am not the author of the proposal (which 
> is @Quuxplusone), the committee agrees that this breakage is a good thing.

I'm less convinced than the committee; I put a high value on existing, working, 
conforming code continuing to work in newer language modes. However, this is 
what the standard requires for that language mode, so I can live with it unless 
the code pattern shows up in some common system header that users can't change 
themselves, and I haven't run into evidence of that for this particular case 
yet.

> In D99005#2859652 , @aaron.ballman 
> wrote:
>
>> I'm not certain it's reasonable to wait for MSVC STL to change as that 
>> leaves every existing user of older MSVC STLs out in the cold. This is 
>> causing some significant regressions at Intel, to the extent that I wonder 
>> if this should be temporarily reverted until the MSVC STL headers can be 
>> compiled again.
>
> That does interfere with the wishes of the committee to get implementation 
> experience with this.

I would argue it gives the committee valuable implementation experience 
feedback: the change breaks at least one popular system header.

> I am not saying one way or another, but would leaving this effect on by 
> default, but providing a command line flag to turn it off, be a reasonable 
> option on the table?

I don't think it's reasonable to leave this on by default for MSVC 
compatibility; it's not like `std::ifstream` is an obscure part of the STL or 
there's only one version of the STL that's impacted. The suggestions I have for 
how to move forward are:

- Add a compatibility hack that recognizes using the STL as a system header in 
a limited way to disable the diagnostics and get the old behavior (we do this 
on occasion for libstdc++, no reason we couldn't do something similar for MSVC 
STL). Then old headers still work without needing a flag and new (fixed) 
headers never see the issue. Someday in the distant future, we can remove the 
compatibility hack.
- Or, add a command line flag that defaults off for `-fms-compatibility` and 
defaults on otherwise. The default can be switched based on the compatibility 
version being used (perhaps) once the STL has been fixed.

I'd prefer to keep existing code working without requiring users to enable a 
flag, if at all possible (esp because I don't expect the flag to be needed 
forever). That said, I still think it makes sense to temporarily revert this 
while doing that work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99005/new/

https://reviews.llvm.org/D99005

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


[PATCH] D105408: [clang-format] Pass a TextDiagnosticPrinter when we can not create tempory file.

2021-07-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Yeah, I made the almost identical change but got some push back on it extending 
the dependencies (I think it also meant that the clang-format target needed 
alot more source to be compiled)

Dinking around in clangBasic is probably outside my pay grade ;-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105408/new/

https://reviews.llvm.org/D105408

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


[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2801-2802
+  // Get a root symbol in case of SymbolCast.
+  while (isa(Sym))
+Sym = cast(Sym)->getOperand();
+

ASDenysPetrov wrote:
> vsavchenko wrote:
> > This looks like a pattern and we should probably make into a method of 
> > `SymbolCast`
> I did it :) but refused. It will just turn into:
> ```
>   if (isa(Sym))
> Sym = cast(Sym)->getRootOperand();
> ```
> It looks pretty the same and brings no benefit IMO, does it?
> Every time I used `getRootOperand` I also needed some additional traverse 
> through the types te get some another information, so I couldn't avoid the 
> `while` loop there. So I decided not to introduce a new method in 
> `SymbolCast`.
Aha, I see your point.  I guess we can take it into `SymExpr` and call it not 
`getRootOperand`, which won't tell much to a person reading the name, but 
something like `ignoreCasts`.  It will fit well with `Expr::IgnoreCasts`, 
`Expr::IgnoreParens`, etc.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096

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


[PATCH] D104917: [Analyzer] Extend exploded-graph-rewriter to support eq and diseq classes

2021-07-06 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 356751.
martong added a comment.
Herald added a reviewer: Szelethus.

- Rebase on top of the newest version of the dependent patch
- Draw borders for the table of the disequality info
- Add tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104917/new/

https://reviews.llvm.org/D104917

Files:
  clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
  clang/test/Analysis/exploded-graph-rewriter/checker_messages_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/constraints.dot
  clang/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/disequality_info.dot
  clang/test/Analysis/exploded-graph-rewriter/disequality_info_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/equivalence_classes.dot
  clang/test/Analysis/exploded-graph-rewriter/equivalence_classes_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/test/Analysis/exploded-graph-rewriter/store_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/topology.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -267,6 +267,8 @@
 'store': None,
 'environment': None,
 'constraints': None,
+'equivalence_classes': None,
+'disequality_info': None,
 'dynamic_types': None,
 'constructing_objects': None,
 'checker_messages': None
@@ -285,6 +287,43 @@
 (c['symbol'], c['range']) for c in json_ps['constraints']
 ]) if json_ps['constraints'] is not None else None
 
+# Each equivalence_class is represented as List[Str].
+# json_ps['equivalence_classes']: List[List[Str]]
+# Sort by the first element of each equivalence_class.
+eq_classes = (
+json_ps['equivalence_classes']
+if json_ps['equivalence_classes']
+else None
+)
+self.equivalence_classes = (
+GenericMap({i: ", ".join(eq_classes[i]) for i in range(0, len(eq_classes))})
+if eq_classes
+else None
+)
+
+# Each equivalence_class is represented as List[Str].
+# Disequality info is a mapping from an equivalence class to many
+# equivalence classes:
+# json_ps['disequality_info']: Dict[List[Str], List[List[Str]]]
+def get_diseq_classes(classes):
+""" Flatten List[List[Str]] to Str """
+return (
+""
++ "".join([", ".join(cl) for cl in classes])
++ ""
+)
+
+self.disequality_info = (
+GenericMap(
+{
+", ".join(c["class"]): get_diseq_classes(c["disequal_to"])
+for c in json_ps["disequality_info"]
+}
+)
+if json_ps["disequality_info"]
+else None
+)
+
 self.dynamic_types = GenericMap([
 (t['region'], '%s%s' % (t['dyn_type'],
 ' (or a sub-class)'
@@ -682,8 +721,8 @@
 self.visit_store(st)
 self._dump('')
 
-def visit_generic_map(self, m, prev_m=None):
-self._dump('')
+def visit_generic_map(self, m, prev_m=None, border=0):
+self._dump('' % (border))
 
 def dump_pair(m, k, is_added=None):
 self._dump('%s'
@@ -704,7 +743,7 @@
 
 self._dump('')
 
-def visit_generic_map_in_state(self, selector, title, s, prev_s=None):
+def visit_generic_map_in_state(self, selector, title, s, prev_s=None, border=0):
 m = getattr(s, selector)
 prev_m = getattr(prev_s, selector) if prev_s is not None else None
 if m is None and prev_m is None:
@@ -719,12 +758,12 @@
 if prev_m is not None:
 if m.is_different(prev_m):
 self._dump('')
-self.visit_generic_map(m, prev_m)
+self.visit_generic_map(m, prev_m, border)
 else:
 self._dump(' No changes!')
 else:
 self._dump('')
-self.visit_generic_map(m)
+self.visit_generic_map(m, prev_m=None, border=border)
 
 self._dump('')
 
@@ -791,6 +830,12 @@
 s, prev_s)
 self.visit_generic_map_in_state('constraints', 'Ranges',
 s, prev_s)
+self.visit_generic_map_in_state('equivalence_classes',
+  

[PATCH] D105297: [OPENMP]Fix PR50347: Mapping of global scope deep object fails.

2021-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 356752.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105297/new/

https://reviews.llvm.org/D105297

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_34.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

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


[PATCH] D105489: [compiler-rt] [test] Fix asan symbolize tests on py3.10

2021-07-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: delcypher.
Herald added a subscriber: dberris.
mgorny requested review of this revision.

Update the asan_symbolize_script for changes in argparse output
in Python 3.10.  The parser output 'options' instead of 'optional
arguments'.


https://reviews.llvm.org/D105489

Files:
  
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
  
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp


Index: 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
===
--- 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
+++ 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
@@ -2,6 +2,6 @@
 // RUN: %asan_symbolize --log-level info --plugins %S/plugin_no_op.py --help 
2>&1 | FileCheck %s
 // CHECK: Registering plugin NoOpPlugin
 // CHECK: Adding --unlikely-option-name-XXX option
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --unlikely-option-name-XXX
 
Index: 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
===
--- 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
+++ 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
@@ -1,5 +1,5 @@
 // RUN: %asan_symbolize --help > %t_help_output.txt
 // RUN: FileCheck %s -input-file=%t_help_output.txt
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --log-dest
 // CHECK: --log-level


Index: compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
===
--- compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
+++ compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
@@ -2,6 +2,6 @@
 // RUN: %asan_symbolize --log-level info --plugins %S/plugin_no_op.py --help 2>&1 | FileCheck %s
 // CHECK: Registering plugin NoOpPlugin
 // CHECK: Adding --unlikely-option-name-XXX option
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --unlikely-option-name-XXX
 
Index: compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
===
--- compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
+++ compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
@@ -1,5 +1,5 @@
 // RUN: %asan_symbolize --help > %t_help_output.txt
 // RUN: FileCheck %s -input-file=%t_help_output.txt
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --log-dest
 // CHECK: --log-level
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104917: [Analyzer] Extend exploded-graph-rewriter to support eq and diseq classes

2021-07-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D104917#2845181 , @NoQ wrote:

>> We have a few in `test/Analysis/exploded-graph-rewriter/` where we test 
>> parts of the emitted html.
>
> And they're now failing on the pre-merge buildbots. So i guess updating 
> existing tests would already be nice.

Yeah, just updated the tests. Plus I added some new tests for the Eq/DisEq info.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104917/new/

https://reviews.llvm.org/D104917

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


[clang] f1cbea3 - [RISCV] Remove Zvamo implication for v1.0-rc change

2021-07-06 Thread ShihPo Hung via cfe-commits
Author: ShihPo Hung
Date: 2021-07-07T00:14:58+08:00
New Revision: f1cbea3e527547fc08c55235c11970a8d9f2637e

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

LOG: [RISCV] Remove Zvamo implication for v1.0-rc change

As v1.0-rc specs say Zvamo is removed from standard extension,
Zvamo has to be specified explicitly.

Reviewed By: evandro

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index f131d5321070c..ade93d6881a7a 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -258,10 +258,13 @@ static void getExtensionFeatures(const Driver &D,
 << MArch << Error << Ext;
   return;
 }
-if (Ext == "zvamo" || Ext == "zvlsseg") {
+if (Ext == "zvlsseg") {
+  Features.push_back("+experimental-v");
+  Features.push_back("+experimental-zvlsseg");
+} else if (Ext == "zvamo") {
   Features.push_back("+experimental-v");
-  Features.push_back("+experimental-zvamo");
   Features.push_back("+experimental-zvlsseg");
+  Features.push_back("+experimental-zvamo");
 } else if (isExperimentalExtension(Ext))
   Features.push_back(Args.MakeArgString("+experimental-" + Ext));
 else
@@ -429,7 +432,6 @@ static bool getArchFeatures(const Driver &D, StringRef 
MArch,
   break;
 case 'v':
   Features.push_back("+experimental-v");
-  Features.push_back("+experimental-zvamo");
   Features.push_back("+experimental-zvlsseg");
   break;
 }

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index da9b15b88a4c4..ea5754a83f1ea 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -225,12 +225,6 @@
 // RUN: -march=rv64iv0p10 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
-// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
-// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
 // RUN: -march=rv32izvlsseg0p10 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
@@ -238,9 +232,19 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // CHECK-V-EXT: __riscv_v 1
 // CHECK-V-EXT: __riscv_vector 1
-// CHECK-V-EXT: __riscv_zvamo 1
 // CHECK-V-EXT: __riscv_zvlsseg 1
 
+// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
+// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVAMO-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
+// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVAMO-EXT %s
+// CHECK-ZVAMO-EXT: __riscv_v 1
+// CHECK-ZVAMO-EXT: __riscv_vector 1
+// CHECK-ZVAMO-EXT: __riscv_zvamo 1
+// CHECK-ZVAMO-EXT: __riscv_zvlsseg 1
+
 // RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
 // RUN: -march=rv32izfh0p1 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s



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


[PATCH] D105396: [RISCV] Remove Zvamo implication for v1.0-rc change

2021-07-06 Thread ShihPo Hung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1cbea3e5275: [RISCV] Remove Zvamo implication for v1.0-rc 
change (authored by arcbbb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105396/new/

https://reviews.llvm.org/D105396

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Preprocessor/riscv-target-features.c


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -225,12 +225,6 @@
 // RUN: -march=rv64iv0p10 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
-// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
-// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
 // RUN: -march=rv32izvlsseg0p10 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
@@ -238,9 +232,19 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // CHECK-V-EXT: __riscv_v 1
 // CHECK-V-EXT: __riscv_vector 1
-// CHECK-V-EXT: __riscv_zvamo 1
 // CHECK-V-EXT: __riscv_zvlsseg 1
 
+// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
+// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVAMO-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
+// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVAMO-EXT %s
+// CHECK-ZVAMO-EXT: __riscv_v 1
+// CHECK-ZVAMO-EXT: __riscv_vector 1
+// CHECK-ZVAMO-EXT: __riscv_zvamo 1
+// CHECK-ZVAMO-EXT: __riscv_zvlsseg 1
+
 // RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
 // RUN: -march=rv32izfh0p1 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -258,10 +258,13 @@
 << MArch << Error << Ext;
   return;
 }
-if (Ext == "zvamo" || Ext == "zvlsseg") {
+if (Ext == "zvlsseg") {
+  Features.push_back("+experimental-v");
+  Features.push_back("+experimental-zvlsseg");
+} else if (Ext == "zvamo") {
   Features.push_back("+experimental-v");
-  Features.push_back("+experimental-zvamo");
   Features.push_back("+experimental-zvlsseg");
+  Features.push_back("+experimental-zvamo");
 } else if (isExperimentalExtension(Ext))
   Features.push_back(Args.MakeArgString("+experimental-" + Ext));
 else
@@ -429,7 +432,6 @@
   break;
 case 'v':
   Features.push_back("+experimental-v");
-  Features.push_back("+experimental-zvamo");
   Features.push_back("+experimental-zvlsseg");
   break;
 }


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -225,12 +225,6 @@
 // RUN: -march=rv64iv0p10 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
-// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
-// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
-// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
-// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
 // RUN: -march=rv32izvlsseg0p10 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
@@ -238,9 +232,19 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
 // CHECK-V-EXT: __riscv_v 1
 // CHECK-V-EXT: __riscv_vector 1
-// CHECK-V-EXT: __riscv_zvamo 1
 // CHECK-V-EXT: __riscv_zvlsseg 1
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVAMO-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv32izvamo0p10 -x c -E -dM %s \
+// RUN: -o 

[PATCH] D104917: [Analyzer] Extend exploded-graph-rewriter to support eq and diseq classes

2021-07-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> Do you happen to have a screenshot of how it looks?

Yes! :)

F17793264: image.png 
F17793282: image.png 

I've added borders to the tables in the `Disequality Info` section, because the 
default rendering makes it hard to notice if there are multiple disequivalent 
classes attached to one class (see the second pics).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104917/new/

https://reviews.llvm.org/D104917

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


[PATCH] D105490: Remove unused parameter from parseMSInlineAsm.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
Herald added a subscriber: hiraditya.
simon_tatham requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

No implementation uses the `LocCookie` parameter at all. Errors are
reported from inside that function by `llvm::SourceMgr`, and the
instance of that at the clang call site arranges to pass the error
messages back to a `ClangAsmParserCallback`, which is where the clang
SourceLocation for the error is computed.

(This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.
But this particular change seems beneficial in its own right.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105490

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  llvm/include/llvm/MC/MCParser/MCAsmParser.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp


Index: llvm/lib/MC/MCParser/MasmParser.cpp
===
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -514,9 +514,9 @@
 
   bool lookUpType(StringRef Name, AsmTypeInfo &Info) const override;
 
-  bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
-unsigned &NumOutputs, unsigned &NumInputs,
-SmallVectorImpl> &OpDecls,
+  bool parseMSInlineAsm(std::string &AsmString, unsigned &NumOutputs,
+unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers,
 const MCInstrInfo *MII, const MCInstPrinter *IP,
@@ -7257,8 +7257,8 @@
 }
 
 bool MasmParser::parseMSInlineAsm(
-void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
 const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -258,9 +258,9 @@
 return LTODiscardSymbols.contains(Name);
   }
 
-  bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
-unsigned &NumOutputs, unsigned &NumInputs,
-SmallVectorImpl> &OpDecls,
+  bool parseMSInlineAsm(std::string &AsmString, unsigned &NumOutputs,
+unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers,
 const MCInstrInfo *MII, const MCInstPrinter *IP,
@@ -5927,8 +5927,8 @@
 }
 
 bool AsmParser::parseMSInlineAsm(
-void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
 const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
Index: llvm/include/llvm/MC/MCParser/MCAsmParser.h
===
--- llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -202,8 +202,8 @@
 
   /// Parse MS-style inline assembly.
   virtual bool parseMSInlineAsm(
-  void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-  unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+  std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+  SmallVectorImpl> &OpDecls,
   SmallVectorImpl &Constraints,
   SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
   const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) = 0;
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -633,9 +633,9 @@
   SmallVector, 4> OpExprs;
   SmallVector Constraints;
   SmallVector Clobbers;
-  if (Parser->parseMSInlineAsm(AsmLoc.getPtrEncoding(), AsmStringIR, 
NumOutputs,
-   NumInputs, OpExprs, Constraints, Clobbers,
-   MII.get(), IP.get(), Callback))
+  if (Parser->parseMSInlineAsm(AsmStringIR, NumOutputs, NumInputs, OpExprs,
+   Constraints, Clobbers, MII.get(), IP.get(),
+   Callback))
 return StmtError();
 
   // Filter out "fpsw" and "mxcsr". They aren't valid GCC a

[PATCH] D105491: [clang] Use i64 for the !srcloc metadata on asm IR nodes.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
Herald added subscribers: dexonsmith, hiraditya.
simon_tatham requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

!srcloc is generated in clang codegen, and pulled back out by llvm
functions like AsmPrinter::emitInlineAsm that need to report errors in
the inline asm. From there it goes to LLVMContext::emitError, is
stored in DiagnosticInfoInlineAsm, and ends up back in clang, at
BackendConsumer::InlineAsmDiagHandler(), which reconstitutes a true
clang::SourceLocation from the integer cookie.

Throughout this code path, it's now 64-bit rather than 32, which means
that if SourceLocation is expanded to a 64-bit type, this error report
won't lose half of the data.

Patch originally by Mikhail Maltsev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105491

Files:
  clang/lib/CodeGen/CGStmt.cpp
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/MachineInstr.cpp
  llvm/lib/IR/LLVMContext.cpp

Index: llvm/lib/IR/LLVMContext.cpp
===
--- llvm/lib/IR/LLVMContext.cpp
+++ llvm/lib/IR/LLVMContext.cpp
@@ -248,7 +248,7 @@
 exit(1);
 }
 
-void LLVMContext::emitError(unsigned LocCookie, const Twine &ErrorStr) {
+void LLVMContext::emitError(uint64_t LocCookie, const Twine &ErrorStr) {
   diagnose(DiagnosticInfoInlineAsm(LocCookie, ErrorStr));
 }
 
Index: llvm/lib/CodeGen/MachineInstr.cpp
===
--- llvm/lib/CodeGen/MachineInstr.cpp
+++ llvm/lib/CodeGen/MachineInstr.cpp
@@ -2083,7 +2083,7 @@
 
 void MachineInstr::emitError(StringRef Msg) const {
   // Find the source location cookie.
-  unsigned LocCookie = 0;
+  uint64_t LocCookie = 0;
   const MDNode *LocMD = nullptr;
   for (unsigned i = getNumOperands(); i != 0; --i) {
 if (getOperand(i-1).isMetadata() &&
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -130,7 +130,7 @@
 
 static void EmitMSInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
MachineModuleInfo *MMI, AsmPrinter *AP,
-   unsigned LocCookie, raw_ostream &OS) {
+   uint64_t LocCookie, raw_ostream &OS) {
   // Switch to the inline assembly variant.
   OS << "\t.intel_syntax\n\t";
 
@@ -272,7 +272,7 @@
 
 static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
 MachineModuleInfo *MMI, const MCAsmInfo *MAI,
-AsmPrinter *AP, unsigned LocCookie,
+AsmPrinter *AP, uint64_t LocCookie,
 raw_ostream &OS) {
   int CurVariant = -1;// The number of the {.|.|.} region we are in.
   const char *LastEmitted = AsmStr; // One past the last character emitted.
@@ -483,7 +483,7 @@
 
   // Get the !srcloc metadata node if we have it, and decode the loc cookie from
   // it.
-  unsigned LocCookie = 0;
+  uint64_t LocCookie = 0;
   const MDNode *LocMD = nullptr;
   for (unsigned i = MI->getNumOperands(); i != 0; --i) {
 if (MI->getOperand(i-1).isMetadata() &&
Index: llvm/include/llvm/IR/LLVMContext.h
===
--- llvm/include/llvm/IR/LLVMContext.h
+++ llvm/include/llvm/IR/LLVMContext.h
@@ -290,7 +290,7 @@
   /// be prepared to drop the erroneous construct on the floor and "not crash".
   /// The generated code need not be correct.  The error message will be
   /// implicitly prefixed with "error: " and should not end with a ".".
-  void emitError(unsigned LocCookie, const Twine &ErrorStr);
+  void emitError(uint64_t LocCookie, const Twine &ErrorStr);
   void emitError(const Instruction *I, const Twine &ErrorStr);
   void emitError(const Twine &ErrorStr);
 
Index: llvm/include/llvm/IR/DiagnosticInfo.h
===
--- llvm/include/llvm/IR/DiagnosticInfo.h
+++ llvm/include/llvm/IR/DiagnosticInfo.h
@@ -131,7 +131,7 @@
 class DiagnosticInfoInlineAsm : public DiagnosticInfo {
 private:
   /// Optional line information. 0 if not set.
-  unsigned LocCookie = 0;
+  uint64_t LocCookie = 0;
   /// Message to be reported.
   const Twine &MsgStr;
   /// Optional origin of the problem.
@@ -149,7 +149,7 @@
   /// \p MsgStr gives the message.
   /// This class does not copy \p MsgStr, therefore the reference must be valid
   /// for the whole life 

[PATCH] D105492: [clang] Introduce SourceLocation::[U]IntType typedefs.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
Herald added subscribers: dexonsmith, arphaman, kbarton, nemanjai.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

NFC: this patch introduces typedefs for the integer type used by
SourceLocation and makes all the boring changes to use the typedefs
everywhere, but for the moment, they are unconditionally defined to
uint32_t.

Patch originally by Mikhail Maltsev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105492

Files:
  clang/include/clang/AST/DeclarationName.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/Token.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPCaching.cpp
  clang/lib/Lex/TokenLexer.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1982,7 +1982,8 @@
 return static_cast(data[0]);
   }
   SourceLocation getLoc() const {
-return SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)data[1]);
+return SourceLocation::getFromRawEncoding(
+(SourceLocation::UIntType)(uintptr_t)data[1]);
   }
 };
 class EnqueueVisitor : public ConstStmtVisitor {
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2041,7 +2041,7 @@
   Record.push_back(Expansion.isExpansionTokenRange());
 
   // Compute the token length for this macro expansion.
-  unsigned NextOffset = SourceMgr.getNextLocalOffset();
+  SourceLocation::UIntType NextOffset = SourceMgr.getNextLocalOffset();
   if (I + 1 != N)
 NextOffset = SourceMgr.getLocalSLocEntry(I + 1).getOffset();
   Record.push_back(NextOffset - SLoc->getOffset() - 1);
@@ -4640,7 +4640,7 @@
 // another module after it or have more than one entity inside it.
 uint32_t None = std::numeric_limits::max();
 
-auto writeBaseIDOrNone = [&](uint32_t BaseID, bool ShouldWrite) {
+auto writeBaseIDOrNone = [&](auto BaseID, bool ShouldWrite) {
   assert(BaseID < std::numeric_limits::max() && "base id too high");
   if (ShouldWrite)
 LE.write(BaseID);
@@ -5027,8 +5027,8 @@
 }
 
 void ASTWriter::AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record) {
-  uint32_t Raw = Loc.getRawEncoding();
-  Record.push_back((Raw << 1) | (Raw >> 31));
+  SourceLocation::UIntType Raw = Loc.getRawEncoding();
+  Record.push_back((Raw << 1) | (Raw >> (8 * sizeof(Raw) - 1)));
 }
 
 void ASTWriter::AddSourceRange(SourceRange Range, RecordDataImpl &Record) {
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1482,7 +1482,7 @@
   }
 
   BitstreamCursor &SLocEntryCursor = F->SLocEntryCursor;
-  unsigned BaseOffset = F->SLocEntryBaseOffset;
+  SourceLocation::UIntType BaseOffset = F->SLocEntryBaseOffset;
 
   ++NumSLocEntriesRead;
   Expected MaybeEntry = SLocEntryCursor.advance();
@@ -3404,7 +3404,7 @@
 case SOURCE_LOCATION_OFFSETS: {
   F.SLocEntryOffsets = (const uint32_t *)Blob.data();
   F.LocalNumSLocEntries = Record[0];
-  unsigned SLocSpaceSize = Record[1];
+  SourceLocation::UIntType SLocSpaceSize = Record[1];
   F.SLocEntryOffsetsBase = Record[2] + F.SourceManagerBlockStartOffset;
   std::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
   SourceMgr.AllocateLoadedSLocEntries(F.LocalNumSLocEntries,
@@ -3422,7 +3422,7 @@
   F.FirstLoc = SourceLocation::getFromRawEncoding(F.SLocEntryBaseOffset);
 
   // SLocEntryBaseOffset is lower than MaxLoadedOffset and decreasing.
-  assert((F.SLocEntryBaseOffset & (1U << 31U)) == 0);
+  assert((F.SLocEntryBaseOffset & SourceLocation::MacroIDBit) == 0);
   GlobalSLocOffsetMap.insert(
   std::make_pair(SourceManager::MaxLoadedOffset - F.SLocEntryBaseOffset
- SLocSpaceSize,&F));
@@ -3431,8 +3431,8 @@
   // In

[PATCH] D105494: [clang] Introduce a union inside ProgramPoint.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

The `void *Data1` field in ProgramPoint is sometimes used to store a
SourceLocation in pointer encoding, and sometimes used to store other
pointer data. If SourceLocation becomes 64-bit when clang is compiled
for a 32-bit platform, then this won't fit any more. Hence, we change
the type of `Data1` to a union storing either an actual SourceLocation
or a pointer.

Patch originally by Mikhail Maltsev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105494

Files:
  clang/include/clang/Analysis/ProgramPoint.h

Index: clang/include/clang/Analysis/ProgramPoint.h
===
--- clang/include/clang/Analysis/ProgramPoint.h
+++ clang/include/clang/Analysis/ProgramPoint.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/DataTypes.h"
 #include 
@@ -85,9 +86,31 @@
   MaxImplicitCallKind = PostImplicitCallKind,
   LoopExitKind,
   EpsilonKind};
-
 private:
-  const void *Data1;
+  union PtrOrSLoc {
+PtrOrSLoc() {}
+PtrOrSLoc(const void *P) {
+  memset(Raw.buffer, 0, sizeof(Raw.buffer));
+  Ptr = P;
+}
+PtrOrSLoc(SourceLocation L) {
+  memset(Raw.buffer, 0, sizeof(Raw.buffer));
+  new (&SLoc) SourceLocation(L);
+}
+bool operator==(const PtrOrSLoc &RHS) const {
+  return memcmp(this, &RHS, sizeof(PtrOrSLoc)) == 0;
+}
+bool operator!=(const PtrOrSLoc &RHS) const { return !(*this == RHS); }
+StringRef AsBuffer() const {
+  const char *c = (const char *)this;
+  return StringRef(c, sizeof(PtrOrSLoc));
+}
+const void *Ptr;
+SourceLocation SLoc;
+llvm::AlignedCharArrayUnion Raw;
+  };
+
+  PtrOrSLoc Data1;
   llvm::PointerIntPair Data2;
 
   // The LocationContext could be NULL to allow ProgramPoint to be used in
@@ -108,30 +131,38 @@
   Tag(tag, (((unsigned) k) >> 4) & 0x3) {
 assert(getKind() == k);
 assert(getLocationContext() == l);
-assert(getData1() == P);
+assert(getData1Ptr() == P);
   }
 
-  ProgramPoint(const void *P1,
-   const void *P2,
-   Kind k,
-   const LocationContext *l,
-   const ProgramPointTag *tag = nullptr)
-: Data1(P1),
-  Data2(P2, (((unsigned) k) >> 0) & 0x3),
-  L(l, (((unsigned) k) >> 2) & 0x3),
-  Tag(tag, (((unsigned) k) >> 4) & 0x3) {}
-
-protected:
-  const void *getData1() const { return Data1; }
-  const void *getData2() const { return Data2.getPointer(); }
-  void setData2(const void *d) { Data2.setPointer(d); }
-
-public:
-  /// Create a new ProgramPoint object that is the same as the original
-  /// except for using the specified tag value.
-  ProgramPoint withTag(const ProgramPointTag *tag) const {
-return ProgramPoint(getData1(), getData2(), getKind(),
-getLocationContext(), tag);
+  ProgramPoint(PtrOrSLoc D1, const void *P2, Kind k,
+   const LocationContext *l,
+   const ProgramPointTag *tag = nullptr)
+  : Data1(D1), Data2(P2, (((unsigned)k) >> 0) & 0x3),
+L(l, (((unsigned)k) >> 2) & 0x3),
+Tag(tag, (((unsigned)k) >> 4) & 0x3) {}
+
+  ProgramPoint(const void *P1, const void *P2, Kind k,
+   const LocationContext *l,
+   const ProgramPointTag *tag = nullptr)
+  : ProgramPoint(PtrOrSLoc(P1), P2, k, l, tag) {}
+
+  ProgramPoint(SourceLocation Loc, const void *P2, Kind k,
+   const LocationContext *l,
+   const ProgramPointTag *tag = nullptr)
+  : ProgramPoint(PtrOrSLoc(Loc), P2, k, l, tag) {}
+
+protected:
+  const PtrOrSLoc &getData1() const { return Data1; }
+  const void *getData1Ptr() const { return Data1.Ptr; }
+  const void *getData2() const { return Data2.getPointer(); }
+  void setData2(const void *d) { Data2.setPointer(d); }
+
+public:
+  /// Create a new ProgramPoint object that is the same as the original
+  /// except for using the specified tag value.
+  ProgramPoint withTag(const ProgramPointTag *tag) const {
+return ProgramPoint(getData1(), getData2(), getKind(),
+getLocationContext(), tag);
   }
 
   /// Convert to the specified ProgramPoint type, asserting that this
@@ -207,7 +238,7 @@
 
   void Profile(llvm::FoldingSetNodeID& ID) const {
 ID.AddInteger((unsigned) getKind());
-ID.AddPointer(getData1());
+ID.A

[PATCH] D105493: [clang] Change set type used for SourceLocation.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
Herald added a subscriber: dexonsmith.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

If clang is built for a 32-bit platform and SourceLocation is 64 bits
wide, then a SourceLocation will be larger than a pointer, so it won't
be possible to keep them in a SmallPtrSet any more. Switch to
SmallDenseSet instead.

Patch originally by Mikhail Maltsev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105493

Files:
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Lex/Preprocessor.h


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -781,8 +781,7 @@
   /// deserializing from PCH, we don't need to deserialize identifier & macros
   /// just so that we can report that they are unused, we just warn using
   /// the SourceLocations of this set (that will be filled by the ASTReader).
-  /// We are using SmallPtrSet instead of a vector for faster removal.
-  using WarnUnusedMacroLocsTy = llvm::SmallPtrSet;
+  using WarnUnusedMacroLocsTy = llvm::SmallDenseSet;
   WarnUnusedMacroLocsTy WarnUnusedMacroLocs;
 
   /// A "freelist" of MacroArg objects that can be
Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -513,20 +513,6 @@
 static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID);
   };
 
-  // Teach SmallPtrSet how to handle SourceLocation.
-  template<>
-  struct PointerLikeTypeTraits {
-static constexpr int NumLowBitsAvailable = 0;
-
-static void *getAsVoidPointer(clang::SourceLocation L) {
-  return L.getPtrEncoding();
-}
-
-static clang::SourceLocation getFromVoidPointer(void *P) {
-  return clang::SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)P);
-}
-  };
-
 } // namespace llvm
 
 #endif // LLVM_CLANG_BASIC_SOURCELOCATION_H


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -781,8 +781,7 @@
   /// deserializing from PCH, we don't need to deserialize identifier & macros
   /// just so that we can report that they are unused, we just warn using
   /// the SourceLocations of this set (that will be filled by the ASTReader).
-  /// We are using SmallPtrSet instead of a vector for faster removal.
-  using WarnUnusedMacroLocsTy = llvm::SmallPtrSet;
+  using WarnUnusedMacroLocsTy = llvm::SmallDenseSet;
   WarnUnusedMacroLocsTy WarnUnusedMacroLocs;
 
   /// A "freelist" of MacroArg objects that can be
Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -513,20 +513,6 @@
 static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID);
   };
 
-  // Teach SmallPtrSet how to handle SourceLocation.
-  template<>
-  struct PointerLikeTypeTraits {
-static constexpr int NumLowBitsAvailable = 0;
-
-static void *getAsVoidPointer(clang::SourceLocation L) {
-  return L.getPtrEncoding();
-}
-
-static clang::SourceLocation getFromVoidPointer(void *P) {
-  return clang::SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)P);
-}
-  };
-
 } // namespace llvm
 
 #endif // LLVM_CLANG_BASIC_SOURCELOCATION_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105495: [clang] Make negative getLocWithOffset widening-safe.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
Herald added subscribers: dexonsmith, martong.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

In many places in the code, SourceLocation::getLocWithOffset is used
with an argument of type `unsigned`, holding a value that's
conceptually negative (to find a location shortly before the current
one). If SourceLocation becomes a 64-bit type, this won't work any
more, because the negation will happen before widening to 64 bits, so
that instead of an offset of (say) -3, you'll get 2^32-3.

One answer would be to add casts to SourceLocation::IntType at all the
call sites, but that's quite cumbersome. In this patch I've taken a
different approach: getLocWithOffset now takes an optional second
parameter, which is subtracted from the location in addition to adding
the first parameter. That happens after widening to SourceLocation's
native integer type, so it will avoid this problem.

So you can compute an offset of -N for known-positive N by saying
`Loc.getLocWithOffset(0, N)`. And if you know the file offsets of two
features A,B and want to translate a SourceLocation for A into one for
B, you can say `Loc.getLocWithOffset(B, A)` to add (B-A) to the
position, without having to worry about integer types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105495

Files:
  clang/include/clang/Basic/SourceLocation.h
  clang/lib/AST/SelectorLocationsKind.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -1081,8 +1081,7 @@
   // Highlight the range.  Make the span tag the outermost tag for the
   // selected range.
 
-  SourceLocation E =
-InstantiationEnd.getLocWithOffset(EndColNo - OldEndColNo);
+  SourceLocation E = InstantiationEnd.getLocWithOffset(EndColNo, OldEndColNo);
 
   html::HighlightRange(R, InstantiationStart, E, HighlightStart, HighlightEnd);
 }
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -185,7 +185,7 @@
   if (TokIndex < AsmToks.size()) {
 const Token &Tok = AsmToks[TokIndex];
 Loc = Tok.getLocation();
-Loc = Loc.getLocWithOffset(Offset - TokOffset);
+Loc = Loc.getLocWithOffset(Offset, TokOffset);
   }
   return Loc;
 }
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -527,7 +527,7 @@
 return Loc;
 
   // Create a lexer starting at the beginning of this token.
-  SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
+  SourceLocation LexerStartLoc = Loc.getLocWithOffset(0, LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
@@ -570,7 +570,7 @@
   SM.getDecomposedLoc(BeginFileLoc);
   assert(FileLocInfo.first == BeginFileLocInfo.first &&
  FileLocInfo.second >= BeginFileLocInfo.second);
-  return Loc.getLocWithOffset(BeginFileLocInfo.second - FileLocInfo.second);
+  return Loc.getLocWithOffset(BeginFileLocInfo.second, FileLocInfo.second);
 }
 
 namespace {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -832,7 +832,7 @@
   FormatTok = new (Allocator.Allocate()) FormatToken;
   readRawToken(*FormatTok);
   SourceLocation WhitespaceStart =
-  FormatTok->Tok.getLocation().getLocWithOffset(-TrailingWhitespace);
+  FormatTok->Tok.getLocation().getLocWithOffset(0, TrailingWhitespace);
   FormatTok->IsFirst = IsFirstToken;
   IsFirstToken = false;
 
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -233,7 +233,7 @@
   /// Return the start location of an included file or expanded macro.
   SourceLocation getStartOfFileOrMacro(SourceLocation Loc) {
 if (Loc.isMacroID())
-  return Loc.getLocWithOffset(-SM.getFileOffset(Loc));
+  return Loc.getLocWithOffset(0, SM.getFileOffset(Loc));
 return SM.getLocForStartOfFile(SM.getFileID(Loc));
   }
 
Index: clang/lib/AST/SelectorLocationsKind.cpp
==

[PATCH] D105497: [clang] Serialize source locations as 64-bit in PCH.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

Unconditionally expanding the serialized encoding to 64 bits is the
simplest way to ensure that it will be big enough to handle an
expanded SourceLocation.

As I understand it, PCH files are already automatically versioned with
the exact revision of the compiler that built them, so this shouldn't
introduce any compatibility problem, because clang will already refuse
to load any PCH from a different version of itself.

Patch based on previous work by Mikhail Maltsev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105497

Files:
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -4636,21 +4636,29 @@
 LE.write(Name.size());
 Out.write(Name.data(), Name.size());
 
-// Note: if a base ID was uint max, it would not be possible to load
-// another module after it or have more than one entity inside it.
-uint32_t None = std::numeric_limits::max();
-
 auto writeBaseIDOrNone = [&](auto BaseID, bool ShouldWrite) {
-  assert(BaseID < std::numeric_limits::max() && "base id too high");
+  using T = decltype(BaseID);
+  static_assert(std::is_same::value ||
+std::is_same::value,
+"Invalid BaseID type");
+  assert(BaseID < std::numeric_limits::max() && "base id too high");
   if (ShouldWrite)
-LE.write(BaseID);
-  else
-LE.write(None);
+LE.write(BaseID);
+  else {
+// Note: if a base ID was uint max, it would not be possible to load
+// another module after it or have more than one entity inside it.
+constexpr T None = std::numeric_limits::max();
+LE.write(None);
+  }
 };
 
 // These values should be unique within a chain, since they will be read
 // as keys into ContinuousRangeMaps.
-writeBaseIDOrNone(M.SLocEntryBaseOffset, M.LocalNumSLocEntries);
+
+// SourceLocations are serialized as uint64_t, irrespective of
+// CLANG_64_BIT_SOURCE_LOCATIONS
+writeBaseIDOrNone(static_cast(M.SLocEntryBaseOffset),
+  M.LocalNumSLocEntries);
 writeBaseIDOrNone(M.BaseIdentifierID, M.LocalNumIdentifiers);
 writeBaseIDOrNone(M.BaseMacroID, M.LocalNumMacros);
 writeBaseIDOrNone(M.BasePreprocessedEntityID,
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3868,8 +3868,7 @@
   return;
 }
 
-SourceLocation::UIntType SLocOffset =
-endian::readNext(Data);
+uint64_t SLocOffset = endian::readNext(Data);
 uint32_t IdentifierIDOffset =
 endian::readNext(Data);
 uint32_t MacroIDOffset =
@@ -3885,6 +3884,15 @@
 uint32_t TypeIndexOffset =
 endian::readNext(Data);
 
+// SourceLocations are serialized as uint64_t, irrespective of
+// CLANG_64_BIT_SOURCE_LOCATIONS. So we have to bounds-check them
+// when reading back in.
+if (SLocOffset > std::numeric_limits::max()) {
+  Error("This version of clang cannot handle SourceLocations bigger than "
+"32 bits");
+  return;
+}
+
 auto mapOffset = [&](uint32_t Offset, uint32_t BaseOffset,
  RemapBuilder &Remap) {
   constexpr uint32_t None = std::numeric_limits::max();
Index: clang/include/clang/Serialization/ASTReader.h
===
--- clang/include/clang/Serialization/ASTReader.h
+++ clang/include/clang/Serialization/ASTReader.h
@@ -781,7 +781,7 @@
   ///
   /// CodeGen has to emit VTables for these records, so they have to be eagerly
   /// deserialized.
-  SmallVector VTableUses;
+  SmallVector VTableUses;
 
   /// A snapshot of the pending instantiations in the chain.
   ///
@@ -789,7 +789,7 @@
   /// end of the TU. It consists of a pair of values for every pending
   /// instantiation where the first value is the ID of the decl and the second
   /// is the instantiation location.
-  SmallVector PendingInstantiations;
+  SmallVector PendingInstantiations;
 
   //@}
 
@@ -807,11 +807,11 @@
 
   /// Method selectors used in a @selector expression. Used for
   /// implementation of -Wselector.
-  SmallVe

[PATCH] D105498: [clang] Remove assumption about SourceLocation alignment.

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: rsmith, lebedev.ri, akyrtzi.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

In `ObjCMethodDecl`, an array of pointers (parameters) and an array of
SourceLocations are stored end to end in a single allocated piece of
memory. The offset within that memory where the second array begins
was being computed in a really simple way, based on the assumption
that pointers had at least as much alignment requirement as
SourceLocations. But when pointers and SourceLocations can each be
either 32 or 64 bits, this won't be a reliable assumption any more.

This patch explicitly computes the offset in a way that should work
for any combination of alignment requirements.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105498

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/lib/AST/DeclObjC.cpp


Index: clang/lib/AST/DeclObjC.cpp
===
--- clang/lib/AST/DeclObjC.cpp
+++ clang/lib/AST/DeclObjC.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -874,11 +875,8 @@
   if (Params.empty() && SelLocs.empty())
 return;
 
-  static_assert(alignof(ParmVarDecl *) >= alignof(SourceLocation),
-"Alignment not sufficient for SourceLocation");
-
-  unsigned Size = sizeof(ParmVarDecl *) * NumParams +
-  sizeof(SourceLocation) * SelLocs.size();
+  unsigned Size =
+  getStoredSelLocsOffset() + sizeof(SourceLocation) * SelLocs.size();
   ParamsAndSelLocs = C.Allocate(Size);
   std::copy(Params.begin(), Params.end(), getParams());
   std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
Index: clang/include/clang/AST/DeclObjC.h
===
--- clang/include/clang/AST/DeclObjC.h
+++ clang/include/clang/AST/DeclObjC.h
@@ -190,13 +190,20 @@
 return getSelLocsKind() != SelLoc_NonStandard;
   }
 
+  size_t getStoredSelLocsOffset() const {
+return llvm::alignTo(sizeof(ParmVarDecl *) *
+  NumParams);
+  }
+
   /// Get a pointer to the stored selector identifiers locations array.
   /// No locations will be stored if HasStandardSelLocs is true.
   SourceLocation *getStoredSelLocs() {
-return reinterpret_cast(getParams() + NumParams);
+return reinterpret_cast(
+reinterpret_cast(ParamsAndSelLocs) + getStoredSelLocsOffset());
   }
   const SourceLocation *getStoredSelLocs() const {
-return reinterpret_cast(getParams() + NumParams);
+return reinterpret_cast(
+reinterpret_cast(ParamsAndSelLocs) + getStoredSelLocsOffset());
   }
 
   /// Get a pointer to the stored selector identifiers locations array.


Index: clang/lib/AST/DeclObjC.cpp
===
--- clang/lib/AST/DeclObjC.cpp
+++ clang/lib/AST/DeclObjC.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -874,11 +875,8 @@
   if (Params.empty() && SelLocs.empty())
 return;
 
-  static_assert(alignof(ParmVarDecl *) >= alignof(SourceLocation),
-"Alignment not sufficient for SourceLocation");
-
-  unsigned Size = sizeof(ParmVarDecl *) * NumParams +
-  sizeof(SourceLocation) * SelLocs.size();
+  unsigned Size =
+  getStoredSelLocsOffset() + sizeof(SourceLocation) * SelLocs.size();
   ParamsAndSelLocs = C.Allocate(Size);
   std::copy(Params.begin(), Params.end(), getParams());
   std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
Index: clang/include/clang/AST/DeclObjC.h
===
--- clang/include/clang/AST/DeclObjC.h
+++ clang/include/clang/AST/DeclObjC.h
@@ -190,13 +190,20 @@
 return getSelLocsKind() != SelLoc_NonStandard;
   }
 
+  size_t getStoredSelLocsOffset() const {
+return llvm::alignTo(sizeof(ParmVarDecl *) *
+  NumParams);
+  }
+
   /// Get a pointer to the stored selector identifiers locations array.
   /// No locations will be stored if HasStandardSelLocs is true.
   SourceLocation *getStoredSelLocs() {
-return reinterpret_cast(getParams() + NumParams);
+return reinterpret_cast(
+reinterpret_cast(ParamsAndSelLocs) + getStoredSelLocsOffset());
   }
   const SourceLocation *getStoredSelLocs() const {
-return reinterpret_cast(getParams() + NumParams);
+retu

[PATCH] D97204: [RFC] Clang 64-bit source locations

2021-07-06 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

This patch doesn't seem to have attracted much review attention in the last 
couple of weeks. On the theory that perhaps it's just too big and monolithic to 
review in one go, I've started to break it up into smaller pieces.

So far I've only covered the preparation stages, so I //hope// the following 
patches won't be too controversial:
D105490 : Remove unused parameter from 
parseMSInlineAsm.
D105491 : [clang] Use i64 for the !srcloc 
metadata on asm IR nodes.
D105492 : [clang] Introduce 
SourceLocation::[U]IntType typedefs.
D105493 : [clang] Change set type used for 
SourceLocation.
D105494 : [clang] Introduce a union inside 
ProgramPoint.
D105495 : [clang] Make negative 
getLocWithOffset widening-safe.
D105497 : [clang] Serialize source locations 
as 64-bit in PCH.
D105498 : [clang] Remove assumption about 
SourceLocation alignment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97204/new/

https://reviews.llvm.org/D97204

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


[PATCH] D105151: [OPENMP]Fix PR50733: unexpected final value of list-item in linear clause in loop construct.

2021-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 356766.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105151/new/

https://reviews.llvm.org/D105151

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp

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


[PATCH] D103165: Threading: use independent llvm::thread implementation on Apple platforms to increase stack size

2021-07-06 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103165/new/

https://reviews.llvm.org/D103165

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


[PATCH] D104858: [OpenCL][ARM] Fix ICE when compiling a kernel

2021-07-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D104858#2859742 , 
@pekka.jaaskelainen wrote:

>> Ok, thanks for clarification. Does it mean there is something we need to add 
>> to LLVM somewhere to make it work correctly? Would it be specific to Arm or 
>> generally for all CPU targets?
>
> To my understanding, what is required is to keep SPIR_KERNEL CC working for 
> Arm since that is the generic way for PoCL supports clSetKernelArg for CPU 
> targets by default. I have been under impression that it has worked so far 
> for Arm, but I haven't tested it personally, and PoCL still lacks an official 
> Arm maintainer, so cannot say for sure.

Ok, but as is clang can't compile OpenCL sources

In D104858#2859742 , 
@pekka.jaaskelainen wrote:

>> Ok, thanks for clarification. Does it mean there is something we need to add 
>> to LLVM somewhere to make it work correctly? Would it be specific to Arm or 
>> generally for all CPU targets?
>
> To my understanding, what is required is to keep SPIR_KERNEL CC working for 
> Arm since that is the generic way for PoCL supports clSetKernelArg for CPU 
> targets by default. I have been under impression that it has worked so far 
> for Arm, but I haven't tested it personally, and PoCL still lacks an official 
> Arm maintainer, so cannot say for sure.

Well right now clang doesn't seem to cope with `SPIR_KERNEL` for Arm CPU as it 
crashes its instruction selection https://godbolt.org/z/rraG9roee. So the flow 
is definitely broken. And if we fix the failure we can use this properly in 
godbolt instead of working around by removing the kernel in the preprocessor.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104858/new/

https://reviews.llvm.org/D104858

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


[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-06 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2801-2802
+  // Get a root symbol in case of SymbolCast.
+  while (isa(Sym))
+Sym = cast(Sym)->getOperand();
+

vsavchenko wrote:
> ASDenysPetrov wrote:
> > vsavchenko wrote:
> > > This looks like a pattern and we should probably make into a method of 
> > > `SymbolCast`
> > I did it :) but refused. It will just turn into:
> > ```
> >   if (isa(Sym))
> > Sym = cast(Sym)->getRootOperand();
> > ```
> > It looks pretty the same and brings no benefit IMO, does it?
> > Every time I used `getRootOperand` I also needed some additional traverse 
> > through the types te get some another information, so I couldn't avoid the 
> > `while` loop there. So I decided not to introduce a new method in 
> > `SymbolCast`.
> Aha, I see your point.  I guess we can take it into `SymExpr` and call it not 
> `getRootOperand`, which won't tell much to a person reading the name, but 
> something like `ignoreCasts`.  It will fit well with `Expr::IgnoreCasts`, 
> `Expr::IgnoreParens`, etc.
Nice idea! True, `getRootOperand` would only tell enough to user in scope of 
`SymbolCast`. I'll try to implement this in the next update.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/avx512fp16intrin.h:254
+/// Constructs a 512-bit floating-point vector of [32 x half] from a
+///128-bit floating-point vector of [16 x half]. The lower 256 bits
+///contain the value of the source vector. The upper 256 bits are set

256-bit



Comment at: clang/lib/Headers/avx512vlfp16intrin.h:74
+static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_abs_ph(__m256h __A) {
+  return (__m256h)_mm256_and_epi32(_mm256_set1_epi32(0x7FFF7FFF), 
(__m256i)__A);
+}

Why do we use _mm256_set1_epi32 instead of _mm256_set1_epi16?



Comment at: clang/lib/Headers/avx512vlfp16intrin.h:78
+static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_abs_ph(__m128h __A) {
+  return (__m128h)_mm_and_epi32(_mm_set1_epi32(0x7FFF7FFF), (__m128i)__A);
+}

Same question



Comment at: llvm/include/llvm/IR/RuntimeLibcalls.def:290
 HANDLE_LIBCALL(FPEXT_F16_F128, "__extendhftf2")
+HANDLE_LIBCALL(FPEXT_F16_F80, "__extendhfxf2")
 HANDLE_LIBCALL(FPEXT_F32_F64, "__extendsfdf2")

Is this tested in this patch?



Comment at: llvm/lib/Target/X86/X86FastISel.cpp:58
   bool X86ScalarSSEf32;
+  bool X86ScalarAVXf16;
 

AVX here should maybe be AVX512, but maybe this is pointing out that this name 
is bad. Would X86ScalarXMMf* be better?



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:13537
+unsigned MovOpc = 0;
+if (EltVT == MVT::f16) {
+  MovOpc = X86ISD::MOVSH;

Drop curly braces on these.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105263/new/

https://reviews.llvm.org/D105263

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


[PATCH] D105501: [PowerPC] Power ISA features for Semachecking

2021-07-06 Thread Quinn Pham via Phabricator via cfe-commits
quinnp created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
quinnp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[NFC] This patch adds features for pwr7, pwr8, and pwr9 that can be
used for semacheking builtin functions that are only valid for certain
versions of ppc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105501

Files:
  clang/lib/Basic/Targets/PPC.cpp


Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -422,6 +422,14 @@
 return false;
   }
 
+  Features["isa207"] = llvm::StringSwitch(CPU)
+   .Case("pwr9", true)
+   .Case("ppc64le", true)
+   .Case("pwr8", true)
+   .Default(false);
+  Features["isa30"] =
+  llvm::StringSwitch(CPU).Case("pwr9", true).Default(false);
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
@@ -434,6 +442,7 @@
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
   Features["prefix-instrs"] = true;
+  Features["isa31"] = true;
   return;
 }
 


Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -422,6 +422,14 @@
 return false;
   }
 
+  Features["isa207"] = llvm::StringSwitch(CPU)
+   .Case("pwr9", true)
+   .Case("ppc64le", true)
+   .Case("pwr8", true)
+   .Default(false);
+  Features["isa30"] =
+  llvm::StringSwitch(CPU).Case("pwr9", true).Default(false);
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
@@ -434,6 +442,7 @@
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
   Features["prefix-instrs"] = true;
+  Features["isa31"] = true;
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105501: [PowerPC] Power ISA features for Semachecking

2021-07-06 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 356774.
quinnp added a comment.

Updating pwr10 features to include previous features.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105501/new/

https://reviews.llvm.org/D105501

Files:
  clang/lib/Basic/Targets/PPC.cpp


Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -422,6 +422,14 @@
 return false;
   }
 
+  Features["isa207"] = llvm::StringSwitch(CPU)
+   .Case("pwr9", true)
+   .Case("ppc64le", true)
+   .Case("pwr8", true)
+   .Default(false);
+  Features["isa30"] =
+  llvm::StringSwitch(CPU).Case("pwr9", true).Default(false);
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
@@ -434,6 +442,9 @@
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
   Features["prefix-instrs"] = true;
+  Features["isa207"] = true;
+  Features["isa30"] = true;
+  Features["isa31"] = true;
   return;
 }
 


Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -422,6 +422,14 @@
 return false;
   }
 
+  Features["isa207"] = llvm::StringSwitch(CPU)
+   .Case("pwr9", true)
+   .Case("ppc64le", true)
+   .Case("pwr8", true)
+   .Default(false);
+  Features["isa30"] =
+  llvm::StringSwitch(CPU).Case("pwr9", true).Default(false);
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
@@ -434,6 +442,9 @@
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
   Features["prefix-instrs"] = true;
+  Features["isa207"] = true;
+  Features["isa30"] = true;
+  Features["isa31"] = true;
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105295: [CUDA] Only allow NVIDIA offload-arch during CUDA compilation.

2021-07-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105295/new/

https://reviews.llvm.org/D105295

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


[PATCH] D105285: [Clang] Add test dependency on llvm-ar

2021-07-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105285/new/

https://reviews.llvm.org/D105285

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


[PATCH] D103986: [PowerPC] Floating Point Builtins for XL Compat.

2021-07-06 Thread Quinn Pham via Phabricator via cfe-commits
quinnp added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-sync.c:2
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
-// RUN:-emit-llvm %s -o -  -target-cpu pwr8 | FileCheck %s
+// RUN:-emit-llvm %s -o -  -target-cpu pwr7 | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown \

qiucf wrote:
> Why change `pwr7` to `pwr8`?
This was to match the testing convention for XL compatibility builtins of 
targeting pwr7 for big endian and pwr8 for little endian. However, I will not 
be changing the `sync` tests in this patch, I have reversed those changes and 
will be putting them into a different patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103986/new/

https://reviews.llvm.org/D103986

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


[PATCH] D105489: [compiler-rt] [test] Fix asan symbolize tests on py3.10

2021-07-06 Thread Dan Liew via Phabricator via cfe-commits
delcypher accepted this revision.
delcypher added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105489/new/

https://reviews.llvm.org/D105489

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


[clang] 045872f - [AIX] Define __TOS_AIX__ predefined macro

2021-07-06 Thread Steven Wan via cfe-commits
Author: Jake Egan
Date: 2021-07-06T14:15:35-04:00
New Revision: 045872f42203223450c96a518b6478d255a5d586

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

LOG: [AIX] Define __TOS_AIX__ predefined macro

%%%
Transfer the predefined macro, __TOS_AIX__, from the AIX XL C/C++ compilers.

__TOS_AIX__ indicates that the target operating system is AIX.
%%%

Reviewed By: cebowleratibm

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

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init-ppc.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index fd1b15c512a2f..31f8b4bea30d9 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -675,6 +675,7 @@ class AIXTargetInfo : public OSTargetInfo {
 Builder.defineMacro("_POWER");
 
 Builder.defineMacro("_AIX");
+Builder.defineMacro("__TOS_AIX__");
 
 if (Opts.C11) {
   Builder.defineMacro("__STDC_NO_ATOMICS__");

diff  --git a/clang/test/Preprocessor/init-ppc.c 
b/clang/test/Preprocessor/init-ppc.c
index f59edd119ab0b..4803a8511c7ed 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -541,6 +541,7 @@
 // PPC-AIX:#define __SIZE_MAX__ 4294967295UL
 // PPC-AIX:#define __SIZE_TYPE__ long unsigned int
 // PPC-AIX:#define __SIZE_WIDTH__ 32
+// PPC-AIX:#define __TOS_AIX__ 1
 // PPC-AIX:#define __UINT16_C_SUFFIX__
 // PPC-AIX:#define __UINT16_MAX__ 65535
 // PPC-AIX:#define __UINT16_TYPE__ unsigned short



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


[PATCH] D103587: [AIX] Define __TOS_AIX__ predefined macro

2021-07-06 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG045872f42203: [AIX] Define __TOS_AIX__ predefined macro 
(authored by Jake-Egan, committed by stevewan).

Changed prior to commit:
  https://reviews.llvm.org/D103587?vs=349913&id=356783#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103587/new/

https://reviews.llvm.org/D103587

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-ppc.c


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -541,6 +541,7 @@
 // PPC-AIX:#define __SIZE_MAX__ 4294967295UL
 // PPC-AIX:#define __SIZE_TYPE__ long unsigned int
 // PPC-AIX:#define __SIZE_WIDTH__ 32
+// PPC-AIX:#define __TOS_AIX__ 1
 // PPC-AIX:#define __UINT16_C_SUFFIX__
 // PPC-AIX:#define __UINT16_MAX__ 65535
 // PPC-AIX:#define __UINT16_TYPE__ unsigned short
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -675,6 +675,7 @@
 Builder.defineMacro("_POWER");
 
 Builder.defineMacro("_AIX");
+Builder.defineMacro("__TOS_AIX__");
 
 if (Opts.C11) {
   Builder.defineMacro("__STDC_NO_ATOMICS__");


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -541,6 +541,7 @@
 // PPC-AIX:#define __SIZE_MAX__ 4294967295UL
 // PPC-AIX:#define __SIZE_TYPE__ long unsigned int
 // PPC-AIX:#define __SIZE_WIDTH__ 32
+// PPC-AIX:#define __TOS_AIX__ 1
 // PPC-AIX:#define __UINT16_C_SUFFIX__
 // PPC-AIX:#define __UINT16_MAX__ 65535
 // PPC-AIX:#define __UINT16_TYPE__ unsigned short
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -675,6 +675,7 @@
 Builder.defineMacro("_POWER");
 
 Builder.defineMacro("_AIX");
+Builder.defineMacro("__TOS_AIX__");
 
 if (Opts.C11) {
   Builder.defineMacro("__STDC_NO_ATOMICS__");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105135: [Internalize] Preserve variables externally initialized.

2021-07-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM. Pls change the negative tests to positive tests as Artem suggested.




Comment at: clang/test/CodeGenCUDA/host-used-device-var.cu:20
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;

tra wrote:
> hliao wrote:
> > BTW, as clang codegen tests, those checks should not rely on middle-end 
> > optimizations to work correctly.
> What happens if you remove -O3?
> Sometimes optimization is helpful as it reduces the amount of IR we need to 
> check and how it's structured. It's much easier to see what went wrong when 
> you get just a handful of IR statements in the failing test output.
These tests were introduced with -O3 since they can only be tested with clang 
and -O3. (https://reviews.llvm.org/D98783) Clang may emit IR containing unused 
LLVM constants. Saving the IR as a file will cause such unused LLVM constants 
to disappear, therefore unable to reproduce the issue.



Comment at: clang/test/CodeGenCUDA/host-used-device-var.cu:20
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;

yaxunl wrote:
> tra wrote:
> > hliao wrote:
> > > BTW, as clang codegen tests, those checks should not rely on middle-end 
> > > optimizations to work correctly.
> > What happens if you remove -O3?
> > Sometimes optimization is helpful as it reduces the amount of IR we need to 
> > check and how it's structured. It's much easier to see what went wrong when 
> > you get just a handful of IR statements in the failing test output.
> These tests were introduced with -O3 since they can only be tested with clang 
> and -O3. (https://reviews.llvm.org/D98783) Clang may emit IR containing 
> unused LLVM constants. Saving the IR as a file will cause such unused LLVM 
> constants to disappear, therefore unable to reproduce the issue.
If -O3 is removed, those unused variables will not be internalized and removed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105135/new/

https://reviews.llvm.org/D105135

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


[PATCH] D105489: [compiler-rt] [test] Fix asan symbolize tests on py3.10

2021-07-06 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d68bb1765f9: [compiler-rt] [test] Fix asan symbolize tests 
on py3.10 (authored by mgorny).
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105489/new/

https://reviews.llvm.org/D105489

Files:
  
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
  
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp


Index: 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
===
--- 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
+++ 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
@@ -2,6 +2,6 @@
 // RUN: %asan_symbolize --log-level info --plugins %S/plugin_no_op.py --help 
2>&1 | FileCheck %s
 // CHECK: Registering plugin NoOpPlugin
 // CHECK: Adding --unlikely-option-name-XXX option
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --unlikely-option-name-XXX
 
Index: 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
===
--- 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
+++ 
compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
@@ -1,5 +1,5 @@
 // RUN: %asan_symbolize --help > %t_help_output.txt
 // RUN: FileCheck %s -input-file=%t_help_output.txt
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --log-dest
 // CHECK: --log-level


Index: compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
===
--- compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
+++ compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_no_op_help_output.cpp
@@ -2,6 +2,6 @@
 // RUN: %asan_symbolize --log-level info --plugins %S/plugin_no_op.py --help 2>&1 | FileCheck %s
 // CHECK: Registering plugin NoOpPlugin
 // CHECK: Adding --unlikely-option-name-XXX option
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --unlikely-option-name-XXX
 
Index: compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
===
--- compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
+++ compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/logging_options_in_help.cpp
@@ -1,5 +1,5 @@
 // RUN: %asan_symbolize --help > %t_help_output.txt
 // RUN: FileCheck %s -input-file=%t_help_output.txt
-// CHECK: optional arguments:
+// CHECK: option{{al arguments|s}}:
 // CHECK: --log-dest
 // CHECK: --log-level
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-07-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D99005#2860021 , @aaron.ballman 
wrote:

> I would argue it gives the committee valuable implementation experience 
> feedback: the change breaks at least one popular system header.

But we already knew that :-)
Reverting the change globally would stop us from finding further affected 
entities.
But it is a given that because of this STL bug, this is affecting our ability 
to get that feedback on user code in that ecosystem as well.

> I don't think it's reasonable to leave this on by default for MSVC 
> compatibility; it's not like `std::ifstream` is an obscure part of the STL or 
> there's only one version of the STL that's impacted. The suggestions I have 
> for how to move forward are:
>
> - Add a compatibility hack that recognizes using the STL as a system header 
> in a limited way to disable the diagnostics and get the old behavior (we do 
> this on occasion for libstdc++, no reason we couldn't do something similar 
> for MSVC STL). Then old headers still work without needing a flag and new 
> (fixed) headers never see the issue. Someday in the distant future, we can 
> remove the compatibility hack.
> - Or, add a command line flag that defaults off for `-fms-compatibility` and 
> defaults on otherwise. The default can be switched based on the compatibility 
> version being used (perhaps) once the STL has been fixed.

I find interesting the idea of combining these two options. We can suppress the 
effect when compiling with fms-compatibility but only on the STL headers 
themselves.

> I'd prefer to keep existing code working without requiring users to enable a 
> flag, if at all possible (esp because I don't expect the flag to be needed 
> forever). That said, I still think it makes sense to temporarily revert this 
> while doing that work.

I'd like to give some time for other stakeholders to give their opinion if this 
is not too urgent, specially @Quuxplusone and @rsmith.
But thinking of another option, almost as easy as a global revert for this, we 
could suppress the effect under -fms-compatibility for now, and then implement 
a more targetted fix where we only suppress this when parsing the STL system 
headers themselves under fms-compatibility.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99005/new/

https://reviews.llvm.org/D99005

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


[PATCH] D102531: PR45881: Properly use CXXThisOverride for templated lambda

2021-07-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 356796.
ychen added a comment.

- address feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102531/new/

https://reviews.llvm.org/D102531

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
  clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp

Index: clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -emit-llvm-only %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -fdelayed-template-parsing %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -fms-extensions %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -fdelayed-template-parsing -fms-extensions %s
+
+namespace PR45881 {
+struct A {
+void f();
+};
+int id(A*);
+void A::f() {
+auto z = [*this](auto z2, decltype(z2(this)) z3){};
+z(id,3);
+}
+
+struct B {
+void f();
+};
+void B::f() {
+auto z = [](){return 0;};
+z.template operator()();
+}
+
+struct C {
+void f();
+};
+void C::f() {
+auto z = [](){return 0;};
+z.template operator()();
+}
+} // namespace PR45881
Index: clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
===
--- clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
+++ clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
@@ -298,3 +298,13 @@
 
 } // namespace PR32831
 
+namespace PR45881 {
+struct A {
+void f();
+};
+int id(A*);
+void A::f() {
+auto z = [*this](auto z2, decltype(z2(this)) z3){};
+z(id,3);
+}
+} // namespace PR45881
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2858,9 +2858,24 @@
   return Sema::TDK_Incomplete;
 }
 
-TemplateArgumentLoc DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
-TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, Builder,
-HasDefaultArg);
+TemplateArgumentLoc DefArg;
+{
+  Qualifiers ThisTypeQuals;
+  CXXRecordDecl *ThisContext = nullptr;
+  if (auto *Rec = dyn_cast(TD->getDeclContext()))
+if (Rec->isLambda())
+  if (auto *Method = dyn_cast(Rec->getDeclContext())) {
+ThisContext = Method->getParent();
+ThisTypeQuals = Method->getMethodQualifiers();
+  }
+
+  Sema::CXXThisScopeRAII ThisScope(S, ThisContext, ThisTypeQuals,
+   S.getLangOpts().CPlusPlus17);
+
+  DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
+  TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, Builder,
+  HasDefaultArg);
+}
 
 // If there was no default argument, deduction is incomplete.
 if (DefArg.getArgument().isNull()) {
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -5110,7 +5110,11 @@
 for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
   TemplateArgLists.addOuterTemplateArguments(None);
 
-Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
+bool ForLambdaCallOperator = false;
+if (const auto *Rec = dyn_cast(Template->getDeclContext()))
+  ForLambdaCallOperator = Rec->isLambda();
+Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext(),
+   !ForLambdaCallOperator);
 ArgType =
 SemaRef.SubstType(ArgType, TemplateArgLists,
   Param->getDefaultArgumentLoc(), Param->getDeclName());
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1137,11 +1137,10 @@
 }
   }
 
-  // 2) We've run out of ScopeInfos but check if CurDC is a lambda (which can
-  // happen during instantiation of its nested generic lambda call operator)
-  if (isLambdaCallOperator(CurDC)) {
-assert(CurLSI && "While computing 'this' capture-type for a generic "
- "lambda, we must have a corresponding LambdaScopeInfo");
+  // 2) We've run out of ScopeInfos but check 1. if CurDC is a lambda (which
+  //can happen during instantiation of its nested generic lambda call
+  //operator); 2. if we're in a lambda scope (lambda body).
+  if (CurLSI && isLambdaCallOperator(CurDC)) {
 assert(isGenericLambdaCallOperatorSpecialization(CurLSI->CallOperator) &&
"While computing 'this' capture-type for a generic lambda, when we "
"run out of enclosing LSI's, yet the enclosing DC is a "

[PATCH] D103527: [Clang][RISCV] Implement vlseg and vlsegff.

2021-07-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103527/new/

https://reviews.llvm.org/D103527

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


[PATCH] D105457: [clang] Refactor AST printing tests to share more infrastructure

2021-07-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Looks generally good - few things might be able to be tidied up/simplified, I 
think?




Comment at: clang/unittests/AST/ASTPrint.h:61-62
+private:
+  // Can be specialized for specific node types.
+  bool shouldIgnoreNode(const NodeType *N) { return false; }
 };

Why is this implemented via specialization but other configuration is 
implemented via functors (like `Printer` and `PolicyAdjuster`) are done via 
passed in functors? Might be worth using the same mechanism for all of them - 
this one can have a default argument value in the ctor so it doesn't have to be 
specified by all uses of this class/they can get this default behavior as 
implemented here.



Comment at: clang/unittests/AST/DeclPrinterTest.cpp:59
+  return PrintedNodeMatches(Code, Args, NodeMatch, ExpectedPrinted,
+  FileName, PrinterType{PrintDecl},
+  PolicyModifier, AllowError);

Is the `PrinterType{}` needed here, or could `PrintDecl` be passed 
directly/without explicitly constructing the wrapper? (functions should be 
implicitly convertible to the lambda type, I think?) 

Similarly for all the `PrintingPolicyAdjuster(...)` - might be able to skip 
that wrapping expression & rely on an implicit conversion.



Comment at: clang/unittests/AST/StmtPrinterTest.cpp:55-56
+   PrintingPolicyAdjuster PolicyAdjuster = nullptr) {
+  return PrintedNodeMatches(Code, Args, NodeMatch, ExpectedPrinted, "",
+PrinterType{PrintStmt}, PolicyAdjuster);
+}

I guess maybe this could be changed (better or worse, not sure) to this:
```
return PrintedNodeMatches(..., PrintStmt, ...);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105457/new/

https://reviews.llvm.org/D105457

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


[PATCH] D105395: [IRBuilder] Add type argument to CreateMaskedLoad/Gather

2021-07-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Might use some testing? (guess there was previously missing testing, or this 
API change would've broken those tests)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105395/new/

https://reviews.llvm.org/D105395

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


[PATCH] D103165: Threading: use independent llvm::thread implementation on Apple platforms to increase stack size

2021-07-06 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

This LGTM, with some whitespace nits inline.

In D103165#2790932 , @t.p.northover 
wrote:

>> Also this way llvm::thread users that don't need full-sized stacks can 
>> continue getting the Darwin default of smaller pages.
>
> I'm not sure I've implemented this, since I've just made 8MB the Darwin 
> default here. The case I care about is LTOBackend via `ThreadPool`. Would you 
> prefer me to push an optional `StackSize` argument into `ThreadPool` too and 
> make LTOBackend specify it?
>
> I kind of think this has come up often enough (it's at least the second time 
> I've had to fix it somewhere), and 8MB is small enough for anything running 
> Clang that it's better to make sure it doesn't happen again.

8MB by default is probably fine; I don't feel strongly either way.




Comment at: llvm/include/llvm/Support/thread.h:107
+
+  bool joinable() const noexcept {
+return Thread != native_handle_type();

Seems like you might as well run `git-clang-format` to pick up these changes...



Comment at: llvm/include/llvm/Support/thread.h:261
+#endif // LLVM_SUPPORT_THREAD_H
\ No newline at end of file


Looks like it's missing a newline here at the end of the file.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103165/new/

https://reviews.llvm.org/D103165

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-07-06 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

> I'd like to give some time for other stakeholders to give their opinion if 
> this is not too urgent, specially @Quuxplusone and @rsmith.

I have no strong/well-informed opinions here. I have an idea to offer, //if// 
there is precedent for it. My idea is, keep it as an error if the rvalue 
resolution finds nothing, but (1) fall back to an lvalue resolution //for 
error-recovery purposes//, and (2) suppress the error in system headers. Then, 
the usage in MSVC STL will keep working but only because it's in a system 
header. I seem to recall that there is precedent for diagnostics that are 
"non-downgradable error in user code, yet still suppressed in system headers." 
If I'm imagining things, then please do not invent such a facility purely for 
this feature.

My second choice is to do whatever minimalistic hack suffices to satisfy the 
customer (Aaron etc. in this case), but only with the understanding that we 
plan to eliminate that hack as soon as MSVC STL gets updated. My third choice 
is to revert the whole thing and then land a new version of it that always 
falls back to lvalue resolution, but with an on-by-default //warning// (not 
error) (so this would probably affect a ton of your test cases); then the user 
can downgrade that warning as a workaround.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99005/new/

https://reviews.llvm.org/D99005

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-07-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D99005#2860598 , @Quuxplusone wrote:

> I have no strong/well-informed opinions here. I have an idea to offer, //if// 
> there is precedent for it. My idea is, keep it as an error if the rvalue 
> resolution finds nothing, but (1) fall back to an lvalue resolution //for 
> error-recovery purposes//, and (2) suppress the error in system headers. 
> Then, the usage in MSVC STL will keep working but only because it's in a 
> system header. I seem to recall that there is precedent for diagnostics that 
> are "non-downgradable error in user code, yet still suppressed in system 
> headers." If I'm imagining things, then please do not invent such a facility 
> purely for this feature.

That would still leave the effect of changing the deduced type of a 
`decltype(auto)` returning function. But I am on the same boat here in that I 
am not sure if you are imagining things as well :)

> My second choice is to do whatever minimalistic hack suffices to satisfy the 
> customer (Aaron etc. in this case), but only with the understanding that we 
> plan to eliminate that hack as soon as MSVC STL gets updated. My third choice 
> is to revert the whole thing and then land a new version of it that always 
> falls back to lvalue resolution, but with an on-by-default //warning// (not 
> error) (so this would probably affect a ton of your test cases); then the 
> user can downgrade that warning as a workaround.

Again, the change in flow where we make the expression an xvalue early and 
definitively before return type deduction occurs makes things more complicated.

My vote is the second choice, as I think making a workaround where we 
temporarily do the C++20 thing only in some contexts is far simpler, specially 
if we don't have to update a ton of test cases to cover it :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99005/new/

https://reviews.llvm.org/D99005

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


[PATCH] D105512: [AIX] Don't pass no-integrated-as by default

2021-07-06 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
jsji added reviewers: PowerPC, shchenz.
jsji requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

D105314  added the abibility choose to use 
AsmParser for parsing inline
asm. -no-intergrated-as will override this default if specified
explicitly.

If toolchain choose to use MCAsmParser for inline asm, don't pass
the option to disable integrated-as explictly unless set by user.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105512

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-as.c


Index: clang/test/Driver/aix-as.c
===
--- clang/test/Driver/aix-as.c
+++ clang/test/Driver/aix-as.c
@@ -63,3 +63,18 @@
 // CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
 // CHECK-AS32-MultiInput: "-a32"
 // CHECK-AS32-MultiInput: "-many"
+
+// Check not passing no-integrated-as flag by default.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS 
--implicit-check-not=-no-integrated-as %s
+// CHECK-IAS: InstalledDir
+// CHECK-IAS: "-a64"
+
+// Check passing no-integrated-as flag if specified by user.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 -fno-integrated-as \
+// RUN:   | FileCheck --check-prefix=CHECK-NOIAS %s
+// CHECK-NOIAS: InstalledDir
+// CHECK-NOIAS: -no-integrated-as
+// CHECK-NOIAS: "-a64"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5038,7 +5038,9 @@
   << A->getValue() << A->getOption().getName();
   }
 
-  if (!TC.useIntegratedAs())
+  // If toolchain choose to use MCAsmParser for inline asm don't pass the
+  // option to disable integrated-as explictly.
+  if (!TC.useIntegratedAs() && !TC.parseInlineAsmUsingAsmParser())
 CmdArgs.push_back("-no-integrated-as");
 
   if (Args.hasArg(options::OPT_fdebug_pass_structure)) {
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -59,6 +59,9 @@
   AIX(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
 
+  bool parseInlineAsmUsingAsmParser() const override {
+return ParseInlineAsmUsingAsmParser;
+  }
   bool isPICDefault() const override { return true; }
   bool isPIEDefault() const override { return false; }
   bool isPICDefaultForced() const override { return true; }
@@ -87,6 +90,7 @@
 
 private:
   llvm::StringRef GetHeaderSysroot(const llvm::opt::ArgList &DriverArgs) const;
+  bool ParseInlineAsmUsingAsmParser;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -176,6 +176,8 @@
 /// AIX - AIX tool chain which can call as(1) and ld(1) directly.
 AIX::AIX(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
+  ParseInlineAsmUsingAsmParser = Args.hasFlag(
+  options::OPT_fintegrated_as, options::OPT_fno_integrated_as, true);
   getLibraryPaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -380,6 +380,10 @@
   /// Check if the toolchain should use the integrated assembler.
   virtual bool useIntegratedAs() const;
 
+  /// Check if the toolchain should use AsmParser to parse inlineAsm when
+  /// integrated assembler is not default.
+  virtual bool parseInlineAsmUsingAsmParser() const { return false; }
+
   /// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
   virtual bool IsMathErrnoDefault() const { return true; }
 


Index: clang/test/Driver/aix-as.c
===
--- clang/test/Driver/aix-as.c
+++ clang/test/Driver/aix-as.c
@@ -63,3 +63,18 @@
 // CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
 // CHECK-AS32-MultiInput: "-a32"
 // CHECK-AS32-MultiInput: "-many"
+
+// Check not passing no-integrated-as flag by default.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS --implicit-check-not=-no-integrated-as %s
+// CHECK-IAS: InstalledDir
+// CHECK-IAS: "-a64"
+
+// Check passing no-integrated-as flag i

[PATCH] D105447: [analyzer] Allow cmake options to be passed to satest container

2021-07-06 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 356821.
manas added a comment.

Pass commands through settings instead of rest


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105447/new/

https://reviews.llvm.org/D105447

Files:
  clang/utils/analyzer/entrypoint.py


Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -9,10 +9,11 @@
 
 def main():
 settings, rest = parse_arguments()
+cmake_opts = ['-D' + cmd for cmd in settings.D]
 if settings.wait:
 wait()
 if settings.build_llvm or settings.build_llvm_only:
-build_llvm()
+build_llvm(cmake_opts)
 if settings.build_llvm_only:
 return
 sys.exit(test(rest))
@@ -30,14 +31,15 @@
 parser.add_argument('--wait', action='store_true')
 parser.add_argument('--build-llvm', action='store_true')
 parser.add_argument('--build-llvm-only', action='store_true')
+parser.add_argument('-D', action='append', default=[])
 return parser.parse_known_args()
 
 
-def build_llvm():
+def build_llvm(cmake_options):
 os.chdir('/build')
 try:
 if is_cmake_needed():
-cmake()
+cmake(cmake_options)
 ninja()
 except CalledProcessError:
 print("Build failed!")
@@ -55,8 +57,9 @@
 "-DCLANG_ENABLE_STATIC_ANALYZER=ON"
 
 
-def cmake():
-check_call(CMAKE_COMMAND + ' /llvm-project/llvm', shell=True)
+def cmake(cmake_options):
+check_call(CMAKE_COMMAND + ' '.join(cmake_options) + ' /llvm-project/llvm',
+shell=True)
 
 
 def ninja():


Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -9,10 +9,11 @@
 
 def main():
 settings, rest = parse_arguments()
+cmake_opts = ['-D' + cmd for cmd in settings.D]
 if settings.wait:
 wait()
 if settings.build_llvm or settings.build_llvm_only:
-build_llvm()
+build_llvm(cmake_opts)
 if settings.build_llvm_only:
 return
 sys.exit(test(rest))
@@ -30,14 +31,15 @@
 parser.add_argument('--wait', action='store_true')
 parser.add_argument('--build-llvm', action='store_true')
 parser.add_argument('--build-llvm-only', action='store_true')
+parser.add_argument('-D', action='append', default=[])
 return parser.parse_known_args()
 
 
-def build_llvm():
+def build_llvm(cmake_options):
 os.chdir('/build')
 try:
 if is_cmake_needed():
-cmake()
+cmake(cmake_options)
 ninja()
 except CalledProcessError:
 print("Build failed!")
@@ -55,8 +57,9 @@
 "-DCLANG_ENABLE_STATIC_ANALYZER=ON"
 
 
-def cmake():
-check_call(CMAKE_COMMAND + ' /llvm-project/llvm', shell=True)
+def cmake(cmake_options):
+check_call(CMAKE_COMMAND + ' '.join(cmake_options) + ' /llvm-project/llvm',
+shell=True)
 
 
 def ninja():
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105375: [OPENMP]Remove const firstprivate allocation as a variable in a constant space.

2021-07-06 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari accepted this revision.
vzakhari added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105375/new/

https://reviews.llvm.org/D105375

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


[PATCH] D105516: [clang][PassManager] Add -falways-mem2reg to run mem2reg at -O0

2021-07-06 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 created this revision.
jrtc27 added reviewers: chandlerc, rjmccall, rsmith.
Herald added subscribers: ormris, dexonsmith, dang, s.egerton, simoncook, 
hiraditya, kristof.beyls.
jrtc27 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Standard -O0 IR and assembly can be hard to follow as, without mem2reg,
there are loads and stores to the stack everywhere that clutter things
up and make it hard to see where the actual interesting instructions are
(such as when trying to debug a crash in unoptimised code from the
disassembly). It is therefore useful to be able to force mem2reg to be
run even at -O0 to clean up a lot of those stack loads and stores. There
are also Clang CodeGen tests in the tree that explicitly run mem2reg on
the output in order to make the CHECK lines more readable, which
requires manually passing -disable-O0-optnone and pipling to opt; having
a flag for the driver that supports this also makes those less clunky.

Whilst optimisation for speed's sake is not the primary purpose of this
patch, it does provide an easy significant improvement in code size as
you might expect, giving a ~12% decrease in code size on macOS/arm64
when compiling Clang itself with the option enabled, likely also having
a significant improvement on the running time of the test suite over a
plain Debug build. On GNU/Linux/amd64 the decrease is less pronounced,
at about 4%, likely due to the fact that many instructions can take one
memory operand and so do not have to pay the additional cost of a load
or store like on load-store architectures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105516

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/falways-mem2reg.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -187,6 +187,7 @@
 LibraryInfo = nullptr;
 Inliner = nullptr;
 DisableUnrollLoops = false;
+AlwaysMem2Reg = false;
 SLPVectorize = false;
 LoopVectorize = true;
 LoopsInterleaved = true;
@@ -658,8 +659,11 @@
   MPM.add(createForceFunctionAttrsLegacyPass());
 
   // If all optimizations are disabled, just run the always-inline pass and,
-  // if enabled, the function merging pass.
+  // if enabled, the mem2reg and function merging passes.
   if (OptLevel == 0) {
+if (AlwaysMem2Reg)
+  MPM.add(createPromoteMemoryToRegisterPass());
+
 addPGOInstrPasses(MPM);
 if (Inliner) {
   MPM.add(Inliner);
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -283,6 +283,7 @@
   SLPVectorization = false;
   LoopUnrolling = true;
   ForgetAllSCEVInLoopUnroll = ForgetSCEVInLoopUnroll;
+  AlwaysMem2Reg = false;
   Coroutines = false;
   LicmMssaOptCap = SetLicmMssaOptCap;
   LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
@@ -1931,6 +1932,9 @@
   MPM.addPass(AlwaysInlinerPass(
   /*InsertLifetimeIntrinsics=*/PTO.Coroutines));
 
+  if (PTO.AlwaysMem2Reg)
+MPM.addPass(createModuleToFunctionPassAdaptor(PromotePass()));
+
   if (PTO.MergeFunctions)
 MPM.addPass(MergeFunctionsPass());
 
Index: llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
===
--- llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
+++ llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
@@ -156,6 +156,7 @@
 
   bool DisableTailCalls;
   bool DisableUnrollLoops;
+  bool AlwaysMem2Reg;
   bool CallGraphProfile;
   bool SLPVectorize;
   bool LoopVectorize;
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -107,6 +107,10 @@
   /// is that of the flag: `-forget-scev-loop-unroll`.
   bool ForgetAllSCEVInLoopUnroll;
 
+  /// Tuning option to always run mem2reg regardless of the optimisation level.
+  /// Its default value is false.
+  bool AlwaysMem2Reg;
+
   /// Tuning option to enable/disable coroutine intrinsic lowering. Its default
   /// value is false. Frontends such as Clang may enable this conditionally. For
   /// example, Clang enables this option if the flags `-std=c++2a` or above, or
Index: clang/test/CodeGen/falways-mem2reg.c
===
--- /dev/null
+++ cl

[PATCH] D102582: [RISCV] Report an error when ABI mismatch with target-abi module flag.

2021-07-06 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/test/CodeGen/RISCV/module-target-abi-tests.ll:5
+; RUN: cat %s > %t.emptyabi
+; RUN: echo '!0 = !{i32 1, !"target-abi", !""}' >> %t.emptyabi
+; RUN: llc -mtriple=riscv32 < %t.emptyabi -o /dev/null

khchen wrote:
> jrtc27 wrote:
> > khchen wrote:
> > > khchen wrote:
> > > > luismarques wrote:
> > > > > Is this something that we are handling in general, having such flag 
> > > > > without a value?
> > > > Good cached, in general the target-abi is not empty, I updated the 
> > > > current implementation, thanks!
> > > @luismarques 
> > > 
> > > Sorry, I forget that the empty target-abi are coming from some clang cc1 
> > > tests. 
> > > They are missing -target-abi option in clang cc1 so target-abi module 
> > > flag is empty.
> > >  
> > > ```
> > > CodeGen/RISCV/riscv-atomics.c
> > > CodeGen/RISCV/riscv-inline-asm-rvv.c
> > > CodeGen/RISCV/riscv-inline-asm-xsfvfhbfmin.c
> > > CodeGen/RISCV/riscv-inline-asm.c
> > > ```
> > > 
> > > Maybe we need to calculate the default target-abi if it's empty? or 
> > > handle empty target-abi in the backend?
> > > 
> > I do think we should be filling in the default ABI here, otherwise it's 
> > very fragile.
> Do you mean cc1 need to calculate the default target-abi and fill it in IR? 
Yes. Otherwise if Clang and LLVM ever disagree on the default ABI for any 
particular case then you will get inconsistent code, as the C source-visible 
ABI will use one but the code generation will use another. It also means you 
can never change the default ABI in LLVM since otherwise you will break 
existing bitcode files that rely on the default.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102582/new/

https://reviews.llvm.org/D102582

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


[PATCH] D105380: [clang] fixes named return of variables with dependent alignment

2021-07-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 356833.
mizvekov added a comment.

- hasDependentAlignment now returns true for VarDecls with undeduced auto types.
- Add couple of tests that cover these kinds of VarDecls appearing:
  - Valid code with a range for loop in dependent context.
  - Error recovery on invalid initialization of auto variable in dependent 
context.

Remove `isInvalidDecl` check on FinalizeDeclaration for alignment of TLS 
variables,
as this is covered by the undeduced auto check above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105380/new/

https://reviews.llvm.org/D105380

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CodeGen/nrvo-tracking.cpp

Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -std=c++20 -fblocks -Wno-return-stack-address -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
 
-struct X {
-X();
-X(const X&);
-X(X&&);
+struct alignas(4) X {
+  X();
+  X(const X &);
+  X(X &&);
 };
 
 #define L(A, B, C) void l##A() {\
@@ -210,3 +210,75 @@
 };
   }()();
 }
+
+namespace test_alignas {
+
+template  X t1() {
+  X a [[gnu::aligned(A)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi1EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t1<1>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi4EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t1<4>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi8EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template X t1<8>();
+
+template  X t2() {
+  X a [[gnu::aligned(1)]] [[gnu::aligned(A)]] [[gnu::aligned(2)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t2ILi1EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t2<1>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t2ILi4EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t2<4>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t2ILi8EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template X t2<8>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t3Ev
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+X t3() {
+  X a [[gnu::aligned(1)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t4Ev
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+X t4() {
+  X a [[gnu::aligned(8)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t5Ev
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+X t5() {
+  X a [[gnu::aligned(1)]] [[gnu::aligned(8)]];
+  return a;
+}
+
+} // namespace test_alignas
Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -487,3 +487,27 @@
 }
 
 } // namespace test_simpler_implicit_move
+
+namespace test_auto_variables {
+
+template struct X {};
+
+template struct range {
+  X *begin() const;
+  X *end() const;
+};
+
+template X test_dependent_ranged_for() {
+  for(auto x : range())
+return x;
+  return X();
+}
+template X test_dependent_ranged_for();
+
+template X test_dependent_invalid_decl() {
+  auto x = X().foo(); // expected-error {{no member named 'foo'}}
+  return x;
+}
+template X test_dependent_invalid_decl(); // expected-note {{requested here}}
+
+} // namespace test_auto_variables
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3395,7 +3395,7 @@
 
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
-  if (!VDType->isDependentType() && VD->hasAttr() &&
+  if (!VD->hasDependentAlignment() &&
   Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 Info.S = NamedReturnInfo::MoveEligible;
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13310,16 +13310,6 @@
 CheckCompleteDeco

[PATCH] D71387: pass -mabi to LTO linker only in RISC-V targets, enable RISC-V LTO

2021-07-06 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:633
 
+  // pass more options in specific target
+  switch (ToolChain.getArch()) {





Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:634-638
+  switch (ToolChain.getArch()) {
+  default:
+break;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64: {

ToolChain.getArch().isRISCV()? No need for a switch until there are other 
architectures that need code here too.



Comment at: clang/test/Driver/lto.c:126
+// RUN: %clang -target riscv32-unknown-linux-gnu %s -fuse-ld=gold -flto \
+// RUN:   -mabi=ilp32f -### 2>&1 | FileCheck %s --check-prefix=RISCV-SPEC-ABI-1
+// RUN: %clang -target riscv32-unknown-linux-gnu %s -fuse-ld=gold -flto \

Give these meaningful names



Comment at: clang/test/Driver/lto.c:134-137
+// RISCV-SPEC-ABI-1: "-plugin-opt=-target-abi=ilp32f"
+// RISCV-SPEC-ABI-2: "-plugin-opt=-target-abi=ilp32d"
+// RISCV-SPEC-ABI-3: "-plugin-opt=-target-abi=lp64"
+// RISCV-SPEC-ABI-4: "-plugin-opt=-target-abi=lp64f"

Why this set without ilp32 and lp64d, two of the four most common ABIs?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71387/new/

https://reviews.llvm.org/D71387

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


[clang] 6c9559b - DebugInfo: Mangle K&R declarations for debug info linkage names

2021-07-06 Thread David Blaikie via cfe-commits
Author: David Blaikie
Date: 2021-07-06T16:28:02-07:00
New Revision: 6c9559b67b91966bfeff9e17808a3e84a92e64a0

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

LOG: DebugInfo: Mangle K&R declarations for debug info linkage names

This fixes a gap in the `overloadable` attribute support (K&R declared
functions would get mangled symbol names, but that name wouldn't be
represented in the debug info linkage name field for the function) and
in -funique-internal-linkage-names (this came up in review discussion on
D98799) where K&R static declarations would not get the uniqued linkage
names.

Added: 
clang/test/CodeGen/overloadable-debug.c

Modified: 
clang/lib/AST/ItaniumMangle.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/unique-internal-linkage-names-dwarf.c

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index b5b9cd7535196..c40916308611b 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -649,7 +649,7 @@ bool ItaniumMangleContextImpl::isUniqueInternalLinkageDecl(
 
   // For C functions without prototypes, return false as their
   // names should not be mangled.
-  if (!FD->hasPrototype())
+  if (!FD->getType()->getAs())
 return false;
 
   if (isInternalLinkageDecl(ND))

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8a5b246275b15..0363fd7023f32 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3546,7 +3546,7 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, 
llvm::DIFile *Unit,
   const auto *FD = cast(GD.getCanonicalDecl().getDecl());
   Name = getFunctionName(FD);
   // Use mangled name as linkage name for C/C++ functions.
-  if (FD->hasPrototype()) {
+  if (FD->getType()->getAs()) {
 LinkageName = CGM.getMangledName(GD);
 Flags |= llvm::DINode::FlagPrototyped;
   }

diff  --git a/clang/test/CodeGen/overloadable-debug.c 
b/clang/test/CodeGen/overloadable-debug.c
new file mode 100644
index 0..6eda318844960
--- /dev/null
+++ b/clang/test/CodeGen/overloadable-debug.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck %s
+
+__attribute__((overloadable)) void f1(a) int a; {
+}
+
+// CHECK: !DISubprogram(name: "f1", linkageName: "_Z2f1i"

diff  --git a/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c 
b/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
index e5d507e154aeb..cae839830c6e2 100644
--- a/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
+++ b/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
@@ -13,27 +13,15 @@ static int foo(void) {
   return glob;
 }
 
-// bar should not be given a uniquefied name under 
-funique-internal-linkage-names, 
-// since it doesn't come with valid prototype.
+// K&R prototypes should be given uniquefied names under 
-funique-internal-linkage-names.
 static int bar(a) int a;
 {
   return glob + a;
 }
 
-// go should be given a uniquefied name under -funique-internal-linkage-names, 
even 
-// if its definition doesn't come with a valid prototype, but the declaration 
here
-// has a prototype.
-static int go(int);
-
 void baz() {
   foo();
   bar(1);
-  go(2);
-}
-
-static int go(a) int a;
-{
-  return glob + a;
 }
 
 
@@ -43,13 +31,11 @@ static int go(a) int a;
 // PLAIN: distinct !DIGlobalVariable(name: "glob"{{.*}})
 // PLAIN: distinct !DISubprogram(name: "foo"{{.*}})
 // PLAIN: distinct !DISubprogram(name: "bar"{{.*}})
-// PLAIN: distinct !DISubprogram(name: "go"{{.*}})
 // PLAIN-NOT: linkageName:
 //
 // UNIQUE: @glob = internal global i32
 // UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]()
-// UNIQUE: define internal i32 @bar(i32 %a)
-// UNIQUE: define internal i32 @_ZL2goi.[[MODHASH]](i32 %a)
+// UNIQUE: define internal i32 @_ZL3bari.[[MODHASH]](i32 %a)
 // UNIQUE: distinct !DIGlobalVariable(name: "glob"{{.*}})
 // UNIQUE: distinct !DISubprogram(name: "foo", linkageName: 
"_ZL3foov.[[MODHASH]]"{{.*}})
-// UNIQUE: distinct !DISubprogram(name: "go", linkageName: 
"_ZL2goi.[[MODHASH]]"{{.*}})
+// UNIQUE: distinct !DISubprogram(name: "bar", linkageName: 
"_ZL3bari.[[MODHASH]]"{{.*}})



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


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-07-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D98799#2850700 , @dblaikie wrote:

> In D98799#2850682 , @ahatanak wrote:
>
>> I think I've fixed all the places in CodeGen that create fake 
>> `FunctionDecl`s and would cause clang to crash.
>
> Thanks, I really appreciate it! I'll have a go at unifying this mangled V 
> unique internal linkage name stuff soon.

Committed a patch to resolve the inconsistencies with K&R declarations, 
`__attribute__((overloadable))` (which would mangle overloadable K&R 
declarations, but would not attach the mangled name to the debug info 
metadata), and `-funique-internal-linkage-names` (which wouldn't mangle/suffix 
K&R declarations (but would make this choice consistently between debug info 
and the actual symbol name) - now all those cases can/do mangle the names: 
6c9559b67b91966bfeff9e17808a3e84a92e64a0 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98799/new/

https://reviews.llvm.org/D98799

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


[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-07-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added subscribers: rampitec, arsenm.
MaskRay added a comment.

This is great.

  unsigned long foo(unsigned long addr, unsigned long a0,
unsigned long a1, unsigned long a2,
unsigned long a3, unsigned long a4,
unsigned long a5) {
unsigned long result asm("rax");
unsigned long b2 asm("rdx") = a2;
unsigned long b3 asm("rcx") = a3;
unsigned long b4 asm("r8") = a4;
unsigned long b5 asm("r9") = a5;
asm("call *%1" : "=r" (result) : "{rax}"(addr), "{rdi}"(a0), "{rsi}"(a1), 
"r"(b2), "r"(b3), "r"(b4), "r"(b5));
return result;
  }

this compiles to`%0 = tail call i64 asm "call *$1", 
"=r,{r{ax}x},{r{dx}i},{rsi},r,r,r,r,~{dirflag},~{fpsr},~{flags}"(i64 %addr, i64 
%a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5) #1, !srcloc !3`
(note `{r{ax}x},{r{dx}i}`) which will cause a backend failure `error: couldn't 
allocate input reg for constraint '{r{dx}'`.
Can you investigate it?

> For example the AMDGPU target. It supports syntax of the form {register-name} 
> as well as {register-name[...]}.

CC @arsenm @rampitec for AMDGPU thoughts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105142/new/

https://reviews.llvm.org/D105142

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


[PATCH] D105380: [clang] fixes named return of variables with dependent alignment

2021-07-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 356835.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105380/new/

https://reviews.llvm.org/D105380

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CodeGen/nrvo-tracking.cpp

Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -std=c++20 -fblocks -Wno-return-stack-address -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
 
-struct X {
-X();
-X(const X&);
-X(X&&);
+struct alignas(4) X {
+  X();
+  X(const X &);
+  X(X &&);
 };
 
 #define L(A, B, C) void l##A() {\
@@ -210,3 +210,75 @@
 };
   }()();
 }
+
+namespace test_alignas {
+
+template  X t1() {
+  X a [[gnu::aligned(A)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi1EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t1<1>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi4EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t1<4>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t1ILi8EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template X t1<8>();
+
+template  X t2() {
+  X a [[gnu::aligned(1)]] [[gnu::aligned(A)]] [[gnu::aligned(2)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t2ILi1EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t2<1>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t2ILi4EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+template X t2<4>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t2ILi8EEE1Xv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template X t2<8>();
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t3Ev
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+X t3() {
+  X a [[gnu::aligned(1)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t4Ev
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+X t4() {
+  X a [[gnu::aligned(8)]];
+  return a;
+}
+
+// CHECK-LABEL: define{{.*}} void @_ZN12test_alignas2t5Ev
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
+// CHECK-NEXT:  call void @llvm.lifetime.end
+X t5() {
+  X a [[gnu::aligned(1)]] [[gnu::aligned(8)]];
+  return a;
+}
+
+} // namespace test_alignas
Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -487,3 +487,29 @@
 }
 
 } // namespace test_simpler_implicit_move
+
+namespace test_auto_variables {
+
+struct S {};
+
+template  struct range {
+  S *begin() const;
+  S *end() const;
+};
+
+template  S test_dependent_ranged_for() {
+  for (auto x : range())
+return x;
+  return S();
+}
+template S test_dependent_ranged_for();
+
+template  struct X {};
+
+template  X test_dependent_invalid_decl() {
+  auto x = X().foo(); // expected-error {{no member named 'foo'}}
+  return x;
+}
+template X test_dependent_invalid_decl(); // expected-note {{requested here}}
+
+} // namespace test_auto_variables
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3395,7 +3395,7 @@
 
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
-  if (!VDType->isDependentType() && VD->hasAttr() &&
+  if (!VD->hasDependentAlignment() &&
   Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 Info.S = NamedReturnInfo::MoveEligible;
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13310,16 +13310,6 @@
 CheckCompleteDecompositionDeclaration(DD);
 }
 
-/// Determines if a variable's alignment is dependent.
-static bool hasDependentAlignment(VarDecl *VD) {
-  if (VD->getType()->isDependentType())
-return true;
-  for (auto *I : VD->specific_attrs())
-if (I->isAlignmentDependent())
-  return true;
-  return false;
-}
-
 /// Check if VD needs to be dllexport/dllimport due to being in a
 /// dllexport/import functio

[PATCH] D105451: [clang] Fix crash when there is an invalid declaration with flag -Wcast-align

2021-07-06 Thread Queen Dela Cruz via Phabricator via cfe-commits
qdelacru updated this revision to Diff 356836.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105451/new/

https://reviews.llvm.org/D105451

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-cast-align.c


Index: clang/test/Sema/warn-cast-align.c
===
--- clang/test/Sema/warn-cast-align.c
+++ clang/test/Sema/warn-cast-align.c
@@ -67,3 +67,11 @@
 FnTy test5(void) {
   return (FnTy)&func5;
 }
+
+void test6() {
+  struct {
+int hello;
+doesnotexist world; // expected-error {{unknown type name 'doesnotexist'}}
+  } foo;
+  void **repro = (void **)&foo.hello; // expected-warning {{cast from 'int *' 
to 'void **' increases required alignment from 4 to 8}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14475,7 +14475,8 @@
   case Stmt::MemberExprClass: {
 auto *ME = cast(E);
 auto *FD = dyn_cast(ME->getMemberDecl());
-if (!FD || FD->getType()->isReferenceType())
+if (!FD || FD->getType()->isReferenceType() ||
+FD->getParent()->isInvalidDecl())
   break;
 Optional> P;
 if (ME->isArrow())


Index: clang/test/Sema/warn-cast-align.c
===
--- clang/test/Sema/warn-cast-align.c
+++ clang/test/Sema/warn-cast-align.c
@@ -67,3 +67,11 @@
 FnTy test5(void) {
   return (FnTy)&func5;
 }
+
+void test6() {
+  struct {
+int hello;
+doesnotexist world; // expected-error {{unknown type name 'doesnotexist'}}
+  } foo;
+  void **repro = (void **)&foo.hello; // expected-warning {{cast from 'int *' to 'void **' increases required alignment from 4 to 8}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14475,7 +14475,8 @@
   case Stmt::MemberExprClass: {
 auto *ME = cast(E);
 auto *FD = dyn_cast(ME->getMemberDecl());
-if (!FD || FD->getType()->isReferenceType())
+if (!FD || FD->getType()->isReferenceType() ||
+FD->getParent()->isInvalidDecl())
   break;
 Optional> P;
 if (ME->isArrow())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-07-06 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added a comment.

In D98799#2860881 , @dblaikie wrote:

> In D98799#2850700 , @dblaikie wrote:
>
>> In D98799#2850682 , @ahatanak wrote:
>>
>>> I think I've fixed all the places in CodeGen that create fake 
>>> `FunctionDecl`s and would cause clang to crash.
>>
>> Thanks, I really appreciate it! I'll have a go at unifying this mangled V 
>> unique internal linkage name stuff soon.
>
> Committed a patch to resolve the inconsistencies with K&R declarations, 
> `__attribute__((overloadable))` (which would mangle overloadable K&R 
> declarations, but would not attach the mangled name to the debug info 
> metadata), and `-funique-internal-linkage-names` (which wouldn't 
> mangle/suffix K&R declarations (but would make this choice consistently 
> between debug info and the actual symbol name) - now all those cases can/do 
> mangle the names: 6c9559b67b91966bfeff9e17808a3e84a92e64a0 
> 

Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98799/new/

https://reviews.llvm.org/D98799

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


  1   2   >