[PATCH] D111760: [clang] Support __float128 on DragonFlyBSD.

2021-10-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:182
 DefineStd(Builder, "unix", Opts);
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");

Maybe I'm missing something but do you actually need to state `this->` 
explicitly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111760

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


[clang] 37ca7a7 - Fix missing failures in clang-ppc64be* and retry fixing clang-x64-windows-msvc

2021-10-16 Thread Juneyoung Lee via cfe-commits

Author: Juneyoung Lee
Date: 2021-10-16T16:20:14+09:00
New Revision: 37ca7a795b277c20c02a218bf44052278c03344b

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

LOG: Fix missing failures in clang-ppc64be* and retry fixing 
clang-x64-windows-msvc

Added: 


Modified: 
clang/test/CodeGen/ppc-mm-malloc.c
clang/test/CodeGenCXX/mangle-abi-tag.cpp

Removed: 




diff  --git a/clang/test/CodeGen/ppc-mm-malloc.c 
b/clang/test/CodeGen/ppc-mm-malloc.c
index f7102459afa3b..25711e80fffd2 100644
--- a/clang/test/CodeGen/ppc-mm-malloc.c
+++ b/clang/test/CodeGen/ppc-mm-malloc.c
@@ -35,7 +35,7 @@ test_mm_malloc() {
 // CHECK: [[REG24]]:
 // CHECK-NEXT: [[REG26:[0-9a-zA-Z_%.]+]] = load i64, i64* [[REG5]], align 8
 // CHECK-NEXT: [[REG27:[0-9a-zA-Z_%.]+]] = load i64, i64* [[REG4]], align 8
-// CHECK-NEXT: [[REG28:[0-9a-zA-Z_%.]+]] = call signext i32 
@posix_memalign(i8** [[REG29:[0-9a-zA-Z_%.]+]], i64 [[REG26]], i64 [[REG27]])
+// CHECK-NEXT: [[REG28:[0-9a-zA-Z_%.]+]] = call signext i32 
@posix_memalign(i8** noundef [[REG29:[0-9a-zA-Z_%.]+]], i64 noundef [[REG26]], 
i64 noundef [[REG27]])
 // CHECK-NEXT: [[REG30:[0-9a-zA-Z_%.]+]] = icmp eq i32 [[REG28]], 0
 // CHECK-NEXT: br i1 [[REG30]], label %[[REG31:[0-9a-zA-Z_%.]+]], label 
%[[REG32:[0-9a-zA-Z_%.]+]]
 // CHECK: [[REG31]]:
@@ -49,8 +49,8 @@ test_mm_malloc() {
 // CHECK-NEXT: [[REG34:[0-9a-zA-Z_%.]+]] = load i8*, i8** [[REG3]], align 8
 // CHECK-NEXT: ret i8* [[REG34]]
 
-// CHECK: define internal void @_mm_free(i8* [[REG35:[0-9a-zA-Z_%.]+]])
+// CHECK: define internal void @_mm_free(i8* noundef [[REG35:[0-9a-zA-Z_%.]+]])
 // CHECK: store i8* [[REG35]], i8** [[REG36:[0-9a-zA-Z_%.]+]], align 8
 // CHECK-NEXT: [[REG37:[0-9a-zA-Z_%.]+]] = load i8*, i8** [[REG36]], align 8
-// CHECK-NEXT: call void @free(i8* [[REG37]])
+// CHECK-NEXT: call void @free(i8* noundef [[REG37]])
 // CHECK-NEXT: ret void

diff  --git a/clang/test/CodeGenCXX/mangle-abi-tag.cpp 
b/clang/test/CodeGenCXX/mangle-abi-tag.cpp
index 433d500bcad6c..5399d829f37b0 100644
--- a/clang/test/CodeGenCXX/mangle-abi-tag.cpp
+++ b/clang/test/CodeGenCXX/mangle-abi-tag.cpp
@@ -145,7 +145,7 @@ void f13_test() {
   f13();
 }
 // f13()::L::foo[abi:C][abi:D]()
-// CHECK-DAG: define linkonce_odr {{(noundef )?}}{{(dso_local )?}}%struct.E* 
@_ZZ3f13vEN1L3fooB1CB1DEv(
+// CHECK-DAG: define linkonce_odr {{(dso_local )?}}{{(noundef )?}}%struct.E* 
@_ZZ3f13vEN1L3fooB1CB1DEv(
 
 // f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
 // CHECK-DAG: @_ZZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =



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


[clang-tools-extra] f071110 - [clang-tidy] Fix false positive in cppcoreguidelines-virtual-class-destructor

2021-10-16 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2021-10-16T08:27:08Z
New Revision: f0711106dc6c14dcaf06437a0467043e983bf9dc

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

LOG: [clang-tidy] Fix false positive in 
cppcoreguidelines-virtual-class-destructor

Incorrectly triggers for template classes that inherit
from a base class that has virtual destructor.

Any class inheriting from a base that has a virtual destructor
will have their destructor also virtual, as per the Standard:

https://timsong-cpp.github.io/cppwp/n4140/class.dtor#9

> If a class has a base class with a virtual destructor,
> its destructor (whether user- or implicitly-declared) is virtual.

Added unit tests to prevent regression.

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

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

Added: 


Modified: 

clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
index d9c8ecf9d033a..0cf7cc9ad6d52 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -19,6 +19,21 @@ namespace clang {
 namespace tidy {
 namespace cppcoreguidelines {
 
+AST_MATCHER(CXXRecordDecl, hasPublicVirtualOrProtectedNonVirtualDestructor) {
+  // We need to call Node.getDestructor() instead of matching a
+  // CXXDestructorDecl. Otherwise, tests will fail for class templates, since
+  // the primary template (not the specialization) always gets a non-virtual
+  // CXXDestructorDecl in the AST. https://bugs.llvm.org/show_bug.cgi?id=51912
+  const CXXDestructorDecl *Destructor = Node.getDestructor();
+  if (!Destructor)
+return false;
+
+  return (((Destructor->getAccess() == AccessSpecifier::AS_public) &&
+   Destructor->isVirtual()) ||
+  ((Destructor->getAccess() == AccessSpecifier::AS_protected) &&
+   !Destructor->isVirtual()));
+}
+
 void VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
   ast_matchers::internal::Matcher InheritsVirtualMethod =
   hasAnyBase(hasType(cxxRecordDecl(has(cxxMethodDecl(isVirtual());
@@ -26,9 +41,7 @@ void 
VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   cxxRecordDecl(
   anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
-  unless(anyOf(
-  has(cxxDestructorDecl(isPublic(), isVirtual())),
-  has(cxxDestructorDecl(isProtected(), unless(isVirtual()))
+  unless(hasPublicVirtualOrProtectedNonVirtualDestructor()))
   .bind("ProblematicClassOrStruct"),
   this);
 }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
index 0aa5723b81afa..3fe392e05a95f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
@@ -202,3 +202,73 @@ struct NonOverridingDerivedStruct : 
ProtectedNonVirtualBaseStruct {
   void m();
 };
 // inherits virtual method
+
+namespace Bugzilla_51912 {
+// Fixes https://bugs.llvm.org/show_bug.cgi?id=51912
+
+// Forward declarations
+// CHECK-MESSAGES-NOT: :[[@LINE+1]]:8: warning: destructor of 
'ForwardDeclaredStruct' is public and non-virtual 
[cppcoreguidelines-virtual-class-destructor]
+struct ForwardDeclaredStruct;
+
+struct ForwardDeclaredStruct : PublicVirtualBaseStruct {
+};
+
+// Normal Template
+// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 
'TemplatedDerived' is public and non-virtual 
[cppcoreguidelines-virtual-class-destructor]
+template 
+struct TemplatedDerived : PublicVirtualBaseStruct {
+};
+
+TemplatedDerived InstantiationWithInt;
+
+// Derived from template, base has virtual dtor
+// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 
'DerivedFromTemplateVirtualBaseStruct' is public and non-virtual 
[cppcoreguidelines-virtual-class-destructor]
+template 
+struct DerivedFromTemplateVirtualBaseStruct : T {
+  virtual void foo();
+};
+
+DerivedFromTemplateVirtualBaseStruct 
InstantiationWithPublicVirtualBaseStruct;
+
+// Derived from template, base has *not* virtual dtor
+// CHECK-MESSAGES: :[[@LINE+8]]:8: warning: destructor of 
'DerivedFromTemplateNonVirtualBaseStruct' is public and non-virtual 
[cppcoreguidelines-virtual-cl

[PATCH] D110614: [clang-tidy] Fix false positives in cppcoreguidelines-virtual-class-destructor

2021-10-16 Thread Carlos Galvez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0711106dc6c: [clang-tidy] Fix false positive in 
cppcoreguidelines-virtual-class-destructor (authored by carlosgalvezp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110614

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
@@ -202,3 +202,73 @@
   void m();
 };
 // inherits virtual method
+
+namespace Bugzilla_51912 {
+// Fixes https://bugs.llvm.org/show_bug.cgi?id=51912
+
+// Forward declarations
+// CHECK-MESSAGES-NOT: :[[@LINE+1]]:8: warning: destructor of 'ForwardDeclaredStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+struct ForwardDeclaredStruct;
+
+struct ForwardDeclaredStruct : PublicVirtualBaseStruct {
+};
+
+// Normal Template
+// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'TemplatedDerived' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+template 
+struct TemplatedDerived : PublicVirtualBaseStruct {
+};
+
+TemplatedDerived InstantiationWithInt;
+
+// Derived from template, base has virtual dtor
+// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'DerivedFromTemplateVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+template 
+struct DerivedFromTemplateVirtualBaseStruct : T {
+  virtual void foo();
+};
+
+DerivedFromTemplateVirtualBaseStruct InstantiationWithPublicVirtualBaseStruct;
+
+// Derived from template, base has *not* virtual dtor
+// CHECK-MESSAGES: :[[@LINE+8]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+7]]:8: note: make it public and virtual
+// CHECK-MESSAGES: :[[@LINE+6]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-FIXES: struct DerivedFromTemplateNonVirtualBaseStruct : T {
+// CHECK-FIXES-NEXT: virtual ~DerivedFromTemplateNonVirtualBaseStruct() = default;
+// CHECK-FIXES-NEXT: virtual void foo();
+// CHECK-FIXES-NEXT: };
+template 
+struct DerivedFromTemplateNonVirtualBaseStruct : T {
+  virtual void foo();
+};
+
+DerivedFromTemplateNonVirtualBaseStruct InstantiationWithPublicNonVirtualBaseStruct;
+
+// Derived from template, base has virtual dtor, to be used in a typedef
+// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'DerivedFromTemplateVirtualBaseStruct2' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+template 
+struct DerivedFromTemplateVirtualBaseStruct2 : T {
+  virtual void foo();
+};
+
+using DerivedFromTemplateVirtualBaseStruct2Typedef = DerivedFromTemplateVirtualBaseStruct2;
+DerivedFromTemplateVirtualBaseStruct2Typedef InstantiationWithPublicVirtualBaseStruct2;
+
+// Derived from template, base has *not* virtual dtor, to be used in a typedef
+// CHECK-MESSAGES: :[[@LINE+8]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct2' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+7]]:8: note: make it public and virtual
+// CHECK-MESSAGES: :[[@LINE+6]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct2' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-FIXES: struct DerivedFromTemplateNonVirtualBaseStruct2 : T {
+// CHECK-FIXES-NEXT: virtual ~DerivedFromTemplateNonVirtualBaseStruct2() = default;
+// CHECK-FIXES-NEXT: virtual void foo();
+// CHECK-FIXES-NEXT: };
+template 
+struct DerivedFromTemplateNonVirtualBaseStruct2 : T {
+  virtual void foo();
+};
+
+using DerivedFromTemplateNonVirtualBaseStruct2Typedef = DerivedFromTemplateNonVirtualBaseStruct2;
+DerivedFromTemplateNonVirtualBaseStruct2Typedef InstantiationWithPublicNonVirtualBaseStruct2;
+
+} // namespace Bugzilla_51912
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -19,6 +19,21 @@
 namespace tidy {
 namespace cppcoreguidelines {
 
+AST_MATCHER(CXXRecordDecl, hasPublicVirtualOrProtectedNonVirtualDestructor) {
+  // We need to call Node.getDestructor() instead of matching a
+  // CXXDestructorDecl. Ot

[PATCH] D110065: [AArch64] Add support for the 'R' architecture profile.

2021-10-16 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea updated this revision to Diff 380171.
labrinea added a comment.

Added an alternative name to indicate sytem register aliasing.


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

https://reviews.llvm.org/D110065

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64SystemOperands.td
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
  llvm/test/CodeGen/AArch64/arm64-crc32.ll
  llvm/test/MC/AArch64/arm64-branch-encoding.s
  llvm/test/MC/AArch64/arm64-system-encoding.s
  llvm/test/MC/AArch64/armv8.1a-lse.s
  llvm/test/MC/AArch64/armv8.1a-pan.s
  llvm/test/MC/AArch64/armv8.1a-rdma.s
  llvm/test/MC/AArch64/armv8.2a-at.s
  llvm/test/MC/AArch64/armv8.2a-crypto.s
  llvm/test/MC/AArch64/armv8.2a-dotprod-errors.s
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.2a-persistent-memory.s
  llvm/test/MC/AArch64/armv8.2a-uao.s
  llvm/test/MC/AArch64/armv8r-inst.s
  llvm/test/MC/AArch64/armv8r-sysreg.s
  llvm/test/MC/AArch64/armv8r-unsupported-inst.s
  llvm/test/MC/AArch64/armv8r-unsupported-sysreg.s
  llvm/test/MC/AArch64/basic-a64-instructions.s
  llvm/test/MC/AArch64/ras-extension.s
  llvm/test/MC/Disassembler/AArch64/arm64-branch.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-complex.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-js.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-dit.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-flag.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-ras.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-tlb.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-trace.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-virt.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-predres.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-specrestrict.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-ssbs.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-el3.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
  llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt

Index: llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
===
--- llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
+++ llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
@@ -1257,27 +1257,21 @@
 0xe1 0xff 0x1f 0xd4
 
 # CHECK: hvc  #{{1|0x1}}
-# CHECK: smc  #{{12000|0x2ee0}}
 # CHECK: brk  #{{12|0xc}}
 # CHECK: hlt  #{{123|0x7b}}
 0x22 0x0 0x0 0xd4
-0x3 0xdc 0x5 0xd4
 0x80 0x1 0x20 0xd4
 0x60 0xf 0x40 0xd4
 
 # CHECK: dcps1#{{42|0x2a}}
 # CHECK: dcps2#{{9|0x9}}
-# CHECK: dcps3#{{1000|0x3e8}}
 0x41 0x5 0xa0 0xd4
 0x22 0x1 0xa0 0xd4
-0x3 0x7d 0xa0 0xd4
 
 # CHECK: dcps1
 # CHECK: dcps2
-# CHECK: dcps3
 0x1 0x0 0xa0 0xd4
 0x2 0x0 0xa0 0xd4
-0x3 0x0 0xa0 0xd4
 
 #--
 # Extract (immediate)
@@ -3258,13 +3252,11 @@
 # CHECK: msr  {{hacr_el2|HACR_EL2}}, x12
 # CHECK: msr  {{mdcr_el3|MDCR_EL3}}, x12
 # CHECK: msr  {{ttbr0_el1|TTBR0_EL1}}, x12
-# CHECK: msr  {{ttbr0_el2|TTBR0_EL2}}, x12
 # CHECK: msr  {{ttbr0_el3|TTBR0_EL3}}, x12
 # CHECK: msr  {{ttbr1_el1|TTBR1_EL1}}, x12
 # CHECK: msr  {{tcr_el1|TCR_EL1}}, x12
 # CHECK: msr  {{tcr_el2|TCR_EL2}}, x12
 # CHECK: msr  {{tcr_el3|TCR_EL3}}, x12
-# CHECK: msr  {{vttbr_el2|VTTBR_EL2}}, x12
 # CHECK: msr  {{vtcr_el2|VTCR_EL2}}, x12
 # CHECK: msr  {{dacr32_el2|DACR32_EL2}}, x12
 # CHECK: msr  {{spsr_el1|SPSR_EL1}}, x12
@@ -3554,13 +3546,11 @@
 # CHECK: mrs  x9, {{hacr_el2|HACR_EL2}}
 # CHECK: mrs  x9, {{mdcr_el3|MDCR_EL3}}
 # CHECK: mrs  x9, {{ttbr0_el1|TTBR0_EL1}}
-# CHECK: mrs  x9, {{ttbr0_el2|TTBR0_EL2}}
 # CHECK: mrs  x9, {{ttbr0_el3|TTBR0_EL3}}
 # CHECK: mrs  x9, {{ttbr1_el1|TTBR1_EL1}}
 # CHECK: mrs  x9, {{tcr_el1|TCR_EL1}}
 # CHECK: mrs  x9, {{tcr_el2|TCR_EL2}}
 # CHECK: mrs  x9, {{tcr_el3|TCR_EL3}}
-# CHECK: mrs  x9, {{vttbr_el2|VTTBR_EL2}}
 # CHECK: mrs  x9, {{vtcr_el2|VTCR_EL2}}
 # CHECK: mrs  x9, {{dacr32_el2|DACR32_EL2}}
 # CHECK: mrs  x9, {{spsr_el1|SPSR_EL1}}
Index: llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
@@ -1,5 +1,6 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mattr=+fp16fml   --disassemble < %s 2>&1 | File

[PATCH] D110065: [AArch64] Add support for the 'R' architecture profile.

2021-10-16 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea marked an inline comment as done.
labrinea added inline comments.



Comment at: llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp:1548
+
+static const AArch64SysReg::SysReg *lookupSysReg(unsigned Val, bool Read,
+ const MCSubtargetInfo &STI) {

john.brawn wrote:
> It would be better if we had a generic way to handle registers with 
> overlapping encodings, instead of handling the two registers explicitly here. 
> I'm not sure of the best way to do that, but looking at 
> AArch64SystemOperands.td it looks like maybe a way to do it would to add an 
> extra "AltName" field to give an alternate name for the same encoding, so 
> e.g. TTBR0_EL2 would have AltName 
> VSCTLR_EL2 and vice-versa. So you'd first lookup by encoding, then if that 
> didn't work you'd lookup by name with AltName and check if that one is valid.
> 
Done, but it may turn problematic if we start having more than one alternative 
names, i.e. if multiple architecture extensions reference the same encoding 
using a different name.


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

https://reviews.llvm.org/D110065

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


[clang] 49562d3 - Revert "[clang] Pass -clear-ast-before-backend in Clang::ConstructJob()"

2021-10-16 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-16T12:05:41-07:00
New Revision: 49562d3dfed0ed6983d29d040db7e46ef3bc833e

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

LOG: Revert "[clang] Pass -clear-ast-before-backend in Clang::ConstructJob()"

This reverts commit 47eb99aa44ab1d20327d67a49d6c47163de76387.

This causes crashes with -print-stats: PR52193.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Interpreter/Interpreter.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 83afbc3952d8..d2c08412d593 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4660,7 +4660,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // cleanup.
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
-  CmdArgs.push_back("-clear-ast-before-backend");
 
 #ifdef NDEBUG
   const bool IsAssertBuild = false;

diff  --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index d14940d2e132..02b3025297b6 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -113,10 +113,6 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
 
   Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
-  // Don't clear the AST before backend codegen since we do codegen multiple
-  // times, reusing the same AST.
-  Clang->getCodeGenOpts().ClearASTBeforeBackend = false;
-
   return std::move(Clang);
 }
 



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


[PATCH] D111009: Update inline builtin handling to honor gnu inline attribute

2021-10-16 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

I am noticing a clang crash with ToT after this change.

- testcase --

  long a;
  char b, d;
  extern inline __attribute__((always_inline))
  __attribute__((gnu_inline)) unsigned long
  strlen() {
return a;
  }
  c(void) {
strlen(&b);
return 0;
  }
  unsigned long strlen() { return d; }

  bin/clang -x c foo.c -Wno-error
  foo.c:8:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  c(void) {
  ^
  Global is external, but doesn't have external or weak linkage!
  i64 (i8*)* @strlen.inline
  fatal error: error in backend: Broken module found, compilation aborted!
  clang version 14.0.0 (https://github.com/llvm/llvm-project.git 
3129aa5caf1f9b5c48ab708f43cb3fc5173dd021)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111009

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


[PATCH] D111952: [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot

2021-10-16 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: phosek, MaskRay.
Herald added subscribers: pengfei, kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: clang.

For x86, most contempory mingw toolchains use i686 as 32 bit
x86 arch target.

As long as the target triple is set to the right form, this works
fine, either as the compiler's default target, or via e.g.
a triple prefix like i686-w64-mingw32-clang.

However, if the unprefixed toolchain targets x86_64, but the user
tries to switch it to target 32 bit by adding the -m32 option, the
computeTargetTriple function in Clang, together with
Triple::get32BitArchVariant, sets the arch to i386. This causes
the right sysroot to not be found.

When targeting an arch where there are potential spelling ambiguities
with respect to the sysroots (i386 and arm), check if the driver can
find a sysroot with the arch name - if not, try a couple other
candidates.

Other design ideas considered: It would fit in better with the design
to do this kind of arch name fixups in computeTargetTriple (it
already has a couple other OS/arch specific cases), but the
heuristics for detecting the potential right choice ties in quite
closely with how the toolchain looks for the implicit sysroot to use,
so I'd prefer to keep that logic in the toolchain::MinGW class/file.

This is done as a wrapper function before invoking the toolchain::MinGW()
constructor, because the MinGW() constructor can't run code of its own
until the superclass ToolChain() constructor returns. The fixups need to
be done before the ToolChain() constructor, because it uses the Triple
for per-target runtime directories.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111952

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/test/Driver/mingw-sysroot.cpp

Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ clang/test/Driver/mingw-sysroot.cpp
@@ -12,6 +12,7 @@
 // RUN: mkdir -p %T/testroot-clang/bin
 // RUN: ln -s %clang %T/testroot-clang/bin/x86_64-w64-mingw32-clang
 // RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %T/testroot-clang/x86_64-w64-mingw32
+// RUN: ln -s %S/Inputs/mingw_arch_tree/usr/i686-w64-mingw32 %T/testroot-clang/i686-w64-mingw32
 
 
 // If we find a gcc in the path with the right triplet prefix, pick that as
@@ -36,3 +37,14 @@
 // the libgcc directory:
 
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %T/testroot-gcc/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
+
+
+// If the user requests a different arch via the -m32 option, which changes
+// x86_64 into i386, check that the driver notices that it can't find a
+// sysroot for i386 but there is one for i686, and uses that one.
+// (In practice, this usecase is when using an unprefixed native clang
+// that defaults to x86_64 mingw, but it's easier to test in cross setups
+// with symlinks, like the other tests here.)
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %T/testroot-clang/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 -m32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CLANG_I686 %s
+// CHECK_TESTROOT_CLANG_I686: "{{[^"]+}}/testroot-clang{{/|}}i686-w64-mingw32{{/|}}include"
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -56,10 +56,15 @@
 namespace toolchains {
 
 class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
-public:
+private:
   MinGW(const Driver &D, const llvm::Triple &Triple,
 const llvm::opt::ArgList &Args);
 
+public:
+  static std::unique_ptr Create(const Driver &D,
+   const llvm::Triple &Triple,
+   const llvm::opt::ArgList &Args);
+
   bool HasNativeLLVMSupport() const override;
 
   bool IsIntegratedAssemblerDefault() const override;
@@ -103,8 +108,6 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
-  llvm::ErrorOr findGcc();
-  llvm::ErrorOr findClangRelativeSysroot();
 
   bool NativeLLVMSupport;
 };
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -369,9 +369,9 @@
   }
 }
 
-llvm::ErrorOr toolchains::MinGW::findGcc() {
+static llvm::ErrorOr findGcc(const llvm::Triple &T) {
   llvm::SmallVector, 2> Gccs;
-  Gccs.emplace_back(getTriple().getArchName());
+  Gccs.emplace_back(T.getArchName());
   Gccs[0] += "-w64-mingw32-gcc";
   Gccs.emplace_bac

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1179-1180
 
+  if (ExternalFS)
+ExternalFS->setCurrentWorkingDirectory(Path);
+

keith wrote:
> JDevlieghere wrote:
> > I'm pretty sure there was a reason we stopped doing this. There should be 
> > some discussion about that in my original patch. 
> So it sounds like it was related to this:
> 
> > [fallthrough] ... but not for relative paths that would get resolved 
> > incorrectly at the lower layer (for example, in case of the RealFileSystem, 
> > because the strictly virtual path does not exist).
> 
> But if I remove that 2 of my new tests `ReturnsInternalPathVFSHit` and 
> `ReturnsExternalPathVFSHit` do not pass. I think the behavior of them is what 
> we want, what do you think?
We stopped doing this because it puts ExternalFS in an unknown state since 
`Path` may not exist there. Future calls with relative paths could do very 
strange things.

E.g., here's a simple testcase that demonstrates something going very wrong:
- external FS has file `/1/a`
- redirecting FS has file `/2/b` (and passes through to external FS)
- execute: `cd /1 && cd /2 && stat a`

The correct result is for the `stat` to fail because `/2/a` doesn't exist. But 
your change above will instead find `/1/a` in ExternalFS.

Another example:
- external FS has file `/1/a` and `/1/nest/c`
- redirecting FS has file `/2/b`
- execute: `cd /1/nest && cd /2 && cd .. && stat a`

External FS will have CWD of `/1`, redirecting will have CWD of `/`, and `stat 
a` will erroneously give the result for `/1/a` instead of `/a`.

(Probably it'd be good to add tests for cases like this...)

To safely call `ExternalFS->setCurrentWorkingDirectory()`, you'll need extra 
state (and checks anywhere `ExternalFS` is used) tracking whether it has a 
valid working directory. If it does not, then it should not be queried, or it 
should only be sent absolute paths, or (etc.); and there should also be a way 
to re-establish a valid working directory.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D111952: [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot

2021-10-16 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

I guess a downside of this solution, is that if an `i686` sysroot exists next 
to the clang binary, it becomes practically impossible to test codegen 
differences when you run it with various `-target iX86-w64-mingw32` options, as 
they'd all be corrected back to `i686`. (This wouldn't be an issue if the 
autodetection was done in `computeTargetTriple` only when the `-m32`/`-m64` 
options are used though.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111952

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


[clang] 1072699 - Use llvm::erase_value (NFC)

2021-10-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-16T23:31:21-07:00
New Revision: 10726992fad771e7c630fc511d85bb81a8d1562e

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

LOG: Use llvm::erase_value (NFC)

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/Dominators.h
clang/include/clang/Basic/JsonSupport.h
clang/include/clang/Sema/ScopeInfo.h
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaExpr.cpp
lld/ELF/Writer.cpp
llvm/include/llvm/TableGen/DirectiveEmitter.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/Dominators.h 
b/clang/include/clang/Analysis/Analyses/Dominators.h
index 25a5ba9d83fe3..f588a5c7d1d7b 100644
--- a/clang/include/clang/Analysis/Analyses/Dominators.h
+++ b/clang/include/clang/Analysis/Analyses/Dominators.h
@@ -202,7 +202,7 @@ struct ChildrenGetterTy {
 
 auto Children = children(N);
 ChildrenTy Ret{Children.begin(), Children.end()};
-Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end());
+llvm::erase_value(Ret, nullptr);
 return Ret;
   }
 };

diff  --git a/clang/include/clang/Basic/JsonSupport.h 
b/clang/include/clang/Basic/JsonSupport.h
index 8b02e440df447..6cd3f4d57b846 100644
--- a/clang/include/clang/Basic/JsonSupport.h
+++ b/clang/include/clang/Basic/JsonSupport.h
@@ -70,7 +70,7 @@ inline std::string JsonFormat(StringRef RawSR, bool 
AddQuotes) {
   }
 
   // Remove new-lines.
-  Str.erase(std::remove(Str.begin(), Str.end(), '\n'), Str.end());
+  llvm::erase_value(Str, '\n');
 
   if (!AddQuotes)
 return Str;

diff  --git a/clang/include/clang/Sema/ScopeInfo.h 
b/clang/include/clang/Sema/ScopeInfo.h
index 98ed75acd9d27..5c3bfe7e80cdc 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -1001,10 +1001,7 @@ class LambdaScopeInfo final :
 return NonODRUsedCapturingExprs.count(CapturingVarExpr);
   }
   void removePotentialCapture(Expr *E) {
-PotentiallyCapturingExprs.erase(
-std::remove(PotentiallyCapturingExprs.begin(),
-PotentiallyCapturingExprs.end(), E),
-PotentiallyCapturingExprs.end());
+llvm::erase_value(PotentiallyCapturingExprs, E);
   }
   void clearPotentialCaptures() {
 PotentiallyCapturingExprs.clear();

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d9017b347d812..1292cb6eb557c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1125,7 +1125,7 @@ void ASTContext::deduplicateMergedDefinitonsFor(NamedDecl 
*ND) {
   for (Module *&M : Merged)
 if (!Found.insert(M).second)
   M = nullptr;
-  Merged.erase(std::remove(Merged.begin(), Merged.end(), nullptr), 
Merged.end());
+  llvm::erase_value(Merged, nullptr);
 }
 
 ArrayRef

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 472b15b9ea06b..04f8540fe3b1f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16641,8 +16641,7 @@ void Sema::CheckUnusedVolatileAssignment(Expr *E) {
   if (auto *BO = dyn_cast(E->IgnoreParenImpCasts())) {
 if (BO->getOpcode() == BO_Assign) {
   auto &LHSs = ExprEvalContexts.back().VolatileAssignmentLHSs;
-  LHSs.erase(std::remove(LHSs.begin(), LHSs.end(), BO->getLHS()),
- LHSs.end());
+  llvm::erase_value(LHSs, BO->getLHS());
 }
   }
 }

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 7a3b2747042e4..0e55e9cbdb57b 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -221,8 +221,7 @@ void elf::combineEhSections() {
 }
   }
 
-  std::vector &v = inputSections;
-  v.erase(std::remove(v.begin(), v.end(), nullptr), v.end());
+  llvm::erase_value(inputSections, nullptr);
 }
 
 static Defined *addOptionalRegular(StringRef name, SectionBase *sec,

diff  --git a/llvm/include/llvm/TableGen/DirectiveEmitter.h 
b/llvm/include/llvm/TableGen/DirectiveEmitter.h
index 5c4a736eb1074..d73b9ae49235f 100644
--- a/llvm/include/llvm/TableGen/DirectiveEmitter.h
+++ b/llvm/include/llvm/TableGen/DirectiveEmitter.h
@@ -152,7 +152,7 @@ class Clause : public BaseRecord {
   }
   return C;
 });
-N.erase(std::remove(N.begin(), N.end(), '_'), N.end());
+llvm::erase_value(N, '_');
 return N;
   }
 



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