[PATCH] D129635: [OpenMP] Update the default version of OpenMP to 5.1

2022-07-20 Thread Animesh Kumar via Phabricator via cfe-commits
animeshk-amd updated this revision to Diff 446359.
animeshk-amd added a comment.
Herald added a subscriber: zzheng.

[OpenMP] Update remaining tests for OpenMP version update to 5.1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129635

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/test/OpenMP/assumes_messages_attr.c
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_capture_codegen.cpp
  clang/test/OpenMP/atomic_messages.c
  clang/test/OpenMP/atomic_messages.cpp
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/declare_mapper_ast_print.c
  clang/test/OpenMP/declare_mapper_messages.c
  clang/test/OpenMP/declare_mapper_messages.cpp
  clang/test/OpenMP/declare_target_ast_print.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_variant_clauses_ast_print.c
  clang/test/OpenMP/declare_variant_clauses_ast_print.cpp
  clang/test/OpenMP/declare_variant_clauses_messages.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/OpenMP/depobj_messages.cpp
  clang/test/OpenMP/dispatch_ast_print.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_messages.cpp
  clang/test/OpenMP/driver.c
  clang/test/OpenMP/flush_ast_print.cpp
  clang/test/OpenMP/flush_messages.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/generic_loop_messages.cpp
  clang/test/OpenMP/irbuilder_for_iterator.cpp
  clang/test/OpenMP/irbuilder_for_rangefor.cpp
  clang/test/OpenMP/masked_ast_print.cpp
  clang/test/OpenMP/masked_codegen.cpp
  clang/test/OpenMP/masked_messages_attr.cpp
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/openmp_attribute.cpp
  clang/test/OpenMP/parallel_ast_print.cpp
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_generic_loop_messages.cpp
  clang/test/OpenMP/parallel_masked_default_messages.cpp
  clang/test/OpenMP/parallel_masked_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_master_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/parallel_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_ast_print.cpp
  clang/test/OpenMP/parallel_sections_default_messages.cpp
  clang/test/OpenMP/parallel_sections_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/predefined_macro.c
  clang/test/OpenMP/recovery-crash.cpp
  clang/test/OpenMP/requires_acq_rel_codegen.cpp
  clang/test/OpenMP/requires_relaxed_codegen.cpp
  clang/test/OpenMP/requires_seq_cst_codegen.cpp
  clang/test/OpenMP/scan_ast_print.cpp
  clang/test/OpenMP/scan_codegen.cpp
  clang/test/OpenMP/schedule_codegen.cpp
  clang/test/OpenMP/sections_ast_print.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/simd_ast_print.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_data_ast_print.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_addr_ast_print.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_defaultmap_messages.cpp
  clang/test/OpenMP/target_depend_messages.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_device_messages.cpp
  clang/test/OpenMP/target_enter_data_depend_messages.cpp
  clang/test/OpenMP/target_exit_data_depend_messages.cpp
  clang/test/OpenMP/target_has_device_addr_messages.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_ast_print.cpp
  clang/test/OpenMP/target_parallel_default_messages.cpp
  clang/test/OpenMP/target_parallel_defaultmap_messages.cpp
  clang/test/OpenMP/target_parallel_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_ast_print.cpp
  clang/test/OpenMP/target_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_defaultmap_messages.cpp
  

[PATCH] D130210: [SemaCXX] Set promotion type for enum bool to integer type.

2022-07-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

We seem to have a few tests with enums that bool as a specified type. Maybe 
this belongs better in one of those under the namespace `GH56560`

I am curious that this does not change the test results of 
`clang/test/CXX/conv/conv.prom/p4.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130210

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


[PATCH] D129992: [clang][OpenMP] Add IRBuilder support for taskgroup

2022-07-20 Thread Shraiysh 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 rG61fa7a88c7b6: [clang][OpenMP] Add IRBuilder support for 
taskgroup (authored by shraiysh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129992

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp

Index: clang/test/OpenMP/taskgroup_codegen.cpp
===
--- clang/test/OpenMP/taskgroup_codegen.cpp
+++ clang/test/OpenMP/taskgroup_codegen.cpp
@@ -8,6 +8,9 @@
 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
 // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=CHECK2
+
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
@@ -168,3 +171,69 @@
 // DEBUG1-NEXT:call void @__clang_call_terminate(i8* [[TMP3]]) #[[ATTR8]], !dbg [[DBG25]]
 // DEBUG1-NEXT:unreachable, !dbg [[DBG25]]
 //
+
+// CHECK2-LABEL: define dso_local void @_Z3foov() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:call void @_Z8mayThrowv()
+// CHECK2-NEXT:ret void
+
+// CHECK2-LABEL: define dso_local noundef i32 @main() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:%[[RETVAL:.+]] = alloca i32, align 4
+// CHECK2-NEXT:%[[A:.+]] = alloca i8, align 1
+// CHECK2-NEXT:store i32 0, i32* %[[RETVAL]], align 4
+// CHECK2-NEXT:%[[OMP_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:store i8 2, i8* %[[A]], align 1
+// CHECK2-NEXT:br label %taskgroup.exit
+
+// CHECK2:   taskgroup.exit:
+// CHECK2-NEXT:call void @__kmpc_end_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:%[[OMP_THREAD_NUM2:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM2]])
+// CHECK2-NEXT:call void @_Z3foov()
+// CHECK2-NEXT:br label %taskgroup.exit2
+
+// CHECK2:   taskgroup.exit2:
+// CHECK2-NEXT:call void @__kmpc_end_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM2]])
+// CHECK2-NEXT:%[[TMP:.+]] = load i8, i8* %[[A]], align 1
+// CHECK2-NEXT:%[[CONV:.+]] = sext i8 %[[TMP]] to i32
+// CHECK2-NEXT:ret i32 %[[CONV]]
+
+// CHECK2-LABEL: define dso_local void @_Z18parallel_taskgroupv() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:%[[OMP_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:br label %omp_parallel
+
+// CHECK2:   omp_parallel:
+// CHECK2-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @_Z18parallel_taskgroupv..omp_par to void (i32*, i32*, ...)*))
+// CHECK2-NEXT:br label %omp.par.outlined.exit
+
+// CHECK2:   omp.par.outlined.exit:
+// CHECK2-NEXT:br label %omp.par.exit.split
+
+// CHECK2:   omp.par.exit.split:
+// CHECK2-NEXT:ret void
+
+// CHECK2-LABEL: define internal void @_Z18parallel_taskgroupv..omp_par(i32* noalias %{{.+}}, i32* noalias %{{.+}}) #{{.+}} {
+// CHECK2:   omp.par.entry:
+// CHECK2: br label %omp.par.region
+
+// CHECK2:   omp.par.region:
+// CHECK2-NEXT:%[[OMP_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:call void @_Z3foov()
+// CHECK2-NEXT:br label %taskgroup.exit
+
+// CHECK2:   taskgroup.exit:
+// CHECK2-NEXT:call void @__kmpc_end_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:br label %omp.par.region.parallel.after
+
+// CHECK2:   omp.par.region.parallel.after:
+// CHECK2-NEXT:br label %omp.par.pre_finalize
+
+// CHECK2:   omp.par.pre_finalize:
+// CHECK2-NEXT:br label %omp.par.outlined.exit.exitStub
+
+// CHECK2:   omp.par.outlined.exit.exitStub:
+// CHECK2-NEXT:ret void
Index: 

[clang] 61fa7a8 - [clang][OpenMP] Add IRBuilder support for taskgroup

2022-07-20 Thread Shraiysh Vaishay via cfe-commits

Author: Shraiysh Vaishay
Date: 2022-07-21T11:13:57+05:30
New Revision: 61fa7a88c7b6360222d4107e938529f2dccc1176

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

LOG: [clang][OpenMP] Add IRBuilder support for taskgroup

This patch makes use of OMPIRBuilder support for codegen of taskgroup
construct in clang.

Depends on D128203

Reviewed By: Meinersbur

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/taskgroup_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index db0b2ffd3a4f6..aa55cdaca5dca 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5203,8 +5203,30 @@ void CodeGenFunction::EmitOMPTaskwaitDirective(const 
OMPTaskwaitDirective ) {
   CGM.getOpenMPRuntime().emitTaskwaitCall(*this, S.getBeginLoc(), Data);
 }
 
+bool isSupportedByOpenMPIRBuilder(const OMPTaskgroupDirective ) {
+  return T.clauses().empty();
+}
+
 void CodeGenFunction::EmitOMPTaskgroupDirective(
 const OMPTaskgroupDirective ) {
+  OMPLexicalScope Scope(*this, S, OMPD_unknown);
+  if (CGM.getLangOpts().OpenMPIRBuilder && isSupportedByOpenMPIRBuilder(S)) {
+llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
+using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+InsertPointTy AllocaIP(AllocaInsertPt->getParent(),
+   AllocaInsertPt->getIterator());
+
+auto BodyGenCB = [&, this](InsertPointTy AllocaIP,
+   InsertPointTy CodeGenIP) {
+  Builder.restoreIP(CodeGenIP);
+  EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt());
+};
+CodeGenFunction::CGCapturedStmtInfo CapStmtInfo;
+if (!CapturedStmtInfo)
+  CapturedStmtInfo = 
+Builder.restoreIP(OMPBuilder.createTaskgroup(Builder, AllocaIP, 
BodyGenCB));
+return;
+  }
   auto & = [](CodeGenFunction , PrePostActionTy ) {
 Action.Enter(CGF);
 if (const Expr *E = S.getReductionRef()) {
@@ -5230,7 +5252,6 @@ void CodeGenFunction::EmitOMPTaskgroupDirective(
 }
 CGF.EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt());
   };
-  OMPLexicalScope Scope(*this, S, OMPD_unknown);
   CGM.getOpenMPRuntime().emitTaskgroupRegion(*this, CodeGen, S.getBeginLoc());
 }
 

diff  --git a/clang/test/OpenMP/taskgroup_codegen.cpp 
b/clang/test/OpenMP/taskgroup_codegen.cpp
index bf55999641119..b6bd1cd1e2a0b 100644
--- a/clang/test/OpenMP/taskgroup_codegen.cpp
+++ b/clang/test/OpenMP/taskgroup_codegen.cpp
@@ -8,6 +8,9 @@
 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s 
--implicit-check-not="{{__kmpc|__tgt}}"
 // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 
-fopenmp-simd -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only 
-x c++ -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp 
-fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm %s 
-fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=CHECK2
+
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
@@ -168,3 +171,69 @@ void parallel_taskgroup() {
 // DEBUG1-NEXT:call void @__clang_call_terminate(i8* [[TMP3]]) #[[ATTR8]], 
!dbg [[DBG25]]
 // DEBUG1-NEXT:unreachable, !dbg [[DBG25]]
 //
+
+// CHECK2-LABEL: define dso_local void @_Z3foov() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:call void @_Z8mayThrowv()
+// CHECK2-NEXT:ret void
+
+// CHECK2-LABEL: define dso_local noundef i32 @main() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:%[[RETVAL:.+]] = alloca i32, align 4
+// CHECK2-NEXT:%[[A:.+]] = alloca i8, align 1
+// CHECK2-NEXT:store i32 0, i32* %[[RETVAL]], align 4
+// CHECK2-NEXT:%[[OMP_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 
%[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:store i8 2, i8* %[[A]], align 1
+// CHECK2-NEXT:br label %taskgroup.exit
+
+// CHECK2:   taskgroup.exit:
+// CHECK2-NEXT:call void @__kmpc_end_taskgroup(%struct.ident_t* @{{.+}}, 
i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:%[[OMP_THREAD_NUM2:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 
%[[OMP_THREAD_NUM2]])
+// 

[PATCH] D54943: [clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

2022-07-20 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

LGTM with those changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D129448: [CodeGen][Asan] Emit lifetime intrinsic for bypassed label

2022-07-20 Thread luxufan via Phabricator via cfe-commits
StephenFan added inline comments.



Comment at: clang/test/CodeGen/lifetime2.c:42
+// O2: @llvm.lifetime.start.p0i8(i64 1
 bar(, 1);
+// O2: @llvm.lifetime.end.p0i8(i64 1

StephenFan wrote:
> vitalybuka wrote:
> > It assume this will break Msan 
> > Transforms/Instrumentation/MemorySanitizer.cpp:1298 as it assume variable 
> > is not initialized on start
> > 
> > ```
> > void goto_bypass(void) {
> >   {
> > char x;
> >   l1:
> > bar(, 1);
> >if (x)
> >  goto l1
> >   }
> >   goto l1;
> > }
> > ```
> Yes. I still need some time to see how to deal with it.
Candidate solution: D129991


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129448

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


[PATCH] D129992: [clang][OpenMP] Add IRBuilder support for taskgroup

2022-07-20 Thread Shraiysh via Phabricator via cfe-commits
shraiysh updated this revision to Diff 446355.
shraiysh added a comment.

Rebase with main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129992

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp

Index: clang/test/OpenMP/taskgroup_codegen.cpp
===
--- clang/test/OpenMP/taskgroup_codegen.cpp
+++ clang/test/OpenMP/taskgroup_codegen.cpp
@@ -8,6 +8,9 @@
 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
 // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=CHECK2
+
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
@@ -168,3 +171,69 @@
 // DEBUG1-NEXT:call void @__clang_call_terminate(i8* [[TMP3]]) #[[ATTR8]], !dbg [[DBG25]]
 // DEBUG1-NEXT:unreachable, !dbg [[DBG25]]
 //
+
+// CHECK2-LABEL: define dso_local void @_Z3foov() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:call void @_Z8mayThrowv()
+// CHECK2-NEXT:ret void
+
+// CHECK2-LABEL: define dso_local noundef i32 @main() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:%[[RETVAL:.+]] = alloca i32, align 4
+// CHECK2-NEXT:%[[A:.+]] = alloca i8, align 1
+// CHECK2-NEXT:store i32 0, i32* %[[RETVAL]], align 4
+// CHECK2-NEXT:%[[OMP_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:store i8 2, i8* %[[A]], align 1
+// CHECK2-NEXT:br label %taskgroup.exit
+
+// CHECK2:   taskgroup.exit:
+// CHECK2-NEXT:call void @__kmpc_end_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:%[[OMP_THREAD_NUM2:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM2]])
+// CHECK2-NEXT:call void @_Z3foov()
+// CHECK2-NEXT:br label %taskgroup.exit2
+
+// CHECK2:   taskgroup.exit2:
+// CHECK2-NEXT:call void @__kmpc_end_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM2]])
+// CHECK2-NEXT:%[[TMP:.+]] = load i8, i8* %[[A]], align 1
+// CHECK2-NEXT:%[[CONV:.+]] = sext i8 %[[TMP]] to i32
+// CHECK2-NEXT:ret i32 %[[CONV]]
+
+// CHECK2-LABEL: define dso_local void @_Z18parallel_taskgroupv() #{{.+}} {
+// CHECK2:   entry:
+// CHECK2-NEXT:%[[OMP_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:br label %omp_parallel
+
+// CHECK2:   omp_parallel:
+// CHECK2-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @_Z18parallel_taskgroupv..omp_par to void (i32*, i32*, ...)*))
+// CHECK2-NEXT:br label %omp.par.outlined.exit
+
+// CHECK2:   omp.par.outlined.exit:
+// CHECK2-NEXT:br label %omp.par.exit.split
+
+// CHECK2:   omp.par.exit.split:
+// CHECK2-NEXT:ret void
+
+// CHECK2-LABEL: define internal void @_Z18parallel_taskgroupv..omp_par(i32* noalias %{{.+}}, i32* noalias %{{.+}}) #{{.+}} {
+// CHECK2:   omp.par.entry:
+// CHECK2: br label %omp.par.region
+
+// CHECK2:   omp.par.region:
+// CHECK2-NEXT:%[[OMP_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @{{.+}})
+// CHECK2-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:call void @_Z3foov()
+// CHECK2-NEXT:br label %taskgroup.exit
+
+// CHECK2:   taskgroup.exit:
+// CHECK2-NEXT:call void @__kmpc_end_taskgroup(%struct.ident_t* @{{.+}}, i32 %[[OMP_THREAD_NUM]])
+// CHECK2-NEXT:br label %omp.par.region.parallel.after
+
+// CHECK2:   omp.par.region.parallel.after:
+// CHECK2-NEXT:br label %omp.par.pre_finalize
+
+// CHECK2:   omp.par.pre_finalize:
+// CHECK2-NEXT:br label %omp.par.outlined.exit.exitStub
+
+// CHECK2:   omp.par.outlined.exit.exitStub:
+// CHECK2-NEXT:ret void
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ 

[PATCH] D129982: [clang-format][NFC] Refactor RequiresDoesNotChangeParsingOfTheRest

2022-07-20 Thread Owen Pan 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 rGa4c62f66545d: [clang-format][NFC] Refactor 
RequiresDoesNotChangeParsingOfTheRest (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129982

Files:
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -549,323 +549,171 @@
 }
 
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
-  auto NumberOfAdditionalRequiresClauseTokens = 5u;
-  auto NumberOfTokensBeforeRequires = 5u;
-
-  auto BaseTokens = annotate("template\n"
- "T Pi = 3.14;");
-  auto ConstrainedTokens = annotate("template\n"
-"  requires Foo\n"
-"T Pi = 3.14;");
-
-  auto NumberOfBaseTokens = 11u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
+  const char *BaseCode = nullptr;
+  const char *ConstrainedCode = nullptr;
+  auto BaseTokenCount = 0u;
+  auto RequiresTokenCount = 0u;
+  auto PrefixTokenCount = 0u;
+
+  auto TestRequires = [&](int Line) {
+const auto BaseTokens = annotate(BaseCode);
+const auto ConstrainedTokens = annotate(ConstrainedCode);
+
+#define LINE " (Line " << Line << ')'
+
+ASSERT_EQ(BaseTokens.size(), BaseTokenCount) << BaseTokens << LINE;
+ASSERT_EQ(ConstrainedTokens.size(), BaseTokenCount + RequiresTokenCount)
+<< LINE;
+
+for (auto I = 0u; I < BaseTokenCount; ++I) {
+  EXPECT_EQ(
+  *BaseTokens[I],
+  *ConstrainedTokens[I < PrefixTokenCount ? I : I + RequiresTokenCount])
+  << I << LINE;
 }
-  }
 
-  BaseTokens = annotate("template\n"
-"struct Bar;");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "struct Bar;");
-  NumberOfBaseTokens = 9u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
-}
-  }
-
-  BaseTokens = annotate("template\n"
-"struct Bar {"
-"  T foo();\n"
-"  T bar();\n"
-"};");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "struct Bar {"
-   "  T foo();\n"
-   "  T bar();\n"
-   "};");
-  NumberOfBaseTokens = 21u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
-}
-  }
-
-  BaseTokens = annotate("template\n"
-"Bar(T) -> Bar;");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "Bar(T) -> Bar;");
-  NumberOfBaseTokens = 16u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-

[clang] a4c62f6 - [clang-format][NFC] Refactor RequiresDoesNotChangeParsingOfTheRest

2022-07-20 Thread via cfe-commits

Author: owenca
Date: 2022-07-20T21:56:48-07:00
New Revision: a4c62f66545d11253ef76384b78d9dc196fc8e0e

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

LOG: [clang-format][NFC] Refactor RequiresDoesNotChangeParsingOfTheRest

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

Added: 


Modified: 
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index bdbfca78a6cb..4b2622522e0f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -549,323 +549,171 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresExpressions) {
 }
 
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
-  auto NumberOfAdditionalRequiresClauseTokens = 5u;
-  auto NumberOfTokensBeforeRequires = 5u;
-
-  auto BaseTokens = annotate("template\n"
- "T Pi = 3.14;");
-  auto ConstrainedTokens = annotate("template\n"
-"  requires Foo\n"
-"T Pi = 3.14;");
-
-  auto NumberOfBaseTokens = 11u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
+  const char *BaseCode = nullptr;
+  const char *ConstrainedCode = nullptr;
+  auto BaseTokenCount = 0u;
+  auto RequiresTokenCount = 0u;
+  auto PrefixTokenCount = 0u;
+
+  auto TestRequires = [&](int Line) {
+const auto BaseTokens = annotate(BaseCode);
+const auto ConstrainedTokens = annotate(ConstrainedCode);
+
+#define LINE " (Line " << Line << ')'
+
+ASSERT_EQ(BaseTokens.size(), BaseTokenCount) << BaseTokens << LINE;
+ASSERT_EQ(ConstrainedTokens.size(), BaseTokenCount + RequiresTokenCount)
+<< LINE;
+
+for (auto I = 0u; I < BaseTokenCount; ++I) {
+  EXPECT_EQ(
+  *BaseTokens[I],
+  *ConstrainedTokens[I < PrefixTokenCount ? I : I + 
RequiresTokenCount])
+  << I << LINE;
 }
-  }
 
-  BaseTokens = annotate("template\n"
-"struct Bar;");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "struct Bar;");
-  NumberOfBaseTokens = 9u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
-}
-  }
-
-  BaseTokens = annotate("template\n"
-"struct Bar {"
-"  T foo();\n"
-"  T bar();\n"
-"};");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "struct Bar {"
-   "  T foo();\n"
-   "  T bar();\n"
-   "};");
-  NumberOfBaseTokens = 21u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-if (I < NumberOfTokensBeforeRequires) {
-  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
-} else {
-  EXPECT_EQ(*BaseTokens[I],
-*ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens])
-  << I;
-}
-  }
-
-  BaseTokens = annotate("template\n"
-"Bar(T) -> Bar;");
-  ConstrainedTokens = annotate("template\n"
-   "  requires Foo\n"
-   "Bar(T) -> Bar;");
-  NumberOfBaseTokens = 16u;
-
-  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
-  ASSERT_EQ(ConstrainedTokens.size(),
-NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
-  << ConstrainedTokens;
-
-  for (auto I = 0u; I < NumberOfBaseTokens; ++I) {
-  

[PATCH] D130136: [clang-format] Indent tokens after hash only if it starts a line

2022-07-20 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG892a9968ec77: [clang-format] Indent tokens after hash only 
if it starts a line (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130136

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5385,6 +5385,10 @@
"#endif",
Style);
   Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#if 1\n"
+   "#  define __STR(x) #x\n"
+   "#endif",
+   Style);
   verifyFormat("#ifdef _WIN32\n"
"#  define A 0\n"
"#  ifdef VAR2\n"
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -656,6 +656,7 @@
   int PPColumnCorrection = 0;
   if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
   Previous.is(tok::hash) && State.FirstIndent > 0 &&
+   == State.Line->First &&
   (State.Line->Type == LT_PreprocessorDirective ||
State.Line->Type == LT_ImportStatement)) {
 Spaces += State.FirstIndent;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5385,6 +5385,10 @@
"#endif",
Style);
   Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#if 1\n"
+   "#  define __STR(x) #x\n"
+   "#endif",
+   Style);
   verifyFormat("#ifdef _WIN32\n"
"#  define A 0\n"
"#  ifdef VAR2\n"
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -656,6 +656,7 @@
   int PPColumnCorrection = 0;
   if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
   Previous.is(tok::hash) && State.FirstIndent > 0 &&
+   == State.Line->First &&
   (State.Line->Type == LT_PreprocessorDirective ||
State.Line->Type == LT_ImportStatement)) {
 Spaces += State.FirstIndent;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 892a996 - [clang-format] Indent tokens after hash only if it starts a line

2022-07-20 Thread via cfe-commits

Author: owenca
Date: 2022-07-20T21:52:17-07:00
New Revision: 892a9968ec7753467a7663cb91ee1e5a299844cf

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

LOG: [clang-format] Indent tokens after hash only if it starts a line

Fixes #56602.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 6c13e09282fc..651ec80d6196 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -656,6 +656,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
, bool DryRun,
   int PPColumnCorrection = 0;
   if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
   Previous.is(tok::hash) && State.FirstIndent > 0 &&
+   == State.Line->First &&
   (State.Line->Type == LT_PreprocessorDirective ||
State.Line->Type == LT_ImportStatement)) {
 Spaces += State.FirstIndent;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 038c29914ef6..e26cfb0ee88a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5385,6 +5385,10 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
"#endif",
Style);
   Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#if 1\n"
+   "#  define __STR(x) #x\n"
+   "#endif",
+   Style);
   verifyFormat("#ifdef _WIN32\n"
"#  define A 0\n"
"#  ifdef VAR2\n"



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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-07-20 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:238
+// Stores the mapping between an operand and its BFS traversal information.
+DenseMap operandToItsBFSMap;
+

srishti-pm wrote:
> Mogball wrote:
> > Why can't you sort the OperandBFS directly to avoid the hash map?
> Because comparators are not allowed to modify their input arguments.
The arguments have to be const references? If so, just const_cast 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-07-20 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm marked an inline comment as done.
srishti-pm added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:238
+// Stores the mapping between an operand and its BFS traversal information.
+DenseMap operandToItsBFSMap;
+

Mogball wrote:
> Why can't you sort the OperandBFS directly to avoid the hash map?
Because comparators are not allowed to modify their input arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-07-20 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:238
+// Stores the mapping between an operand and its BFS traversal information.
+DenseMap operandToItsBFSMap;
+

Why can't you sort the OperandBFS directly to avoid the hash map?



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:286
+for (unsigned i = 0, e = op->getNumOperands(); i < e; i++) {
+  OperandBFS *bfs = new OperandBFS();
+  bfs->pushAncestor(operands[i].getDefiningOp());

Can you use unique_ptr so that the memory doesn't leak?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D129461: [PowerPC] Support x86 compatible intrinsics on AIX

2022-07-20 Thread ChenZheng via Phabricator via cfe-commits
shchenz accepted this revision as: shchenz.
shchenz added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the enablement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129461

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


[PATCH] D129461: [PowerPC] Support x86 compatible intrinsics on AIX

2022-07-20 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 446335.
qiucf marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129461

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Headers/ppc_wrappers/emmintrin.h
  clang/lib/Headers/ppc_wrappers/mm_malloc.h
  clang/lib/Headers/ppc_wrappers/mmintrin.h
  clang/lib/Headers/ppc_wrappers/pmmintrin.h
  clang/lib/Headers/ppc_wrappers/smmintrin.h
  clang/lib/Headers/ppc_wrappers/tmmintrin.h
  clang/lib/Headers/ppc_wrappers/xmmintrin.h
  clang/test/CodeGen/PowerPC/ppc-emmintrin.c
  clang/test/CodeGen/PowerPC/ppc-mm-malloc.c
  clang/test/CodeGen/PowerPC/ppc-mmintrin.c
  clang/test/CodeGen/PowerPC/ppc-pmmintrin.c
  clang/test/CodeGen/PowerPC/ppc-smmintrin.c
  clang/test/CodeGen/PowerPC/ppc-tmmintrin.c
  clang/test/CodeGen/PowerPC/ppc-x86gprintrin.c
  clang/test/CodeGen/PowerPC/ppc-xmmintrin.c

Index: clang/test/CodeGen/PowerPC/ppc-xmmintrin.c
===
--- clang/test/CodeGen/PowerPC/ppc-xmmintrin.c
+++ clang/test/CodeGen/PowerPC/ppc-xmmintrin.c
@@ -10,7 +10,7 @@
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr10 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-P10
+// RUN:   -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-P10-LE
 
 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -nostdlibinc -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
@@ -21,6 +21,13 @@
 // RUN: %clang -Xclang -no-opaque-pointers -x c++ -fsyntax-only -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -nostdlibinc -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
+// RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-ibm-aix -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -Xclang -no-opaque-pointers -x c++ -fsyntax-only -target powerpc64-ibm-aix -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
+// RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-ibm-aix -mcpu=pwr10 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-P10-BE
+
 #include 
 
 __m128 res, m1, m2;
@@ -388,7 +395,8 @@
 // CHECK-LABEL: define available_externally signext i32 @_mm_cvtss_si32
 // CHECK-LE: %[[VEC:[0-9a-zA-Z_.]+]] = call { <4 x float>, i32, double } asm "xxsldwi ${0:x},${0:x},${0:x},3;\0Axscvspdp ${2:x},${0:x};\0Afctiw  $2,$2;\0Amfvsrd  $1,${2:x};\0A", "=^wa,=r,=f,0"
 // CHECK-BE: %[[VEC:[0-9a-zA-Z_.]+]] = call { <4 x float>, i32, double } asm "xscvspdp ${2:x},${0:x};\0Afctiw  $2,$2;\0Amfvsrd  $1,${2:x};\0A", "=^wa,=r,=f,0"
-// CHECK-P10: %[[VEC:[0-9a-zA-Z_.]+]] = call { <4 x float>, i32, double } asm "xxsldwi ${0:x},${0:x},${0:x},3;\0Axscvspdp ${2:x},${0:x};\0Afctiw  $2,$2;\0Amfvsrd  $1,${2:x};\0A", "=^wa,=r,=f,0"
+// CHECK-P10-LE: %[[VEC:[0-9a-zA-Z_.]+]] = call { <4 x float>, i32, double } asm "xxsldwi ${0:x},${0:x},${0:x},3;\0Axscvspdp ${2:x},${0:x};\0Afctiw  $2,$2;\0Amfvsrd  $1,${2:x};\0A", "=^wa,=r,=f,0"
+// CHECK-P10-BE: %[[VEC:[0-9a-zA-Z_.]+]] = call { <4 x float>, i32, double } asm "xscvspdp ${2:x},${0:x};\0Afctiw  $2,$2;\0Amfvsrd  $1,${2:x};\0A", "=^wa,=r,=f,0"
 // CHECK: extractvalue { <4 x float>, i32, double } %[[VEC]], 0
 // CHECK: extractvalue { <4 x float>, i32, double } %[[VEC]], 1
 // CHECK: extractvalue { <4 x float>, i32, double } %[[VEC]], 2
@@ -688,7 +696,8 @@
 // CHECK-BE: call <2 x i64> @vec_vbpermq(unsigned char vector[16], unsigned char vector[16])(<16 x i8> noundef %{{[0-9a-zA-Z_.]+}}, <16 x i8> noundef bitcast (<4 x i32>  to <16 x i8>))
 // CHECK-BE: %[[EXT:[0-9a-zA-Z_.]+]] = extractelement <2 x i64> %{{[0-9a-zA-Z_.]+}}, i32 0
 // CHECK-BE: trunc i64 %[[EXT]] to i32
-// CHECK-P10: call zeroext i32 @vec_extractm(unsigned int vector[4])(<4 x i32> noundef %{{[0-9a-zA-Z_.]+}})
+// CHECK-P10-LE: call zeroext i32 @vec_extractm(unsigned int vector[4])(<4 x i32> noundef %{{[0-9a-zA-Z_.]+}})
+// CHECK-P10-BE: call zeroext i32 @vec_extractm(unsigned int vector[4])(<4 x i32> noundef %{{[0-9a-zA-Z_.]+}})
 
 void 

[PATCH] D130168: [CUDA] remove duplicate condition

2022-07-20 Thread VitalyR via Phabricator via cfe-commits
VitalyR added a comment.

@yaxunl Hi! Could you commit this on my behalf? I read the documentation and it 
seems the appropriate way to commit changes for a newcomer not having commit 
access like me. My name is "VitalyR" and my email address is 
"vitalya...@gmail.com". Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130168

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-20 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D126907#3665900 , @erichkeane 
wrote:

> The more I look at this... the more I question my approach.  I now am 
> definitely sure we won't make Clang15, and hope that I can figure something 
> better out for 16 :/

I feel like it could be helpful to split it into several small patches next 
time.


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

https://reviews.llvm.org/D126907

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


[PATCH] D129855: [clang][PowerPC] Set lld as clang's default linker for PowerPC Linux

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D129855#3662457 , @quinnp wrote:

> In D129855#3657006 , @MaskRay wrote:
>
>> This is not right as using `ld.lld` as the default linker isn't the majority 
>> case. If you want to change the default for your distribution, set 
>> `-DCLANG_DEFAULT_LINKER=lld`.
>> (Alternatively, you can have a `ld` symlink pointing to `lld`.)
>
> Hi @MaskRay! Do you mean I should abandon this change or find a way to set 
> the CMake variable `CLANG_DEFAULT_LINKER` to `lld` as default when building 
> for PowerPC Linux? I wasn't able to find any examples of people setting CMake 
> variables for specific distributions.
>
> Thanks!

You can customize `CLANG_DEFAULT_LINKER` in your clang distribution. I don't 
find convincing argument to change the default for `PPCLinuxToolChain` and 
diverge from `Linux`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129855

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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2022-07-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D28213

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


[PATCH] D130078: [flang][nfc] Rename `AddOtherOptions` as `ForwardOptions`

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

`forwardOptions` will be better if you are renaming it anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130078

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


[PATCH] D130138: [modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D130138#3664913 , @iains wrote:

> makes sense to me...
>
> I guess the name looks long at first, but it's specific (I find that 
> easy-to-remember flag names are more important than short-to-type ones, but 
> maybe that's just me) - I wonder if @MaskRay has any comments on the flag 
> name,
>
> For the record:
> GCC uses : -flang-info-include-translate (-flang for flag-language, rather 
> than 'flang', of course).
> (which is a note, i.e. similar idea to the remark)
>
> BTW.. (not for this patch, of course)
> GCC also has 
> info-include-translate-not
> Note #include directives not translated to import declarations, and not known 
> to be textual.

Using remarks is suitable and the new name -Rmodule-include-translation looks 
good to me.

Thanks for mentioning similar options from GCC. The names feel a bit odd to me 
as I am thinking what "lang-info" means.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130138

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


[PATCH] D128845: [HLSL]Add -O and -Od option for dxc mode.

2022-07-20 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 446310.
python3kgae added a comment.

Use CLDXCOption for opt level.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128845

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/test/CodeGenHLSL/disable_opt.hlsl
  clang/test/Driver/dxc_O.hlsl

Index: clang/test/Driver/dxc_O.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_O.hlsl
@@ -0,0 +1,19 @@
+// RUN: %clang_dxc -T lib_6_7  foo.hlsl -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -T lib_6_7 -Od foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=Od
+// RUN: %clang_dxc -T lib_6_7 -O0 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O0
+// RUN: %clang_dxc -T lib_6_7 -O1 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O1
+// RUN: %clang_dxc -T lib_6_7 -O2 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O2
+// RUN: %clang_dxc -T lib_6_7 -O3 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O3
+
+// Make sure default is O3.
+// CHECK: "-O3"
+
+// Make sure Od option flag which translated into "-O0" "-dxc-opt-disable"
+// Od: "-O0"
+// Od-SAME: "-dxc-opt-disable"
+
+// Make sure O0/O1/O2/O3 is send to cc1.
+// O0: "-O0"
+// O1: "-O1"
+// O2: "-O2"
+// O3: "-O3"
Index: clang/test/CodeGenHLSL/disable_opt.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/disable_opt.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -dxc-opt-disable -emit-llvm -xhlsl  -o - %s | FileCheck %s
+// RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -emit-llvm -xhlsl  -o - %s | FileCheck %s --check-prefix=OPT
+
+// CHECK:!"dx.disable_optimizations", i32 1}
+
+// OPT-NOT:"dx.disable_optimizations"
+
+float bar(float a, float b);
+
+float foo(float a, float b) {
+  return bar(a, b);
+}
Index: clang/lib/Driver/ToolChains/HLSL.cpp
===
--- clang/lib/Driver/ToolChains/HLSL.cpp
+++ clang/lib/Driver/ToolChains/HLSL.cpp
@@ -158,6 +158,19 @@
   if (!isLegalValidatorVersion(ValVerStr, getDriver()))
 continue;
 }
+if (A->getOption().getID() == options::OPT__SLASH_O) {
+  StringRef OStr = A->getValue();
+  if (OStr == "d") {
+DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_dxc_opt_disable));
+DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_O0));
+A->claim();
+continue;
+  } else {
+DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O), OStr);
+A->claim();
+continue;
+  }
+}
 if (A->getOption().getID() == options::OPT_emit_pristine_llvm) {
   // Translate fcgl into -S -emit-llvm and -disable-llvm-passes.
   DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_S));
@@ -177,6 +190,9 @@
 Opts.getOption(options::OPT_dxil_validator_version),
 DefaultValidatorVer);
   }
+  if (!DAL->hasArg(options::OPT_O_Group)) {
+DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O), "3");
+  }
   // FIXME: add validation for enable_16bit_types should be after HLSL 2018 and
   // shader model 6.2.
   return DAL;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3513,6 +3513,8 @@
  options::OPT_D,
  options::OPT_I,
  options::OPT_S,
+ options::OPT_O,
+ options::OPT_dxc_opt_disable,
  options::OPT_emit_llvm,
  options::OPT_disable_llvm_passes,
  options::OPT_fnative_half_type};
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -42,6 +42,11 @@
   StringRef DxilValKey = "dx.valver";
   M.addModuleFlag(llvm::Module::ModFlagBehavior::AppendUnique, DxilValKey, Val);
 }
+void addDisableOptimizations(llvm::Module ) {
+  StringRef Key = "dx.disable_optimizations";
+  M.addModuleFlag(llvm::Module::ModFlagBehavior::Override, Key, 1);
+}
+
 } // namespace
 
 void CGHLSLRuntime::finishCodeGen() {
@@ -49,4 +54,6 @@
 
   llvm::Module  = CGM.getModule();
   addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
+  if (TargetOpts.DxcOptDisable)
+addDisableOptimizations(M);
 }
Index: clang/include/clang/Driver/Options.td

[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2022-07-20 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added subscribers: t.p.northover, EricWF, rsmith.
rprichard edited reviewers, added: efriedma, craig.topper; removed: 
t.p.northover, EricWF, rsmith.
rprichard added a comment.
Herald added a subscriber: StephenFan.

@efriedma @craig.topper Could you review this patch (or suggest someone else 
that could)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D28213

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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2022-07-20 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard updated this revision to Diff 446302.
rprichard added a comment.

Stylistic change: keep the -ALIGN32 and -ALIGN64 suffixes in the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D28213

Files:
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/init-x86.c
  clang/test/Sema/atomic-ops.c


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -33,11 +33,7 @@
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == __CLANG_ATOMIC_INT_LOCK_FREE, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == __CLANG_ATOMIC_LONG_LOCK_FREE, 
"");
-#ifdef __i386__
-_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
-#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
-#endif
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == __CLANG_ATOMIC_LLONG_LOCK_FREE, 
"");
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 
__CLANG_ATOMIC_POINTER_LOCK_FREE, "");
Index: clang/test/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -185,9 +185,9 @@
 // I386:#define __i386__ 1
 // I386:#define i386 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN32 %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-CXX 
-check-prefix I386-LINUX-ALIGN32 %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 -malign-double < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-LINUX -check-prefix 
I386-LINUX-ALIGN64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu i486 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN32 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN64 %s
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN64 
-check-prefix I386-LINUX-CXX %s
 //
 // I386-LINUX-NOT:#define _LP64
 // I386-LINUX:#define __BIGGEST_ALIGNMENT__ 16
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -298,12 +298,12 @@
 
 /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
 /// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
-unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
   // Fully-aligned, power-of-2 sizes no larger than the inline
   // width will be inlined as lock-free operations.
-  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
-  TypeWidth <= InlineWidth)
+  // Note: we do not need to check alignment since _Atomic(T) is always
+  // appropriately-aligned in clang.
+  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
 return "2"; // "always lock free"
   // We cannot be certain what operations the lib calls might be
   // able to implement as lock-free on future processors.
@@ -1148,7 +1148,6 @@
 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) 
\
   Builder.defineMacro(Prefix + #TYPE "_LOCK_FREE", 
\
   getLockFreeValue(TI.get##Type##Width(),  
\
-   TI.get##Type##Align(),  
\
InlineWidthBits));
 DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
 DEFINE_LOCK_FREE_MACRO(CHAR, Char);
@@ -1163,7 +1162,6 @@
 DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
 Builder.defineMacro(Prefix + "POINTER_LOCK_FREE",
 getLockFreeValue(TI.getPointerWidth(0),
- TI.getPointerAlign(0),
  InlineWidthBits));
 #undef DEFINE_LOCK_FREE_MACRO
   };


Index: clang/test/Sema/atomic-ops.c
===
--- 

[PATCH] D117977: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

2022-07-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 446301.
Ericson2314 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117977

Files:
  bolt/tools/CMakeLists.txt
  bolt/tools/driver/CMakeLists.txt
  bolt/tools/heatmap/CMakeLists.txt
  bolt/tools/merge-fdata/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/cmake/modules/TableGen.cmake
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  mlir/tools/mlir-cpu-runner/CMakeLists.txt
  mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
  mlir/tools/mlir-lsp-server/CMakeLists.txt
  mlir/tools/mlir-opt/CMakeLists.txt
  mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
  mlir/tools/mlir-reduce/CMakeLists.txt
  mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
  mlir/tools/mlir-translate/CMakeLists.txt
  mlir/tools/mlir-vulkan-runner/CMakeLists.txt
  mlir/tools/tblgen-lsp-server/CMakeLists.txt
  openmp/libomptarget/tools/CMakeLists.txt
  openmp/libomptarget/tools/deviceinfo/CMakeLists.txt

Index: openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
===
--- openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
+++ openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
@@ -12,7 +12,7 @@
 
 libomptarget_say("Building the llvm-omp-device-info tool")
 
-add_llvm_tool(llvm-omp-device-info llvm-omp-device-info.cpp)
+add_openmp_tool(llvm-omp-device-info llvm-omp-device-info.cpp)
 
 llvm_update_compile_flags(llvm-omp-device-info)
 
Index: openmp/libomptarget/tools/CMakeLists.txt
===
--- openmp/libomptarget/tools/CMakeLists.txt
+++ openmp/libomptarget/tools/CMakeLists.txt
@@ -10,4 +10,18 @@
 #
 ##===--===##
 
+set(OPENMP_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
+"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
+mark_as_advanced(OPENMP_TOOLS_INSTALL_DIR)
+
+# Move these macros to AddOpenMP if such a CMake module is ever created.
+
+macro(add_openmp_tool name)
+  llvm_add_tool(OPENMP ${ARGV})
+endmacro()
+
+macro(add_openmp_tool_symlink name)
+  llvm_add_tool_symlink(OPENMP ${ARGV})
+endmacro()
+
 add_subdirectory(deviceinfo)
Index: mlir/tools/tblgen-lsp-server/CMakeLists.txt
===
--- mlir/tools/tblgen-lsp-server/CMakeLists.txt
+++ mlir/tools/tblgen-lsp-server/CMakeLists.txt
@@ -2,7 +2,7 @@
   TableGenLspServerLib
   )
 
-add_llvm_tool(tblgen-lsp-server
+add_mlir_tool(tblgen-lsp-server
   tblgen-lsp-server.cpp
 
   DEPENDS
Index: mlir/tools/mlir-vulkan-runner/CMakeLists.txt
===
--- mlir/tools/mlir-vulkan-runner/CMakeLists.txt
+++ mlir/tools/mlir-vulkan-runner/CMakeLists.txt
@@ -88,7 +88,7 @@
 LIST(APPEND targets_to_link "LLVM${t}")
   ENDFOREACH(t)
 
-  add_llvm_tool(mlir-vulkan-runner
+  add_mlir_tool(mlir-vulkan-runner
 mlir-vulkan-runner.cpp
 
 DEPENDS
Index: mlir/tools/mlir-translate/CMakeLists.txt
===
--- mlir/tools/mlir-translate/CMakeLists.txt
+++ mlir/tools/mlir-translate/CMakeLists.txt
@@ -5,7 +5,7 @@
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
 get_property(translation_libs GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
 
-add_llvm_tool(mlir-translate
+add_mlir_tool(mlir-translate
   mlir-translate.cpp
   )
 llvm_update_compile_flags(mlir-translate)
Index: mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
===
--- mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
+++ mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
@@ -5,7 +5,7 @@
 if (MLIR_ENABLE_SPIRV_CPU_RUNNER)
   message(STATUS "Building SPIR-V CPU runner")
 
-  add_llvm_tool(mlir-spirv-cpu-runner
+  add_mlir_tool(mlir-spirv-cpu-runner
 mlir-spirv-cpu-runner.cpp
   )
 
Index: mlir/tools/mlir-reduce/CMakeLists.txt
===
--- mlir/tools/mlir-reduce/CMakeLists.txt
+++ mlir/tools/mlir-reduce/CMakeLists.txt
@@ -17,7 +17,7 @@
   MLIRReduceLib
   )
 
-add_llvm_tool(mlir-reduce
+add_mlir_tool(mlir-reduce
   mlir-reduce.cpp
 
   DEPENDS
Index: mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
===
--- mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
+++ mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
@@ -2,7 +2,7 @@
   MLIRPdllLspServerLib
   )
 
-add_llvm_tool(mlir-pdll-lsp-server
+add_mlir_tool(mlir-pdll-lsp-server
   mlir-pdll-lsp-server.cpp
 
   DEPENDS

[PATCH] D130123: Extend ptr32 support to be applied on typedef

2022-07-20 Thread Ariel Burton via Phabricator via cfe-commits
Ariel-Burton added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:7116
+  for (;;) {
+if (const TypedefType *TT = dyn_cast(Desugared)) {
+  Desugared = TT->desugar();

rnk wrote:
> Ariel-Burton wrote:
> > rnk wrote:
> > > This seems like a good place to use getSingleStepDesugaredType to look 
> > > through all type sugar (parens, typedefs, template substitutions, etc).
> > > This seems like a good place to use getSingleStepDesugaredType to look 
> > > through all type sugar (parens, typedefs, template substitutions, etc).
> > 
> > I'm not sure what you mean.  Could you expand a little, please?
> Clang's AST has lots of "type sugar nodes". These are types which usually 
> don't have any semantic meaning, they just carry source location information, 
> like whether there was a typedef or extra parens in the type. AttributedType 
> is also a type sugar node, so we cannot do a full desugaring here, we have to 
> step through each node one at a time to accumulate the attributes.
> 
> Your code looks through one kind of type sugar, but this loop should probably 
> be generalized to handle all kinds of type sugar. I think 
> getSingleStepDesugaredType will do that.
Thanks for the clarification.  Do you mean something like:

 
```
 for (;;) {
const AttributedType *AT = dyn_cast(Desugared);
if (AT) {
  Attrs[AT->getAttrKind()] = true;
  Desugared = AT->getModifiedType();
} else {
  QualType QT = Desugared.getSingleStepDesugaredType(S.Context);
  if (Desugared != QT) {
Desugared = QT;
  } else {
break;
  }
}
  }
