[PATCH] D110257: [CFE][Codegen] Do not break the contiguity of static allocas.

2021-09-28 Thread Mahesha S via Phabricator via cfe-commits
hsmhsm updated this revision to Diff 375789.
hsmhsm added a comment.

Fix review comments by @jdoerfert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
  clang/test/CodeGenCXX/vla.cpp
  clang/test/CodeGenSYCL/address-space-deduction.cpp
  clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp

Index: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
===
--- clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
+++ clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
@@ -12,6 +12,8 @@
   int arr[N];
 
   // CHECK:  [[VAR_ADDR:%.+]] = alloca [100 x i32]*, align 8, addrspace(5)
+  // CHECK-NEXT: [[VAR2_ADDR:%.+]] = alloca i32, align 4, addrspace(5)
+  // CHECK-NEXT: [[VAR2_ADDR_CAST:%.+]] = addrspacecast i32 addrspace(5)* [[VAR2_ADDR]] to i32*
   // CHECK-NEXT: [[VAR_ADDR_CAST:%.+]] = addrspacecast [100 x i32]* addrspace(5)* [[VAR_ADDR]] to [100 x i32]**
   // CHECK:  store [100 x i32]* [[VAR:%.+]], [100 x i32]** [[VAR_ADDR_CAST]], align 8
 
Index: clang/test/CodeGenSYCL/address-space-deduction.cpp
===
--- clang/test/CodeGenSYCL/address-space-deduction.cpp
+++ clang/test/CodeGenSYCL/address-space-deduction.cpp
@@ -5,31 +5,31 @@
 // CHECK-LABEL: @_Z4testv(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK-NEXT:[[I_ASCAST:%.*]] = addrspacecast i32* [[I]] to i32 addrspace(4)*
 // CHECK-NEXT:[[PPTR:%.*]] = alloca i32 addrspace(4)*, align 8
-// CHECK-NEXT:[[PPTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[PPTR]] to i32 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[IS_I_PTR:%.*]] = alloca i8, align 1
-// CHECK-NEXT:[[IS_I_PTR_ASCAST:%.*]] = addrspacecast i8* [[IS_I_PTR]] to i8 addrspace(4)*
 // CHECK-NEXT:[[VAR23:%.*]] = alloca i32, align 4
-// CHECK-NEXT:[[VAR23_ASCAST:%.*]] = addrspacecast i32* [[VAR23]] to i32 addrspace(4)*
 // CHECK-NEXT:[[CP:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[CP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CP]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[ARR:%.*]] = alloca [42 x i32], align 4
-// CHECK-NEXT:[[ARR_ASCAST:%.*]] = addrspacecast [42 x i32]* [[ARR]] to [42 x i32] addrspace(4)*
 // CHECK-NEXT:[[CPP:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[CPP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CPP]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[APTR:%.*]] = alloca i32 addrspace(4)*, align 8
-// CHECK-NEXT:[[APTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[APTR]] to i32 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[STR:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[STR]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[PHI_STR:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[PHI_STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[PHI_STR]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[SELECT_NULL:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[SELECT_NULL_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_NULL]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[SELECT_STR_TRIVIAL1:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[SELECT_STR_TRIVIAL1_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_STR_TRIVIAL1]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[SELECT_STR_TRIVIAL2:%.*]] = alloca i8 addrspace(4)*, align 8
 // CHECK-NEXT:[[SELECT_STR_TRIVIAL2_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_STR_TRIVIAL2]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[SELECT_STR_TRIVIAL1_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_STR_TRIVIAL1]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[SELECT_NULL_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_NULL]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[PHI_STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[PHI_STR]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[STR]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[APTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[APTR]] to i32 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[CPP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CPP]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[ARR_ASCAST:%.*]] = addrspacecast [42 x i32]* [[ARR]] to [42 x i32] addrspace(4)*
+// CHECK-NEXT:[[CP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CP]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[VA

[PATCH] D110676: [CFE][Codegen] Update auto-generated check lines for few GPU lit tests

2021-09-28 Thread Mahesha S via Phabricator via cfe-commits
hsmhsm updated this revision to Diff 375788.
hsmhsm added a comment.

Only update lit tests which undergo changes within 
https://reviews.llvm.org/D110257


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110676

Files:
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
  clang/test/CodeGenSYCL/address-space-deduction.cpp

Index: clang/test/CodeGenSYCL/address-space-deduction.cpp
===
--- clang/test/CodeGenSYCL/address-space-deduction.cpp
+++ clang/test/CodeGenSYCL/address-space-deduction.cpp
@@ -1,73 +1,129 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
 
-// CHECK:@_ZZ4testvE3foo = internal addrspace(1) constant i32 66, align 4
-// CHECK: @[[STR:[.a-zA-Z0-9_]+]] = private unnamed_addr addrspace(1) constant [14 x i8] c"Hello, world!\00", align 1
 
-// CHECK-LABEL: @_Z4testv
+// CHECK-LABEL: @_Z4testv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[I:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[I_ASCAST:%.*]] = addrspacecast i32* [[I]] to i32 addrspace(4)*
+// CHECK-NEXT:[[PPTR:%.*]] = alloca i32 addrspace(4)*, align 8
+// CHECK-NEXT:[[PPTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[PPTR]] to i32 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[IS_I_PTR:%.*]] = alloca i8, align 1
+// CHECK-NEXT:[[IS_I_PTR_ASCAST:%.*]] = addrspacecast i8* [[IS_I_PTR]] to i8 addrspace(4)*
+// CHECK-NEXT:[[VAR23:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[VAR23_ASCAST:%.*]] = addrspacecast i32* [[VAR23]] to i32 addrspace(4)*
+// CHECK-NEXT:[[CP:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[CP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CP]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[ARR:%.*]] = alloca [42 x i32], align 4
+// CHECK-NEXT:[[ARR_ASCAST:%.*]] = addrspacecast [42 x i32]* [[ARR]] to [42 x i32] addrspace(4)*
+// CHECK-NEXT:[[CPP:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[CPP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CPP]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[APTR:%.*]] = alloca i32 addrspace(4)*, align 8
+// CHECK-NEXT:[[APTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[APTR]] to i32 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[STR:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[STR]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[PHI_STR:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[PHI_STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[PHI_STR]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[SELECT_NULL:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[SELECT_NULL_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_NULL]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[SELECT_STR_TRIVIAL1:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[SELECT_STR_TRIVIAL1_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_STR_TRIVIAL1]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[SELECT_STR_TRIVIAL2:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[SELECT_STR_TRIVIAL2_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_STR_TRIVIAL2]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:store i32 0, i32 addrspace(4)* [[I_ASCAST]], align 4
+// CHECK-NEXT:store i32 addrspace(4)* [[I_ASCAST]], i32 addrspace(4)* addrspace(4)* [[PPTR_ASCAST]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* [[PPTR_ASCAST]], align 8
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 addrspace(4)* [[TMP0]], [[I_ASCAST]]
+// CHECK-NEXT:[[FROMBOOL:%.*]] = zext i1 [[CMP]] to i8
+// CHECK-NEXT:store i8 [[FROMBOOL]], i8 addrspace(4)* [[IS_I_PTR_ASCAST]], align 1
+// CHECK-NEXT:[[TMP1:%.*]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* [[PPTR_ASCAST]], align 8
+// CHECK-NEXT:store i32 66, i32 addrspace(4)* [[TMP1]], align 4
+// CHECK-NEXT:store i32 23, i32 addrspace(4)* [[VAR23_ASCAST]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = bitcast i32 addrspace(4)* [[VAR23_ASCAST]] to i8 addrspace(4)*
+// CHECK-NEXT:store i8 addrspace(4)* [[TMP2]], i8 addrspace(4)* addrspace(4)* [[CP_ASCAST]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* [[CP_ASCAST]], align 8
+// CHECK-NEXT:store i8 41, i8 addrspace(4)* [[TMP3]], align 1
+// CHECK-NEXT:[[ARRAYDECAY:%.*]] = getelementptr inbounds [42 x i32], [42 x i32] addrspace(4)* [[ARR_ASCAST]], i64 0, i64 0
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast i32 addrspace(4)*

[PATCH] D108822: [python bindings] Add missing cursor kind in Clang Python's bindings.

2021-09-28 Thread Teemu Rytkönen via Phabricator via cfe-commits
teerytko added a comment.

What is the process / schedule to get this change in? I am facing the same 
problem with llvm 12 and python bindings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108822

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


[PATCH] D109902: [PowerPC] Improved codegen related to xscvdpsxws/xscvdpuxws

2021-09-28 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 375780.
Conanap marked an inline comment as done.
Conanap added a comment.

Updated correct version of the patch


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

https://reviews.llvm.org/D109902

Files:
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/test-vector-insert.ll
  llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll

Index: llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
===
--- llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
+++ llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
@@ -13,12 +13,8 @@
 ; CHECK-P8-LABEL: test2elt:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpuxws f1, v2
-; CHECK-P8-NEXT:xscvdpuxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpuxws v2, v2
+; CHECK-P8-NEXT:xscvdpuxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -26,26 +22,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpuxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpuxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpuxws v3, v2
+; CHECK-P9-NEXT:xscvdpuxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpuxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpuxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpuxws v3, v2
+; CHECK-BE-NEXT:xscvdpuxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
@@ -305,12 +293,8 @@
 ; CHECK-P8-LABEL: test2elt_signed:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpsxws f1, v2
-; CHECK-P8-NEXT:xscvdpsxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpsxws v2, v2
+; CHECK-P8-NEXT:xscvdpsxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -318,26 +302,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt_signed:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpsxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpsxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpsxws v3, v2
+; CHECK-P9-NEXT:xscvdpsxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt_signed:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpsxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpsxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpsxws v3, v2
+; CHECK-BE-NEXT:xscvdpsxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
Index: llvm/test/CodeGen/PowerPC/test-vector-insert.ll
===
--- llvm/test/CodeGen/PowerPC/test-vector-insert.ll
+++ llvm/test/CodeGen/PowerPC/test-vector-insert.ll
@@ -38,20 +38,16 @@
 ;
 ; CHECK-LE-P8-LABEL: test:
 ; CHECK-LE-P8:   # %bb.0: # %entry
-; CHECK-LE-P8-NEXT:xscvdpsxws f0, f1
+; CHECK-LE-P8-NEXT:xscvdpsxws v3, f1
 ; CHECK-LE-P8-NEXT:addis r3, r2, .LCPI0_0@toc@ha
 ; CHECK-LE-P8-NEXT:addi r3, r3, .LCPI0_0@toc@l
-; CHECK-LE-P8-NEXT:lvx v3, 0, r3
-; CHECK-LE-P8-NEXT:mffprwz r4, f0
-; CHECK-LE-P8-NEXT:mtvsrwz v4, r4
-; CHECK-LE-P8-NEXT:vperm v2, v4, v2, v3
+; CHECK-LE-P8-NEXT:lvx v4, 0, r3
+; CHECK-LE-P8-NEXT:vperm v2, v3, v2, v4
 ; CHECK-LE-P8-NEXT:blr
 ;
 ; CHECK-LE-P9-LABEL: test:
 ; CHECK-LE-P9:   # %bb.0: # %entry
 ; CHECK-LE-P9-NEXT:xscvdpsxws f0, f1
-; CHECK-LE-P9-NEXT:mffprwz r3, f0
-; CHECK-LE-P9-NEXT:mtfprwz f0, r3
 ; CHECK-LE-P9-NEXT:xxinsertw v2, vs0, 0
 ; CHECK-LE-P9-NEXT:blr
 ;
@@ -70,9 +66,7 @@
 ;
 ; CHECK-BE-P8-LABEL: test:
 ; CHECK-BE-P8:   # %bb.0: # %entry
-; CHECK-BE-P8-NEXT:xscvdpsxws f0, f1
-; CHECK-B

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 375778.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added subscribers: luismarques, s.egerton, PkmX, atanasyan, simoncook, 
arichardson, sdardis.

Support Debian -m32


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/c++/v1/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/i386-linux-gnu/c++/v1/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/x86_64-linux-gnu/c++/v1/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/i386-linux-gnu/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/x86_64-linux-gnu/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/i386-linux-gnu/.keep
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/i386-linux-gnu/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/x86_64-linux-gnu/libclang_rt.builtins.a
  clang/test/Driver/linux-cross.cpp

Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -151,6 +151,59 @@
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/lib"
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
 
+/// Test native x86-64 with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on.
+// RUN: %clang -### %s --target=x86_64-linux-gnu --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   -ccc-install-dir %S/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin -resource-dir=%S/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0 \
+// RUN:   --stdlib=libc++ --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=DEBIAN_X86_64_PER_TARGET
+// DEBIAN_X86_64_PER_TARGET:  "-resource-dir" "[[RESOURCE:[^"]+]]"
+// DEBIAN_X86_64_PER_TARGET:  "-internal-isystem"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "[[PREFIX:[^"]+llvm-14]]/bin/../include/x86_64-linux-gnu/c++/v1"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[PREFIX]]/bin/../include/c++/v1"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[SYSROOT:[^"]+]]/usr/local/include"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+
+// DEBIAN_X86_64_PER_TARGET:  "-L
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}}[[PREFIX]]/bin/../lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
+/// Debian patches MULTILIB_OSDIRNAMES (../lib64 -> ../lib), so gcc uses 'lib' instead of 'lib64'.
+/// This difference does not matter in practice.
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib64"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib64"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
+/// /usr/x86_64-linux-gnu does not exist, so there is no /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib.
+/// -ccc-install-dir is not within sysroot. No bin/../lib.
+/// $sysroot/lib and $sysroot/usr/lib. Fallback when GCC installation is unavailable.
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+// DEBIAN_X86_64_PER_TARGET-SAME: "[[RESOURCE]]/lib/x86_64-linux-gnu/libclang_rt.builtins.a"
+
+/// Test -m32.
+// RUN: %clang -### %s --target=x86_64-linux-gnu -m32 --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   -ccc-install-dir %S/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin -resource-dir=%S/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0 \
+// RUN:   --stdlib=libc++ --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=DEBIAN_X86_64_M32_PER_TARGET
+// DEBIAN_X86_64_M32_PER_TARGET:  "-resource-dir" "[[RESOURCE:[^"]+]]"
+// DEBIAN_X86_64_M32_PER_TARGET:  "-internal-isystem"
+// DEBIAN_X86_64_M32_PER_TARGET-SAME: {{^}} "[[PREFIX:[^"]+llvm-14]]/bin/../include/i386-linux-gnu/c++/v1"
+// DEBIAN_X86_64_M32_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[PREFIX]]/bin/../include/c++/v1"
+// DEBIAN_X86_64_M32_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
+// DEBIAN_X86_64_M32_PER_TARGET-SAME: 

[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375775.
expnkx added a comment.

clang format + clang tidy

all clang tests pass locally.

flang is bugged. Do not know why flang cannot find llvm-jxx


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

https://reviews.llvm.org/D110485

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Preprocessor/has_attribute.cpp
  clang/test/SemaCXX/cxx2a-no-unique-address.cpp

Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
+// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows
+// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows-gnu
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/test/Preprocessor/has_attribute.cpp
===
--- clang/test/Preprocessor/has_attribute.cpp
+++ clang/test/Preprocessor/has_attribute.cpp
@@ -65,7 +65,7 @@
 // CHECK: likely: 201803L
 // CHECK: maybe_unused: 201603L
 // ITANIUM: no_unique_address: 201803L
-// WINDOWS: no_unique_address: 0
+// WINDOWS: no_unique_address: 201803L
 // CHECK: nodiscard: 201907L
 // CHECK: noreturn: 200809L
 // CHECK: unlikely: 201803L
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -14,8 +14,8 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/VTableBuilder.h"
 #include "clang/AST/RecordLayout.h"
+#include "clang/AST/VTableBuilder.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/Format.h"
@@ -44,7 +44,7 @@
   bool IsVirtual;
 
   /// Bases - Information about the base subobjects.
-  SmallVector Bases;
+  SmallVector Bases;
 
   /// PrimaryVirtualBaseInfo - Holds the base info for the primary virtual base
   /// of this base info (if one exists).
@@ -78,8 +78,7 @@
   /// Get the offset of the given field. The external source must provide
   /// entries for all fields in the record.
   uint64_t getExternalFieldOffset(const FieldDecl *FD) {
-assert(FieldOffsets.count(FD) &&
-   "Field does not have an external offset");
+assert(FieldOffsets.count(FD) && "Field does not have an external offset");
 return FieldOffsets[FD];
   }
 
@@ -139,8 +138,8 @@
 return Offset <= MaxEmptyClassOffset;
   }
 
-  CharUnits
-  getFieldOffset(const ASTRecordLayout &Layout, unsigned FieldNo) const {
+  CharUnits getFieldOffset(const ASTRecordLayout &Layout,
+   unsigned FieldNo) const {
 uint64_t FieldOffset = Layout.getFieldOffset(FieldNo);
 assert(FieldOffset % CharWidth == 0 &&
"Field offset not at char boundary!");
@@ -168,16 +167,15 @@
   CharUnits SizeOfLargestEmptySubobject;
 
   EmptySubobjectMap(const ASTContext &Context, const CXXRecordDecl *Class)
-  : Context(Context), CharWidth(Context.getCharWidth()), Class(Class) {
-  ComputeEmptySubobjectSizes();
+  : Context(Context), CharWidth(Context.getCharWidth()), Class(Class) {
+ComputeEmptySubobjectSizes();
   }
 
   /// CanPlaceBaseAtOffset - Return whether the given base class can be placed
   /// at the given offset.
   /// Returns false if placing the record will result in two components
   /// (direct or indirect) of the same type having the same offset.
-  bool CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info,
-CharUnits Offset);
+  bool CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info, CharUnits Offset);
 
   /// CanPlaceFieldAtOffset - Return whether a field can be placed at the given
   /// offset.
@@ -228,9 +226,8 @@
   }
 }
 
-bool
-EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
- CharUnits Offset) const {
+bool EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
+  CharUnits Offset) const {
   // We only need to check empty bases.
   if (!RD->isEmpty())
 return true;
@@ -266,9 +263,8 @@
 MaxEmptyClassOffset = Offset;
 }
 
