[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-23 Thread Xun Li via Phabricator via cfe-commits
lxfind added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:1318
 /// otherwise
 llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
 llvm::Value *Addr) {

ChuanqiXu wrote:
> Can we sure frontend would always call this API to emit lifetime start? I 
> mean the frontend may call EmitIntrinsic or create lifetime.start intrinsic 
> directly whether by IRBuilder::CreateXXX or Instrinsic::Create(...). I worry 
> about if this would incur changes out of design.
> 
> Then if we add check in EmitLifetimeStart, why not we add check in 
> EmitLfietimeEnd?
I searched in the codebase, and we always call this API to emit lifetime start 
in the front-end.
Also, for coroutine to behave correctly, we really only need SD_FullExpression 
to be able to emit it. Other cases are less critical.

Usually when it emits a LifetimeStart instruction, it will store it somewhere, 
and latter check on it to decide whether it needs to emit a lifetime end. 
That's when there is no checks needed for lifetime end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99237: [AVR][clang] Fix wrong calling convention in functions return struct type

2021-03-23 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 332871.

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

https://reviews.llvm.org/D99237

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/avr/struct.c


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+struct s10 a0;
+a0.a = c;
+a0.b = b;
+a0.c = a;
+return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+struct s06 a0;
+a0.a = a;
+a0.b = b;
+a0.c = c;
+return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8087,14 +8087,39 @@
 }
 
 
//===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 
//===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less equal than 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of DefaultABIInfo::computeInfo(),
+  // since DefaultABIInfo::classify{Return,Argument}Type() are not virtual.
+  void computeInfo(CGFunctionInfo ) const override {
+if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+for (auto  : FI.arguments())
+  I.info = classifyArgumentType(I.type);
+  }
+};
+
 class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   AVRTargetCodeGenInfo(CodeGenTypes )
-  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override {


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+struct s10 a0;
+a0.a = c;
+a0.b = b;
+a0.c = a;
+return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+struct s06 a0;
+a0.a = a;
+a0.b = b;
+a0.c = c;
+return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8087,14 +8087,39 @@
 }
 
 //===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 //===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less equal than 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of 