```

I don't think that we can use getSingleStepDesugaredType indiscriminately.  Not 
all sugar should be peeled away, for example, in the case of of parentheses:


```
int *(__ptr32 wrong);
```

is accepted when it shouldn't.

To check for the cases where we don't want to desugar has the same sort of 
complexity as checking for the cases where we do.  I suggest going with the 
original proposal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130123

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


[PATCH] D130205: [Darwin toolchain] Tune the logic for finding arclite.

2022-07-20 Thread Steven Wu 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 rGd0728260577d: [Darwin toolchain] Tune the logic for finding 
arclite. (authored by steven_wu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130205

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


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1141,25 +1141,38 @@
   SmallString<128> P(getDriver().ClangExecutable);
   llvm::sys::path::remove_filename(P); // 'clang'
   llvm::sys::path::remove_filename(P); // 'bin'
+  llvm::sys::path::append(P, "lib", "arc");
 
   // 'libarclite' usually lives in the same toolchain as 'clang'. However, the
   // Swift open source toolchains for macOS distribute Clang without 
libarclite.
   // In that case, to allow the linker to find 'libarclite', we point to the
   // 'libarclite' in the XcodeDefault toolchain instead.
-  if (getXcodeDeveloperPath(P).empty()) {
-if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  if (!getVFS().exists(P)) {
+auto updatePath = [&](const Arg *A) {
   // Try to infer the path to 'libarclite' in the toolchain from the
   // specified SDK path.
   StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue());
-  if (!XcodePathForSDK.empty()) {
-P = XcodePathForSDK;
-llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr");
-  }
+  if (XcodePathForSDK.empty())
+return false;
+
+  P = XcodePathForSDK;
+  llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr",
+  "lib", "arc");
+  return getVFS().exists(P);
+};
+
+bool updated = false;
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot))
+  updated = updatePath(A);
+
+if (!updated) {
+  if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
+updatePath(A);
 }
   }
 
   CmdArgs.push_back("-force_load");
-  llvm::sys::path::append(P, "lib", "arc", "libarclite_");
+  llvm::sys::path::append(P, "libarclite_");
   // Mash in the platform.
   if (isTargetWatchOSSimulator())
 P += "watchsimulator";


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1141,25 +1141,38 @@
   SmallString<128> P(getDriver().ClangExecutable);
   llvm::sys::path::remove_filename(P); // 'clang'
   llvm::sys::path::remove_filename(P); // 'bin'
+  llvm::sys::path::append(P, "lib", "arc");
 
   // 'libarclite' usually lives in the same toolchain as 'clang'. However, the
   // Swift open source toolchains for macOS distribute Clang without libarclite.
   // In that case, to allow the linker to find 'libarclite', we point to the
   // 'libarclite' in the XcodeDefault toolchain instead.
-  if (getXcodeDeveloperPath(P).empty()) {
-if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  if (!getVFS().exists(P)) {
+auto updatePath = [&](const Arg *A) {
   // Try to infer the path to 'libarclite' in the toolchain from the
   // specified SDK path.
   StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue());
-  if (!XcodePathForSDK.empty()) {
-P = XcodePathForSDK;
-llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr");
-  }
+  if (XcodePathForSDK.empty())
+return false;
+
+  P = XcodePathForSDK;
+  llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr",
+  "lib", "arc");
+  return getVFS().exists(P);
+};
+
+bool updated = false;
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot))
+  updated = updatePath(A);
+
+if (!updated) {
+  if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
+updatePath(A);
 }
   }
 
   CmdArgs.push_back("-force_load");
-  llvm::sys::path::append(P, "lib", "arc", "libarclite_");
+  llvm::sys::path::append(P, "libarclite_");
   // Mash in the platform.
   if (isTargetWatchOSSimulator())
 P += "watchsimulator";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d072826 - [Darwin toolchain] Tune the logic for finding arclite.

2022-07-20 Thread Steven Wu via cfe-commits

Author: Steven Wu
Date: 2022-07-20T16:45:52-07:00
New Revision: d0728260577d66b4b4d922adf0a40de86f09ccf5

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

LOG: [Darwin toolchain] Tune the logic for finding arclite.

The heuristic used to determine where the arclite libraries are to be
found was based on the path of the `clang` executable. However, in some
scenarios the `clang` executable is within a toolchain that does not
have arclite. When this happens, derive the arclite paths from the
sysroot option.

This allows Clang to correctly derive the arclite directory in, e.g.,
Swift CI, using similar logic to what the Swift driver has been doing
for several years.

Patched by Doug Gregor.

Reviewed By: keith

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 71b0c5bc9c71..bada811daadf 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1141,25 +1141,38 @@ void DarwinClang::AddLinkARCArgs(const ArgList ,
   SmallString<128> P(getDriver().ClangExecutable);
   llvm::sys::path::remove_filename(P); // 'clang'
   llvm::sys::path::remove_filename(P); // 'bin'
+  llvm::sys::path::append(P, "lib", "arc");
 
   // 'libarclite' usually lives in the same toolchain as 'clang'. However, the
   // Swift open source toolchains for macOS distribute Clang without 
libarclite.
   // In that case, to allow the linker to find 'libarclite', we point to the
   // 'libarclite' in the XcodeDefault toolchain instead.
-  if (getXcodeDeveloperPath(P).empty()) {
-if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  if (!getVFS().exists(P)) {
+auto updatePath = [&](const Arg *A) {
   // Try to infer the path to 'libarclite' in the toolchain from the
   // specified SDK path.
   StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue());
-  if (!XcodePathForSDK.empty()) {
-P = XcodePathForSDK;
-llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr");
-  }
+  if (XcodePathForSDK.empty())
+return false;
+
+  P = XcodePathForSDK;
+  llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr",
+  "lib", "arc");
+  return getVFS().exists(P);
+};
+
+bool updated = false;
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot))
+  updated = updatePath(A);
+
+if (!updated) {
+  if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
+updatePath(A);
 }
   }
 
   CmdArgs.push_back("-force_load");
-  llvm::sys::path::append(P, "lib", "arc", "libarclite_");
+  llvm::sys::path::append(P, "libarclite_");
   // Mash in the platform.
   if (isTargetWatchOSSimulator())
 P += "watchsimulator";



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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-07-20 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm updated this revision to Diff 446295.
srishti-pm added a comment.

Used the `stable_sort` function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

Files:
  mlir/include/mlir/Transforms/CommutativityUtils.h
  mlir/lib/Transforms/Utils/CMakeLists.txt
  mlir/lib/Transforms/Utils/CommutativityUtils.cpp
  mlir/test/Transforms/test-commutativity-utils.mlir
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Transforms/CMakeLists.txt
  mlir/test/lib/Transforms/TestCommutativityUtils.cpp
  mlir/tools/mlir-opt/mlir-opt.cpp

Index: mlir/tools/mlir-opt/mlir-opt.cpp
===
--- mlir/tools/mlir-opt/mlir-opt.cpp
+++ mlir/tools/mlir-opt/mlir-opt.cpp
@@ -57,6 +57,7 @@
 void registerVectorizerTestPass();
 
 namespace test {
+void registerCommutativityUtils();
 void registerConvertCallOpPass();
 void registerInliner();
 void registerMemRefBoundCheck();
@@ -153,6 +154,7 @@
   registerVectorizerTestPass();
   registerTosaTestQuantUtilAPIPass();
 
+  mlir::test::registerCommutativityUtils();
   mlir::test::registerConvertCallOpPass();
   mlir::test::registerInliner();
   mlir::test::registerMemRefBoundCheck();
Index: mlir/test/lib/Transforms/TestCommutativityUtils.cpp
===
--- /dev/null
+++ mlir/test/lib/Transforms/TestCommutativityUtils.cpp
@@ -0,0 +1,48 @@
+//===- TestCommutativityUtils.cpp - Pass to test the commutativity utility-===//
+//
+// 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
+//
+//===--===//
+//
+// This pass tests the functionality of the commutativity utility pattern.
+//
+//===--===//
+
+#include "mlir/Transforms/CommutativityUtils.h"
+
+#include "TestDialect.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+
+namespace {
+
+struct CommutativityUtils
+: public PassWrapper> {
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)
+
+  StringRef getArgument() const final { return "test-commutativity-utils"; }
+  StringRef getDescription() const final {
+return "Test the functionality of the commutativity utility";
+  }
+
+  void runOnOperation() override {
+auto func = getOperation();
+auto *context = ();
+
+RewritePatternSet patterns(context);
+populateCommutativityUtilsPatterns(patterns);
+
+(void)applyPatternsAndFoldGreedily(func, std::move(patterns));
+  }
+};
+} // namespace
+
+namespace mlir {
+namespace test {
+void registerCommutativityUtils() { PassRegistration(); }
+} // namespace test
+} // namespace mlir
Index: mlir/test/lib/Transforms/CMakeLists.txt
===
--- mlir/test/lib/Transforms/CMakeLists.txt
+++ mlir/test/lib/Transforms/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Exclude tests from libMLIR.so
 add_mlir_library(MLIRTestTransforms
+  TestCommutativityUtils.cpp
   TestConstantFold.cpp
   TestControlFlowSink.cpp
   TestInlining.cpp
Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -1180,11 +1180,21 @@
   let hasFolder = 1;
 }
 
+def TestAddIOp : TEST_Op<"addi"> {
+  let arguments = (ins I32:$op1, I32:$op2);
+  let results = (outs I32);
+}
+
 def TestCommutativeOp : TEST_Op<"op_commutative", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4);
   let results = (outs I32);
 }
 
+def TestLargeCommutativeOp : TEST_Op<"op_large_commutative", [Commutative]> {
+  let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4, I32:$op5, I32:$op6, I32:$op7);
+  let results = (outs I32);
+}
+
 def TestCommutative2Op : TEST_Op<"op_commutative2", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2);
   let results = (outs I32);
Index: mlir/test/Transforms/test-commutativity-utils.mlir
===
--- /dev/null
+++ mlir/test/Transforms/test-commutativity-utils.mlir
@@ -0,0 +1,116 @@
+// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s
+
+// CHECK-LABEL: @test_small_pattern_1
+func.func @test_small_pattern_1(%arg0 : i32) -> i32 {
+  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant
+  %0 = arith.constant 45 : i32
+
+  // CHECK-NEXT: %[[TEST_ADD:.*]] = "test.addi"
+  %1 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
+
+  // CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi
+  %2 = arith.addi %arg0, %arg0 : i32
+
+  // CHECK-NEXT: %[[ARITH_MUL:.*]] = arith.muli
+  %3 = arith.muli %arg0, %arg0 : i32
+

[PATCH] D130210: [SemaCXX] Set promotion type for enum bool to integer type.

2022-07-20 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: hans, aaron.ballman.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

EnumDecl's promotion type is set either to the parsed type or calculated type
after completing its definition. When it's bool type and has no definition,
its promotion type is bool which is not allowed by clang.

This fixes https://github.com/llvm/llvm-project/issues/56560.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130210

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/enum-bool.cpp


Index: clang/test/SemaCXX/enum-bool.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/enum-bool.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1  -fsyntax-only %s
+
+// This shouldn't crash.
+
+enum GH56560_1 : bool;
+bool GH56560_2(GH56560_1 a, GH56560_1 b) {
+return a == b;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16194,7 +16194,11 @@
   ED->setIntegerTypeSourceInfo(TI);
 else
   ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-ED->setPromotionType(ED->getIntegerType());
+QualType EnumTy = ED->getIntegerType();
+if (EnumTy->isPromotableIntegerType())
+  ED->setPromotionType(Context.getPromotedIntegerType(EnumTy));
+else
+  ED->setPromotionType(EnumTy);
   }
 } else { // struct/union
   New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
@@ -16816,8 +16820,12 @@
   if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast())
 ED->setIntegerTypeSourceInfo(TI);
   else
-ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-  ED->setPromotionType(ED->getIntegerType());
+ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
+  QualType EnumTy = ED->getIntegerType();
+  if (EnumTy->isPromotableIntegerType())
+ED->setPromotionType(Context.getPromotedIntegerType(EnumTy));
+  else
+ED->setPromotionType(EnumTy);
   assert(ED->isComplete() && "enum with type should be complete");
 }
   } else {


Index: clang/test/SemaCXX/enum-bool.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/enum-bool.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1  -fsyntax-only %s
+
+// This shouldn't crash.
+
+enum GH56560_1 : bool;
+bool GH56560_2(GH56560_1 a, GH56560_1 b) {
+return a == b;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16194,7 +16194,11 @@
   ED->setIntegerTypeSourceInfo(TI);
 else
   ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-ED->setPromotionType(ED->getIntegerType());
+QualType EnumTy = ED->getIntegerType();
+if (EnumTy->isPromotableIntegerType())
+  ED->setPromotionType(Context.getPromotedIntegerType(EnumTy));
+else
+  ED->setPromotionType(EnumTy);
   }
 } else { // struct/union
   New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
@@ -16816,8 +16820,12 @@
   if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast())
 ED->setIntegerTypeSourceInfo(TI);
   else
-ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-  ED->setPromotionType(ED->getIntegerType());
+ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
+  QualType EnumTy = ED->getIntegerType();
+  if (EnumTy->isPromotableIntegerType())
+ED->setPromotionType(Context.getPromotedIntegerType(EnumTy));
+  else
+ED->setPromotionType(EnumTy);
   assert(ED->isComplete() && "enum with type should be complete");
 }
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128955: [WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes

2022-07-20 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D128955#3666830 , @aeubanks wrote:

> the assert that there are no public.type.tests in LTT fails on 
> `CodeGenCXX/thinlto-distributed-type-metadata.cpp`. for some reason clang 
> doesn't go through the LTO API at [1], it just ends up calling the normal 
> optimization pipeline. any ideas why?
>
> [1] 
> https://github.com/llvm/llvm-project/blob/0c1b32717bcffcf8edf95294e98933bd4c1e76ed/clang/lib/CodeGen/BackendUtil.cpp#L1173

Ah ok, that handling is for some cases where we may decide not to do ThinLTO, 
but rather compile the IR down to native code normally without a thin link (we 
use that feature for distributed build system reasons). Looks like we need a 
fallback mechanism to convert these in that case. Maybe right at the start of 
DevirtModule::run? We could do in LTT where you are currently asserting too, 
but to me it seems more natural to get rid of these at the start of WPD, 
because with LTO they are gone by then.




Comment at: llvm/lib/LTO/LTOBackend.cpp:595
 
+  updatePublicTypeTestCalls(Mod, Conf.HasWholeProgramVisibility);
+

aeubanks wrote:
> aeubanks wrote:
> > tejohnson wrote:
> > > aeubanks wrote:
> > > > tejohnson wrote:
> > > > > aeubanks wrote:
> > > > > > I'm not sure where the best place to put these is
> > > > > I don't think that this will work for distributed ThinLTO, where the 
> > > > > ThinLTO Backends are run via clang, which isn't going to have this 
> > > > > config variable set (since it is set only during LTO linking). I 
> > > > > think something may need to be recorded in the index as a flag there 
> > > > > at thin link / indexing time that can be checked here.
> > > > > 
> > > > > It would then be nice to consolidate this handling into WPD itself, 
> > > > > e.g. at the start of DevirtModule::run, but unfortunately we won't 
> > > > > have a summary index for pure regular LTO WPD so I don't think that 
> > > > > would work. So in here is ok but I would do it early to handle some 
> > > > > of the early return cases.
> > > > > 
> > > > > (Please add a distributed ThinLTO test too)
> > > > Added a distributed ThinLTO test: 
> > > > clang/test/CodeGenCXX/thinlto_public_type_test_distributed.ll.
> > > > 
> > > > I added `ModuleSummaryIndex::WithWholeProgramVisibility` but I'm not 
> > > > sure where I'd set it, and that's causing the test to fail.
> > > I see from your most recent update that you added code to set/check this 
> > > new index flag. But I think you would want to set it around the same 
> > > place where we update the vcall visibility during the thin link (see 
> > > calls to updateVCallVisibilityInIndex). And I would do it via a new 
> > > method in the WPD source file that uses the existing 
> > > hasWholeProgramVisibility() that checks the OR of the config flag or the 
> > > internal option. Then you don't need to add a new flag to llvm-lto2 for 
> > > this purpose.
> > > 
> > > Also, as I noted for the regular LTO handling elsewhere, I think you need 
> > > to add similar handling for the legacy LTO implementation. See other 
> > > callers to updateVCallVisibilityInIndex.
> > ah, I needed a separate WPV flag in llvm-lto2 to set `llvm::lto::Config`, 
> > now everything passes
> exposed the existing `hasWholeProgramVisibility`
See note about needing this for legacy LTO API (ThinLTOCodeGenerator.cpp).



Comment at: llvm/test/LTO/X86/public-type-test.ll:1
+; Test to ensure that the legacy LTO API lowers @llvm.public.type.test.
+

Needs some CHECKs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128955

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


[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 446286.
jdoerfert added a comment.

Use <...>


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129536

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGenCUDA/shuffle_long_long.cu


Index: clang/test/CodeGenCUDA/shuffle_long_long.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/shuffle_long_long.cu
@@ -0,0 +1,61 @@
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm 
-target-cpu sm_30 %s -o - | FileCheck %s --check-prefix=NO_SYNC
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm 
-target-cpu sm_30 -target-feature +ptx70 -DSYNC -DCUDA_VERSION=9000 %s -o - | 
FileCheck %s --check-prefix=SYNC
+
+#include "Inputs/cuda.h"
+
+__device__ void *memcpy(void *dest, const void *src, size_t n);
+
+#define warpSize 32
+#include <__clang_cuda_intrinsics.h>
+
+__device__ void use(unsigned long long, long long);
+
+// Test function, 4 shfl calls.
+// NO_SYNC: define{{.*}} @_Z14test_long_longv
+// NO_SYNC: call noundef i64 @_Z6__shflyii(
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+
+// SYNC: define{{.*}} @_Z14test_long_longv
+// SYNC:call noundef i64 @_Z11__shfl_syncjyii(
+// SYNC:call noundef i64 @_Z11__shfl_syncjxii(
+
+// unsigned long long -> long long
+// NO_SYNC: define{{.*}} @_Z6__shflyii
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+
+// long long -> int + int
+// NO_SYNC: define{{.*}} @_Z6__shflxii
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+
+// NO_SYNC: define{{.*}} @_Z6__shfliii
+// NO_SYNC:   call i32 @llvm.nvvm.shfl.idx.i32
+
+// unsigned long long -> long long
+// SYNC: _Z11__shfl_syncjyii
+// SYNC: call noundef i64 @_Z11__shfl_syncjxii(
+
+// long long -> int + int
+// SYNC: define{{.*}} @_Z11__shfl_syncjxii
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+
+// SYNC: define{{.*}} @_Z11__shfl_syncjiii
+// SYNC:  call i32 @llvm.nvvm.shfl.sync.idx.i32
+
+__device__ void test_long_long() {
+  unsigned long long ull = 13;
+  long long ll = 17;
+#ifndef SYNC
+  ull = __shfl(ull, 7, 32);
+  ll = __shfl(ll, 7, 32);
+  use(ull, ll);
+#else
+  ull = __shfl_sync(0x11, ull, 7, 32);
+  ll = __shfl_sync(0x11, ll, 7, 32);
+  use(ull, ll);
+#endif
+}
+
Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -71,8 +71,8 @@
   }
\
   inline __device__ unsigned long long __FnName(   
\
   unsigned long long __val, __Type __offset, int __width = warpSize) { 
\
-return static_cast(::__FnName( 
\
-static_cast(__val), __offset, __width));   
\
+return static_cast(
\
+::__FnName(static_cast(__val), __offset, __width)); 
\
   }
\
   inline __device__ double __FnName(double __val, __Type __offset, 
\
 int __width = warpSize) {  
\
@@ -139,8 +139,8 @@
   inline __device__ unsigned long long __FnName(   
\
   unsigned int __mask, unsigned long long __val, __Type __offset,  
\
   int __width = warpSize) {
\
-return static_cast(::__FnName( 
\
-__mask, static_cast(__val), __offset, __width));   
\
+return static_cast(
\
+::__FnName(__mask, static_cast(__val), __offset, __width)); 
\
   }
\
   inline __device__ long __FnName(unsigned int __mask, long __val, 
\
   __Type __offset, int __width = warpSize) {   
\


Index: clang/test/CodeGenCUDA/shuffle_long_long.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/shuffle_long_long.cu
@@ -0,0 +1,61 @@
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -target-cpu sm_30 %s -o - | FileCheck %s --check-prefix=NO_SYNC
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -target-cpu sm_30 -target-feature +ptx70 -DSYNC -DCUDA_VERSION=9000 %s -o - | FileCheck %s --check-prefix=SYNC
+
+#include "Inputs/cuda.h"
+
+__device__ void *memcpy(void *dest, const void *src, size_t n);
+
+#define warpSize 32
+#include 

[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D129536#3666884 , @tra wrote:

> In D129536#3666860 , @jdoerfert 
> wrote:
>
>> The assertion is arguably not great but doesn't really matter, does it? How 
>> would I detect if they are supported?
>
> The latest revision of the patch is fine in this regard. My comment pointing 
> to compiler crash reproducer was only intended to address the "For me this 
> passes fine" part.
>
> The only remaining thing is the manual `__CUDA_ARCH__` redifinition which 
> looks suspect to me. Is there any reason not to use `-target-cpu sm_30` 
> instead?

No reason. Changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129536

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


[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 446285.
jdoerfert added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129536

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGenCUDA/shuffle_long_long.cu


Index: clang/test/CodeGenCUDA/shuffle_long_long.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/shuffle_long_long.cu
@@ -0,0 +1,61 @@
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm 
-target-cpu sm_30 %s -o - | FileCheck %s --check-prefix=NO_SYNC
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm 
-target-cpu sm_30 -target-feature +ptx70 -DSYNC -DCUDA_VERSION=9000 %s -o - | 
FileCheck %s --check-prefix=SYNC
+
+#include "Inputs/cuda.h"
+
+__device__ void *memcpy(void *dest, const void *src, size_t n);
+
+#define warpSize 32
+#include "__clang_cuda_intrinsics.h"
+
+__device__ void use(unsigned long long, long long);
+
+// Test function, 4 shfl calls.
+// NO_SYNC: define{{.*}} @_Z14test_long_longv
+// NO_SYNC: call noundef i64 @_Z6__shflyii(
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+
+// SYNC: define{{.*}} @_Z14test_long_longv
+// SYNC:call noundef i64 @_Z11__shfl_syncjyii(
+// SYNC:call noundef i64 @_Z11__shfl_syncjxii(
+
+// unsigned long long -> long long
+// NO_SYNC: define{{.*}} @_Z6__shflyii
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+
+// long long -> int + int
+// NO_SYNC: define{{.*}} @_Z6__shflxii
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+
+// NO_SYNC: define{{.*}} @_Z6__shfliii
+// NO_SYNC:   call i32 @llvm.nvvm.shfl.idx.i32
+
+// unsigned long long -> long long
+// SYNC: _Z11__shfl_syncjyii
+// SYNC: call noundef i64 @_Z11__shfl_syncjxii(
+
+// long long -> int + int
+// SYNC: define{{.*}} @_Z11__shfl_syncjxii
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+
+// SYNC: define{{.*}} @_Z11__shfl_syncjiii
+// SYNC:  call i32 @llvm.nvvm.shfl.sync.idx.i32
+
+__device__ void test_long_long() {
+  unsigned long long ull = 13;
+  long long ll = 17;
+#ifndef SYNC
+  ull = __shfl(ull, 7, 32);
+  ll = __shfl(ll, 7, 32);
+  use(ull, ll);
+#else
+  ull = __shfl_sync(0x11, ull, 7, 32);
+  ll = __shfl_sync(0x11, ll, 7, 32);
+  use(ull, ll);
+#endif
+}
+
Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -71,8 +71,8 @@
   }
\
   inline __device__ unsigned long long __FnName(   
\
   unsigned long long __val, __Type __offset, int __width = warpSize) { 
\
-return static_cast(::__FnName( 
\
-static_cast(__val), __offset, __width));   
\
+return static_cast(
\
+::__FnName(static_cast(__val), __offset, __width)); 
\
   }
\
   inline __device__ double __FnName(double __val, __Type __offset, 
\
 int __width = warpSize) {  
\
@@ -139,8 +139,8 @@
   inline __device__ unsigned long long __FnName(   
\
   unsigned int __mask, unsigned long long __val, __Type __offset,  
\
   int __width = warpSize) {
\
-return static_cast(::__FnName( 
\
-__mask, static_cast(__val), __offset, __width));   
\
+return static_cast(
\
+::__FnName(__mask, static_cast(__val), __offset, __width)); 
\
   }
\
   inline __device__ long __FnName(unsigned int __mask, long __val, 
\
   __Type __offset, int __width = warpSize) {   
\


Index: clang/test/CodeGenCUDA/shuffle_long_long.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/shuffle_long_long.cu
@@ -0,0 +1,61 @@
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -target-cpu sm_30 %s -o - | FileCheck %s --check-prefix=NO_SYNC
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -target-cpu sm_30 -target-feature +ptx70 -DSYNC -DCUDA_VERSION=9000 %s -o - | FileCheck %s --check-prefix=SYNC
+
+#include "Inputs/cuda.h"
+
+__device__ void *memcpy(void *dest, const void *src, size_t n);
+
+#define warpSize 32
+#include 

[PATCH] D130207: [HLSL] Move DXIL validation version out of ModuleFlags

2022-07-20 Thread Xiang Li via Phabricator via cfe-commits
python3kgae created this revision.
python3kgae added reviewers: Anastasia, kuhar, bogner, beanz, pow2clk.
Herald added a subscriber: hiraditya.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Put DXIL validation version into separate NamedMetadata to avoid update 
ModuleFlags.

Currently DXIL validation version is saved in ModuleFlags in clang codeGen.
Then in DirectX backend, the data will be extracted from ModuleFlags and cause 
rebuild of ModuleFlags.
This patch will build NamedMetadata for DXIL validation version and remove the 
code to rebuild ModuleFlags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130207

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/test/CodeGenHLSL/validator_version.hlsl
  llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
  llvm/test/CodeGen/DirectX/dxil_ver.ll

Index: llvm/test/CodeGen/DirectX/dxil_ver.ll
===
--- llvm/test/CodeGen/DirectX/dxil_ver.ll
+++ llvm/test/CodeGen/DirectX/dxil_ver.ll
@@ -3,18 +3,18 @@
 target triple = "dxil-pc-shadermodel6.3-library"
 
 ; Make sure dx.valver metadata is generated.
-; CHECK:!dx.valver = !{![[valver:[0-9]+]]}
+; CHECK-DAG:!dx.valver = !{![[valver:[0-9]+]]}
 ; Make sure module flags still exist and only have 1 operand left.
-; CHECK:!llvm.module.flags = !{{{![0-9]}}}
+; CHECK-DAG:!llvm.module.flags = !{{{![0-9]}}}
 ; Make sure validator version is 1.1.
-; CHECK:![[valver]] = !{i32 1, i32 1}
+; CHECK-DAG:![[valver]] = !{i32 1, i32 1}
 ; Make sure wchar_size still exist.
-; CHECK:!{i32 1, !"wchar_size", i32 4}
+; CHECK-DAG:!{i32 1, !"wchar_size", i32 4}
 
-!llvm.module.flags = !{!0, !1}
-!llvm.ident = !{!3}
+!llvm.module.flags = !{!0}
+!dx.valver = !{!1}
+!llvm.ident = !{!2}
 
 !0 = !{i32 1, !"wchar_size", i32 4}
-!1 = !{i32 6, !"dx.valver", !2}
-!2 = !{i32 1, i32 1}
-!3 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project 71de12113a0661649ecb2f533fba4a2818a1ad68)"}
+!1 = !{i32 1, i32 1}
+!2 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project 71de12113a0661649ecb2f533fba4a2818a1ad68)"}
Index: llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
===
--- llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -58,31 +58,7 @@
   return VersionTuple(Major, Minor);
 }
 
-static void cleanModuleFlags(Module ) {
-  constexpr StringLiteral DeadKeys[] = {ValVerKey};
-  // Collect DeadKeys in ModuleFlags.
-  StringSet<> DeadKeySet;
-  for (auto  : DeadKeys) {
-if (M.getModuleFlag(Key))
-  DeadKeySet.insert(Key);
-  }
-  if (DeadKeySet.empty())
-return;
-
-  SmallVector ModuleFlags;
-  M.getModuleFlagsMetadata(ModuleFlags);
-  NamedMDNode *MDFlags = M.getModuleFlagsMetadata();
-  MDFlags->eraseFromParent();
-  // Add ModuleFlag which not dead.
-  for (auto  : ModuleFlags) {
-StringRef Key = Flag.Key->getString();
-if (DeadKeySet.contains(Key))
-  continue;
-M.addModuleFlag(Flag.Behavior, Key, Flag.Val);
-  }
-}
-
-static void cleanModule(Module ) { cleanModuleFlags(M); }
+static void cleanModule(Module ) {}
 
 namespace {
 class DXILTranslateMetadata : public ModulePass {
@@ -101,8 +77,8 @@
 } // namespace
 
 bool DXILTranslateMetadata::runOnModule(Module ) {
-  if (MDNode *ValVerMD = cast_or_null(M.getModuleFlag(ValVerKey))) {
-auto ValVer = loadDXILValidatorVersion(ValVerMD);
+  if (auto *ValVerMD = M.getNamedMetadata(ValVerKey)) {
+auto ValVer = loadDXILValidatorVersion(ValVerMD->getOperand(0));
 if (!ValVer.empty())
   ValidatorVer = ValVer;
   }
Index: clang/test/CodeGenHLSL/validator_version.hlsl
===
--- clang/test/CodeGenHLSL/validator_version.hlsl
+++ clang/test/CodeGenHLSL/validator_version.hlsl
@@ -1,8 +1,11 @@
 // RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -S -emit-llvm -xhlsl -validator-version 1.1 -o - %s | FileCheck %s
+// RUN: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl -validator-version 1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
 
-// CHECK:!"dx.valver", ![[valver:[0-9]+]]}
+// CHECK:!dx.valver = !{![[valver:[0-9]+]]}
 // CHECK:![[valver]] = !{i32 1, i32 1}
 
+// NOT_DXIL-NOT:!dx.valver
+
 float bar(float a, float b);
 
 float foo(float a, float b) {
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -39,14 +39,16 @@
   IRBuilder<> B(M.getContext());
   MDNode *Val = MDNode::get(Ctx, {ConstantAsMetadata::get(B.getInt32(Major)),
   ConstantAsMetadata::get(B.getInt32(Minor))});
-  StringRef DxilValKey = "dx.valver";
-  M.addModuleFlag(llvm::Module::ModFlagBehavior::AppendUnique, 

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-20 Thread Fangrui Song 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 rG304027206c88: [ThinLTO] Support aliased GlobalIFunc 
(authored by SchrodingerZhu, committed by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D129009?vs=446277=446279#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/include/llvm/IR/GlobalIFunc.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
  llvm/test/ThinLTO/X86/alias-ifunc.ll

Index: llvm/test/ThinLTO/X86/alias-ifunc.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/alias-ifunc.ll
@@ -0,0 +1,57 @@
+; RUN: opt -module-summary -o %t.bc %s
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-BAR
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-BAZ
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-QUX
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-RESOLVER
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-QUUX
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-CORGE
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-GRAULT
+; RUN: llvm-lto2 run %t.bc -r %t.bc,foo,px -r %t.bc,bar,px -r %t.bc,baz,px -r %t.bc,qux,px -r %t.bc,grault,px -o %t2
+; RUN: llvm-nm %t2.1 | FileCheck %s --check-prefix=CHECK-SYMBOL
+
+; CHECK-SYMBOL: i bar
+; CHECK-SYMBOL: i baz
+; CHECK-SYMBOL: i foo
+; CHECK-SYMBOL: t foo_resolver
+; CHECK-SYMBOL: i grault
+; CHECK-SYMBOL: i quuz
+; CHECK-SYMBOL: i qux
+
+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"
+@foo = ifunc i32 (i32), ptr @foo_resolver
+; CHECK-RESOLVER:  (name: "foo_resolver"
+; CHECK-RESOLVER-SAME: live: 1
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+; CHECK-BAR:  (name: "bar"
+; CHECK-BAR-NOT:  summaries: (
+; CHECK-BAR-SAME: ; guid = {{[0-9]+}}
+@bar = alias i32 (i32), ptr @foo
+
+; CHECK-BAZ:  (name: "baz"
+; CHECK-BAZ-NOT:  summaries: (
+; CHECK-BAZ-SAME: ; guid = {{[0-9]+}}
+@baz = weak alias i32 (i32), ptr @foo
+
+; CHECK-QUX:  (name: "qux"
+; CHECK-QUX-NOT:  summaries: (
+; CHECK-QUX-SAME: ; guid = {{[0-9]+}}
+@qux = alias i32 (i32), ptr @bar
+
+; CHECK-QUUX:  (name: "quux"
+; CHECK-QUUX-SAME: live: 1
+@quux = internal alias i32 (i32)* (), ptr @foo_resolver
+@quuz = internal ifunc i32 (i32), ptr @quux
+
+; CHECK-CORGE:  (name: "corge"
+; CHECK-CORGE-NOT:  summaries: (
+; CHECK-CORGE-SAME: ; guid = {{[0-9]+}}
+@corge = internal alias i32 (i32), ptr @quuz
+
+; CHECK-GRAULT:  (name: "grault"
+; CHECK-GRAULT-NOT:  summaries: (
+; CHECK-GRAULT-SAME: ; guid = {{[0-9]+}}
+@grault = alias i32 (i32), ptr @corge
Index: llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
===
--- llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -35,6 +35,13 @@
 bool FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(
 const GlobalValue *SGV, ValueInfo VI) {
   assert(SGV->hasLocalLinkage());
+
+  // Ifuncs and ifunc alias does not have summary.
+  if (isa(SGV) ||
+  (isa(SGV) &&
+   isa(cast(SGV)->getAliaseeObject(
+return false;
+
   // Both the imported references and the original local variable must
   // be promoted.
   if (!isPerformingImport() && !isModuleExporting())
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -1147,6 +1147,14 @@
   // Declare a callback for the internalize pass that will ask for every
   // candidate GlobalValue if it can be internalized or not.
   auto MustPreserveGV = [&](const GlobalValue ) -> bool {
+// It may be the case that GV is on a chain of an ifunc, its alias and
+// subsequent aliases. In this case, the summary for the value is not
+// available.
+if (isa() ||
+(isa() &&
+ isa(cast()->getAliaseeObject(
+  return true;
+
 // Lookup the linkage recorded in the summaries during global analysis.
 auto GS = DefinedGlobals.find(GV.getGUID());
 if (GS == DefinedGlobals.end()) {
@@ -1277,7 +1285,7 @@
   }
 }
 for (GlobalAlias  : SrcModule->aliases()) {
-  if (!GA.hasName())
+  if (!GA.hasName() || isa(GA.getAliaseeObject()))
 continue;
   auto GUID = GA.getGUID();
   auto Import = ImportGUIDs.count(GUID);
Index: llvm/lib/IR/Globals.cpp

[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Yeah, turning off `LLVM_OPTIMIZED_TABLEGEN` made cmake instantly generate the 
correct CXXSymbols.inc. So while I think there is a bug out there somewhere, it 
might not necessarily be in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 446277.
MaskRay added a comment.

Add blank lines
remove trailing whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/include/llvm/IR/GlobalIFunc.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
  llvm/test/ThinLTO/X86/alias-ifunc.ll

Index: llvm/test/ThinLTO/X86/alias-ifunc.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/alias-ifunc.ll
@@ -0,0 +1,57 @@
+; RUN: opt -module-summary -o %t.bc %s
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-BAR
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-BAZ
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-QUX
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-RESOLVER
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-QUUX
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-CORGE
+; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-GRAULT
+; RUN: llvm-lto2 run %t.bc -r %t.bc,foo,px -r %t.bc,bar,px -r %t.bc,baz,px -r %t.bc,qux,px -r %t.bc,grault,px -o %t2
+; RUN: llvm-nm %t2.1 | FileCheck %s --check-prefix=CHECK-SYMBOL
+
+; CHECK-SYMBOL: i bar
+; CHECK-SYMBOL: i baz
+; CHECK-SYMBOL: i foo
+; CHECK-SYMBOL: t foo_resolver
+; CHECK-SYMBOL: i grault
+; CHECK-SYMBOL: i quuz
+; CHECK-SYMBOL: i qux
+
+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"
+@foo = ifunc i32 (i32), ptr @foo_resolver
+; CHECK-RESOLVER:  (name: "foo_resolver"
+; CHECK-RESOLVER-SAME: live: 1
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+; CHECK-BAR:  (name: "bar"
+; CHECK-BAR-NOT:  summaries: (
+; CHECK-BAR-SAME: ; guid = {{[0-9]+}}
+@bar = alias i32 (i32), ptr @foo
+
+; CHECK-BAZ:  (name: "baz"
+; CHECK-BAZ-NOT:  summaries: (
+; CHECK-BAZ-SAME: ; guid = {{[0-9]+}}
+@baz = weak alias i32 (i32), ptr @foo
+
+; CHECK-QUX:  (name: "qux"
+; CHECK-QUX-NOT:  summaries: (
+; CHECK-QUX-SAME: ; guid = {{[0-9]+}}
+@qux = alias i32 (i32), ptr @bar
+
+; CHECK-QUUX:  (name: "quux"
+; CHECK-QUUX-SAME: live: 1
+@quux = internal alias i32 (i32)* (), ptr @foo_resolver
+@quuz = internal ifunc i32 (i32), ptr @quux
+
+; CHECK-CORGE:  (name: "corge"
+; CHECK-CORGE-NOT:  summaries: (
+; CHECK-CORGE-SAME: ; guid = {{[0-9]+}}
+@corge = internal alias i32 (i32), ptr @quuz
+
+; CHECK-GRAULT:  (name: "grault"
+; CHECK-GRAULT-NOT:  summaries: (
+; CHECK-GRAULT-SAME: ; guid = {{[0-9]+}}
+@grault = alias i32 (i32), ptr @corge
Index: llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
===
--- llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -35,6 +35,13 @@
 bool FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(
 const GlobalValue *SGV, ValueInfo VI) {
   assert(SGV->hasLocalLinkage());
+
+  // Ifuncs and ifunc alias does not have summary.
+  if (isa(SGV) ||
+  (isa(SGV) &&
+   isa(cast(SGV)->getAliaseeObject(
+return false;
+
   // Both the imported references and the original local variable must
   // be promoted.
   if (!isPerformingImport() && !isModuleExporting())
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -1147,6 +1147,14 @@
   // Declare a callback for the internalize pass that will ask for every
   // candidate GlobalValue if it can be internalized or not.
   auto MustPreserveGV = [&](const GlobalValue ) -> bool {
+// It may be the case that GV is on a chain of an ifunc, its alias and
+// subsequent aliases. In this case, the summary for the value is not
+// available.
+if (isa() ||
+(isa() &&
+ isa(cast()->getAliaseeObject(
+  return true;
+
 // Lookup the linkage recorded in the summaries during global analysis.
 auto GS = DefinedGlobals.find(GV.getGUID());
 if (GS == DefinedGlobals.end()) {
@@ -1277,7 +1285,7 @@
   }
 }
 for (GlobalAlias  : SrcModule->aliases()) {
-  if (!GA.hasName())
+  if (!GA.hasName() || isa(GA.getAliaseeObject()))
 continue;
   auto GUID = GA.getGUID();
   auto Import = ImportGUIDs.count(GUID);
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -316,32 +316,38 @@
   return true;
 }
 
+template 
 static const GlobalObject *
-findBaseObject(const Constant *C, DenseSet ) {
-  if (auto *GO = 

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D129009#3665664 , @SchrodingerZhu 
wrote:

> Hi, is there anything else I should do for this patch?

There is no. I am waiting a bit to collect more response. I'll do some testing 
and push this. Thanks for your contribution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

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


[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

The clang-pseudo-gen that sits in `.\llvm\RelWithDebInfo\bin\clang-pseudo-gen` 
generates correct output, the one that sits in 
`.\llvm\NATIVE\Release\bin\clang-pseudo-gen.exe` doesn't, which seems to be the 
one cmake is picking up for this job.

This could have something to do with `"LLVM_OPTIMIZED_TABLEGEN": "ON",` 
perhaps, and there is some dependency missing to rebuild the NATIVE target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Running `clang-pseudo-gen --grammar ..\clang-tools-extra\pseudo\lib\cxx\cxx.bnf 
--emit-symbol-list` does seem to generate something that would work. But even 
if I delete `CXXSymbols.inc`, the cmake rule seems to be regenerating a wrong 
CXXSymbols.inc again, so I suspect this is a build system bug and we have wrong 
targets or dependecies somewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D129536#3666860 , @jdoerfert wrote:

> The assertion is arguably not great but doesn't really matter, does it? How 
> would I detect if they are supported?

The latest revision of the patch is fine in this regard. My comment pointing to 
compiler crash reproducer was only intended to address the "For me this passes 
fine" part.

The only remaining thing is the manual `__CUDA_ARCH__` redifinition which looks 
suspect to me. Is there any reason not to use `-target-cpu sm_30` instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129536

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


[PATCH] D130161: Added command-line options to exclude functions from function instrumentation output.

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

See https://clang.llvm.org/docs/SanitizerSpecialCaseList.html , 
-fsanitize-ignorelist and `*san_ignorelist.txt` in the Clang resource directory.
If you can state your motivation, I am happy to implement it as I just modified 
related code for sanitizers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130161

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


[PATCH] D130130: [clang-tidy] Add an IgnoreMacros option to readability-avoid-const-params-in-decls

2022-07-20 Thread Thomas Etter via Phabricator via cfe-commits
thomasetter added a comment.

In D130130#3666111 , @njames93 wrote:

> Please can you upload your diff with full context(or use arcanist which does 
> it for you).

Sorry about that, should be fixed now


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

https://reviews.llvm.org/D130130

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


[PATCH] D130130: [clang-tidy] Add an IgnoreMacros option to readability-avoid-const-params-in-decls

2022-07-20 Thread Thomas Etter via Phabricator via cfe-commits
thomasetter updated this revision to Diff 446274.

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

https://reviews.llvm.org/D130130

Files:
  clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
  
clang-tools-extra/docs/clang-tidy/checks/readability/avoid-const-params-in-decls.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls.cpp
@@ -170,12 +170,17 @@
 void NF(const int* const*);
 void NF(alias_const_type);
 
-// Regression test for when the 'const' token is not in the code.
+// Regression tests involving macros, which are ignored by default.
 #define CONCAT(a, b) a##b
 void ConstNotVisible(CONCAT(cons, t) int i);
-// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: parameter 'i'
-// We warn, but we can't give a fix
-// CHECK-FIXES: void ConstNotVisible(CONCAT(cons, t) int i);
+
+#define CONST_INT_PARAM const int i
+void ConstInMacro(CONST_INT_PARAM);
+
+#define DECLARE_FUNCTION_WITH_ARG(x) struct InsideMacro{ x }
+DECLARE_FUNCTION_WITH_ARG(
+void member_function(const int i);
+);
 
 // Regression test. We should not warn (or crash) on lambda expressions
 auto lambda_with_name = [](const int n) {};
Index: clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls-macros.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls-macros.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s readability-avoid-const-params-in-decls %t -- \
+// RUN:   -config="{CheckOptions: [{key: readability-avoid-const-params-in-decls.IgnoreMacros, value: false}]}"
+
+// Regression tests involving macros
+#define CONCAT(a, b) a##b
+void ConstNotVisible(CONCAT(cons, t) int i);
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: parameter 'i'
+// We warn, but we can't give a fix
+// CHECK-FIXES: void ConstNotVisible(CONCAT(cons, t) int i);
+
+#define CONST_INT_PARAM const int i
+void ConstInMacro(CONST_INT_PARAM);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+// We warn, but we can't give a fix
+// CHECK-FIXES: void ConstInMacro(CONST_INT_PARAM);
+
+#define DECLARE_FUNCTION_WITH_ARG(x) struct InsideMacro{ x }
+DECLARE_FUNCTION_WITH_ARG(
+void member_function(const int i);
+);
+// CHECK-MESSAGES: :[[@LINE-2]]:26: warning: parameter 'i'
+// CHECK-FIXES: void member_function(int i);
Index: clang-tools-extra/docs/clang-tidy/checks/readability/avoid-const-params-in-decls.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/avoid-const-params-in-decls.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/avoid-const-params-in-decls.rst
@@ -15,3 +15,11 @@
 
   void f(const string);   // Bad: const is top level.
   void f(const string&);  // Good: const is not top level.
+
+Options
+---
+
+.. option:: IgnoreMacros
+
+   If set to `true`, the check will not give warnings inside macros. Default
+   is `true`.
Index: clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
===
--- clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
+++ clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
@@ -20,13 +20,18 @@
 class AvoidConstParamsInDecls : public ClangTidyCheck {
 public:
   AvoidConstParamsInDecls(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context),
+IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
   llvm::Optional getCheckTraversalKind() const override {
 return TK_IgnoreUnlessSpelledInSource;
   }
+
+private:
+  const bool IgnoreMacros;
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -27,6 +27,10 @@
 
 } // namespace
 
+void AvoidConstParamsInDecls::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
 void 

[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D129536#3666257 , @tra wrote:

> In D129536#3663957 , @jdoerfert 
> wrote:
>
>> @tra, unsure about the crash. For me this passes fine (no gpu), is anything 
>> missing?
>
> The tests in the patch are running with `-emit-llvm`, so they are not 
> actually lowering to NVPTX and that's where the failure happens. 
> https://godbolt.org/z/cchaWxrhn

The assertion is arguably not great but doesn't really matter, does it? How 
would I detect if they are supported?




Comment at: clang/lib/Headers/__clang_cuda_intrinsics.h:237-238
 
-inline __device__ unsigned int
-__match64_any_sync(unsigned int mask, unsigned long long value) {
+inline __device__ unsigned int __match64_any_sync(unsigned int mask,
+  unsigned long long value) {
   return __nvvm_match_any_sync_i64(mask, value);

tra wrote:
> Nit: this change is irrelevant to the patch and can be removed.
me running clang format on the file. I'll push it nfc before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129536

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


[PATCH] D128955: [WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes

2022-07-20 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

the assert that there are no public.type.tests in LTT fails on 
`CodeGenCXX/thinlto-distributed-type-metadata.cpp`. for some reason clang 
doesn't go through the LTO API at [1], it just ends up calling the normal 
optimization pipeline. any ideas why?

[1] 
https://github.com/llvm/llvm-project/blob/0c1b32717bcffcf8edf95294e98933bd4c1e76ed/clang/lib/CodeGen/BackendUtil.cpp#L1173




Comment at: clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp:22
 // OPT-NOT: @llvm.type.test
-// OPT-NOT: call void @llvm.assume
 // We should have only one @llvm.assume call, the one that was expanded

tejohnson wrote:
> aeubanks wrote:
> > tejohnson wrote:
> > > Why remove this one here and below?
> > we end up RAUWing the `public.type.test` with true and end up with 
> > `assume(true)` which is harmless and gets removed by something like 
> > instcombine
> Sure, but it should still be gone and can confirm that here? If it isn't 
> useful to check for, then the comment should probably be changed too since it 
> mentions assumes.
There's an `-O0` RUN line below where the `assume(true)` won't be removed.
Updated comments.



Comment at: clang/test/CodeGenCXX/thinlto_public_type_test_distributed.ll:23
+; RUN:   -o %t.native.o -x ir %t.o --save-temps=obj
+; RUN: llvm-dis %t.native.o.1.promote.bc -o - | FileCheck %s 
--check-prefix=HIDDEN
+

tejohnson wrote:
> Is there a reason why the hidden version checks after promote but the public 
> version above checks after importing?
unintentional, fixed. I've changed everything to check 0.preopt since 1.promote 
wasn't appearing in some cases, not sure why



Comment at: lld/test/ELF/lto/update_public_type_test.ll:1
+; REQUIRES: x86
+

tejohnson wrote:
> aeubanks wrote:
> > tejohnson wrote:
> > > Add comments about what is being tested. Also good to test via llvm-lto2 
> > > which has a similar -whole-program-visibility option, rather than just 
> > > via lld here. See for example 
> > > llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll.
> > added comments
> > 
> > I extended llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll, is that ok?
> Yeah sure that's fine. But maybe also add a direct check there in both cases 
> after promote that the public.type.test/assume were transformed as expected 
> as you do in this test.
done



Comment at: llvm/lib/LTO/LTOBackend.cpp:595
 
+  updatePublicTypeTestCalls(Mod, Conf.HasWholeProgramVisibility);
+

aeubanks wrote:
> tejohnson wrote:
> > aeubanks wrote:
> > > tejohnson wrote:
> > > > aeubanks wrote:
> > > > > I'm not sure where the best place to put these is
> > > > I don't think that this will work for distributed ThinLTO, where the 
> > > > ThinLTO Backends are run via clang, which isn't going to have this 
> > > > config variable set (since it is set only during LTO linking). I think 
> > > > something may need to be recorded in the index as a flag there at thin 
> > > > link / indexing time that can be checked here.
> > > > 
> > > > It would then be nice to consolidate this handling into WPD itself, 
> > > > e.g. at the start of DevirtModule::run, but unfortunately we won't have 
> > > > a summary index for pure regular LTO WPD so I don't think that would 
> > > > work. So in here is ok but I would do it early to handle some of the 
> > > > early return cases.
> > > > 
> > > > (Please add a distributed ThinLTO test too)
> > > Added a distributed ThinLTO test: 
> > > clang/test/CodeGenCXX/thinlto_public_type_test_distributed.ll.
> > > 
> > > I added `ModuleSummaryIndex::WithWholeProgramVisibility` but I'm not sure 
> > > where I'd set it, and that's causing the test to fail.
> > I see from your most recent update that you added code to set/check this 
> > new index flag. But I think you would want to set it around the same place 
> > where we update the vcall visibility during the thin link (see calls to 
> > updateVCallVisibilityInIndex). And I would do it via a new method in the 
> > WPD source file that uses the existing hasWholeProgramVisibility() that 
> > checks the OR of the config flag or the internal option. Then you don't 
> > need to add a new flag to llvm-lto2 for this purpose.
> > 
> > Also, as I noted for the regular LTO handling elsewhere, I think you need 
> > to add similar handling for the legacy LTO implementation. See other 
> > callers to updateVCallVisibilityInIndex.
> ah, I needed a separate WPV flag in llvm-lto2 to set `llvm::lto::Config`, now 
> everything passes
exposed the existing `hasWholeProgramVisibility`



Comment at: llvm/lib/Transforms/IPO/LowerTypeTests.cpp:1849
+  dropTypeTests(M, *TypeTestFunc);
+Function *PublicTypeTestFunc =
+M.getFunction(Intrinsic::getName(Intrinsic::public_type_test));

tejohnson wrote:
> aeubanks wrote:
> > tejohnson wrote:
> > > Shouldn't we have converted all of these by 

[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

I un-reverted this locally to take a better look.

It does not seem to me to be a compiler bug, because both cl.exe and 
intellisense are picking this error up, and I believe the MSVC intellisense is 
based on a completely different frontend (EDG).

What I see is that `enum class Rule` is empty.

We try to populate it with

  enum class Rule : RuleID {
  #define RULE(X, Y) X = Y,
  #include "CXXSymbols.inc"
  #undef RULE
  };

But I open `CXXSymbols.inc` and I see nothing that would expand that RULE 
macro, the contents of the file don't mention it at all, just `NONTERMINAL` and 
`EXTENSION`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D128955: [WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes

2022-07-20 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 446269.
aeubanks marked 3 inline comments as done.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128955

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/cfi-mfcall.cpp
  clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp
  clang/test/CodeGenCXX/thinlto_public_type_test_distributed.ll
  clang/test/CodeGenCXX/type-metadata.cpp
  lld/test/ELF/lto/update_public_type_test.ll
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Analysis/TypeMetadataUtils.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/LTO/X86/public-type-test.ll
  llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll

Index: llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
===
--- llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
+++ llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
@@ -10,6 +10,7 @@
 ; RUN:   -whole-program-visibility \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t2.o,test,px \
+; RUN:   -r=%t2.o,test_public,px \
 ; RUN:   -r=%t2.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
@@ -17,6 +18,7 @@
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
 ; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; Hybrid WPD
@@ -26,6 +28,7 @@
 ; RUN:   -whole-program-visibility \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,test_public,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t.o,_ZN1C1fEi,p \
@@ -40,6 +43,7 @@
 ; RUN:   -r=%t.o,_ZTV1B,px \
 ; RUN:   -r=%t.o,_ZTV1C,px \
 ; RUN:   -r=%t.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK --dump-input=fail
+; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; Regular LTO WPD
@@ -48,6 +52,7 @@
 ; RUN:   -whole-program-visibility \
 ; RUN:   -o %t5 \
 ; RUN:   -r=%t4.o,test,px \
+; RUN:   -r=%t4.o,test_public,px \
 ; RUN:   -r=%t4.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t4.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t4.o,_ZN1C1fEi,p \
@@ -55,8 +60,11 @@
 ; RUN:   -r=%t4.o,_ZTV1B,px \
 ; RUN:   -r=%t4.o,_ZTV1C,px \
 ; RUN:   -r=%t4.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: llvm-dis %t5.0.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t5.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
+; REMARK-DAG: single-impl: devirtualized a call to _ZN1A1nEi
+; REMARK-DAG: single-impl: devirtualized a call to _ZN1D1mEi
 ; REMARK-DAG: single-impl: devirtualized a call to _ZN1A1nEi
 ; REMARK-DAG: single-impl: devirtualized a call to _ZN1D1mEi
 
@@ -67,6 +75,7 @@
 ; RUN: llvm-lto2 run %t2.o -save-temps -pass-remarks=. \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t2.o,test,px \
+; RUN:   -r=%t2.o,test_public,px \
 ; RUN:   -r=%t2.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
@@ -74,12 +83,14 @@
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
 ; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --implicit-check-not single-impl --allow-empty
+; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-NODEVIRT-IR
 
 ; Hybrid WPD
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,test_public,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t.o,_ZN1C1fEi,p \
@@ -94,12 +105,14 @@
 ; RUN:   -r=%t.o,_ZTV1B,px \
 ; RUN:   -r=%t.o,_ZTV1C,px \
 ; RUN:   -r=%t.o,_ZTV1D,px 2>&1 | FileCheck %s --implicit-check-not single-impl --allow-empty
+; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-NODEVIRT-IR
 
 ; Regular LTO WPD
 ; RUN: llvm-lto2 run %t4.o -save-temps -pass-remarks=. \
 ; RUN:   -o %t5 \
 ; RUN:   -r=%t4.o,test,px \
+; RUN:   -r=%t4.o,test_public,px \
 ; RUN:   -r=%t4.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t4.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t4.o,_ZN1C1fEi,p \
@@ -107,6 +120,7 @@
 ; RUN:   -r=%t4.o,_ZTV1B,px \
 ; RUN:   -r=%t4.o,_ZTV1C,px \
 ; RUN:   -r=%t4.o,_ZTV1D,px 2>&1 | FileCheck %s --implicit-check-not 

[PATCH] D130205: [Darwin toolchain] Tune the logic for finding arclite.

2022-07-20 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor created this revision.
doug.gregor added a reviewer: arphaman.
doug.gregor added a project: clang.
Herald added a project: All.
doug.gregor requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.

The heuristic used to determine where the arclite libraries are to be
found was based on the path of the `clang` executable. However, in some
scenarios the `clang` executable is within a toolchain that does not
have arclite. When this happens, derive the arclite paths from the
sysroot option.

This allows Clang to correctly derive the arclite directory in, e.g.,
Swift CI, using similar logic to what the Swift driver has been doing
for several years.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130205

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


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1141,25 +1141,38 @@
   SmallString<128> P(getDriver().ClangExecutable);
   llvm::sys::path::remove_filename(P); // 'clang'
   llvm::sys::path::remove_filename(P); // 'bin'
+  llvm::sys::path::append(P, "lib", "arc");
 
   // 'libarclite' usually lives in the same toolchain as 'clang'. However, the
   // Swift open source toolchains for macOS distribute Clang without 
libarclite.
   // In that case, to allow the linker to find 'libarclite', we point to the
   // 'libarclite' in the XcodeDefault toolchain instead.
-  if (getXcodeDeveloperPath(P).empty()) {
-if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  if (!getVFS().exists(P)) {
+auto updatePath = [&](const Arg *A) {
   // Try to infer the path to 'libarclite' in the toolchain from the
   // specified SDK path.
   StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue());
-  if (!XcodePathForSDK.empty()) {
-P = XcodePathForSDK;
-llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr");
-  }
+  if (XcodePathForSDK.empty())
+return false;
+
+  P = XcodePathForSDK;
+  llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr",
+  "lib", "arc");
+  return getVFS().exists(P);
+};
+
+bool updated = false;
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot))
+  updated = updatePath(A);
+
+if (!updated) {
+  if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
+updatePath(A);
 }
   }
 
   CmdArgs.push_back("-force_load");
-  llvm::sys::path::append(P, "lib", "arc", "libarclite_");
+  llvm::sys::path::append(P, "libarclite_");
   // Mash in the platform.
   if (isTargetWatchOSSimulator())
 P += "watchsimulator";


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1141,25 +1141,38 @@
   SmallString<128> P(getDriver().ClangExecutable);
   llvm::sys::path::remove_filename(P); // 'clang'
   llvm::sys::path::remove_filename(P); // 'bin'
+  llvm::sys::path::append(P, "lib", "arc");
 
   // 'libarclite' usually lives in the same toolchain as 'clang'. However, the
   // Swift open source toolchains for macOS distribute Clang without libarclite.
   // In that case, to allow the linker to find 'libarclite', we point to the
   // 'libarclite' in the XcodeDefault toolchain instead.
-  if (getXcodeDeveloperPath(P).empty()) {
-if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  if (!getVFS().exists(P)) {
+auto updatePath = [&](const Arg *A) {
   // Try to infer the path to 'libarclite' in the toolchain from the
   // specified SDK path.
   StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue());
-  if (!XcodePathForSDK.empty()) {
-P = XcodePathForSDK;
-llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr");
-  }
+  if (XcodePathForSDK.empty())
+return false;
+
+  P = XcodePathForSDK;
+  llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr",
+  "lib", "arc");
+  return getVFS().exists(P);
+};
+
+bool updated = false;
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot))
+  updated = updatePath(A);
+
+if (!updated) {
+  if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
+updatePath(A);
 }
   }
 
   CmdArgs.push_back("-force_load");
-  llvm::sys::path::append(P, "lib", "arc", "libarclite_");
+  llvm::sys::path::append(P, "libarclite_");
   // Mash in the platform.
   if (isTargetWatchOSSimulator())
 P += "watchsimulator";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

`Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31627.1 for x64`

As included in `Microsoft Visual Studio 2022` `Version 17.3.0 Preview 4.0`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-20 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:17899
+  ConstraintSatisfaction Satisfaction;
+  if (S.CheckFunctionConstraints(Method, Satisfaction))
+SatisfactionStatus.push_back(false);

cor3ntin wrote:
> erichkeane wrote:
> > royjacobson wrote:
> > > erichkeane wrote:
> > > > royjacobson wrote:
> > > > > erichkeane wrote:
> > > > > > cor3ntin wrote:
> > > > > > > erichkeane wrote:
> > > > > > > > cor3ntin wrote:
> > > > > > > > > royjacobson wrote:
> > > > > > > > > > erichkeane wrote:
> > > > > > > > > > > This seems problematic, doesn't it?  Checking this 
> > > > > > > > > > > constraint will (once I figure out how to get deferred 
> > > > > > > > > > > instantiation to work) cause instantiation, which can 
> > > > > > > > > > > cause issues with incomplete types/CRTP/etc.
> > > > > > > > > > > 
> > > > > > > > > > > I think the result is that we cannot 'calculate' this 
> > > > > > > > > > > until it is queried, else we will cause incorrect errors.
> > > > > > > > > > Making this queried on demand is a relatively big change to 
> > > > > > > > > > how we handle type triviality, so I want to be sure we 
> > > > > > > > > > actually need to do this to be conformant.
> > > > > > > > > > 
> > > > > > > > > > When I started working on this I checked what GCC does and 
> > > > > > > > > > it instantiates those constraints during class completion 
> > > > > > > > > > as well. For example this CRTP case: 
> > > > > > > > > > https://godbolt.org/z/EdoYf96zq. MSVC seem to do it as well.
> > > > > > > > > > 
> > > > > > > > > > So maybe it's OK to check the constraints of SMFs 
> > > > > > > > > > specifically?
> > > > > > > > > > 
> > > > > > > > > I think this is done on completeness already in this patch, 
> > > > > > > > > unless i misunderstood the code.
> > > > > > > > > I don't think doing it on demand is a great direction, as 
> > > > > > > > > this does not only affect type traits but also code gen, etc. 
> > > > > > > > > It would create instanciations in unexpected places. wouldn't 
> > > > > > > > > it.
> > > > > > > > > Does the standard has wording suggesting it should be done 
> > > > > > > > > later than on type completeness?
> > > > > > > > The problem, at least for the deferred concepts, is that it 
> > > > > > > > breaks in the CRTP as required to implement ranges.  So 
> > > > > > > > something like this: https://godbolt.org/z/hPqrcqhx5 breaks.
> > > > > > > > 
> > > > > > > > I'm currently working to 'fix' that, so if this patch causes us 
> > > > > > > > to 'check' constraints early, it'll go back to breaking that 
> > > > > > > > example.  The example that Roy showed seems to show that it is 
> > > > > > > > actually checking 'delayed' right now (that is, on demand) in 
> > > > > > > > GCC/MSVC.  I don't know of the consequence/standardeeze that 
> > > > > > > > causes that though.
> > > > > > > Thanks, 
> > > > > > > Follow up stupid question then, do we care about the triviality 
> > > > > > > of dependant types?
> > > > > > > I think doing the check on complete non-dependant types might be 
> > > > > > > a better solution than trying to do it lazily on triviality 
> > > > > > > checks?
> > > > > > I would think it would be not a problem on non-dependent types.  
> > > > > > BUT concepts are only allowed on templated functions (note not only 
> > > > > > on function-templates!) anyway, so I don't think this would be a 
> > > > > > problem?  
> > > > > Erich, I'm a bit confused by your response. I think my example 
> > > > > demonstrates that for default constructors (and other SMFs) GCC and 
> > > > > MSVC instantiate the constraints on class completion and **not** on 
> > > > > demand. This is what I would like to do as well, if we don't have a 
> > > > > good reason not to. (For destructors, performing the checks is even 
> > > > > explicit in the standard.)
> > > > > 
> > > > > Not doing this can introduce some REALLY bad edge cases. What does 
> > > > > this do if we defer the triviality computation?
> > > > > 
> > > > > ```c++
> > > > > 
> > > > > template 
> > > > > struct Base {
> > > > >   Base() = default;
> > > > >   Base() requires (!std::is_trivial_v);
> > > > > };
> > > > > 
> > > > > struct Child : Base { };
> > > > > ```
> > > > > We defer the computation of the constraints on `Base`, and complete 
> > > > > `Child` somehow, but if `Child` is complete then 
> > > > > `std::is_trivial_v` should be well-formed, right? But we get a 
> > > > > logical contradiction instead.
> > > > > 
> > > > > 
> > > > >Erich, I'm a bit confused by your response
> > > > It is entirely possible we're talking past eachother, or 
> > > > misunderstanding eachothers examples.  I'm totally open to that being 
> > > > part of this issue.
> > > > 
> > > > In that example, if we calculate the triviality at '`Base` Class 
> > > > completion', `Child` is not yet complete, right?  So the is_trivial_v 
> > > > would be UB.  

[PATCH] D130190: [Driver] Error for -gsplit-dwarf with RISC-V linker relaxation

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:146
+Arg *A;
+if (getDebugFissionKind(D, Args, A) != DwarfFissionKind::None)
+  D.Diag(clang::diag::err_drv_riscv_unsupported_with_linker_relaxation)

compnerd wrote:
> This should be hoisted out, this will occur with or without relaxation.  That 
> is, `-mrelax` and `-mno-relax` are both problematic.
No. -mno-relax is supported with -gsplit-dwarf. I think the current code is 
correct.



Comment at: clang/test/Driver/riscv-features.c:41
+// RUN: not %clang -c --target=riscv64 -gsplit-dwarf=single %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: %clang -### -c --target=riscv64 -mno-relax -g -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT-DWARF
+

compnerd wrote:
> Can you please add a `-mno-relax` check as well?
The line you reference has `-mno-relax` :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130190

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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-20 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 446264.
royjacobson added a comment.

Add a test for the CRTP constraints timings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128619

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/conditionally-trivial-smfs.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/constrained-special-member-functions.cpp
  clang/www/cxx_status.html

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

 https://wg21.link/p0848r3;>P0848R3
-No
+Clang 15
   
   
 https://wg21.link/p1616r1;>P1616R1
Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s
+
+template 
+concept C0 = (N == 0);
+template 
+concept C1 = (N == 1);
+template 
+concept C2 = (N == 2);
+
+// Checks are indexed by:
+// Definition:
+//  1. Explicitly defaulted definition
+//  2. Deleted definition
+//  3. User provided definition
+// We have a less constrained user provided method that should not disable
+// the (copyable) triviality of the type.
+
+// Note that because Clang does not implement DRs 1496 and 1734, we say some
+// classes are trivial when the SMFs are deleted.
+
+template 
+struct DefaultConstructorChecker {
+DefaultConstructorChecker() requires C0 = default;
+DefaultConstructorChecker() requires C1 = delete;
+DefaultConstructorChecker() requires C2;
+DefaultConstructorChecker();
+};
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<0>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<1>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<2>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<3>));
+static_assert(__is_trivial(DefaultConstructorChecker<0>));
+// FIXME: DR1496
+static_assert(__is_trivial(DefaultConstructorChecker<1>));
+static_assert(!__is_trivial(DefaultConstructorChecker<2>));
+static_assert(!__is_trivial(DefaultConstructorChecker<3>));
+
+template 
+struct CopyConstructorChecker {
+CopyConstructorChecker(const CopyConstructorChecker&) requires C0 = default;
+CopyConstructorChecker(const CopyConstructorChecker&) requires C1 = delete;
+CopyConstructorChecker(const CopyConstructorChecker&) requires C2;
+CopyConstructorChecker(const CopyConstructorChecker&);
+};
+
+static_assert(__is_trivially_copyable(CopyConstructorChecker<0>));
+// FIXME: DR1734
+static_assert(__is_trivially_copyable(CopyConstructorChecker<1>));
+static_assert(!__is_trivially_copyable(CopyConstructorChecker<2>));
+static_assert(!__is_trivially_copyable(CopyConstructorChecker<3>));
+static_assert(!__is_trivial(CopyConstructorChecker<0>));
+static_assert(!__is_trivial(CopyConstructorChecker<1>));
+static_assert(!__is_trivial(CopyConstructorChecker<2>));
+static_assert(!__is_trivial(CopyConstructorChecker<3>));
+
+template 
+struct MoveConstructorChecker {
+MoveConstructorChecker(MoveConstructorChecker&&) requires C0 = default;
+MoveConstructorChecker(MoveConstructorChecker&&) requires C1 = delete;
+MoveConstructorChecker(MoveConstructorChecker&&) requires C2;
+MoveConstructorChecker(MoveConstructorChecker&&);
+};
+
+static_assert(__is_trivially_copyable(MoveConstructorChecker<0>));
+// FIXME: DR1734
+static_assert(__is_trivially_copyable(MoveConstructorChecker<1>));
+static_assert(!__is_trivially_copyable(MoveConstructorChecker<2>));
+static_assert(!__is_trivially_copyable(MoveConstructorChecker<3>));
+static_assert(!__is_trivial(MoveConstructorChecker<0>));
+static_assert(!__is_trivial(MoveConstructorChecker<1>));
+static_assert(!__is_trivial(MoveConstructorChecker<2>));
+static_assert(!__is_trivial(MoveConstructorChecker<3>));
+
+template 
+struct MoveAssignmentChecker {
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&) requires C0 = default;
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&) requires C1 = delete;
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&) requires C2;
+MoveAssignmentChecker& operator=(MoveAssignmentChecker&&);
+};
+
+static_assert(__is_trivially_copyable(MoveAssignmentChecker<0>));
+// FIXME: DR1734.
+static_assert(__is_trivially_copyable(MoveAssignmentChecker<1>));
+static_assert(!__is_trivially_copyable(MoveAssignmentChecker<2>));
+static_assert(!__is_trivially_copyable(MoveAssignmentChecker<3>));
+static_assert(__is_trivial(MoveAssignmentChecker<0>));
+// FIXME: 

[PATCH] D129784: [HIP] Allow the new driver to compile HIP in non-RDC mode

2022-07-20 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c1b32717bcf: [HIP] Allow the new driver to compile HIP in 
non-RDC mode (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129784

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/hip-binding.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip

Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -21,6 +21,16 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK %s
 
+// RUN: %clang -### -target x86_64-linux-gnu -fno-gpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
+// RUN:   -fuse-ld=lld -nogpuinc --offload-new-driver -c \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=CHECK %s
+
 // RUN: touch %T/a.o
 // RUN: touch %T/b.o
 // RUN: %clang -### -target x86_64-linux-gnu \
Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -11,7 +11,10 @@
 //
 // RUN: %clang -x hip -target x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 %s 2>&1 \
-// RUN: | FileCheck -check-prefixes=BIN,NRD %s
+// RUN: | FileCheck -check-prefixes=BIN,NRD,OLD %s
+// RUN: %clang -x hip -target x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --offload-new-driver --cuda-gpu-arch=gfx803 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=BIN,NRD,NEW %s
 //
 // RUN: %clang -x hip -target x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 -fgpu-rdc %s 2>&1 \
@@ -38,7 +41,8 @@
 // RDC-DAG: [[P11:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa)" {[[P10]]}, object
 // NRD-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]])
 // NRD-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
-// NRD-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]])
+// OLD-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]])
+// NEW-DAG: [[P14:[0-9]+]]: clang-linker-wrapper, {[[P13]]}, image, (host-[[T]])
 // RDC-DAG: [[P14:[0-9]+]]: linker, {[[P13]], [[P11]]}, image, (host-[[T]])
 
 //
Index: clang/test/Driver/hip-binding.hip
===
--- clang/test/Driver/hip-binding.hip
+++ clang/test/Driver/hip-binding.hip
@@ -4,6 +4,9 @@
 // RUN: %clang -ccc-print-bindings -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
 // RUN:   -c 2>&1 | FileCheck -check-prefix=NRDCS %s
+// RUN: %clang -ccc-print-bindings -target x86_64-linux-gnu --offload-new-driver \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -c 2>&1 | FileCheck -check-prefix=NRDCS %s
 // NRDCS: # "amdgcn-amd-amdhsa" - "clang", inputs: ["[[IN:.*hip-binding.hip]]"], output: "[[OBJ1:.*o]]"
 // NRDCS: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ1]]"], output: "[[IMG1:.*]]"
 // NRDCS: # "amdgcn-amd-amdhsa" - "clang", inputs: ["[[IN:.*hip-binding.hip]]"], output: "[[OBJ2:.*o]]"
@@ -19,6 +22,14 @@
 // RDCS: # "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[IN]]"], output: "[[HOSTOBJ:.*o]]"
 // RDCS: # "x86_64-unknown-linux-gnu" - "offload bundler", inputs: ["[[BC1]]", "[[BC2]]", "[[HOSTOBJ]]"], output: "{{.*}}"
 
+// RUN: %clang -ccc-print-bindings -target x86_64-linux-gnu --offload-new-driver \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -c -fgpu-rdc 2>&1 | FileCheck -check-prefix=RDCS-NEW %s
+// RDCS-NEW: # "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HIP803:.+]]"
+// RDCS-NEW: # "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]"], output: "[[HIP900:.+]]"
+// RDCS-NEW: # "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[HIP803]]", "[[HIP900]]"], output: "[[HIPFB:.+]]"
+// RDCS-NEW: # "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT]]", "[[HIPFB]]"], output: "{{.*}}"
+
 // RUN: touch %t.o
 // RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 -fgpu-rdc %t.o\
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7006,7 +7006,7 @@
 CmdArgs.push_back("-fcuda-include-gpubinary");
   

[clang] 0c1b327 - [HIP] Allow the new driver to compile HIP in non-RDC mode

2022-07-20 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-20T16:52:23-04:00
New Revision: 0c1b32717bcffcf8edf95294e98933bd4c1e76ed

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

LOG: [HIP] Allow the new driver to compile HIP in non-RDC mode

The new driver primarily allows us to support RDC-mode compilations with
proper linking. This is not needed for non-RDC mode compilation, but we
still would like the new driver to be able to handle this mode so we can
transition away from the old driver in the future. This patch adds the
necessary code to support creating a fatbinary for HIP code generation.

Reviewed By: yaxunl

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/hip-binding.hip
clang/test/Driver/hip-phases.hip
clang/test/Driver/hip-toolchain-no-rdc.hip

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e50fdd61423be..3f29afd359718 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4478,6 +4478,15 @@ Action *Driver::BuildOffloadingActions(Compilation ,
   }
 }
 
+// Compiling HIP in non-RDC mode requires linking each action individually.
+for (Action * : DeviceActions) {
+  if (A->getType() != types::TY_Object || Kind != Action::OFK_HIP ||
+  Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false))
+continue;
+  ActionList LinkerInput = {A};
+  A = C.MakeAction(LinkerInput, types::TY_Image);
+}
+
 auto TCAndArch = TCAndArchs.begin();
 for (Action *A : DeviceActions) {
   DDeps.add(*A, *TCAndArch->first, TCAndArch->second.data(), Kind);
@@ -4497,12 +4506,21 @@ Action *Driver::BuildOffloadingActions(Compilation ,
   OffloadAction::DeviceDependences DDep;
   if (C.isOffloadingHostKind(Action::OFK_Cuda) &&
   !Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false)) {
-// If we are not in RDC-mode we just emit the final CUDA fatbinary for each
-// translation unit without requiring any linking.
+// If we are not in RDC-mode we just emit the final CUDA fatbinary for
+// each translation unit without requiring any linking.
 Action *FatbinAction =
 C.MakeAction(OffloadActions, types::TY_CUDA_FATBIN);
 DDep.add(*FatbinAction, *C.getSingleOffloadToolChain(),
  nullptr, Action::OFK_Cuda);
+  } else if (C.isOffloadingHostKind(Action::OFK_HIP) &&
+ !Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
+   false)) {
+// If we are not in RDC-mode we just emit the final HIP fatbinary for each
+// translation unit, linking each input individually.
+Action *FatbinAction =
+C.MakeAction(OffloadActions, types::TY_HIP_FATBIN);
+DDep.add(*FatbinAction, *C.getSingleOffloadToolChain(),
+ nullptr, Action::OFK_HIP);
   } else {
 // Package all the offloading actions into a single output that can be
 // embedded in the host and linked.
@@ -4511,6 +4529,7 @@ Action *Driver::BuildOffloadingActions(Compilation ,
 DDep.add(*PackagerAction, *C.getSingleOffloadToolChain(),
  nullptr, Action::OFK_None);
   }
+
   OffloadAction::HostDependence HDep(
   *HostAction, *C.getSingleOffloadToolChain(),
   /*BoundArch=*/nullptr, isa(HostAction) ? DDep : DDeps);

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f50a80d7ff821..6337a996a9ace 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7006,7 +7006,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 CmdArgs.push_back("-fcuda-include-gpubinary");
 CmdArgs.push_back(CudaDeviceInput->getFilename());
   } else if (!HostOffloadingInputs.empty()) {
-if (IsCuda && !IsRDCMode) {
+if ((IsCuda || IsHIP) && !IsRDCMode) {
   assert(HostOffloadingInputs.size() == 1 && "Only one input expected");
   CmdArgs.push_back("-fcuda-include-gpubinary");
   CmdArgs.push_back(HostOffloadingInputs.front().getFilename());

diff  --git a/clang/test/Driver/hip-binding.hip 
b/clang/test/Driver/hip-binding.hip
index 94612954dfe60..6a27558dbf03d 100644
--- a/clang/test/Driver/hip-binding.hip
+++ b/clang/test/Driver/hip-binding.hip
@@ -4,6 +4,9 @@
 // RUN: %clang -ccc-print-bindings -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
 // RUN:   -c 2>&1 | FileCheck -check-prefix=NRDCS %s
+// RUN: %clang -ccc-print-bindings -target x86_64-linux-gnu 
--offload-new-driver \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -c 2>&1 | FileCheck -check-prefix=NRDCS %s
 // NRDCS: # 

[PATCH] D129784: [HIP] Allow the new driver to compile HIP in non-RDC mode

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

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129784

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


[PATCH] D130181: [clang-tidy] Add readability-use-early-exits check

2022-07-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 446255.
njames93 added a comment.

Fix pre-build failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130181

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/use-early-exits.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-braces.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
@@ -0,0 +1,164 @@
+// RUN: %check_clang_tidy %s readability-use-early-exits -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2}}"
+
+// Run the check with the braces around statements check also enabled, but 
+// ShortStatementLines is set so that we shouldn't add braces.
+// RUN: %check_clang_tidy %s readability-use-early-exits,readability-braces-around-statements -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2, \
+// RUN:readability-braces-around-statements.ShortStatementLines: 2}}"
+
+// Just to hit the threshold
+void padLines();
+
+void nomralFunc(int *A) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (A) {
+*A = 10;
+  }
+  //   CHECK-FIXES: if (!A)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *A = 10;
+}
+
+void funcWithTrailing(int *B) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (B) {
+*B = 10;
+  }
+  return;
+  ;
+  //   CHECK-FIXES: if (!B)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *B = 10;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: return;
+  //  CHECK-FIXES-NEXT: ;
+}
+
+void normal(int A, int B) {
+  
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A == B) {
+  padLines();
+}
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A != B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  //  CHECK-FIXES-NEXT: }
+
+  // Eat continue and empty nulls
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A != B) {
+  padLines();
+}
+continue;
+;
+continue;
+  } 
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT:   ;
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: }
+}
+
+void toShort(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+  }
+}
+
+void hasElse(int A, int B) {
+  while (true) {
+if (A == B) {
+
+} else {
+}
+  }
+}
+
+void hasTrailingStmt(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+padLines();
+  }
+}
+
+void nested(int A, int B) {
+  // if (A > B) {
+  // CHECK-MESSAGES: [[@LINE+6]]:5: warning: use early exit
+  // if (B < A) {
+  // CHECK-MESSAGES: [[@LINE+5]]:7: warning: use early exit
+  // if (A == B) {
+  // CHECK-MESSAGES: [[@LINE+4]]:9: warning: use early exit
+  while (true) { // Nested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  }
+}
+  } // EndLoop
+  //   CHECK-FIXES: while (true) { // Nested
+  //  CHECK-FIXES-NEXT: if (A <= B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (B >= A)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: } // EndLoop
+}
+
+void badNested(bool B) {
+  // Ensure check doesn't check for nested `if` if outer `if` has else.
+  while (true) {
+if (B) {
+  if (B) {
+  }
+} else {
+}
+  }
+}
+
+void semiNested(int A, int B) {
+  // CHECK-MESSAGES: [[@LINE+2]]:5: warning: use early exit
+  while (true) { // SemiNested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  } else {
+  }
+}
+  }
+  //   CHECK-FIXES: while (true) { // SemiNested
+  //  CHECK-FIXES-NEXT:   if (A <= B)
+  //  

[PATCH] D127267: [NVPTX] Add setAuxTarget override rather than make a new TargetInfo

2022-07-20 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard abandoned this revision.
rprichard added a comment.

Abandoning this patch because D127465  is a 
better fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127267

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


[PATCH] D130199: [pseudo] Add ambiguity & unparseability metrics to -print-statistics

2022-07-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

As mentioned offline, we may want a length-weighted version of the ambiguity 
metric when prioritizing, but I think this one is easier to understand in 
isolation. If we end up preferring the weighted version we can change this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130199

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


[PATCH] D130199: [pseudo] Add ambiguity & unparseability metrics to -print-statistics

2022-07-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: usaxena95.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.

These can be used to quantify parsing improvements from a change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130199

Files:
  clang-tools-extra/pseudo/test/glr.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp


Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -24,6 +24,8 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 
+using clang::pseudo::ForestNode;
+using clang::pseudo::Token;
 using clang::pseudo::TokenStream;
 using llvm::cl::desc;
 using llvm::cl::init;
@@ -172,9 +174,8 @@
   llvm::outs() << "GSS bytes: " << GSS.bytes()
<< " nodes: " << GSS.nodesCreated() << "\n";
 
-  for (auto  :
-   {std::make_pair("Ambiguous", clang::pseudo::ForestNode::Ambiguous),
-std::make_pair("Opaque", clang::pseudo::ForestNode::Opaque)}) {
+  for (auto  : {std::make_pair("Ambiguous", ForestNode::Ambiguous),
+  std::make_pair("Opaque", ForestNode::Opaque)}) {
 clang::pseudo::NodeStats Stats(
 Root, [&](const auto ) { return N.kind() == P.second; });
 llvm::outs() << "\n" << Stats.Total << " " << P.first << " nodes:\n";
@@ -182,6 +183,39 @@
   llvm::outs() << llvm::formatv("  {0,3} {1}\n", S.second,
 Lang.G.symbolName(S.first));
   }
+
+  // Metrics for how imprecise parsing was.
+  // These are rough but aim to be:
+  // - linear: if we eliminate half the errors the metric should halve
+  // - length-independent
+  unsigned UnparsedTokens = 0; // Tokens covered by Opaque. (not unique)
+  unsigned Misparses = 0;  // Sum of alternatives-1
+  llvm::DenseSet Visited;
+  auto DFS = [&](const ForestNode , Token::Index End, auto ) -> void 
{
+if (N.kind() == ForestNode::Opaque) {
+  UnparsedTokens += End - N.startTokenIndex();
+} else if (N.kind() == ForestNode::Ambiguous) {
+  Misparses += N.alternatives().size() - 1;
+  for (const auto *C : N.alternatives())
+if (Visited.insert(C).second)
+  DFS(*C, End, DFS);
+} else if (N.kind() == ForestNode::Sequence) {
+  for (unsigned I = 0, E = N.children().size(); I < E; ++I)
+if (Visited.insert(N.children()[I]).second)
+  DFS(*N.children()[I],
+  I + 1 == N.children().size()
+  ? End
+  : N.children()[I + 1]->startTokenIndex(),
+  DFS);
+}
+  };
+  unsigned Len = ParseableStream->tokens().size();
+  DFS(Root, Len, DFS);
+  llvm::outs() << "\n";
+  llvm::outs() << llvm::formatv("Ambiguity: {0} misparses/token\n",
+double(Misparses) / Len);
+  llvm::outs() << llvm::formatv("Unparsed: {0}%\n",
+100.0 * UnparsedTokens / Len);
 }
   }
 
Index: clang-tools-extra/pseudo/test/glr.cpp
===
--- clang-tools-extra/pseudo/test/glr.cpp
+++ clang-tools-extra/pseudo/test/glr.cpp
@@ -29,3 +29,6 @@
 // CHECK-NEXT: 1 type-name
 // CHECK-EMPTY:
 // CHECK-NEXT: 0 Opaque nodes:
+// CHECK-EMPTY:
+// CHECK-NEXT: Ambiguity: 0.40 misparses/token
+// CHECK-NEXT: Unparsed: 0.00%


Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -24,6 +24,8 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 
+using clang::pseudo::ForestNode;
+using clang::pseudo::Token;
 using clang::pseudo::TokenStream;
 using llvm::cl::desc;
 using llvm::cl::init;
@@ -172,9 +174,8 @@
   llvm::outs() << "GSS bytes: " << GSS.bytes()
<< " nodes: " << GSS.nodesCreated() << "\n";
 
-  for (auto  :
-   {std::make_pair("Ambiguous", clang::pseudo::ForestNode::Ambiguous),
-std::make_pair("Opaque", clang::pseudo::ForestNode::Opaque)}) {
+  for (auto  : {std::make_pair("Ambiguous", ForestNode::Ambiguous),
+  std::make_pair("Opaque", ForestNode::Opaque)}) {
 clang::pseudo::NodeStats Stats(
 Root, [&](const auto ) { return N.kind() == P.second; });
 llvm::outs() << "\n" << Stats.Total << " " << P.first << " nodes:\n";
@@ -182,6 +183,39 @@
   llvm::outs() << llvm::formatv("  {0,3} {1}\n", S.second,
 

[PATCH] D130190: [Driver] Error for -gsplit-dwarf with RISC-V linker relaxation

2022-07-20 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:146
+Arg *A;
+if (getDebugFissionKind(D, Args, A) != DwarfFissionKind::None)
+  D.Diag(clang::diag::err_drv_riscv_unsupported_with_linker_relaxation)

This should be hoisted out, this will occur with or without relaxation.  That 
is, `-mrelax` and `-mno-relax` are both problematic.



Comment at: clang/test/Driver/riscv-features.c:41
+// RUN: not %clang -c --target=riscv64 -gsplit-dwarf=single %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: %clang -### -c --target=riscv64 -mno-relax -g -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT-DWARF
+

Can you please add a `-mno-relax` check as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130190

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


[PATCH] D130190: [Driver] Error for -gsplit-dwarf with RISC-V linker relaxation

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:10
 #include "RISCV.h"
+#include "../Clang.h"
 #include "ToolChains/CommonArgs.h"

compnerd wrote:
> This feels like a layering violation.  I suppose that as long as modular 
> builds are okay ...
lib/Driver/ToolChains/Arch does not form a module or library. Arch/ is just a 
subdirectory containing these arch-specific files. So I think this is fine.



Comment at: clang/test/Driver/riscv-features.c:40
+// RUN: not %clang -c --target=riscv64-linux-gnu -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: not %clang -c --target=riscv64 -gsplit-dwarf=single %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: %clang -### -c --target=riscv64 -mno-relax -g -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT-DWARF

compnerd wrote:
> Did you mean to add `-###` to these two?
No. In the presence of errors, without `-###` the clang command exists with 1 
and does not write to the output. I feel that this behavior is better for error 
testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130190

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