-bool
-EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
- CharUnits Offset) {
+bool EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(
+const BaseSubobjectInfo *

[PATCH] D110655: [OpenMP] Apply OpenMP assumptions to applicable call sites

2021-09-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 375773.
jhuber6 added a comment.

Fix test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110655

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/OpenMP/assumes_codegen.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp

Index: clang/test/OpenMP/assumes_include_nvptx.cpp
===
--- clang/test/OpenMP/assumes_include_nvptx.cpp
+++ clang/test/OpenMP/assumes_include_nvptx.cpp
@@ -24,7 +24,7 @@
 // CHECK:   attributes [[attr1]]
 // CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
 // CHECK:   attributes [[attr2]]
-// CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
+// CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations,ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
 
 
 template 
Index: clang/test/OpenMP/assumes_codegen.cpp
===
--- clang/test/OpenMP/assumes_codegen.cpp
+++ clang/test/OpenMP/assumes_codegen.cpp
@@ -67,6 +67,20 @@
 }
 #pragma omp end assumes
 
+void no_assume() {
+  foo();
+}
+
+#pragma omp begin assumes ext_call_site
+void assume() {
+  foo();
+}
+
+void assembly() {
+  asm ("nop");
+}
+#pragma omp end assumes ext_call_site
+
 // AST:  void foo() __attribute__((assume("omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses"))) __attribute__((assume("omp_no_openmp"))) {
 // AST-NEXT: }
 // AST-NEXT: class BAR {
@@ -115,29 +129,41 @@
 // CHECK: define{{.*}} void @_Z3barv()
 // CHECK-SAME: [[attr1:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BARC1Ev(%class.BAR*{{.*}} %b)
-// CHECK-SAME: [[attr9:#[0-9]]]
+// CHECK-SAME: [[attr10:#[0-9]]]
 // CHECK: define{{.*}} void @_ZN3BARC1Ev(%class.BAR*{{.*}} %this)
 // CHECK-SAME: [[attr2:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BARC2Ev(%class.BAR*{{.*}} %this1)
-// CHECK-SAME: [[attr9]]
+// CHECK-SAME: [[attr10]]
 // CHECK: define{{.*}} void @_ZN3BARC2Ev(%class.BAR*{{.*}} %this)
 // CHECK-SAME: [[attr3:#[0-9]]]
 // CHECK: define{{.*}} void @_Z3bazv()
 // CHECK-SAME: [[attr4:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BAZIfEC1Ev(%class.BAZ*{{.*}} %b)
-// CHECK-SAME: [[attr10:#[0-9]]]
+// CHECK-SAME: [[attr11:#[0-9]]]
 // CHECK: define{{.*}} void @_ZN3BAZIfEC1Ev(%class.BAZ*{{.*}} %this)
 // CHECK-SAME: [[attr5:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BAZIfEC2Ev(%class.BAZ*{{.*}} %this1)
-// CHECK-SAME: [[attr10]]
+// CHECK-SAME: [[attr12:#[0-9]]]
 // CHECK: define{{.*}} void @_ZN3BAZIfEC2Ev(%class.BAZ*{{.*}} %this)
 // CHECK-SAME: [[attr6:#[0-9]]]
 // CHECK: define{{.*}} i32 @_Z12lambda_outerv()
 // CHECK-SAME: [[attr7:#[0-9]]]
 // CHECK: call{{.*}} @"_ZZ12lambda_outervENK3$_0clEv"
-// CHECK-SAME: [[attr11:#[0-9]]]
+// CHECK-SAME: [[attr13:#[0-9]]]
 // CHECK: define{{.*}} i32 @"_ZZ12lambda_outervENK3$_0clEv"(%class.anon*{{.*}} %this)
 // CHECK-SAME: [[attr8:#[0-9]]]
+// CHECK: define{{.*}} void @_Z9no_assumev()
+// CHECK-SAME: [[attr0:#[0-9]]]
+// CHECK: call{{.*}} @_Z3foov()
+// CHECK-SAME: [[attr14:#[0-9]]]
+// CHECK: define{{.*}} void @_Z6assumev()
+// CHECK-SAME: [[attr9:#[0-9]]]
+// CHECK: call{{.*}} @_Z3foov()
+// CHECK-SAME: [[attr15:#[0-9]]]
+// CHECK: define{{.*}} void @_Z8assemblyv()
+// CHECK-SAME: [[attr9:#[0-9]]]
+// CHECK: call{{.*}} void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK-SAME: [[attr16:#[0-9]]]
 
 // CHECK: attributes [[attr0]]
 // CHECK-SAME:  "llvm.assume"="omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
@@ -158,8 +184,18 @@
 // CHECK: attributes [[attr8]]
 // CHECK-SAME:  "llvm.assume"="ompx_lambda_assumption,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
 // CHECK: attributes [[attr9]]
-// CHECK-SAME:  "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
+// CHECK-SAME:  "llvm.assume"="ompx_call_site,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
 // CHECK: attributes [[attr10]]
-// CHECK-SAME:  "llvm.assume"="ompx_1234,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
+// CHECK-SAME:  "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp,ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
 // CHECK: attributes [[attr11]]
-// CHECK-SAME: 

[PATCH] D110665: [clang] Don't use the AST to display backend diagnostics

2021-09-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:336-337
 
+  for (auto &F : getModule()->functions()) {
+if (const Decl *FD = Gen->GetDeclForMangledName(F.getName())) {
+  auto Loc = FD->getASTContext().getFullLoc(FD->getLocation());

Could we record these earlier, partly to avoid having to do the lookup by 
mangled name here? (eg: when the function's created instead)



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:642-645
+  for (auto &Pair : ManglingFullSourceLocs) {
+if (Pair.first == Hash)
+  return Pair.second;
+  }

Not worth doing anything faster (hash table, etc)?

If it's going to stay linear - could use `llvm::find_if` perhaps - though I 
realize it doesn't add a /huge/ amount of value here.

If it's going to stay with the explicit loop, the Pair reference should 
probably be made const.



Comment at: clang/test/Frontend/backend-diagnostic.c:18-20
+// REGULAR: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in 
stackSizeWarning
+// PROMOTE: error: stack frame size ([[#]]) exceeds limit ([[#]]) in 
stackSizeWarning
+// IGNORE-NOT: stack frame size ([[#]]) exceeds limit ([[#]]) in 
stackSizeWarning

I'm surprised these and other warning updates don't show the signature of the 
function, I'd have expected demangle to have returned something like 
'stackSizeWarning()' rather than just 'stackSizeWarning'?

(also it seems nice to retain the word "function" and quotation marks around 
the function name in the diagnostic messages, I think? (could end up with weird 
situations where simple function names could be confused with prose in the 
error message))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110665

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


[PATCH] D110280: [modules] Fix IRGen assertion on accessing ObjC ivar inside a method.

2021-09-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 375771.
vsapsai added a comment.

Rebase and add a test case with `always_inline`.

Interaction between `always_inline` function and `testAccessBitField` has
revealed that we cannot avoid having expressions referencing decls from "wrong"
module. So returning a canonical ivar in name lookup is not sufficient. Mimic
`CGRecordLayout` approach and use canonical ivar in
`ASTContext::lookupFieldBitOffset`, where we look up concrete layout data.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110280

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/merge-objc-interface.m

Index: clang/test/Modules/merge-objc-interface.m
===
--- /dev/null
+++ clang/test/Modules/merge-objc-interface.m
@@ -0,0 +1,105 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test-functions.m \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// Test a case when Objective-C interface ivars are present in two different modules.
+
+//--- Frameworks/Foundation.framework/Headers/Foundation.h
+@interface NSObject
+@end
+
+//--- Frameworks/Foundation.framework/Modules/module.modulemap
+framework module Foundation {
+  header "Foundation.h"
+  export *
+}
+
+//--- Frameworks/ObjCInterface.framework/Headers/ObjCInterface.h
+#import 
+@interface ObjCInterface : NSObject {
+@public
+  id _item;
+}
+@end
+
+@interface WithBitFields : NSObject {
+@public
+  int x: 3;
+  int y: 4;
+}
+@end
+
+//--- Frameworks/ObjCInterface.framework/Modules/module.modulemap
+framework module ObjCInterface {
+  header "ObjCInterface.h"
+  export *
+}
+
+//--- Frameworks/ObjCInterfaceCopy.framework/Headers/ObjCInterfaceCopy.h
+#import 
+@interface ObjCInterface : NSObject {
+@public
+  id _item;
+}
+@end
+
+@interface WithBitFields : NSObject {
+@public
+  int x: 3;
+  int y: 4;
+}
+@end
+
+// Inlined function present only in Copy.framework to make sure it uses decls from Copy module.
+__attribute__((always_inline)) void inlinedIVarAccessor(ObjCInterface *obj, WithBitFields *bitFields) {
+  obj->_item = 0;
+  bitFields->x = 0;
+}
+
+//--- Frameworks/ObjCInterfaceCopy.framework/Modules/module.modulemap
+framework module ObjCInterfaceCopy {
+  header "ObjCInterfaceCopy.h"
+  export *
+}
+
+//--- test.m
+#import 
+#import 
+
+@implementation ObjCInterface
+- (void)test:(id)item {
+  _item = item;
+}
+@end
+
+@implementation WithBitFields
+- (void)reset {
+  x = 0;
+  y = 0;
+}
+@end
+
+//--- test-functions.m
+#import 
+
+void testAccessIVar(ObjCInterface *obj, id item) {
+  obj->_item = item;
+}
+void testAccessBitField(WithBitFields *obj) {
+  obj->x = 0;
+}
+
+#import 
+
+void testAccessIVarLater(ObjCInterface *obj, id item) {
+  obj->_item = item;
+}
+void testAccessBitFieldLater(WithBitFields *obj) {
+  obj->y = 0;
+}
+void testInlinedFunction(ObjCInterface *obj, WithBitFields *bitFields) {
+  inlinedIVarAccessor(obj, bitFields);
+}
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3350,6 +3350,9 @@
 return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
   : nullptr;
 
+  if (auto *OID = dyn_cast(DC))
+return OID->getDefinition();
+
   // We can see the TU here only if we have no Sema object. In that case,
   // there's no TU scope to look in, so using the DC alone is sufficient.
   if (auto *TU = dyn_cast(DC))
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -3404,6 +3404,7 @@
 uint64_t ASTContext::lookupFieldBitOffset(const ObjCInterfaceDecl *OID,
   const ObjCImplementationDecl *ID,
   const ObjCIvarDecl *Ivar) const {
+  Ivar = Ivar->getCanonicalDecl();
   const ObjCInterfaceDecl *Container = Ivar->getContainingInterface();
 
   // FIXME: We should eliminate the need to have ObjCImplementationDecl passed
Index: clang/include/clang/AST/DeclObjC.h
===
--- clang/include/clang/AST/DeclObjC.h
+++ clang/include/clang/AST/DeclObjC.h
@@ -1955,6 +1955,13 @@
   const ObjCIvarDecl *getNextIvar() const { return NextIvar; }
   void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; }
 
+  ObjCIvarDecl *getCa

[PATCH] D110673: [clang] Don't modify OptRemark if the argument is not relevant

2021-09-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D110673#3029253 , @dblaikie wrote:

> It'd be good to understand/document (maybe document in the form of a test if 
> possible) how downstream users are relying on this - perhaps it's not a valid 
> reliance and we shouldn't maintain compatibility? Maybe it is and we should 
> ensure some test coverage of the sort of use case we're supporting, if 
> possible.

@JamesNagurne, given the description could you figure out why the test was 
failing for you downstream? I don't think I can show any difference upstream, 
but perhaps we should wait to see if @JamesNagurne can shed some more insight.

However, this logic is clearly wrong and just happens to work due to what I 
described in the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110673

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


[PATCH] D110673: [clang] Don't modify OptRemark if the argument is not relevant

2021-09-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

It'd be good to understand/document (maybe document in the form of a test if 
possible) how downstream users are relying on this - perhaps it's not a valid 
reliance and we shouldn't maintain compatibility? Maybe it is and we should 
ensure some test coverage of the sort of use case we're supporting, if possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110673

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

On top on this Diff, with the following patch, `ninja check-clang-driver` 
passes. We may consider dropping the normalized triple code.

  --- i/clang/lib/Driver/ToolChain.cpp
  +++ w/clang/lib/Driver/ToolChain.cpp
  @@ -494,6 +494,7 @@ std::string ToolChain::getRuntimePath() const {
 // "x86_64-linux-gnu" (no vendor part).
 SmallString<128> P;
 llvm::sys::path::append(P, D.ResourceDir, "lib", D.getTargetTriple());
  +  return std::string(P);
 if (getVFS().exists(P))
   return std::string(P);
   
  @@ -506,6 +507,7 @@ std::string ToolChain::getStdlibPath() const {
 SmallString<128> P;
 // First try the unnormalized triple a la getRuntimePath().
 llvm::sys::path::append(P, D.Dir, "..", "lib", D.getTargetTriple());
  +  return std::string(P);
 if (getVFS().exists(P))
   return std::string(P);
   


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> You mean when you build runtimes with the host compiler and then use them 
> with Clang (i.e. by using -DLLVM_ENABLE_PROJECTS="clang;lld;libcx")? This has 
> been discussed several times on llvm-dev in the past, ideally nobody should 
> be using this mode because there's no guarantee that the host compiler is ABI 
> compatible with Clang. Unfortunately, I believe that some projects still 
> build that way and it might take a while to migrate them to another approach.

I think many groups will object to disallowing `LLVM_ENABLE_PROJECTS` for 
libcxx/libcxxabi/libunwind.
They can not be unsupported anytime soon.
For example, one step of a msan build uses 
`-DLLVM_ENABLE_PROJECTS='libcxx;libcxxabi'`.

>> My previous comment has been edited. I believe by making Debian derivatives 
>> stick with *-linux-gnu, we can actually remove more code from the driver.
>
> Can you elaborate on it? What solution do you have in mind?

See updated https://reviews.llvm.org/D110663#3029138


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110671: [AIX] Enable PGO without LTO

2021-09-28 Thread Jinsong Ji 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 rG1e48951c736c: [AIX] Enable PGO without LTO (authored by 
jsji).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110671

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unsupported-option.c


Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -14,14 +14,6 @@
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-SAMPLE
 // AIX-PROFILE-SAMPLE: error: unsupported option '-fprofile-sample-use=' for 
target
 
-// RUN: not %clang -fprofile-generate --target=powerpc-ibm-aix %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-LTO
-// AIX-PROFILE-LTO: error: invalid argument '-fprofile-generate' only allowed 
with '-flto'
-
-// RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 
2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
-// AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only 
allowed with '-flto'
-
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
 // AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for 
target 'powerpc-ibm-aix'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -795,11 +795,6 @@
   }
 
   if (TC.getTriple().isOSAIX()) {
-if (PGOGenerateArg)
-  if (!D.isUsingLTO(false /*IsDeviceOffloadAction */) ||
-  D.getLTOMode() != LTOK_Full)
-D.Diag(clang::diag::err_drv_argument_only_allowed_with)
-<< PGOGenerateArg->getSpelling() << "-flto";
 if (ProfileGenerateArg)
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << ProfileGenerateArg->getSpelling() << TC.getTriple().str();
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -98,6 +98,25 @@
 CmdArgs.push_back("-bnoentry");
   }
 
+  // Specify PGO linker option
+  if ((Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
+false) ||
+   Args.hasFlag(options::OPT_fprofile_generate,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_generate_EQ,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate_EQ,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fcs_profile_generate,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fcs_profile_generate_EQ,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasArg(options::OPT_fcreate_profile) ||
+   Args.hasArg(options::OPT_coverage)))
+CmdArgs.push_back("-bdbg:namedcsects");
+
   // Specify linker output file.
   assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
   if (Output.isFilename()) {


Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -14,14 +14,6 @@
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-SAMPLE
 // AIX-PROFILE-SAMPLE: error: unsupported option '-fprofile-sample-use=' for target
 
-// RUN: not %clang -fprofile-generate --target=powerpc-ibm-aix %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-LTO
-// AIX-PROFILE-LTO: error: invalid argument '-fprofile-generate' only allowed with '-flto'
-
-// RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
-// AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only allowed with '-flto'
-
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
 // AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for target 'powerpc-ibm-aix'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -795,11 +795,6 @@
   }
 
   if (TC.getTriple().isOSAIX()) {
-if (PGOGene

[clang] 1e48951 - [AIX] Enable PGO without LTO

2021-09-28 Thread Jinsong Ji via cfe-commits

Author: Jinsong Ji
Date: 2021-09-29T02:00:11Z
New Revision: 1e48951c736cb346df34605fc42a39ef6c349b29

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

LOG: [AIX] Enable PGO without LTO

On AIX, we relied on LTO to merge the csects for profiling data/counter
sections.

AIX binder now get the namedcsect support to support the merging,
so now we can enable PGO without LTO with the new binder.

Reviewed By: Whitney

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/unsupported-option.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 2a380d9676003..5c82d6566497e 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -98,6 +98,25 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-bnoentry");
   }
 
+  // Specify PGO linker option
+  if ((Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
+false) ||
+   Args.hasFlag(options::OPT_fprofile_generate,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_generate_EQ,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate_EQ,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fcs_profile_generate,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fcs_profile_generate_EQ,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasArg(options::OPT_fcreate_profile) ||
+   Args.hasArg(options::OPT_coverage)))
+CmdArgs.push_back("-bdbg:namedcsects");
+
   // Specify linker output file.
   assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
   if (Output.isFilename()) {

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7642692ced99b..23932bf9fd24e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -795,11 +795,6 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
   }
 
   if (TC.getTriple().isOSAIX()) {
-if (PGOGenerateArg)
-  if (!D.isUsingLTO(false /*IsDeviceOffloadAction */) ||
-  D.getLTOMode() != LTOK_Full)
-D.Diag(clang::diag::err_drv_argument_only_allowed_with)
-<< PGOGenerateArg->getSpelling() << "-flto";
 if (ProfileGenerateArg)
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << ProfileGenerateArg->getSpelling() << TC.getTriple().str();

diff  --git a/clang/test/Driver/unsupported-option.c 
b/clang/test/Driver/unsupported-option.c
index c263bb0b853c5..7594d0fc17eeb 100644
--- a/clang/test/Driver/unsupported-option.c
+++ b/clang/test/Driver/unsupported-option.c
@@ -14,14 +14,6 @@
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-SAMPLE
 // AIX-PROFILE-SAMPLE: error: unsupported option '-fprofile-sample-use=' for 
target
 
-// RUN: not %clang -fprofile-generate --target=powerpc-ibm-aix %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-LTO
-// AIX-PROFILE-LTO: error: invalid argument '-fprofile-generate' only allowed 
with '-flto'
-
-// RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 
2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
-// AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only 
allowed with '-flto'
-
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
 // AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for 
target 'powerpc-ibm-aix'



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


[PATCH] D110673: [clang] Don't modify OptRemark if the argument is not relevant

2021-09-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A followup to D110201 .

For example, we'd set OptimizationRemarkMissed's Regex to '.*' when
encountering -Rpass.  This doesn't actually affect remarks we emit
because in clang::ProcessWarningOptions() we'll separately look at all
-R arguments and turn on/off corresponding diagnostic groups.

Downstream users have somehow noticed this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110673

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1201,6 +1201,8 @@
 Result.Kind = CodeGenOptions::RK_Disabled;
   else if (Value == "no-everything")
 Result.Kind = CodeGenOptions::RK_DisabledEverything;
+  else
+continue;
 
   if (Result.Kind == CodeGenOptions::RK_Disabled ||
   Result.Kind == CodeGenOptions::RK_DisabledEverything) {


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1201,6 +1201,8 @@
 Result.Kind = CodeGenOptions::RK_Disabled;
   else if (Value == "no-everything")
 Result.Kind = CodeGenOptions::RK_DisabledEverything;
+  else
+continue;
 
   if (Result.Kind == CodeGenOptions::RK_Disabled ||
   Result.Kind == CodeGenOptions::RK_DisabledEverything) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106191: [clang] Option control afn flag

2021-09-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Added @jansvoboda11 to the review as it appears he was the one that added the 
original option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106191

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


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375758.
expnkx added a comment.

fixing clang format


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

https://reviews.llvm.org/D110485

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,12 +2923,17 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField) {
 FieldOffset = CharUnits::Zero();
-  else
+  } else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);
   Size = std::max(Size, FieldOffset + Info.Size);


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,12 +2923,17 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField) {
 FieldOffset = CharUnits::Zero();
-  else
+  } else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);
   Size = std::max(Size, FieldOffset + Info.Size);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D110663#3029147 , @MaskRay wrote:

> In D110663#3029146 , @phosek wrote:
>
>> In D110663#3029124 , @MaskRay 
>> wrote:
>>
>>> In D110663#3029088 , @phosek 
>>> wrote:
>>>
 The reason I removed this behavior in D101194 
 , aside from extra overhead introduced 
 by the extra checks,  is that we've seen cases where people would have 
 both paths on their system which lead to difficult to diagnose issues 
 where Clang would pick up a library different from the one they expected. 
 I'd therefore prefer supporting only a single spelling of the triple that 
 could be configured, and making sure that Clang build on Debian uses the 
 right configuration.
>>>
>>> The problem is that when LLVM_DEFAULT_TARGET_TRIPLE is "x86_64-linux-gnu" 
>>> (no vendor part), CMake respects it (instead of adding `unknown`) and 
>>> installs files to `lib/clang/14.0.0/x86_64-linux-gnu/`.
>>> Currently clang driver only inspects the normalized 
>>> `lib/clang/14.0.0/x86_64-unknown-linux-gnu/` and cannot find it.
>>
>> I ran into this issue the past and the solution I considered would be to 
>> modify the CMake build of runtimes to query Clang for the triple (using 
>> `-dumpmachine`) and use that instead of `LLVM_DEFAULT_TARGET_TRIPLE`. I 
>> still think that change would be desirable for consistency and would be 
>> happy to implement it.
>
> If the host compiler is GCC (`gcc -dumpmachine` => `x86_64-linux-gnu` on 
> Debian amd64), how to query Clang for the triple?

You mean when you build runtimes with the host compiler and then use them with 
Clang (i.e. by using `-DLLVM_ENABLE_PROJECTS="clang;lld;libcx"`)? This has been 
discussed several times on llvm-dev in the past, ideally nobody should be using 
this mode because there's no guarantee that the host compiler is ABI compatible 
with Clang. Unfortunately, I believe that some projects still build that way 
and it might take a while to migrate them to another approach.

> My previous comment has been edited. I believe by making Debian derivatives 
> stick with `*-linux-gnu`, we can actually remove more code from the driver.

Can you elaborate on it? What solution do you have in mind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D106959: [PowerPC] swdiv builtins for XL compatibility

2021-09-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Please note in the commit message that this is simply a wrapper for a 
floating point divide. XL provided this builtin because it doesn't produce 
software estimates by default at `-Ofast`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106959

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


[PATCH] D109178: [PowerPC] Disable vector types when not supported by subtarget features

2021-09-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai 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/D109178/new/

https://reviews.llvm.org/D109178

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D110663#3029146 , @phosek wrote:

> In D110663#3029124 , @MaskRay wrote:
>
>> In D110663#3029088 , @phosek wrote:
>>
>>> The reason I removed this behavior in D101194 
>>> , aside from extra overhead introduced by 
>>> the extra checks,  is that we've seen cases where people would have both 
>>> paths on their system which lead to difficult to diagnose issues where 
>>> Clang would pick up a library different from the one they expected. I'd 
>>> therefore prefer supporting only a single spelling of the triple that could 
>>> be configured, and making sure that Clang build on Debian uses the right 
>>> configuration.
>>
>> The problem is that when LLVM_DEFAULT_TARGET_TRIPLE is "x86_64-linux-gnu" 
>> (no vendor part), CMake respects it (instead of adding `unknown`) and 
>> installs files to `lib/clang/14.0.0/x86_64-linux-gnu/`.
>> Currently clang driver only inspects the normalized 
>> `lib/clang/14.0.0/x86_64-unknown-linux-gnu/` and cannot find it.
>
> I ran into this issue the past and the solution I considered would be to 
> modify the CMake build of runtimes to query Clang for the triple (using 
> `-dumpmachine`) and use that instead of `LLVM_DEFAULT_TARGET_TRIPLE`. I still 
> think that change would be desirable for consistency and would be happy to 
> implement it.

If the host compiler is GCC (`gcc -dumpmachine` => `x86_64-linux-gnu` on Debian 
amd64), how to query Clang for the triple?

My previous comment has been edited. I believe by making Debian derivatives 
stick with `*-linux-gnu`, we can actually remove more code from the driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D110663#3029124 , @MaskRay wrote:

> In D110663#3029088 , @phosek wrote:
>
>> The reason I removed this behavior in D101194 
>> , aside from extra overhead introduced by 
>> the extra checks,  is that we've seen cases where people would have both 
>> paths on their system which lead to difficult to diagnose issues where Clang 
>> would pick up a library different from the one they expected. I'd therefore 
>> prefer supporting only a single spelling of the triple that could be 
>> configured, and making sure that Clang build on Debian uses the right 
>> configuration.
>
> The problem is that when LLVM_DEFAULT_TARGET_TRIPLE is "x86_64-linux-gnu" (no 
> vendor part), CMake respects it (instead of adding `unknown`) and installs 
> files to `lib/clang/14.0.0/x86_64-linux-gnu/`.
> Currently clang driver only inspects the normalized 
> `lib/clang/14.0.0/x86_64-unknown-linux-gnu/` and cannot find it.

I ran into this issue the past and the solution I considered would be to modify 
the CMake build of runtimes to query Clang for the triple (using 
`-dumpmachine`) and use that instead of `LLVM_DEFAULT_TARGET_TRIPLE`. I still 
think that change would be desirable for consistency and would be happy to 
implement it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I'd actually want to get rid of the function `Linux::getMultiarchTriple`, when 
all Debian Clang use `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=*-linux-gnu` instead 
of `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=*-{unknown,pc}-linux-gnu`

In D110663#3029131 , @jrtc27 wrote:

> x86 is unusual; the default vendor, at least in the GNU world, is pc, not 
> unknown (e.g. `config.guess x86_64-linux-gnu` prints x86_64-pc-linux-gnu).

OK. llvm-project's old config.guess uses `unknown`.

  % sh llvm/cmake/config.guess   
  x86_64-unknown-linux-gnu
  % sh /tmp/c/config.guess   # 
'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
  x86_64-pc-linux-gnu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D110663#3029124 , @MaskRay wrote:

> In D110663#3029088 , @phosek wrote:
>
>> The reason I removed this behavior in D101194 
>> , aside from extra overhead introduced by 
>> the extra checks,  is that we've seen cases where people would have both 
>> paths on their system which lead to difficult to diagnose issues where Clang 
>> would pick up a library different from the one they expected. I'd therefore 
>> prefer supporting only a single spelling of the triple that could be 
>> configured, and making sure that Clang build on Debian uses the right 
>> configuration.
>
> The problem is that when LLVM_DEFAULT_TARGET_TRIPLE is "x86_64-linux-gnu" (no 
> vendor part), CMake respects it (instead of adding `unknown`) and installs 
> files to `lib/clang/14.0.0/x86_64-linux-gnu/`.
> Currently clang driver only inspects the normalized 
> `lib/clang/14.0.0/x86_64-unknown-linux-gnu/` and cannot find it.
>
> I think D101194  caused the workaround used 
> by @sylvestre.ledru: symlink `/usr/lib/llvm-14/lib/x86_64-linux-gnu` -> 
> `x86_64-pc-linux-gnu`
> (I am quite confused by the pc part. That looks like a Debian configuration 
> issue.)
>
>> A potential solution would be to reintroduce the portion D101194 
>>  which would let each driver control the 
>> triple spelling (by overriding getMultiarchTriple. On Linux, including 
>> Debian, that logic is already implemented in 
>> https://github.com/llvm/llvm-project/blob/7255ce30e48feb07e4e82613f518683fbc247c1c/clang/lib/Driver/ToolChains/Linux.cpp#L40,
>>  and on all other platforms this could simply return TargetTriple.str() as 
>> was done in D101194 .
>
> On many Debian/Ubuntu derivatives, `Distro.IsDebian() || Distro.IsUbuntu()` 
> is false but they use the Debian multiarch hierarchy. How to make these 
> distributions work?
> For non-Debian distros (e.g. Arch Linux), I'd still prefer we use the GCC 
> vanilla `x86_64-unknown-linux-gnu`.

x86 is unusual; the default vendor, at least in the GNU world, is pc, not 
unknown (e.g. `config.guess x86_64-linux-gnu` prints x86_64-pc-linux-gnu).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110653: [PowerPC] The builtins load8r and store8r are Power 7 plus.

2021-09-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110653

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D110663#3029088 , @phosek wrote:

> The reason I removed this behavior in D101194 
> , aside from extra overhead introduced by 
> the extra checks,  is that we've seen cases where people would have both 
> paths on their system which lead to difficult to diagnose issues where Clang 
> would pick up a library different from the one they expected. I'd therefore 
> prefer supporting only a single spelling of the triple that could be 
> configured, and making sure that Clang build on Debian uses the right 
> configuration.

The problem is that when LLVM_DEFAULT_TARGET_TRIPLE is "x86_64-linux-gnu" (no 
vendor part), CMake respects it (instead of adding `unknown`) and installs 
files to `lib/clang/14.0.0/x86_64-linux-gnu/`.
Currently clang driver only inspects the normalized 
`lib/clang/14.0.0/x86_64-unknown-linux-gnu/` and cannot find it.

I think D101194  caused the workaround used 
by @sylvestre.ledru: symlink `/usr/lib/llvm-14/lib/x86_64-linux-gnu` -> 
`x86_64-pc-linux-gnu`
(I am quite confused by the pc part. That looks like a Debian configuration 
issue.)

> A potential solution would be to reintroduce the portion D101194 
>  which would let each driver control the 
> triple spelling (by overriding getMultiarchTriple. On Linux, including 
> Debian, that logic is already implemented in 
> https://github.com/llvm/llvm-project/blob/7255ce30e48feb07e4e82613f518683fbc247c1c/clang/lib/Driver/ToolChains/Linux.cpp#L40,
>  and on all other platforms this could simply return TargetTriple.str() as 
> was done in D101194 .

On many Debian/Ubuntu derivatives, `Distro.IsDebian() || Distro.IsUbuntu()` is 
false but they use the Debian multiarch hierarchy. How to make these 
distributions work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

A potential solution would be to reintroduce the portion D101194 
 which would let each driver control the 
triple spelling (by overriding `getMultiarchTriple`. On Linux, including 
Debian, that logic is already implemented in 
https://github.com/llvm/llvm-project/blob/7255ce30e48feb07e4e82613f518683fbc247c1c/clang/lib/Driver/ToolChains/Linux.cpp#L40,
 and on all other platforms this could simply return `TargetTriple.str()` as 
was done in D101194 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D110663#3029076 , @MaskRay wrote:

> Prefer unnormalized over normalized (@smeenai)

To be clear, I wasn't advocating for one ordering over the other, just pointing 
out the similarity to the prior state of things :) @phosek would know what the 
right ordering is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110671: [AIX] Enable PGO without LTO

2021-09-28 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
jsji added reviewers: PowerPC, Whitney.
Herald added subscribers: wenlei, inglorion.
jsji requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On AIX, we relied on LTO to merge the csects for profiling data/counter
sections.

AIX binder now get the namedcsect support to support the merging,
so now we can enable PGO without LTO with the new binder.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110671

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unsupported-option.c


Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -14,14 +14,6 @@
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-SAMPLE
 // AIX-PROFILE-SAMPLE: error: unsupported option '-fprofile-sample-use=' for 
target
 
-// RUN: not %clang -fprofile-generate --target=powerpc-ibm-aix %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-LTO
-// AIX-PROFILE-LTO: error: invalid argument '-fprofile-generate' only allowed 
with '-flto'
-
-// RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 
2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
-// AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only 
allowed with '-flto'
-
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
 // AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for 
target 'powerpc-ibm-aix'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -795,11 +795,6 @@
   }
 
   if (TC.getTriple().isOSAIX()) {
-if (PGOGenerateArg)
-  if (!D.isUsingLTO(false /*IsDeviceOffloadAction */) ||
-  D.getLTOMode() != LTOK_Full)
-D.Diag(clang::diag::err_drv_argument_only_allowed_with)
-<< PGOGenerateArg->getSpelling() << "-flto";
 if (ProfileGenerateArg)
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << ProfileGenerateArg->getSpelling() << TC.getTriple().str();
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -98,6 +98,25 @@
 CmdArgs.push_back("-bnoentry");
   }
 
+  // Specify PGO linker option
+  if ((Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
+false) ||
+   Args.hasFlag(options::OPT_fprofile_generate,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_generate_EQ,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate_EQ,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fcs_profile_generate,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasFlag(options::OPT_fcs_profile_generate_EQ,
+options::OPT_fno_profile_generate, false) ||
+   Args.hasArg(options::OPT_fcreate_profile) ||
+   Args.hasArg(options::OPT_coverage)))
+CmdArgs.push_back("-bdbg:namedcsects");
+
   // Specify linker output file.
   assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
   if (Output.isFilename()) {


Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -14,14 +14,6 @@
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-SAMPLE
 // AIX-PROFILE-SAMPLE: error: unsupported option '-fprofile-sample-use=' for target
 
-// RUN: not %clang -fprofile-generate --target=powerpc-ibm-aix %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-LTO
-// AIX-PROFILE-LTO: error: invalid argument '-fprofile-generate' only allowed with '-flto'
-
-// RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
-// AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only allowed with '-flto'
-
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
 // AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for target 'powerpc-ibm-aix'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 375753.
MaskRay added a comment.

fix getRuntimePath
test libclang_rt.builtins.a


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/c++/v1/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/x86_64-linux-gnu/c++/v1/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/x86_64-linux-gnu/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/x86_64-linux-gnu/libclang_rt.builtins.a
  clang/test/Driver/linux-cross.cpp

Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -151,6 +151,35 @@
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/lib"
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
 
+/// Test native x86-64 with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on.
+// RUN: %clang -### %s --target=x86_64-linux-gnu --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   -ccc-install-dir %S/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin -resource-dir=%S/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0 \
+// RUN:   --stdlib=libc++ --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=DEBIAN_X86_64_PER_TARGET
+// DEBIAN_X86_64_PER_TARGET:  "-resource-dir" "[[RESOURCE:[^"]+]]"
+// DEBIAN_X86_64_PER_TARGET:  "-internal-isystem"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "[[PREFIX:[^"]+llvm-14]]/bin/../include/x86_64-linux-gnu/c++/v1"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[PREFIX]]/bin/../include/c++/v1"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[SYSROOT:[^"]+]]/usr/local/include"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+
+// DEBIAN_X86_64_PER_TARGET:  "-L
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}}[[PREFIX]]/bin/../lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
+/// Debian patches MULTILIB_OSDIRNAMES (../lib64 -> ../lib), so gcc uses 'lib' instead of 'lib64'.
+/// This difference does not matter in practice.
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib64"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib64"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
+/// /usr/x86_64-linux-gnu does not exist, so there is no /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib.
+/// -ccc-install-dir is not within sysroot. No bin/../lib.
+/// $sysroot/lib and $sysroot/usr/lib. Fallback when GCC installation is unavailable.
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+// DEBIAN_X86_64_PER_TARGET-SAME: "[[RESOURCE]]/lib/x86_64-linux-gnu/libclang_rt.builtins.a"
+
 /// LDSO_ARCH is i386 for all x86-32 variants.
 // RUN: %clang -### %s --target=i686-linux-musl --sysroot= \
 // RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s --check-prefix=MUSL_I686
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2910,9 +2910,17 @@
   return false;
 
 // First add the per-target include path if it exists.
-std::string TargetDir = Path + "/" + Target + "/c++/" + Version;
-if (D.getVFS().exists(TargetDir))
+std::string TargetDir =
+Path + "/" + D.getTargetTriple() + "/c++/" + Version;
+if (D.getVFS().exists(TargetDir)) {
+  // Unnormalized D.getTargetTriple(), e.g. x86_64-linux-gnu if --target
+  // does not contain vendor part.
   addSystemInclude(DriverArgs, CC1Args, TargetDir);
+} else {
+  // Normalized Target, e.g. x86_64-unknown-linux-gnu.
+  TargetDir = Path + "/" + Target + "/c++/" + Version;
+  addSystemInclude(DriverArgs, CC1Args, TargetDir);
+}
 
 // Second add the generic one.
 addSystemInclude(DriverArgs, CC1Args, Path + "/c++/" + Version);
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -488,15 +488,31 @@
 }
 
 std::string ToolC

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

The reason I removed this behavior in D101194 
, aside from extra overhead introduced by the 
extra checks,  is that we've seen cases where people would have both paths on 
their system which lead to difficult to diagnose issues where Clang would pick 
up a library different from the one they expected. I'd therefore prefer 
supporting only a single spelling of the triple that could be configured, and 
making sure that Clang build on Debian uses the right configuration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110422: [AIX] Change the linkage of profiling counter/data to be private

2021-09-28 Thread Jinsong Ji 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 rG25c30324e953: [AIX] Change the linkage of profiling 
counter/data to be private (authored by jsji).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

Files:
  clang/test/Profile/cxx-templates.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  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
@@ -45,8 +45,8 @@
 ; MACHO: @__profd_foo_weak = weak hidden global
 ; COFF: @__profc_foo_weak = weak hidden global
 ; COFF: @__profd_foo_weak = private global
-; XCOFF: @__profc_foo_weak = weak hidden global
-; XCOFF: @__profd_foo_weak = weak hidden global
+; XCOFF: @__profc_foo_weak = private global
+; XCOFF: @__profd_foo_weak = private global
 define weak void @foo_weak() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([8 x i8], [8 
x i8]* @__profn_foo_weak, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -71,8 +71,8 @@
 ; MACHO: @__profd_foo_inline = linkonce_odr hidden global
 ; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}} section 