[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-03-23 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok updated this revision to Diff 332870.
alok added a comment.

Re-based after setting the parent patch.


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

https://reviews.llvm.org/D99238

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Target/TargetOptions.h
  llvm/test/DebugInfo/X86/callsitepar-fastisel.ll


Index: llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
===
--- llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
+++ llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
@@ -9,6 +9,17 @@
 ;CHECK: DW_AT_location (DW_OP_reg4 RSI)
 ;CHECK: DW_AT_GNU_call_site_value
 
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for option 
-O0
+;RUN: clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj  -main-file-name 
%s -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O0 -x ir %s 
-o - | llvm-dwarfdump - | FileCheck %s --check-prefix=CLANG
+
+;CLANG: DW_TAG_GNU_call_site
+;CLANG: DW_AT_abstract_origin
+;CLANG-SAME: "foo"
+;CLANG: DW_AT_low_pc
+;CLANG: DW_TAG_GNU_call_site_parameter
+;CLANG: DW_AT_location (DW_OP_reg4 RSI)
+;CLANG: DW_AT_GNU_call_site_value
+
 ;;The IR is generated from below source program
 ;
 ;;subroutine foo (array)
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -302,8 +302,8 @@
 std::shared_ptr BBSectionsFuncListBuf;
 
 /// The flag enables call site info production. It is used only for debug
-/// info, and it is restricted only to optimized code. This can be used for
-/// something else, so that should be controlled in the frontend.
+/// info. This can be used for something else, so that should be controlled
+/// in the frontend.
 unsigned EmitCallSiteInfo : 1;
 /// Set if the target supports the debug entry values by default.
 unsigned SupportsDebugEntryValues : 1;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1642,7 +1642,7 @@
   llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
   llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -68,8 +68,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
-CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
-   ///< '-g' + 'O>0' level.
+CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info.
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
===
--- llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
+++ llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
@@ -9,6 +9,17 @@
 ;CHECK: DW_AT_location (DW_OP_reg4 RSI)
 ;CHECK: DW_AT_GNU_call_site_value
 
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for option -O0
+;RUN: clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj  -main-file-name %s -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O0 -x ir %s -o - | llvm-dwarfdump - | FileCheck %s --check-prefix=CLANG
+
+;CLANG: DW_TAG_GNU_call_site
+;CLANG: DW_AT_abstract_origin
+;CLANG-SAME: "foo"
+;CLANG: DW_AT_low_pc
+;CLANG: DW_TAG_GNU_call_site_parameter
+;CLANG: DW_AT_location (DW_OP_reg4 RSI)
+;CLANG: DW_AT_GNU_call_site_value
+
 ;;The IR is generated from below source program
 ;
 ;;subroutine foo (array)
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -302,8 +302,8 @@
 std::shared_ptr BBSectionsFuncListBuf;
 
 /// The flag enables call site info production. It is used only for debug
-/// info, and it is restricted only to optimized code. This can be used for
-/// something else, so that should be controlled in 

[clang] 4020932 - [PowerPC] Make altivec.h work with AIX which has no __int128

2021-03-23 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-03-24T00:35:51-05:00
New Revision: 4020932706f6f8538b48b9b8439a7ec1266a7ae5

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

LOG: [PowerPC] Make altivec.h work with AIX which has no __int128

There are a number of functions in altivec.h that use
vector __int128 which isn't supported on AIX. Those functions
need to be guarded for targets that don't support the type.
Furthermore, the functions that produce quadword instructions
without using the type need a builtin. This patch adds the
macro guards to altivec.h using the __SIZEOF_INT128__ which
is only defined on targets that support the __int128 type.

Added: 
clang/test/CodeGen/builtins-ppc-quadword-noi128.c

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 39c66f5daeb1..66c35a9a82be 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -39,6 +39,7 @@ BUILTIN(__builtin_altivec_vadduws, "V4UiV4UiV4Ui", "")
 BUILTIN(__builtin_altivec_vaddeuqm, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
 BUILTIN(__builtin_altivec_vaddcuq, "V1ULLLiV1ULLLiV1ULLLi","")
 BUILTIN(__builtin_altivec_vaddecuq, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
+BUILTIN(__builtin_altivec_vadduqm, "V1ULLLiV16UcV16Uc","")
 
 BUILTIN(__builtin_altivec_vsubsbs, "V16ScV16ScV16Sc", "")
 BUILTIN(__builtin_altivec_vsububs, "V16UcV16UcV16Uc", "")
@@ -49,6 +50,7 @@ BUILTIN(__builtin_altivec_vsubuws, "V4UiV4UiV4Ui", "")
 BUILTIN(__builtin_altivec_vsubeuqm, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
 BUILTIN(__builtin_altivec_vsubcuq, "V1ULLLiV1ULLLiV1ULLLi","")
 BUILTIN(__builtin_altivec_vsubecuq, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
+BUILTIN(__builtin_altivec_vsubuqm, "V1ULLLiV16UcV16Uc","")
 
 BUILTIN(__builtin_altivec_vavgsb, "V16ScV16ScV16Sc", "")
 BUILTIN(__builtin_altivec_vavgub, "V16UcV16UcV16Uc", "")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 33a444e471f5..f86b7e52c9a9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15028,6 +15028,18 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 llvm::Function *F = CGM.getIntrinsic(Intrinsic::ctpop, ResultType);
 return Builder.CreateCall(F, X);
   }
+  case PPC::BI__builtin_altivec_vadduqm:
+  case PPC::BI__builtin_altivec_vsubuqm: {
+llvm::Type *Int128Ty = llvm::IntegerType::get(getLLVMContext(), 128);
+Ops[0] =
+Builder.CreateBitCast(Ops[0], llvm::FixedVectorType::get(Int128Ty, 1));
+Ops[1] =
+Builder.CreateBitCast(Ops[1], llvm::FixedVectorType::get(Int128Ty, 1));
+if (BuiltinID == PPC::BI__builtin_altivec_vadduqm)
+  return Builder.CreateAdd(Ops[0], Ops[1], "vadduqm");
+else
+  return Builder.CreateSub(Ops[0], Ops[1], "vsubuqm");
+  }
   // Copy sign
   case PPC::BI__builtin_vsx_xvcpsgnsp:
   case PPC::BI__builtin_vsx_xvcpsgndp: {

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 84a85888422a..56328187fff8 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -293,6 +293,7 @@ vec_add(vector unsigned long long __a, vector unsigned long 
long __b) {
   return __a + __b;
 }
 
+#ifdef __SIZEOF_INT128__
 static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_add(vector signed __int128 __a, vector signed __int128 __b) {
   return __a + __b;
@@ -302,11 +303,11 @@ static __inline__ vector unsigned __int128 __ATTRS_o_ai
 vec_add(vector unsigned __int128 __a, vector unsigned __int128 __b) {
   return __a + __b;
 }
+#endif
 
 static __inline__ vector unsigned char __attribute__((__always_inline__))
 vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
-  return (vector unsigned char)((vector unsigned __int128)__a +
-(vector unsigned __int128)__b);
+  return __builtin_altivec_vadduqm(__a, __b);
 }
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
@@ -325,6 +326,7 @@ static __inline__ vector double __ATTRS_o_ai vec_add(vector 
double __a,
 /* vec_adde */
 
 #if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#ifdef __SIZEOF_INT128__
 static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_adde(vector signed __int128 __a, vector signed __int128 __b,
  vector signed __int128 __c) {
@@ -336,13 +338,12 @@ vec_adde(vector unsigned __int128 __a, vector unsigned 
__int128 __b,
  vector unsigned __int128 __c) {
   return __builtin_altivec_vaddeuqm(__a, __b, __c);
 }
+#endif
 
 static __inline__ vector unsigned char __attribute__((__always_inline__))
 vec_adde_u128(vector unsigned char __a, vector 

[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-03-23 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok created this revision.
alok added reviewers: djtodoro, aprantl, jmorse, SouraVX, jini.susan.george, 
bhuvanendrakumarn.
alok added a project: debug-info.
Herald added subscribers: jansvoboda11, dexonsmith.
alok requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This works with debug entry value feature, which works by default.
Without call site parameter feature, debug entry value feature is of no use.
With current changes, debuggers should be able to show optimized out parameters 
by default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99238

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Target/TargetOptions.h
  llvm/test/DebugInfo/X86/callsitepar-fastisel.ll


Index: llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
===
--- llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
+++ llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
@@ -9,6 +9,17 @@
 ;CHECK: DW_AT_location (DW_OP_reg4 RSI)
 ;CHECK: DW_AT_GNU_call_site_value
 
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for option 
-O0
+;RUN: clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj  -main-file-name 
%s -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O0 -x ir %s 
-o - | llvm-dwarfdump - | FileCheck %s --check-prefix=CLANG
+
+;CLANG: DW_TAG_GNU_call_site
+;CLANG: DW_AT_abstract_origin
+;CLANG-SAME: "foo"
+;CLANG: DW_AT_low_pc
+;CLANG: DW_TAG_GNU_call_site_parameter
+;CLANG: DW_AT_location (DW_OP_reg4 RSI)
+;CLANG: DW_AT_GNU_call_site_value
+
 ;;The IR is generated from below source program
 ;
 ;;subroutine foo (array)
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -302,8 +302,8 @@
 std::shared_ptr BBSectionsFuncListBuf;
 
 /// The flag enables call site info production. It is used only for debug
-/// info, and it is restricted only to optimized code. This can be used for
-/// something else, so that should be controlled in the frontend.
+/// info. This can be used for something else, so that should be controlled
+/// in the frontend.
 unsigned EmitCallSiteInfo : 1;
 /// Set if the target supports the debug entry values by default.
 unsigned SupportsDebugEntryValues : 1;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1642,7 +1642,7 @@
   llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
   llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -68,8 +68,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
-CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
-   ///< '-g' + 'O>0' level.
+CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info.
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
===
--- llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
+++ llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
@@ -9,6 +9,17 @@
 ;CHECK: DW_AT_location (DW_OP_reg4 RSI)
 ;CHECK: DW_AT_GNU_call_site_value
 
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for option -O0
+;RUN: clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj  -main-file-name %s -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O0 -x ir %s -o - | llvm-dwarfdump - | FileCheck %s --check-prefix=CLANG
+
+;CLANG: DW_TAG_GNU_call_site
+;CLANG: DW_AT_abstract_origin
+;CLANG-SAME: "foo"
+;CLANG: DW_AT_low_pc
+;CLANG: DW_TAG_GNU_call_site_parameter
+;CLANG: DW_AT_location (DW_OP_reg4 RSI)
+;CLANG: DW_AT_GNU_call_site_value
+
 ;;The IR is generated from below source program
 ;
 ;;subroutine foo (array)
Index: 

[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-23 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D99227#2646568 , @ChuanqiXu wrote:

> Only one problem I had for emitting lifetime markers even at O0 is that would 
> action make allocas to be optimized even at O0? If so, I wonder if it 
> confuses programmers since they may find some variables disappear 
> surprisingly. Or there would be no optimization since every function would be 
> marked with optnone attribute. I am not sure about this.

It will only cause variables to be put on the stack instead of on the frame, 
which shouldn't affect developer's view?

> If I understand this problem correctly, this patch could fix problems for the 
> return value of symmetric transfer and the gro that we discussed in D98638 
> . Then D98638 
>  may be unneeded. I prefer the 
> implementation in this patch.

I doubt it can fix the gro problem. I will need to double check on that latter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-03-23 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok updated this revision to Diff 332867.
alok added a comment.

Updated to incorporate comments from @djtodoro

- to split out separate patch for clang change.

and fixed clang-format issue.


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

https://reviews.llvm.org/D99160

Files:
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/Target/X86/X86FastISel.cpp
  llvm/test/CodeGen/X86/call-site-info-output.ll
  llvm/test/DebugInfo/X86/callsitepar-fastisel.ll

Index: llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
@@ -0,0 +1,204 @@
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for fastIsel.
+; REQUIRES: x86_64-linux
+;RUN: llc -mtriple=x86_64-pc-linux-gnu -emit-call-site-info -fast-isel=true -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
+;CHECK: DW_TAG_GNU_call_site
+;CHECK: DW_AT_abstract_origin
+;CHECK-SAME: "foo"
+;CHECK: DW_AT_low_pc
+;CHECK: DW_TAG_GNU_call_site_parameter
+;CHECK: DW_AT_location (DW_OP_reg4 RSI)
+;CHECK: DW_AT_GNU_call_site_value
+
+;;The IR is generated from below source program
+;
+;;subroutine foo (array)
+;;  integer :: array(:,:)
+;;  array(:,:) = 5
+;;  array(1,1) = 30
+;;end subroutine
+;;
+;;program vla_sub
+;;  interface
+;;subroutine foo (array)
+;;  integer :: array (:,:)
+;;end subroutine
+;;  end interface
+;;
+;;  integer :: sub_arr(42,42)
+;;  sub_arr(:,:) = 1
+;;  call foo(sub_arr)
+;;end program vla_sub
+;
+
+; ModuleID = 'fast.ll'
+source_filename = "/tmp/fast.ll"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.BSS2 = type <{ [7056 x i8] }>
+
+@.BSS2 = internal global %struct.BSS2 zeroinitializer, align 32, !dbg !0
+@.C359_MAIN_ = internal constant i64 42
+@.C333_MAIN_ = internal constant i64 1
+@.C368_MAIN_ = internal constant i64 4
+@.C367_MAIN_ = internal constant i64 25
+@.C331_MAIN_ = internal constant i64 0
+@.C330_MAIN_ = internal constant i32 0
+
+; Function Attrs: nofree norecurse nounwind
+define void @foo_(i64* noalias nocapture %array, i64* noalias nocapture readonly %"array$sd") local_unnamed_addr #0 !dbg !15 {
+L.entry:
+  call void @llvm.dbg.value(metadata i64* %array, metadata !28, metadata !DIExpression()), !dbg !29
+  call void @llvm.dbg.declare(metadata i64* %"array$sd", metadata !30, metadata !DIExpression()), !dbg !29
+  %0 = getelementptr i64, i64* %"array$sd", i64 11
+  %1 = load i64, i64* %0, align 8
+  call void @llvm.dbg.value(metadata i64 %1, metadata !21, metadata !DIExpression()), !dbg !29
+  %2 = getelementptr i64, i64* %"array$sd", i64 20
+  %3 = load i64, i64* %2, align 8
+  %4 = getelementptr i64, i64* %"array$sd", i64 17
+  %5 = load i64, i64* %4, align 8
+  call void @llvm.dbg.value(metadata i64 %5, metadata !24, metadata !DIExpression()), !dbg !29
+  %6 = getelementptr i64, i64* %"array$sd", i64 7
+  %7 = load i64, i64* %6, align 8
+  %8 = getelementptr i64, i64* %"array$sd", i64 16
+  %9 = load i64, i64* %8, align 8
+  %10 = add nsw i64 %9, -1
+  %11 = mul nsw i64 %10, %3
+  %12 = getelementptr i64, i64* %"array$sd", i64 10
+  %13 = load i64, i64* %12, align 8
+  %14 = add i64 %7, -1
+  %15 = add i64 %14, %13
+  %16 = add i64 %15, %11
+  %17 = icmp slt i64 %1, 1, !dbg !35
+  %18 = icmp slt i64 %5, 1, !dbg !35
+  %19 = or i1 %17, %18, !dbg !35
+  br i1 %19, label %L.LB1_372, label %L.LB1_371.preheader, !dbg !35
+
+L.LB1_371.preheader:  ; preds = %L.entry
+  %20 = bitcast i64* %array to i8*
+  %21 = getelementptr i8, i8* %20, i64 -4
+  %22 = bitcast i8* %21 to i32*
+  br label %L.LB1_371
+
+L.LB1_371:; preds = %L.LB1_371.preheader, %L.LB1_426
+  %"i$a_368.0" = phi i64 [ %28, %L.LB1_426 ], [ 1, %L.LB1_371.preheader ], !dbg !35
+  %23 = mul nsw i64 %"i$a_368.0", %3
+  %24 = add i64 %23, %16
+  br label %L.LB1_374
+
+L.LB1_374:; preds = %L.LB1_374, %L.LB1_371
+  %"i$b_369.0" = phi i64 [ 1, %L.LB1_371 ], [ %27, %L.LB1_374 ], !dbg !35
+  %25 = add i64 %24, %"i$b_369.0", !dbg !35
+  %26 = getelementptr i32, i32* %22, i64 %25, !dbg !35
+  store i32 5, i32* %26, align 4, !dbg !35
+  %27 = add nuw i64 %"i$b_369.0", 1, !dbg !35
+  %exitcond.not = icmp eq i64 %"i$b_369.0", %1, !dbg !35
+  br i1 %exitcond.not, label %L.LB1_426, label %L.LB1_374, !dbg !35
+
+L.LB1_426:; preds = %L.LB1_374
+  %28 = add nuw i64 %"i$a_368.0", 1, !dbg !35
+  %exitcond9.not = icmp eq i64 %"i$a_368.0", %5, !dbg !35
+  br i1 %exitcond9.not, label %L.LB1_372, label %L.LB1_371, !dbg !35
+
+L.LB1_372:; preds = %L.LB1_426, %L.entry
+  %29 = add nsw i64 %16, %3, !dbg !36
+  %30 = bitcast i64* %array to i32*, !dbg !36
+  %31 = 

[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-23 Thread Xun Li via Phabricator via cfe-commits
lxfind added a subscriber: lewissbaker.
lxfind added a comment.

> I think you just set `ShouldEmitLifetimeMarkers` correctly in the first place 
> instead of adding this as an extra condition to every place that considers 
> it, however.

This was set when a CodeGenFunction is constructed, at that point it doesn't 
yet know if this function is a coroutine.
I could turn ShouldEmitLifetimeMarkers to non-const, and then modify it once it 
realizes it's a coroutine though, if that's better than the current approach.

> Sorry, I re-read this after posting, and it's not exactly clear what I was 
> saying.  There are a lot of situations where Clang doesn't emit lifetime 
> intrinsics for every `alloca` it emits, or emits unnecessarily weak bounds.  
> Certain LLVM transforms can also introduce `alloca`s that don't have 
> corresponding lifetime intrinsics.  So I think it's problematic to consider 
> it a correctness condition that we're emitting optimally-tight lifetimes.

I tend to agree. Relying on lifetime for correctness seems fragile.
I wonder if there is a better way to inform optimizer that a "variable" is 
really a temporary value that should die at the end of an expression?
For instance, whenever we do something simple like:

  foo().bar();
  co_await ...

If we compile it under -O0 without lifetime intrinsics, the return value of 
`foo()` will always be put on the coroutine frame, unless the compiler knows in 
advance that `bar()` does not capture.
This becomes a problem if this code appears at a location where the current 
coroutine frame may be destroyed (but the code itself isn't wrong, it simply 
doesn't access the frame).
The case for symmetric transfer is exactly this situation.

An alternative to solve the problem for the case of symmetric transfer, is to 
change the design of symmetric transfer. For example, if we let `await_suspend` 
to return `void*` instead of `coroutine_handle`, we won't have this problem in 
the first place, because we no longer need to call `address()`. Maybe 
@lewissbaker can comment on the viability of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-03-23 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1645
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

djtodoro wrote:
> I think this should be a different patch.
> 
> Are you saying this is useful for some -O0 cases? Can you please provide a 
> test case? Is this related to Fortran only?
Sure. I shall move this in separate patch.

Yes this is useful in -O0 case. the testcase is added with the current patch as 
"callsitepar-fastisel.ll". Though the IR is generated from fortran program 
(mentioned in test case). But I think it is not specific to fortran. Since even 
with -O0 many optimizations work, it is very much possible that parameter gets 
optimized out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99160

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


[PATCH] D99151: [RISCV][Clang] Add RVV vleff intrinsic functions.

2021-03-23 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

maybe we could merge different test into one vleff.c?




Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics/vle16ff.c:9
+// RUN:   -target-feature +experimental-zfh -target-feature +m 
-fallow-half-arguments-and-returns -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+

nit: skip the temporary file and remove +experimental-zfh and 
-fallow-half-arguments-and-returns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99151

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


[PATCH] D99237: [AVR][clang] Fix wrong calling convention in functions return struct type

2021-03-23 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: dylanmckay, aykevl, MaskRay.
Herald added a subscriber: Jim.
benshi001 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

According to AVR ABI (https://gcc.gnu.org/wiki/avr-gcc), returned struct value
within size 1-8 bytes are returned directly (via register r18-r25), while larger
ones are returned via an implict struct pointer argument.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99237

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/avr/struct.c


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+struct s10 a0;
+a0.a = c;
+a0.b = b;
+a0.c = a;
+return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+struct s06 a0;
+a0.a = a;
+a0.b = b;
+a0.c = c;
+return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8087,14 +8087,39 @@
 }
 
 
//===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 
//===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less equal than 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of DefaultABIInfo::computeInfo(),
+  // since DefaultABIInfo::classify{Return,Argument}Type() are not virtual.
+  void computeInfo(CGFunctionInfo ) const override {
+   if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+for (auto  : FI.arguments())
+  I.info = classifyArgumentType(I.type);
+  }
+};
+
 class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   AVRTargetCodeGenInfo(CodeGenTypes )
-  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override {


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+struct s10 a0;
+a0.a = c;
+a0.b = b;
+a0.c = a;
+return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+struct s06 a0;
+a0.a = a;
+a0.b = b;
+a0.c = c;
+return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8087,14 +8087,39 @@
 }
 
 //===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 //===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo 

Re: [clang] aae84b8 - Revert "[Driver] Bring back "Clean up Debian multiarch /usr/include/ madness" and restore i586-linux-gnu"

2021-03-23 Thread Nico Weber via cfe-commits
(Reduced repro:
https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20210322/362775.html
)

On Tue, Mar 23, 2021 at 11:14 PM Zequan Wu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Zequan Wu
> Date: 2021-03-23T20:12:09-07:00
> New Revision: aae84b8e3939e815bbc1e64b3b30c0f10b055be4
>
> URL:
> https://github.com/llvm/llvm-project/commit/aae84b8e3939e815bbc1e64b3b30c0f10b055be4
> DIFF:
> https://github.com/llvm/llvm-project/commit/aae84b8e3939e815bbc1e64b3b30c0f10b055be4.diff
>
> LOG: Revert "[Driver] Bring back "Clean up Debian multiarch
> /usr/include/ madness" and restore i586-linux-gnu"
>
> This breaks bots in chromium goma building.
>
> This reverts commit 424bf5d8918f6356f1b8e99205c5fc8b4783ca22.
>
> Added:
>
>
> Modified:
> clang/lib/Driver/ToolChains/Gnu.cpp
> clang/lib/Driver/ToolChains/Linux.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp
> b/clang/lib/Driver/ToolChains/Gnu.cpp
> index bf0c3fa679d2..f2106a8c09f3 100644
> --- a/clang/lib/Driver/ToolChains/Gnu.cpp
> +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
> @@ -2109,11 +2109,9 @@ void
> Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
>static const char *const X32LibDirs[] = {"/libx32"};
>static const char *const X86LibDirs[] = {"/lib32", "/lib"};
>static const char *const X86Triples[] = {
> -  "i586-linux-gnu", "i686-linux-gnu",
> -  "i686-pc-linux-gnu",  "i386-redhat-linux6E",
> -  "i686-redhat-linux",  "i386-redhat-linux",
> -  "i586-suse-linux","i686-montavista-linux",
> -  "i686-linux-android", "i386-gnu",
> +  "i686-linux-gnu","i686-pc-linux-gnu",
> "i386-redhat-linux6E",
> +  "i686-redhat-linux", "i386-redhat-linux",  "i586-suse-linux",
> +  "i686-montavista-linux", "i686-linux-android", "i386-gnu",
>};
>
>static const char *const M68kLibDirs[] = {"/lib"};
> @@ -3015,6 +3013,8 @@ Generic_GCC::addGCCLibStdCxxIncludePaths(const
> llvm::opt::ArgList ,
>const Multilib  = GCCInstallation.getMultilib();
>const std::string Triple = getMultiarchTriple(
>getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
> +  const std::string TargetMultiarchTriple =
> +  getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
>const GCCVersion  = GCCInstallation.getVersion();
>
>// Try /../$triple/include/c++/$version then /../include/c++/$version.
>
> diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp
> b/clang/lib/Driver/ToolChains/Linux.cpp
> index 0df2d3793819..cbfa5152bc8e 100644
> --- a/clang/lib/Driver/ToolChains/Linux.cpp
> +++ b/clang/lib/Driver/ToolChains/Linux.cpp
> @@ -604,11 +604,172 @@ void Linux::AddClangSystemIncludeArgs(const ArgList
> ,
>  return;
>}
>
> -  // On Android and Debian, add /usr/include/$triple if exists.
> -  std::string MultiarchIncludeDir = getMultiarchTriple(D, getTriple(),
> SysRoot);
> -  if (!MultiarchIncludeDir.empty() &&
> -  D.getVFS().exists(SysRoot + "/usr/include/" + MultiarchIncludeDir))
> -addExternCSystemInclude(DriverArgs, CC1Args, SysRoot +
> "/usr/include/" + MultiarchIncludeDir);
> +  // Implement generic Debian multiarch support.
> +  const StringRef X86_64MultiarchIncludeDirs[] = {
> +  "/usr/include/x86_64-linux-gnu",
> +
> +  // FIXME: These are older forms of multiarch. It's not clear that
> they're
> +  // in use in any released version of Debian, so we should consider
> +  // removing them.
> +  "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
> +  const StringRef X86MultiarchIncludeDirs[] = {
> +  "/usr/include/i386-linux-gnu",
> +
> +  // FIXME: These are older forms of multiarch. It's not clear that
> they're
> +  // in use in any released version of Debian, so we should consider
> +  // removing them.
> +  "/usr/include/x86_64-linux-gnu/32", "/usr/include/i686-linux-gnu",
> +  "/usr/include/i486-linux-gnu"};
> +  const StringRef AArch64MultiarchIncludeDirs[] = {
> +  "/usr/include/aarch64-linux-gnu"};
> +  const StringRef ARMMultiarchIncludeDirs[] = {
> +  "/usr/include/arm-linux-gnueabi"};
> +  const StringRef ARMHFMultiarchIncludeDirs[] = {
> +  "/usr/include/arm-linux-gnueabihf"};
> +  const StringRef ARMEBMultiarchIncludeDirs[] = {
> +  "/usr/include/armeb-linux-gnueabi"};
> +  const StringRef ARMEBHFMultiarchIncludeDirs[] = {
> +  "/usr/include/armeb-linux-gnueabihf"};
> +  const StringRef M68kMultiarchIncludeDirs[] =
> {"/usr/include/m68k-linux-gnu"};
> +  const StringRef MIPSMultiarchIncludeDirs[] =
> {"/usr/include/mips-linux-gnu"};
> +  const StringRef MIPSELMultiarchIncludeDirs[] = {
> +  "/usr/include/mipsel-linux-gnu"};
> +  const StringRef MIPS64MultiarchIncludeDirs[] = {
> +  "/usr/include/mips64-linux-gnuabi64"};
> +  const StringRef MIPS64ELMultiarchIncludeDirs[] = {
> +  

Re: [clang] 874bdc8 - [Driver] Clean up Debian multiarch /usr/include/ madness

2021-03-23 Thread Nico Weber via cfe-commits
Yes.

1. Download
https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/500976182686961e34974ea7bdc0a21fca32be06/debian_sid_amd64_sysroot.tar.xz
2. Unpack somewhere
3. Delete the lib/ folder in it
4. Try to use that sysroot like so:

thakis@thakis:~/src/llvm-project$ cat test.cc
#include 
int main(int argc, char* argv[]) {
}
thakis@thakis:~/src/llvm-project$ out/gn/bin/clang --sysroot
~/src/chrome/src/build/linux/debian_sid_amd64-sysroot -c test.cc
In file included from test.cc:1:
/usr/local/google/home/thakis/src/chrome/src/build/linux/debian_sid_amd64-sysroot/usr/include/features.h:461:12:
fatal error: 'sys/cdefs.h' file not found
#  include 
   ^
1 error generated.



On Tue, Mar 23, 2021 at 11:01 PM Fangrui Song  wrote:

> On Tue, Mar 23, 2021 at 7:09 PM Nico Weber  wrote:
> >
> > Was this reviewed anywhere?
>
> No. This is a nice code cleanup. Do you find a case it does not handle
> correctly?
>
> > On Mon, Mar 22, 2021 at 1:40 AM Fangrui Song via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >>
> >> Author: Fangrui Song
> >> Date: 2021-03-21T22:40:38-07:00
> >> New Revision: 874bdc8e61662b5f39a9626b9132e0979fae556f
> >>
> >> URL:
> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f
> >> DIFF:
> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f.diff
> >>
> >> LOG: [Driver] Clean up Debian multiarch /usr/include/ madness
> >>
> >> Debian multiarch additionally adds /usr/include/ and somehow
> >> Android borrowed the idea. (Note /usr//include is already an
> >> include dir...). On Debian, we should just assume a GCC installation is
> >> available and use its triple.
> >>
> >> Added:
> >>
>  clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crt1.o
> >>
>  clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crti.o
> >>
>  clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crtn.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crt1.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crti.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crtn.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crt1.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crti.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crtn.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crt1.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crti.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crtn.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabi/10/crtbegin.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabihf/10/crtbegin.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabi/10/crtbegin.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabihf/10/crtbegin.o
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabihf/.keep
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabi/.keep
> >>
>  
> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
> >>
> >> Modified:
> >> clang/lib/Driver/ToolChains/Gnu.cpp
> >> clang/lib/Driver/ToolChains/Linux.cpp
> >> clang/test/Driver/arm-multilibs.c
> >>
> >> Removed:
> >>
>  
> clang/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/.keep
> >>
>  
> clang/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
> >>
>  
> clang/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf/.keep
> >>
> >>
> >>
> 
> >> diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp
> b/clang/lib/Driver/ToolChains/Gnu.cpp
> >> index c554047beac3..972044fb615e 100644
> >> --- a/clang/lib/Driver/ToolChains/Gnu.cpp
> >> +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
> >> @@ -2999,8 +2999,6 @@ Generic_GCC::addGCCLibStdCxxIncludePaths(const
> llvm::opt::ArgList ,
> >>const Multilib  = GCCInstallation.getMultilib();
> >>const std::string Triple = getMultiarchTriple(
> >>getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
> >> -  const std::string TargetMultiarchTriple =
> >> -  getMultiarchTriple(getDriver(), getTriple(),
> getDriver().SysRoot);
> >>const GCCVersion  = GCCInstallation.getVersion();
> >>
> >>// Try /../$triple/include/c++/$version then
> /../include/c++/$version.
> >>
> >> diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp
> b/clang/lib/Driver/ToolChains/Linux.cpp
> >> 

[PATCH] D99235: [HIP] Change to code object v4

2021-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Change to code object v4 by default to match ROCm 4.1.

This is upstream of code object v4 support from amd-stg-open branch.


https://reviews.llvm.org/D99235

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-code-object-version.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-device-only.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -1143,6 +1143,7 @@
  .Case("host", true)
  .Case("openmp", true)
  .Case("hip", true)
+ .Case("hipv4", true)
  .Default(false);
 
 bool TripleIsValid = !Triple.empty();
Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -97,7 +97,7 @@
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // CHECK-SAME: "-bundle-align=4096"
-// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
+// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
 // CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -85,7 +85,7 @@
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
+// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
 // CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -125,7 +125,7 @@
 // LINK-SAME: "-o" "[[IMG_DEV2:.*.out]]" "[[A_BC2]]" "[[B_BC2]]"
 
 // LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// LINK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
+// LINK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
 // LINK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
 // LINK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -82,7 +82,7 @@
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // CHECK-SAME: "-bundle-align=4096"
-// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
+// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV_A_803]],[[IMG_DEV_A_900]]" "-outputs=[[BUNDLE_A:.*hipfb]]"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
@@ -145,7 +145,7 @@
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // CHECK-SAME: "-bundle-align=4096"
-// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
+// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV_B_803]],[[IMG_DEV_B_900]]" "-outputs=[[BUNDLE_A:.*hipfb]]"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
Index: clang/test/Driver/hip-toolchain-device-only.hip
===
--- clang/test/Driver/hip-toolchain-device-only.hip
+++ clang/test/Driver/hip-toolchain-device-only.hip
@@ -25,5 +25,5 @@
 // 

[PATCH] D99233: [HIP] Add option --gpu-inline-threshold

2021-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: jansvoboda11, dang.
yaxunl requested review of this revision.

Add option --gpu-inline-threshold for inline threshold for device compilation 
only.


https://reviews.llvm.org/D99233

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -51,3 +51,8 @@
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=CTA %s
 // CTA: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-mconstructor-aliases"
 // CTA-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-mconstructor-aliases"
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 --gpu-inline-threshold=1000 %s 2>&1 | 
FileCheck -check-prefix=THRESH %s
+// THRESH: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-mllvm" 
"-inline-threshold=1000"
+// THRESH-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-inline-threshold=1000"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -291,6 +291,13 @@
 CC1Args.push_back("-mlink-builtin-bitcode");
 CC1Args.push_back(DriverArgs.MakeArgString(BCFile));
   });
+
+  StringRef InlineThresh =
+  DriverArgs.getLastArgValue(options::OPT_gpu_inline_threshold_EQ);
+  if (!InlineThresh.empty()) {
+std::string ArgStr = std::string("-inline-threshold=") + 
InlineThresh.str();
+CC1Args.append({"-mllvm", DriverArgs.MakeArgStringRef(ArgStr)});
+  }
 }
 
 llvm::opt::DerivedArgList *
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -950,6 +950,9 @@
   HelpText<"Default max threads per block for kernel launch bounds for HIP">,
   MarshallingInfoInt, "1024">,
   ShouldParseIf;
+def gpu_inline_threshold_EQ : Joined<["--"], "gpu-inline-threshold=">,
+  Flags<[CC1Option]>,
+  HelpText<"Inline threshold for device compilation for HIP">;
 def gpu_instrument_lib_EQ : Joined<["--"], "gpu-instrument-lib=">,
   HelpText<"Instrument device library for HIP, which is a LLVM bitcode 
containing "
   "__cyg_profile_func_enter and __cyg_profile_func_exit">;


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -51,3 +51,8 @@
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=CTA %s
 // CTA: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-mconstructor-aliases"
 // CTA-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-mconstructor-aliases"
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 --gpu-inline-threshold=1000 %s 2>&1 | FileCheck -check-prefix=THRESH %s
+// THRESH: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-mllvm" "-inline-threshold=1000"
+// THRESH-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-inline-threshold=1000"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -291,6 +291,13 @@
 CC1Args.push_back("-mlink-builtin-bitcode");
 CC1Args.push_back(DriverArgs.MakeArgString(BCFile));
   });
+
+  StringRef InlineThresh =
+  DriverArgs.getLastArgValue(options::OPT_gpu_inline_threshold_EQ);
+  if (!InlineThresh.empty()) {
+std::string ArgStr = std::string("-inline-threshold=") + InlineThresh.str();
+CC1Args.append({"-mllvm", DriverArgs.MakeArgStringRef(ArgStr)});
+  }
 }
 
 llvm::opt::DerivedArgList *
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -950,6 +950,9 @@
   HelpText<"Default max threads per block for kernel launch bounds for HIP">,
   MarshallingInfoInt, "1024">,
   ShouldParseIf;
+def gpu_inline_threshold_EQ : Joined<["--"], "gpu-inline-threshold=">,
+  Flags<[CC1Option]>,
+  HelpText<"Inline threshold for device compilation for HIP">;
 def gpu_instrument_lib_EQ : Joined<["--"], "gpu-instrument-lib=">,
   HelpText<"Instrument device library for HIP, which is a LLVM bitcode containing "
   "__cyg_profile_func_enter and __cyg_profile_func_exit">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] aae84b8 - Revert "[Driver] Bring back "Clean up Debian multiarch /usr/include/ madness" and restore i586-linux-gnu"

2021-03-23 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2021-03-23T20:12:09-07:00
New Revision: aae84b8e3939e815bbc1e64b3b30c0f10b055be4

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

LOG: Revert "[Driver] Bring back "Clean up Debian multiarch 
/usr/include/ madness" and restore i586-linux-gnu"

This breaks bots in chromium goma building.

This reverts commit 424bf5d8918f6356f1b8e99205c5fc8b4783ca22.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index bf0c3fa679d2..f2106a8c09f3 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2109,11 +2109,9 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
-  "i586-linux-gnu", "i686-linux-gnu",
-  "i686-pc-linux-gnu",  "i386-redhat-linux6E",
-  "i686-redhat-linux",  "i386-redhat-linux",
-  "i586-suse-linux","i686-montavista-linux",
-  "i686-linux-android", "i386-gnu",
+  "i686-linux-gnu","i686-pc-linux-gnu",  "i386-redhat-linux6E",
+  "i686-redhat-linux", "i386-redhat-linux",  "i586-suse-linux",
+  "i686-montavista-linux", "i686-linux-android", "i386-gnu",
   };
 
   static const char *const M68kLibDirs[] = {"/lib"};
@@ -3015,6 +3013,8 @@ Generic_GCC::addGCCLibStdCxxIncludePaths(const 
llvm::opt::ArgList ,
   const Multilib  = GCCInstallation.getMultilib();
   const std::string Triple = getMultiarchTriple(
   getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
+  const std::string TargetMultiarchTriple =
+  getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
   const GCCVersion  = GCCInstallation.getVersion();
 
   // Try /../$triple/include/c++/$version then /../include/c++/$version.

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 0df2d3793819..cbfa5152bc8e 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -604,11 +604,172 @@ void Linux::AddClangSystemIncludeArgs(const ArgList 
,
 return;
   }
 
-  // On Android and Debian, add /usr/include/$triple if exists.
-  std::string MultiarchIncludeDir = getMultiarchTriple(D, getTriple(), 
SysRoot);
-  if (!MultiarchIncludeDir.empty() &&
-  D.getVFS().exists(SysRoot + "/usr/include/" + MultiarchIncludeDir))
-addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include/" + 
MultiarchIncludeDir);
+  // Implement generic Debian multiarch support.
+  const StringRef X86_64MultiarchIncludeDirs[] = {
+  "/usr/include/x86_64-linux-gnu",
+
+  // FIXME: These are older forms of multiarch. It's not clear that they're
+  // in use in any released version of Debian, so we should consider
+  // removing them.
+  "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
+  const StringRef X86MultiarchIncludeDirs[] = {
+  "/usr/include/i386-linux-gnu",
+
+  // FIXME: These are older forms of multiarch. It's not clear that they're
+  // in use in any released version of Debian, so we should consider
+  // removing them.
+  "/usr/include/x86_64-linux-gnu/32", "/usr/include/i686-linux-gnu",
+  "/usr/include/i486-linux-gnu"};
+  const StringRef AArch64MultiarchIncludeDirs[] = {
+  "/usr/include/aarch64-linux-gnu"};
+  const StringRef ARMMultiarchIncludeDirs[] = {
+  "/usr/include/arm-linux-gnueabi"};
+  const StringRef ARMHFMultiarchIncludeDirs[] = {
+  "/usr/include/arm-linux-gnueabihf"};
+  const StringRef ARMEBMultiarchIncludeDirs[] = {
+  "/usr/include/armeb-linux-gnueabi"};
+  const StringRef ARMEBHFMultiarchIncludeDirs[] = {
+  "/usr/include/armeb-linux-gnueabihf"};
+  const StringRef M68kMultiarchIncludeDirs[] = {"/usr/include/m68k-linux-gnu"};
+  const StringRef MIPSMultiarchIncludeDirs[] = {"/usr/include/mips-linux-gnu"};
+  const StringRef MIPSELMultiarchIncludeDirs[] = {
+  "/usr/include/mipsel-linux-gnu"};
+  const StringRef MIPS64MultiarchIncludeDirs[] = {
+  "/usr/include/mips64-linux-gnuabi64"};
+  const StringRef MIPS64ELMultiarchIncludeDirs[] = {
+  "/usr/include/mips64el-linux-gnuabi64"};
+  const StringRef MIPSN32MultiarchIncludeDirs[] = {
+  "/usr/include/mips64-linux-gnuabin32"};
+  const StringRef MIPSN32ELMultiarchIncludeDirs[] = {
+  "/usr/include/mips64el-linux-gnuabin32"};
+  const StringRef MIPSR6MultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa32-linux-gnu"};
+  const StringRef MIPSR6ELMultiarchIncludeDirs[] = {
+  

[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

Only one problem I had for emitting lifetime markers even at O0 is that would 
action make allocas to be optimized even at O0? If so, I wonder if it confuses 
programmers since they may find some variables disappear surprisingly. Or there 
would be no optimization since every function would be marked with option 
attribute. I am not sure about this.

If I understand this problem correctly, this patch could fix problems for the 
return value of symmetric transfer and the gro that we discussed in D98638 
. Then D98638 
 may be unneeded. I prefer the implementation 
in this patch.




Comment at: clang/lib/CodeGen/CGDecl.cpp:1318
 /// otherwise
 llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
 llvm::Value *Addr) {

Can we sure frontend would always call this API to emit lifetime start? I mean 
the frontend may call EmitIntrinsic or create lifetime.start intrinsic directly 
whether by IRBuilder::CreateXXX or Instrinsic::Create(...). I worry about if 
this would incur changes out of design.

Then if we add check in EmitLifetimeStart, why not we add check in 
EmitLfietimeEnd?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99189: [RISCV][Clang] Update new overloading rules for RVV intrinsics.

2021-03-23 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 332852.
khchen added a comment.

Fix unintended change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99189

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vse.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

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


[PATCH] D98848: [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.

2021-03-23 Thread Zakk Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88c2d4c8eb0e: [RISCV][Clang] Add RVV Vector Indexed Load 
intrinsic functions. (authored by khchen).

Changed prior to commit:
  https://reviews.llvm.org/D98848?vs=332660=332850#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98848

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxei.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


Re: [clang] 874bdc8 - [Driver] Clean up Debian multiarch /usr/include/ madness

2021-03-23 Thread Nico Weber via cfe-commits
Was this reviewed anywhere?

On Mon, Mar 22, 2021 at 1:40 AM Fangrui Song via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Fangrui Song
> Date: 2021-03-21T22:40:38-07:00
> New Revision: 874bdc8e61662b5f39a9626b9132e0979fae556f
>
> URL:
> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f
> DIFF:
> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f.diff
>
> LOG: [Driver] Clean up Debian multiarch /usr/include/ madness
>
> Debian multiarch additionally adds /usr/include/ and somehow
> Android borrowed the idea. (Note /usr//include is already an
> include dir...). On Debian, we should just assume a GCC installation is
> available and use its triple.
>
> Added:
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crt1.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crti.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crtn.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crt1.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crti.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crtn.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crt1.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crti.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crtn.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crt1.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crti.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crtn.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabi/10/crtbegin.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabihf/10/crtbegin.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabi/10/crtbegin.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabihf/10/crtbegin.o
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabihf/.keep
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabi/.keep
>
> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
>
> Modified:
> clang/lib/Driver/ToolChains/Gnu.cpp
> clang/lib/Driver/ToolChains/Linux.cpp
> clang/test/Driver/arm-multilibs.c
>
> Removed:
>
> clang/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/.keep
>
> clang/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
>
> clang/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf/.keep
>
>
>
> 
> diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp
> b/clang/lib/Driver/ToolChains/Gnu.cpp
> index c554047beac3..972044fb615e 100644
> --- a/clang/lib/Driver/ToolChains/Gnu.cpp
> +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
> @@ -2999,8 +2999,6 @@ Generic_GCC::addGCCLibStdCxxIncludePaths(const
> llvm::opt::ArgList ,
>const Multilib  = GCCInstallation.getMultilib();
>const std::string Triple = getMultiarchTriple(
>getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
> -  const std::string TargetMultiarchTriple =
> -  getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
>const GCCVersion  = GCCInstallation.getVersion();
>
>// Try /../$triple/include/c++/$version then /../include/c++/$version.
>
> diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp
> b/clang/lib/Driver/ToolChains/Linux.cpp
> index cbfa5152bc8e..e889791d19b2 100644
> --- a/clang/lib/Driver/ToolChains/Linux.cpp
> +++ b/clang/lib/Driver/ToolChains/Linux.cpp
> @@ -604,172 +604,16 @@ void Linux::AddClangSystemIncludeArgs(const ArgList
> ,
>  return;
>}
>
> -  // Implement generic Debian multiarch support.
> -  const StringRef X86_64MultiarchIncludeDirs[] = {
> -  "/usr/include/x86_64-linux-gnu",
> -
> -  // FIXME: These are older forms of multiarch. It's not clear that
> they're
> -  // in use in any released version of Debian, so we should consider
> -  // removing them.
> -  "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
> -  const StringRef X86MultiarchIncludeDirs[] = {
> -  "/usr/include/i386-linux-gnu",
> -
> -  // FIXME: These are older forms of multiarch. It's not clear that
> they're
> -  // in use in any released version of Debian, so we should consider
> -  // removing them.
> -  "/usr/include/x86_64-linux-gnu/32", "/usr/include/i686-linux-gnu",
> -  "/usr/include/i486-linux-gnu"};
> -  const StringRef AArch64MultiarchIncludeDirs[] = {
> -  "/usr/include/aarch64-linux-gnu"};
> -  const StringRef ARMMultiarchIncludeDirs[] = {
> - 

[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-23 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D99227#2646532 , @rjmccall wrote:

> I am skeptical that it's reasonable to do this for *correctness*, however; I 
> don't think the frontend unconditionally emits lifetime intrinsics.

Sorry, I re-read this after posting, and it's not exactly clear what I was 
saying.  There are a lot of situations where Clang doesn't emit lifetime 
intrinsics for every `alloca` it emits, or emits unnecessarily weak bounds.  
Certain LLVM transforms can also introduce `alloca`s that don't have 
corresponding lifetime intrinsics.  So I think it's problematic to consider it 
a correctness condition that we're emitting optimally-tight lifetimes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-23 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I have no objection to trying to always emit lifetime intrinsics in coroutines 
since it has a less-trivial runtime cost.  I am skeptical that it's reasonable 
to do this for *correctness*, however; I don't think the frontend 
unconditionally emits lifetime intrinsics.  But since I think this fine to do 
regardless, I have no objection to the patch.

I think you just set `ShouldEmitLifetimeMarkers` correctly in the first place 
instead of adding this as an extra condition to every place that considers it, 
however.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99225: [clang] cxx tests: cleanup, update and add some new ones

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 332844.
mizvekov added a comment.

Normalize test tag names on clang/test/SemaCXX/P1155 
.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
  clang/test/CXX/special/class.copy/p3-cxx11.cpp
  clang/test/CXX/special/class.copy/p33-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/test/SemaCXX/return-stack-addr.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp

Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++20 -verify=cxx20 %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
 // definitions for std::move
 namespace std {
@@ -76,8 +78,8 @@
 Base test2() {
 Derived d2;
 return d2;  // e1
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
 }
 ConstructFromDerived test3() {
@@ -87,22 +89,22 @@
 ConstructFromBase test4() {
 Derived d4;
 return d4;  // e3
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
 }
 ConvertFromDerived test5() {
 Derived d5;
 return d5;  // e4
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
 }
 ConvertFromBase test6() {
 Derived d6;
 return d6;  // e5
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: 

[PATCH] D97831: [Clang][Sema] Implement GCC -Wcast-function-type

2021-03-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:1044-1048
+  // Allow integral type mismatch if their size are equal.
+  if (SrcType->isIntegralType(Context) && DestType->isIntegralType(Context))
+if (Context.getTypeInfoInChars(SrcType).Width ==
+Context.getTypeInfoInChars(DestType).Width)
+  return true;

rsmith wrote:
> In addition to allowing the cases where the sizes are the same width, should 
> we also allow cases where the promoted types are the same width (eg, `int` 
> versus `short`)? What does GCC do?
GCC does exactly that. I didn't find a way to do that by looking at TargetInfo. 
Maybe there is a way for clang?



Comment at: clang/lib/Sema/SemaCast.cpp:1050-1055
+  llvm::DenseSet> NonEquivalentDecls;
+  StructuralEquivalenceContext Ctx(
+  Context, Context, NonEquivalentDecls, StructuralEquivalenceKind::Default,
+  false /*StrictTypeSpelling*/, false /*Complain*/,
+  false /*ErrorOnTagTypeMismatch*/);
+  return Ctx.IsEquivalent(SrcType, DestType);

rsmith wrote:
> I think a "same type" check (`Context.hasSameUnqualifiedType(SrcType, 
> DestType)`) would be more appropriate here than a structural equivalence 
> check.
Agreed.



Comment at: clang/lib/Sema/SemaCast.cpp:1082-1083
+ ->castAs();
+  } else {
+return true;
+  }

rsmith wrote:
> We should also handle the case where the source is of function type and the 
> destination is a reference-to-function type.
> 
> Maybe also block pointer types?
Yep. Code/tests added for `function -> function pointer` and `block pointer -> 
function pointer`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97831

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


[PATCH] D97831: [Clang][Sema] Implement GCC -Wcast-function-type

2021-03-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 332840.
ychen marked 3 inline comments as done.
ychen added a comment.

- Add code/tests for `function -> function pointer` and `block pointer -> 
function pointer`.
- Use Context.hasSameUnqualifiedType
- Style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97831

Files:
  clang/docs/DiagnosticsReference.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/warn-cast-function-type.c
  clang/test/Sema/warn-cast-function-type.cpp

Index: clang/test/Sema/warn-cast-function-type.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-cast-function-type.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -x c++ %s -fblocks -fsyntax-only -Wcast-function-type -triple x86_64-- -verify
+
+int x(long);
+
+typedef int (f1)(long);
+typedef int (f2)(void*);
+typedef int (f3)(...);
+typedef void (f4)(...);
+typedef void (f5)(void);
+typedef int (f6)(long, int);
+typedef int (f7)(long,...);
+typedef int ()(long, int);
+
+f1 *a;
+f2 *b;
+f3 *c;
+f4 *d;
+f5 *e;
+f6 *f;
+f7 *g;
+
+struct S
+{
+  void foo (int*);
+  void bar (int);
+};
+
+typedef void (S::*mf)(int);
+
+void foo() {
+  a = (f1 *)x;
+  b = (f2 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function types}} */
+  b = reinterpret_cast(x); /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function types}} */
+  c = (f3 *)x;
+  d = (f4 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f4 *' (aka 'void (*)(...)') converts to incompatible function types}} */
+  e = (f5 *)x;
+  f = (f6 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function types}} */
+  g = (f7 *)x;
+
+  mf p1 = (mf)::foo; /* expected-warning {{cast from 'void (S::*)(int *)' to 'mf' (aka 'void (S::*)(int)') converts to incompatible function types}} */
+
+  f8 f2 = (f8)x; /* expected-warning {{cast from 'int (long)' to 'f8' (aka 'int (&)(long, int)') converts to incompatible function types}} */
+  (void)f2;
+
+  int (^y)(long);
+  f = (f6 *)y; /* expected-warning {{cast from 'int (^)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function types}} */
+}
Index: clang/test/Sema/warn-cast-function-type.c
===
--- /dev/null
+++ clang/test/Sema/warn-cast-function-type.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -x c %s -fsyntax-only -Wcast-function-type -triple x86_64-- -verify
+
+int x(long);
+
+typedef int (f1)(long);
+typedef int (f2)(void*);
+typedef int (f3)();
+typedef void (f4)();
+typedef void (f5)(void);
+typedef int (f6)(long, int);
+typedef int (f7)(long,...);
+
+f1 *a;
+f2 *b;
+f3 *c;
+f4 *d;
+f5 *e;
+f6 *f;
+f7 *g;
+
+void foo(void) {
+  a = (f1 *)x;
+  b = (f2 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function types}} */
+  c = (f3 *)x;
+  d = (f4 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f4 *' (aka 'void (*)()') converts to incompatible function types}} */
+  e = (f5 *)x;
+  f = (f6 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function types}} */
+  g = (f7 *)x;
+}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -13,8 +13,8 @@
 //
 //===--===//
 
-#include "clang/Sema/SemaInternal.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTStructuralEquivalence.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
@@ -23,6 +23,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/Initialization.h"
+#include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 using namespace clang;
@@ -1035,6 +1036,90 @@
 << FixItHint::CreateReplacement(BeginLoc, "static_cast");
 }
 
+static bool argTypeIsABIEquivalent(QualType SrcType, QualType DestType,
+   ASTContext ) {
+  if (SrcType->isPointerType() && DestType->isPointerType())
+return true;
+
+  // Allow integral type mismatch if their size are equal.
+  if (SrcType->isIntegralType(Context) && DestType->isIntegralType(Context))
+if (Context.getTypeInfoInChars(SrcType).Width ==
+Context.getTypeInfoInChars(DestType).Width)
+  return true;
+
+  return Context.hasSameUnqualifiedType(SrcType, DestType);
+}
+
+static bool checkCastFunctionType(Sema , const ExprResult ,
+  

[PATCH] D98554: Save strings for CC_PRINT env vars

2021-03-23 Thread Sean via Phabricator via cfe-commits
SeanP marked 2 inline comments as done.
SeanP added inline comments.



Comment at: clang/include/clang/Driver/Driver.h:160
   /// The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
-  const char *CCPrintStatReportFilename;
+  std::string CCPrintStatReportFilename;
 

hubert.reinterpretcast wrote:
> I'm seeing code left unchanged like:
> ```
> TheDriver.CCPrintOptionsFilename = ::getenv("CC_PRINT_OPTIONS_FILE");
> ```
> 
> Assigning to a `std::string` from a null `char *` is known to cause things 
> like
> ```
> Segmentation fault
> ```
> 
I've fixed in newest patch.


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

https://reviews.llvm.org/D98554

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


[PATCH] D98554: Save strings for CC_PRINT env vars

2021-03-23 Thread Sean via Phabricator via cfe-commits
SeanP updated this revision to Diff 332836.
SeanP added a comment.

Changed the  code checking the env vars so it doesn't assign a null_ptr to the 
string.


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

https://reviews.llvm.org/D98554

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -244,25 +244,28 @@
 }
 
 static void SetBackdoorDriverOutputsFromEnvVars(Driver ) {
-  // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
-  TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
-  if (TheDriver.CCPrintOptions)
-TheDriver.CCPrintOptionsFilename = ::getenv("CC_PRINT_OPTIONS_FILE");
-
-  // Handle CC_PRINT_HEADERS and CC_PRINT_HEADERS_FILE.
-  TheDriver.CCPrintHeaders = !!::getenv("CC_PRINT_HEADERS");
-  if (TheDriver.CCPrintHeaders)
-TheDriver.CCPrintHeadersFilename = ::getenv("CC_PRINT_HEADERS_FILE");
-
-  // Handle CC_LOG_DIAGNOSTICS and CC_LOG_DIAGNOSTICS_FILE.
-  TheDriver.CCLogDiagnostics = !!::getenv("CC_LOG_DIAGNOSTICS");
-  if (TheDriver.CCLogDiagnostics)
-TheDriver.CCLogDiagnosticsFilename = ::getenv("CC_LOG_DIAGNOSTICS_FILE");
-
-  // Handle CC_PRINT_PROC_STAT and CC_PRINT_PROC_STAT_FILE.
-  TheDriver.CCPrintProcessStats = !!::getenv("CC_PRINT_PROC_STAT");
-  if (TheDriver.CCPrintProcessStats)
-TheDriver.CCPrintStatReportFilename = ::getenv("CC_PRINT_PROC_STAT_FILE");
+  auto CheckEnvVar = [](const char *EnvOptSet, const char *EnvOptFile,
+std::string ) {
+bool OptSet = !!::getenv(EnvOptSet);
+if (OptSet) {
+  if (const char *Var = ::getenv(EnvOptFile))
+OptFile = Var;
+}
+return OptSet;
+  };
+
+  TheDriver.CCPrintOptions =
+  CheckEnvVar("CC_PRINT_OPTIONS", "CC_PRINT_OPTIONS_FILE",
+  TheDriver.CCPrintOptionsFilename);
+  TheDriver.CCPrintHeaders =
+  CheckEnvVar("CC_PRINT_HEADERS", "CC_PRINT_HEADERS_FILE",
+  TheDriver.CCPrintHeadersFilename);
+  TheDriver.CCLogDiagnostics =
+  CheckEnvVar("CC_LOG_DIAGNOSTICS", "CC_LOG_DIAGNOSTICS_FILE",
+  TheDriver.CCLogDiagnosticsFilename);
+  TheDriver.CCPrintProcessStats =
+  CheckEnvVar("CC_PRINT_PROC_STAT", "CC_PRINT_PROC_STAT_FILE",
+  TheDriver.CCPrintStatReportFilename);
 }
 
 static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5107,8 +5107,9 @@
 
   if (D.CCPrintHeaders && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-header-include-file");
-CmdArgs.push_back(D.CCPrintHeadersFilename ? D.CCPrintHeadersFilename
-   : "-");
+CmdArgs.push_back(!D.CCPrintHeadersFilename.empty()
+  ? D.CCPrintHeadersFilename.c_str()
+  : "-");
 CmdArgs.push_back("-sys-header-deps");
   }
   Args.AddLastArg(CmdArgs, options::OPT_P);
@@ -5116,8 +5117,9 @@
 
   if (D.CCLogDiagnostics && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-diagnostic-log-file");
-CmdArgs.push_back(D.CCLogDiagnosticsFilename ? D.CCLogDiagnosticsFilename
- : "-");
+CmdArgs.push_back(!D.CCLogDiagnosticsFilename.empty()
+  ? D.CCLogDiagnosticsFilename.c_str()
+  : "-");
   }
 
   // Give the gen diagnostics more chances to succeed, by avoiding intentional
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -135,14 +135,13 @@
 : Diags(Diags), VFS(std::move(VFS)), Mode(GCCMode),
   SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone), LTOMode(LTOK_None),
   ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT),
-  DriverTitle(Title), CCPrintStatReportFilename(nullptr),
-  CCPrintOptionsFilename(nullptr), CCPrintHeadersFilename(nullptr),
-  CCLogDiagnosticsFilename(nullptr), CCCPrintBindings(false),
-  CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
-  CCGenDiagnostics(false), CCPrintProcessStats(false),
-  TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc),
-  CheckInputsExist(true), GenReproducer(false),
-  SuppressMissingInputWarning(false) {
+  DriverTitle(Title), CCPrintStatReportFilename(), CCPrintOptionsFilename(),
+  CCPrintHeadersFilename(), CCLogDiagnosticsFilename(),
+  CCCPrintBindings(false), CCPrintOptions(false), CCPrintHeaders(false),
+  CCLogDiagnostics(false), 

[PATCH] D99005: [clang] WIP: Implement P2266

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Splitting off the test changes into: https://reviews.llvm.org/D99225


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] D99231: [AST] Add introspection support for more base nodes

2021-03-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: njames93.
Herald added a subscriber: mgorny.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Replace an assert for a CXXCtorInitializer SourceLocation with a
condition, as was done for other locations in commit 54272e5b (NFC:
Replace asserts with if() in SourceLocation accessors, 2019-01-07).

Fix the logic of detecting pseudo-virtual getBeginLoc etc on Stmt and
Decl subclasses.

Adjust the test infrastructure to filter out invalid source locations.
This makes the tests more clear about which nodes have which locations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99231

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -30,7 +30,10 @@
 std::map
 FormatExpected(const MapType ) {
   std::map Result;
-  llvm::transform(Accessors,
+  llvm::transform(llvm::make_filter_range(Accessors,
+  [](const auto ) {
+return Accessor.first.isValid();
+  }),
   std::inserter(Result, Result.end()),
   [](const auto ) {
 return std::make_pair(
@@ -126,11 +129,9 @@
   UnorderedElementsAre(
   STRING_LOCATION_PAIR(MethodDecl, getBeginLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getBodyRBrace()),
-  STRING_LOCATION_PAIR(MethodDecl, getEllipsisLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getInnerLocStart()),
   STRING_LOCATION_PAIR(MethodDecl, getLocation()),
   STRING_LOCATION_PAIR(MethodDecl, getOuterLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getPointOfInstantiation()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecEndLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecStartLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getEndLoc(;
@@ -145,3 +146,538 @@
   STRING_LOCATION_PAIR(MethodDecl, getReturnTypeSourceRange()),
   STRING_LOCATION_PAIR(MethodDecl, getSourceRange(;
 }
+
+TEST(Introspection, SourceLocations_NNS) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+namespace ns
+{
+  struct A {
+  void foo();
+};
+}
+void ns::A::foo() {}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto  = AST->getASTContext();
+  auto  = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(nestedNameSpecifierLoc().bind("nns"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *NNS = BoundNodes[0].getNodeAs("nns");
+
+  auto Result = NodeIntrospection::GetLocations(NNS);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(
+  ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getEndLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalEndLoc(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getLocalSourceRange()),
+   STRING_LOCATION_PAIR(NNS, getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_TA_Type) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+template
+  struct A {
+  void foo();
+};
+
+void foo()
+{
+  A a;
+}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto  = AST->getASTContext();
+  auto  = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(templateArgumentLoc().bind("ta"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *TA = BoundNodes[0].getNodeAs("ta");
+
+  auto Result = NodeIntrospection::GetLocations(TA);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(TA, getLocation(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(ExpectedRanges,
+   

[PATCH] D99225: [clang] cxx tests: cleanup, update and add some new ones

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 332832.
mizvekov added a comment.

Changes per Arthur.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
  clang/test/CXX/special/class.copy/p3-cxx11.cpp
  clang/test/CXX/special/class.copy/p33-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/test/SemaCXX/return-stack-addr.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp

Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++20 -verify=cxx20 %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
 // definitions for std::move
 namespace std {
@@ -76,8 +78,8 @@
 Base test2() {
 Derived d2;
 return d2;  // e1
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
 }
 ConstructFromDerived test3() {
@@ -87,22 +89,22 @@
 ConstructFromBase test4() {
 Derived d4;
 return d4;  // e3
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
 }
 ConvertFromDerived test5() {
 Derived d5;
 return d5;  // e4
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
 }
 ConvertFromBase test6() {
 Derived d6;
 return d6;  // e5
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d6)"
 }
 
@@ -150,8 +152,8 @@
 

[PATCH] D99225: [clang] cxx tests: cleanup, update and add some new ones

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/test/CXX/drs/dr3xx.cpp:444
   void f(volatile void); // expected-error {{'void' as parameter must not have 
type qualifiers}}
+  // cxx20_2b-warning@-1 {{volatile-qualified parameter type 'volatile void' 
is deprecated}}
   void g(const void); // expected-error {{'void' as parameter must not have 
type qualifiers}}

mizvekov wrote:
> Quuxplusone wrote:
> > This gives an error //and// a C++20 warning? 
> > Oh yeah. Huh. https://godbolt.org/z/eMY9zMs54 That's definitely a Clang 
> > bug. Feel like filing it?
> heh, no problem.
https://bugs.llvm.org/show_bug.cgi?id=49703


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

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


[PATCH] D99225: [clang] cxx tests: cleanup, update and add some new ones

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: 
clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp:3
+// RUN: %clang_cc1 -verify -std=c++20 -verify %s
+// RUN: %clang_cc1 -verify -std=c++14 -verify %s
 

Quuxplusone wrote:
> (1) You skipped 17.
> (2) Isn't there some way to mark a Clang test as "run this in all modes '14 
> and later"? We shouldn't have to touch every single test every 3 years; there 
> must be a way to do this; I just don't know what it is.
1) I skipped on purpose, felt like may have been adding more than is necessary, 
but I can add it no problem.
2) It sucks I know, but not as far as I know. Something has to be implemented 
in lit for that to happen.



Comment at: clang/test/CXX/drs/dr3xx.cpp:6
+// RUN: %clang_cc1 -std=c++11 -verify=expected,cxx98_17,cxx98_2b -triple 
%itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++98 -verify=expected,cxx98_17,cxx98_2b -triple 
%itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
 

Quuxplusone wrote:
> `cxx98_2b` is "unconditional", right?
err, yes, I was not thinking very clearly :P



Comment at: clang/test/CXX/drs/dr3xx.cpp:444
   void f(volatile void); // expected-error {{'void' as parameter must not have 
type qualifiers}}
+  // cxx20_2b-warning@-1 {{volatile-qualified parameter type 'volatile void' 
is deprecated}}
   void g(const void); // expected-error {{'void' as parameter must not have 
type qualifiers}}

Quuxplusone wrote:
> This gives an error //and// a C++20 warning? 
> Oh yeah. Huh. https://godbolt.org/z/eMY9zMs54 That's definitely a Clang bug. 
> Feel like filing it?
heh, no problem.



Comment at: clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp:3
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
+

Quuxplusone wrote:
> And 11, 14, 17?
Again, just avoiding the extra workload there, but I can add it.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:1771
+  // expected-warning {{expression with side effects will be evaluated despite 
being used as an operand to 'typeid'}} \\
+  // cxx20_2b-note {{non-constexpr function 'g' cannot be used in a constant 
expression}}
 }

Quuxplusone wrote:
> What are those trailing (occasionally doubled) backslashes doing on lines 
> 1768–1770?
> Get rid of them.
> You might then need to say `expected-warning@-1` and so on... which is fine.
Err the doubled one was a typo, but I was just keeping the local style.



Comment at: clang/test/SemaCXX/coroutine-rvo.cpp:1
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z 
-fcoroutines-ts -fsyntax-only
+// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
 

Quuxplusone wrote:
> Surely this should be tested in 20 (and 2b), since coroutines are a C++20 
> feature.
Yeah but remember, the coroutine change was unconditional, and I don't think 
this test is picking up any differences for the other modes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

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


[clang] 4259301 - Support #__private_macro and #__public_macro in local submodule

2021-03-23 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-03-23T16:54:28-07:00
New Revision: 4259301aaf58c13b004d968dfbd20428bf978b32

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

LOG: Support #__private_macro and #__public_macro in local submodule
visibility mode.

Added: 
clang/test/Modules/Inputs/lsv-private-macro/mod.map
clang/test/Modules/Inputs/lsv-private-macro/other.h
clang/test/Modules/Inputs/lsv-private-macro/self.h
clang/test/Modules/lsv-private-macro.cpp

Modified: 
clang/lib/Lex/PPDirectives.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 252697b2fd35..a771b7c5d122 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1045,12 +1045,12 @@ void Preprocessor::HandleDirective(Token ) {
   break;
 
 case tok::pp___public_macro:
-  if (getLangOpts().Modules)
+  if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility)
 return HandleMacroPublicDirective(Result);
   break;
 
 case tok::pp___private_macro:
-  if (getLangOpts().Modules)
+  if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility)
 return HandleMacroPrivateDirective();
   break;
 }

diff  --git a/clang/test/Modules/Inputs/lsv-private-macro/mod.map 
b/clang/test/Modules/Inputs/lsv-private-macro/mod.map
new file mode 100644
index ..62b92fb63e79
--- /dev/null
+++ b/clang/test/Modules/Inputs/lsv-private-macro/mod.map
@@ -0,0 +1,7 @@
+module self {
+  header "self.h"
+}
+
+module other {
+  header "other.h"
+}

diff  --git a/clang/test/Modules/Inputs/lsv-private-macro/other.h 
b/clang/test/Modules/Inputs/lsv-private-macro/other.h
new file mode 100644
index ..356eccaec27f
--- /dev/null
+++ b/clang/test/Modules/Inputs/lsv-private-macro/other.h
@@ -0,0 +1,7 @@
+#define OTHER_PRIVATE
+#__private_macro OTHER_PRIVATE
+
+#define OTHER_PUBLIC
+#__public_macro OTHER_PUBLIC
+
+#define OTHER_DEFAULT

diff  --git a/clang/test/Modules/Inputs/lsv-private-macro/self.h 
b/clang/test/Modules/Inputs/lsv-private-macro/self.h
new file mode 100644
index ..5a361308a10d
--- /dev/null
+++ b/clang/test/Modules/Inputs/lsv-private-macro/self.h
@@ -0,0 +1,7 @@
+#define SELF_PRIVATE
+#__private_macro SELF_PRIVATE
+
+#define SELF_PUBLIC
+#__public_macro SELF_PUBLIC
+
+#define SELF_DEFAULT

diff  --git a/clang/test/Modules/lsv-private-macro.cpp 
b/clang/test/Modules/lsv-private-macro.cpp
new file mode 100644
index ..6564558453e3
--- /dev/null
+++ b/clang/test/Modules/lsv-private-macro.cpp
@@ -0,0 +1,53 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 %s \
+// RUN:   -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-map-file=%S/Inputs/lsv-private-macro/mod.map \
+// RUN:   -I%S/Inputs/lsv-private-macro -fmodule-name=self \
+// RUN:   -verify=expected-lsv
+//
+// RUN: %clang_cc1 %s \
+// RUN:   -fmodules -fmodules-cache-path=%t \
+// RUN:   -fmodule-map-file=%S/Inputs/lsv-private-macro/mod.map \
+// RUN:   -I%S/Inputs/lsv-private-macro -fmodule-name=self \
+// RUN:   -verify=expected-nolsv
+//
+// RUN: %clang_cc1 %s \
+// RUN:   -fmodules -fmodules-cache-path=%t \
+// RUN:   -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-map-file=%S/Inputs/lsv-private-macro/mod.map \
+// RUN:   -I%S/Inputs/lsv-private-macro -fmodule-name=self \
+// RUN:   -verify=expected-lsv
+
+#include "self.h"
+
+// With local submodule visibility enabled, private macros don't leak out of
+// their respective submodules, even within the same top-level module.
+// expected-lsv-no-diagnostics
+
+// expected-nolsv-error@+2 {{SELF_PRIVATE defined}}
+#ifdef SELF_PRIVATE
+#error SELF_PRIVATE defined
+#endif
+
+#ifndef SELF_PUBLIC
+#error SELF_PUBLIC not defined
+#endif
+
+#ifndef SELF_DEFAULT
+#error SELF_DEFAULT not defined
+#endif
+
+#include "other.h"
+
+#ifdef OTHER_PRIVATE
+#error OTHER_PRIVATE defined
+#endif
+
+#ifndef OTHER_PUBLIC
+#error OTHER_PUBLIC not defined
+#endif
+
+#ifndef OTHER_DEFAULT
+#error OTHER_DEFAULT not defined
+#endif



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


[clang] 4cd1098 - Improve const-correctness. NFC.

2021-03-23 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-03-23T16:54:27-07:00
New Revision: 4cd109891cbc448819eb9de9104cd14d993e45b1

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

LOG: Improve const-correctness. NFC.

Added: 


Modified: 
clang/include/clang/Lex/MacroInfo.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPMacroExpansion.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/MacroInfo.h 
b/clang/include/clang/Lex/MacroInfo.h
index 550abf35c8416..0347a7a37186b 100644
--- a/clang/include/clang/Lex/MacroInfo.h
+++ b/clang/include/clang/Lex/MacroInfo.h
@@ -521,7 +521,7 @@ class ModuleMacro : public llvm::FoldingSetNode {
   }
 
   static void Profile(llvm::FoldingSetNodeID , Module *OwningModule,
-  IdentifierInfo *II) {
+  const IdentifierInfo *II) {
 ID.AddPointer(OwningModule);
 ID.AddPointer(II);
   }

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index e34e35be30b37..d89c4753f8d1a 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1151,7 +1151,7 @@ class Preprocessor {
   /// Register an exported macro for a module and identifier.
   ModuleMacro *addModuleMacro(Module *Mod, IdentifierInfo *II, MacroInfo 
*Macro,
   ArrayRef Overrides, bool );
-  ModuleMacro *getModuleMacro(Module *Mod, IdentifierInfo *II);
+  ModuleMacro *getModuleMacro(Module *Mod, const IdentifierInfo *II);
 
   /// Get the list of leaf (non-overridden) module macros for a name.
   ArrayRef getLeafModuleMacros(const IdentifierInfo *II) const {

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index f04d896247c98..252697b2fd35a 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -124,7 +124,7 @@ static bool isReservedId(StringRef Text, const LangOptions 
) {
 // the specified module, meaning clang won't build the specified module. This 
is
 // useful in a number of situations, for instance, when building a library that
 // vends a module map, one might want to avoid hitting intermediate build
-// products containimg the the module map or avoid finding the system installed
+// products containing the the module map or avoid finding the system installed
 // modulemap for that library.
 static bool isForModuleBuilding(Module *M, StringRef CurrentModule,
 StringRef ModuleName) {

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 43d31d6c5732e..9528a8f575f0c 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -170,7 +170,8 @@ ModuleMacro *Preprocessor::addModuleMacro(Module *Mod, 
IdentifierInfo *II,
   return MM;
 }
 
-ModuleMacro *Preprocessor::getModuleMacro(Module *Mod, IdentifierInfo *II) {
+ModuleMacro *Preprocessor::getModuleMacro(Module *Mod,
+  const IdentifierInfo *II) {
   llvm::FoldingSetNodeID ID;
   ModuleMacro::Profile(ID, Mod, II);
 



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


[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-23 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
Herald added subscribers: ChuanqiXu, hoy, modimo, wenlei.
lxfind requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

tl;dr Correct implementation of Corouintes requires having lifetime intrinsics 
available.

Coroutine functions are functions that can be suspended and resumed latter. To 
do so, data that need to stay alive after suspension must be put on the heap 
(i.e. the coroutine frame).
The optimizer is responsible for analyzing each AllocaInst and figure out 
whether it should be put on the stack or the frame.
In most cases, for data that we are unable to accurately analyze lifetime, we 
can just conservatively put them on the heap.
Unfortunately, there exists a few cases where certain data MUST be put on the 
stack, not on the heap. Without lifetime intrinsics, we are unable to correctly 
analyze those data's lifetime.

To dig into more details, there exists cases where at certain code points, the 
current coroutine frame may have already been destroyed. Hence no frame access 
would be allowed beyond that point.
The following is a common code pattern called "Symmetric Transfer" in coroutine:

  auto tmp = await_suspend();
  __builtin_coro_resume(tmp.address());
  return;

In the above code example, `await_suspend()` returns a new coroutine handle, 
which we will obtain the address and then resume that coroutine. This 
essentially "transfered" from the current coroutine to a different coroutine.
During the call to `await_suspend()`, the current coroutine may be destroyed, 
which should be fine because we are not accessing any data afterwards.
However when LLVM is emitting IR for the above code, it needs to emit an 
AllocaInst for `tmp`. It will then call the `address` function on tmp. 
`address` function is a member function of coroutine, and there is no way for 
the LLVM optimizer to know that it does not capture the `tmp` pointer. So when 
the optimizer looks at it, it has to conservatively assume that `tmp` may 
escape and hence put it on the heap. Furthermore, in some cases `address` call 
would be inlined, which will generate a bunch of store/load instructions that 
move the `tmp` pointer around. Those stores will also make the compiler to 
think that `tmp` might escape.
To summarize, it's really difficult for the mid-end to figure out that the 
`tmp` data is short-lived.
I made some attempt in D98638 , but it appears 
to be way too complex and is basically doing the same thing as inserting 
lifetime intrinsics in coroutines.

Also, for reference, we already force emitting lifetime intrinsics in O0 for 
AlwaysInliner: 
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Passes/PassBuilder.cpp#L1893


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99227

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp


Index: clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp
===
--- clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp
+++ clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-O1 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-O0 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
 
 #include "Inputs/coroutine.h"
 
@@ -50,8 +50,13 @@
 
 // check that the lifetime of the coroutine handle used to obtain the address 
is contained within single basic block, and hence does not live across 
suspension points.
 // CHECK-LABEL: final.suspend:
-// CHECK: %[[PTR1:.+]] = bitcast 
%"struct.std::experimental::coroutines_v1::coroutine_handle.0"* 
%[[ADDR_TMP:.+]] to i8*
-// CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 8, i8* %[[PTR1]])
-// CHECK: call i8* 
@{{.*address.*}}(%"struct.std::experimental::coroutines_v1::coroutine_handle.0"*
 {{[^,]*}} %[[ADDR_TMP]])
-// CHECK-NEXT:%[[PTR2:.+]] = bitcast 
%"struct.std::experimental::coroutines_v1::coroutine_handle.0"* %[[ADDR_TMP]] 
to i8*
-// CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 8, i8* %[[PTR2]])
+// CHECK: %{{.+}} = call token @llvm.coro.save(i8* null)
+// CHECK: %[[HDL_CAST1:.+]] = bitcast 
%"struct.std::experimental::coroutines_v1::coroutine_handle.0"* %[[HDL:.+]] to 
i8*
+// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* 
%[[HDL_CAST1]])
+// CHECK: %[[CALL:.+]] = call i8* 
@_ZN13detached_task12promise_type13final_awaiter13await_suspendENSt12experimental13coroutines_v116coroutine_handleIS0_EE(
+// CHECK: %[[HDL_CAST2:.+]] = getelementptr inbounds 
%"struct.std::experimental::coroutines_v1::coroutine_handle.0", 

[PATCH] D99225: [clang] cxx tests: cleanup, update and add some new ones

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

IMHO you should just go ahead and land the trivial trailing-whitespace changes.




Comment at: 
clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp:3
+// RUN: %clang_cc1 -verify -std=c++20 -verify %s
+// RUN: %clang_cc1 -verify -std=c++14 -verify %s
 

(1) You skipped 17.
(2) Isn't there some way to mark a Clang test as "run this in all modes '14 and 
later"? We shouldn't have to touch every single test every 3 years; there must 
be a way to do this; I just don't know what it is.



Comment at: clang/test/CXX/drs/dr3xx.cpp:6
+// RUN: %clang_cc1 -std=c++11 -verify=expected,cxx98_17,cxx98_2b -triple 
%itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++98 -verify=expected,cxx98_17,cxx98_2b -triple 
%itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
 

`cxx98_2b` is "unconditional", right?



Comment at: clang/test/CXX/drs/dr3xx.cpp:444
   void f(volatile void); // expected-error {{'void' as parameter must not have 
type qualifiers}}
+  // cxx20_2b-warning@-1 {{volatile-qualified parameter type 'volatile void' 
is deprecated}}
   void g(const void); // expected-error {{'void' as parameter must not have 
type qualifiers}}

This gives an error //and// a C++20 warning? 
Oh yeah. Huh. https://godbolt.org/z/eMY9zMs54 That's definitely a Clang bug. 
Feel like filing it?



Comment at: clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp:3
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
+

And 11, 14, 17?



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:3
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx20_2b -triple 
x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array 
-Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment 
-Wno-tautological-pointer-compare -Wno-bool-conversion
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11 -triple 
x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array 
-Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment 
-Wno-tautological-pointer-compare -Wno-bool-conversion
 

And 14, 17?



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:1771
+  // expected-warning {{expression with side effects will be evaluated despite 
being used as an operand to 'typeid'}} \\
+  // cxx20_2b-note {{non-constexpr function 'g' cannot be used in a constant 
expression}}
 }

What are those trailing (occasionally doubled) backslashes doing on lines 
1768–1770?
Get rid of them.
You might then need to say `expected-warning@-1` and so on... which is fine.



Comment at: clang/test/SemaCXX/constant-expression-cxx14.cpp:3
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx20_2b %s 
-fcxx-exceptions -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=expected,cxx14%s 
-fcxx-exceptions -triple=x86_64-linux-gnu
 

17?



Comment at: clang/test/SemaCXX/conversion-function.cpp:5
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx98_14 -triple 
%itanium_abi_triple -Wbind-to-temporary-copy %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify=expected,cxx98_14 -triple 
%itanium_abi_triple -Wbind-to-temporary-copy %s
 

17?



Comment at: clang/test/SemaCXX/coroutine-rvo.cpp:1
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z 
-fcoroutines-ts -fsyntax-only
+// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
 

Surely this should be tested in 20 (and 2b), since coroutines are a C++20 
feature.



Comment at: clang/test/SemaCXX/deduced-return-type-cxx14.cpp:8
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=expected,cxx14%s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=expected,cxx14%s 
-fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING
 

17?



Comment at: clang/test/SemaCXX/return-stack-addr.cpp:3
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected   %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11 %s
 

14, 17?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

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


[clang] 431e313 - [CGAtomic] Lift stronger requirements on cmpxch and support acquire failure mode

2021-03-23 Thread Bruno Cardoso Lopes via cfe-commits

Author: Bruno Cardoso Lopes
Date: 2021-03-23T16:45:37-07:00
New Revision: 431e3138a1f3fd2bb7b25e1f4766d935058136f8

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

LOG: [CGAtomic] Lift stronger requirements on cmpxch and support acquire 
failure mode

- Fix `emitAtomicCmpXchgFailureSet` to support release/acquire (succ/fail) 
memory order.
- Remove stronger checks for cmpxch.

Effectively, this addresses http://wg21.link/p0418

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

Added: 


Modified: 
clang/lib/CodeGen/CGAtomic.cpp
clang/test/CodeGen/atomic-ops.c
clang/test/CodeGenOpenCL/atomic-ops.cl
llvm/docs/LangRef.rst

Removed: 




diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index c7256e240a31..8ac36e4a6b64 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -427,6 +427,8 @@ static void emitAtomicCmpXchgFailureSet(CodeGenFunction 
, AtomicExpr *E,
 else
   switch ((llvm::AtomicOrderingCABI)FOS) {
   case llvm::AtomicOrderingCABI::relaxed:
+  // 31.7.2.18: "The failure argument shall not be memory_order_release
+  // nor memory_order_acq_rel". Fallback to monotonic.
   case llvm::AtomicOrderingCABI::release:
   case llvm::AtomicOrderingCABI::acq_rel:
 FailureOrder = llvm::AtomicOrdering::Monotonic;
@@ -439,12 +441,10 @@ static void emitAtomicCmpXchgFailureSet(CodeGenFunction 
, AtomicExpr *E,
 FailureOrder = llvm::AtomicOrdering::SequentiallyConsistent;
 break;
   }
-if (isStrongerThan(FailureOrder, SuccessOrder)) {
-  // Don't assert on undefined behavior "failure argument shall be no
-  // stronger than the success argument".
-  FailureOrder =
-  llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(SuccessOrder);
-}
+// Prior to c++17, "the failure argument shall be no stronger than the
+// success argument". This condition has been lifted and the only
+// precondition is 31.7.2.18. Effectively treat this as a DR and skip
+// language version checks.
 emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2, Size, 
SuccessOrder,
   FailureOrder, Scope);
 return;
@@ -454,8 +454,7 @@ static void emitAtomicCmpXchgFailureSet(CodeGenFunction 
, AtomicExpr *E,
   llvm::BasicBlock *MonotonicBB = nullptr, *AcquireBB = nullptr,
*SeqCstBB = nullptr;
   MonotonicBB = CGF.createBasicBlock("monotonic_fail", CGF.CurFn);
-  if (SuccessOrder != llvm::AtomicOrdering::Monotonic &&
-  SuccessOrder != llvm::AtomicOrdering::Release)
+  if (SuccessOrder != llvm::AtomicOrdering::Monotonic)
 AcquireBB = CGF.createBasicBlock("acquire_fail", CGF.CurFn);
   if (SuccessOrder == llvm::AtomicOrdering::SequentiallyConsistent)
 SeqCstBB = CGF.createBasicBlock("seqcst_fail", CGF.CurFn);
@@ -479,8 +478,9 @@ static void emitAtomicCmpXchgFailureSet(CodeGenFunction 
, AtomicExpr *E,
 emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2,
   Size, SuccessOrder, llvm::AtomicOrdering::Acquire, 
Scope);
 CGF.Builder.CreateBr(ContBB);
-SI->addCase(CGF.Builder.getInt32((int)llvm::AtomicOrderingCABI::consume),
-AcquireBB);
+if (SuccessOrder != llvm::AtomicOrdering::Release)
+  SI->addCase(CGF.Builder.getInt32((int)llvm::AtomicOrderingCABI::consume),
+  AcquireBB);
 SI->addCase(CGF.Builder.getInt32((int)llvm::AtomicOrderingCABI::acquire),
 AcquireBB);
   }

diff  --git a/clang/test/CodeGen/atomic-ops.c b/clang/test/CodeGen/atomic-ops.c
index 4deb1322e0ff..269406fc3c50 100644
--- a/clang/test/CodeGen/atomic-ops.c
+++ b/clang/test/CodeGen/atomic-ops.c
@@ -500,6 +500,7 @@ void generalFailureOrder(_Atomic(int) *ptr, int *ptr2, int 
success, int fail) {
 
   // CHECK: [[RELEASE]]
   // CHECK: switch {{.*}}, label %[[RELEASE_MONOTONIC:[0-9a-zA-Z._]+]] [
+  // CHECK-NEXT: i32 2, label %[[RELEASE_ACQUIRE:[0-9a-zA-Z._]+]]
   // CHECK-NEXT: ]
 
   // CHECK: [[ACQREL]]
@@ -527,6 +528,14 @@ void generalFailureOrder(_Atomic(int) *ptr, int *ptr2, int 
success, int fail) {
   // CHECK: cmpxchg {{.*}} acquire acquire, align
   // CHECK: br
 
+  // CHECK: [[RELEASE_MONOTONIC]]
+  // CHECK: cmpxchg {{.*}} release monotonic, align
+  // CHECK: br
+
+  // CHECK: [[RELEASE_ACQUIRE]]
+  // CHECK: cmpxchg {{.*}} release acquire, align
+  // CHECK: br
+
   // CHECK: [[ACQREL_MONOTONIC]]
   // CHECK: cmpxchg {{.*}} acq_rel monotonic, align
   // CHECK: br
@@ -562,6 +571,20 @@ void generalWeakness(int *ptr, int *ptr2, _Bool weak) {
   // CHECK-NOT: br
   // CHECK: cmpxchg weak {{.*}} seq_cst seq_cst, align
   // CHECK: br
+
+  __atomic_compare_exchange_n(ptr, ptr2, 42, weak, memory_order_release, 

[PATCH] D98995: [CGAtomic] Lift stronger requirements on cmpxch and add support for acquire failure mode

2021-03-23 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG431e3138a1f3: [CGAtomic] Lift stronger requirements on 
cmpxch and support acquire failure mode (authored by bruno).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98995

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGenOpenCL/atomic-ops.cl
  llvm/docs/LangRef.rst

Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -9768,8 +9768,7 @@
 
 The success and failure :ref:`ordering ` arguments specify how this
 ``cmpxchg`` synchronizes with other atomic operations. Both ordering parameters
-must be at least ``monotonic``, the ordering constraint on failure must be no
-stronger than that on success, and the failure ordering cannot be either
+must be at least ``monotonic``, the failure ordering cannot be either
 ``release`` or ``acq_rel``.
 
 A ``cmpxchg`` instruction can also take an optional
Index: clang/test/CodeGenOpenCL/atomic-ops.cl
===
--- clang/test/CodeGenOpenCL/atomic-ops.cl
+++ clang/test/CodeGenOpenCL/atomic-ops.cl
@@ -227,6 +227,7 @@
 
   // CHECK: [[RELEASE]]
   // CHECK: switch {{.*}}, label %[[RELEASE_MONOTONIC:[0-9a-zA-Z._]+]] [
+  // CHECK-NEXT: i32 2, label %[[RELEASE_ACQUIRE:[0-9a-zA-Z._]+]]
   // CHECK-NEXT: ]
 
   // CHECK: [[ACQREL]]
@@ -254,6 +255,14 @@
   // CHECK: cmpxchg {{.*}} acquire acquire, align 4
   // CHECK: br
 
+  // CHECK: [[RELEASE_MONOTONIC]]
+  // CHECK: cmpxchg {{.*}} release monotonic, align 4
+  // CHECK: br
+
+  // CHECK: [[RELEASE_ACQUIRE]]
+  // CHECK: cmpxchg {{.*}} release acquire, align 4
+  // CHECK: br
+
   // CHECK: [[ACQREL_MONOTONIC]]
   // CHECK: cmpxchg {{.*}} acq_rel monotonic, align 4
   // CHECK: br
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -500,6 +500,7 @@
 
   // CHECK: [[RELEASE]]
   // CHECK: switch {{.*}}, label %[[RELEASE_MONOTONIC:[0-9a-zA-Z._]+]] [
+  // CHECK-NEXT: i32 2, label %[[RELEASE_ACQUIRE:[0-9a-zA-Z._]+]]
   // CHECK-NEXT: ]
 
   // CHECK: [[ACQREL]]
@@ -527,6 +528,14 @@
   // CHECK: cmpxchg {{.*}} acquire acquire, align
   // CHECK: br
 
+  // CHECK: [[RELEASE_MONOTONIC]]
+  // CHECK: cmpxchg {{.*}} release monotonic, align
+  // CHECK: br
+
+  // CHECK: [[RELEASE_ACQUIRE]]
+  // CHECK: cmpxchg {{.*}} release acquire, align
+  // CHECK: br
+
   // CHECK: [[ACQREL_MONOTONIC]]
   // CHECK: cmpxchg {{.*}} acq_rel monotonic, align
   // CHECK: br
@@ -562,6 +571,20 @@
   // CHECK-NOT: br
   // CHECK: cmpxchg weak {{.*}} seq_cst seq_cst, align
   // CHECK: br
+
+  __atomic_compare_exchange_n(ptr, ptr2, 42, weak, memory_order_release, memory_order_acquire);
+  // CHECK: switch i1 {{.*}}, label %[[WEAK:[0-9a-zA-Z._]+]] [
+  // CHECK-NEXT: i1 false, label %[[STRONG:[0-9a-zA-Z._]+]]
+
+  // CHECK: [[STRONG]]
+  // CHECK-NOT: br
+  // CHECK: cmpxchg {{.*}} release acquire
+  // CHECK: br
+
+  // CHECK: [[WEAK]]
+  // CHECK-NOT: br
+  // CHECK: cmpxchg weak {{.*}} release acquire
+  // CHECK: br
 }
 
 // Having checked the flow in the previous two cases, we'll trust clang to
@@ -576,7 +599,9 @@
   // CHECK: = cmpxchg weak {{.*}} acquire monotonic, align
   // CHECK: = cmpxchg weak {{.*}} acquire acquire, align
   // CHECK: = cmpxchg {{.*}} release monotonic, align
+  // CHECK: = cmpxchg {{.*}} release acquire, align
   // CHECK: = cmpxchg weak {{.*}} release monotonic, align
+  // CHECK: = cmpxchg weak {{.*}} release acquire, align
   // CHECK: = cmpxchg {{.*}} acq_rel monotonic, align
   // CHECK: = cmpxchg {{.*}} acq_rel acquire, align
   // CHECK: = cmpxchg weak {{.*}} acq_rel monotonic, align
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -427,6 +427,8 @@
 else
   switch ((llvm::AtomicOrderingCABI)FOS) {
   case llvm::AtomicOrderingCABI::relaxed:
+  // 31.7.2.18: "The failure argument shall not be memory_order_release
+  // nor memory_order_acq_rel". Fallback to monotonic.
   case llvm::AtomicOrderingCABI::release:
   case llvm::AtomicOrderingCABI::acq_rel:
 FailureOrder = llvm::AtomicOrdering::Monotonic;
@@ -439,12 +441,10 @@
 FailureOrder = llvm::AtomicOrdering::SequentiallyConsistent;
 break;
   }
-if (isStrongerThan(FailureOrder, SuccessOrder)) {
-  // Don't assert on undefined behavior "failure argument shall be no
-  // stronger than the success argument".
-  FailureOrder =
-  

[PATCH] D98995: [CGAtomic] Lift stronger requirements on cmpxch and add support for acquire failure mode

2021-03-23 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 332823.
bruno edited the summary of this revision.
bruno added a comment.

@jfb sure!

Also fix test failures.


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

https://reviews.llvm.org/D98995

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGenOpenCL/atomic-ops.cl
  llvm/docs/LangRef.rst

Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -9768,8 +9768,7 @@
 
 The success and failure :ref:`ordering ` arguments specify how this
 ``cmpxchg`` synchronizes with other atomic operations. Both ordering parameters
-must be at least ``monotonic``, the ordering constraint on failure must be no
-stronger than that on success, and the failure ordering cannot be either
+must be at least ``monotonic``, the failure ordering cannot be either
 ``release`` or ``acq_rel``.
 
 A ``cmpxchg`` instruction can also take an optional
Index: clang/test/CodeGenOpenCL/atomic-ops.cl
===
--- clang/test/CodeGenOpenCL/atomic-ops.cl
+++ clang/test/CodeGenOpenCL/atomic-ops.cl
@@ -227,6 +227,7 @@
 
   // CHECK: [[RELEASE]]
   // CHECK: switch {{.*}}, label %[[RELEASE_MONOTONIC:[0-9a-zA-Z._]+]] [
+  // CHECK-NEXT: i32 2, label %[[RELEASE_ACQUIRE:[0-9a-zA-Z._]+]]
   // CHECK-NEXT: ]
 
   // CHECK: [[ACQREL]]
@@ -254,6 +255,14 @@
   // CHECK: cmpxchg {{.*}} acquire acquire, align 4
   // CHECK: br
 
+  // CHECK: [[RELEASE_MONOTONIC]]
+  // CHECK: cmpxchg {{.*}} release monotonic, align 4
+  // CHECK: br
+
+  // CHECK: [[RELEASE_ACQUIRE]]
+  // CHECK: cmpxchg {{.*}} release acquire, align 4
+  // CHECK: br
+
   // CHECK: [[ACQREL_MONOTONIC]]
   // CHECK: cmpxchg {{.*}} acq_rel monotonic, align 4
   // CHECK: br
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -500,6 +500,7 @@
 
   // CHECK: [[RELEASE]]
   // CHECK: switch {{.*}}, label %[[RELEASE_MONOTONIC:[0-9a-zA-Z._]+]] [
+  // CHECK-NEXT: i32 2, label %[[RELEASE_ACQUIRE:[0-9a-zA-Z._]+]]
   // CHECK-NEXT: ]
 
   // CHECK: [[ACQREL]]
@@ -527,6 +528,14 @@
   // CHECK: cmpxchg {{.*}} acquire acquire, align
   // CHECK: br
 
+  // CHECK: [[RELEASE_MONOTONIC]]
+  // CHECK: cmpxchg {{.*}} release monotonic, align
+  // CHECK: br
+
+  // CHECK: [[RELEASE_ACQUIRE]]
+  // CHECK: cmpxchg {{.*}} release acquire, align
+  // CHECK: br
+
   // CHECK: [[ACQREL_MONOTONIC]]
   // CHECK: cmpxchg {{.*}} acq_rel monotonic, align
   // CHECK: br
@@ -562,6 +571,20 @@
   // CHECK-NOT: br
   // CHECK: cmpxchg weak {{.*}} seq_cst seq_cst, align
   // CHECK: br
+
+  __atomic_compare_exchange_n(ptr, ptr2, 42, weak, memory_order_release, memory_order_acquire);
+  // CHECK: switch i1 {{.*}}, label %[[WEAK:[0-9a-zA-Z._]+]] [
+  // CHECK-NEXT: i1 false, label %[[STRONG:[0-9a-zA-Z._]+]]
+
+  // CHECK: [[STRONG]]
+  // CHECK-NOT: br
+  // CHECK: cmpxchg {{.*}} release acquire
+  // CHECK: br
+
+  // CHECK: [[WEAK]]
+  // CHECK-NOT: br
+  // CHECK: cmpxchg weak {{.*}} release acquire
+  // CHECK: br
 }
 
 // Having checked the flow in the previous two cases, we'll trust clang to
@@ -576,7 +599,9 @@
   // CHECK: = cmpxchg weak {{.*}} acquire monotonic, align
   // CHECK: = cmpxchg weak {{.*}} acquire acquire, align
   // CHECK: = cmpxchg {{.*}} release monotonic, align
+  // CHECK: = cmpxchg {{.*}} release acquire, align
   // CHECK: = cmpxchg weak {{.*}} release monotonic, align
+  // CHECK: = cmpxchg weak {{.*}} release acquire, align
   // CHECK: = cmpxchg {{.*}} acq_rel monotonic, align
   // CHECK: = cmpxchg {{.*}} acq_rel acquire, align
   // CHECK: = cmpxchg weak {{.*}} acq_rel monotonic, align
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -427,6 +427,8 @@
 else
   switch ((llvm::AtomicOrderingCABI)FOS) {
   case llvm::AtomicOrderingCABI::relaxed:
+  // 31.7.2.18: "The failure argument shall not be memory_order_release
+  // nor memory_order_acq_rel". Fallback to monotonic.
   case llvm::AtomicOrderingCABI::release:
   case llvm::AtomicOrderingCABI::acq_rel:
 FailureOrder = llvm::AtomicOrdering::Monotonic;
@@ -439,12 +441,10 @@
 FailureOrder = llvm::AtomicOrdering::SequentiallyConsistent;
 break;
   }
-if (isStrongerThan(FailureOrder, SuccessOrder)) {
-  // Don't assert on undefined behavior "failure argument shall be no
-  // stronger than the success argument".
-  FailureOrder =
-  llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(SuccessOrder);
-}
+// Prior to c++17, "the failure argument shall be no stronger than the
+// success argument". This condition has been lifted and the only
+// 

[PATCH] D99225: [clang] cxx tests: cleanup, update and add some new ones

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a subscriber: lxfind.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reworks a small set of tests, as preparatory work for implementing
P2266 .

- Run for more standard versions, including c++2b.
- Normalize file names and run commands.
- Adds some extra tests.

New Coroutine tests taken from Aaron Puchert's D68845 
.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99225

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
  clang/test/CXX/special/class.copy/p3-cxx11.cpp
  clang/test/CXX/special/class.copy/p33-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/test/SemaCXX/return-stack-addr.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp

Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++20 -verify=cxx20 %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
 // definitions for std::move
 namespace std {
@@ -76,8 +78,8 @@
 Base test2() {
 Derived d2;
 return d2;  // e1
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
 }
 ConstructFromDerived test3() {
@@ -87,22 +89,22 @@
 ConstructFromBase test4() {
 Derived d4;
 return d4;  // e3
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
 }
 ConvertFromDerived test5() {
 Derived d5;
 return d5;  // e4
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
 }
 ConvertFromBase test6() {
 Derived 

[PATCH] D98881: [RISCV] Fix mcount name

2021-03-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/CodeGen/mcount.c:17
+// RUN: %clang_cc1 -pg -triple riscv64 -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32-elf -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-elf -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s

No need to test both `riscv32` and `riscv32-elf`. They are the same - generic 
ELF.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98881

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


[PATCH] D98881: [RISCV] Fix mcount name

2021-03-23 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance updated this revision to Diff 332811.
nathanchance retitled this revision from "[RISCV] Fix mcount name for Linux" to 
"[RISCV] Fix mcount name".
nathanchance edited the summary of this revision.
nathanchance added a comment.
Herald added subscribers: frasercrmck, apazos, jocewei, the_o, brucehoult, 
MartinMosbeck, edward-jones, zzheng, MaskRay, niosHD, sabuasal, johnrusso, rbar.

- Hoist MCountName assignment into RISCVTargetInfo
- Prevent MCountName from getting assigned in FreeBSD and OpenBSD targets
- Add more tests

I did not update Fuchsia or any other operating systems because it appears that 
the only supported configurations from GCC are -elf, -linux, -rtems, and 
-freebsd so I figured it was wise to only influence those. If anyone disagrees, 
let me know and I can update this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98881

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/mcount.c


Index: clang/test/CodeGen/mcount.c
===
--- clang/test/CodeGen/mcount.c
+++ clang/test/CodeGen/mcount.c
@@ -12,6 +12,15 @@
 // RUN: %clang_cc1 -pg -triple mipsel-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple mips64-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple mips64el-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32 -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64 -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32-elf -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-elf -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32-linux -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-linux -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-freebsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-freebsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-openbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple powerpc-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple powerpc64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple powerpc64le-netbsd -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -59,6 +59,7 @@
 WCharType = SignedInt;
 WIntType = UnsignedInt;
 HasRISCVVTypes = true;
+MCountName = "_mcount";
   }
 
   bool setCPU(const std::string ) override {
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -261,6 +261,9 @@
 case llvm::Triple::arm:
   this->MCountName = "__mcount";
   break;
+case llvm::Triple::riscv32:
+case llvm::Triple::riscv64:
+  break;
 }
   }
 };
@@ -491,6 +494,9 @@
 case llvm::Triple::sparcv9:
   this->MCountName = "_mcount";
   break;
+case llvm::Triple::riscv32:
+case llvm::Triple::riscv64:
+  break;
 }
   }
 };


Index: clang/test/CodeGen/mcount.c
===
--- clang/test/CodeGen/mcount.c
+++ clang/test/CodeGen/mcount.c
@@ -12,6 +12,15 @@
 // RUN: %clang_cc1 -pg -triple mipsel-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple mips64-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple mips64el-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32 -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64 -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32-elf -emit-llvm -o - %s | FileCheck 

[PATCH] D99220: [RISCV] Fix mcount name

2021-03-23 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance created this revision.
Herald added subscribers: vkmr, frasercrmck, evandro, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
nathanchance requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

GCC's name for this symbol is _mcount, which the Linux kernel expects in
a few different place:

  $ echo 'int main(void) { return 0; }' | riscv32-linux-gcc -c -pg -o tmp.o -x 
c -
  
  $ llvm-objdump -dr tmp.o | grep mcount
  000c:  R_RISCV_CALL _mcount
  
  $ echo 'int main(void) { return 0; }' | riscv64-linux-gcc -c -pg -o tmp.o -x 
c -
  
  $ llvm-objdump -dr tmp.o | grep mcount
  000c:  R_RISCV_CALL _mcount
  
  $ echo 'int main(void) { return 0; }' | clang -c -pg -o tmp.o 
--target=riscv32-linux-gnu -x c -
  
  $ llvm-objdump -dr tmp.o | grep mcount
  000a:  R_RISCV_CALL_PLT mcount
  
  $ echo 'int main(void) { return 0; }' | clang -c -pg -o tmp.o 
--target=riscv64-linux-gnu -x c -
  
  $ llvm-objdump -dr tmp.o | grep mcount
  000a:  R_RISCV_CALL_PLT mcount

Set MCountName to "_mcount" in RISCVTargetInfo then prevent it from
getting overridden in certain OSTargetInfo constructors.

Signed-off-by: Nathan Chancellor 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99220

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/mcount.c


Index: clang/test/CodeGen/mcount.c
===
--- clang/test/CodeGen/mcount.c
+++ clang/test/CodeGen/mcount.c
@@ -12,6 +12,15 @@
 // RUN: %clang_cc1 -pg -triple mipsel-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple mips64-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple mips64el-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32 -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64 -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32-elf -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-elf -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32-linux -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-linux -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-freebsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-freebsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-openbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple powerpc-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple powerpc64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
 // RUN: %clang_cc1 -pg -triple powerpc64le-netbsd -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -59,6 +59,7 @@
 WCharType = SignedInt;
 WIntType = UnsignedInt;
 HasRISCVVTypes = true;
+MCountName = "_mcount";
   }
 
   bool setCPU(const std::string ) override {
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -261,6 +261,9 @@
 case llvm::Triple::arm:
   this->MCountName = "__mcount";
   break;
+case llvm::Triple::riscv32:
+case llvm::Triple::riscv64:
+  break;
 }
   }
 };
@@ -491,6 +494,9 @@
 case llvm::Triple::sparcv9:
   this->MCountName = "_mcount";
   break;
+case llvm::Triple::riscv32:
+case llvm::Triple::riscv64:
+  break;
 }
   }
 };


Index: clang/test/CodeGen/mcount.c
===
--- clang/test/CodeGen/mcount.c
+++ clang/test/CodeGen/mcount.c
@@ -12,6 +12,15 @@
 // RUN: %clang_cc1 -pg -triple mipsel-unknown-gnu-linux -emit-llvm -o - %s | 

[PATCH] D69218: [ASTMatchers] Add `cxxBaseSpecifier` matcher (non-top-level)

2021-03-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Does anything prevent this going in now?


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

https://reviews.llvm.org/D69218

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


[PATCH] D97831: [Clang][Sema] Implement GCC -Wcast-function-type

2021-03-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8368
+def warn_cast_function_type : Warning<
+  "cast between incompatible function types from %0 to %1">,
+  InGroup, DefaultIgnore;

I'd find something like "cast from function type %0 to incompatible function 
type %1" to be easier to read. But I suppose %0 and %1 are the pointer types, 
not the function types, so perhaps "cast from %0 to %1 converts to incompatible 
function type" or something like that?



Comment at: clang/lib/Sema/SemaCast.cpp:1044-1048
+  // Allow integral type mismatch if their size are equal.
+  if (SrcType->isIntegralType(Context) && DestType->isIntegralType(Context))
+if (Context.getTypeInfoInChars(SrcType).Width ==
+Context.getTypeInfoInChars(DestType).Width)
+  return true;

In addition to allowing the cases where the sizes are the same width, should we 
also allow cases where the promoted types are the same width (eg, `int` versus 
`short`)? What does GCC do?



Comment at: clang/lib/Sema/SemaCast.cpp:1050-1055
+  llvm::DenseSet> NonEquivalentDecls;
+  StructuralEquivalenceContext Ctx(
+  Context, Context, NonEquivalentDecls, StructuralEquivalenceKind::Default,
+  false /*StrictTypeSpelling*/, false /*Complain*/,
+  false /*ErrorOnTagTypeMismatch*/);
+  return Ctx.IsEquivalent(SrcType, DestType);

I think a "same type" check (`Context.hasSameUnqualifiedType(SrcType, 
DestType)`) would be more appropriate here than a structural equivalence check.



Comment at: clang/lib/Sema/SemaCast.cpp:1067-1081
+  if (SrcType->isFunctionPointerType() && DestType->isFunctionPointerType()) {
+SrcFTy = SrcType->castAs()
+ ->getPointeeType()
+ ->castAs();
+DstFTy = DestType->castAs()
+ ->getPointeeType()
+ ->castAs();

This can be simplified a bit.



Comment at: clang/lib/Sema/SemaCast.cpp:1082-1083
+ ->castAs();
+  } else {
+return true;
+  }

We should also handle the case where the source is of function type and the 
destination is a reference-to-function type.

Maybe also block pointer types?



Comment at: clang/lib/Sema/SemaCast.cpp:1090
+  return false;
+if (auto PT = T->getAs())
+  return !PT->isVariadic() && PT->getNumParams() == 0;

Please use `auto *` here (or `const auto *` as the linter suggests).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97831

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


[PATCH] D99193: [PowerPC] Add mprivileged option

2021-03-23 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision as: amyk.
amyk added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99193

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


[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-03-23 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2668
   // ::= g  # __float128
+  // ::= g  # __ibm128
   // UNSUPPORTED:::= Dd # IEEE 754r decimal floating point (64 bits)

jwakely wrote:
> steven.zhang wrote:
> > This is a bit confusing as the 'g' is for both __float128 and __ibm128. I 
> > know that PowerPC will mangle the __float128 as "u9__ieee128", and "g" for 
> > __ibm128. But c++filt demangle the "g" as __float128 which seems not right. 
> The (de)mangling is very confusing, but that's consistent with gcc.
> See comment 3 and 4 at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98389#c3
> 
> I think double-double should never have used `g` it should have been 
> something else (e.g. `u8__ibm128`), and then we could have `g` for the 
> `__ieee128` (aka `__float128`) type. But it is many years too late to change 
> that now.
Yeah, I think that's an unfortunate but ultimately understandable platform 
decision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

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


[clang] c4f65ef - [test] Add --sysroot= to make gcc-toolchain.cpp stable

2021-03-23 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-23T13:32:30-07:00
New Revision: c4f65ef78fd71b4db2dc7bc6646c7e3d2be11746

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

LOG: [test] Add --sysroot= to make gcc-toolchain.cpp stable

Added: 


Modified: 
clang/test/Driver/gcc-toolchain.cpp

Removed: 




diff  --git a/clang/test/Driver/gcc-toolchain.cpp 
b/clang/test/Driver/gcc-toolchain.cpp
index fa256bec2b9a..287aa2cb694d 100644
--- a/clang/test/Driver/gcc-toolchain.cpp
+++ b/clang/test/Driver/gcc-toolchain.cpp
@@ -2,12 +2,12 @@
 //
 /// Without --rtlib=libgcc the driver may pick clang_rt.crtbegin.o if
 /// -DCLANG_DEFAULT_RTLIB=compiler-rt.
-// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 
--target=x86_64-linux-gnu \
+// RUN: %clangxx %s -### --target=x86_64-linux-gnu --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/ubuntu_14.04_multiarch_tree/usr 
-stdlib=libstdc++ --rtlib=libgcc 2>&1 | \
 // RUN:   FileCheck %s
 //
 // Additionally check that the legacy spelling of the flag works.
-// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 
--target=x86_64-linux-gnu \
+// RUN: %clangxx %s -### --target=x86_64-linux-gnu --sysroot= \
 // RUN:   -gcc-toolchain %S/Inputs/ubuntu_14.04_multiarch_tree/usr 
-stdlib=libstdc++ --rtlib=libgcc 2>&1 | \
 // RUN:   FileCheck %s
 //
@@ -29,10 +29,10 @@
 // CHECK-SAME: "-L[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.."
 
 /// Test we don't detect GCC installation under -B.
-// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: %clangxx %s -### --sysroot= 2>&1 \
 // RUN:   --target=aarch64-suse-linux 
--gcc-toolchain=%S/Inputs/opensuse_42.2_aarch64_tree/usr | \
 // RUN:   FileCheck %s --check-prefix=AARCH64
-// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: %clangxx %s -### --sysroot= 2>&1 \
 // RUN:   --target=aarch64-suse-linux 
-B%S/Inputs/opensuse_42.2_aarch64_tree/usr | \
 // RUN:   FileCheck %s --check-prefix=NO_AARCH64
 



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


[PATCH] D99107: [clang][CodeGen] Do not emit NVRO debug helper when not emitting debug info

2021-03-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D99107#2642599 , @nick wrote:

> Is this hack actually needed? I could not reproduce a problem with 
> https://bugs.chromium.org/p/chromium/issues/detail?id=860398#c13 repro, the 
> breakpoint fires for me and I see the variable.
>
> The difference with the hack and without, using `clang.exe src.cpp -S 
> -masm=intel -O2 -g -o out.asm` is

You enabled optimizations, so I wouldn't expect there to be any difference. The 
main purpose of taking the sret pointer and storing it into a local alloca is 
to make it easier to find in unoptimized builds. Otherwise we have this 
variable value living in the first register parameter, and at the time, the 
backend would quickly lose track of it. It's always safer to anchor your 
variable location info in memory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99107

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-03-23 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

What are we gaining from making the intrinsics use vector types if no vector 
operations are supported other than the intrinsics? Why can't we just use an 
xlen integer type?




Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:706
+
+  setOperationAction(ISD::BITCAST, VT, Legal);
+

What about bitcast from float/double to any of these vector types? I'm guess 
that's not legal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99158

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


[PATCH] D98061: [InstrProfiling] Generate runtime hook for ELF platforms

2021-03-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This approach was already used prior to 9a041a75221ca, but we changed it to 
> always generate the llvm_profile_runtime due to a TAPI limitation.

D43794  (rG9a041a75221ca 
) does not 
seem to affect the ELF behavior.

> We can stop passing -u__llvm_profile_runtime to the linker on Linux and 
> Fuchsia since the generated undefined symbol in each translation unit that 
> needed it serves the same purpose.

This restores the behavior before @davidxl's 
rG170cd100ed6f38ec5826dbd1bd6930ddfd3490a4 
 (2015).
While having less code in the clang driver side is pros to me, I don't know 
whether it should come with the cost of conditional presence/absence of the 
.profraw file.
(you can specify LLVM_PROFILE_FILE without %m; -fprofile-profile-generate by 
default does not use %m)

>> There are also going to be binaries in our system build that don't use foo.h 
>> and ideally shouldn't have any overhead since nothing inside them is 
>> instrumented (they should behave as if -fprofile-instr-generate wasn't set 
>> for them at all). That's not the case today because if you set 
>> -fprofile-instr-generate, driver passes -u__llvm_profile_runtime to the 
>> linker which "pulls in" the profile runtime introducing some extra bloat and 
>> startup overhead I described earlier.
>>
>> The overhead is just __llvm_profile_write_file, right? It just writes a 100+ 
>> bytes file which has very little overhead.
>
> It could be more if you use the continuous mode where you'd also need to mmap 
> the profile and do some additional setup.

Can the cost be avoided in the runtime?




Comment at: llvm/test/Instrumentation/InstrProfiling/linkage.ll:13
 ; MACHO: @__llvm_profile_runtime = external global i32
-; ELF-NOT: @__llvm_profile_runtime = external global i32
 

If the symbol is now present, a CHECK line should be kept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98061

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


[PATCH] D99189: [RISCV][Clang] Update new overloading rules for RVV intrinsics.

2021-03-23 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/docs/CommandGuide/tblgen.rst:133
 
-  Generate generic automata.
+  Generate overloaded automata.
 

This looks like an unintended change



Comment at: llvm/docs/CommandGuide/tblgen.rst:279
 
-  Generate generic searchable tables. See :doc:`TableGen BackEnds 
<../TableGen/BackEnds>`
+  Generate overloaded searchable tables. See :doc:`TableGen BackEnds 
<../TableGen/BackEnds>`
   for a detailed description.

Unintended change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99189

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


[PATCH] D99121: [IR][InstCombine] IntToPtr Produces Typeless Pointer To Byte

2021-03-23 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: jyknight.
dblaikie added a comment.

In D99121#2644362 , @lebedev.ri wrote:

> In D99121#2644223 , @nlopes wrote:
>
>> The pointee type in LLVM doesn't really matter. It's even supposed to 
>> disappear one day after the migration is completed.
>> E.g., i8* and i64* are exactly the same thing: they are pointers to data.
>
> Yep. That will be indeed a great to see.
>
>> So, I don't understand the motivation for this patch. It doesn't solve the 
>> root cause of the problem (which one btw?).
>
> It is indeed temporary until Opaque pointers are here.
> The problem has been stated last time in D99051 
>  by @ruiling:
> https://godbolt.org/z/x7E1EjWvv, i.e. given the same integer,
> there can be any number of pointers `inttoptr`'d from it,
> and passes won't be able to tell that they are identical.
>
> @dblaikie @t.p.northover can anyone comment on the Opaque Pointers progress? 
> Is there a checklist somewhere?

no checklist, unfortunately - myself, @t.p.northover, @jyknight, and @arsenm 
have all done bits and pieces of work on it lately.

I think we've got most of the big IR changes (adding explicit types where 
they'll be needed when they're no longer carried on the type of pointer 
parameters) - @arsenm's D98146  is another 
piece in that area, hopefully near the last I think.

After all that's in place, the next step I think would be to introduce the 
typeless pointer, support it as an operand to these various operations - and 
then try producing it as a result of instructions too. But I'm probably missing 
a bunch of important steps we'll find are necessary...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99121

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


[PATCH] D98061: [InstrProfiling] Generate runtime hook for ELF platforms

2021-03-23 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D98061#2623959 , @MaskRay wrote:

> I am a bit concerned that whether the file is generated or not is now 
> dependent on the instrumentation and linker garbage collection.

That's a fair concern, do you know about use cases where this would cause 
issues?

>> There are also going to be binaries in our system build that don't use foo.h 
>> and ideally shouldn't have any overhead since nothing inside them is 
>> instrumented (they should behave as if -fprofile-instr-generate wasn't set 
>> for them at all). That's not the case today because if you set 
>> -fprofile-instr-generate, driver passes -u__llvm_profile_runtime to the 
>> linker which "pulls in" the profile runtime introducing some extra bloat and 
>> startup overhead I described earlier.
>
> The overhead is just `__llvm_profile_write_file`, right? It just writes a 
> 100+ bytes file which has very little overhead.

It could be more if you use the continuous mode where you'd also need to `mmap` 
the profile and do some additional setup.

> Some sanitizers can be used in a link-only manner without instrumentation, 
> e.g. `-fsanitize=leak` does not need instrumentation. The source code just 
> loses `__has_feature(leak_sanitizer)` detection. 
> Link-only `-fsanitize=address` can catch double free and mismatching 
> new/delete.
>
> Do we expect that libclang_rt.profile- can provide other features which may 
> be useful even if there is nothing to instrument according to 
> `-fprofile-list`?

I'm not aware of any such features being planned right now.

> If yes, making the library conditionally not linked can lose such features.
>
> Another case is `ld.lld --thinlto-index-only` always creates `*.imports` and 
> `*.thinlto.bc` files, to convey to the build system that the files are 
> correctly generated.

Since each instrumented binary (that is executable and shared library) 
generates its own profile, how many profiles get generated really depends on 
how many instrumented shared libraries your binary depends on. Furthermore, if 
you use profile merging, you cannot even predict what the profile names are 
going to be, so I assumed that build systems/test runners would need some other 
mechanism to find out what profiles were generated, at least that's the case 
for us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98061

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


[PATCH] D98848: [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.

2021-03-23 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




Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:23
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/TableGen/Error.h"

Drop this now that we're not using Regex


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98848

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


[PATCH] D72566: [clang-tidy] Clang tidy is now alias aware

2021-03-23 Thread Martin G via Phabricator via cfe-commits
MartinG added a comment.

In D72566#1815917 , @aaron.ballman 
wrote:

> I'm not certain I agree. Many of the aliases have different sets of default 
> checking options from the primary check.

And that's precisely the problem. Aliases should be just that: aliases. If two 
checks check for the same thing but have different options, they should be 
merged into one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72566

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


[PATCH] D98061: [InstrProfiling] Generate runtime hook for ELF platforms

2021-03-23 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 332739.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98061

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/test/Driver/coverage-ld.c
  clang/test/Driver/fuchsia.c
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Instrumentation/InstrProfiling/profiling.ll

Index: llvm/test/Instrumentation/InstrProfiling/profiling.ll
===
--- llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ llvm/test/Instrumentation/InstrProfiling/profiling.ll
@@ -1,14 +1,11 @@
 ; RUN: opt < %s -mtriple=x86_64 -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,ELF,ELF_GENERIC
 ; RUN: opt < %s -mtriple=x86_64-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,ELF_LINUX
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,MACHO
-; RUN: opt < %s -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,WIN
+; RUN: opt < %s -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,COFF
 
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s
 
-; ELF_GENERIC: @__llvm_profile_runtime = external global i32
-; ELF_LINUX-NOT: @__llvm_profile_runtime
 ; MACHO: @__llvm_profile_runtime = external global i32
-; WIN: @__llvm_profile_runtime = external global i32
 
 @__profn_foo = hidden constant [3 x i8] c"foo"
 ; CHECK-NOT: __profn_foo
@@ -21,8 +18,8 @@
 ; ELF:   @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_foo = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_foo = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_foo = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_foo = internal {{.*}}, section ".lprfd$M", align 8
 define void @foo() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -32,8 +29,8 @@
 ; ELF:   @__profd_bar = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_bar = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_bar = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_bar = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_bar = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_bar = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_bar = internal {{.*}}, section ".lprfd$M", align 8
 define void @bar() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_bar, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -43,8 +40,8 @@
 ; ELF:   @__profd_baz = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_baz = hidden global [3 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_baz = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_baz = internal global [3 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_baz = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_baz = internal global [3 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_baz = internal {{.*}}, section ".lprfd$M", align 8
 define void @baz() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 0)
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 1)
@@ -54,9 +51,12 @@
 
 declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
 
-; ELF:   @llvm.compiler.used = appending global {{.*}} @__llvm_profile_runtime_user {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz
+; ELF:   @__llvm_profile_runtime = external global i32
+; COFF:  @__llvm_profile_runtime = external global i32
+
+; ELF:   @llvm.compiler.used = appending global {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz {{.*}} @__llvm_profile_runtime
 ; MACHO: @llvm.used = appending global {{.*}} @__llvm_profile_runtime_user {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz
-; WIN:   

[PATCH] D98971: [C++20] [P1825] Fix bugs with implicit-move from variables of reference type

2021-03-23 Thread Arthur O'Dwyer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5f1de9cab1ce: [C++20] [P1825] Fix bugs with implicit-move 
from variables of reference type. (authored by arthur.j.odwyer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98971

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp

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
@@ -292,3 +292,108 @@
   return b; // cxx20-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
 }
 } // namespace test_ctor_param_rvalue_ref
+
+namespace test_lvalue_ref_is_not_moved_from {
+
+struct Target {};
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
+  // cxx11_14_17-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
+  // cxx11_14_17-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
+
+struct CopyOnly {
+  CopyOnly(CopyOnly&&) = delete; // cxx20-note {{has been explicitly marked deleted here}}
+  CopyOnly(CopyOnly&);
+  operator Target() && = delete; // cxx20-note {{has been explicitly marked deleted here}}
+  operator Target() &;
+};
+
+struct MoveOnly {
+  MoveOnly(MoveOnly&&); // expected-note {{copy constructor is implicitly deleted because}}
+// cxx11_14_17-note@-1 {{copy constructor is implicitly deleted because}}
+  operator Target() &&; // expected-note {{candidate function not viable}}
+// cxx11_14_17-note@-1 {{candidate function not viable}}
+};
+
+extern CopyOnly copyonly;
+extern MoveOnly moveonly;
+
+CopyOnly t1() {
+CopyOnly& r = copyonly;
+return r;
+}
+
+CopyOnly t2() {
+CopyOnly&& r = static_cast(copyonly);
+return r; // cxx20-error {{call to deleted constructor}}
+}
+
+MoveOnly t3() {
+MoveOnly& r = moveonly;
+return r; // expected-error {{call to implicitly-deleted copy constructor}}
+}
+
+MoveOnly t4() {
+MoveOnly&& r = static_cast(moveonly);
+return r; // cxx11_14_17-error {{call to implicitly-deleted copy constructor}}
+}
+
+Target t5() {
+CopyOnly& r = copyonly;
+return r;
+}
+
+Target t6() {
+CopyOnly&& r = static_cast(copyonly);
+return r; // cxx20-error {{invokes a deleted function}}
+}
+
+Target t7() {
+MoveOnly& r = moveonly;
+return r; // expected-error {{no viable conversion}}
+}
+
+Target t8() {
+MoveOnly&& r = static_cast(moveonly);
+return r; // cxx11_14_17-error {{no viable conversion}}
+}
+
+} // namespace test_lvalue_ref_is_not_moved_from
+
+namespace test_rvalue_ref_to_nonobject {
+
+struct CopyOnly {};
+struct MoveOnly {};
+
+struct Target {
+Target(CopyOnly (&)());
+Target(CopyOnly (&&)()) = delete;
+Target(MoveOnly (&)()) = delete; // expected-note {{has been explicitly marked deleted here}}
+  // expected-note@-1 {{has been explicitly marked deleted here}}
+Target(MoveOnly (&&)());
+};
+
+CopyOnly make_copyonly();
+MoveOnly make_moveonly();
+
+Target t1() {
+CopyOnly ()() = make_copyonly;
+return r;
+}
+
+Target t2() {
+CopyOnly (&)() = static_cast(make_copyonly);
+return r; // OK in all modes; not subject to implicit move
+}
+
+Target t3() {
+MoveOnly ()() = make_moveonly;
+return r; // expected-error {{invokes a deleted function}}
+}
+
+Target t4() {
+MoveOnly (&)() = static_cast(make_moveonly);
+return r; // expected-error {{invokes a deleted function}}
+}
+
+} // namespace test_rvalue_ref_to_nonobject
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3092,24 +3092,30 @@
   if (VD->hasAttr())
 return false;
 
-  // ...non-volatile...
-  if (VD->getType().isVolatileQualified())
-return false;
-
-  // C++20 [class.copy.elision]p3:
-  // ...rvalue reference to a non-volatile...
-  if (VD->getType()->isRValueReferenceType() &&
-  (!(CESK & CES_AllowRValueReferenceType) ||
-   VD->getType().getNonReferenceType().isVolatileQualified()))
+  if (VDType->isObjectType()) {
+// C++17 [class.copy.elision]p3:
+// ...non-volatile automatic object...
+if (VDType.isVolatileQualified())
+  return false;
+  } else if (VDType->isRValueReferenceType()) {
+// C++20 [class.copy.elision]p3:
+// ...either a non-volatile object or an rvalue reference to a non-volatile object type...
+if (!(CESK & CES_AllowRValueReferenceType))
+  return false;
+QualType VDReferencedType = VDType.getNonReferenceType();
+if 

[clang] 5f1de9c - [C++20] [P1825] Fix bugs with implicit-move from variables of reference type.

2021-03-23 Thread Arthur O'Dwyer via cfe-commits

Author: Arthur O'Dwyer
Date: 2021-03-23T14:12:06-04:00
New Revision: 5f1de9cab1ce2fbb1e45239d3e0e8d4970d2124e

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

LOG: [C++20] [P1825] Fix bugs with implicit-move from variables of reference 
type.

Review D88220 turns out to have some pretty severe bugs, but I *think*
this patch fixes them.

Paper P1825 is supposed to enable implicit move from "non-volatile objects
and rvalue references to non-volatile object types." Instead, what was committed
seems to have enabled implicit move from "non-volatile things of all kinds,
except that if they're rvalue references then they must also refer to 
non-volatile
things." In other words, D88220 accidentally enabled implicit move from
lvalue object references (super yikes!) and also from non-object references
(such as references to functions).

These two cases are now fixed and regression-tested.

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

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp
clang/test/CXX/class/class.init/class.copy.elision/p3.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 4a275e6bd2a1..ceba83bcd814 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3092,24 +3092,30 @@ bool Sema::isCopyElisionCandidate(QualType ReturnType, 
const VarDecl *VD,
   if (VD->hasAttr())
 return false;
 
-  // ...non-volatile...
-  if (VD->getType().isVolatileQualified())
-return false;
-
-  // C++20 [class.copy.elision]p3:
-  // ...rvalue reference to a non-volatile...
-  if (VD->getType()->isRValueReferenceType() &&
-  (!(CESK & CES_AllowRValueReferenceType) ||
-   VD->getType().getNonReferenceType().isVolatileQualified()))
+  if (VDType->isObjectType()) {
+// C++17 [class.copy.elision]p3:
+// ...non-volatile automatic object...
+if (VDType.isVolatileQualified())
+  return false;
+  } else if (VDType->isRValueReferenceType()) {
+// C++20 [class.copy.elision]p3:
+// ...either a non-volatile object or an rvalue reference to a 
non-volatile object type...
+if (!(CESK & CES_AllowRValueReferenceType))
+  return false;
+QualType VDReferencedType = VDType.getNonReferenceType();
+if (VDReferencedType.isVolatileQualified() || 
!VDReferencedType->isObjectType())
+  return false;
+  } else {
 return false;
+  }
 
   if (CESK & CES_AllowDifferentTypes)
 return true;
 
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
-  if (!VD->getType()->isDependentType() && VD->hasAttr() &&
-  Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VD->getType()))
+  if (!VDType->isDependentType() && VD->hasAttr() &&
+  Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 return false;
 
   return true;

diff  --git a/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp 
b/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
index 29d818602537..e4056221b4f3 100644
--- a/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ b/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -292,3 +292,108 @@ NeedValue test_4_3() {
   return b; // cxx20-error {{calling a private constructor of class 
'test_ctor_param_rvalue_ref::B2'}}
 }
 } // namespace test_ctor_param_rvalue_ref
+
+namespace test_lvalue_ref_is_not_moved_from {
+
+struct Target {};
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) 
not viable}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) 
not viable}}
+  // cxx11_14_17-note@-3 {{candidate constructor (the implicit copy 
constructor) not viable}}
+  // cxx11_14_17-note@-4 {{candidate constructor (the implicit move 
constructor) not viable}}
+
+struct CopyOnly {
+  CopyOnly(CopyOnly&&) = delete; // cxx20-note {{has been explicitly marked 
deleted here}}
+  CopyOnly(CopyOnly&);
+  operator Target() && = delete; // cxx20-note {{has been explicitly marked 
deleted here}}
+  operator Target() &;
+};
+
+struct MoveOnly {
+  MoveOnly(MoveOnly&&); // expected-note {{copy constructor is implicitly 
deleted because}}
+// cxx11_14_17-note@-1 {{copy constructor is implicitly deleted because}}
+  operator Target() &&; // expected-note {{candidate function not viable}}
+// cxx11_14_17-note@-1 {{candidate function not viable}}
+};
+
+extern CopyOnly copyonly;
+extern MoveOnly moveonly;
+
+CopyOnly t1() {
+CopyOnly& r = copyonly;
+return r;
+}
+
+CopyOnly t2() {
+CopyOnly&& r = static_cast(copyonly);
+return r; // cxx20-error {{call to deleted constructor}}
+}
+
+MoveOnly t3() {
+MoveOnly& r = moveonly;
+return r; // expected-error {{call to implicitly-deleted copy constructor}}
+}
+

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D71726#2645269 , @tra wrote:

> @jyknight - James, do you have further concerns about the patch?

I separated the change about diagnosing unaligned atomics for amdgpu to 
https://reviews.llvm.org/D99201 since these two changes are orthogonal.


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

https://reviews.llvm.org/D71726

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


[PATCH] D99201: [HIP] Diagnose unaligned atomic for amdgpu

2021-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall, jfb.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, jvesely, 
kzhuravl.
yaxunl requested review of this revision.
Herald added a subscriber: wdng.

https://reviews.llvm.org/D99201

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/hip-options.hip
  clang/test/SemaCUDA/amdgpu-atomic-ops.cu


Index: clang/test/SemaCUDA/amdgpu-atomic-ops.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/amdgpu-atomic-ops.cu
@@ -0,0 +1,26 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 %s -verify -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx906 -fnative-half-type \
+// RUN:   -fnative-half-arguments-and-returns -Werror=atomic-alignment
+
+#include "Inputs/cuda.h"
+#include 
+
+__device__ _Float16 test_Flot16(_Float16 *p) {
+  return __atomic_fetch_sub(p, 1.0f16, memory_order_relaxed);
+}
+
+__device__ __fp16 test_fp16(__fp16 *p) {
+  return __atomic_fetch_sub(p, 1.0f16, memory_order_relaxed);
+}
+
+struct BigStruct {
+  int data[128];
+};
+
+__device__ void test_big(BigStruct *p1, BigStruct *p2) {
+  __atomic_load(p1, p2, memory_order_relaxed);
+  // expected-error@-1 {{misaligned atomic operation may incur significant 
performance penalty; the expected alignment (512 bytes) exceeds the actual 
alignment (4 bytes)}}
+  // expected-error@-2 {{large atomic operation may incur significant 
performance penalty; the access size (512 bytes) exceeds the max lock-free size 
(8  bytes)}}
+}
Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -51,3 +51,15 @@
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=CTA %s
 // CTA: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-mconstructor-aliases"
 // CTA-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-mconstructor-aliases"