[PATCH] D130190: [Driver] Error for -gsplit-dwarf with RISC-V linker relaxation

2022-07-20 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:10
 #include "RISCV.h"
+#include "../Clang.h"
 #include "ToolChains/CommonArgs.h"

This feels like a layering violation.  I suppose that as long as modular builds 
are okay ...



Comment at: clang/test/Driver/riscv-features.c:40
+// RUN: not %clang -c --target=riscv64-linux-gnu -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: not %clang -c --target=riscv64 -gsplit-dwarf=single %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: %clang -### -c --target=riscv64 -mno-relax -g -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT-DWARF

Did you mean to add `-###` to these two?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130190

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


[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/forwarding-sections-liblto.c:2
+// RUN: touch %t.o
+// RUN: %clang %t.o -### -flto 2>&1 | FileCheck %s
+// RUN: %clang %t.o -### -flto 2>&1 -ffunction-sections -fdata-sections | \

Using a default triple this way does not work on platforms with a default 
toolchain which doesn't use LTO.

Instead of adding a new file, you may rename gold-lto-sections.c and add more 
RUN lines there.

Change `-target x86_64-unknown-linux` to `--target=...` if you make such a 
change.



Comment at: llvm/test/LTO/PowerPC/data-sections-aix.ll:18
+
+; CHECK:  SYMBOL TABLE:
+; CHECK:  .data

Err I want that you test something like ` g F .text  {{.*}} 
f`

Is the output not implemented in AIX?



Comment at: llvm/test/LTO/PowerPC/data-sections-linux.ll:18
+
+; CHECK:  SYMBOL TABLE:
+; CHECK:  .bss.var

Just test one line, something like ` g O .data  {{.*}} var`

Is the output not implemented in AIX?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

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


[PATCH] D130138: [modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.

2022-07-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Looks like GCC has some naming pattern there, thanks for sharing, Iain. So I 
want to share the pattern I'm aiming for. I'd like the flag to start with 
`-Rmodule-...` to be consistent with `-Rmodule-build`, `-Rmodule-import`, 
`-Rmodule-lock`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130138

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


[PATCH] D130160: [pseudo] Eliminate the dangling-else syntax ambiguity.

2022-07-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Language.h:25
+  const TokenStream 
+  SymbolID Lookahead;
+};

passing the position in the stream would be more general, there's no reason in 
particular that the amount of lookahead the guard needs is the same as what we 
have in GLR

OTOH as long as it *is* the same this is probably faster



Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:25
 
-bool guardOverride(llvm::ArrayRef RHS,
-   const TokenStream ) {
-  assert(RHS.size() == 1 &&
- RHS.front()->symbol() == tokenSymbol(clang::tok::identifier));
-  return Tokens.tokens()[RHS.front()->startTokenIndex()].text() == "override";
+bool guardOverride(const GuardParams ) {
+  assert(Params.RHS.size() == 1 &&

nit: I would suggest calling this conventionally P instead of Params, the 
bodies of these are really verbose



Comment at: clang-tools-extra/pseudo/test/cxx/dangling-else.cpp:3
+
+if (true)
+ if (true) {

nit: place this all on one line so it's clear there's no indentation-based 
heuristics at play?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130160

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


[PATCH] D130190: [Driver] Error for -gsplit-dwarf with RISC-V linker relaxation

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 446239.
MaskRay added a comment.

incompatible => unsupported

since it is implementable (but difficult).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130190

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -35,3 +35,10 @@
 // RUN: not %clang -cc1 -triple riscv64-unknown-elf -target-feature +e 2>&1 | 
FileCheck %s -check-prefix=RV64-WITH-E
 
 // RV64-WITH-E: error: invalid feature combination: standard user-level 
extension 'e' requires 'rv32'
+
+// RUN: not %clang -c --target=riscv64-linux-gnu -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: not %clang -c --target=riscv64 -gsplit-dwarf=single %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: %clang -### -c --target=riscv64 -mno-relax -g -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT-DWARF
+
+// ERR-SPLIT-DWARF: error: -gsplit-dwarf{{.*}} is unsupported with RISC-V 
linker relaxation (-mrelax)
+// SPLIT-DWARF: "-split-dwarf-file"
Index: clang/lib/Driver/ToolChains/Clang.h
===
--- clang/lib/Driver/ToolChains/Clang.h
+++ clang/lib/Driver/ToolChains/Clang.h
@@ -198,6 +198,12 @@
 const char *LinkingOutput) const override;
 };
 
+enum class DwarfFissionKind { None, Split, Single };
+
+DwarfFissionKind getDebugFissionKind(const Driver ,
+ const llvm::opt::ArgList ,
+ llvm::opt::Arg *);
+
 } // end namespace tools
 
 } // end namespace driver
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4051,9 +4051,7 @@
  options::OPT_fno_spell_checking);
 }
 