".lprfc$M", align 8
 ; COFF: @__profd_foo_inline = private global{{.*}} section ".lprfd$M", align 8
-; XCOFF: @__profc_foo_inline = linkonce_odr hidden global
-; XCOFF: @__profd_foo_inline = linkonce_odr hidden global
+; XCOFF: @__profc_foo_inline = private global
+; XCOFF: @__profd_foo_inline = private global
 define linkonce_odr void @foo_inline() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], 
[10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -84,8 +84,8 @@
 ; MACHO: @__profd_foo_extern = linkonce_odr hidden global
 ; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section 
".lprfc$M", comdat, align 8
 ; COFF: @__profd_foo_extern = private global {{.*}}section ".lprfd$M", 
comdat($__profc_foo_extern), align 8
-; XCOFF: @__profc_foo_extern = linkonce_odr hidden global
-; XCOFF: @__profd_foo_extern = linkonce_odr hidden global
+; XCOFF: @__profc_foo_extern = private global
+; XCOFF: @__profd_foo_extern = private global
 define available_externally void @foo_extern() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], 
[10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -862,6 +862,15 @@
   GlobalValue::LinkageTypes Linkage = NamePtr->getLinkage();
   GlobalValue::VisibilityTypes Visibility = NamePtr->getVisibility();
 
+  // Due to the limitation of binder as of 2021/09/28, the duplicate weak
+  // symbols in the same csect won't be discarded. When there are duplicate 
weak
+  // symbols, we can NOT guarantee that the relocations get resolved to the
+  // intended weak symbol, so we can not ensure the correctness of the relative
+  // CounterPtr, so we have to use private linkage for counter and data 
symbols.
+  if (TT.isOSBinFormatXCOFF()) {
+Linkage = GlobalValue::PrivateLinkage;
+Visibility = GlobalValue::DefaultVisibility;
+  }
   // Move the name variable to the right section. Place them in a COMDAT group
   // if the associated function is a COMDAT. This will make sure that only one
   // copy of counters of the COMDAT function will be emitted after linking. 
Keep
Index: clang/test/Profile/cxx-templates.cpp
===
--- clang/test/Profile/cxx-templates.cpp
+++ clang/test/Profile/cxx-templates.cpp
@@ -10,8 +10,10 @@
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
-// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
-// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
+// The linkage can be target dependent, so accept all linkage here,
+// the linkage tests for different target are in 
llvm/test/Instrumentation/InstrProfiling/profiling.ll
+// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = {{.*}} global [2 x i64] 
zeroinitializer
+// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = {{.*}} global [2 x i64] 
zeroinitializer
 
 // T0GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()
 // T0USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()


Index: llvm/t

[clang] 25c3032 - [AIX] Change the linkage of profiling counter/data to be private

2021-09-28 Thread Jinsong Ji via cfe-commits

Author: Jinsong Ji
Date: 2021-09-29T00:47:25Z
New Revision: 25c30324e953c1c0011d1ab7529991db5c6ba741

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

LOG: [AIX] Change the linkage of profiling counter/data to be private

We generate symbols like `profc`/`profd` for each function, and put them into 
csects.
When there are weak functions,  we generate weak symbols for the functions as 
well,
with ELF (and some others),  linker (binder) will discard and only keep one 
copy of the weak symbols.

However, on AIX, the current binder can NOT discard the weak symbols if we put 
all of them into the same csect,
as binder can NOT discard a subset of a csect.

This creates a unique challenge for using those symbols to calculate some 
relative offsets.

This patch changed the linkage of `profc`/`profd` symbols to be private, so 
that all the profc/profd for each weak symbol will be *local* to objects, and 
all kept in the csect, so we won't have problem. Although only one of the 
counters will be used, all the pointer in the profd is correct.

The downside is that we won't be able to discard the duplicated counters and 
profile data,
but those can not be discarded even if we keep the weak linkage,
due to the binder limitation of not discarding a subsect of the csect either .

Reviewed By: Whitney, MaskRay

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

Added: 


Modified: 
clang/test/Profile/cxx-templates.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/profiling.ll

Removed: 




diff  --git a/clang/test/Profile/cxx-templates.cpp 
b/clang/test/Profile/cxx-templates.cpp
index 7af6660f521db..9f8c5a0bcf593 100644
--- a/clang/test/Profile/cxx-templates.cpp
+++ b/clang/test/Profile/cxx-templates.cpp
@@ -10,8 +10,10 @@
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
-// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
-// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
+// The linkage can be target dependent, so accept all linkage here,
+// the linkage tests for 
diff erent target are in llvm/test/Instrumentation/InstrProfiling/profiling.ll
+// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = {{.*}} global [2 x i64] 
zeroinitializer
+// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = {{.*}} global [2 x i64] 
zeroinitializer
 
 // T0GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()
 // T0USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()

diff  --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp 
b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index bdeb7c8cbbb15..fe93e27075044 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -862,6 +862,15 @@ 
InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
   GlobalValue::LinkageTypes Linkage = NamePtr->getLinkage();
   GlobalValue::VisibilityTypes Visibility = NamePtr->getVisibility();
 
+  // Due to the limitation of binder as of 2021/09/28, the duplicate weak
+  // symbols in the same csect won't be discarded. When there are duplicate 
weak
+  // symbols, we can NOT guarantee that the relocations get resolved to the
+  // intended weak symbol, so we can not ensure the correctness of the relative
+  // CounterPtr, so we have to use private linkage for counter and data 
symbols.
+  if (TT.isOSBinFormatXCOFF()) {
+Linkage = GlobalValue::PrivateLinkage;
+Visibility = GlobalValue::DefaultVisibility;
+  }
   // Move the name variable to the right section. Place them in a COMDAT group
   // if the associated function is a COMDAT. This will make sure that only one
   // copy of counters of the COMDAT function will be emitted after linking. 
Keep

diff  --git a/llvm/test/Instrumentation/InstrProfiling/profiling.ll 
b/llvm/test/Instrumentation/InstrProfiling/profiling.ll
index e4bc8387ef294..8138552b42d59 100644
--- a/llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/profiling.ll
@@ -45,8 +45,8 @@ define void @foo() {
 ; MACHO: @__profd_foo_weak = weak hidden global
 ; COFF: @__profc_foo_weak = weak hidden global
 ; COFF: @__profd_foo_weak = private global
-; XCOFF: @__profc_foo_weak = weak hidden global
-; XCOFF: @__profd_foo_weak = weak hidden global
+; XCOFF: @__profc_foo_weak = private global
+; XCOFF: @__profd_foo_weak = private global
 define weak void @foo_weak() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([8 x i8], [8 
x i8]* 

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 375751.
MaskRay marked an inline comment as done.
MaskRay retitled this revision from "[Driver] Support Debian multiarch style 
lib/clang/14.0.0/x86_64-linux-gnu runtime path" to "[Driver] Support Debian 
multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and 
include/x86_64-linux-gnu/c++/v1 libc++ path".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Fix libc++ include path as well
Prefer unnormalized over normalized (@smeenai)
Fix getStdlibPath as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/c++/v1/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/x86_64-linux-gnu/c++/v1/.keep
  
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/x86_64-linux-gnu/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/x86_64-linux-gnu/libclang_rt.builtins.a
  clang/test/Driver/linux-cross.cpp


Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -151,6 +151,34 @@
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/lib"
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
 
+/// Test native x86-64 with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on.
+// RUN: %clang -### %s --target=x86_64-linux-gnu 
--sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   -ccc-install-dir 
%S/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin 
-resource-dir=%S/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0 
\
+// RUN:   --stdlib=libc++ --rtlib=compiler-rt 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_X86_64_PER_TARGET
+// DEBIAN_X86_64_PER_TARGET:  "-resource-dir" "[[RESOURCE:[^"]+]]"
+// DEBIAN_X86_64_PER_TARGET:  "-internal-isystem"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} 
"[[PREFIX:[^"]+llvm-14]]/bin/../include/x86_64-linux-gnu/c++/v1"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" 
"[[PREFIX]]/bin/../include/c++/v1"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" 
"[[RESOURCE]]/include"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT:[^"]+]]/usr/local/include"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+
+// DEBIAN_X86_64_PER_TARGET:  "-L
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}}[[PREFIX]]/bin/../lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
+/// Debian patches MULTILIB_OSDIRNAMES (../lib64 -> ../lib), so gcc uses 'lib' 
instead of 'lib64'.
+/// This difference does not matter in practice.
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib64"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib64"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
+/// /usr/x86_64-linux-gnu does not exist, so there is no 
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib.
+/// -ccc-install-dir is not within sysroot. No bin/../lib.
+/// $sysroot/lib and $sysroot/usr/lib. Fallback when GCC installation is 
unavailable.
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// DEBIAN_X86_64_PER_TARGET-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
 /// LDSO_ARCH is i386 for all x86-32 variants.
 // RUN: %clang -### %s --target=i686-linux-musl --sysroot= \
 // RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=MUSL_I686
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2910,9 +2910,16 @@
   return false;
 
 // First add the per-target include path if it exists.
-std::string TargetDir = Path + "/" + Target + "/c++/" + Version;
-if (D.getVFS().exists(TargetDir))
+std::string TargetDir = Path + "/" + D.getTargetTriple() + "/c++/" + 
Version;
+if (D.getVFS().exists(TargetDir)) {
+  // Unnormalized D.getTargetTriple(), e.g. x86_64-linux-gnu if --target
+  // does not contain vendor part.
   addSystemInclude(DriverArgs, CC1Args, TargetDir);
+} else {
+  // Normalized Target, e.g. x86_64-unknown-linux-gnu.
+  TargetDir = Path + "/" + Target + "/c++/" + Version;
+  addSystemInclude(DriverArgs, CC1Args, TargetDir);
+}

[PATCH] D110668: [clang-cl] Accept `#pragma warning(disable : N)` for some N

2021-09-28 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 375750.
thakis added a comment.

tweak


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

https://reviews.llvm.org/D110668

Files:
  clang/include/clang/Basic/CLWarnings.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/CLWarnings.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Driver/cl-options.c
  clang/test/Sema/pragma-warning.cpp
  llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
@@ -55,6 +55,7 @@
   sources = [
 "Attributes.cpp",
 "Builtins.cpp",
+"CLWarnings.cpp",
 "CharInfo.cpp",
 "CodeGenOptions.cpp",
 "Cuda.cpp",
Index: clang/test/Sema/pragma-warning.cpp
===
--- /dev/null
+++ clang/test/Sema/pragma-warning.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fms-extensions -fsyntax-only -verify %s
+
+[[deprecated]] void f() {} // expected-note 2 {{marked deprecated here}}
+
+#define From__pragma() \
+  __pragma(warning(push)) \
+  __pragma(warning(disable:4996)) \
+  f(); \
+  __pragma(warning(pop))
+
+void g() {
+  f(); // expected-warning {{deprecated}}
+
+#pragma warning(push)
+#pragma warning(disable: 4996)
+  f(); // no diag
+
+#pragma warning(disable: 4996)
+#pragma warning(pop)
+
+  f(); // expected-warning {{deprecated}}
+
+  From__pragma(); // no diag
+}
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -353,7 +353,7 @@
 // CHECK-C11: -std=c11
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd12345678 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/Lex/Pragma.h"
+#include "clang/Basic/CLWarnings.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticLex.h"
 #include "clang/Basic/FileManager.h"
@@ -1413,12 +1414,15 @@
   return;
 }
   }
+  PP.getDiagnostics().pushMappings(DiagLoc);
   if (Callbacks)
 Callbacks->PragmaWarningPush(DiagLoc, Level);
 } else if (II && II->isStr("pop")) {
   // #pragma warning( pop )
   PP.Lex(Tok);
-  if (Callbacks)
+  if (!PP.getDiagnostics().popMappings(DiagLoc))
+PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop);
+  else if (Callbacks)
 Callbacks->PragmaWarningPop(DiagLoc);
 } else {
   // #pragma warning( warning-specifier : warning-number-list
@@ -1482,6 +1486,21 @@
   }
   Ids.push_back(int(Value));
 }
+
+// Only act on disable for now.
+diag::Severity SV = diag::Severity();
+if (Specifier == PPCallbacks::PWS_Disable)
+  SV = diag::Severity::Ignored;
+if (SV != diag::Severity())
+  for (int Id : Ids)
+if (const char *Group = diagGroupFromCLWarningID(Id)) {
+  bool unknownDiag = PP.getDiagnostics().setSeverityForGroup(
+  diag::Flavor::WarningOrError, Group, SV, DiagLoc);
+  assert(!unknownDiag &&
+ "wd table should only contain known diags");
+  (void)unknownDiag;
+}
+
 if (Callbacks)
   Callbacks->PragmaWarning(DiagLoc, Specifier, Ids);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -22,6 +22,7 @@
 #include "Hexagon.h"
 #include "MSP430.h"
 #include "PS4CPU.h"
+#include "clang/Basic/CLWarnings.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/LangOptions.h"
@@ -5443,7 +5444,24 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_R_Group);
 
-  Args.AddAllArgs(CmdArgs, options::OPT_W_Group);
+  for (const Arg *A :
+   Args.filtered(options::OPT_W_Group, options::OPT__SLASH_wd)) {
+A->claim();
+if (A->getOption().getID() == options::OPT__SLASH_wd) {
+  unsigned WarningNumber;
+  if (StringRef(A->getValue()).getAsInteger(10, WarningNumber)) {
+D.Diag(diag::err_drv_invalid_int_value)
+<< A->getAsString(Args) << A->ge

[PATCH] D110668: [clang-cl] Accept `#pragma warning(disable : N)` for some N

2021-09-28 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 375749.
thakis added a comment.

some clang-format


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

https://reviews.llvm.org/D110668

Files:
  clang/include/clang/Basic/CLWarnings.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/CLWarnings.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Driver/cl-options.c
  clang/test/Sema/pragma-warning.cpp
  llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
@@ -55,6 +55,7 @@
   sources = [
 "Attributes.cpp",
 "Builtins.cpp",
+"CLWarnings.cpp",
 "CharInfo.cpp",
 "CodeGenOptions.cpp",
 "Cuda.cpp",
Index: clang/test/Sema/pragma-warning.cpp
===
--- /dev/null
+++ clang/test/Sema/pragma-warning.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fms-extensions -fsyntax-only -verify %s
+
+[[deprecated]] void f() {} // expected-note 2 {{marked deprecated here}}
+
+#define From__pragma() \
+  __pragma(warning(push)) \
+  __pragma(warning(disable:4996)) \
+  f(); \
+  __pragma(warning(pop))
+
+void g() {
+  f(); // expected-warning {{deprecated}}
+
+#pragma warning(push)
+#pragma warning(disable: 4996)
+  f(); // no diag
+
+#pragma warning(disable: 4996)
+#pragma warning(pop)
+
+  f(); // expected-warning {{deprecated}}
+
+  From__pragma(); // no diag
+}
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -353,7 +353,7 @@
 // CHECK-C11: -std=c11
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd12345678 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/Lex/Pragma.h"
+#include "clang/Basic/CLWarnings.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticLex.h"
 #include "clang/Basic/FileManager.h"
@@ -1413,12 +1414,15 @@
   return;
 }
   }
+  PP.getDiagnostics().pushMappings(DiagLoc);
   if (Callbacks)
 Callbacks->PragmaWarningPush(DiagLoc, Level);
 } else if (II && II->isStr("pop")) {
   // #pragma warning( pop )
   PP.Lex(Tok);
-  if (Callbacks)
+  if (!PP.getDiagnostics().popMappings(DiagLoc))
+PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop);
+  else if (Callbacks)
 Callbacks->PragmaWarningPop(DiagLoc);
 } else {
   // #pragma warning( warning-specifier : warning-number-list
@@ -1470,6 +1474,11 @@
   return;
 }
 
+// Only act on disable for now.
+diag::Severity SV;
+if (Specifier == PPCallbacks::PWS_Disable)
+  SV = diag::Severity::Ignored;
+
 // Collect the warning ids.
 SmallVector Ids;
 PP.Lex(Tok);
@@ -1482,6 +1491,15 @@
   }
   Ids.push_back(int(Value));
 }
+if (SV != diag::Severity())
+  for (int Id : Ids)
+if (const char *Group = diagGroupFromCLWarningID(Id)) {
+  bool unknownDiag = PP.getDiagnostics().setSeverityForGroup(
+  diag::Flavor::WarningOrError, Group, SV, DiagLoc);
+  assert(!unknownDiag &&
+ "wd table should only contain known diags");
+  (void)unknownDiag;
+}
 if (Callbacks)
   Callbacks->PragmaWarning(DiagLoc, Specifier, Ids);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -22,6 +22,7 @@
 #include "Hexagon.h"
 #include "MSP430.h"
 #include "PS4CPU.h"
+#include "clang/Basic/CLWarnings.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/LangOptions.h"
@@ -5443,7 +5444,24 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_R_Group);
 