+
+// Check -Werror=atomic-alignment is passed for amdpu by default.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 %s 2>&1 | FileCheck -check-prefix=WARN-ATOMIC 
%s
+// WARN-ATOMIC: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-Werror=atomic-alignment"
+// WARN-ATOMIC-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-Werror=atomic-alignment"
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -Wno-error=atomic-alignment %s 2>&1 | 
FileCheck -check-prefix=NO-WARN-ATOMIC %s
+// NO-WARN-ATOMIC-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-Werror=atomic-alignment"
+// NO-WARN-ATOMIC-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-Werror=atomic-alignment"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6447,6 +6447,18 @@
 if (Args.hasFlag(options::OPT_munsafe_fp_atomics,
  options::OPT_mno_unsafe_fp_atomics, /*Default=*/false))
   CmdArgs.push_back("-munsafe-fp-atomics");
+
+// AMDGPU does not support atomic lib call. Treat atomic alignment
+// warnings as errors by default unless it is disabled explicitly.
+bool DiagAtomicLibCall = true;
+for (auto *A : Args.filtered(options::OPT_W_Joined)) {
+  if (StringRef(A->getValue()) == "no-error=atomic-alignment")
+DiagAtomicLibCall = false;
+  if (StringRef(A->getValue()) == "error=atomic-alignment")
+DiagAtomicLibCall = true;
+}
+if (DiagAtomicLibCall)
+  CmdArgs.push_back("-Werror=atomic-alignment");
   }
 
   // For all the host OpenMP offloading compile jobs we need to pass the 