-enum class DwarfFissionKind { None, Split, Single };
-
-static DwarfFissionKind getDebugFissionKind(const Driver ,
+DwarfFissionKind tools::getDebugFissionKind(const Driver ,
 const ArgList , Arg *) {
   Arg = Args.getLastArg(options::OPT_gsplit_dwarf, 
options::OPT_gsplit_dwarf_EQ,
 options::OPT_gno_split_dwarf);
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "RISCV.h"
+#include "../Clang.h"
 #include "ToolChains/CommonArgs.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Driver/Driver.h"
@@ -137,10 +138,17 @@
 Features.push_back("+reserve-x31");
 
   // -mrelax is default, unless -mno-relax is specified.
-  if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))
+  if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) {
 Features.push_back("+relax");
-  else
+// -gsplit-dwarf -mrelax requires DW_AT_high_pc/DW_AT_ranges/... indexing
+// into .debug_addr, which is currently not implemented.
+Arg *A;
+if (getDebugFissionKind(D, Args, A) != DwarfFissionKind::None)
+  D.Diag(clang::diag::err_drv_riscv_unsupported_with_linker_relaxation)
+  << A->getAsString(Args);
+  } else {
 Features.push_back("-relax");
+  }
 
   // GCC Compatibility: -mno-save-restore is default, unless -msave-restore is
   // specified.
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -678,4 +678,7 @@
 def err_drv_invalid_empty_dxil_validator_version : Error<
   "invalid validator version : %0\n"
   "If validator major version is 0, minor version must also be 0.">;