-  Args.AddAllArgs(CmdArgs, options::OPT_W_Group);
+  for (const Arg *A :
+   Args.filtered(options::OPT_W_Group, options::OPT__SLASH_wd)) {
+A->claim();
+if (A->getOption().getID() == options::OPT__SLASH_wd) {
+  unsigned WarningNumber;
+  if (StringRef(A->getValue()

[PATCH] D110670: [Sema] Allow comparisons between different ms ptr size address space types.

2021-09-28 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added a reviewer: aaron.ballman.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We're currently using address spaces to implement __ptr32/__ptr64 attributes;
this patch fixes a bug where clang doesn't allow types with different pointer
size attributes to be compared.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110670

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Sema/MicrosoftExtensions.cpp


Index: clang/test/Sema/MicrosoftExtensions.cpp
===
--- /dev/null
+++ clang/test/Sema/MicrosoftExtensions.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wmicrosoft -verify 
-fms-extensions
+// RUN: %clang_cc1 -triple x86_64-windows %s -fsyntax-only -Wmicrosoft -verify 
-fms-extensions
+// expected-no-diagnostics
+
+// Check that __ptr32/__ptr64 can be compared.
+int test_ptr_comparison(int * __ptr32 __uptr p32u, int * __ptr32 __sptr p32s,
+ int * __ptr64 p64) {
+  return (p32u == p32s) +
+ (p32u == p64) +
+ (p32s == p64);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6674,8 +6674,15 @@
   } else if (Steps.size() == 1) {
 bool MaybeQ1 = Q1.isAddressSpaceSupersetOf(Q2);
 bool MaybeQ2 = Q2.isAddressSpaceSupersetOf(Q1);
-if (MaybeQ1 == MaybeQ2)
-  return QualType(); // No unique best address space.
+if (MaybeQ1 == MaybeQ2) {
+  // Exception for ptr size address spaces. Should be able to choose
+  // either address space during comparison.
+  if (isPtrSizeAddressSpace(Q1.getAddressSpace()) ||
+  isPtrSizeAddressSpace(Q2.getAddressSpace()))
+MaybeQ1 = true;
+  else
+return QualType(); // No unique best address space.
+}
 Quals.setAddressSpace(MaybeQ1 ? Q1.getAddressSpace()
   : Q2.getAddressSpace());
   } else {


Index: clang/test/Sema/MicrosoftExtensions.cpp
===
--- /dev/null
+++ clang/test/Sema/MicrosoftExtensions.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+// RUN: %clang_cc1 -triple x86_64-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+// expected-no-diagnostics
+
+// Check that __ptr32/__ptr64 can be compared.
+int test_ptr_comparison(int * __ptr32 __uptr p32u, int * __ptr32 __sptr p32s,
+ int * __ptr64 p64) {
+  return (p32u == p32s) +
+ (p32u == p64) +
+ (p32s == p64);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6674,8 +6674,15 @@
   } else if (Steps.size() == 1) {
 bool MaybeQ1 = Q1.isAddressSpaceSupersetOf(Q2);
 bool MaybeQ2 = Q2.isAddressSpaceSupersetOf(Q1);
-if (MaybeQ1 == MaybeQ2)
-  return QualType(); // No unique best address space.
+if (MaybeQ1 == MaybeQ2) {
+  // Exception for ptr size address spaces. Should be able to choose
+  // either address space during comparison.
+  if (isPtrSizeAddressSpace(Q1.getAddressSpace()) ||
+  isPtrSizeAddressSpace(Q2.getAddressSpace()))
+MaybeQ1 = true;
+  else
+return QualType(); // No unique best address space.
+}
 Quals.setAddressSpace(MaybeQ1 ? Q1.getAddressSpace()
   : Q2.getAddressSpace());
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-09-28 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added a comment.

In D102107#3028386 , @ronlieb wrote:

> i backed up to your reverted patch, and applied this one.
> I see some new errors
>
>   libomptarget :: amdgcn-amd-amdhsa :: mapping/declare_mapper_target.cpp
>   libomptarget :: amdgcn-amd-amdhsa :: mapping/declare_mapper_target_data.cpp
>   libomptarget :: amdgcn-amd-amdhsa :: 
> mapping/declare_mapper_target_data_enter_exit.cpp
>   libomptarget :: amdgcn-amd-amdhsa :: 
> mapping/declare_mapper_target_update.cpp
>   libomptarget :: amdgcn-amd-amdhsa :: offloading/parallel_offloading_map.cpp
>   libomptarget :: amdgcn-amd-amdhsa :: offloading/taskloop_offload_nowait.cpp
>
> Dont know if Jon is around, so i will ask Singh @pdhaliwal if he can dig into 
> it a bit more.

Hmm, thanks @ronlieb, @pdhaliwal  please let me know what fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path

2021-09-28 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

NB: summary has x86_64-known rather than x86_64-unknown in a couple of places


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110276: Clean up large copies of binaries copied into temp directories in tests

2021-09-28 Thread Teresa Johnson 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 rGd87bdc272ba4: Clean up large copies of binaries copied into 
temp directories in tests (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110276

Files:
  clang/test/Driver/clang_f_opts.c
  lld/test/COFF/pdb-relative-source-lines.test


Index: lld/test/COFF/pdb-relative-source-lines.test
===
--- lld/test/COFF/pdb-relative-source-lines.test
+++ lld/test/COFF/pdb-relative-source-lines.test
@@ -41,6 +41,9 @@
 RUN: ./lld-link -debug -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb 
pdb_lines_1_relative.obj pdb_lines_2_relative.obj
 RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms 
-subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=ABSOLUTE %s
 
+Clean up copy of large binary copied into temp directory to avoid bloat.
+RUN: rm ./lld-link
+
 CHECK-LABEL:  - Module:  'c:\src\pdb_lines_1_relative.obj'
 CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_1_relative.obj'
 CHECK:  SourceFiles:
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -565,6 +565,8 @@
 // RUN: cp %clang "%t.r/with spaces/clang"
 // RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux 
-frecord-gcc-switches %s 2>&1 | FileCheck 
-check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ 
spaces{{.+}}"
+// Clean up copy of large binary copied into temp directory to avoid bloat.
+// RUN: rm "%t.r/with spaces/clang"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | 
FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck 
-check-prefix=CHECK-TRIVIAL-PATTERN %s


Index: lld/test/COFF/pdb-relative-source-lines.test
===
--- lld/test/COFF/pdb-relative-source-lines.test
+++ lld/test/COFF/pdb-relative-source-lines.test
@@ -41,6 +41,9 @@
 RUN: ./lld-link -debug -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj
 RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=ABSOLUTE %s
 
+Clean up copy of large binary copied into temp directory to avoid bloat.
+RUN: rm ./lld-link
+
 CHECK-LABEL:  - Module:  'c:\src\pdb_lines_1_relative.obj'
 CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_1_relative.obj'
 CHECK:  SourceFiles:
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -565,6 +565,8 @@
 // RUN: cp %clang "%t.r/with spaces/clang"
 // RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
+// Clean up copy of large binary copied into temp directory to avoid bloat.
+// RUN: rm "%t.r/with spaces/clang"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d87bdc2 - Clean up large copies of binaries copied into temp directories in tests

2021-09-28 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2021-09-28T17:04:09-07:00
New Revision: d87bdc272ba47b7d9109ff5c7191454ab2ae6fcb

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

LOG: Clean up large copies of binaries copied into temp directories in tests

In looking at the disk space used by a ninja check-all, I found that a
few of the largest files were copies of clang and lld made into temp
directories by a couple of tests. These tests were added in D53021 and
D74811. Clean up these copies after usage.

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

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c
lld/test/COFF/pdb-relative-source-lines.test

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 487ae08250396..2405fc9f0327e 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -565,6 +565,8 @@
 // RUN: cp %clang "%t.r/with spaces/clang"
 // RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux 
-frecord-gcc-switches %s 2>&1 | FileCheck 
-check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ 
spaces{{.+}}"
+// Clean up copy of large binary copied into temp directory to avoid bloat.
+// RUN: rm "%t.r/with spaces/clang"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | 
FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck 
-check-prefix=CHECK-TRIVIAL-PATTERN %s

diff  --git a/lld/test/COFF/pdb-relative-source-lines.test 
b/lld/test/COFF/pdb-relative-source-lines.test
index cc241c7ee4d7c..2a131dd39f561 100644
--- a/lld/test/COFF/pdb-relative-source-lines.test
+++ b/lld/test/COFF/pdb-relative-source-lines.test
@@ -41,6 +41,9 @@ Also check without -pdbsourcepath
 RUN: ./lld-link -debug -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb 
pdb_lines_1_relative.obj pdb_lines_2_relative.obj
 RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms 
-subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=ABSOLUTE %s
 
+Clean up copy of large binary copied into temp directory to avoid bloat.
+RUN: rm ./lld-link
+
 CHECK-LABEL:  - Module:  'c:\src\pdb_lines_1_relative.obj'
 CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_1_relative.obj'
 CHECK:  SourceFiles:



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


[PATCH] D110364: [clang] Rework dontcall attributes

2021-09-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D110364#3028995 , @thakis wrote:

> Looks like this breaks tests on windows: 
> http://45.33.8.238/win/46089/step_7.txt
>
> Please take a look, and revert for now if it takes a while to fix.

Should be fixed with 2d56fbf6cd16bb 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110364

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


[clang] 2d56fbf - [test] Specify triple in backend-attribute-error-warning.cpp

2021-09-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-09-28T17:00:10-07:00
New Revision: 2d56fbf6cd16bb7d2ae6c726b37d2096b9bdcd5a

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

LOG: [test] Specify triple in backend-attribute-error-warning.cpp

Tests fail on Windows otherwise.

Added: 


Modified: 
clang/test/Frontend/backend-attribute-error-warning.cpp

Removed: 




diff  --git a/clang/test/Frontend/backend-attribute-error-warning.cpp 
b/clang/test/Frontend/backend-attribute-error-warning.cpp
index 0338fe4131d17..9e3fac8fcd7a6 100644
--- a/clang/test/Frontend/backend-attribute-error-warning.cpp
+++ b/clang/test/Frontend/backend-attribute-error-warning.cpp
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -verify=expected,enabled -emit-codegen-only %s
-// RUN: %clang_cc1 -verify -emit-codegen-only -Wno-attribute-warning %s
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -verify=expected,enabled 
-emit-codegen-only %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -emit-codegen-only 
-Wno-attribute-warning %s
 
 __attribute__((error("oh no foo"))) void foo(void);
 



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


[PATCH] D109902: [PowerPC] Improved codegen related to xscvdpsxws/xscvdpuxws

2021-09-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

I really don't understand what happened now. It seems that you have simply 
reverted to an older version of this patch. The test case appears to not have 
been pre-committed any longer, the Power9 patterns and test cases are gone. 
What has happened here?


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

https://reviews.llvm.org/D109902

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


[PATCH] D110364: [clang] Rework dontcall attributes

2021-09-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on windows: http://45.33.8.238/win/46089/step_7.txt

Please take a look, and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110364

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


[PATCH] D106550: [PowerPC] Allow MMA built-ins to accept restrict and volatile qualified pointers

2021-09-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai 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/D106550/new/

https://reviews.llvm.org/D106550

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


[clang-tools-extra] 5cf0606 - [clang] Let PPCallbacks::PragmaWarning() pass specifier as enum instead of string

2021-09-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-28T19:47:27-04:00
New Revision: 5cf0606140974b7560490778725c134eb35f0cc7

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

LOG: [clang] Let PPCallbacks::PragmaWarning() pass specifier as enum instead of 
string

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
clang-tools-extra/pp-trace/PPCallbacksTracker.h
clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
clang/include/clang/Lex/PPCallbacks.h
clang/lib/Frontend/PrintPreprocessedOutput.cpp
clang/lib/Lex/Pragma.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp 
b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 23765da1b46f5..a75fca13e2e5a 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -234,7 +234,8 @@ void ExpandModularHeadersPPCallbacks::PragmaOpenCLExtension(
   parseToLocation(NameLoc);
 }
 void ExpandModularHeadersPPCallbacks::PragmaWarning(SourceLocation Loc,
-StringRef, ArrayRef) {
+PragmaWarningSpecifier,
+ArrayRef) {
   parseToLocation(Loc);
 }
 void ExpandModularHeadersPPCallbacks::PragmaWarningPush(SourceLocation Loc,

diff  --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h 
b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
index fe1b00b4680a1..6fdc8bd21c6bd 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
@@ -94,7 +94,8 @@ class ExpandModularHeadersPPCallbacks : public PPCallbacks {
   SrcMgr::CharacteristicKind) override;
   void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *,
  SourceLocation StateLoc, unsigned) override;
-  void PragmaWarning(SourceLocation Loc, StringRef, ArrayRef) override;
+  void PragmaWarning(SourceLocation Loc, PragmaWarningSpecifier,
+ ArrayRef) override;
   void PragmaWarningPush(SourceLocation Loc, int) override;
   void PragmaWarningPop(SourceLocation Loc) override;
   void PragmaAssumeNonNullBegin(SourceLocation Loc) override;

diff  --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp 
b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
index 8f646f75c5fb6..63faae651998d 100644
--- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
+++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
@@ -78,6 +78,12 @@ static const char *const PragmaMessageKindStrings[] = {
   "PMK_Message", "PMK_Warning", "PMK_Error"
 };
 
+// PragmaWarningSpecifier strings.
+static const char *const PragmaWarningSpecifierStrings[] = {
+"PWS_Default", "PWS_Disable", "PWS_Error",  "PWS_Once",   "PWS_Suppress",
+"PWS_Level1",  "PWS_Level2",  "PWS_Level3", "PWS_Level4",
+};
+
 // ConditionValueKind strings.
 static const char *const ConditionValueKindStrings[] = {
   "CVK_NotEvaluated", "CVK_False", "CVK_True"
@@ -267,11 +273,11 @@ void 
PPCallbacksTracker::PragmaOpenCLExtension(SourceLocation NameLoc,
 
 // Callback invoked when a #pragma warning directive is read.
 void PPCallbacksTracker::PragmaWarning(SourceLocation Loc,
-   llvm::StringRef WarningSpec,
+   PragmaWarningSpecifier WarningSpec,
llvm::ArrayRef Ids) {
   beginCallback("PragmaWarning");
   appendArgument("Loc", Loc);
-  appendArgument("WarningSpec", WarningSpec);
+  appendArgument("WarningSpec", WarningSpec, PragmaWarningSpecifierStrings);
 
   std::string Str;
   llvm::raw_string_ostream SS(Str);

diff  --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.h 
b/clang-tools-extra/pp-trace/PPCallbacksTracker.h
index 5bd334ee83f4f..db5d51b003649 100644
--- a/clang-tools-extra/pp-trace/PPCallbacksTracker.h
+++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.h
@@ -121,7 +121,7 @@ class PPCallbacksTracker : public PPCallbacks {
 diag::Severity mapping, llvm::StringRef Str) override;
   void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo 
*Name,
  SourceLocation StateLoc, unsigned State) override;
-  void PragmaWarning(SourceLocation Loc, llvm::StringRef WarningSpec,
+  void PragmaWarning(SourceLocation Loc, PragmaWarningSpecifier WarningSpec,
  

[PATCH] D110635: [clang] Let PPCallbacks::PragmaWarning() pass specifier as enum instead of string

2021-09-28 Thread Nico Weber 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 rG5cf060614097: [clang] Let PPCallbacks::PragmaWarning() pass 
specifier as enum instead of… (authored by thakis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110635

Files:
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
  clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
  clang-tools-extra/pp-trace/PPCallbacksTracker.h
  clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Lex/Pragma.cpp

Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1432,14 +1432,19 @@
 
 // Figure out which warning specifier this is.
 bool SpecifierValid;
-StringRef Specifier;
-llvm::SmallString<1> SpecifierBuf;
+PPCallbacks::PragmaWarningSpecifier Specifier;
 if (II) {
-  Specifier = II->getName();
-  SpecifierValid = llvm::StringSwitch(Specifier)
-   .Cases("default", "disable", "error", "once",
-  "suppress", true)
-   .Default(false);
+  int SpecifierInt = llvm::StringSwitch(II->getName())
+ .Case("default", PPCallbacks::PWS_Default)
+ .Case("disable", PPCallbacks::PWS_Disable)
+ .Case("error", PPCallbacks::PWS_Error)
+ .Case("once", PPCallbacks::PWS_Once)
+ .Case("suppress", PPCallbacks::PWS_Suppress)
+ .Default(-1);
+  if ((SpecifierValid = SpecifierInt != -1))
+Specifier =
+static_cast(SpecifierInt);
+
   // If we read a correct specifier, snatch next token (that should be
   // ":", checked later).
   if (SpecifierValid)
@@ -1447,9 +1452,10 @@
 } else {
   // Token is a numeric constant. It should be either 1, 2, 3 or 4.
   uint64_t Value;
-  Specifier = PP.getSpelling(Tok, SpecifierBuf);
   if (PP.parseSimpleIntegerLiteral(Tok, Value)) {
-SpecifierValid = (Value >= 1) && (Value <= 4);
+if ((SpecifierValid = (Value >= 1) && (Value <= 4)))
+  Specifier = static_cast(
+  PPCallbacks::PWS_Level1 + Value - 1);
   } else
 SpecifierValid = false;
   // Next token already snatched by parseSimpleIntegerLiteral.
Index: clang/lib/Frontend/PrintPreprocessedOutput.cpp
===
--- clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -155,7 +155,7 @@
   void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override;
   void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
 diag::Severity Map, StringRef Str) override;
-  void PragmaWarning(SourceLocation Loc, StringRef WarningSpec,
+  void PragmaWarning(SourceLocation Loc, PragmaWarningSpecifier WarningSpec,
  ArrayRef Ids) override;
   void PragmaWarningPush(SourceLocation Loc, int Level) override;
   void PragmaWarningPop(SourceLocation Loc) override;
@@ -580,10 +580,24 @@
 }
 
 void PrintPPOutputPPCallbacks::PragmaWarning(SourceLocation Loc,
- StringRef WarningSpec,
+ PragmaWarningSpecifier WarningSpec,
  ArrayRef Ids) {
   MoveToLine(Loc, /*RequireStartOfLine=*/true);
-  OS << "#pragma warning(" << WarningSpec << ':';
+
+  OS << "#pragma warning(";
+  switch(WarningSpec) {
+case PWS_Default:  OS << "default"; break;
+case PWS_Disable:  OS << "disable"; break;
+case PWS_Error:OS << "error"; break;
+case PWS_Once: OS << "once"; break;
+case PWS_Suppress: OS << "suppress"; break;
+case PWS_Level1:   OS << '1'; break;
+case PWS_Level2:   OS << '2'; break;
+case PWS_Level3:   OS << '3'; break;
+case PWS_Level4:   OS << '4'; break;
+  }
+  OS << ':';
+
   for (ArrayRef::iterator I = Ids.begin(), E = Ids.end(); I != E; ++I)
 OS << ' ' << *I;
   OS << ')';
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -252,9 +252,20 @@
   }
 
   /// Callback invoked when a \#pragma warning directive is read.
-  virtual void PragmaWarning(SourceLocation Loc, Str

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-09-28 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.
Herald added a subscriber: achieveartificialintelligence.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D110668: [clang-cl] Accept `#pragma warning(disable : N)` for some N

2021-09-28 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
thakis added a project: clang.
Herald added subscribers: dexonsmith, dang, mgorny.
thakis requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

clang-cl maps /wd to -Wno-flags for a few warnings that map
cleanly from cl.exe concepts to clang concepts.

This patch adds support for the same numbers to
`#pragma warning(disable : )`. It also lets
`#pragma warning(push)` and `#pragma warning(pop)` have an effect,
since these are used together with `warning(disable)`.

The optional numeric argument to `warning(push)` is ignored,
as are the other non-`disable` `pragma warning()` arguments.
(Supporting `error` would be easy, but we also don't support
`/we`, and those should probably be added together.)

The motivating example is that a bunch of code (including in LLVM)
uses this idiom to locally disable warnings about calls to deprecated
functions in Windows-only code, and 4996 maps nicely to
-Wno-deprecated-declarations:

  #pragma warning(push)
  #pragma warning(disable: 4996)
f();
  #pragma warning(pop)

Implementation-wise:

- Move `/wd` flag handling from Options.td to actual Driver-level code
- Extract the function mapping cl.exe IDs to warning groups to the new file 
clang/lib/Basic/CLWarnings.cpp
- Call that new function from the PragmaWarning handler


https://reviews.llvm.org/D110668

Files:
  clang/include/clang/Basic/CLWarnings.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/CLWarnings.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Driver/cl-options.c
  clang/test/Sema/pragma-warning.cpp
  llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
@@ -55,6 +55,7 @@
   sources = [
 "Attributes.cpp",
 "Builtins.cpp",
+"CLWarnings.cpp",
 "CharInfo.cpp",
 "CodeGenOptions.cpp",
 "Cuda.cpp",
Index: clang/test/Sema/pragma-warning.cpp
===
--- /dev/null
+++ clang/test/Sema/pragma-warning.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fms-extensions -fsyntax-only -verify %s
+
+[[deprecated]] void f() {} // expected-note 2 {{marked deprecated here}}
+
+#define From__pragma() \
+  __pragma(warning(push)) \
+  __pragma(warning(disable:4996)) \
+  f(); \
+  __pragma(warning(pop))
+
+void g() {
+  f(); // expected-warning {{deprecated}}
+
+#pragma warning(push)
+#pragma warning(disable: 4996)
+  f(); // no diag
+
+#pragma warning(disable: 4996)
+#pragma warning(pop)
+
+  f(); // expected-warning {{deprecated}}
+
+  From__pragma(); // no diag
+}
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -353,7 +353,7 @@
 // CHECK-C11: -std=c11
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd12345678 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/Lex/Pragma.h"
+#include "clang/Basic/CLWarnings.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticLex.h"
 #include "clang/Basic/FileManager.h"
@@ -1413,12 +1414,15 @@
   return;
 }
   }
+  PP.getDiagnostics().pushMappings(DiagLoc);
   if (Callbacks)
 Callbacks->PragmaWarningPush(DiagLoc, Level);
 } else if (II && II->isStr("pop")) {
   // #pragma warning( pop )
   PP.Lex(Tok);
-  if (Callbacks)
+  if (!PP.getDiagnostics().popMappings(DiagLoc))
+PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop);
+  else if (Callbacks)
 Callbacks->PragmaWarningPop(DiagLoc);
 } else {
   // #pragma warning( warning-specifier : warning-number-list
@@ -1470,6 +1474,11 @@
   return;
 }
 
+// Only act on disable for now.
+diag::Severity SV;
+if (Specifier == PPCallbacks::PWS_Disable)
+  SV = diag::Severity::Ignored;
+
 // Collect the warning ids.
 SmallVector Ids;
 PP.Lex(Tok);
@@ -1482,6 +1491,14 @@
   }
   Ids.push_back(int(Value));
 }
+if (SV != diag::Severity())
+  for (int Id : Ids)
+

[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2021-09-28 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added inline comments.



Comment at: clang/include/clang/Basic/Sarif.h:95
+//
+/// Since every in clang artifact MUST have a location (there being no nested
+/// artifacts), the creation method \ref SarifArtifact::create requires a

aaron.ballman wrote:
> How do we expect to handle artifact locations that don't correspond directly 
> to a file? For example, the user can specify macros on the command line and 
> those macros could have a diagnostic result associated with them. Can we 
> handle that sort of scenario?
I hadn't considered `-D` macros. Definitely a valid case to handle. I will 
respond with more information once I read through the related portions of the 
SARIF spec. A (sort of hacky?) solution come to mind after a quick glance:

Setting the artifact URI to: `data:text/plain:` with an offset, and 
saying that it's role is `"referencedOnCommandLine"`. It seems strange since we 
need to copy over the command line, instead of referencing it directly. What do 
you think: 
https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317617

Dropping a TODO comment so I can update later.

`TODO(envp)`



Comment at: clang/include/clang/Basic/Sarif.h:109
+  SarifArtifactLocation Location;
+  SmallVector Roles;
+

aaron.ballman wrote:
> What size would you like this `SmallVector` to have?
Glancing through valid values for roles: my expectation is that each artifact 
will have a _small_ number of roles associated, so `4` seems like a good 
threshold here. I don't really have a strong opinion on the size, so I'm open 
to changing this.



Comment at: clang/include/clang/Basic/Sarif.h:250
+
+  SarifResult() = default;
+

aaron.ballman wrote:
> A default constructed `SarifResult` will have an uninitialized `RuleIdx` -- 
> are you okay with that?
Hrm, I had overlooked that case (since `appendResult` took and index and a 
rule). I'll make it take a rule index upon construction. This will also make it 
so that `appendResult` takes just the `SarifResult`, and not an (Idx, Result), 
which is definitely an artifact of before I added RuleIdx to `SarifResult`.




Comment at: clang/include/clang/Basic/Sarif.h:297-298
+  /// \internal
+  /// Return a pointer to the current tool. If no run exists, this will
+  /// crash.
+  json::Object *getCurrentTool();

aaron.ballman wrote:
> 
Thanks for rewording. I'll also make this return a reference, since the pointer 
returned cannot be null.



Comment at: clang/include/clang/Basic/Sarif.h:388-389
+private:
+  /// Langauge options to use for the current SARIF document
+  const LangOptions *LangOpts;
+

aaron.ballman wrote:
> I think this should be a value type rather than a possibly null pointer type 
> -- this way, the document can always rely on there being valid language 
> options to check, and if the user provides no custom language options, the 
> default `LangOptions` suffice. Alternatively, it seems reasonable to expect 
> the user to have to pass in a valid language options object in order to 
> create a SARIF document. WDYT?
I agree with that, will change it to store an owned value.

I think leaving the two constructors as is is fine as long as the `default` 
variant will also leave `LangOpts` in a valid state.



Comment at: clang/lib/Basic/Sarif.cpp:207-209
+if (statusIter.second) {
+  I = statusIter.first;
+}

aaron.ballman wrote:
> Our usual coding style elides these too. Btw, you can find the coding style 
> document at: https://llvm.org/docs/CodingStandards.html
Thanks, sorry there's so many of these! I definitely need to not auto-pilot 
with style.



Comment at: clang/lib/Basic/Sarif.cpp:219-222
+json::Object *SarifDocumentWriter::getCurrentTool() {
+  assert(hasRun() && "Need to call createRun() before using getcurrentTool!");
+  return Runs.back().getAsObject()->get("tool")->getAsObject();
+}

aaron.ballman wrote:
> Should this return a reference rather than a pointer?
Makes sense to convert to a ref, the pointer returned can never be null anyway



Comment at: clang/lib/Basic/Sarif.cpp:230-232
+  if (!hasRun()) {
+return;
+  }

aaron.ballman wrote:
> Is there a reason why we don't want to assert instead?
Creating a document requires ending any ongoing runs, and it is valid to create 
a document without any runs, so `createDocument()` calls `endRun()`.

I guess having a flag to mark the status of the document, and only calling 
`endRun()` if a an active run exists would likely be better. (`hasRun()` seems 
to have a rather broad responsibility, tracking both the availability & state 
of the current run)

I'm thinking of adding a `Closed` flag to the writer (default `true`), which is 
unset whenever `createRun()` is called, and `endRun()` will set the same flag.

[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2021-09-28 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y updated this revision to Diff 375734.
vaibhav.y marked 34 inline comments as done.
vaibhav.y added a comment.

Address comments from upstream review:

- Mark anonymous functions static, improve documentation
- Coding style fixes
- Use Ref types as they are intended (as non-owning lightweight refs)
- SarifDocumentWriter now stores a copy of `clang::LangOptions` passed to it
- getCurrentTool, getCurrentRun return mutable refs instead of raw pointers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

Files:
  clang/include/clang/Basic/Sarif.h
  clang/include/clang/Basic/SourceLocation.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Sarif.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/SarifTest.cpp

Index: clang/unittests/Basic/SarifTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/SarifTest.cpp
@@ -0,0 +1,153 @@
+//===- unittests/Basic/SarifTest.cpp - Test writing SARIF documents ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/Sarif.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include 
+
+#include "gmock/gmock.h"
+#include "gtest/gtest-death-test.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace llvm;
+
+namespace {
+
+TEST(SarifDocumentWriterTest, createEmptyDocument) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+
+  // WHEN:
+  const json::Object &emptyDocument = writer.createDocument();
+  std::vector keys(emptyDocument.size());
+  std::transform(emptyDocument.begin(), emptyDocument.end(), keys.begin(),
+ [](auto item) { return item.getFirst(); });
+
+  // THEN:
+  ASSERT_THAT(keys, testing::UnorderedElementsAre("$schema", "version"));
+}
+
+// Test that a newly inserted run will associate correct tool names
+TEST(SarifDocumentWriterTest, documentWithARun) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+  const char *shortName = "sariftest";
+  const char *longName = "sarif writer test";
+
+  // WHEN:
+  writer.createRun(shortName, longName);
+  writer.endRun();
+  const json::Object &document = writer.createDocument();
+  const json::Array *runs = document.getArray("runs");
+
+  // THEN:
+  // A run was created
+  ASSERT_THAT(runs, testing::NotNull());
+
+  // It is the only run
+  ASSERT_EQ(runs->size(), 1UL);
+
+  // The tool associated with the run was the tool
+  const json::Object *driver =
+  runs->begin()->getAsObject()->getObject("tool")->getObject("driver");
+  ASSERT_THAT(driver, testing::NotNull());
+
+  ASSERT_TRUE(driver->getString("name").hasValue());
+  ASSERT_TRUE(driver->getString("fullName").hasValue());
+  ASSERT_TRUE(driver->getString("language").hasValue());
+
+  EXPECT_EQ(driver->getString("name").getValue(), shortName);
+  EXPECT_EQ(driver->getString("fullName").getValue(), longName);
+  EXPECT_EQ(driver->getString("language").getValue(), "en-US");
+}
+
+// Test adding result without a run causes a crash
+TEST(SarifDocumentWriterTest, addingResultsWillCrashIfThereIsNoRun) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+  SarifResult &&emptyResult = SarifResult::create();
+
+  // WHEN:
+  //  A SarifDocumentWriter::createRun(...) was not called prior to
+  //  SarifDocumentWriter::appendResult(...)
+  // But a rule exists
+  auto ruleIdx = writer.createRule(SarifRule::create());
+
+  // THEN:
+  ASSERT_DEATH({ writer.appendResult(ruleIdx, emptyResult); },
+   ".*create a run first.*");
+}
+
+// Test adding result for invalid ruleIdx causes a crash
+TEST(SarifDocumentWriterTest, addingResultsWithoutRuleWillCrash) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+  SarifResult &&emptyResult = SarifResult::create();
+
+  // WHEN:
+  writer.createRun("sarif test", "sarif test runner");
+  // But caller forgot to create a rule for this run:
+
+  // THEN:
+  ASSERT_DEATH({ writer.appendResult(0, emptyResult); },
+   "Trying to reference a rule that doesn't exist");
+}
+
+// Test adding rule and result shows up in the final document
+TEST(SarifDocumentWriterTest, addResultWIthValidRuleIsOk) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+  const SarifResult &result = SarifResult::create();
+  const SarifRule &rule =
+  SarifRule::create()
+  .setRuleId("clang.unittest")
+  .setDescription("Example rule created during unit tests")
+  .setName("clang unit test");
+
+  // WHEN:
+  writer.createRun("sarif test", "sarif test runner");
+  unsigned ruleIdx = writer.createRule(rule);
+  writer.appendResult(ruleIdx, result);
+  const json::Object &document = writer.createDocument();

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path

2021-09-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This doesn't help the world-breaking D107799  
on debian for me.
I don't know if this stands on it's own.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110665: [clang] Don't use the AST to display backend diagnostics

2021-09-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks added reviewers: dblaikie, rnk.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We keep a map from function name to source location so we don't have to
do it via looking up a source location from the AST. However, since
function names can be long, we actually use a hash of the function name
as the key.

Additionally, we can't rely on Clang's printing of function names via
the AST, so we just demangle the name instead.

This is necessary to implement
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068930.html.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110665

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/Frontend/backend-diagnostic.c
  clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp
  clang/test/Misc/backend-stack-frame-diagnostics.cpp

Index: clang/test/Misc/backend-stack-frame-diagnostics.cpp
===
--- clang/test/Misc/backend-stack-frame-diagnostics.cpp
+++ clang/test/Misc/backend-stack-frame-diagnostics.cpp
@@ -26,7 +26,7 @@
 
 void frameSizeWarning();
 
-void frameSizeWarning() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in function 'frameSizeWarning'}}
+void frameSizeWarning() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in frameSizeWarning()}}
   char buffer[80];
   doIt(buffer);
 }
@@ -45,7 +45,7 @@
 
 void frameSizeLocalClassWarning() {
   struct S {
-S() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in function 'frameSizeLocalClassWarning()::S::S'}}
+S() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in frameSizeLocalClassWarning()::S::S()}}
   char buffer[80];
   doIt(buffer);
 }