targets


Index: clang/test/SemaCUDA/amdgpu-atomic-ops.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/amdgpu-atomic-ops.cu
@@ -0,0 +1,26 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 %s -verify -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx906 -fnative-half-type \
+// RUN:   -fnative-half-arguments-and-returns -Werror=atomic-alignment
+
+#include "Inputs/cuda.h"
+#include 
+
+__device__ _Float16 test_Flot16(_Float16 *p) {
+  return __atomic_fetch_sub(p, 1.0f16, memory_order_relaxed);
+}
+
+__device__ __fp16 test_fp16(__fp16 *p) {
+  return __atomic_fetch_sub(p, 1.0f16, memory_order_relaxed);
+}
+
+struct BigStruct {
+  int data[128];
+};
+
+__device__ void test_big(BigStruct *p1, BigStruct *p2) {
+  __atomic_load(p1, p2, memory_order_relaxed);
+  // expected-error@-1 {{misaligned atomic operation may incur significant performance penalty; the expected alignment (512 bytes) exceeds the actual alignment (4 bytes)}}
+  // expected-error@-2 {{large 

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 332730.
yaxunl edited the summary of this revision.
yaxunl added a comment.

separate diagnosing unaligned atomc for amdgpu to another review.


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

https://reviews.llvm.org/D71726

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/fp-atomic-ops.c
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/Sema/atomic-ops.c
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify=expected,spir \
+// RUN:   -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \
+// RUN:   -triple=amdgcn-amd-amdhsa
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 typedef __INTPTR_TYPE__ intptr_t;
 typedef int int8 __attribute__((ext_vector_type(8)));
@@ -36,7 +39,7 @@
 
 atomic_int gn;
 void f(atomic_int *i, const atomic_int *ci,
-   atomic_intptr_t *p, atomic_float *d,
+   atomic_intptr_t *p, atomic_float *f, atomic_double *d, atomic_half *h, // expected-error {{unknown type name 'atomic_half'}}
int *I, const int *CI,
intptr_t *P, float *D, struct S *s1, struct S *s2,
global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
@@ -57,37 +60,38 @@
 
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(f, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+  (int)__opencl_atomic_store(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
 
   int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_group);
   int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
 
   __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(f, 1.0f, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_add(d, 1.0, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_and(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_and(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
 
   __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_min(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic 

[PATCH] D99200: [SystemZ][z/OS] JSON file should be text files

2021-03-23 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch sets the OF_Text flag correctly for the json file created in 
Clang::DumpCompilationDatabaseFragmentToDir.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99200

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2336,7 +2336,8 @@
   Twine(llvm::sys::path::filename(Input.getFilename())) + "..json");
   int FD;
   SmallString<256> TempPath;
-  Err = llvm::sys::fs::createUniqueFile(Path, FD, TempPath);
+  Err = llvm::sys::fs::createUniqueFile(Path, FD, TempPath,
+llvm::sys::fs::OF_Text);
   if (Err) {
 Driver.Diag(diag::err_drv_compilationdatabase) << Path << Err.message();
 return;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2336,7 +2336,8 @@
   Twine(llvm::sys::path::filename(Input.getFilename())) + "..json");
   int FD;
   SmallString<256> TempPath;
-  Err = llvm::sys::fs::createUniqueFile(Path, FD, TempPath);
+  Err = llvm::sys::fs::createUniqueFile(Path, FD, TempPath,
+llvm::sys::fs::OF_Text);
   if (Err) {
 Driver.Diag(diag::err_drv_compilationdatabase) << Path << Err.message();
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99199: Make -fcrash-diagnostics-dir control the Windows (mini-)dump location

2021-03-23 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: rnk.
Herald added subscribers: dexonsmith, hiraditya.
probinson requested review of this revision.
Herald added projects: clang, LLVM.

There's no automated test for this, as I don't see any existing tests for 
creating minidumps.  I have tried it locally, and it works fine even when the 
directory name has a space in it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99199

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/crash-diagnostics-dir-2.c
  llvm/lib/Support/Signals.cpp
  llvm/lib/Support/Windows/Signals.inc


Index: llvm/lib/Support/Windows/Signals.inc
===
--- llvm/lib/Support/Windows/Signals.inc
+++ llvm/lib/Support/Windows/Signals.inc
@@ -766,16 +766,18 @@
 if (!GetDumpType(DefaultLocalDumpsKey, DumpType))
   DumpType = MiniDumpNormal;
 
-  // Look to see if a dump location is specified in the registry; first with 
the
+  // Look to see if a dump location is specified on the command line.  If not,
+  // look to see if a dump location is specified in the registry; first with 
the
   // app-specific key and failing that with the global key.  If none are found
   // we'll just create the dump file in the default temporary file location
   // (GetDumpFolder will return false either if the key is NULL or if there is
   // no valid DumpFolder value at its location).
   bool ExplicitDumpDirectorySet = true;
-  SmallString DumpDirectory;
-  if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
-if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
-  ExplicitDumpDirectorySet = false;
+  SmallString DumpDirectory(CrashDiagnosticsDirectory);
+  if (DumpDirectory.empty())
+if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
+  if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
+ExplicitDumpDirectorySet = false;
 
   int FD;
   SmallString DumpPath;
Index: llvm/lib/Support/Signals.cpp
===
--- llvm/lib/Support/Signals.cpp
+++ llvm/lib/Support/Signals.cpp
@@ -43,6 +43,13 @@
 DisableSymbolication("disable-symbolication",
  cl::desc("Disable symbolizing crash backtraces."),
  cl::location(DisableSymbolicationFlag), cl::Hidden);
+#ifdef _WIN32
+static std::string CrashDiagnosticsDirectory;
+static cl::opt
+CrashDiagnosticsDir("crash-diagnostics-dir", cl::value_desc("directory"),
+cl::desc("Directory to use for any crash dump file."),
+cl::location(CrashDiagnosticsDirectory), cl::Hidden);
+#endif
 
 constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
 constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";
Index: clang/test/Driver/crash-diagnostics-dir-2.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir-2.c
@@ -0,0 +1,6 @@
+// REQUIRES: system-windows
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=OPTION
+// OPTION: "-crash-diagnostics-dir=mydumps"
+// RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
+// NOOPTION-NOT: "-crash-diagnostics-dir
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5124,6 +5124,15 @@
   if (D.CCGenDiagnostics)
 CmdArgs.push_back("-disable-pragma-debug-crash");
 
+#ifdef _WIN32
+  // Put (mini-)dumps in the same place as other crash diagnostics files.
+  if (Args.hasArg(options::OPT_fcrash_diagnostics_dir)) {
+StringRef Dir = Args.getLastArgValue(options::OPT_fcrash_diagnostics_dir);
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-crash-diagnostics-dir=" + Dir));
+  }
+#endif
+
   bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,


Index: llvm/lib/Support/Windows/Signals.inc
===
--- llvm/lib/Support/Windows/Signals.inc
+++ llvm/lib/Support/Windows/Signals.inc
@@ -766,16 +766,18 @@
 if (!GetDumpType(DefaultLocalDumpsKey, DumpType))
   DumpType = MiniDumpNormal;
 
-  // Look to see if a dump location is specified in the registry; first with the
+  // Look to see if a dump location is specified on the command line.  If not,
+  // look to see if a dump location is specified in the registry; first with the
   // app-specific key and failing that with the global key.  If none are found
   // we'll just create the dump file in the default temporary file location
   // (GetDumpFolder will return false either if the key is NULL or if there is
   // no valid DumpFolder value at its location).
   bool ExplicitDumpDirectorySet = true;

[PATCH] D98873: Document -fcrash-diagnostics-dir

2021-03-23 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe150be612bf7: Document -fcrash-diagnostics-dir (authored by 
probinson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98873

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1279,7 +1279,9 @@
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
-def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused, CoreOption]>;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
+  Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Put crash-report files in ">, MetaVarName<"">;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 defm cxx_exceptions: BoolFOption<"cxx-exceptions",
   LangOpts<"CXXExceptions">, DefaultFalse,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -674,6 +674,11 @@
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+.. option:: -fcrash-diagnostics-dir=
+
+  Specify where to write the crash diagnostics files; defaults to the
+  usual location for temporary files.
+
 Clang is also capable of generating preprocessed source file(s) and associated
 run script(s) even without a crash. This is specially useful when trying to
 generate a reproducer for warnings or errors while using modules.
@@ -3629,6 +3634,8 @@
   -fcomplete-member-pointers
   Require member pointer base types to be complete 
if they would be significant under the Microsoft ABI
   -fcoverage-mapping  Generate coverage mapping to enable code 
coverage analysis
+  -fcrash-diagnostics-dir=
+  Put crash-report files in 
   -fdebug-macro   Emit macro debug information
   -fdelayed-template-parsing
   Parse templated function definitions at the end 
of the translation unit


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1279,7 +1279,9 @@
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, Group, Flags<[NoArgumentUnused, CoreOption]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script for reproduction during a clang crash">;
-def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, Group, Flags<[NoArgumentUnused, CoreOption]>;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
+  Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Put crash-report files in ">, MetaVarName<"">;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 defm cxx_exceptions: BoolFOption<"cxx-exceptions",
   LangOpts<"CXXExceptions">, DefaultFalse,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -674,6 +674,11 @@
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+.. option:: -fcrash-diagnostics-dir=
+
+  Specify where to write the crash diagnostics files; defaults to the
+  usual location for temporary files.
+
 Clang is also capable of generating preprocessed source file(s) and associated
 run script(s) even without a crash. This is specially useful when trying to
 generate a reproducer for warnings or errors while using modules.
@@ -3629,6 +3634,8 @@
   -fcomplete-member-pointers
   Require member pointer base types to be complete if they would be significant under the Microsoft ABI
   -fcoverage-mapping  Generate coverage mapping to enable code coverage analysis
+  -fcrash-diagnostics-dir=
+  Put crash-report files in 
   -fdebug-macro   Emit macro debug information
   -fdelayed-template-parsing
   Parse templated function definitions at the end of the translation unit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e150be6 - Document -fcrash-diagnostics-dir

2021-03-23 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2021-03-23T10:47:12-07:00
New Revision: e150be612bf79b75ce5b04136f18a7a1142aa423

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

LOG: Document -fcrash-diagnostics-dir

This was added in LLVM 7.0 but without help text or other docs.

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

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 28de4e3aac6f..7709556fbace 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -674,6 +674,11 @@ control the crash diagnostics.
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+.. option:: -fcrash-diagnostics-dir=
+
+  Specify where to write the crash diagnostics files; defaults to the
+  usual location for temporary files.
+
 Clang is also capable of generating preprocessed source file(s) and associated
 run script(s) even without a crash. This is specially useful when trying to
 generate a reproducer for warnings or errors while using modules.
@@ -3629,6 +3634,8 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   -fcomplete-member-pointers
   Require member pointer base types to be complete 
if they would be significant under the Microsoft ABI
   -fcoverage-mapping  Generate coverage mapping to enable code 
coverage analysis
+  -fcrash-diagnostics-dir=
+  Put crash-report files in 
   -fdebug-macro   Emit macro debug information
   -fdelayed-template-parsing
   Parse templated function definitions at the end 
of the translation unit

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 25de15f48495..975ab3a93379 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1279,7 +1279,9 @@ def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
-def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused, CoreOption]>;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
+  Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Put crash-report files in ">, MetaVarName<"">;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 defm cxx_exceptions: BoolFOption<"cxx-exceptions",
   LangOpts<"CXXExceptions">, DefaultFalse,



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


[PATCH] D97831: [Clang][Sema] Implement GCC -Wcast-function-type

2021-03-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97831

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


[PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-23 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 332720.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.

After going through all the function usages, I realized FileSize is not used 
anywhere. I can remove this parameter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99182

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/InputFiles.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/unittests/TestingSupport/TestUtilities.cpp
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/BinaryFormat/Magic.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
  llvm/lib/FuzzMutate/FuzzerCLI.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Object/Binary.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cov/gcov.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-pdbutil/InputFile.cpp
  llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/obj2yaml/obj2yaml.cpp
  llvm/tools/sanstats/sanstats.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,7 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +843,7 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/tools/sanstats/sanstats.cpp
===
--- llvm/tools/sanstats/sanstats.cpp
+++ llvm/tools/sanstats/sanstats.cpp
@@ -125,8 +125,8 @@
   cl::ParseCommandLineOptions(argc, argv,
   "Sanitizer Statistics Processing Tool");
 
-  ErrorOr> MBOrErr =
-  MemoryBuffer::getFile(ClInputFile, -1, false);
+  ErrorOr> MBOrErr = MemoryBuffer::getFile(
+  ClInputFile, /*IsText=*/false, /*RequiresNullTerminator=*/false);
   if (!MBOrErr) {
 errs() << argv[0] << ": " << ClInputFile << ": "
<< MBOrErr.getError().message() << '\n';
Index: llvm/tools/obj2yaml/obj2yaml.cpp
===
--- llvm/tools/obj2yaml/obj2yaml.cpp
+++ llvm/tools/obj2yaml/obj2yaml.cpp
@@ -36,7 +36,7 @@
 
 static Error dumpInput(StringRef File) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return errorCodeToError(EC);
Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -653,7 +653,7 @@
 /// Opens \a File and dumps it.
 static void dumpInput(StringRef File, ScopedPrinter ) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(errorCodeToError(EC), File);
Index: llvm/tools/llvm-rc/ResourceFileWriter.cpp
===
--- llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1524,14 +1524,16 @@
   // properly though, so if using that to append paths below, this early
   // exception case could be removed.)
   if (sys::path::has_root_directory(File))
-return 

[PATCH] D99185: [PowerPC] Change option to mrop-protect

2021-03-23 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision as: amyk.
amyk added a comment.

This also LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99185

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


[PATCH] D99193: [PowerPC] Add mprivileged option

2021-03-23 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision.
lei 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/D99193/new/

https://reviews.llvm.org/D99193

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-03-23 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

@jyknight - James, do you have further concerns about the patch?




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6454
+bool DiagAtomicLibCall = true;
+for (auto *A : Args.filtered(options::OPT_W_Joined)) {
+  if (StringRef(A->getValue()) == "no-error=atomic-alignment")

If we rely on promoting the warnings to errors for correctness, I think we may 
need a more robust mechanism to enforce that than trying to guess the state 
based on provided options.
E.g. can these diagnostics be enabled/disabled with a wider scope option like 
`-W[no-]extra` or `-W[no-]all`?

Maybe we should add a cc1-only option `--enforce-atomic-alignment` and use that 
to determine if misalignment should be an error at the point where we issue the 
diagnostics?




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6457
+DiagAtomicLibCall = false;
+  if (StringRef(A->getValue()) == "error=atomic-alignment")
+DiagAtomicLibCall = true;

This should be `else if`, or,  maybe use `llvm::StringSwitch()`instead:
```
DiagAtomicLibCall = llvm::StringSwitch(A->getValue())
   .Case("no-error=atomic-alignment", false)
   .Case("error=atomic-alignment", true)
   .Default(DiagAtomicLibCall)
```


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

https://reviews.llvm.org/D71726

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


[PATCH] D99185: [PowerPC] Change option to mrop-protect

2021-03-23 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision as: lei.
lei 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/D99185/new/

https://reviews.llvm.org/D99185

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


[PATCH] D98793: [SystemZ][z/OS] fix lit test related to alignment

2021-03-23 Thread Muiez Ahmed via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf46c41febb88: [SystemZ][z/OS] fix lit test related to 
alignment (authored by NancyWang, committed by muiez).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98793

Files:
  clang/test/AST/alignas_maybe_odr_cleanup.cpp
  clang/test/CodeGen/PR5060-align.c
  clang/test/Layout/itanium-union-bitfield.cpp


Index: clang/test/Layout/itanium-union-bitfield.cpp
===
--- clang/test/Layout/itanium-union-bitfield.cpp
+++ clang/test/Layout/itanium-union-bitfield.cpp
@@ -1,15 +1,23 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple 
-fdump-record-layouts %s 2>/dev/null \
 // RUN:| FileCheck %s
 
+// On z/OS, a bit-field has single byte alignment.  Add aligned(4) on z/OS so 
the union has
+// the same size & alignment as expected.
+#ifdef __MVS__
+#define ALIGN4 __attribute__((aligned(4)))
+#else
+#define ALIGN4
+#endif
+
 union A {
-  int f1: 3;
+  int f1 : 3 ALIGN4;
   A();
 };
 
 A::A() {}
 
 union B {
-  char f1: 35;
+  char f1 : 35 ALIGN4;
   B();
 };
 
Index: clang/test/CodeGen/PR5060-align.c
===
--- clang/test/CodeGen/PR5060-align.c
+++ clang/test/CodeGen/PR5060-align.c
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 
-// CHECK: @foo.p = internal global i8 0, align 32
+// CHECK: @foo.p = internal global i8 0, align 16
 char *foo(void) {
-  static char p __attribute__((aligned(32)));
+  static char p __attribute__((aligned(16)));
   return 
 }
 
 void bar(long n) {
-  // CHECK: align 32
-  char p[n] __attribute__((aligned(32)));
+  // CHECK: align 16
+  char p[n] __attribute__((aligned(16)));
 }
 
Index: clang/test/AST/alignas_maybe_odr_cleanup.cpp
===
--- clang/test/AST/alignas_maybe_odr_cleanup.cpp
+++ clang/test/AST/alignas_maybe_odr_cleanup.cpp
@@ -8,7 +8,7 @@
 // RUN: | FileCheck %s
 
 struct FOO {
-  static const int vec_align_bytes = 32;
+  static const int vec_align_bytes = 16;
   void foo() {
 double a alignas(vec_align_bytes);
 ;
@@ -17,7 +17,7 @@
 
 // CHECK:  |   `-AlignedAttr {{.*}}  alignas
 // CHECK-NEXT:  | `-ConstantExpr {{.*}}  'int'
-// CHECK-NEXT:  |   |-value: Int 32
+// CHECK-NEXT:  |   |-value: Int 16
 // CHECK-NEXT:  |   `-ImplicitCastExpr {{.*}}  'int' 

 // CHECK-NEXT:  | `-DeclRefExpr {{.*}}  'const int' lvalue 
Var {{.*}} 'vec_align_bytes' 'const int' non_odr_use_constant
 // CHECK-NEXT:  `-NullStmt {{.*}} 


Index: clang/test/Layout/itanium-union-bitfield.cpp
===
--- clang/test/Layout/itanium-union-bitfield.cpp
+++ clang/test/Layout/itanium-union-bitfield.cpp
@@ -1,15 +1,23 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple -fdump-record-layouts %s 2>/dev/null \
 // RUN:| FileCheck %s
 
+// On z/OS, a bit-field has single byte alignment.  Add aligned(4) on z/OS so the union has
+// the same size & alignment as expected.
+#ifdef __MVS__
+#define ALIGN4 __attribute__((aligned(4)))
+#else
+#define ALIGN4
+#endif
+
 union A {
-  int f1: 3;
+  int f1 : 3 ALIGN4;
   A();
 };
 
 A::A() {}
 
 union B {
-  char f1: 35;
+  char f1 : 35 ALIGN4;
   B();
 };
 
Index: clang/test/CodeGen/PR5060-align.c
===
--- clang/test/CodeGen/PR5060-align.c
+++ clang/test/CodeGen/PR5060-align.c
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 
-// CHECK: @foo.p = internal global i8 0, align 32
+// CHECK: @foo.p = internal global i8 0, align 16
 char *foo(void) {
-  static char p __attribute__((aligned(32)));
+  static char p __attribute__((aligned(16)));
   return 
 }
 
 void bar(long n) {
-  // CHECK: align 32
-  char p[n] __attribute__((aligned(32)));
+  // CHECK: align 16
+  char p[n] __attribute__((aligned(16)));
 }
 
Index: clang/test/AST/alignas_maybe_odr_cleanup.cpp
===
--- clang/test/AST/alignas_maybe_odr_cleanup.cpp
+++ clang/test/AST/alignas_maybe_odr_cleanup.cpp
@@ -8,7 +8,7 @@
 // RUN: | FileCheck %s
 
 struct FOO {
-  static const int vec_align_bytes = 32;
+  static const int vec_align_bytes = 16;
   void foo() {
 double a alignas(vec_align_bytes);
 ;
@@ -17,7 +17,7 @@
 
 // CHECK:  |   `-AlignedAttr {{.*}}  alignas
 // CHECK-NEXT:  | `-ConstantExpr {{.*}}  'int'
-// CHECK-NEXT:  |   |-value: Int 32
+// CHECK-NEXT:  |   |-value: Int 16
 // CHECK-NEXT:  |   `-ImplicitCastExpr {{.*}}  'int' 
 // CHECK-NEXT:  | `-DeclRefExpr {{.*}}  'const int' lvalue Var {{.*}} 

[clang] f46c41f - [SystemZ][z/OS] fix lit test related to alignment

2021-03-23 Thread Muiez Ahmed via cfe-commits

Author: Nancy Wang
Date: 2021-03-23T13:15:19-04:00
New Revision: f46c41febb88182f172d0260b55bd17e4c690a43

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

LOG: [SystemZ][z/OS] fix lit test related to alignment

This patch is to fix lit test case failure relate to alignment, on z/OS, 
maximum alignment value for 64 bit mode is 16 and also fixed 
clang/test/Layout/itanium-union-bitfield.cpp, attribute ((aligned(4))) is 
needed for bit-field member in Union for z/OS because single bit-field has one 
byte alignment, this will make sure size and alignment will be correct value on 
z/OS.

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

Added: 


Modified: 
clang/test/AST/alignas_maybe_odr_cleanup.cpp
clang/test/CodeGen/PR5060-align.c
clang/test/Layout/itanium-union-bitfield.cpp

Removed: 




diff  --git a/clang/test/AST/alignas_maybe_odr_cleanup.cpp 
b/clang/test/AST/alignas_maybe_odr_cleanup.cpp
index 3adef4cba1440..ed34930e98a05 100644
--- a/clang/test/AST/alignas_maybe_odr_cleanup.cpp
+++ b/clang/test/AST/alignas_maybe_odr_cleanup.cpp
@@ -8,7 +8,7 @@
 // RUN: | FileCheck %s
 
 struct FOO {
-  static const int vec_align_bytes = 32;
+  static const int vec_align_bytes = 16;
   void foo() {
 double a alignas(vec_align_bytes);
 ;
@@ -17,7 +17,7 @@ struct FOO {
 
 // CHECK:  |   `-AlignedAttr {{.*}}  alignas
 // CHECK-NEXT:  | `-ConstantExpr {{.*}}  'int'
-// CHECK-NEXT:  |   |-value: Int 32
+// CHECK-NEXT:  |   |-value: Int 16
 // CHECK-NEXT:  |   `-ImplicitCastExpr {{.*}}  'int' 

 // CHECK-NEXT:  | `-DeclRefExpr {{.*}}  'const int' lvalue 
Var {{.*}} 'vec_align_bytes' 'const int' non_odr_use_constant
 // CHECK-NEXT:  `-NullStmt {{.*}} 

diff  --git a/clang/test/CodeGen/PR5060-align.c 
b/clang/test/CodeGen/PR5060-align.c
index 34293a933aa9e..6e65175a71155 100644
--- a/clang/test/CodeGen/PR5060-align.c
+++ b/clang/test/CodeGen/PR5060-align.c
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 
-// CHECK: @foo.p = internal global i8 0, align 32
+// CHECK: @foo.p = internal global i8 0, align 16
 char *foo(void) {
-  static char p __attribute__((aligned(32)));
+  static char p __attribute__((aligned(16)));
   return 
 }
 
 void bar(long n) {
-  // CHECK: align 32
-  char p[n] __attribute__((aligned(32)));
+  // CHECK: align 16
+  char p[n] __attribute__((aligned(16)));
 }
 

diff  --git a/clang/test/Layout/itanium-union-bitfield.cpp 
b/clang/test/Layout/itanium-union-bitfield.cpp
index 961bf5b6f3b44..febfc46dfee54 100644
--- a/clang/test/Layout/itanium-union-bitfield.cpp
+++ b/clang/test/Layout/itanium-union-bitfield.cpp
@@ -1,15 +1,23 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple 
-fdump-record-layouts %s 2>/dev/null \
 // RUN:| FileCheck %s
 
+// On z/OS, a bit-field has single byte alignment.  Add aligned(4) on z/OS so 
the union has
+// the same size & alignment as expected.
+#ifdef __MVS__
+#define ALIGN4 __attribute__((aligned(4)))
+#else
+#define ALIGN4
+#endif
+
 union A {
-  int f1: 3;
+  int f1 : 3 ALIGN4;
   A();
 };
 
 A::A() {}
 
 union B {
-  char f1: 35;
+  char f1 : 35 ALIGN4;
   B();
 };
 



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


[PATCH] D99188: [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.

2021-03-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik 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/D99188/new/

https://reviews.llvm.org/D99188

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


[PATCH] D98873: Document -fcrash-diagnostics-dir

2021-03-23 Thread Matthew Voss via Phabricator via cfe-commits
ormris accepted this revision.
ormris 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/D98873/new/

https://reviews.llvm.org/D98873

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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-03-23 Thread Jake Harr via Phabricator via cfe-commits
jakar added a comment.

@catskul can you share your changes somehow? If you did, sorry, I'm new to 
Phabricator.

Before I saw @catskul's comment, I rebased @stringham's diff and got the 
existing unit tests to work. But after some experimentation, I found that it 
didn't always behave like I expected. It would sometimes do things like this:

  someFunction(anotherLongFunctionName(arg1, arg2, "this is a description")
  );
  
  void SomeClass::someMemberFunction(const std::string& whatever, int blah
  ) const {
  }

I think it should only break before closing when the matching opening was 
followed by a new line (with possible whitespace or comment).

And it also didn't handle brace-initialized vars consistently:

  LongClassName longVarName1(
somethingElseThatIsLong(arg1, arg2, arg3, arg4),
anotherLongVarName
  );
  
  LongClassName longVarName2{
somethingElseThatIsLong(arg1, arg2, arg3, arg4),
anotherLongVarName};

So I think there is still a bit of work here to be done. And unit tests could 
definitely help.

I can take my best stab at this, when I get time, but I'm honestly not familiar 
with any of it. Any suggestions would be great. Please let me know how I can 
help.

Anyhow, I'm excited about this feature, mostly because I find it more readable, 
but also because it allows consistency with other languages, like Python (see 
PEP8):

  my_list = [
  1, 2, 3,
  4, 5, 6,
  ]
  result = some_function_that_takes_arguments(
  'a', 'b', 'c',
  'd', 'e', 'f',
  )


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

https://reviews.llvm.org/D33029

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


[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 332703.
arnamoy10 added a comment.

1. Leaning out the "wrong-option" test case
2. Adding aliases in f18 (`-pedantic` and `-std=2018` for `-Mstandard`)


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

https://reviews.llvm.org/D97119

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/std2018.f90
  flang/test/Driver/std2018_wrong.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -487,7 +487,8 @@
   options.features.Enable(
   Fortran::common::LanguageFeature::BackslashEscapes, true);
 } else if (arg == "-Mstandard" || arg == "-std=f95" ||
-arg == "-std=f2003" || arg == "-std=f2008" || arg == "-std=legacy") {
+arg == "-std=f2003" || arg == "-std=f2008" || arg == "-std=legacy" ||
+arg == "-std=f2018" || arg == "-pedantic") {
   driver.warnOnNonstandardUsage = true;
 } else if (arg == "-fopenacc") {
   options.features.Enable(Fortran::common::LanguageFeature::OpenACC);
Index: flang/test/Driver/std2018_wrong.f90
===
--- /dev/null
+++ flang/test/Driver/std2018_wrong.f90
@@ -0,0 +1,12 @@
+! REQUIRES: new-flang-driver
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! EXPECTED OUTPUT WITH WRONG
+!-
+! WRONG: Only -std=f2018 is allowed currently.
Index: flang/test/Driver/std2018.f90
===
--- /dev/null
+++ flang/test/Driver/std2018.f90
@@ -0,0 +1,28 @@
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: A DO loop should terminate with an END DO or CONTINUE
+
+subroutine foo2()
+do 01 m=1,2
+  select case (m)
+  case default
+print*, "default", m
+  case (1)
+print*, "start"
+01end select
+end subroutine
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -45,6 +45,8 @@
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -o   Write output to 
+! HELP-NEXT: -pedantic  Warn on language extensions
+! HELP-NEXT: -std=   Language standard to compile for
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
@@ -92,6 +94,8 @@
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -pedantic  Warn on language extensions
+! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -45,6 +45,8 @@
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -o  Write output to 
+! CHECK-NEXT: -pedantic  Warn on language extensions
+! CHECK-NEXT: -std=   Language standard to compile for
 ! CHECK-NEXT: -U  Undefine macro 
 ! 

[clang] 8298899 - [ASTMatchers][NFC] Use SmallVector when building variadic matcher descriptor

2021-03-23 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-23T16:38:45Z
New Revision: 8298899e56cdf89c68215853010352c45398ab10

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

LOG: [ASTMatchers][NFC] Use SmallVector when building variadic matcher 
descriptor

Saves having to manually deallocate storage and keeps InnerArgs will have good 
cache locality.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/ASTMatchers/Dynamic/Marshallers.h

Removed: 




diff  --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h 
b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
index 3ffa0d6af217..783fb203c408 100644
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -492,9 +492,11 @@ template  Args, Diagnostics *Error) {
-  ArgT **InnerArgs = new ArgT *[Args.size()]();
+  SmallVector InnerArgsPtr;
+  InnerArgsPtr.resize_for_overwrite(Args.size());
+  SmallVector InnerArgs;
+  InnerArgs.reserve(Args.size());
 
-  bool HasError = false;
   for (size_t i = 0, e = Args.size(); i != e; ++i) {
 using ArgTraits = ArgTypeTraits;
 
@@ -503,8 +505,7 @@ variadicMatcherDescriptor(StringRef MatcherName, 
SourceRange NameRange,
 if (!ArgTraits::hasCorrectType(Value)) {
   Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
   << (i + 1) << ArgTraits::getKind().asString() << 
Value.getTypeAsString();
-  HasError = true;
-  break;
+  return {};
 }
 if (!ArgTraits::hasCorrectValue(Value)) {
   if (llvm::Optional BestGuess =
@@ -521,24 +522,12 @@ variadicMatcherDescriptor(StringRef MatcherName, 
SourceRange NameRange,
 << (i + 1) << ArgTraits::getKind().asString()
 << Value.getTypeAsString();
   }
-  HasError = true;
-  break;
+  return {};
 }
-
-InnerArgs[i] = new ArgT(ArgTraits::get(Value));
-  }
-
-  VariantMatcher Out;
-  if (!HasError) {
-Out = outvalueToVariantMatcher(Func(llvm::makeArrayRef(InnerArgs,
-   Args.size(;
+InnerArgs.set_size(i + 1);
+InnerArgsPtr[i] = new ([i]) ArgT(ArgTraits::get(Value));
   }
-
-  for (size_t i = 0, e = Args.size(); i != e; ++i) {
-delete InnerArgs[i];
-  }
-  delete[] InnerArgs;
-  return Out;
+  return outvalueToVariantMatcher(Func(InnerArgsPtr));
 }
 
 /// Matcher descriptor for variadic functions.



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


[PATCH] D99106: [ASTMatchers][NFC] Use SmallVector when building variadic matcher descriptor

2021-03-23 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8298899e56cd: [ASTMatchers][NFC] Use SmallVector when 
building variadic matcher descriptor (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99106

Files:
  clang/lib/ASTMatchers/Dynamic/Marshallers.h


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -492,9 +492,11 @@
 VariantMatcher
 variadicMatcherDescriptor(StringRef MatcherName, SourceRange NameRange,
   ArrayRef Args, Diagnostics *Error) {
-  ArgT **InnerArgs = new ArgT *[Args.size()]();
+  SmallVector InnerArgsPtr;
+  InnerArgsPtr.resize_for_overwrite(Args.size());
+  SmallVector InnerArgs;
+  InnerArgs.reserve(Args.size());
 
-  bool HasError = false;
   for (size_t i = 0, e = Args.size(); i != e; ++i) {
 using ArgTraits = ArgTypeTraits;
 
@@ -503,8 +505,7 @@
 if (!ArgTraits::hasCorrectType(Value)) {
   Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
   << (i + 1) << ArgTraits::getKind().asString() << 
Value.getTypeAsString();
-  HasError = true;
-  break;
+  return {};
 }
 if (!ArgTraits::hasCorrectValue(Value)) {
   if (llvm::Optional BestGuess =
@@ -521,24 +522,12 @@
 << (i + 1) << ArgTraits::getKind().asString()
 << Value.getTypeAsString();
   }
-  HasError = true;
-  break;
+  return {};
 }
-
-InnerArgs[i] = new ArgT(ArgTraits::get(Value));
-  }
-
-  VariantMatcher Out;
-  if (!HasError) {
-Out = outvalueToVariantMatcher(Func(llvm::makeArrayRef(InnerArgs,
-   Args.size(;
+InnerArgs.set_size(i + 1);
+InnerArgsPtr[i] = new ([i]) ArgT(ArgTraits::get(Value));
   }
-
-  for (size_t i = 0, e = Args.size(); i != e; ++i) {
-delete InnerArgs[i];
-  }
-  delete[] InnerArgs;
-  return Out;
+  return outvalueToVariantMatcher(Func(InnerArgsPtr));
 }
 
 /// Matcher descriptor for variadic functions.


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -492,9 +492,11 @@
 VariantMatcher
 variadicMatcherDescriptor(StringRef MatcherName, SourceRange NameRange,
   ArrayRef Args, Diagnostics *Error) {
-  ArgT **InnerArgs = new ArgT *[Args.size()]();
+  SmallVector InnerArgsPtr;
+  InnerArgsPtr.resize_for_overwrite(Args.size());
+  SmallVector InnerArgs;
+  InnerArgs.reserve(Args.size());
 
-  bool HasError = false;
   for (size_t i = 0, e = Args.size(); i != e; ++i) {
 using ArgTraits = ArgTypeTraits;
 
@@ -503,8 +505,7 @@
 if (!ArgTraits::hasCorrectType(Value)) {
   Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
   << (i + 1) << ArgTraits::getKind().asString() << Value.getTypeAsString();
-  HasError = true;
-  break;
+  return {};
 }
 if (!ArgTraits::hasCorrectValue(Value)) {
   if (llvm::Optional BestGuess =
@@ -521,24 +522,12 @@
 << (i + 1) << ArgTraits::getKind().asString()
 << Value.getTypeAsString();
   }
-  HasError = true;
-  break;
+  return {};
 }
-
-InnerArgs[i] = new ArgT(ArgTraits::get(Value));
-  }
-
-  VariantMatcher Out;
-  if (!HasError) {
-Out = outvalueToVariantMatcher(Func(llvm::makeArrayRef(InnerArgs,
-   Args.size(;
+InnerArgs.set_size(i + 1);
+InnerArgsPtr[i] = new ([i]) ArgT(ArgTraits::get(Value));
   }
-
-  for (size_t i = 0, e = Args.size(); i != e; ++i) {
-delete InnerArgs[i];
-  }
-  delete[] InnerArgs;
-  return Out;
+  return outvalueToVariantMatcher(Func(InnerArgsPtr));
 }
 
 /// Matcher descriptor for variadic functions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98712: [Utils] Support lit-like substitutions in update_cc_test_checks

2021-03-23 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added inline comments.



Comment at: llvm/utils/update_cc_test_checks.py:228
+  '%t' : tempfile.NamedTemporaryFile().name,
+  '%S' : os.getcwd(),
+}

arichardson wrote:
> Shouldn't this be the directory containing the test? 
You are right, I will submit a patch soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98712

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd4abc5242c0: [flang][driver] Add -fintrinsic-modules-path 
option (authored by Arnamoy Bhattacharyya 
arnamoy.bhattachar...@huawei.com, committed by arnamoy10).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,37 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+! REQUIRES: new-flang-driver
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -83,6 +85,8 @@
 ! HELP-FC1-NEXT: -fget-symbols-sources   Dump symbols and their source code locations
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! 

[clang] cd4abc5 - [flang][driver] Add -fintrinsic-modules-path option

2021-03-23 Thread Arnamoy Bhattacharyya via cfe-commits

Author: Arnamoy Bhattacharyya
Date: 2021-03-23T12:28:19-04:00
New Revision: cd4abc5242c03804b3d88277b03b52215a899f75

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

LOG: [flang][driver] Add -fintrinsic-modules-path option

Reviewed By: awarzynski

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

Added: 
flang/test/Driver/Inputs/ieee_arithmetic.mod
flang/test/Driver/Inputs/iso_fortran_env.mod
flang/test/Driver/intrinsic_module_path.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/PreprocessorOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2e9d0f53f9a31..25de15f484952 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4256,7 +4256,6 @@ defm f2c : BooleanFFlag<"f2c">, Group;
 defm frontend_optimize : BooleanFFlag<"frontend-optimize">, 
Group;
 defm init_local_zero : BooleanFFlag<"init-local-zero">, Group;
 defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, 
Group;
-defm intrinsic_modules_path : BooleanFFlag<"intrinsic-modules-path">, 
Group;
 defm max_identifier_length : BooleanFFlag<"max-identifier-length">, 
Group;
 defm module_private : BooleanFFlag<"module-private">, Group;
 defm pack_derived : BooleanFFlag<"pack-derived">, Group;
@@ -4338,6 +4337,10 @@ def fimplicit_none : Flag<["-"], "fimplicit-none">, 
Group,
 def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group;
 def falternative_parameter_statement : Flag<["-"], 
"falternative-parameter-statement">, Group,
   HelpText<"Enable the old style PARAMETER statement">;
+def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">,  
Group, MetaVarName<"">,
+  HelpText<"Specify where to find the compiled intrinsic modules">,
+  DocBrief<[{This option specifies the location of pre-compiled intrinsic 
modules, 
+  if they are not in the default location expected by the compiler.}]>;
 }
 
 def J : JoinedOrSeparate<["-"], "J">,

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 153a1dfc85927..1fa62030b1134 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,7 +42,8 @@ void Flang::AddPreprocessingOptions(const ArgList ,
 
 void Flang::AddOtherOptions(const ArgList , ArgStringList ) const 
{
   Args.AddAllArgs(CmdArgs,
-  {options::OPT_module_dir, 
options::OPT_fdebug_module_writer});
+  {options::OPT_module_dir, options::OPT_fdebug_module_writer,
+   options::OPT_fintrinsic_modules_path});
 }
 
 void Flang::ConstructJob(Compilation , const JobAction ,

diff  --git a/flang/include/flang/Frontend/PreprocessorOptions.h 
b/flang/include/flang/Frontend/PreprocessorOptions.h
index 39ea4d3d3c6cf..3a3877bf0b286 100644
--- a/flang/include/flang/Frontend/PreprocessorOptions.h
+++ b/flang/include/flang/Frontend/PreprocessorOptions.h
@@ -29,6 +29,8 @@ class PreprocessorOptions {
   // consider collecting them in a separate aggregate. For now we keep it here
   // as there is no point creating a class for just one field.
   std::vector searchDirectoriesFromDashI;
+  // Search directories specified by the user with -fintrinsic-modules-path
+  std::vector searchDirectoriesFromIntrModPath;
 
 public:
   PreprocessorOptions() {}
@@ -44,4 +46,4 @@ class PreprocessorOptions {
 
 } // namespace Fortran::frontend
 
-#endif // LLVM_FLANG_PREPROCESSOROPTIONS_H
\ No newline at end of file
+#endif // LLVM_FLANG_PREPROCESSOROPTIONS_H

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index d2318d3d683d2..69c78bde7ff11 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -21,6 +21,8 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -285,6 +287,16 @@ static InputKind ParseFrontendArgs(FrontendOptions ,
   return dashX;
 }
 
+// Generate the path to look for intrinsic modules
+static std::string getIntrinsicDir() {
+  // TODO: Find a system independent API
+  llvm::SmallString<128> driverPath;
+  driverPath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+  llvm::sys::path::remove_filename(driverPath);
+  driverPath.append("/../include/flang/");
+  return std::string(driverPath);
+}
+
 /// Parses all 

[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 332692.
arnamoy10 added a comment.

Thanks @awarzynski for the comments.

1. Moving diagnostics options parsing to a separate function
2. Adding a check so that `-Wblah` does not trigger the treatment of warnings 
as werrors, only `-Werror` triggers it
3. Adding a new test case.


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

https://reviews.llvm.org/D98657

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/werror.f90

Index: flang/test/Driver/werror.f90
===
--- /dev/null
+++ flang/test/Driver/werror.f90
@@ -0,0 +1,27 @@
+! Ensure argument -Werror work as expected.
+! TODO: Modify test cases in test/Semantics/ related to f18 when -std= is upstreamed
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang_fc1 -Werror %s  2>&1 | FileCheck %s --check-prefix=WITH
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+
+!-
+! EXPECTED OUTPUT WITH -Werror
+!-
+! WITH: Semantic errors in
+
+!-
+! EXPECTED OUTPUT WITHOUT -Werror
+!-
+! WITHOUT-NOT: Semantic errors in
+
+PROGRAM werror
+REAL, DIMENSION(20, 10) :: A
+FORALL (J=1:N)  A(I, I) = 1
+END PROGRAM werror
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -47,6 +47,7 @@
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
+! HELP-NEXT: -WEnable the specified warning
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
@@ -95,6 +96,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
+! HELP-FC1-NEXT: -WEnable the specified warning
 
 !---
 ! EXPECTED ERROR
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -47,6 +47,7 @@
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
+! CHECK-NEXT: -WEnable the specified warning
 ! CHECK-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -64,7 +64,9 @@
   // Prescan. In case of failure, report and return.
   ci.parsing().Prescan(currentInputPath, parserOptions);
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 const unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not scan %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -97,7 +99,9 @@
   // Prescan. In case of failure, report and return.
   ci.parsing().Prescan(currentInputPath, parserOptions);
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 const unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not scan %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -109,7 +113,9 @@
   // Parse. In case of failure, report and return.
   ci.parsing().Parse(llvm::outs());
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not parse %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -264,7 

[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added inline comments.



Comment at: flang/test/Semantics/dosemantics03.f90:1-2
 ! RUN: %S/test_errors.sh %s %t %f18 -Mstandard -Werror
+! RUN: %S/test_errors.sh %s %t %flang_fc1 -Werror
 

awarzynski wrote:
> Rather than adding the 2nd line, could you update the first line to use 
> `%flang_fc1` instead of `%f18`?
I am not modifying this test case, as it would create a dependency on 
`-std=f2018` up-streamed (due to this particular test case having dependency on 
language standard).  I create a new test case, we can come back to it later.


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

https://reviews.llvm.org/D98657

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


[PATCH] D99194: [analyzer] Fix body farm for Obj-C++ properties

2021-03-23 Thread Balázs Benics via Phabricator via cfe-commits
steakhal resigned from this revision.
steakhal added a comment.
Herald added a subscriber: steakhal.

I'm not familiar with Objective-C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99194

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


[PATCH] D99194: [analyzer] Fix body farm for Obj-C++ properties

2021-03-23 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, xazax.hun, steakhal, ASDenysPetrov.
Herald added subscribers: Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, kristof.beyls.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When property is declared in a superclass (or in a protocol),
it still can be of CXXRecord type and Sema could've already
generated a body for us.  This patch joins two branches and
two ways of acquiring IVar in order to reuse the existing code.
And prevent us from generating l-value to r-value casts for
C++ types.

rdar://67416721


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99194

Files:
  clang/lib/Analysis/BodyFarm.cpp
  clang/test/Analysis/properties.mm

Index: clang/test/Analysis/properties.mm
===
--- clang/test/Analysis/properties.mm
+++ clang/test/Analysis/properties.mm
@@ -77,3 +77,23 @@
 
   clang_analyzer_eval(w.inner.value == 42); // expected-warning{{TRUE}}
 }
+
+@protocol NoDirectPropertyDecl
+@property IntWrapperStruct inner;
+@end
+@interface NoDirectPropertyDecl 
+@end
+@implementation NoDirectPropertyDecl
+@synthesize inner;
+@end
+
+// rdar://67416721
+void testNoDirectPropertyDecl(NoDirectPropertyDecl *w) {
+  clang_analyzer_eval(w.inner.value == w.inner.value); // expected-warning{{TRUE}}
+
+  int origValue = w.inner.value;
+  if (origValue != 42)
+return;
+
+  clang_analyzer_eval(w.inner.value == 42); // expected-warning{{TRUE}}
+}
Index: clang/lib/Analysis/BodyFarm.cpp
===
--- clang/lib/Analysis/BodyFarm.cpp
+++ clang/lib/Analysis/BodyFarm.cpp
@@ -742,8 +742,9 @@
 
 static Stmt *createObjCPropertyGetter(ASTContext ,
   const ObjCMethodDecl *MD) {
-// First, find the backing ivar.
+  // First, find the backing ivar.
   const ObjCIvarDecl *IVar = nullptr;
+  const ObjCPropertyDecl *Prop = nullptr;
 
   // Property accessor stubs sometimes do not correspond to any property decl
   // in the current interface (but in a superclass). They still have a
@@ -751,54 +752,56 @@
   if (MD->isSynthesizedAccessorStub()) {
 const ObjCInterfaceDecl *IntD = MD->getClassInterface();
 const ObjCImplementationDecl *ImpD = IntD->getImplementation();
-for (const auto *PI: ImpD->property_impls()) {
-  if (const ObjCPropertyDecl *P = PI->getPropertyDecl()) {
-if (P->getGetterName() == MD->getSelector())
-  IVar = P->getPropertyIvarDecl();
+for (const auto *PI : ImpD->property_impls()) {
+  if (PI->getPropertyDecl()) {
+Prop = PI->getPropertyDecl();
+if (Prop->getGetterName() == MD->getSelector())
+  IVar = Prop->getPropertyIvarDecl();
   }
 }
   }
 
   if (!IVar) {
-const ObjCPropertyDecl *Prop = MD->findPropertyDecl();
+Prop = MD->findPropertyDecl();
 IVar = findBackingIvar(Prop);
-if (!IVar)
-  return nullptr;
+  }
 
-// Ignore weak variables, which have special behavior.
-if (Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
-  return nullptr;
+  if (!IVar || !Prop)
+return nullptr;
 
-// Look to see if Sema has synthesized a body for us. This happens in
-// Objective-C++ because the return value may be a C++ class type with a
-// non-trivial copy constructor. We can only do this if we can find the
-// @synthesize for this property, though (or if we know it's been auto-
-// synthesized).
-const ObjCImplementationDecl *ImplDecl =
+  // Ignore weak variables, which have special behavior.
+  if (Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
+return nullptr;
+
+  // Look to see if Sema has synthesized a body for us. This happens in
+  // Objective-C++ because the return value may be a C++ class type with a
+  // non-trivial copy constructor. We can only do this if we can find the
+  // @synthesize for this property, though (or if we know it's been auto-
+  // synthesized).
+  const ObjCImplementationDecl *ImplDecl =
   IVar->getContainingInterface()->getImplementation();
-if (ImplDecl) {
-  for (const auto *I : ImplDecl->property_impls()) {
-if (I->getPropertyDecl() != Prop)
-  continue;
-
-if (I->getGetterCXXConstructor()) {
-  ASTMaker M(Ctx);
-  return M.makeReturn(I->getGetterCXXConstructor());
-}
+  if (ImplDecl) {
+for (const auto *I : ImplDecl->property_impls()) {
+  if (I->getPropertyDecl() != Prop)
+continue;
+
+  if (I->getGetterCXXConstructor()) {
+ASTMaker M(Ctx);
+return M.makeReturn(I->getGetterCXXConstructor());
   }
 }
-
-// Sanity check that the property is the same type as the ivar, or a
-// reference to it, and that it is either an object pointer or 

[PATCH] D98950: [clang][deps] NFC: Document collector, rename members

2021-03-23 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

Thanks for the cleanup. Code makes more sense now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98950

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


[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 3 inline comments as done.
balazske added a comment.

Ping.
I am not sure how to the test should be changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D99193: [PowerPC] Add mprivileged option

2021-03-23 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp created this revision.
stefanp added a reviewer: nemanjai.
Herald added subscribers: jansvoboda11, dang, shchenz, kbarton, hiraditya.
stefanp requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Add an option to tell the compiler that it can use privileged instructions.

This patch only adds the option. Backend implementation will be added in a
future patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99193

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-mprivileged-support-check.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -113,6 +113,7 @@
   bool HasPCRelativeMemops;
   bool HasMMA;
   bool HasROPProtect;
+  bool HasPrivileged;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -275,6 +276,7 @@
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMMA() const { return HasMMA; }
   bool hasROPProtect() const { return HasROPProtect; }
+  bool hasPrivileged() const { return HasPrivileged; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -88,6 +88,7 @@
   HasP9Altivec = false;
   HasMMA = false;
   HasROPProtect = false;
+  HasPrivileged = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -256,6 +256,10 @@
   SubtargetFeature<"rop-protect", "HasROPProtect", "true",
"Add ROP protect">;
 
+def FeaturePrivileged :
+  SubtargetFeature<"privileged", "HasPrivileged", "true",
+   "Add privileged instructions">;
+
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
"PredictableSelectIsExpensive",
Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -567,6 +567,7 @@
 // PPCPWR8:#define _ARCH_PWR7 1
 // PPCPWR8:#define _ARCH_PWR8 1
 // PPCPWR8-NOT:#define __ROP_PROTECT__ 1
+// PPCPWR8-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER8 %s
 //
@@ -585,6 +586,7 @@
 // PPCPOWER8:#define _ARCH_PWR7 1
 // PPCPOWER8:#define _ARCH_PWR8 1
 // PPCPOWER8-NOT:#define __ROP_PROTECT__ 1
+// PPCPOWER8-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPWR9 %s
 //
@@ -600,6 +602,7 @@
 // PPCPWR9:#define _ARCH_PWR7 1
 // PPCPWR9:#define _ARCH_PWR9 1
 // PPCPWR9-NOT:#define __ROP_PROTECT__ 1
+// PPCPWR9-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER9 %s
 //
@@ -615,6 +618,7 @@
 // PPCPOWER9:#define _ARCH_PWR7 1
 // PPCPOWER9:#define _ARCH_PWR9 1
 // PPCPOWER9-NOT:#define __ROP_PROTECT__ 1
+// PPCPOWER9-NOT:#define __PRIVILEGED__ 1
 //

[PATCH] D99106: [ASTMatchers][NFC] Use SmallVector when building variadic matcher descriptor

2021-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman 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/D99106/new/

https://reviews.llvm.org/D99106

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


[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 332686.
balazske added a comment.

Fixed according to the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

Files:
  clang/lib/AST/Expr.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,63 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedLookupExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto ) {
+f_overload(p); // UnresolvedLookupExpr
+// CalleeType in getCallReturntype is Overload and not dependent
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedMemberExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+
+struct A {
+  void f_overload(int);
+  void f_overload(double);
+};
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto ) {
+A a;
+a.f_overload(p); // UnresolvedMemberExpr
+// CalleeType in getCallReturntype is BoundMember and has overloads
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1383,6 +1383,7 @@
 QualType CallExpr::getCallReturnType(const ASTContext ) const {
   const Expr *Callee = getCallee();
   QualType CalleeType = Callee->getType();
+
   if (const auto *FnTypePtr = CalleeType->getAs()) {
 CalleeType = FnTypePtr->getPointeeType();
   } else if (const auto *BPT = CalleeType->getAs()) {
@@ -1391,8 +1392,16 @@
 if (isa(Callee->IgnoreParens()))
   return Ctx.VoidTy;
 
+if (isa(Callee->IgnoreParens()))
+  return Ctx.DependentTy;
+
 // This should never be overloaded and so should never return null.
 CalleeType = Expr::findBoundMemberType(Callee);
+assert(!CalleeType.isNull());
+
+  } else if (CalleeType->isDependentType() ||
+ CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
+return Ctx.DependentTy;
   }
 
   const FunctionType *FnType = CalleeType->castAs();


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,63 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedLookupExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto ) {
+f_overload(p); // UnresolvedLookupExpr
+// CalleeType in getCallReturntype is Overload and not dependent
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedMemberExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+
+struct A {
+  void f_overload(int);
+  void f_overload(double);
+};
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto ) {
+A a;
+a.f_overload(p); // UnresolvedMemberExpr
+// CalleeType in getCallReturntype is BoundMember and has overloads
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1383,6 +1383,7 @@
 QualType 

[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 332679.
djtodoro added a comment.

- addressing comments


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

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -376,6 +376,17 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+Testing of original debug info preservation can be invoked from front-end level
+as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Mutation testing for MIR-level transformations
 --
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,19 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve-export=%t.json %s -S 2>&1 \
+// RUN: | FileCheck --check-prefix=WARN %s
+
+// WARN: warning: ignoring -fverify-debuginfo-preserve-export
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1641,6 +1641,12 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  if (!Opts.EnableDIPreservationVerify && Opts.DIBugsReportFilePath.size()) {
+Diags.Report(diag::warn_ignoring_verify_debuginfo_preserve_export)
+<< Opts.DIBugsReportFilePath;
+Opts.DIBugsReportFilePath = "";
+  }
+
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -81,6 +81,7 @@
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -945,7 +946,16 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  DebugifyCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4865,6 +4865,18 @@
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">,
 MarshallingInfoFlag>;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">,
+  MarshallingInfoFlag>;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], 

[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added inline comments.



Comment at: clang/include/clang/Driver/Options.td:4872
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,

jansvoboda11 wrote:
> Please, update the new options to use the marshalling infrastructure. You can 
> then remove the code from `CompilerInvocation`.
> 
> https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option
Sure. Thanks!



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1644-1650
+  Opts.EnableDIPreservationVerify = 
Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+Opts.DIBugsReportFilePath = std::string(
+Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }

StephenTozer wrote:
> Any particular behaviour if the user specifies a file for 
> `-fverify-debuginfo-preserve-export` but doesn't set 
> `-fverify-debuginfo-preserve`? It seems like it would be worth emitting a 
> warning in this case, though I'm not sure if that's an established precedent.
it makes sense


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

https://reviews.llvm.org/D82547

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-23 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S added a comment.

In D98237#2643815 , @MyDeveloperDay 
wrote:

> If you follow people tweeting about clang-format (as I do) and you look 
> through the bug tracking system, one major criticism of clang-format is that 
> the second clang-format can be different from the first, sometimes an 
> equilibrium can be found sometimes not.
>
> When I started working on clang-format I was encouraged to use verifyFormat() 
> as it tests that scenario and also tries to mess up the format and ensure it 
> returns to the desired state. It found bugs in my code which would have made 
> clang-format worse.
>
> Apart from it being the convention I believe it makes for much more readable 
> code, even if there is repetition as I don't need to keep cross referencing 
> variables with rather obscure names `NL_B_3_A_0_I_0` this is unnecessary 
> noise and makes the code overly verbose.
>
> No you'll need to check out what the messUp() function is actually doing but 
> I think by and large IMHO we should stick with verifyFormat.

Ok then I will change the tests accordingly. This reasoning should be written 
down somewhere.

In D98237#2643880 , @MyDeveloperDay 
wrote:

> I'd be quite interested to understand what the impact (if any) would be on 
> javascript and C# formatting

I have not done anything in javascript a quick google search showed no such 
modifiers in classes. Do you have an example? C# seems to handle it like java 
and then the modifiers become properties of the functions member, there should 
be no influence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D98971: [C++20] [P1825] Fix bugs with implicit-move from variables of reference type

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D98971#2644747 , @Quuxplusone wrote:

> Shrink the code by one line, by introducing another local named variable.
> Still hoping for an "accept" here.

My two cents:

Functionality-wise I think it is OK, but like I said before, I think the extra 
repetition / verbosity hurts more than helps.

I think the suggested shortening captures the intention of the standard better: 
The object itself should be non-volatile, no matter if we have it by value or 
rvalue reference.

It does not look like to me that the clang code is in general styled to spell 
the wording that precisely, or else those comments quoting the standard wording 
would not be of much use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98971

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


[PATCH] D98971: [C++20] [P1825] Fix bugs with implicit-move from variables of reference type

2021-03-23 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert accepted this revision.
aaronpuchert added a comment.
This revision is now accepted and ready to land.

I thought maybe you wanted to follow @mizvekov's proposal to simplify, but I 
understand you want to stick close to the standard language.

So LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98971

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


[PATCH] D99190: [SYCL] Add design document for SYCL mode

2021-03-23 Thread Alexey Bader via Phabricator via cfe-commits
bader created this revision.
Herald added subscribers: mstorsjo, Anastasia, ebevhan, yaxunl.
bader requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Initial version of the document covers most of the compiler components.
SYCL runtime library part is to be defined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99190

Files:
  clang/docs/SYCLSupport.md
  clang/docs/images/Compiler-HLD.svg
  clang/docs/images/DeviceCodeSplit.svg
  clang/docs/images/DeviceLinkAndWrap.svg
  clang/docs/images/DevicePTXProcessing.svg
  clang/docs/images/SplitCompileAndLink.svg

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


[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-23 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 332675.
svenvh added a comment.

Emit `#if` guards for extensions and versions.


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

https://reviews.llvm.org/D97869

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -123,6 +123,8 @@
 
 void EmitClangOpenCLBuiltins(llvm::RecordKeeper ,
  llvm::raw_ostream );
+void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper ,
+ llvm::raw_ostream );
 
 void EmitClangDataCollectors(llvm::RecordKeeper ,
  llvm::raw_ostream );
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangCommentCommandInfo,
   GenClangCommentCommandList,
   GenClangOpenCLBuiltins,
+  GenClangOpenCLBuiltinTests,
   GenArmNeon,
   GenArmFP16,
   GenArmBF16,
@@ -195,6 +196,8 @@
"documentation comments"),
 clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
"Generate OpenCL builtin declaration handlers"),
+clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
+   "Generate OpenCL builtin declaration tests"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
 clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
@@ -375,6 +378,9 @@
   case GenClangOpenCLBuiltins:
 EmitClangOpenCLBuiltins(Records, OS);
 break;
+  case GenClangOpenCLBuiltinTests:
+EmitClangOpenCLBuiltinTests(Records, OS);
+break;
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -228,6 +228,64 @@
   // same entry ().
   MapVector SignatureListMap;
 };
+
+// OpenCL builtin test generator.  This class processes the same TableGen input
+// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
+// builtin function described in the .td input.
+class OpenCLBuiltinTestEmitter {
+public:
+  OpenCLBuiltinTestEmitter(RecordKeeper , raw_ostream )
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions for testing all OpenCL builtin
+  // functions.
+  void Emit();
+
+private:
+  struct TypeFlags {
+TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
+bool IsConst : 1;
+bool IsVolatile : 1;
+bool IsPointer : 1;
+StringRef AddrSpace;
+  };
+
+  // Return a string representation of the given type, such that it can be
+  // used as a type in OpenCL C code.
+  std::string getTypeString(const Record *Type, TypeFlags Flags,
+int VectorSize) const;
+
+  // Return the type(s) and vector size(s) for the given type.  For
+  // non-GenericTypes, the resulting vectors will contain 1 element.  For
+  // GenericTypes, the resulting vectors typically contain multiple elements.
+  void getTypeLists(Record *Type, TypeFlags ,
+std::vector ,
+std::vector ) const;
+
+  // Expand the TableGen Records representing a builtin function signature into
+  // one or more function signatures.  Return them as a vector of a vector of
+  // strings, with each string containing an OpenCL C type and optional
+  // qualifiers.
+  //
+  // The Records may contain GenericTypes, which expand into multiple
+  // signatures.  Repeated occurrences of GenericType in a signature expand to
+  // the same types.  For example [char, FGenType, FGenType] expands to:
+  //   [char, float, float]
+  //   [char, float2, float2]
+  //   [char, float3, float3]
+  //   ...
+  void
+  expandTypesInSignature(const std::vector ,
+ SmallVectorImpl> );
+
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper 
+
+  // The output file.
+  raw_ostream 
+};
+
 } // namespace
 
 void BuiltinNameEmitter::Emit() {
@@ -816,7 +874,221 @@
   OS << "\n} // OCL2Qual\n";
 }
 
+std::string OpenCLBuiltinTestEmitter::getTypeString(const Record *Type,
+TypeFlags Flags,
+int VectorSize) const {
+  std::string S;
+  if 

[PATCH] D99189: [RISCV][Clang] Update new overloading rules for RVV intrinsics.

2021-03-23 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, HsiangKai, evandro, liaolucy, 
jrtc27.
Herald added subscribers: vkmr, frasercrmck, dexonsmith, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb, mgorny.
khchen requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

RVV intrinsics has new overloading rule, please see
https://github.com/riscv/rvv-intrinsic-doc/commit/82aac7dad4c6c1c351ed5b17ca6007c395843ed7

Changed:

1. Rename `generic` to `overloaded` because the new rule is not using C11 
generic.
2. Change HasGeneric to HasNoMaskedOverloaded because all masked operations 
support overloading api.
3. Add more overloaded tests due to overloading rule changed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99189

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vse.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

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


  1   2   >