+
+def err_drv_riscv_unsupported_with_linker_relaxation : Error<
+  "%0 is unsupported with RISC-V linker relaxation (-mrelax)">;
 }


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -35,3 +35,10 @@
 // RUN: not %clang -cc1 -triple riscv64-unknown-elf -target-feature +e 2>&1 | FileCheck %s -check-prefix=RV64-WITH-E
 
 // RV64-WITH-E: error: invalid feature combination: standard user-level extension 'e' requires 'rv32'
+
+// RUN: not %clang -c --target=riscv64-linux-gnu -gsplit-dwarf %s 

[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D129222#3666043 , @mizvekov wrote:

> I confirm reverting just this patch fixes the build for me.

Hi @mizvekov,
Can you provide details about the compiler version?
Neither the presubmit nor postsubmit bots (e.g. 
) had this error, 
and I can't relate the error messages to the code (member declaration on line 
59?!)
I fear this is a compiler bug we'll need to work around.

@hokein it probably still makes sense to revert...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D67025: Add .inl as valid C++ header type

2022-07-20 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Note that in this directory is an ,inl file:
https://github.com/openucx/ucx/tree/master/src/uct/ib/mlx5
It is a pure C library with C++ gtest.

I believe that .inl is about inlining, but it is not tied to a language.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67025

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-20 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