@@ -55,7 +55,7 @@
 
 void frameSizeLambdaWarning() {
   auto fn =
-  []() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in lambda expression}}
+  []() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in frameSizeLambdaWarning()::$_0::operator()()}}
 char buffer[80];
 doIt(buffer);
   };
@@ -64,7 +64,7 @@
 
 void frameSizeBlocksWarning() {
   auto fn =
-  ^() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in block literal}}
+  ^() { // expected-warning-re {{stack frame size ({{[0-9]+}}) exceeds limit ({{[0-9]+}}) in invocation function for block in frameSizeBlocksWarning()}}
 char buffer[80];
 doIt(buffer);
   };
Index: clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp
===
--- clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp
+++ clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp
@@ -12,7 +12,7 @@
 virtual void f();
   };
 
-  // CHECK: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in function 'frameSizeThunkWarning::B::f'
+  // CHECK: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in frameSizeThunkWarning::B::f()
   // CHECK: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in function '_ZTv0_n12_N21frameSizeThunkWarning1B1fEv'
   void B::f() {
 volatile int x = 0; // Ensure there is stack usage.
Index: clang/test/Frontend/backend-diagnostic.c
===
--- clang/test/Frontend/backend-diagnostic.c
+++ clang/test/Frontend/backend-diagnostic.c
@@ -15,9 +15,9 @@
 
 extern void doIt(char *);
 
-// REGULAR: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in function 'stackSizeWarning'
-// PROMOTE: error: stack frame size ([[#]]) exceeds limit ([[#]]) in function 'stackSizeWarning'
-// IGNORE-NOT: stack frame size ([[#]]) exceeds limit ([[#]]) in function 'stackSizeWarning'
+// REGULAR: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in stackSizeWarning
+// PROMOTE: error: stack frame size ([[#]]) exceeds limit ([[#]]) in stackSizeWarning
+// IGNORE-NOT: stack frame size ([[#]]) exceeds limit ([[#]]) in stackSizeWarning
 void stackSizeWarning() {
   char buffer[80];
   doIt(buffer);
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -25,6 +25,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
 #include "llvm/Demangle/Demangle.h"
@@ -125,6 +126,8 @@
 std::unique_ptr Gen;
 
 SmallVector LinkModules;
+std::vector>
+ManglingFullSourceLocs;
 
 // This is here so that 

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path

2021-09-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:494
+  std::string Ret(P);
+  // When LLVM_DEFAULT_TARGET_TRIPLE uses Debian multiarch style
+  // "x86_64-linux-gnu" (no vendor part), use the unnormalized

This is effectively reverting the change to this function made in D101194 (and 
amended in rG36430d44edba), except it prefers the normalized triple over the 
unnormalized triple, right? Does `getStdlibPath` need to be changed as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110481: fixes bug #51926 where dangling comma caused overrun

2021-09-28 Thread Fred Grim 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 rGa36227cb2b6a: fixes bug #51926 where dangling comma caused 
overrun (authored by feg208).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110481

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17800,13 +17800,25 @@
 TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) {
   auto Style = getLLVMStyle();
   Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
+  /* FIXME: This case gets misformatted.
+  verifyFormat("auto foo = Items{\n"
+   "Section{0, bar(), },\n"
+   "Section{1, boo()  }\n"
+   "};\n",
+   Style);
+  */
+  verifyFormat("auto foo = Items{\n"
+   "Section{\n"
+   "0, bar(),\n"
+   "}\n"
+   "};\n",
+   Style);
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"},\n"
"{-1, 93463, \"world\"},\n"
"{7,  5, \"!!\"   }\n"
"};\n",
Style);
-
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"}, // first line\n"
"{-1, 93463, \"world\"}, // second line\n"
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1146,14 +1146,15 @@
   } else if (C.Tok->is(tok::comma)) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
-Cell++;
+if (C.Tok->getNextNonComment()->isNot(tok::r_brace)) // dangling comma
+  ++Cell;
   }
 } else if (Depth == 1) {
   if (C.Tok == MatchingParen) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
 Cells.push_back(CellDescription{i, ++Cell, i + 1, false, nullptr});
-CellCount = Cell + 1;
+CellCount = C.Tok->Previous->isNot(tok::comma) ? Cell + 1 : Cell;
 // Go to the next non-comment and ensure there is a break in front
 const auto *NextNonComment = C.Tok->getNextNonComment();
 while (NextNonComment->is(tok::comma))
@@ -1190,6 +1191,17 @@
 // So if we split a line previously and the tail line + this token is
 // less then the column limit we remove the split here and just put
 // the column start at a space past the comma
+//
+// FIXME This if branch covers the cases where the column is not
+// the first column. This leads to weird pathologies like the 
formatting
+// auto foo = Items{
+// Section{
+// 0, bar(),
+// }
+// };
+// Well if it doesn't lead to that it's indicative that the line
+// breaking should be revisited. Unfortunately alot of other options
+// interact with this
 auto j = i - 1;
 if ((j - 1) > Start && Changes[j].Tok->is(tok::comma) &&
 Changes[j - 1].NewlinesBefore > 0) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17800,13 +17800,25 @@
 TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) {
   auto Style = getLLVMStyle();
   Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
+  /* FIXME: This case gets misformatted.
+  verifyFormat("auto foo = Items{\n"
+   "Section{0, bar(), },\n"
+   "Section{1, boo()  }\n"
+   "};\n",
+   Style);
+  */
+  verifyFormat("auto foo = Items{\n"
+   "Section{\n"
+   "0, bar(),\n"
+   "}\n"
+   "};\n",
+   Style);
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"},\n"
"{-1, 93463, \"world\"},\n"
"{7,  5, \"!!\"   }\n"
"};\n",
Style);
-
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"}, // first line\n"
"{-1, 93463, \"world\"}, // second line\n"
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1146,14 +1146,15 @@
   } else if (C.Tok->is(tok::comma)) {
 if (!Cells.empty())
   Cells.b

[clang] a36227c - fixes bug #51926 where dangling comma caused overrun

2021-09-28 Thread Fred Grim via cfe-commits

Author: Fred Grim
Date: 2021-09-28T15:59:37-07:00
New Revision: a36227cb2b6a14fc30bfd303328d1d1abb632010

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

LOG: fixes bug #51926 where dangling comma caused overrun

bug 51926 identified an issue where a dangling comma caused the cell count to 
be to off by one

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

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index a822e0aaf1f93..74136d2f5caa1 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1146,14 +1146,15 @@ WhitespaceManager::CellDescriptions 
WhitespaceManager::getCells(unsigned Start,
   } else if (C.Tok->is(tok::comma)) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
-Cell++;
+if (C.Tok->getNextNonComment()->isNot(tok::r_brace)) // dangling comma
+  ++Cell;
   }
 } else if (Depth == 1) {
   if (C.Tok == MatchingParen) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
 Cells.push_back(CellDescription{i, ++Cell, i + 1, false, nullptr});
-CellCount = Cell + 1;
+CellCount = C.Tok->Previous->isNot(tok::comma) ? Cell + 1 : Cell;
 // Go to the next non-comment and ensure there is a break in front
 const auto *NextNonComment = C.Tok->getNextNonComment();
 while (NextNonComment->is(tok::comma))
@@ -1190,6 +1191,17 @@ WhitespaceManager::CellDescriptions 
WhitespaceManager::getCells(unsigned Start,
 // So if we split a line previously and the tail line + this token is
 // less then the column limit we remove the split here and just put
 // the column start at a space past the comma
+//
+// FIXME This if branch covers the cases where the column is not
+// the first column. This leads to weird pathologies like the 
formatting
+// auto foo = Items{
+// Section{
+// 0, bar(),
+// }
+// };
+// Well if it doesn't lead to that it's indicative that the line
+// breaking should be revisited. Unfortunately alot of other options
+// interact with this
 auto j = i - 1;
 if ((j - 1) > Start && Changes[j].Tok->is(tok::comma) &&
 Changes[j - 1].NewlinesBefore > 0) {

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 1c0db59dfd8cf..737cea0291eba 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -17800,13 +17800,25 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresRightAlignment) {
 TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) {
   auto Style = getLLVMStyle();
   Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
+  /* FIXME: This case gets misformatted.
+  verifyFormat("auto foo = Items{\n"
+   "Section{0, bar(), },\n"
+   "Section{1, boo()  }\n"
+   "};\n",
+   Style);
+  */
+  verifyFormat("auto foo = Items{\n"
+   "Section{\n"
+   "0, bar(),\n"
+   "}\n"
+   "};\n",
+   Style);
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"},\n"
"{-1, 93463, \"world\"},\n"
"{7,  5, \"!!\"   }\n"
"};\n",
Style);
-
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"}, // first line\n"
"{-1, 93463, \"world\"}, // second line\n"



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


[PATCH] D110625: [analyzer] canonicalize special case of structure/pointer deref

2021-09-28 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 375727.
vabridgers added a comment.

improve test cases per @martong


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110625

Files:
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/ptr-arith.c


Index: clang/test/Analysis/ptr-arith.c
===
--- clang/test/Analysis/ptr-arith.c
+++ clang/test/Analysis/ptr-arith.c
@@ -330,3 +330,26 @@
   simd_float2 x = {0, 1};
   return x[1]; // no-warning
 }
+
+struct s {
+  int v;
+  char y;
+};
+
+void clang_analyzer_dump(int);
+
+// These three expressions should produce the same sym vals.
+void struct_pointer_canon(struct s *ps) {
+  struct s ss = *ps;
+  clang_analyzer_dump((*ps).v);// expected-warning{{reg_$3}.v>}}
+  clang_analyzer_dump(ps[0].v);// expected-warning{{reg_$3}.v>}}
+  clang_analyzer_dump(ps->v);  // expected-warning{{reg_$3}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang_analyzer_eval((*ps).v == ps->v);   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ps[0].v == ps->v);   // expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_bidim(struct s **ps) {
+  struct s ss = **ps;
+  clang_analyzer_eval(&(ps[0][0].v) == &((*ps)->v)); // 
expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -442,6 +442,15 @@
 
 SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset,
 SVal Base) {
+
+  // Special case, if index is 0, return the same type as if
+  // this was not an array dereference.
+  if (Offset.isZeroConstant()) {
+QualType BT = Base.getType(this->Ctx);
+if (!BT.isNull() && BT->getPointeeType() == elementType)
+  return Base;
+  }
+
   // If the base is an unknown or undefined value, just return it back.
   // FIXME: For absolute pointer addresses, we just return that value back as
   //  well, although in reality we should return the offset added to that


Index: clang/test/Analysis/ptr-arith.c
===
--- clang/test/Analysis/ptr-arith.c
+++ clang/test/Analysis/ptr-arith.c
@@ -330,3 +330,26 @@
   simd_float2 x = {0, 1};
   return x[1]; // no-warning
 }
+
+struct s {
+  int v;
+  char y;
+};
+
+void clang_analyzer_dump(int);
+
+// These three expressions should produce the same sym vals.
+void struct_pointer_canon(struct s *ps) {
+  struct s ss = *ps;
+  clang_analyzer_dump((*ps).v);// expected-warning{{reg_$3}.v>}}
+  clang_analyzer_dump(ps[0].v);// expected-warning{{reg_$3}.v>}}
+  clang_analyzer_dump(ps->v);  // expected-warning{{reg_$3}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang_analyzer_eval((*ps).v == ps->v);   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ps[0].v == ps->v);   // expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_bidim(struct s **ps) {
+  struct s ss = **ps;
+  clang_analyzer_eval(&(ps[0][0].v) == &((*ps)->v)); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -442,6 +442,15 @@
 
 SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset,
 SVal Base) {
+
+  // Special case, if index is 0, return the same type as if
+  // this was not an array dereference.
+  if (Offset.isZeroConstant()) {
+QualType BT = Base.getType(this->Ctx);
+if (!BT.isNull() && BT->getPointeeType() == elementType)
+  return Base;
+  }
+
   // If the base is an unknown or undefined value, just return it back.
   // FIXME: For absolute pointer addresses, we just return that value back as
   //  well, although in reality we should return the offset added to that
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110625: [analyzer] canonicalize special case of structure/pointer deref

2021-09-28 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

@martong, Thanks for yes for sure! I'll post an update soon with a few minor 
test improvements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110625

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


[clang] aa53785 - Reland [clang] Rework dontcall attributes

2021-09-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-09-28T15:31:30-07:00
New Revision: aa53785f23b2b89a9a423af131697b1f7c92869f

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

LOG: Reland [clang] Rework dontcall attributes

To avoid using the AST when emitting diagnostics, split the "dontcall"
attribute into "dontcall-warn" and "dontcall-error", and also add the
frontend attribute value as the LLVM attribute value. This gives us all
the information to report diagnostics we need from within the IR (aside
from access to the original source).

One downside is we directly use LLVM's demangler rather than using the
existing Clang diagnostic pretty printing of symbols.

Previous revisions didn't properly declare the new dependencies.

Reviewed By: nickdesaulniers

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

Added: 
clang/test/Frontend/backend-attribute-error-warning.cpp

Modified: 
clang/lib/CodeGen/CMakeLists.txt
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-error.c
clang/test/CodeGen/attr-warning.c
clang/test/Frontend/backend-attribute-error-warning-optimize.c
clang/test/Frontend/backend-attribute-error-warning.c
llvm/docs/LangRef.rst
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/test/CodeGen/X86/attr-dontcall.ll
llvm/test/ThinLTO/X86/dontcall.ll
llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

Removed: 




diff  --git a/clang/lib/CodeGen/CMakeLists.txt 
b/clang/lib/CodeGen/CMakeLists.txt
index 4039277707c5f..5d493595dcd51 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   Coroutines
   Coverage
+  Demangle
   Extensions
   FrontendOpenMP
   IPO

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 789c06a15b71c..6e1d7f320673c 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -27,6 +27,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
@@ -760,30 +761,18 @@ void BackendConsumer::OptimizationFailureHandler(
 }
 
 void BackendConsumer::DontCallDiagHandler(const DiagnosticInfoDontCall &D) {
-  if (const Decl *DE = Gen->GetDeclForMangledName(D.getFunctionName()))
-if (const auto *FD = dyn_cast(DE)) {
-  assert(FD->hasAttr() &&
- "expected error or warning function attribute");
-
-  if (const auto *EA = FD->getAttr()) {
-assert((EA->isError() || EA->isWarning()) &&
-   "ErrorAttr neither error or warning");
-
-SourceLocation LocCookie =
-SourceLocation::getFromRawEncoding(D.getLocCookie());
-
-// FIXME: we can't yet diagnose indirect calls. When/if we can, we
-// should instead assert that LocCookie.isValid().
-if (!LocCookie.isValid())
-  return;
-
-Diags.Report(LocCookie, EA->isError()
-? diag::err_fe_backend_error_attr
-: diag::warn_fe_backend_warning_attr)
-<< FD << EA->getUserDiagnostic();
-  }
-}
-  // TODO: assert if DE or FD were nullptr?
+  SourceLocation LocCookie =
+  SourceLocation::getFromRawEncoding(D.getLocCookie());
+
+  // FIXME: we can't yet diagnose indirect calls. When/if we can, we
+  // should instead assert that LocCookie.isValid().
+  if (!LocCookie.isValid())
+return;
+
+  Diags.Report(LocCookie, D.getSeverity() == DiagnosticSeverity::DS_Error
+  ? diag::err_fe_backend_error_attr
+  : diag::warn_fe_backend_warning_attr)
+  << llvm::demangle(D.getFunctionName().str()) << D.getNote();
 }
 
 /// This function is invoked when the backend needs

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 83418014f0b5c..d26b1343247f0 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2138,8 +2138,12 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   else if (const auto *SA = FD->getAttr())
  F->setSection(SA->getName());
 
-  if (FD->hasAttr())
-F->addFnAttr("dontcall");
+  if (const auto *EA = FD->getAttr()) {
+if (EA->isError())
+  F->addFnAttr("dontcall-error", EA->getUserDiagnostic());
+else if (EA-

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D110663#3028811 , @sylvestre.ledru 
wrote:

> just to make sure I understand, it will also update the install or "just" the 
> dumpmachine option ?

If `LLVM_DEFAULT_TARGET_TRIPLE` is `x86_64-linux-gnu, `clang -dumpmachine` will 
still be the normalized (by `Driver.cpp:computeTargetTriple`) 
`x86_64-unknown-linux-gnu`.

This just affects the `lib/clang/14.0.0/x86_64-linux-gnu` detection which is 
used by `libclang_rt.builtins.a` (with `--rtlib=compiler-rt), and more common, 
asan/msan/etc runtime archives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110422: [AIX] Change the linkage of profiling counter/data to be private

2021-09-28 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

@MaskRay Thank you so much for your review and discussion!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 375722.
MaskRay added a comment.

add missing file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

Files:
  clang/lib/Driver/ToolChain.cpp
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/x86_64-linux-gnu/libclang_rt.builtins.a
  clang/test/Driver/linux-per-target-runtime-dir.c


Index: clang/test/Driver/linux-per-target-runtime-dir.c
===
--- clang/test/Driver/linux-per-target-runtime-dir.c
+++ clang/test/Driver/linux-per-target-runtime-dir.c
@@ -25,3 +25,10 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-FILE-NAME-X8664 %s
 // CHECK-FILE-NAME-X8664: 
lib{{/|\\}}x86_64-unknown-linux-gnu{{/|\\}}libclang_rt.builtins.a
+
+/// On Debian, LLVM_DEFAULT_TARGET_TRIPLE may use Debian multiarch style 
"x86_64-linux-gnu".
+// RUN: %clangxx -### %s --target=x86_64-linux-gnu 
--sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN:   -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir_debian \
+// RUN:   --rtlib=compiler-rt 2>&1 | FileCheck 
--check-prefix=CHECK-DEBIAN-X8664 %s
+// CHECK-DEBIAN-X8664: 
lib{{/|\\}}x86_64-linux-gnu{{/|\\}}libclang_rt.builtins.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -490,7 +490,18 @@
 std::string ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib", getTripleString());
-  return std::string(P.str());
+  std::string Ret(P);
+  // When LLVM_DEFAULT_TARGET_TRIPLE uses Debian multiarch style
+  // "x86_64-linux-gnu" (no vendor part), use the unnormalized
+  // D.getTargetTriple() instead of the normalized getTripleString()
+  // ("x86_64-unknown-linux-gnu").
+  if (!getVFS().exists(Ret)) {
+P.clear();
+llvm::sys::path::append(P, D.ResourceDir, "lib", D.getTargetTriple());
+if (getVFS().exists(P))
+  Ret = std::string(P);
+  }
+  return Ret;
 }
 
 std::string ToolChain::getStdlibPath() const {


Index: clang/test/Driver/linux-per-target-runtime-dir.c
===
--- clang/test/Driver/linux-per-target-runtime-dir.c
+++ clang/test/Driver/linux-per-target-runtime-dir.c
@@ -25,3 +25,10 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-FILE-NAME-X8664 %s
 // CHECK-FILE-NAME-X8664: lib{{/|\\}}x86_64-unknown-linux-gnu{{/|\\}}libclang_rt.builtins.a
+
+/// On Debian, LLVM_DEFAULT_TARGET_TRIPLE may use Debian multiarch style "x86_64-linux-gnu".
+// RUN: %clangxx -### %s --target=x86_64-linux-gnu --sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN:   -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir_debian \
+// RUN:   --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=CHECK-DEBIAN-X8664 %s
+// CHECK-DEBIAN-X8664: lib{{/|\\}}x86_64-linux-gnu{{/|\\}}libclang_rt.builtins.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -490,7 +490,18 @@
 std::string ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib", getTripleString());
-  return std::string(P.str());
+  std::string Ret(P);
+  // When LLVM_DEFAULT_TARGET_TRIPLE uses Debian multiarch style
+  // "x86_64-linux-gnu" (no vendor part), use the unnormalized
+  // D.getTargetTriple() instead of the normalized getTripleString()
+  // ("x86_64-unknown-linux-gnu").
+  if (!getVFS().exists(Ret)) {
+P.clear();
+llvm::sys::path::append(P, D.ResourceDir, "lib", D.getTargetTriple());
+if (getVFS().exists(P))
+  Ret = std::string(P);
+  }
+  return Ret;
 }
 
 std::string ToolChain::getStdlibPath() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375720.
expnkx added a comment.

it should first update the field and then test no_unique_address


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

https://reviews.llvm.org/D110485

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,11 +2923,18 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
+  {
 FieldOffset = CharUnits::Zero();
+  }
   else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,11 +2923,18 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
+  {
 FieldOffset = CharUnits::Zero();
+  }
   else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path

2021-09-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

just to make sure I understand, it will also update the install or "just" the 
dumpmachine option ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: phosek, sylvestre.ledru.
Herald added a subscriber: pengfei.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is needed when config.guess is removed (D109837 
) and
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on is enabled.

If LLVM_DEFAULT_TARGET_TRIPLE is Debian multiarch style "x86_64-linux-gnu"
(`gcc -dumpmachine` output), CMake will install runtime libraries to
`lib/clang/14.0.0/x86_64-linux-gnu/` but `clang --print-runtime-dir` still use
`lib/clang/14.0.0/x86_64-known-linux-gnu/` (inferred from the normalized triple:
"x86_64-known-linux-gnu").

Alternative: it would probably be nice to not normalize triples in
`Driver.cpp:computeTargetTriple`, but the complexity would be very high.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110663

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/linux-per-target-runtime-dir.c


Index: clang/test/Driver/linux-per-target-runtime-dir.c
===
--- clang/test/Driver/linux-per-target-runtime-dir.c
+++ clang/test/Driver/linux-per-target-runtime-dir.c
@@ -25,3 +25,10 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-FILE-NAME-X8664 %s
 // CHECK-FILE-NAME-X8664: 
lib{{/|\\}}x86_64-unknown-linux-gnu{{/|\\}}libclang_rt.builtins.a
+
+/// On Debian, LLVM_DEFAULT_TARGET_TRIPLE may use Debian multiarch style 
"x86_64-linux-gnu".
+// RUN: %clangxx -### %s --target=x86_64-linux-gnu 
--sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN:   -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir_debian \
+// RUN:   --rtlib=compiler-rt 2>&1 | FileCheck 
--check-prefix=CHECK-DEBIAN-X8664 %s
+// CHECK-DEBIAN-X8664: 
lib{{/|\\}}x86_64-linux-gnu{{/|\\}}libclang_rt.builtins.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -490,7 +490,18 @@
 std::string ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib", getTripleString());
-  return std::string(P.str());
+  std::string Ret(P);
+  // When LLVM_DEFAULT_TARGET_TRIPLE uses Debian multiarch style
+  // "x86_64-linux-gnu" (no vendor part), use the unnormalized
+  // D.getTargetTriple() instead of the normalized getTripleString()
+  // ("x86_64-unknown-linux-gnu").
+  if (!getVFS().exists(Ret)) {
+P.clear();
+llvm::sys::path::append(P, D.ResourceDir, "lib", D.getTargetTriple());
+if (getVFS().exists(P))
+  Ret = std::string(P);
+  }
+  return Ret;
 }
 
 std::string ToolChain::getStdlibPath() const {


Index: clang/test/Driver/linux-per-target-runtime-dir.c
===
--- clang/test/Driver/linux-per-target-runtime-dir.c
+++ clang/test/Driver/linux-per-target-runtime-dir.c
@@ -25,3 +25,10 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-FILE-NAME-X8664 %s
 // CHECK-FILE-NAME-X8664: lib{{/|\\}}x86_64-unknown-linux-gnu{{/|\\}}libclang_rt.builtins.a
+
+/// On Debian, LLVM_DEFAULT_TARGET_TRIPLE may use Debian multiarch style "x86_64-linux-gnu".
+// RUN: %clangxx -### %s --target=x86_64-linux-gnu --sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN:   -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir_debian \
+// RUN:   --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=CHECK-DEBIAN-X8664 %s
+// CHECK-DEBIAN-X8664: lib{{/|\\}}x86_64-linux-gnu{{/|\\}}libclang_rt.builtins.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -490,7 +490,18 @@
 std::string ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib", getTripleString());
-  return std::string(P.str());
+  std::string Ret(P);
+  // When LLVM_DEFAULT_TARGET_TRIPLE uses Debian multiarch style
+  // "x86_64-linux-gnu" (no vendor part), use the unnormalized
+  // D.getTargetTriple() instead of the normalized getTripleString()
+  // ("x86_64-unknown-linux-gnu").
+  if (!getVFS().exists(Ret)) {
+P.clear();
+llvm::sys::path::append(P, D.ResourceDir, "lib", D.getTargetTriple());
+if (getVFS().exists(P))
+  Ret = std::string(P);
+  }
+  return Ret;
 }
 
 std::string ToolChain::getStdlibPath() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110422: [AIX] Change the linkage of profiling counter/data to be private

2021-09-28 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 375716.
jsji added a comment.

Remove empty line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

Files:
  clang/test/Profile/cxx-templates.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  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
@@ -45,8 +45,8 @@
 ; MACHO: @__profd_foo_weak = weak hidden global
 ; COFF: @__profc_foo_weak = weak hidden global
 ; COFF: @__profd_foo_weak = private global
-; XCOFF: @__profc_foo_weak = weak hidden global
-; XCOFF: @__profd_foo_weak = weak hidden global
+; XCOFF: @__profc_foo_weak = private global
+; XCOFF: @__profd_foo_weak = private global
 define weak void @foo_weak() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([8 x i8], [8 
x i8]* @__profn_foo_weak, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -71,8 +71,8 @@
 ; MACHO: @__profd_foo_inline = linkonce_odr hidden global
 ; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}} section 
".lprfc$M", align 8
 ; COFF: @__profd_foo_inline = private global{{.*}} section ".lprfd$M", align 8
-; XCOFF: @__profc_foo_inline = linkonce_odr hidden global
-; XCOFF: @__profd_foo_inline = linkonce_odr hidden global
+; XCOFF: @__profc_foo_inline = private global
+; XCOFF: @__profd_foo_inline = private global
 define linkonce_odr void @foo_inline() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], 
[10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -84,8 +84,8 @@
 ; MACHO: @__profd_foo_extern = linkonce_odr hidden global
 ; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section 
".lprfc$M", comdat, align 8
 ; COFF: @__profd_foo_extern = private global {{.*}}section ".lprfd$M", 
comdat($__profc_foo_extern), align 8
-; XCOFF: @__profc_foo_extern = linkonce_odr hidden global
-; XCOFF: @__profd_foo_extern = linkonce_odr hidden global
+; XCOFF: @__profc_foo_extern = private global
+; XCOFF: @__profd_foo_extern = private global
 define available_externally void @foo_extern() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], 
[10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -862,6 +862,15 @@
   GlobalValue::LinkageTypes Linkage = NamePtr->getLinkage();
   GlobalValue::VisibilityTypes Visibility = NamePtr->getVisibility();
 
+  // Due to the limitation of binder as of 2021/09/28, the duplicate weak
+  // symbols in the same csect won't be discarded. When there are duplicate 
weak
+  // symbols, we can NOT guarantee that the relocations get resolved to the
+  // intended weak symbol, so we can not ensure the correctness of the relative
+  // CounterPtr, so we have to use private linkage for counter and data 
symbols.
+  if (TT.isOSBinFormatXCOFF()) {
+Linkage = GlobalValue::PrivateLinkage;
+Visibility = GlobalValue::DefaultVisibility;
+  }
   // Move the name variable to the right section. Place them in a COMDAT group
   // if the associated function is a COMDAT. This will make sure that only one
   // copy of counters of the COMDAT function will be emitted after linking. 
Keep
Index: clang/test/Profile/cxx-templates.cpp
===
--- clang/test/Profile/cxx-templates.cpp
+++ clang/test/Profile/cxx-templates.cpp
@@ -10,8 +10,10 @@
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
-// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
-// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
+// The linkage can be target dependent, so accept all linkage here,
+// the linkage tests for different target are in 
llvm/test/Instrumentation/InstrProfiling/profiling.ll
+// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = {{.*}} global [2 x i64] 
zeroinitializer
+// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = {{.*}} global [2 x i64] 
zeroinitializer
 
 // T0GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()
 // T0USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()


Index: llvm/test/Instrumentation/InstrProfiling/profiling.ll
===
--- llvm/test/Instrumentation/InstrProfiling/pr

[PATCH] D109625: [compiler-rt] Ensure required deps for tests targets are actually built

2021-09-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 375713.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109625

Files:
  compiler-rt/test/CMakeLists.txt


Index: compiler-rt/test/CMakeLists.txt
===
--- compiler-rt/test/CMakeLists.txt
+++ compiler-rt/test/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Needed for lit support in standalone builds.
 include(AddLLVM)
+include(LLVMExternalProjectUtils)
 
 option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS
   "When set to ON and testing in a standalone build, test the runtime \
@@ -36,6 +37,21 @@
 if (WIN32)
   list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
 endif()
+  elseif(COMPILER_RT_STANDALONE_BUILD)
+# These are tools needed for testing in a standalone/runtimes build, but we
+# don't have a corresponding CMAKE_* flag for. These will need to be 
rebuilt.
+set(LIT_ONLY_TOOLS FileCheck count not)
+foreach(dep ${LIT_ONLY_TOOLS})
+  if (NOT TARGET ${dep})
+llvm_ExternalProject_BuildCmd(build_${dep} ${dep} ${BINARY_DIR})
+add_custom_target(${dep}
+  COMMAND ${build_${dep}}
+  WORKING_DIRECTORY ${BINARY_DIR}
+  VERBATIM USES_TERMINAL)
+  endif()
+endforeach()
+
+list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS ${LIT_ONLY_TOOLS})
   endif()
   # Tests use C++ standard library headers.
   if (TARGET cxx-headers OR HAVE_LIBCXX)


Index: compiler-rt/test/CMakeLists.txt
===
--- compiler-rt/test/CMakeLists.txt
+++ compiler-rt/test/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Needed for lit support in standalone builds.
 include(AddLLVM)
+include(LLVMExternalProjectUtils)
 
 option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS
   "When set to ON and testing in a standalone build, test the runtime \
@@ -36,6 +37,21 @@
 if (WIN32)
   list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
 endif()
+  elseif(COMPILER_RT_STANDALONE_BUILD)
+# These are tools needed for testing in a standalone/runtimes build, but we
+# don't have a corresponding CMAKE_* flag for. These will need to be rebuilt.
+set(LIT_ONLY_TOOLS FileCheck count not)
+foreach(dep ${LIT_ONLY_TOOLS})
+  if (NOT TARGET ${dep})
+llvm_ExternalProject_BuildCmd(build_${dep} ${dep} ${BINARY_DIR})
+add_custom_target(${dep}
+  COMMAND ${build_${dep}}
+  WORKING_DIRECTORY ${BINARY_DIR}
+  VERBATIM USES_TERMINAL)
+  endif()
+endforeach()
+
+list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS ${LIT_ONLY_TOOLS})
   endif()
   # Tests use C++ standard library headers.
   if (TARGET cxx-headers OR HAVE_LIBCXX)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110656: [clang][Sema] Warn on uninitialized array elments

2021-09-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 375711.
beanz added a comment.

Updating so that the warning doesn't fire on an empty initializer list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110656

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/missing-array-initializers.c


Index: clang/test/Sema/missing-array-initializers.c
===
--- /dev/null
+++ clang/test/Sema/missing-array-initializers.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-array-initializers %s
+
+// We should only warn on an explicitly sized initializer for an array
+// specifier. This means no warning on arrays without size, and no warning on
+// string literal specfiers (even if the string literal has a size).
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Doggo[] = "Doggo";
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Pupper[16] = "Pupper";
+
+// expected-warning@+1 {{missing array initializer: expected 16 elements, 
found 7}}
+char Floofer[16] = {'F', 'L', 'O', 'O', 'F', 'E', 'R'};
+
+// not-expected-warning@+1 {{missing array initializer}}
+int Array[] = {1, 2, 3, 4, 5};
+
+// expected-warning@+1 {{missing array initializer: expected 10 elements, 
found 5}}
+int SizedArray[10] = {1, 2, 3, 4, 5};
+
+// Don't fire on zero-initialized shorthand either
+// not-expected-warning@+1 {{missing array initializer}}
+int ZeroInitialized[10] = {};
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1991,6 +1991,12 @@
   CheckEmptyInitializable(
   InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity),
   IList->getEndLoc());
+if (!VerifyOnly && maxElementsKnown && elementIndex > 0 &&
+elementIndex < maxElements) {
+  SemaRef.Diag(IList->getEndLoc(), diag::warn_missing_array_initializers)
+  << (unsigned)maxElements.getExtValue()
+  << (unsigned)elementIndex.getExtValue();
+}
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5797,6 +5797,9 @@
 def warn_missing_field_initializers : Warning<
   "missing field %0 initializer">,
   InGroup, DefaultIgnore;
+def warn_missing_array_initializers : Warning<
+  "missing array initializer: expected %0 elements, found %1">,
+  InGroup, DefaultIgnore;
 def warn_braces_around_init : Warning<
   "braces around %select{scalar |}0initializer">,
   InGroup>;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -466,6 +466,7 @@
 def MismatchedReturnTypes : DiagGroup<"mismatched-return-types">;
 def MismatchedTags : DiagGroup<"mismatched-tags">;
 def MissingFieldInitializers : DiagGroup<"missing-field-initializers">;
+def MissingArrayInitializers : DiagGroup<"missing-array-initializers">;
 def ModuleLock : DiagGroup<"module-lock">;
 def ModuleBuild : DiagGroup<"module-build">;
 def ModuleImport : DiagGroup<"module-import">;


Index: clang/test/Sema/missing-array-initializers.c
===
--- /dev/null
+++ clang/test/Sema/missing-array-initializers.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-array-initializers %s
+
+// We should only warn on an explicitly sized initializer for an array
+// specifier. This means no warning on arrays without size, and no warning on
+// string literal specfiers (even if the string literal has a size).
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Doggo[] = "Doggo";
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Pupper[16] = "Pupper";
+
+// expected-warning@+1 {{missing array initializer: expected 16 elements, found 7}}
+char Floofer[16] = {'F', 'L', 'O', 'O', 'F', 'E', 'R'};
+
+// not-expected-warning@+1 {{missing array initializer}}
+int Array[] = {1, 2, 3, 4, 5};
+
+// expected-warning@+1 {{missing array initializer: expected 10 elements, found 5}}
+int SizedArray[10] = {1, 2, 3, 4, 5};
+
+// Don't fire on zero-initialized shorthand either
+// not-expected-warning@+1 {{missing array initializer}}
+int ZeroInitialized[10] = {};
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1991,6 +1991,12 @@
   CheckEmptyInitializable(
   InitializedEntity::InitializeElement(SemaRef.Context, 0, Ent

[PATCH] D110422: [AIX] Change the linkage of profiling counter/data to be private

2021-09-28 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 375709.
jsji added a comment.

Split the Driver changes to another patch, also fixed the duplicate code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

Files:
  clang/test/Profile/cxx-templates.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  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
@@ -45,8 +45,8 @@
 ; MACHO: @__profd_foo_weak = weak hidden global
 ; COFF: @__profc_foo_weak = weak hidden global
 ; COFF: @__profd_foo_weak = private global
-; XCOFF: @__profc_foo_weak = weak hidden global
-; XCOFF: @__profd_foo_weak = weak hidden global
+; XCOFF: @__profc_foo_weak = private global
+; XCOFF: @__profd_foo_weak = private global
 define weak void @foo_weak() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([8 x i8], [8 
x i8]* @__profn_foo_weak, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -71,8 +71,8 @@
 ; MACHO: @__profd_foo_inline = linkonce_odr hidden global
 ; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}} section 
".lprfc$M", align 8
 ; COFF: @__profd_foo_inline = private global{{.*}} section ".lprfd$M", align 8
-; XCOFF: @__profc_foo_inline = linkonce_odr hidden global
-; XCOFF: @__profd_foo_inline = linkonce_odr hidden global
+; XCOFF: @__profc_foo_inline = private global
+; XCOFF: @__profd_foo_inline = private global
 define linkonce_odr void @foo_inline() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], 
[10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -84,8 +84,8 @@
 ; MACHO: @__profd_foo_extern = linkonce_odr hidden global
 ; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section 
".lprfc$M", comdat, align 8
 ; COFF: @__profd_foo_extern = private global {{.*}}section ".lprfd$M", 
comdat($__profc_foo_extern), align 8
-; XCOFF: @__profc_foo_extern = linkonce_odr hidden global
-; XCOFF: @__profd_foo_extern = linkonce_odr hidden global
+; XCOFF: @__profc_foo_extern = private global
+; XCOFF: @__profd_foo_extern = private global
 define available_externally void @foo_extern() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], 
[10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -862,6 +862,15 @@
   GlobalValue::LinkageTypes Linkage = NamePtr->getLinkage();
   GlobalValue::VisibilityTypes Visibility = NamePtr->getVisibility();
 
+  // Due to the limitation of binder as of 2021/09/28, the duplicate weak
+  // symbols in the same csect won't be discarded. When there are duplicate 
weak
+  // symbols, we can NOT guarantee that the relocations get resolved to the
+  // intended weak symbol, so we can not ensure the correctness of the relative
+  // CounterPtr, so we have to use private linkage for counter and data 
symbols.
+  if (TT.isOSBinFormatXCOFF()) {
+Linkage = GlobalValue::PrivateLinkage;
+Visibility = GlobalValue::DefaultVisibility;
+  }
   // Move the name variable to the right section. Place them in a COMDAT group
   // if the associated function is a COMDAT. This will make sure that only one
   // copy of counters of the COMDAT function will be emitted after linking. 
Keep
@@ -971,6 +980,7 @@
 Linkage = GlobalValue::PrivateLinkage;
 Visibility = GlobalValue::DefaultVisibility;
   }
+
   auto *Data =
   new GlobalVariable(*M, DataTy, false, Linkage, nullptr, DataVarName);
   // Reference the counter variable with a label difference (link-time
Index: clang/test/Profile/cxx-templates.cpp
===
--- clang/test/Profile/cxx-templates.cpp
+++ clang/test/Profile/cxx-templates.cpp
@@ -10,8 +10,10 @@
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
-// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
-// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = linkonce_odr 
{{(hidden|dso_local)}} global [2 x i64] zeroinitializer
+// The linkage can be target dependent, so accept all linkage here,
+// the linkage tests for different target are in 
llvm/test/Instrumentation/InstrProfiling/profiling.ll
+// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = {{.*}} global [2 x i64] 
zeroinitializer
+// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = {{.*}} global 

[clang] 7833d20 - Revert "[clang] Rework dontcall attributes"

2021-09-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-09-28T14:49:27-07:00
New Revision: 7833d20f1fd575fac89ce76822ffd561a40552e5

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

LOG: Revert "[clang] Rework dontcall attributes"

This reverts commit 2943071e2ee0c7f31f34062a44d12aeb0e3a66fd.

Breaks bots

Added: 


Modified: 
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-error.c
clang/test/CodeGen/attr-warning.c
clang/test/Frontend/backend-attribute-error-warning-optimize.c
clang/test/Frontend/backend-attribute-error-warning.c
llvm/docs/LangRef.rst
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/test/CodeGen/X86/attr-dontcall.ll
llvm/test/ThinLTO/X86/dontcall.ll

Removed: 
clang/test/Frontend/backend-attribute-error-warning.cpp



diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 6e1d7f320673c..789c06a15b71c 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -27,7 +27,6 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
-#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
@@ -761,18 +760,30 @@ void BackendConsumer::OptimizationFailureHandler(
 }
 
 void BackendConsumer::DontCallDiagHandler(const DiagnosticInfoDontCall &D) {
-  SourceLocation LocCookie =
-  SourceLocation::getFromRawEncoding(D.getLocCookie());
-
-  // FIXME: we can't yet diagnose indirect calls. When/if we can, we
-  // should instead assert that LocCookie.isValid().
-  if (!LocCookie.isValid())
-return;
-
-  Diags.Report(LocCookie, D.getSeverity() == DiagnosticSeverity::DS_Error
-  ? diag::err_fe_backend_error_attr
-  : diag::warn_fe_backend_warning_attr)
-  << llvm::demangle(D.getFunctionName().str()) << D.getNote();
+  if (const Decl *DE = Gen->GetDeclForMangledName(D.getFunctionName()))
+if (const auto *FD = dyn_cast(DE)) {
+  assert(FD->hasAttr() &&
+ "expected error or warning function attribute");
+
+  if (const auto *EA = FD->getAttr()) {
+assert((EA->isError() || EA->isWarning()) &&
+   "ErrorAttr neither error or warning");
+
+SourceLocation LocCookie =
+SourceLocation::getFromRawEncoding(D.getLocCookie());
+
+// FIXME: we can't yet diagnose indirect calls. When/if we can, we
+// should instead assert that LocCookie.isValid().
+if (!LocCookie.isValid())
+  return;
+
+Diags.Report(LocCookie, EA->isError()
+? diag::err_fe_backend_error_attr
+: diag::warn_fe_backend_warning_attr)
+<< FD << EA->getUserDiagnostic();
+  }
+}
+  // TODO: assert if DE or FD were nullptr?
 }
 
 /// This function is invoked when the backend needs

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d26b1343247f0..83418014f0b5c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2138,12 +2138,8 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   else if (const auto *SA = FD->getAttr())
  F->setSection(SA->getName());
 
-  if (const auto *EA = FD->getAttr()) {
-if (EA->isError())
-  F->addFnAttr("dontcall-error", EA->getUserDiagnostic());
-else if (EA->isWarning())
-  F->addFnAttr("dontcall-warn", EA->getUserDiagnostic());
-  }
+  if (FD->hasAttr())
+F->addFnAttr("dontcall");
 
   // If we plan on emitting this inline builtin, we can't treat it as a 