From a purely personal perspective, I'd prefer if this landed after the branch 
for llvm-15.

We try to co-release IWYU shortly after LLVM/Clang are released, to get a 
public API-compatible release out there. So it would be really nice if we 
didn't have to spend time working around AST changes while the clock is ticking 
to get a release out the door.

That said, I know we're just an out-of-tree project and the LLVM project as 
such doesn't make any promises (and shouldn't have to!). I just thought I'd 
raise the concern to see if anybody shares it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D67025: Add .inl as valid C++ header type

2022-07-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

> ! In D67025#3665293 , @aaron.ballman 
> wrote:
>  this is why we have the `-x` option so that users can specify a specific 
> language mode to use. Is there a reason that option does not suffice for 
> clangd?

The difficulty here is that command-line flags are a very awkward/brittle 
interface but also the only one we have.

The situation we're in is:

- we have filename and a collection of `clang` flags mashed together from build 
system, config, and defaults
- we need a CompilerInvocation that reflects those flags... (which only Driver 
can provide)
- *except* that if the extension and flags don't imply a language then treat it 
as "c++-header" by default, rather than failing

It's very difficult to robustly manipulate the flags to achieve these effects, 
basically needing a model of the driver's behavior (identify every flag that 
can affect the parse language, remember which flags are global and which affect 
following filenames, and guarantee these rules never change).

What would solve the problem is a flag like `-xfallback=c++-header` to change 
the driver's behavior but adding that to clang is ugly.
What we may end up with is a bunch of heuristics about whether to add -x or 
not, which are complicated and usually buggy. We have lots of these.
I wish I had a better answer...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67025

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


[PATCH] D129748: [Modules] Disable preferred_name attribute in C++20 Modules

2022-07-20 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

> Personally, the problem is not serializing class template specializations 
> "too early". The problem is that we are deserializing class template 
> specializations "too early".

Yes, I agree.

> The key point here is that Modules would read declarations lazily for 
> performance reasons. This is a feature of modules.

Indeed it is, and an important one. I don't think laziness poses a problem 
though; the issue is ensuring that dependencies are (de)serialized in a proper 
order. In this case, that implies that, at least for a class template declared 
with the `__preferred_name__` attribute, a non-defining declaration must be 
deserialized before the defining declaration.

I can imagine several ways in which things may be going wrong. Perhaps 
(de)serialization is switching to a canonical declaration when it should not be 
(e.g., reading/writing a definition when only a declaration should be). 
Perhaps, for implicitly instantiated declarations (at least for ones for which 
`__preferred_name__` is attached), separate non-defining and defining 
declarations should be (de)serialized (in the dumps above, there appears to 
only be a single address associated with the `basic_string_view` 
specialization). Perhaps `ClassTemplateSpecializationDecl` should be 
(de)serialized such that a (valid) non-defining declaration is created before 
attempting to load anything else that might lead to recursion to the same 
declaration (the intent being that an early return when recursion is detected 
still yields a valid incomplete declaration).

I briefly looked at some code, but (unsurprisingly) did not see anything 
obvious. I am inclined towards finding a better fix for this before accepting 
it. If a good fix isn't identified for the initial Clang 15 release, I think an 
argument can be made for including it in a Clang 15.0.X release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129748

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-20 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

import-std-module test changes look good to me, thanks for fixing that up.

And yes, ideally the tests should never use any libc++ internal names (and LLDB 
should never print them for those tests). So I think not having those in the 
here is a step in the right direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:17899
+  ConstraintSatisfaction Satisfaction;
+  if (S.CheckFunctionConstraints(Method, Satisfaction))
+SatisfactionStatus.push_back(false);

erichkeane wrote:
> royjacobson wrote:
> > erichkeane wrote:
> > > royjacobson wrote:
> > > > erichkeane wrote:
> > > > > cor3ntin wrote:
> > > > > > erichkeane wrote:
> > > > > > > cor3ntin wrote:
> > > > > > > > royjacobson wrote:
> > > > > > > > > erichkeane wrote:
> > > > > > > > > > This seems problematic, doesn't it?  Checking this 
> > > > > > > > > > constraint will (once I figure out how to get deferred 
> > > > > > > > > > instantiation to work) cause instantiation, which can cause 
> > > > > > > > > > issues with incomplete types/CRTP/etc.
> > > > > > > > > > 
> > > > > > > > > > I think the result is that we cannot 'calculate' this until 
> > > > > > > > > > it is queried, else we will cause incorrect errors.
> > > > > > > > > Making this queried on demand is a relatively big change to 
> > > > > > > > > how we handle type triviality, so I want to be sure we 
> > > > > > > > > actually need to do this to be conformant.
> > > > > > > > > 
> > > > > > > > > When I started working on this I checked what GCC does and it 
> > > > > > > > > instantiates those constraints during class completion as 
> > > > > > > > > well. For example this CRTP case: 
> > > > > > > > > https://godbolt.org/z/EdoYf96zq. MSVC seem to do it as well.
> > > > > > > > > 
> > > > > > > > > So maybe it's OK to check the constraints of SMFs 
> > > > > > > > > specifically?
> > > > > > > > > 
> > > > > > > > I think this is done on completeness already in this patch, 
> > > > > > > > unless i misunderstood the code.
> > > > > > > > I don't think doing it on demand is a great direction, as this 
> > > > > > > > does not only affect type traits but also code gen, etc. It 
> > > > > > > > would create instanciations in unexpected places. wouldn't it.
> > > > > > > > Does the standard has wording suggesting it should be done 
> > > > > > > > later than on type completeness?
> > > > > > > The problem, at least for the deferred concepts, is that it 
> > > > > > > breaks in the CRTP as required to implement ranges.  So something 
> > > > > > > like this: https://godbolt.org/z/hPqrcqhx5 breaks.
> > > > > > > 
> > > > > > > I'm currently working to 'fix' that, so if this patch causes us 
> > > > > > > to 'check' constraints early, it'll go back to breaking that 
> > > > > > > example.  The example that Roy showed seems to show that it is 
> > > > > > > actually checking 'delayed' right now (that is, on demand) in 
> > > > > > > GCC/MSVC.  I don't know of the consequence/standardeeze that 
> > > > > > > causes that though.
> > > > > > Thanks, 
> > > > > > Follow up stupid question then, do we care about the triviality of 
> > > > > > dependant types?
> > > > > > I think doing the check on complete non-dependant types might be a 
> > > > > > better solution than trying to do it lazily on triviality checks?
> > > > > I would think it would be not a problem on non-dependent types.  BUT 
> > > > > concepts are only allowed on templated functions (note not only on 
> > > > > function-templates!) anyway, so I don't think this would be a 
> > > > > problem?  
> > > > Erich, I'm a bit confused by your response. I think my example 
> > > > demonstrates that for default constructors (and other SMFs) GCC and 
> > > > MSVC instantiate the constraints on class completion and **not** on 
> > > > demand. This is what I would like to do as well, if we don't have a 
> > > > good reason not to. (For destructors, performing the checks is even 
> > > > explicit in the standard.)
> > > > 
> > > > Not doing this can introduce some REALLY bad edge cases. What does this 
> > > > do if we defer the triviality computation?
> > > > 
> > > > ```c++
> > > > 
> > > > template 
> > > > struct Base {
> > > >   Base() = default;
> > > >   Base() requires (!std::is_trivial_v);
> > > > };
> > > > 
> > > > struct Child : Base { };
> > > > ```
> > > > We defer the computation of the constraints on `Base`, and complete 
> > > > `Child` somehow, but if `Child` is complete then 
> > > > `std::is_trivial_v` should be well-formed, right? But we get a 
> > > > logical contradiction instead.
> > > > 
> > > > 
> > > >Erich, I'm a bit confused by your response
> > > It is entirely possible we're talking past eachother, or misunderstanding 
> > > eachothers examples.  I'm totally open to that being part of this issue.
> > > 
> > > In that example, if we calculate the triviality at '`Base` Class 
> > > completion', `Child` is not yet complete, right?  So the is_trivial_v 
> > > would be UB.  If you instead require `sizeof(T)`, we typically give a 
> > > diagnostic.
> > > 
> > > In this case, you'd at MINIMUM have to wait to calculate the 
> > > requires-clause until after `Child` is complete.  And it isn't clear to 
> > > me 

[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:17899
+  ConstraintSatisfaction Satisfaction;
+  if (S.CheckFunctionConstraints(Method, Satisfaction))
+SatisfactionStatus.push_back(false);

royjacobson wrote:
> erichkeane wrote:
> > royjacobson wrote:
> > > erichkeane wrote:
> > > > cor3ntin wrote:
> > > > > erichkeane wrote:
> > > > > > cor3ntin wrote:
> > > > > > > royjacobson wrote:
> > > > > > > > erichkeane wrote:
> > > > > > > > > This seems problematic, doesn't it?  Checking this constraint 
> > > > > > > > > will (once I figure out how to get deferred instantiation to 
> > > > > > > > > work) cause instantiation, which can cause issues with 
> > > > > > > > > incomplete types/CRTP/etc.
> > > > > > > > > 
> > > > > > > > > I think the result is that we cannot 'calculate' this until 
> > > > > > > > > it is queried, else we will cause incorrect errors.
> > > > > > > > Making this queried on demand is a relatively big change to how 
> > > > > > > > we handle type triviality, so I want to be sure we actually 
> > > > > > > > need to do this to be conformant.
> > > > > > > > 
> > > > > > > > When I started working on this I checked what GCC does and it 
> > > > > > > > instantiates those constraints during class completion as well. 
> > > > > > > > For example this CRTP case: https://godbolt.org/z/EdoYf96zq. 
> > > > > > > > MSVC seem to do it as well.
> > > > > > > > 
> > > > > > > > So maybe it's OK to check the constraints of SMFs specifically?
> > > > > > > > 
> > > > > > > I think this is done on completeness already in this patch, 
> > > > > > > unless i misunderstood the code.
> > > > > > > I don't think doing it on demand is a great direction, as this 
> > > > > > > does not only affect type traits but also code gen, etc. It would 
> > > > > > > create instanciations in unexpected places. wouldn't it.
> > > > > > > Does the standard has wording suggesting it should be done later 
> > > > > > > than on type completeness?
> > > > > > The problem, at least for the deferred concepts, is that it breaks 
> > > > > > in the CRTP as required to implement ranges.  So something like 
> > > > > > this: https://godbolt.org/z/hPqrcqhx5 breaks.
> > > > > > 
> > > > > > I'm currently working to 'fix' that, so if this patch causes us to 
> > > > > > 'check' constraints early, it'll go back to breaking that example.  
> > > > > > The example that Roy showed seems to show that it is actually 
> > > > > > checking 'delayed' right now (that is, on demand) in GCC/MSVC.  I 
> > > > > > don't know of the consequence/standardeeze that causes that though.
> > > > > Thanks, 
> > > > > Follow up stupid question then, do we care about the triviality of 
> > > > > dependant types?
> > > > > I think doing the check on complete non-dependant types might be a 
> > > > > better solution than trying to do it lazily on triviality checks?
> > > > I would think it would be not a problem on non-dependent types.  BUT 
> > > > concepts are only allowed on templated functions (note not only on 
> > > > function-templates!) anyway, so I don't think this would be a problem?  
> > > Erich, I'm a bit confused by your response. I think my example 
> > > demonstrates that for default constructors (and other SMFs) GCC and MSVC 
> > > instantiate the constraints on class completion and **not** on demand. 
> > > This is what I would like to do as well, if we don't have a good reason 
> > > not to. (For destructors, performing the checks is even explicit in the 
> > > standard.)
> > > 
> > > Not doing this can introduce some REALLY bad edge cases. What does this 
> > > do if we defer the triviality computation?
> > > 
> > > ```c++
> > > 
> > > template 
> > > struct Base {
> > >   Base() = default;
> > >   Base() requires (!std::is_trivial_v);
> > > };
> > > 
> > > struct Child : Base { };
> > > ```
> > > We defer the computation of the constraints on `Base`, and complete 
> > > `Child` somehow, but if `Child` is complete then 
> > > `std::is_trivial_v` should be well-formed, right? But we get a 
> > > logical contradiction instead.
> > > 
> > > 
> > >Erich, I'm a bit confused by your response
> > It is entirely possible we're talking past eachother, or misunderstanding 
> > eachothers examples.  I'm totally open to that being part of this issue.
> > 
> > In that example, if we calculate the triviality at '`Base` Class 
> > completion', `Child` is not yet complete, right?  So the is_trivial_v would 
> > be UB.  If you instead require `sizeof(T)`, we typically give a diagnostic.
> > 
> > In this case, you'd at MINIMUM have to wait to calculate the 
> > requires-clause until after `Child` is complete.  And it isn't clear to me 
> > that we're delaying it until then.
> > 
> > That is what I intend to show with: https://godbolt.org/z/1YjsdY73P
> > 
> > As far as doing it 'on demand', I definitely see your circular argument 
> > here, but I think the is_trivial_v test is UB 

[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-20 Thread Quinn Pham via Phabricator via cfe-commits
quinnp added a comment.

In D129401#3666238 , @MaskRay wrote:

> Mostly looks good, with a nit in the test and some suggestion to the summary.
>
> In D129401#3662857 , @quinnp wrote:
>
>>> If this is for the legacy LTO interface, please state so.  `lld/*/LTO.cpp` 
>>> sets `c.Options.DataSections = true;` to enable data sections by default.
>>
>> Hey @MaskRay, I'm not sure what is considered the legacy LTO interface, but 
>> this change is to make the `libLTO` codegen match the behaviour of `LTO` 
>> used through `lld` and `gold plugin`. Both `lld` and `gold plugin` turn on 
>> `data-sections` for `LTO` by default:
>>
>> - as you mentioned `lld/*/LTO.cpp` sets `c.Options.DataSections = true;` by 
>> default.
>> - and `llvm/tools/gold/gold-plugin.cpp` sets `Conf.Options.DataSections = 
>> SplitSections;` provided that the user did not explicitly set/unset 
>> `data-sections` where `SplitSections` is `true` unless `gold plugin` is 
>> doing a relocatable link.
>
> There is a legacy LTO interface (see 
> llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h) and a resolution-based 
> interface.
> Change libLTO in "This patch changes libLTO to set data-sections by default." 
> to legacy LTO.
>
>> This patch also fixes the forwarding of the clang options -fno-data-sections 
>> and -fno-function-sections to libLTO
>
> This sentence can keep using libLTO or LLVMLTO (the library is LLVMLTO per 
> llvm/lib/LTO/CMakeLists.txt)

Ah I see, thank you @MaskRay! I've updated the testcases and the summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-20 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:17899
+  ConstraintSatisfaction Satisfaction;
+  if (S.CheckFunctionConstraints(Method, Satisfaction))
+SatisfactionStatus.push_back(false);

erichkeane wrote:
> royjacobson wrote:
> > erichkeane wrote:
> > > cor3ntin wrote:
> > > > erichkeane wrote:
> > > > > cor3ntin wrote:
> > > > > > royjacobson wrote:
> > > > > > > erichkeane wrote:
> > > > > > > > This seems problematic, doesn't it?  Checking this constraint 
> > > > > > > > will (once I figure out how to get deferred instantiation to 
> > > > > > > > work) cause instantiation, which can cause issues with 
> > > > > > > > incomplete types/CRTP/etc.
> > > > > > > > 
> > > > > > > > I think the result is that we cannot 'calculate' this until it 
> > > > > > > > is queried, else we will cause incorrect errors.
> > > > > > > Making this queried on demand is a relatively big change to how 
> > > > > > > we handle type triviality, so I want to be sure we actually need 
> > > > > > > to do this to be conformant.
> > > > > > > 
> > > > > > > When I started working on this I checked what GCC does and it 
> > > > > > > instantiates those constraints during class completion as well. 
> > > > > > > For example this CRTP case: https://godbolt.org/z/EdoYf96zq. MSVC 
> > > > > > > seem to do it as well.
> > > > > > > 
> > > > > > > So maybe it's OK to check the constraints of SMFs specifically?
> > > > > > > 
> > > > > > I think this is done on completeness already in this patch, unless 
> > > > > > i misunderstood the code.
> > > > > > I don't think doing it on demand is a great direction, as this does 
> > > > > > not only affect type traits but also code gen, etc. It would create 
> > > > > > instanciations in unexpected places. wouldn't it.
> > > > > > Does the standard has wording suggesting it should be done later 
> > > > > > than on type completeness?
> > > > > The problem, at least for the deferred concepts, is that it breaks in 
> > > > > the CRTP as required to implement ranges.  So something like this: 
> > > > > https://godbolt.org/z/hPqrcqhx5 breaks.
> > > > > 
> > > > > I'm currently working to 'fix' that, so if this patch causes us to 
> > > > > 'check' constraints early, it'll go back to breaking that example.  
> > > > > The example that Roy showed seems to show that it is actually 
> > > > > checking 'delayed' right now (that is, on demand) in GCC/MSVC.  I 
> > > > > don't know of the consequence/standardeeze that causes that though.
> > > > Thanks, 
> > > > Follow up stupid question then, do we care about the triviality of 
> > > > dependant types?
> > > > I think doing the check on complete non-dependant types might be a 
> > > > better solution than trying to do it lazily on triviality checks?
> > > I would think it would be not a problem on non-dependent types.  BUT 
> > > concepts are only allowed on templated functions (note not only on 
> > > function-templates!) anyway, so I don't think this would be a problem?  
> > Erich, I'm a bit confused by your response. I think my example demonstrates 
> > that for default constructors (and other SMFs) GCC and MSVC instantiate the 
> > constraints on class completion and **not** on demand. This is what I would 
> > like to do as well, if we don't have a good reason not to. (For 
> > destructors, performing the checks is even explicit in the standard.)
> > 
> > Not doing this can introduce some REALLY bad edge cases. What does this do 
> > if we defer the triviality computation?
> > 
> > ```c++
> > 
> > template 
> > struct Base {
> >   Base() = default;
> >   Base() requires (!std::is_trivial_v);
> > };
> > 
> > struct Child : Base { };
> > ```
> > We defer the computation of the constraints on `Base`, and complete `Child` 
> > somehow, but if `Child` is complete then `std::is_trivial_v` should 
> > be well-formed, right? But we get a logical contradiction instead.
> > 
> > 
> >Erich, I'm a bit confused by your response
> It is entirely possible we're talking past eachother, or misunderstanding 
> eachothers examples.  I'm totally open to that being part of this issue.
> 
> In that example, if we calculate the triviality at '`Base` Class completion', 
> `Child` is not yet complete, right?  So the is_trivial_v would be UB.  If you 
> instead require `sizeof(T)`, we typically give a diagnostic.
> 
> In this case, you'd at MINIMUM have to wait to calculate the requires-clause 
> until after `Child` is complete.  And it isn't clear to me that we're 
> delaying it until then.
> 
> That is what I intend to show with: https://godbolt.org/z/1YjsdY73P
> 
> As far as doing it 'on demand', I definitely see your circular argument here, 
> but I think the is_trivial_v test is UB if we calculate it at `Base' 
> completion.
I'm arguing for checking the constraints at the completion of `Base`, and for 
making `is_trivial_v/sizeof` ill formed in this context.

Your GCC example is a bit 

[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-20 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 446228.
quinnp marked an inline comment as done.
quinnp added a comment.

Addressing review comments. Changing test cases to use `llvm-objdump -t` 
instead of `obj2yaml`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/forwarding-sections-liblto.c
  clang/test/Driver/gold-lto-sections.c
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/LTO/PowerPC/data-sections-aix.ll
  llvm/test/LTO/PowerPC/data-sections-linux.ll

Index: llvm/test/LTO/PowerPC/data-sections-linux.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-linux.ll
@@ -0,0 +1,25 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc64le-unknown-linux-gnu"
+
+@var = global i32 0
+
+; CHECK:  SYMBOL TABLE:
+; CHECK:  .bss.var
+; CHECK-SAME: var
+
+; CHECK-NO-DATA-SECTIONS:  SYMBOL TABLE:
+; CHECK-NO-DATA-SECTIONS:  .bss
+; CHECK-NO-DATA-SECTIONS-NOT:  .var
+; CHECK-NO-DATA-SECTIONS-SAME: var
Index: llvm/test/LTO/PowerPC/data-sections-aix.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-aix.ll
@@ -0,0 +1,25 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc-ibm-aix7.2.0.0"
+
+@var = global i32 0
+
+; CHECK:  SYMBOL TABLE:
+; CHECK:  .data
+; CHECK-NOT:  (csect: .data)
+; CHECK-SAME: var
+
+; CHECK-NO-DATA-SECTIONS:  SYMBOL TABLE:
+; CHECK-NO-DATA-SECTIONS:  .data (csect: .data)
+; CHECK-NO-DATA-SECTIONS-SAME: var
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/ParallelCG.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/Config/config.h"
@@ -344,6 +345,11 @@
   Config.CPU = "cyclone";
   }
 
+  // If data-sections is not explicitly set or unset, set data-sections by
+  // default to match the behaviour of lld and gold plugin.
+  if (!codegen::getExplicitDataSections())
+Config.Options.DataSections = true;
+
   TargetMach = createTargetMachine();
   assert(TargetMach && "Unable to create target machine");
 
Index: clang/test/Driver/gold-lto-sections.c
===
--- clang/test/Driver/gold-lto-sections.c
+++ clang/test/Driver/gold-lto-sections.c
@@ -4,5 +4,5 @@
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: -ffunction-sections -fdata-sections \
 // RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"
+// CHECK: "-plugin-opt=-function-sections=1"
+// CHECK: "-plugin-opt=-data-sections=1"
Index: clang/test/Driver/forwarding-sections-liblto.c
===
--- /dev/null
+++ clang/test/Driver/forwarding-sections-liblto.c
@@ -0,0 +1,15 @@
+// RUN: touch %t.o
+// RUN: %clang %t.o -### -flto 2>&1 | FileCheck %s
+// RUN: %clang %t.o -### -flto 2>&1 -ffunction-sections -fdata-sections | \
+// RUN:   FileCheck %s --check-prefix=CHECK-SECTIONS
+// RUN: %clang %t.o -### -flto 2>&1 -fno-function-sections -fno-data-sections \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-SECTIONS
+
+// CHECK-NOT: "-plugin-opt=-function-sections=1"
+// CHECK-NOT: "-plugin-opt=-function-sections=0"
+// CHECK-NOT: "-plugin-opt=-data-sections=1"
+// CHECK-NOT: "-plugin-opt=-data-sections=0"
+// CHECK-SECTIONS: "-plugin-opt=-function-sections=1"
+// CHECK-SECTIONS: "-plugin-opt=-data-sections=1"
+// 

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-20 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

In D112374#3665989 , @mizvekov wrote:

> If anyone wants to take a look at the new changes to lldb tests, be my guest. 
> Otherwise I will try to land this again soon. It might well be that we figure 
> out some other in-tree user is affected, but I'd rather do that sooner than 
> later.

Please allow @teemperor some time to take a look at the llvm changes before 
landing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:17899
+  ConstraintSatisfaction Satisfaction;
+  if (S.CheckFunctionConstraints(Method, Satisfaction))
+SatisfactionStatus.push_back(false);

royjacobson wrote:
> erichkeane wrote:
> > cor3ntin wrote:
> > > erichkeane wrote:
> > > > cor3ntin wrote:
> > > > > royjacobson wrote:
> > > > > > erichkeane wrote:
> > > > > > > This seems problematic, doesn't it?  Checking this constraint 
> > > > > > > will (once I figure out how to get deferred instantiation to 
> > > > > > > work) cause instantiation, which can cause issues with incomplete 
> > > > > > > types/CRTP/etc.
> > > > > > > 
> > > > > > > I think the result is that we cannot 'calculate' this until it is 
> > > > > > > queried, else we will cause incorrect errors.
> > > > > > Making this queried on demand is a relatively big change to how we 
> > > > > > handle type triviality, so I want to be sure we actually need to do 
> > > > > > this to be conformant.
> > > > > > 
> > > > > > When I started working on this I checked what GCC does and it 
> > > > > > instantiates those constraints during class completion as well. For 
> > > > > > example this CRTP case: https://godbolt.org/z/EdoYf96zq. MSVC seem 
> > > > > > to do it as well.
> > > > > > 
> > > > > > So maybe it's OK to check the constraints of SMFs specifically?
> > > > > > 
> > > > > I think this is done on completeness already in this patch, unless i 
> > > > > misunderstood the code.
> > > > > I don't think doing it on demand is a great direction, as this does 
> > > > > not only affect type traits but also code gen, etc. It would create 
> > > > > instanciations in unexpected places. wouldn't it.
> > > > > Does the standard has wording suggesting it should be done later than 
> > > > > on type completeness?
> > > > The problem, at least for the deferred concepts, is that it breaks in 
> > > > the CRTP as required to implement ranges.  So something like this: 
> > > > https://godbolt.org/z/hPqrcqhx5 breaks.
> > > > 
> > > > I'm currently working to 'fix' that, so if this patch causes us to 
> > > > 'check' constraints early, it'll go back to breaking that example.  The 
> > > > example that Roy showed seems to show that it is actually checking 
> > > > 'delayed' right now (that is, on demand) in GCC/MSVC.  I don't know of 
> > > > the consequence/standardeeze that causes that though.
> > > Thanks, 
> > > Follow up stupid question then, do we care about the triviality of 
> > > dependant types?
> > > I think doing the check on complete non-dependant types might be a better 
> > > solution than trying to do it lazily on triviality checks?
> > I would think it would be not a problem on non-dependent types.  BUT 
> > concepts are only allowed on templated functions (note not only on 
> > function-templates!) anyway, so I don't think this would be a problem?  
> Erich, I'm a bit confused by your response. I think my example demonstrates 
> that for default constructors (and other SMFs) GCC and MSVC instantiate the 
> constraints on class completion and **not** on demand. This is what I would 
> like to do as well, if we don't have a good reason not to. (For destructors, 
> performing the checks is even explicit in the standard.)
> 
> Not doing this can introduce some REALLY bad edge cases. What does this do if 
> we defer the triviality computation?
> 
> ```c++
> 
> template 
> struct Base {
>   Base() = default;
>   Base() requires (!std::is_trivial_v);
> };
> 
> struct Child : Base { };
> ```
> We defer the computation of the constraints on `Base`, and complete `Child` 
> somehow, but if `Child` is complete then `std::is_trivial_v` should be 
> well-formed, right? But we get a logical contradiction instead.
> 
> 
>Erich, I'm a bit confused by your response
It is entirely possible we're talking past eachother, or misunderstanding 
eachothers examples.  I'm totally open to that being part of this issue.

In that example, if we calculate the triviality at '`Base` Class completion', 
`Child` is not yet complete, right?  So the is_trivial_v would be UB.  If you 
instead require `sizeof(T)`, we typically give a diagnostic.

In this case, you'd at MINIMUM have to wait to calculate the requires-clause 
until after `Child` is complete.  And it isn't clear to me that we're delaying 
it until then.

That is what I intend to show with: https://godbolt.org/z/1YjsdY73P

As far as doing it 'on demand', I definitely see your circular argument here, 
but I think the is_trivial_v test is UB if we calculate it at `Base' completion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128619

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


[PATCH] D130190: [Driver] Error for -gsplit-dwarf with RISC-V linker relaxation

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: compnerd, jrtc27, kito.cheng.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead.
Herald added a project: clang.

-gsplit-dwarf produces a .dwo file which will not be processed by the linker. If
.dwo files contain relocations, they will not be resolved. Therefore the
practice is that .dwo files do not contain relocations. Since features like
address ranges need relocations and cannot be resolved without linking, split
DWARF is foundamentally incompatible with linker relaxation.

Currently there is a difficult-to-read MC error with -gsplit-dwarf with RISC-V 
-mrelax

  % clang --target=riscv64-linux-gnu -g -gsplit-dwarf -c a.c
  error: A dwo section may not contain relocations

Report a driver error instead.

Close https://github.com/llvm/llvm-project/issues/56642


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130190

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -35,3 +35,10 @@
 // RUN: not %clang -cc1 -triple riscv64-unknown-elf -target-feature +e 2>&1 | 
FileCheck %s -check-prefix=RV64-WITH-E
 
 // RV64-WITH-E: error: invalid feature combination: standard user-level 
extension 'e' requires 'rv32'
+
+// RUN: not %clang -c --target=riscv64-linux-gnu -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: not %clang -c --target=riscv64 -gsplit-dwarf=single %s 2>&1 | 
FileCheck %s --check-prefix=ERR-SPLIT-DWARF
+// RUN: %clang -### -c --target=riscv64 -mno-relax -g -gsplit-dwarf %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT-DWARF
+
+// ERR-SPLIT-DWARF: error: -gsplit-dwarf{{.*}} is incompatible with RISC-V 
linker relaxation (-mrelax)
+// SPLIT-DWARF: "-split-dwarf-file"
Index: clang/lib/Driver/ToolChains/Clang.h
===
--- clang/lib/Driver/ToolChains/Clang.h
+++ clang/lib/Driver/ToolChains/Clang.h
@@ -198,6 +198,12 @@
 const char *LinkingOutput) const override;
 };
 
+enum class DwarfFissionKind { None, Split, Single };
+
+DwarfFissionKind getDebugFissionKind(const Driver ,
+ const llvm::opt::ArgList ,
+ llvm::opt::Arg *);
+
 } // end namespace tools
 
 } // end namespace driver
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4051,9 +4051,7 @@
  options::OPT_fno_spell_checking);
 }
 
-enum class DwarfFissionKind { None, Split, Single };
-
-static DwarfFissionKind getDebugFissionKind(const Driver ,
+DwarfFissionKind tools::getDebugFissionKind(const Driver ,
 const ArgList , Arg *) {
   Arg = Args.getLastArg(options::OPT_gsplit_dwarf, 
options::OPT_gsplit_dwarf_EQ,
 options::OPT_gno_split_dwarf);
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "RISCV.h"
+#include "../Clang.h"
 #include "ToolChains/CommonArgs.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Driver/Driver.h"
@@ -137,10 +138,15 @@
 Features.push_back("+reserve-x31");
 
   // -mrelax is default, unless -mno-relax is specified.
-  if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))
+  if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) {
 Features.push_back("+relax");
-  else
+Arg *A;
+if (getDebugFissionKind(D, Args, A) != DwarfFissionKind::None)
+  D.Diag(clang::diag::err_drv_riscv_incompatible_with_linker_relaxation)
+  << A->getAsString(Args);
+  } else {
 Features.push_back("-relax");
+  }
 
   // GCC Compatibility: -mno-save-restore is default, unless -msave-restore is
   // specified.
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ 

[PATCH] D129654: [Clang][Driver] Fix include paths for `--sysroot /` on OpenBSD/FreeBSD

2022-07-20 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan updated this revision to Diff 446223.
egorzhdan added a comment.

- Add a test for OpenBSD
- Modify existing test file instead of adding a new file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129654

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/test/Driver/Inputs/basic_freebsd_libcxx_tree/usr/bin/.keep
  clang/test/Driver/Inputs/basic_freebsd_libcxx_tree/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_freebsd_libcxx_tree/usr/lib/.keep
  clang/test/Driver/Inputs/basic_openbsd_libcxx_tree/usr/bin/.keep
  clang/test/Driver/Inputs/basic_openbsd_libcxx_tree/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_openbsd_libcxx_tree/usr/lib/.keep
  clang/test/Driver/freebsd.cpp
  clang/test/Driver/openbsd.cpp

Index: clang/test/Driver/openbsd.cpp
===
--- clang/test/Driver/openbsd.cpp
+++ clang/test/Driver/openbsd.cpp
@@ -19,3 +19,23 @@
 // RUN: %clangxx %s -### -pg -o %t.o -target arm-unknown-openbsd 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-CXX %s
 // CHECK-PG-CXX: "-lc++_p" "-lc++abi_p" "-lpthread_p" "-lm_p"
+
+// Test include paths with a sysroot.
+// RUN: %clangxx %s -### -fsyntax-only 2>&1 \
+// RUN: --target=amd64-pc-openbsd \
+// RUN: --sysroot=%S/Inputs/basic_openbsd_libcxx_tree \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-SYSROOT %s
+// CHECK-LIBCXX-SYSROOT: "-cc1"
+// CHECK-LIBCXX-SYSROOT-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LIBCXX-SYSROOT-SAME: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+
+// Test include paths when the sysroot path ends with `/`.
+// RUN: %clangxx %s -### -fsyntax-only 2>&1 \
+// RUN: --target=amd64-pc-openbsd \
+// RUN: --sysroot=%S/Inputs/basic_openbsd_libcxx_tree/ \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-SYSROOT-SLASH %s
+// CHECK-LIBCXX-SYSROOT-SLASH: "-cc1"
+// CHECK-LIBCXX-SYSROOT-SLASH-SAME: "-isysroot" "[[SYSROOT:[^"]+/]]"
+// CHECK-LIBCXX-SYSROOT-SLASH-SAME: "-internal-isystem" "[[SYSROOT]]usr/include/c++/v1"
Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -20,3 +20,23 @@
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
+
+// Test include paths with a sysroot.
+// RUN: %clangxx %s -### -fsyntax-only 2>&1 \
+// RUN: --target=amd64-unknown-freebsd \
+// RUN: --sysroot=%S/Inputs/basic_openbsd_libcxx_tree \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-SYSROOT %s
+// CHECK-LIBCXX-SYSROOT: "-cc1"
+// CHECK-LIBCXX-SYSROOT-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LIBCXX-SYSROOT-SAME: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+
+// Test include paths when the sysroot path ends with `/`.
+// RUN: %clangxx %s -### -fsyntax-only 2>&1 \
+// RUN: --target=amd64-unknown-freebsd \
+// RUN: --sysroot=%S/Inputs/basic_openbsd_libcxx_tree/ \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-SYSROOT-SLASH %s
+// CHECK-LIBCXX-SYSROOT-SLASH: "-cc1"
+// CHECK-LIBCXX-SYSROOT-SLASH-SAME: "-isysroot" "[[SYSROOT:[^"]+/]]"
+// CHECK-LIBCXX-SYSROOT-SLASH-SAME: "-internal-isystem" "[[SYSROOT]]usr/include/c++/v1"
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -284,7 +284,7 @@
 OpenBSD::OpenBSD(const Driver , const llvm::Triple ,
  const ArgList )
 : Generic_ELF(D, Triple, Args) {
-  getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
+  getFilePaths().push_back(concat(getDriver().SysRoot, "/usr/lib"));
 }
 
 void OpenBSD::AddClangSystemIncludeArgs(
@@ -317,13 +317,14 @@
 return;
   }
 