builtin.
   if (FD->isInlineBuiltinDeclaration()) {

diff  --git a/clang/test/CodeGen/attr-error.c b/clang/test/CodeGen/attr-error.c
index a1b63ab9fa9e5..da56793a23920 100644
--- a/clang/test/CodeGen/attr-error.c
+++ b/clang/test/CodeGen/attr-error.c
@@ -7,5 +7,5 @@ void bar(void) {
 
 // CHECK: call void @foo(), !srcloc [[SRCLOC:![0-9]+]]
 // CHECK: declare{{.*}} void @foo() [[ATTR:#[0-9]+]]
-// CHECK: attributes [[ATTR]] = {{{.*}}"dontcall-error"="oh no"
+// CHECK: attributes [[ATTR]] = {{{.*}}"dontcall"
 // CHECK: [[SRCLOC]] = !{i32 {{[0-9]+}}}

diff  --git a/clang/test/CodeGen/attr-warning.c 
b/clang/test/CodeGen/attr-warning.c
index 5c89066aff75a..daa53b6616513 100644
--- a/clang/test/CodeGen/attr-warning.c
+++ b/clang/test/CodeGen/attr-warning.c
@@ -7,5 +7,5 @@ void bar(v

[PATCH] D110280: [modules] Fix IRGen assertion on accessing ObjC ivar inside a method.

2021-09-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D110280#3016911 , @rjmccall wrote:

> Hmm.  It sounds like we misbehave if we're working with a non-canonical ivar. 
>  While it does seem preferable in general for lookups done after merging 
> modules to return the canonical ivar, I'm not sure we can rely on the AST 
> only having references to that ivar, since e.g. there might be references to 
> non-canonical ivars in static/inline functions in the modules that declare 
> them.

I've experimented with RecordDecl and always_inline functions. Just "inline" is 
inlined in LLVM but not in Clang, and in IR we have a function declaration and 
its call, so I don't know where to look for potential IRGen problems for 
MemberExpr. Anyway, with always_inline function we can have MemberExpr with 
MemberDecl from a "wrong" module. `FieldDecl` parent is from the "right" module 
because we've merged decl contexts, so `CodeGenTypes::getCGRecordLayout` 
receives correct RecordDecl. Later, when we want to get offset for `FieldDecl` 
from "wrong" module, we are saved by `getCanonicalDecl` (in getLLVMFieldNo 

 and getBitFieldInfo 
,
 for instance) that returns FieldDecl from the "right" module.

I wasn't able to reproduce the exact scenario as in this PR because need to 
access an ivar from a method and I don't think you can inline that. As for 
test-functions.m, the test wasn't failing earlier because of a different name 
lookup code path and I've added it for completeness. I'll add always_inline 
function accessing ivars to the test, it doesn't hurt.

In D110280#3016911 , @rjmccall wrote:

> So while this seems like a good change  in the abstract — although maybe we 
> should just be doing the lookup in the canonical definition in the first 
> place? — it also might not be enough, and the record-layout code might just 
> need to properly handle non-canonical ivars.

Unfortunately, we were doing lookup in the canonical definition but 
`ASTReader::FindExternalVisibleDeclsByName` found decls from both modules 
because we've merged decl contexts and lookup tables from both modules were 
available in `ASTReader.Lookups`. I was considering other options for calling 
`ObjCIvarDecl::getCanonicalDecl` and based on the stack trace

  ASTReader::FindExternalVisibleDeclsByName
  DeclContext::lookup
  ObjCContainerDecl::getIvarDecl
  ObjCInterfaceDecl::lookupInstanceVariable
  Sema::LookupIvarInObjCMethod

decided `ObjCContainerDecl::getIvarDecl` would be the best option as this is 
the earliest opportunity where we have to use a single ObjCIvarDecl instead of 
multiple options.

As for teaching record-layout code to properly handle non-canonical ivars, I 
don't know how involved it is going to be. In https://reviews.llvm.org/D106994 
Richard also suggested adding support for "compatible types". Cannot really 
tell the long-term impact of different approaches but based on my limited 
experience, I still [naively] believe that carefully™ using correct decls is a 
viable solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110280

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


[clang] b69a2c8 - Revert "[test] Pin some RUN lines in optimization-remark.c to new PM"

2021-09-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-09-28T14:42:37-07:00
New Revision: b69a2c8eeca1fee26283ca4c2f99c787aabba067

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

LOG: Revert "[test] Pin some RUN lines in optimization-remark.c to new PM"

This reverts commit 952f030fe6ade193ead8f23a7654cf8d2c7aa3df.

Causes bot failures.

Added: 


Modified: 
clang/test/Frontend/optimization-remark.c

Removed: 




diff  --git a/clang/test/Frontend/optimization-remark.c 
b/clang/test/Frontend/optimization-remark.c
index 198d194de9782..d4cab0bdec0cb 100644
--- a/clang/test/Frontend/optimization-remark.c
+++ b/clang/test/Frontend/optimization-remark.c
@@ -13,8 +13,8 @@
 //
 // Check that we can override -Rpass= with -Rno-pass.
 // RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
-// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -Rno-pass 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
-// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager 
-Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck 
%s --check-prefix=CHECK-NO-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-REMARKS
 // RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager 
-Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-REMARKS
 //
 // The inliner for the new PM does not seem to be enabled at O0, but we still



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


[clang] 952f030 - [test] Pin some RUN lines in optimization-remark.c to new PM

2021-09-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-09-28T14:29:33-07:00
New Revision: 952f030fe6ade193ead8f23a7654cf8d2c7aa3df

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

LOG: [test] Pin some RUN lines in optimization-remark.c to new PM

Some people downstream are reporting that this test fails. I've been
unable to reproduce, but there is indeed something spooky going on.
Pinning to the new PM suppresses the failure. I'm continuing to
investigate this.

Added: 


Modified: 
clang/test/Frontend/optimization-remark.c

Removed: 




diff  --git a/clang/test/Frontend/optimization-remark.c 
b/clang/test/Frontend/optimization-remark.c
index d4cab0bdec0cb..198d194de9782 100644
--- a/clang/test/Frontend/optimization-remark.c
+++ b/clang/test/Frontend/optimization-remark.c
@@ -13,8 +13,8 @@
 //
 // Check that we can override -Rpass= with -Rno-pass.
 // RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
-// RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck 
%s --check-prefix=CHECK-NO-REMARKS
-// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -Rno-pass 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager 
-Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-REMARKS
 // RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager 
-Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-REMARKS
 //
 // The inliner for the new PM does not seem to be enabled at O0, but we still



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


[PATCH] D110364: [clang] Rework dontcall attributes

2021-09-28 Thread Arthur Eubanks 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 rG2943071e2ee0: [clang] Rework dontcall attributes (authored 
by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110364

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-error.c
  clang/test/CodeGen/attr-warning.c
  clang/test/Frontend/backend-attribute-error-warning-optimize.c
  clang/test/Frontend/backend-attribute-error-warning.c
  clang/test/Frontend/backend-attribute-error-warning.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/test/CodeGen/X86/attr-dontcall.ll
  llvm/test/ThinLTO/X86/dontcall.ll

Index: llvm/test/ThinLTO/X86/dontcall.ll
===
--- llvm/test/ThinLTO/X86/dontcall.ll
+++ llvm/test/ThinLTO/X86/dontcall.ll
@@ -7,16 +7,16 @@
 ; RUN:   -r=%t/b.bc,caller,px
 
 ; TODO: As part of LTO, we check that types match, but *we don't yet check that
-; attributes match!!! What should happen if we remove "dontcall" from the
+; attributes match!!! What should happen if we remove "dontcall-error" from the
 ; definition or declaration of @callee?
 
-; CHECK: call to callee marked "dontcall"
+; CHECK: call to callee marked "dontcall-error"
 
 ;--- a.s
 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"
 
-define i32 @callee() "dontcall" noinline {
+define i32 @callee() "dontcall-error" noinline {
   ret i32 42
 }
 
@@ -24,7 +24,7 @@
 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"
 
-declare i32 @callee() "dontcall"
+declare i32 @callee() "dontcall-error"
 
 define i32 @caller() {
 entry:
Index: llvm/test/CodeGen/X86/attr-dontcall.ll
===
--- llvm/test/CodeGen/X86/attr-dontcall.ll
+++ llvm/test/CodeGen/X86/attr-dontcall.ll
@@ -2,10 +2,24 @@
 ; RUN: not llc -mtriple=x86_64 -global-isel=0 -fast-isel=1 -stop-after=finalize-isel < %s 2>&1 | FileCheck %s
 ; RUN: not llc -mtriple=x86_64 -global-isel=1 -fast-isel=0 -stop-after=irtranslator -global-isel-abort=0 < %s 2>&1 | FileCheck %s
 
-declare void @foo() "dontcall"
+declare void @foo() "dontcall-error"="e"
 define void @bar() {
   call void @foo()
   ret void
 }
 
-; CHECK: error: call to foo marked "dontcall"
+declare void @foo2() "dontcall-warn"="w"
+define void @bar2() {
+  call void @foo2()
+  ret void
+}
+
+declare void @foo3() "dontcall-warn"
+define void @bar3() {
+  call void @foo3()
+  ret void
+}
+
+; CHECK: error: call to foo marked "dontcall-error": e
+; CHECK: warning: call to foo2 marked "dontcall-warn": w
+; CHECK: warning: call to foo3 marked "dontcall-warn"{{$}}
Index: llvm/lib/IR/DiagnosticInfo.cpp
===
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -400,6 +400,34 @@
 void OptimizationRemarkAnalysisFPCommute::anchor() {}
 void OptimizationRemarkAnalysisAliasing::anchor() {}
 
+void llvm::diagnoseDontCall(const CallInst &CI) {
+  auto *F = CI.getCalledFunction();
+  if (!F)
+return;
+
+  for (int i = 0; i != 2; ++i) {
+auto AttrName = i == 0 ? "dontcall-error" : "dontcall-warn";
+auto Sev = i == 0 ? DS_Error : DS_Warning;
+
+if (F->hasFnAttribute(AttrName)) {
+  unsigned LocCookie = 0;
+  auto A = F->getFnAttribute(AttrName);
+  if (MDNode *MD = CI.getMetadata("srcloc"))
+LocCookie =
+mdconst::extract(MD->getOperand(0))->getZExtValue();
+  DiagnosticInfoDontCall D(F->getName(), A.getValueAsString(), Sev,
+   LocCookie);
+  F->getContext().diagnose(D);
+}
+  }
+}
+
 void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
-  DP << "call to " << getFunctionName() << " marked \"dontcall\"";
+  DP << "call to " << getFunctionName() << " marked \"dontcall-";
+  if (getSeverity() == DiagnosticSeverity::DS_Error)
+DP << "error\"";
+  else
+DP << "warn\"";
+  if (!getNote().empty())
+DP << ": " << getNote();
 }
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -8036,14 +8036,7 @@
   }
 
   if (Function *F = I.getCalledFunction()) {
-if (F->hasFnAttribute("dontcall")) {
-  unsigned LocCookie = 0;
-  if (MDNode *MD = I.getMetadata("srcloc"))
-LocCookie

[clang] 2943071 - [clang] Rework dontcall attributes

2021-09-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-09-28T14:21:10-07:00
New Revision: 2943071e2ee0c7f31f34062a44d12aeb0e3a66fd

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

LOG: [clang] Rework dontcall attributes

To avoid using the AST when emitting diagnostics, split the "dontcall"
attribute into "dontcall-warn" and "dontcall-error", and also add the
frontend attribute value as the LLVM attribute value. This gives us all
the information to report diagnostics we need from within the IR (aside
from access to the original source).

One downside is we directly use LLVM's demangler rather than using the
existing Clang diagnostic pretty printing of symbols.

Reviewed By: nickdesaulniers

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

Added: 
clang/test/Frontend/backend-attribute-error-warning.cpp

Modified: 
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-error.c
clang/test/CodeGen/attr-warning.c
clang/test/Frontend/backend-attribute-error-warning-optimize.c
clang/test/Frontend/backend-attribute-error-warning.c
llvm/docs/LangRef.rst
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/test/CodeGen/X86/attr-dontcall.ll
llvm/test/ThinLTO/X86/dontcall.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 789c06a15b71c..6e1d7f320673c 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -27,6 +27,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
@@ -760,30 +761,18 @@ void BackendConsumer::OptimizationFailureHandler(
 }
 
 void BackendConsumer::DontCallDiagHandler(const DiagnosticInfoDontCall &D) {
-  if (const Decl *DE = Gen->GetDeclForMangledName(D.getFunctionName()))
-if (const auto *FD = dyn_cast(DE)) {
-  assert(FD->hasAttr() &&
- "expected error or warning function attribute");
-
-  if (const auto *EA = FD->getAttr()) {
-assert((EA->isError() || EA->isWarning()) &&
-   "ErrorAttr neither error or warning");
-
-SourceLocation LocCookie =
-SourceLocation::getFromRawEncoding(D.getLocCookie());
-
-// FIXME: we can't yet diagnose indirect calls. When/if we can, we
-// should instead assert that LocCookie.isValid().
-if (!LocCookie.isValid())
-  return;
-
-Diags.Report(LocCookie, EA->isError()
-? diag::err_fe_backend_error_attr
-: diag::warn_fe_backend_warning_attr)
-<< FD << EA->getUserDiagnostic();
-  }
-}
-  // TODO: assert if DE or FD were nullptr?
+  SourceLocation LocCookie =
+  SourceLocation::getFromRawEncoding(D.getLocCookie());
+
+  // FIXME: we can't yet diagnose indirect calls. When/if we can, we
+  // should instead assert that LocCookie.isValid().
+  if (!LocCookie.isValid())
+return;
+
+  Diags.Report(LocCookie, D.getSeverity() == DiagnosticSeverity::DS_Error
+  ? diag::err_fe_backend_error_attr
+  : diag::warn_fe_backend_warning_attr)
+  << llvm::demangle(D.getFunctionName().str()) << D.getNote();
 }
 
 /// This function is invoked when the backend needs

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 83418014f0b5c..d26b1343247f0 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2138,8 +2138,12 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   else if (const auto *SA = FD->getAttr())
  F->setSection(SA->getName());
 
-  if (FD->hasAttr())
-F->addFnAttr("dontcall");
+  if (const auto *EA = FD->getAttr()) {
+if (EA->isError())
+  F->addFnAttr("dontcall-error", EA->getUserDiagnostic());
+else if (EA->isWarning())
+  F->addFnAttr("dontcall-warn", EA->getUserDiagnostic());
+  }
 
   // If we plan on emitting this inline builtin, we can't treat it as a 
builtin.
   if (FD->isInlineBuiltinDeclaration()) {

diff  --git a/clang/test/CodeGen/attr-error.c b/clang/test/CodeGen/attr-error.c
index da56793a23920..a1b63ab9fa9e5 100644
--- a/clang/test/CodeGen/attr-error.c
+++ b/clang/test/CodeGen/attr-error.c
@@ -7,5 +7,5 @@ void bar(void) {
 
 // CHECK: call void @foo(), !srcloc [[SRCLOC:![0-9

[PATCH] D110656: [clang][Sema] Warn on uninitialized array elments

2021-09-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: aaron.ballman, rsmith, RKSimon, dexonsmith.
beanz requested review of this revision.
Herald added a project: clang.

When defining a statically sized array with explicit array
initializers, having a warning for uninitialized members is nice.

This warning will only fire on missing elements in an explicitly sized
array initialized with an array initializer. It will not fire on char
arrays that are initialized using a string literal sequence.

This warning is added under a new warning group
-Wmissing-array-initializers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110656

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/missing-array-initializers.c


Index: clang/test/Sema/missing-array-initializers.c
===
--- /dev/null
+++ clang/test/Sema/missing-array-initializers.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-array-initializers %s
+
+// We should only warn on an explicitly sized initializer for an array
+// specifier. This means no warning on arrays without size, and no warning on
+// string literal specfiers (even if the string literal has a size).
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Doggo[] = "Doggo";
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Pupper[16] = "Pupper";
+
+// expected-warning@+1 {{missing array initializer: expected 16 elements, 
found 7}}
+char Floofer[16] = {'F', 'L', 'O', 'O', 'F', 'E', 'R'};
+
+// not-expected-warning@+1 {{missing array initializer}}
+int Array[] = {1, 2, 3, 4, 5};
+
+// expected-warning@+1 {{missing array initializer: expected 10 elements, 
found 5}}
+int SizedArray[10] = {1, 2, 3, 4, 5};
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1991,6 +1991,11 @@
   CheckEmptyInitializable(
   InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity),
   IList->getEndLoc());
+if (!VerifyOnly && maxElementsKnown && elementIndex < maxElements) {
+  SemaRef.Diag(IList->getEndLoc(), diag::warn_missing_array_initializers)
+  << (unsigned)maxElements.getExtValue()
+  << (unsigned)elementIndex.getExtValue();
+}
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5797,6 +5797,9 @@
 def warn_missing_field_initializers : Warning<
   "missing field %0 initializer">,
   InGroup, DefaultIgnore;
+def warn_missing_array_initializers : Warning<
+  "missing array initializer: expected %0 elements, found %1">,
+  InGroup, DefaultIgnore;
 def warn_braces_around_init : Warning<
   "braces around %select{scalar |}0initializer">,
   InGroup>;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -466,6 +466,7 @@
 def MismatchedReturnTypes : DiagGroup<"mismatched-return-types">;
 def MismatchedTags : DiagGroup<"mismatched-tags">;
 def MissingFieldInitializers : DiagGroup<"missing-field-initializers">;
+def MissingArrayInitializers : DiagGroup<"missing-array-initializers">;
 def ModuleLock : DiagGroup<"module-lock">;
 def ModuleBuild : DiagGroup<"module-build">;
 def ModuleImport : DiagGroup<"module-import">;


Index: clang/test/Sema/missing-array-initializers.c
===
--- /dev/null
+++ clang/test/Sema/missing-array-initializers.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-array-initializers %s
+
+// We should only warn on an explicitly sized initializer for an array
+// specifier. This means no warning on arrays without size, and no warning on
+// string literal specfiers (even if the string literal has a size).
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Doggo[] = "Doggo";
+
+// not-expected-warning@+1 {{missing array initializer}}
+char Pupper[16] = "Pupper";
+
+// expected-warning@+1 {{missing array initializer: expected 16 elements, found 7}}
+char Floofer[16] = {'F', 'L', 'O', 'O', 'F', 'E', 'R'};
+
+// not-expected-warning@+1 {{missing array initializer}}
+int Array[] = {1, 2, 3, 4, 5};
+
+// expected-warning@+1 {{missing array initializer: expected 10 elements, found 5}}
+int SizedArray[10] = {1, 2, 3, 4, 5};
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1991,6 +1991,11 @@
   CheckEmptyInitializable(
   Initia

[PATCH] D110364: [clang] Rework dontcall attributes

2021-09-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 375698.
aeubanks added a comment.

DRY


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110364

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-error.c
  clang/test/CodeGen/attr-warning.c
  clang/test/Frontend/backend-attribute-error-warning-optimize.c
  clang/test/Frontend/backend-attribute-error-warning.c
  clang/test/Frontend/backend-attribute-error-warning.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/test/CodeGen/X86/attr-dontcall.ll
  llvm/test/ThinLTO/X86/dontcall.ll

Index: llvm/test/ThinLTO/X86/dontcall.ll
===
--- llvm/test/ThinLTO/X86/dontcall.ll
+++ llvm/test/ThinLTO/X86/dontcall.ll
@@ -7,16 +7,16 @@
 ; RUN:   -r=%t/b.bc,caller,px
 
 ; TODO: As part of LTO, we check that types match, but *we don't yet check that
-; attributes match!!! What should happen if we remove "dontcall" from the
+; attributes match!!! What should happen if we remove "dontcall-error" from the
 ; definition or declaration of @callee?
 
-; CHECK: call to callee marked "dontcall"
+; CHECK: call to callee marked "dontcall-error"
 
 ;--- a.s
 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"
 
-define i32 @callee() "dontcall" noinline {
+define i32 @callee() "dontcall-error" noinline {
   ret i32 42
 }
 
@@ -24,7 +24,7 @@
 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"
 
-declare i32 @callee() "dontcall"
+declare i32 @callee() "dontcall-error"
 
 define i32 @caller() {
 entry:
Index: llvm/test/CodeGen/X86/attr-dontcall.ll
===
--- llvm/test/CodeGen/X86/attr-dontcall.ll
+++ llvm/test/CodeGen/X86/attr-dontcall.ll
@@ -2,10 +2,24 @@
 ; RUN: not llc -mtriple=x86_64 -global-isel=0 -fast-isel=1 -stop-after=finalize-isel < %s 2>&1 | FileCheck %s
 ; RUN: not llc -mtriple=x86_64 -global-isel=1 -fast-isel=0 -stop-after=irtranslator -global-isel-abort=0 < %s 2>&1 | FileCheck %s
 
-declare void @foo() "dontcall"
+declare void @foo() "dontcall-error"="e"
 define void @bar() {
   call void @foo()
   ret void
 }
 
-; CHECK: error: call to foo marked "dontcall"
+declare void @foo2() "dontcall-warn"="w"
+define void @bar2() {
+  call void @foo2()
+  ret void
+}
+
+declare void @foo3() "dontcall-warn"
+define void @bar3() {
+  call void @foo3()
+  ret void
+}
+
+; CHECK: error: call to foo marked "dontcall-error": e
+; CHECK: warning: call to foo2 marked "dontcall-warn": w
+; CHECK: warning: call to foo3 marked "dontcall-warn"{{$}}
Index: llvm/lib/IR/DiagnosticInfo.cpp
===
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -400,6 +400,34 @@
 void OptimizationRemarkAnalysisFPCommute::anchor() {}
 void OptimizationRemarkAnalysisAliasing::anchor() {}
 
+void llvm::diagnoseDontCall(const CallInst &CI) {
+  auto *F = CI.getCalledFunction();
+  if (!F)
+return;
+
+  for (int i = 0; i != 2; ++i) {
+auto AttrName = i == 0 ? "dontcall-error" : "dontcall-warn";
+auto Sev = i == 0 ? DS_Error : DS_Warning;
+
+if (F->hasFnAttribute(AttrName)) {
+  unsigned LocCookie = 0;
+  auto A = F->getFnAttribute(AttrName);
+  if (MDNode *MD = CI.getMetadata("srcloc"))
+LocCookie =
+mdconst::extract(MD->getOperand(0))->getZExtValue();
+  DiagnosticInfoDontCall D(F->getName(), A.getValueAsString(), Sev,
+   LocCookie);
+  F->getContext().diagnose(D);
+}
+  }
+}
+
 void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
-  DP << "call to " << getFunctionName() << " marked \"dontcall\"";
+  DP << "call to " << getFunctionName() << " marked \"dontcall-";
+  if (getSeverity() == DiagnosticSeverity::DS_Error)
+DP << "error\"";
+  else
+DP << "warn\"";
+  if (!getNote().empty())
+DP << ": " << getNote();
 }
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -8036,14 +8036,7 @@
   }
 
   if (Function *F = I.getCalledFunction()) {
-if (F->hasFnAttribute("dontcall")) {
-  unsigned LocCookie = 0;
-  if (MDNode *MD = I.getMetadata("srcloc"))
-LocCookie =
-mdconst::extract(MD->getOperand(0))->getZExtValue();
-  DiagnosticInfoDontCall D(F->getName(), LocCookie);
-  DAG.getCon

[PATCH] D108560: [clang-tidy] Add support for `NOLINTBEGIN` ... `NOLINTEND` comments

2021-09-28 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz added a comment.

F19296441: nolintbeginend.cpp.tmp.cpp.msg 
You can see in the attached file, that when I ran the unit test on a x86_64 
Windows 10 PC, the diagnostic from `error_in_include.inc` is printed at the 
end. However, on this this clang-s390x-linux-multistage build, it is printing 
the diagnostic from `error_in_include.inc` first:
https://lab.llvm.org/buildbot/#/builders/8/builds/1860/steps/5/logs/FAIL__Clang_Tools__nolintbeginend_cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108560

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


[PATCH] D110655: [OpenMP] Apply OpenMP assumptions to applicable call sites

2021-09-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds OpenMP assumption attributes to call sites in applicable
regions. Currently this applies the caller's assumption attributes to
any calls contained within it. So, if a call occurs inside an OpenMP
assumes region to a function outside that region, we will assume that
call respects the assumptions. This is primarily useful for inline
assembly calls used heavily in the OpenMP GPU device runtime, which
allows us to then make judgements about what the ASM will do.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110655

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/OpenMP/assumes_codegen.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp

Index: clang/test/OpenMP/assumes_include_nvptx.cpp
===
--- clang/test/OpenMP/assumes_include_nvptx.cpp
+++ clang/test/OpenMP/assumes_include_nvptx.cpp
@@ -24,7 +24,7 @@
 // CHECK:   attributes [[attr1]]
 // CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
 // CHECK:   attributes [[attr2]]
-// CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
+// CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations,ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
 
 
 template 
Index: clang/test/OpenMP/assumes_codegen.cpp
===
--- clang/test/OpenMP/assumes_codegen.cpp
+++ clang/test/OpenMP/assumes_codegen.cpp
@@ -67,6 +67,20 @@
 }
 #pragma omp end assumes
 
+void no_assume() {
+  foo();
+}
+
+#pragma omp begin assumes ext_call_site
+void assume() {
+  foo();
+}
+
+void assembly() {
+  asm ("nop");
+}
+#pragma omp end assumes ext_call_site
+
 // AST:  void foo() __attribute__((assume("omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses"))) __attribute__((assume("omp_no_openmp"))) {
 // AST-NEXT: }
 // AST-NEXT: class BAR {
@@ -115,51 +129,67 @@
 // CHECK: define{{.*}} void @_Z3barv()
 // CHECK-SAME: [[attr1:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BARC1Ev(%class.BAR*{{.*}} %b)
-// CHECK-SAME: [[attr9:#[0-9]]]
+// CHECK-SAME: [[attr10:#[0-9]]]
 // CHECK: define{{.*}} void @_ZN3BARC1Ev(%class.BAR*{{.*}} %this)
 // CHECK-SAME: [[attr2:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BARC2Ev(%class.BAR*{{.*}} %this1)
-// CHECK-SAME: [[attr9]]
+// CHECK-SAME: [[attr10]]
 // CHECK: define{{.*}} void @_ZN3BARC2Ev(%class.BAR*{{.*}} %this)
 // CHECK-SAME: [[attr3:#[0-9]]]
 // CHECK: define{{.*}} void @_Z3bazv()
 // CHECK-SAME: [[attr4:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BAZIfEC1Ev(%class.BAZ*{{.*}} %b)
-// CHECK-SAME: [[attr10:#[0-9]]]
+// CHECK-SAME: [[attr11:#[0-9]]]
 // CHECK: define{{.*}} void @_ZN3BAZIfEC1Ev(%class.BAZ*{{.*}} %this)
 // CHECK-SAME: [[attr5:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BAZIfEC2Ev(%class.BAZ*{{.*}} %this1)
-// CHECK-SAME: [[attr10]]
+// CHECK-SAME: [[attr12]]
 // CHECK: define{{.*}} void @_ZN3BAZIfEC2Ev(%class.BAZ*{{.*}} %this)
 // CHECK-SAME: [[attr6:#[0-9]]]
 // CHECK: define{{.*}} i32 @_Z12lambda_outerv()
 // CHECK-SAME: [[attr7:#[0-9]]]
 // CHECK: call{{.*}} @"_ZZ12lambda_outervENK3$_0clEv"
-// CHECK-SAME: [[attr11:#[0-9]]]
+// CHECK-SAME: [[attr13:#[0-9]]]
 // CHECK: define{{.*}} i32 @"_ZZ12lambda_outervENK3$_0clEv"(%class.anon*{{.*}} %this)
 // CHECK-SAME: [[attr8:#[0-9]]]
+// CHECK: call{{.*}}@_Z3foov()
+// CHECK-SAME: [[attr14:#[0-9]]]
+// CHECK: call{{.*}}@_Z3foov()
+// CHECK-SAME: [[attr15:#[0-9]]]
+// CHECK: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK-SAME: [[attr16:#[0-9]]]
 
 // CHECK: attributes [[attr0]]
-// CHECK-SAME:  "llvm.assume"="omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
+// CHECK-SAME: "llvm.assume"="omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
 // CHECK: attributes [[attr1]]
-// CHECK-SAME:  "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
+// CHECK-SAME: "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
 // CHECK: attributes [[attr2]]
-// CHECK-SAME:  "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
+// CHECK-SAME: "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_inv

[PATCH] D110422: [AIX] Enable PGO without LTO

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I still think the description can be rephrased to be shorter and clearer, and 
am not very sure this workaround should be added.
But I will take a vacation and be back after one week and don't want to appear 
that I am blocking this change.

So LGTM once you decrease the number of `if (TT.isOSBinFormatXCOFF()) {` from 
two to one.
If you track where `Linkage` and `Visibility` are updated it should be clear 
one place is not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

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


[PATCH] D110481: fixes bug #51926 where dangling comma caused overrun

2021-09-28 Thread Fred Grim via Phabricator via cfe-commits
feg208 added a comment.

Absolutely in agreement


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110481

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


[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-09-28 Thread Manas Gupta via Phabricator via cfe-commits
manas added a comment.

The pre-merge checks fail due to the patch being unable to get applied. The 
troubleshooting 

 suggest to update the patch via `arc diff ```git merge-base HEAD origin``` 
--update D106102` and it would include all local changes into that patch. 
Shouldn't I avoid including all local changes, as some local changes are still 
WIP?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106102

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


[PATCH] D110653: [PowerPC] The builtins load8r and store8r are Power 7 plus.

2021-09-28 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp created this revision.
stefanp added reviewers: nemanjai, lei.
Herald added subscribers: shchenz, kbarton, hiraditya.
stefanp requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

This patch makes sure that the builtins __builtin_ppc_load8r and
__ builtin_ppc_store8r are only available for Power 7 and up.
Currently the builtins seem to produce incorrect code if used for
Power 6 or before.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110653

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Driver/ppc-isa-features.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h

Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -147,6 +147,7 @@
   bool HasStoreFusion;
   bool HasAddiLoadFusion;
   bool HasAddisLoadFusion;
+  bool IsISA2_06;
   bool IsISA2_07;
   bool IsISA3_0;
   bool IsISA3_1;
@@ -322,6 +323,7 @@
 
   bool hasHTM() const { return HasHTM; }
   bool hasFloat128() const { return HasFloat128; }
+  bool isISA2_06() const { return IsISA2_06; }
   bool isISA2_07() const { return IsISA2_07; }
   bool isISA3_0() const { return IsISA3_0; }
   bool isISA3_1() const { return IsISA3_1; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -127,6 +127,7 @@
   HasStoreFusion = false;
   HasAddiLoadFusion = false;
   HasAddisLoadFusion = false;
+  IsISA2_06 = false;
   IsISA2_07 = false;
   IsISA3_0 = false;
   IsISA3_1 = false;
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -1182,6 +1182,7 @@
 : Predicate<"!Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
 def HasBPERMD : Predicate<"Subtarget->hasBPERMD()">;
 def HasExtDiv : Predicate<"Subtarget->hasExtDiv()">;
+def IsISA2_06 : Predicate<"Subtarget->isISA2_06()">;
 def IsISA2_07 : Predicate<"Subtarget->isISA2_07()">;
 def IsISA3_0 : Predicate<"Subtarget->isISA3_0()">;
 def HasFPU : Predicate<"Subtarget->hasFPU()">;
Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td
===
--- llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -1302,9 +1302,12 @@
 def LDX  : XForm_1_memOp<31,  21, (outs g8rc:$rD), (ins memrr:$src),
 "ldx $rD, $src", IIC_LdStLD,
 [(set i64:$rD, (load XForm:$src))]>, isPPC64;
+
+let Predicates = [IsISA2_06] in {
 def LDBRX : XForm_1_memOp<31,  532, (outs g8rc:$rD), (ins memrr:$src),
   "ldbrx $rD, $src", IIC_LdStLoad,
   [(set i64:$rD, (PPClbrx ForceXForm:$src, i64))]>, isPPC64;
+}
 
 let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
 def LHBRX8 : XForm_1_memOp<31, 790, (outs g8rc:$rD), (ins memrr:$src),
@@ -1538,10 +1541,13 @@
   "stdx $rS, $dst", IIC_LdStSTD,
   [(store i64:$rS, XForm:$dst)]>, isPPC64,
   PPC970_DGroup_Cracked;
+
+let Predicates = [IsISA2_06] in {
 def STDBRX: XForm_8_memOp<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
   "stdbrx $rS, $dst", IIC_LdStStore,
   [(PPCstbrx i64:$rS, ForceXForm:$dst, i64)]>, isPPC64,
   PPC970_DGroup_Cracked;
+}
 
 let mayStore = 1, hasNoSchedulingInfo = 1 in {
 // Normal 16-byte stores.
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -213,6 +213,9 @@
 def DeprecatedDST: SubtargetFeature<"", "DeprecatedDST", "true",
   "Treat vector data stream cache control instructions as deprecated">;
 
+def FeatureISA2_06 : SubtargetFeature<"isa-v206-instructions", "IsISA2_06",
+  "true",
+  "Enable instructions in ISA 2.06.">;
 def FeatureISA2_07 : SubtargetFeature<"isa-v207-instructions", "IsISA2_07",
   "true",
   "Enable instructions in ISA 2.07.">;
@@ -319,7 +322,8 @@
   FeatureMFTB,
   DeprecatedDST,
   FeatureTwoConstNR,
-  FeatureUnalig

[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375690.
expnkx added a comment.

I cannot find out where to add attribute that starts with msvc::x.

I am just applying this "potential" patch to the clang upstream. In the future 
we can just remove TargetItaniumCXXABI attr in the clang table gen file without 
worrying about too much. So it is a "noop".

So this patch changes nothing but it makes us be convenient to fix it in the 
future.


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

https://reviews.llvm.org/D110485

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2919,6 +2919,10 @@
 layoutBitField(FD);
 return;
   }
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping = FD->hasAttr() && 
FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   LastFieldIsNonZeroWidthBitfield = false;
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
@@ -2926,7 +2930,7 @@
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
 FieldOffset = CharUnits::Zero();
   else
 FieldOffset = Size.alignTo(Info.Alignment);


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2919,6 +2919,10 @@
 layoutBitField(FD);
 return;
   }
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping = FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   LastFieldIsNonZeroWidthBitfield = false;
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
@@ -2926,7 +2930,7 @@
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
 FieldOffset = CharUnits::Zero();
   else
 FieldOffset = Size.alignTo(Info.Alignment);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108560: [clang-tidy] Add support for `NOLINTBEGIN` ... `NOLINTEND` comments

2021-09-28 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 375685.
salman-javed-nz added a comment.

Resolving build error due to failed unit test.

On some build bots, the clang-tidy diagnostics coming from 
`error_in_include.inc` get printed BEFORE all other diagnostics, REGARDLESS of 
the location of the `#include` directive in the unit test cpp file.
On other build bots, these diagnostics are printed AFTER all other diagnostics. 
Due to this inconsistency between build bots, the `CHECK-MESSAGES` statements 
are not finding their expected messages on their expected lines.

Fixed by moving the unit tests related to including `error_in_include.inc` from 
`nolintbeginend.cpp` into its own file 
`nolintbeginend-error-within-include.cpp`.
This new file only checks for one diagnostic, so is therefore unaffected by the 
diagnostic display order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108560

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/error_in_include.inc
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/nolint_in_include.inc
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-at-eof.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-global-end-specific.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-specific-end-global.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-without-end.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-end-at-sof.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-end-without-begin.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-delims.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-typo-in-check-name.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -1,49 +1,51 @@
+// NOLINTNEXTLINE
 class A { A(int i); };
+
+class B { B(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
 // NOLINTNEXTLINE
-class B { B(int i); };
+class C { C(int i); };
 
 // NOLINTNEXTLINE(for-some-other-check)
-class C { C(int i); };
+class D { D(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
 // NOLINTNEXTLINE(*)
-class C1 { C1(int i); };
+class D1 { D1(int i); };
 
 // NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
-class C2 { C2(int i); };
+class D2 { D2(int i); };
 
 // NOLINTNEXTLINE(google-explicit-constructor)
-class C3 { C3(int i); };
+class D3 { D3(int i); };
 
 // NOLINTNEXTLINE(some-check, google-explicit-constructor)
-class C4 { C4(int i); };
+class D4 { D4(int i); };
 
 // NOLINTNEXTLINE without-brackets-skip-all, another-check
-class C5 { C5(int i); };
-
+class D5 { D5(int i); };
 
 // NOLINTNEXTLINE
 
-class D { D(int i); };
+class E { E(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
 // NOLINTNEXTLINE
 //
-class E { E(int i); };
+class F { F(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
 #define MACRO(X) class X { X(int i); };
-MACRO(F)
+MACRO(G)
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
 // NOLINTNEXTLINE
-MACRO(G)
+MACRO(H)
 
-#define MACRO_NOARG class H { H(int i); };
+#define MACRO_NOARG class I { I(int i); };
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s google-explicit-constructor %t
+
+class A { A(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors

[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-09-28 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 375689.
manas added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106102

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


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -466,3 +466,41 @@
 clang_analyzer_eval((c - d) > -71); // expected-warning{{FALSE}}
   }
 }
+
+void testEqualityRules(unsigned int a, unsigned int b, int c, int d) {
+  // Checks when ranges are not overlapping
+  if (a <= 10 && b >= 20) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{TRUE}}
+  }
+
+  if (c <= INT_MIN + 10 && d >= INT_MAX - 10) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{FALSE}}
+  }
+
+  // Checks when ranges are completely overlapping and have more than one point
+  if (a >= 20 && a <= 50 && b >= 20 && b <= 50) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -20 && c <= 20 && d >= -20 && d <= 20) {
+clang_analyzer_eval((c != d) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when ranges are partially overlapping
+  if (a >= 100 && a <= 200 && b >= 150 && b <= 300) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -80 && c <= -50 && d >= -100 && d <= -75) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for ranges which are subset of one-another
+  if (a >= 500 && a <= 1000 && b >= 750 && b <= 1000) {
+clang_analyzer_eval((a != b) == 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -1000 && c <= -500 && d <= -500 && d >= -750) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{UNKNOWN}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -21,8 +21,8 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -956,6 +956,8 @@
   RangeSet VisitBinaryOperator(RangeSet LHS, BinaryOperator::Opcode Op,
RangeSet RHS, QualType T) {
 switch (Op) {
+case BO_NE:
+  return VisitBinaryOperator(LHS, RHS, T);
 case BO_Or:
   return VisitBinaryOperator(LHS, RHS, T);
 case BO_And:
@@ -1029,6 +1031,27 @@
 return infer(T);
   }
 
+  template <>
+  RangeSet VisitBinaryOperator(RangeSet LHS, RangeSet RHS, QualType T) {
+// When both the RangeSets are non-overlapping then all possible pairs of
+// (x, y) in LHS, RHS respectively, will satisfy expression (x != y).
+if ((LHS.getMaxValue() < RHS.getMinValue()) ||
+(LHS.getMinValue() > RHS.getMaxValue())) {
+  return getTrueRange(T);
+}
+
+// If both RangeSets contain only one Point which is equal then the
+// expression will always return true.
+if ((LHS.getMinValue() == RHS.getMaxValue()) &&
+(LHS.getMaxValue() == RHS.getMaxValue()) &&
+(LHS.getMinValue() == RHS.getMinValue())) {
+  return getFalseRange(T);
+}
+
+// In all other cases, the resulting range cannot be deduced.
+return infer(T);
+  }
+
   /// Return a symmetrical range for the given range and type.
   ///
   /// If T is signed, return the smallest range [-x..x] that covers the 
original


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -466,3 +466,41 @@
 clang_analyzer_eval((c - d) > -71); // expected-warning{{FALSE}}
   }
 }
+
+void testEqualityRules(unsigned int a, unsigned int b, int c, int d) {
+  // Checks when ranges are not overlapping
+  if (a <= 10 && b >= 20) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{TRUE}}
+  }
+
+  if (c <= INT_MIN + 10 && d >= INT_MAX - 10) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{FALSE}}
+  }
+
+  // Checks when ranges are completely overlapping and have more than one point
+  if (a >= 20 && a <= 50 && b >= 20 && b <= 50) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -20 && c <= 20 && d >= -20 && d <= 20) {
+clang_analyzer_eval((c != d) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when ranges are partially overlapping
+  if (a >= 100 && a <= 200 && b >= 150 && b <= 300) {
+clang_analyzer_eval((a != b) != 0

[PATCH] D110422: [AIX] Enable PGO without LTO

2021-09-28 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 375688.
jsji marked an inline comment as done.
jsji added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unsupported-option.c
  clang/test/Profile/cxx-templates.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  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
@@ -45,8 +45,8 @@
 ; MACHO: @__profd_foo_weak = weak hidden global
 ; COFF: @__profc_foo_weak = weak hidden global
 ; COFF: @__profd_foo_weak = private global
-; XCOFF: @__profc_foo_weak = weak hidden global
-; XCOFF: @__profd_foo_weak = weak hidden global
+; XCOFF: @__profc_foo_weak = private global
+; XCOFF: @__profd_foo_weak = private global
 define weak void @foo_weak() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__profn_foo_weak, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -71,8 +71,8 @@
 ; MACHO: @__profd_foo_inline = linkonce_odr hidden global
 ; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}} section ".lprfc$M", align 8
 ; COFF: @__profd_foo_inline = private global{{.*}} section ".lprfd$M", align 8
-; XCOFF: @__profc_foo_inline = linkonce_odr hidden global
-; XCOFF: @__profd_foo_inline = linkonce_odr hidden global
+; XCOFF: @__profc_foo_inline = private global
+; XCOFF: @__profd_foo_inline = private global
 define linkonce_odr void @foo_inline() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -84,8 +84,8 @@
 ; MACHO: @__profd_foo_extern = linkonce_odr hidden global
 ; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc$M", comdat, align 8
 ; COFF: @__profd_foo_extern = private global {{.*}}section ".lprfd$M", comdat($__profc_foo_extern), align 8
-; XCOFF: @__profc_foo_extern = linkonce_odr hidden global
-; XCOFF: @__profd_foo_extern = linkonce_odr hidden global
+; XCOFF: @__profc_foo_extern = private global
+; XCOFF: @__profd_foo_extern = private global
 define available_externally void @foo_extern() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -862,6 +862,15 @@
   GlobalValue::LinkageTypes Linkage = NamePtr->getLinkage();
   GlobalValue::VisibilityTypes Visibility = NamePtr->getVisibility();
 
+  // Due to the limitation of binder as of 2021/09/28, the duplicate weak
+  // symbols in the same csect won't be discarded. When there are duplicate weak
+  // symbols, we can NOT guarantee that the relocations get resolved to the
+  // intended weak symbol, so we can not ensure the correctness of the relative
+  // CounterPtr, so we have to use private linkage for counter and data symbols.
+  if (TT.isOSBinFormatXCOFF()) {
+Linkage = GlobalValue::PrivateLinkage;
+Visibility = GlobalValue::DefaultVisibility;
+  }
   // Move the name variable to the right section. Place them in a COMDAT group
   // if the associated function is a COMDAT. This will make sure that only one
   // copy of counters of the COMDAT function will be emitted after linking. Keep
@@ -971,6 +980,17 @@
 Linkage = GlobalValue::PrivateLinkage;
 Visibility = GlobalValue::DefaultVisibility;
   }
+
+  // Due to the limitation of binder as of 2021/09/28, the duplicate weak
+  // symbols in the same csect won't be discarded. When there are duplicate weak
+  // symbols, we can NOT guarantee that the relocations get resolved to the
+  // intended weak symbol, so we can not ensure the correctness of the relative
+  // CounterPtr, so we have to use private linkage for counter and data symbols.
+  if (TT.isOSBinFormatXCOFF()) {
+Linkage = GlobalValue::PrivateLinkage;
+Visibility = GlobalValue::DefaultVisibility;
+  }
+
   auto *Data =
   new GlobalVariable(*M, DataTy, false, Linkage, nullptr, DataVarName);
   // Reference the counter variable with a label difference (link-time
Index: clang/test/Profile/cxx-templates.cpp
===
--- clang/test/Profile/cxx-templates.cpp
+++ clang/test/Profile/cxx-templates.cpp
@@ -10,8 +10,10 @@
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --in

[PATCH] D110481: fixes bug #51926 where dangling comma caused overrun

2021-09-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

In D110481#3027289 , @feg208 wrote:

> By one other bug I mean an entirely separate bug that I will handle in a 
> separate PR. Sorry if that was confusing.

Okay, but this should be handled quickly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110481

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


[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

And on Windows: http://45.33.8.238/win/46077/summary.html ! Thanks for pointing 
those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109967

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


[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-09-28 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 375682.
manas added a comment.

Move method to a specialized template for VisitBinaryOperator


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106102

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


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -466,3 +466,41 @@
 clang_analyzer_eval((c - d) > -71); // expected-warning{{FALSE}}
   }
 }
+
+void testEqualityRules(unsigned int a, unsigned int b, int c, int d) {
+  // Checks when ranges are not overlapping
+  if (a <= 10 && b >= 20) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{TRUE}}
+  }
+
+  if (c <= INT_MIN + 10 && d >= INT_MAX - 10) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{FALSE}}
+  }
+
+  // Checks when ranges are completely overlapping and have more than one point
+  if (a >= 20 && a <= 50 && b >= 20 && b <= 50) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -20 && c <= 20 && d >= -20 && d <= 20) {
+clang_analyzer_eval((c != d) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when ranges are partially overlapping
+  if (a >= 100 && a <= 200 && b >= 150 && b <= 300) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -80 && c <= -50 && d >= -100 && d <= -75) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for ranges which are subset of one-another
+  if (a >= 500 && a <= 1000 && b >= 750 && b <= 1000) {
+clang_analyzer_eval((a != b) == 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -1000 && c <= -500 && d <= -500 && d >= -750) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{UNKNOWN}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -21,8 +21,8 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -956,6 +956,8 @@
   RangeSet VisitBinaryOperator(RangeSet LHS, BinaryOperator::Opcode Op,
RangeSet RHS, QualType T) {
 switch (Op) {
+case BO_NE:
+  return VisitBinaryOperator(LHS, RHS, T);
 case BO_Or:
   return VisitBinaryOperator(LHS, RHS, T);
 case BO_And:
@@ -1029,6 +1031,27 @@
 return infer(T);
   }
 
+  template <>
+  RangeSet VisitBinaryOperator(RangeSet LHS, RangeSet RHS, QualType T) {
+// When both the RangeSets are non-overlapping then all possible pairs of
+// (x, y) in LHS, RHS respectively, will satisfy expression (x != y).
+if ((LHS.getMaxValue() < RHS.getMinValue()) ||
+(LHS.getMinValue() > RHS.getMaxValue())) {
+  return getTrueRange(T);
+}
+
+// If both RangeSets contain only one Point which is equal then the
+// expression will always return true.
+if ((LHS.getMinValue() == RHS.getMaxValue()) &&
+(LHS.getMaxValue() == RHS.getMaxValue()) &&
+(LHS.getMinValue() == RHS.getMinValue())) {
+  return getFalseRange(T);
+}
+
+// In all other cases, the resulting range cannot be deduced.
+return infer(T);
+  }
+
   /// Return a symmetrical range for the given range and type.
   ///
   /// If T is signed, return the smallest range [-x..x] that covers the 
original


Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -466,3 +466,41 @@
 clang_analyzer_eval((c - d) > -71); // expected-warning{{FALSE}}
   }
 }
+
+void testEqualityRules(unsigned int a, unsigned int b, int c, int d) {
+  // Checks when ranges are not overlapping
+  if (a <= 10 && b >= 20) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{TRUE}}
+  }
+
+  if (c <= INT_MIN + 10 && d >= INT_MAX - 10) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{FALSE}}
+  }
+
+  // Checks when ranges are completely overlapping and have more than one point
+  if (a >= 20 && a <= 50 && b >= 20 && b <= 50) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= -20 && c <= 20 && d >= -20 && d <= 20) {
+clang_analyzer_eval((c != d) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when ranges are partially overlapping
+  if (a >= 100 && a <= 200 && b >= 15

[PATCH] D110422: [AIX] Enable PGO without LTO

2021-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp:865
 
+  // Due to the current limitation of binder, the duplicate weak symbols in the
+  // same csect won't be discarded. When there are duplicate weak symbols,

"Due to the current limitation of binder,"

Replace "current" with "as of version XX or date"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

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


[PATCH] D105191: [Clang][OpenMP] Add partial support for Static Device Libraries

2021-09-28 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

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


[PATCH] D110641: Implement P0857R0 -Part B: requires clause for template-template params

2021-09-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 375680.
erichkeane added a comment.

Moments after my last comment, i figured out the scope issue, which makes the 
names in the template-template-parameter parameter-list in scope for this 
requires clause.

I don't think it makes SENSE that this is the case, but I suspect thats what 
the standard says based on the other compiler's behavior.

This fixes the exmaple in the concepts.cpp test.


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

https://reviews.llvm.org/D110641

Files:
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -912,7 +912,7 @@
 

 https://wg21.link/p0857r0";>P0857R0
-Partial
+Clang 14
   

 https://wg21.link/p1084r2";>P1084R2
Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -59,11 +59,10 @@
 x.operator()(); // expected-error {{no matching member function}}
   }
 
-  // FIXME: This is valid under P0857R0.
   template concept C = true;
-  template requires C typename U> struct X {}; // expected-error {{requires 'class'}} expected-error 0+{{}}
+  template requires C typename U> struct X {};
   template requires C struct Y {};
-  X xy; // expected-error {{no template named 'X'}}
+  X xy;
 }
 
 namespace PR50306 {
Index: clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
===
--- clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
+++ clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
@@ -32,3 +32,35 @@
 
 using s31 = S3;
 using s32 = S3;
+
+template
+struct Evals {
+  bool f() { return true; }
+};
+
+template<>
+struct Evals {
+  bool f() { return false; }
+};
+
+template  requires C typename P>
+struct S4 {};
+
+template 
+requires requires { requires T::f(); }
+typename P >
+void func(const P &p){};
+
+template  requires false typename P>
+void func_always_requires_false(const P &p) {};
+
+void use() {
+  S4 s4;
+  func(Evals{});
+  // A naive individual might expect the following to all fail concept checking,
+  // but there does not seem to be any requirement to check these in the
+  // standard, and none of the other implementations do so either.
+  S4 s4b;
+  func(Evals{});
+  func_always_requires_false(Evals{});
+}
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -871,6 +871,31 @@
 ///   type-parameter-key:
 /// 'class'
 /// 'typename'   [C++1z]
+///
+/// In C++20:
+///   template-head: [C++ temp.pre]
+/// template '<' template-parameter-list '>' requires-clause[opt]
+///
+///   template-parameter: [C++ temp.param]
+/// type-parameter
+/// parameter-declaration
+///
+///   type-parameter:
+/// type-parameter-key ...[opt] identifier[opt]
+/// type-parameter-key identifier[opt] = type-id
+/// type-constraint ...[opt] identifier[opt]
+/// type-constraint identifier[opt] = type-id
+/// template-head type-parameter-key ...[opt] identifier[opt]
+/// template-head type-parameter-key identifier[opt] = id-expression
+///
+///   type-parameter-key:
+/// 'class'
+/// 'typename'
+///
+///   type-constraint:
+/// nested-name-specifier[opt] concept-name
+/// nested-name-specifier[opt] concept-name '<'
+///   template-argument-list[opt] '>'
 NamedDecl *
 Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
   assert(Tok.is(tok::kw_template) && "Expected 'template' keyword");
@@ -879,12 +904,26 @@
   SourceLocation TemplateLoc = ConsumeToken();
   SmallVector TemplateParams;
   SourceLocation LAngleLoc, RAngleLoc;
+  ExprResult OptionalRequiresClauseConstraintER;
   {
 MultiParseScope TemplateParmScope(*this);
 if (ParseTemplateParameters(TemplateParmScope, Depth + 1, TemplateParams,
 LAngleLoc, RAngleLoc)) {
   return nullptr;
 }
+
+// Parse optional requires-clause.
+if (getLangOpts().CPlusPlus20 && TryConsumeToken(tok::kw_requires)) {
+  OptionalRequiresClauseConstraintER =
+  Actions.ActOnRequiresClause(ParseConstraintLogicalOrExpression(
+  /*IsTrailingRequiresClause=*/false));
+  if (!OptionalRequiresClauseConstraintER.isUsable()) {
+// Skip until the semi-colon or a '}'.
+SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
+TryConsumeToken(tok::semi);

[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@thakis: fine on OSX: http://45.33.8.238/macm1/18808/summary.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109967

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


[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@thakis if rG1ecb1bc3e214 
 doesn't 
work, I'll revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109967

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


[clang] 1ecb1bc - Fix memcpy-nobuiltin.c test case

2021-09-28 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-09-28T21:55:42+02:00
New Revision: 1ecb1bc3e214c8da53a7fda14f428786441109d7

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

LOG: Fix memcpy-nobuiltin.c test case

Make it more generic by accepting weak_odr and dso_local specifiers.

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

Added: 


Modified: 
clang/test/CodeGen/memcpy-nobuiltin.c

Removed: 




diff  --git a/clang/test/CodeGen/memcpy-nobuiltin.c 
b/clang/test/CodeGen/memcpy-nobuiltin.c
index cbd0ccaa2ebb..d752df8ba0eb 100644
--- a/clang/test/CodeGen/memcpy-nobuiltin.c
+++ b/clang/test/CodeGen/memcpy-nobuiltin.c
@@ -4,7 +4,7 @@
 //
 // CHECK-WITH-DECL-NOT: @llvm.memcpy
 // CHECK-NO-DECL: @llvm.memcpy
-// CHECK-SELF-REF-DECL-LABEL: define dso_local i8* @memcpy.inline
+// CHECK-SELF-REF-DECL-LABEL: define {{.*}}i8* @memcpy.inline
 // CHECK-SELF-REF-DECL:   @memcpy(
 //
 #include 



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


[PATCH] D105191: [Clang][OpenMP] Add partial support for Static Device Libraries

2021-09-28 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 375672.
saiislam added a comment.

fixed nvptx test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/openmp_static_device_link/libFatArchive.a
  clang/test/Driver/fat_archive_amdgpu.cpp
  clang/test/Driver/fat_archive_nvptx.cpp
  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
@@ -180,6 +180,28 @@
   }
 };
 
+static StringRef getDeviceFileExtension(StringRef Device) {
+  if (Device.contains("gfx"))
+return ".bc";
+  if (Device.contains("sm_"))
+return ".cubin";
+
+  WithColor::warning() << "Could not determine extension for archive"
+  "members, using \".o\"\n";
+  return ".o";
+}
+
+static std::string getDeviceLibraryFileName(StringRef BundleFileName,
+StringRef Device) {
+  StringRef LibName = sys::path::stem(BundleFileName);
+  StringRef Extension = getDeviceFileExtension(Device);
+
+  std::string Result;
+  Result += LibName;
+  Result += Extension;
+  return Result;
+}
+
 /// Generic file handler interface.
 class FileHandler {
 public:
@@ -1229,7 +1251,9 @@
   BundledObjectFileName.assign(BundledObjectFile);
   auto OutputBundleName =
   Twine(llvm::sys::path::stem(BundledObjectFileName) + "-" +
-CodeObject)
+CodeObject +
+getDeviceLibraryFileName(BundledObjectFileName,
+ CodeObjectInfo.GPUArch))
   .str();
   // Replace ':' in optional target feature list with '_' to ensure
   // cross-platform validity.
Index: clang/test/Driver/fat_archive_nvptx.cpp
===
--- /dev/null
+++ clang/test/Driver/fat_archive_nvptx.cpp
@@ -0,0 +1,81 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// See the steps to create a fat archive are given at the end of the file.
+
+// Given a FatArchive, clang-offload-bundler should be called to create a
+// device specific archive, which should be passed to clang-nvlink-wrapper.
+// RUN: %clang -O2 -### -fopenmp -fopenmp-targets=nvptx64 %s -L%S/Inputs/openmp_static_device_link -lFatArchive 2>&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "nvptx64"{{.*}}"-target-cpu" "[[GPU:sm_[0-9]+]]"{{.*}}"-o" "[[HOSTBC:.*.s]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-unbundle" "-type=a" "-inputs={{.*}}/Inputs/openmp_static_device_link/libFatArchive.a" "-targets=openmp-nvptx64-[[GPU]]" "-outputs=[[DEVICESPECIFICARCHIVE:.*.a]]" "-allow-missing-bundles"
+// CHECK: clang-nvlink-wrapper{{.*}}"-o" "{{.*}}.out" "-arch" "[[GPU]]" "{{.*}}[[DEVICESPECIFICARCHIVE]]"
+// CHECK: ld"{{.*}}" "-L{{.*}}/Inputs/openmp_static_device_link" "{{.*}} "-lFatArchive" "{{.*}}" "-lomp{{.*}}-lomptarget"
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 10
+
+#pragma omp declare target
+// Functions defined in Fat Archive.
+extern "C" void func_present(float *, float *, unsigned);
+
+#ifdef MISSING
+// Function not defined in the fat archive.
+extern "C" void func_missing(float *, float *, unsigned);
+#endif
+
+#pragma omp end declare target
+
+int main() {
+  float in[N], out[N], sum = 0;
+  unsigned i;
+
+#pragma omp parallel for
+  for (i = 0; i < N; ++i) {
+in[i] = i;
+  }
+
+  func_present(in, out, N); // Returns out[i] = a[i] * 0
+
+#ifdef MISSING
+  func_missing(in, out, N); // Should throw an error here
+#endif
+
+#pragma omp parallel for reduction(+ \
+   : sum)
+  for (i = 0; i < N; ++i)
+sum += out[i];
+
+  if (!sum)
+return 0;
+  return sum;
+}
+
+#endif
+
+/***
+   Steps to create Fat Archive (libFatArchive.a)
+
+* File: func_1.c ***
+void func_present(float* in, float* out, unsigned n){
+  unsigned i;
+  #pragma omp target teams distribute parallel for map(to: in[0:n]) map(from: out[0:n])
+  for(i=0; i&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "[[GPU:gfx[0-9]+]]"{{.*}}"-o" "[[HOSTBC:.*.bc]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-unbundle" "-type=a" "-inputs={{.*}}/Inputs/openmp_static_device_link/libFatArch

[PATCH] D110625: [analyzer] canonicalize special case of structure/pointer deref

2021-09-28 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks Vince! Nice work!

Do you think it would be worth to have a test that checks the equality of a 
double pointer and a bi-dimensional array? Something like:

  void struct_pointer_canon(struct s **ps) {
struct s ss = **ps;
clang_analyzer_eval(&(ps[0][0].v) == &((*ps)->v)); // 
expected-warning{{TRUE}}
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110625

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


  1   2   3   >