-  addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/include");
+  addExternCSystemInclude(DriverArgs, CC1Args,
+  concat(D.SysRoot, "/usr/include"));
 }
 
 void OpenBSD::addLibCxxIncludePaths(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const {
   addSystemInclude(DriverArgs, CC1Args,
-   getDriver().SysRoot + "/usr/include/c++/v1");
+   concat(getDriver().SysRoot, "/usr/include/c++/v1"));
 }
 
 void OpenBSD::AddCXXStdlibLibArgs(const ArgList ,
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -389,10 +389,10 @@
   // back to '/usr/lib' if it 

[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-20 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:17899
+  ConstraintSatisfaction Satisfaction;
+  if (S.CheckFunctionConstraints(Method, Satisfaction))
+SatisfactionStatus.push_back(false);

erichkeane wrote:
> cor3ntin wrote:
> > erichkeane wrote:
> > > cor3ntin wrote:
> > > > royjacobson wrote:
> > > > > erichkeane wrote:
> > > > > > This seems problematic, doesn't it?  Checking this constraint will 
> > > > > > (once I figure out how to get deferred instantiation to work) cause 
> > > > > > instantiation, which can cause issues with incomplete 
> > > > > > types/CRTP/etc.
> > > > > > 
> > > > > > I think the result is that we cannot 'calculate' this until it is 
> > > > > > queried, else we will cause incorrect errors.
> > > > > Making this queried on demand is a relatively big change to how we 
> > > > > handle type triviality, so I want to be sure we actually need to do 
> > > > > this to be conformant.
> > > > > 
> > > > > When I started working on this I checked what GCC does and it 
> > > > > instantiates those constraints during class completion as well. For 
> > > > > example this CRTP case: https://godbolt.org/z/EdoYf96zq. MSVC seem to 
> > > > > do it as well.
> > > > > 
> > > > > So maybe it's OK to check the constraints of SMFs specifically?
> > > > > 
> > > > I think this is done on completeness already in this patch, unless i 
> > > > misunderstood the code.
> > > > I don't think doing it on demand is a great direction, as this does not 
> > > > only affect type traits but also code gen, etc. It would create 
> > > > instanciations in unexpected places. wouldn't it.
> > > > Does the standard has wording suggesting it should be done later than 
> > > > on type completeness?
> > > The problem, at least for the deferred concepts, is that it breaks in the 
> > > CRTP as required to implement ranges.  So something like this: 
> > > https://godbolt.org/z/hPqrcqhx5 breaks.
> > > 
> > > I'm currently working to 'fix' that, so if this patch causes us to 
> > > 'check' constraints early, it'll go back to breaking that example.  The 
> > > example that Roy showed seems to show that it is actually checking 
> > > 'delayed' right now (that is, on demand) in GCC/MSVC.  I don't know of 
> > > the consequence/standardeeze that causes that though.
> > Thanks, 
> > Follow up stupid question then, do we care about the triviality of 
> > dependant types?
> > I think doing the check on complete non-dependant types might be a better 
> > solution than trying to do it lazily on triviality checks?
> I would think it would be not a problem on non-dependent types.  BUT concepts 
> are only allowed on templated functions (note not only on 
> function-templates!) anyway, so I don't think this would be a problem?  
Erich, I'm a bit confused by your response. I think my example demonstrates 
that for default constructors (and other SMFs) GCC and MSVC instantiate the 
constraints on class completion and **not** on demand. This is what I would 
like to do as well, if we don't have a good reason not to. (For destructors, 
performing the checks is even explicit in the standard.)

Not doing this can introduce some REALLY bad edge cases. What does this do if 
we defer the triviality computation?

```c++

template 
struct Base {
  Base() = default;
  Base() requires (!std::is_trivial_v);
};

struct Child : Base { };
```
We defer the computation of the constraints on `Base`, and complete `Child` 
somehow, but if `Child` is complete then `std::is_trivial_v` should be 
well-formed, right? But we get a logical contradiction instead.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128619

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


[PATCH] D130181: [clang-tidy] Add readability-use-early-exits check

2022-07-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 446219.
njames93 added a comment.

Added logic to infer WrapInBraces option if unspecified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130181

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/use-early-exits.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-braces.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
@@ -0,0 +1,164 @@
+// RUN: %check_clang_tidy %s readability-use-early-exits -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2}}"
+
+// Run the check with the braces around statements check also enabled, but 
+// ShortStatementLines is set so that we shouldn't add braces.
+// RUN: %check_clang_tidy %s readability-use-early-exits,readability-braces-around-statements -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2, \
+// RUN:readability-braces-around-statements.ShortStatementLines: 2}}"
+
+// Just to hit the threshold
+void padLines();
+
+void nomralFunc(int *A) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (A) {
+*A = 10;
+  }
+  //   CHECK-FIXES: if (!A)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *A = 10;
+}
+
+void funcWithTrailing(int *B) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (B) {
+*B = 10;
+  }
+  return;
+  ;
+  //   CHECK-FIXES: if (!B)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *B = 10;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: return;
+  //  CHECK-FIXES-NEXT: ;
+}
+
+void normal(int A, int B) {
+  
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A == B) {
+  padLines();
+}
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A != B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  //  CHECK-FIXES-NEXT: }
+
+  // Eat continue and empty nulls
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A != B) {
+  padLines();
+}
+continue;
+;
+continue;
+  } 
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT:   ;
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: }
+}
+
+void toShort(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+  }
+}
+
+void hasElse(int A, int B) {
+  while (true) {
+if (A == B) {
+
+} else {
+}
+  }
+}
+
+void hasTrailingStmt(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+padLines();
+  }
+}
+
+void nested(int A, int B) {
+  // if (A > B) {
+  // CHECK-MESSAGES: [[@LINE+6]]:5: warning: use early exit
+  // if (B < A) {
+  // CHECK-MESSAGES: [[@LINE+5]]:7: warning: use early exit
+  // if (A == B) {
+  // CHECK-MESSAGES: [[@LINE+4]]:9: warning: use early exit
+  while (true) { // Nested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  }
+}
+  } // EndLoop
+  //   CHECK-FIXES: while (true) { // Nested
+  //  CHECK-FIXES-NEXT: if (A <= B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (B >= A)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: } // EndLoop
+}
+
+void badNested(bool B) {
+  // Ensure check doesn't check for nested `if` if outer `if` has else.
+  while (true) {
+if (B) {
+  if (B) {
+  }
+} else {
+}
+  }
+}
+
+void semiNested(int A, int B) {
+  // CHECK-MESSAGES: [[@LINE+2]]:5: warning: use early exit
+  while (true) { // SemiNested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  } else {
+  }
+}
+  }
+  //   CHECK-FIXES: while (true) { // SemiNested
+  //  

[PATCH] D130161: Added command-line options to exclude functions from function instrumentation output.

2022-07-20 Thread Jacques Légaré via Phabricator via cfe-commits
jlegare abandoned this revision.
jlegare added a comment.

I appear to have butchered something in trying to apply a patch. I will revisit 
and resubmit later when I've straightened things out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130161

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-07-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D130096#3666155 , @yaxunl wrote:

> The current patch does not consider HIP/OpenCL compile options, therefore the 
> value of these variables are not correct for OpenCL/HIP. They need to be 
> overridden by the variables with the same name in device libraries by clang 
> through -mlink-builtin-bitcode.
>
> If the patch check HIP/OpenCL compilation options to set the correct value 
> for these variables, then it does not need weak linkage.

Is we instead add it to `compiler.used` it should be propagated while staying 
alive for the linker https://godbolt.org/z/MG5n1MWWj. The downside is that this 
symbol will not be removed and a symbol to it will live in the binary. The 
symbol will have weak binding, so it won't cause any linker errors. But it's a 
little annoying to have things stick around like that. I'm considering making 
this code generation be controlled by a clang driver flag so we could 
potentially change behavior as needed there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-20 Thread Xiang Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa73a84c44753: [HLSL] add -I option for dxc mode. (authored 
by python3kgae).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128462

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/dxc_I.hlsl

Index: clang/test/Driver/dxc_I.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_I.hlsl
@@ -0,0 +1,4 @@
+// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+
+// Make sure -I send to cc1.
+// CHECK:"-I" "test"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3511,6 +3511,7 @@
   types::ID InputType) {
   const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
  options::OPT_D,
+ options::OPT_I,
  options::OPT_S,
  options::OPT_emit_llvm,
  options::OPT_disable_llvm_passes,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -6262,6 +6262,7 @@
   if (IsClCompatMode) {
 // Include CL and Core options.
 IncludedFlagsBitmask |= options::CLOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::CLOption;
@@ -6269,10 +6270,14 @@
   if (IsDXCMode()) {
 // Include DXC and Core options.
 IncludedFlagsBitmask |= options::DXCOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::DXCOption;
   }
+  if (!IsClCompatMode && !IsDXCMode())
+ExcludedFlagsBitmask |= options::CLDXCOption;
+
   return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -53,6 +53,10 @@
 // are made available when the driver is running in DXC compatibility mode.
 def DXCOption : OptionFlag;
 
+// CLDXCOption - This is a cl.exe/dxc.exe compatibility option. Options with this flag
+// are made available when the driver is running in CL/DXC compatibility mode.
+def CLDXCOption : OptionFlag;
+
 // NoDriverOption - This option should not be accepted by the driver.
 def NoDriverOption : OptionFlag;
 
@@ -6355,7 +6359,7 @@
 // clang-cl Options
 //===--===//
 
-def cl_Group : OptionGroup<"">, Flags<[CLOption]>,
+def cl_Group : OptionGroup<"">, Flags<[CLDXCOption]>,
   HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
 
 def cl_compile_Group : OptionGroup<"">,
@@ -6385,6 +6389,9 @@
 class CLJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>;
 
+class CLDXCJoinedOrSeparate : Option<["/", "-"], name,
+  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, NoXarchOption]>;
+
 class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group,
   Flags<[CLOption, NoXarchOption]>;
@@ -6462,7 +6469,7 @@
 def _SLASH_HELP : CLFlag<"HELP">, Alias;
 def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias,
   HelpText<"Create hotpatchable image">;
-def _SLASH_I : CLJoinedOrSeparate<"I">,
+def _SLASH_I : CLDXCJoinedOrSeparate<"I">,
   HelpText<"Add directory to include search path">, MetaVarName<"">,
   Alias;
 def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">,
Index: clang/include/clang/Driver/Options.h
===
--- clang/include/clang/Driver/Options.h
+++ clang/include/clang/Driver/Options.h
@@ -36,7 +36,8 @@
   FC1Option = (1 << 15),
   FlangOnlyOption = (1 << 16),
   DXCOption = (1 << 17),
-  Ignored = (1 << 18),
+  CLDXCOption = (1 << 18),
+  Ignored = (1 << 19),
 };
 
 enum ID {
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -423,6 +423,8 @@
   if (!Opt.hasFlag(driver::options::NoDriverOption)) {
 if (Opt.hasFlag(driver::options::CLOption)) {
   Result |= DM_CL;
+} else if (Opt.hasFlag(driver::options::CLDXCOption)) {
+  

[clang] a73a84c - [HLSL] add -I option for dxc mode.

2022-07-20 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-07-20T11:03:22-07:00
New Revision: a73a84c44753402b33d619035d2c5acec3b04859

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

LOG: [HLSL] add -I option for dxc mode.

A new option -I is added for dxc mode.
It is just alias of existing cc1 -I option.

Reviewed By: beanz

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

Added: 
clang/test/Driver/dxc_I.hlsl

Modified: 
clang-tools-extra/clangd/CompileCommands.cpp
clang/include/clang/Driver/Options.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index 39198d0711998..12aa9dacc2dfe 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -423,6 +423,8 @@ unsigned char getModes(const llvm::opt::Option ) {
   if (!Opt.hasFlag(driver::options::NoDriverOption)) {
 if (Opt.hasFlag(driver::options::CLOption)) {
   Result |= DM_CL;
+} else if (Opt.hasFlag(driver::options::CLDXCOption)) {
+  Result |= DM_CL;
 } else {
   Result |= DM_GCC;
   if (Opt.hasFlag(driver::options::CoreOption)) {

diff  --git a/clang/include/clang/Driver/Options.h 
b/clang/include/clang/Driver/Options.h
index f9b9632ee7cbe..f7ee154b7a7ab 100644
--- a/clang/include/clang/Driver/Options.h
+++ b/clang/include/clang/Driver/Options.h
@@ -36,7 +36,8 @@ enum ClangFlags {
   FC1Option = (1 << 15),
   FlangOnlyOption = (1 << 16),
   DXCOption = (1 << 17),
-  Ignored = (1 << 18),
+  CLDXCOption = (1 << 18),
+  Ignored = (1 << 19),
 };
 
 enum ID {

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 88b675ee8a2cb..3bd3550c9c60f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -53,6 +53,10 @@ def CC1AsOption : OptionFlag;
 // are made available when the driver is running in DXC compatibility mode.
 def DXCOption : OptionFlag;
 
+// CLDXCOption - This is a cl.exe/dxc.exe compatibility option. Options with 
this flag
+// are made available when the driver is running in CL/DXC compatibility mode.
+def CLDXCOption : OptionFlag;
+
 // NoDriverOption - This option should not be accepted by the driver.
 def NoDriverOption : OptionFlag;
 
@@ -6355,7 +6359,7 @@ def defsym : Separate<["-"], "defsym">,
 // clang-cl Options
 
//===--===//
 
-def cl_Group : OptionGroup<"">, Flags<[CLOption]>,
+def cl_Group : OptionGroup<"">, Flags<[CLDXCOption]>,
   HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
 
 def cl_compile_Group : OptionGroup<"">,
@@ -6385,6 +6389,9 @@ class CLIgnoredJoined : Option<["/", "-"], 
name, KIND_JOINED>,
 class CLJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>;
 
+class CLDXCJoinedOrSeparate : Option<["/", "-"], name,
+  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, 
NoXarchOption]>;
+
 class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group,
   Flags<[CLOption, NoXarchOption]>;
@@ -6462,7 +6469,7 @@ def _SLASH_help : CLFlag<"help">, Alias,
 def _SLASH_HELP : CLFlag<"HELP">, Alias;
 def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias,
   HelpText<"Create hotpatchable image">;
-def _SLASH_I : CLJoinedOrSeparate<"I">,
+def _SLASH_I : CLDXCJoinedOrSeparate<"I">,
   HelpText<"Add directory to include search path">, MetaVarName<"">,
   Alias;
 def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index bd2b9a5b39b39..e50fdd61423be 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6262,6 +6262,7 @@ Driver::getIncludeExcludeOptionFlagMasks(bool 
IsClCompatMode) const {
   if (IsClCompatMode) {
 // Include CL and Core options.
 IncludedFlagsBitmask |= options::CLOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::CLOption;
@@ -6269,10 +6270,14 @@ Driver::getIncludeExcludeOptionFlagMasks(bool 
IsClCompatMode) const {
   if (IsDXCMode()) {
 // Include DXC and Core options.
 IncludedFlagsBitmask |= options::DXCOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::DXCOption;
   }
+  if (!IsClCompatMode && !IsDXCMode())
+ExcludedFlagsBitmask |= options::CLDXCOption;
+
   return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
 }
 

diff  --git 

[PATCH] D130123: Extend ptr32 support to be applied on typedef

2022-07-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:7116
+  for (;;) {
+if (const TypedefType *TT = dyn_cast(Desugared)) {
+  Desugared = TT->desugar();

Ariel-Burton wrote:
> rnk wrote:
> > This seems like a good place to use getSingleStepDesugaredType to look 
> > through all type sugar (parens, typedefs, template substitutions, etc).
> > This seems like a good place to use getSingleStepDesugaredType to look 
> > through all type sugar (parens, typedefs, template substitutions, etc).
> 
> I'm not sure what you mean.  Could you expand a little, please?
Clang's AST has lots of "type sugar nodes". These are types which usually don't 
have any semantic meaning, they just carry source location information, like 
whether there was a typedef or extra parens in the type. AttributedType is also 
a type sugar node, so we cannot do a full desugaring here, we have to step 
through each node one at a time to accumulate the attributes.

Your code looks through one kind of type sugar, but this loop should probably 
be generalized to handle all kinds of type sugar. I think 
getSingleStepDesugaredType will do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130123

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


[clang] 7e77d31 - [test] Remove unnecessary -verify-machineinstrs=0

2022-07-20 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-07-20T10:55:54-07:00
New Revision: 7e77d31af75e48e2ac7899026040a66fe601961a

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

LOG: [test] Remove unnecessary -verify-machineinstrs=0

Issue #38784 seems to be fixed and removing these doesn't cause any issues.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
llvm/test/ThinLTO/X86/devirt.ll
llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
llvm/test/ThinLTO/X86/type_test_noindircall.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll 
b/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
index e02b30b392e17..959d89d61ab27 100644
--- a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ b/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
@@ -6,10 +6,8 @@
 
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
 
-; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. 
PR39436.
 ; RUN: llvm-lto2 run -thinlto-distributed-indexes -disable-thinlto-funcattrs=0 
%t.o \
 ; RUN:   -whole-program-visibility \
-; RUN:   -verify-machineinstrs=0 \
 ; RUN:   -o %t2.index \
 ; RUN:   -r=%t.o,test,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \

diff  --git a/llvm/test/ThinLTO/X86/devirt.ll b/llvm/test/ThinLTO/X86/devirt.ll
index cf7d583069437..18bd34840bbfd 100644
--- a/llvm/test/ThinLTO/X86/devirt.ll
+++ b/llvm/test/ThinLTO/X86/devirt.ll
@@ -62,10 +62,8 @@
 ; RUN:   -r=%t2.o,_ZTV1C,px \
 ; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=SKIP
 
-; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. 
PR39436.
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
 ; RUN:   -whole-program-visibility \
-; RUN:   -verify-machineinstrs=0 \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t.o,test,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \

diff  --git a/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll 
b/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
index c416b8f91d532..611be11ff8a7a 100644
--- a/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
+++ b/llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
@@ -21,9 +21,7 @@
 ; Hybrid WPD
 ; Generate split module with summary for hybrid Thin/Regular LTO WPD.
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
-; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. 
PR39436.
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
-; RUN:   -verify-machineinstrs=0 \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t.o,test,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \

diff  --git a/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll 
b/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
index ef752a7d85f23..4451d17709416 100644
--- a/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
+++ b/llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
@@ -22,10 +22,8 @@
 ; Hybrid WPD
 ; Generate split module with summary for hybrid Thin/Regular LTO WPD.
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
-; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. 
PR39436.
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
 ; RUN:   -whole-program-visibility \
-; RUN:   -verify-machineinstrs=0 \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t.o,test,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \
@@ -80,7 +78,6 @@
 
 ; Hybrid WPD
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
-; RUN:   -verify-machineinstrs=0 \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t.o,test,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \

diff  --git a/llvm/test/ThinLTO/X86/type_test_noindircall.ll 
b/llvm/test/ThinLTO/X86/type_test_noindircall.ll
index 3a2badcaea693..2e2f9f8565968 100644
--- a/llvm/test/ThinLTO/X86/type_test_noindircall.ll
+++ b/llvm/test/ThinLTO/X86/type_test_noindircall.ll
@@ -6,10 +6,8 @@
 
 ; RUN: opt -thinlto-bc -o %t.o %s
 
-; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. 
PR39436.
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
 ; RUN:   -whole-program-visibility \
-; RUN:   -verify-machineinstrs=0 \
 ; RUN:  -r=%t.o,_ZTVN12_GLOBAL__N_18RealFileE,px \
 ; RUN:   -o %t2
 ; RUN: llvm-dis %t2.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
@@ -18,7 +16,6 @@
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit=false -o %t3.o %s
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
 ; RUN:   -whole-program-visibility \
-; RUN:   -verify-machineinstrs=0 \
 ; RUN:  -r=%t.o,_ZTVN12_GLOBAL__N_18RealFileE,px \
 ; RUN:   -o %t4
 ; RUN: llvm-dis %t4.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR



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


[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D129536#3663957 , @jdoerfert wrote:

> @tra, unsure about the crash. For me this passes fine (no gpu), is anything 
> missing?

The tests in the patch are running with `-emit-llvm`, so they are not actually 
lowering to NVPTX and that's where the failure happens. 
https://godbolt.org/z/cchaWxrhn




Comment at: clang/lib/Headers/__clang_cuda_intrinsics.h:237-238
 
-inline __device__ unsigned int
-__match64_any_sync(unsigned int mask, unsigned long long value) {
+inline __device__ unsigned int __match64_any_sync(unsigned int mask,
+  unsigned long long value) {
   return __nvvm_match_any_sync_i64(mask, value);

Nit: this change is irrelevant to the patch and can be removed.



Comment at: clang/test/CodeGenCUDA/shuffle_long_long.cu:9
+#undef __CUDA_ARCH__
+#define __CUDA_ARCH__ 300
+

This macro should not be set. If you do need something to be compiled for 
sm_30, you should've specified via `-target-cpu sm_30`.



Comment at: clang/test/CodeGenCUDA/shuffle_long_long.cu:14
+#define warpSize 32
+#include "__clang_cuda_intrinsics.h"
+

Nit: this should be `<...>` as we want the include to be found in compiler's 
include paths.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129536

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


[PATCH] D67025: Add .inl as valid C++ header type

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I agree that this is not suitable in clang, but can be in clangd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67025

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


[PATCH] D130161: Added command-line options to exclude functions from function instrumentation output.

2022-07-20 Thread Jacques Légaré via Phabricator via cfe-commits
jlegare added a comment.

@hans To address your concern about loose matching: I went with this approach 
because it fit my use-case. Do you think that an exact match would be more 
appropriate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130161

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


[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Mostly looks good, with a nit in the test and some suggestion to the summary.

In D129401#3662857 , @quinnp wrote:

>> If this is for the legacy LTO interface, please state so.  `lld/*/LTO.cpp` 
>> sets `c.Options.DataSections = true;` to enable data sections by default.
>
> Hey @MaskRay, I'm not sure what is considered the legacy LTO interface, but 
> this change is to make the `libLTO` codegen match the behaviour of `LTO` used 
> through `lld` and `gold plugin`. Both `lld` and `gold plugin` turn on 
> `data-sections` for `LTO` by default:
>
> - as you mentioned `lld/*/LTO.cpp` sets `c.Options.DataSections = true;` by 
> default.
> - and `llvm/tools/gold/gold-plugin.cpp` sets `Conf.Options.DataSections = 
> SplitSections;` provided that the user did not explicitly set/unset 
> `data-sections` where `SplitSections` is `true` unless `gold plugin` is doing 
> a relocatable link.

There is a legacy LTO interface (see 
llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h) and a resolution-based 
interface.
Change libLTO in "This patch changes libLTO to set data-sections by default." 
to legacy LTO.

> This patch also fixes the forwarding of the clang options -fno-data-sections 
> and -fno-function-sections to libLTO

This sentence can keep using libLTO or LLVMLTO (the library is LLVMLTO per 
llvm/lib/LTO/CMakeLists.txt)




Comment at: llvm/test/LTO/PowerPC/data-sections-linux.ll:9
+; RUN:   %t/no-data-sections.o
+; RUN: obj2yaml %t/default.o | FileCheck --match-full-lines %s
+; RUN: obj2yaml %t/data-sections.o | FileCheck --match-full-lines %s

Using obj2yaml for symbol attributes is overkill and is less readable.

Use `llvm-objdump -t`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

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


[PATCH] D130161: Added command-line options to exclude functions from function instrumentation output.

2022-07-20 Thread Jacques Légaré via Phabricator via cfe-commits
jlegare updated this revision to Diff 446210.
jlegare added a comment.

Addressing review comments.

- Dropped argument to ShouldInstrumentFunction().
- Added file name based exclusion, which had accidentally been left out of 
previous commit.
- Added demangler.
- Applied git clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130161

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp


Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -536,8 +536,7 @@
   // generate tracing for it: at link-time, the function will be gone and the
   // first argument to the __cyg_profile_* function will be unresolvable.
   const FunctionDecl *FDecl = dyn_cast(CurFuncDecl);
-  if (FDecl &&
-  FDecl->isInlined() &&
+  if (FDecl && FDecl->isInlined() &&
   !FDecl->isInlineDefinitionExternallyVisible())
 return false;
 
@@ -563,10 +562,11 @@
 typedef std::vector::const_iterator ExcludedPathIterator;
 
 const std::vector  =
-  CGM.getCodeGenOpts().InstrumentFunctionsExcludedPaths;
+CGM.getCodeGenOpts().InstrumentFunctionsExcludedPaths;
 
 for (ExcludedPathIterator ExcludedPath = ExcludedPaths.begin(),
-   Sentinel = ExcludedPaths.end(); ExcludedPath != Sentinel; 
++ExcludedPath)
+  Sentinel = ExcludedPaths.end();
+ ExcludedPath != Sentinel; ++ExcludedPath)
   if (Path.find(*ExcludedPath) != std::string::npos)
 return false;
   }
@@ -577,12 +577,12 @@
   // is searched to see if any of them is a substring of our (current) function
   // name.
   const std::vector  =
-CGM.getCodeGenOpts().InstrumentFunctionsExcludedFunctions;
+  CGM.getCodeGenOpts().InstrumentFunctionsExcludedFunctions;
 
   std::string MangledName(CurFn->getName());
   std::string DemangledName(llvm::demangle(MangledName));
   for (ExcludedFunctionIterator ExcludedFunction = ExcludedFunctions.begin(),
- Sentinel = ExcludedFunctions.end();
+Sentinel = ExcludedFunctions.end();
ExcludedFunction != Sentinel; ++ExcludedFunction)
 if (DemangledName.find(*ExcludedFunction) != std::string::npos)
   return false;


Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -536,8 +536,7 @@
   // generate tracing for it: at link-time, the function will be gone and the
   // first argument to the __cyg_profile_* function will be unresolvable.
   const FunctionDecl *FDecl = dyn_cast(CurFuncDecl);
-  if (FDecl &&
-  FDecl->isInlined() &&
+  if (FDecl && FDecl->isInlined() &&
   !FDecl->isInlineDefinitionExternallyVisible())
 return false;
 
@@ -563,10 +562,11 @@
 typedef std::vector::const_iterator ExcludedPathIterator;
 
 const std::vector  =
-  CGM.getCodeGenOpts().InstrumentFunctionsExcludedPaths;
+CGM.getCodeGenOpts().InstrumentFunctionsExcludedPaths;
 
 for (ExcludedPathIterator ExcludedPath = ExcludedPaths.begin(),
-   Sentinel = ExcludedPaths.end(); ExcludedPath != Sentinel; ++ExcludedPath)
+  Sentinel = ExcludedPaths.end();
+ ExcludedPath != Sentinel; ++ExcludedPath)
   if (Path.find(*ExcludedPath) != std::string::npos)
 return false;
   }
@@ -577,12 +577,12 @@
   // is searched to see if any of them is a substring of our (current) function
   // name.
   const std::vector  =
-CGM.getCodeGenOpts().InstrumentFunctionsExcludedFunctions;
+  CGM.getCodeGenOpts().InstrumentFunctionsExcludedFunctions;
 
   std::string MangledName(CurFn->getName());
   std::string DemangledName(llvm::demangle(MangledName));
   for (ExcludedFunctionIterator ExcludedFunction = ExcludedFunctions.begin(),
- Sentinel = ExcludedFunctions.end();
+Sentinel = ExcludedFunctions.end();
ExcludedFunction != Sentinel; ++ExcludedFunction)
 if (DemangledName.find(*ExcludedFunction) != std::string::npos)
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67025: Add .inl as valid C++ header type

2022-07-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D67025#3665293 , @aaron.ballman 
wrote:

> this is why we have the `-x` option so that users can specify a specific 
> language mode to use. Is there a reason that option does not suffice for 
> clangd?

One reason is that the most commonly used tools that generate 
`compile_commands.json` files, like CMake, do not create entries for header 
files. Users need to turn to ad-hoc post-processing or third-party tools like 
CompDB  to add entries for header files, to 
even have a place to put the `-x c++header` option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67025

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


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-20 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz 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/D128462/new/

https://reviews.llvm.org/D128462

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


[PATCH] D130181: [clang-tidy] Add readability-use-early-exits check

2022-07-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.cpp:217
+  LineCountThreshold(Options.get("LineCountThreshold", 10U)),
+  WrapInBraces(Options.get("WrapInBraces", false)) {}
+

I have an idea that we could infer this using the 
`readability-braces-around-statements` and its hicpp alias.
If enabled, probe the ShortStatementLines option to infer whether or not that 
check would fire if we make this transformation without using braces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130181

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


  1   2   >