igor.kirillov created this revision. Herald added subscribers: guansong, yaxunl. igor.kirillov requested review of this revision. Herald added a reviewer: jdoerfert. Herald added subscribers: cfe-commits, sstefan1. Herald added a project: clang.
After the changes introduced by D106799 <https://reviews.llvm.org/D106799> it is possible to tag outlined function with both AlwaysInline and NoInline attributes using -fno-inline command line options. This issue is similiar to D107649 <https://reviews.llvm.org/D107649>. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D112645 Files: clang/lib/CodeGen/CGStmtOpenMP.cpp clang/test/OpenMP/parallel_for_noinline.cpp Index: clang/test/OpenMP/parallel_for_noinline.cpp =================================================================== --- /dev/null +++ clang/test/OpenMP/parallel_for_noinline.cpp @@ -0,0 +1,15 @@ +// RUN: %clang -O0 -fopenmp -fno-inline %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0 +// RUN: %clang -O1 -fopenmp -fno-inline %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O1 + +// CHECK-LABEL: define dso_local void @_Z3foov +// CHECK: Function Attrs: +// CHECK-O0-SAME: inline +// CHECK-O0-NOT: awaysinline +// CHECK-O1-SAME: alwaysinline +// CHECK-O1-NOT: noinline +// CHECK-LABEL: define internal void @.omp_outlined +void foo() { + #pragma omp parallel for + for (int i = 0; i < 100; ++i) + ; +} Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -518,8 +518,10 @@ F->setDoesNotRecurse(); // Always inline the outlined function if optimizations are enabled. - if (CGM.getCodeGenOpts().OptimizationLevel != 0) + if (CGM.getCodeGenOpts().OptimizationLevel != 0) { + F->removeFnAttr(llvm::Attribute::NoInline); F->addFnAttr(llvm::Attribute::AlwaysInline); + } // Generate the function. CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,
Index: clang/test/OpenMP/parallel_for_noinline.cpp =================================================================== --- /dev/null +++ clang/test/OpenMP/parallel_for_noinline.cpp @@ -0,0 +1,15 @@ +// RUN: %clang -O0 -fopenmp -fno-inline %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0 +// RUN: %clang -O1 -fopenmp -fno-inline %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O1 + +// CHECK-LABEL: define dso_local void @_Z3foov +// CHECK: Function Attrs: +// CHECK-O0-SAME: inline +// CHECK-O0-NOT: awaysinline +// CHECK-O1-SAME: alwaysinline +// CHECK-O1-NOT: noinline +// CHECK-LABEL: define internal void @.omp_outlined +void foo() { + #pragma omp parallel for + for (int i = 0; i < 100; ++i) + ; +} Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -518,8 +518,10 @@ F->setDoesNotRecurse(); // Always inline the outlined function if optimizations are enabled. - if (CGM.getCodeGenOpts().OptimizationLevel != 0) + if (CGM.getCodeGenOpts().OptimizationLevel != 0) { + F->removeFnAttr(llvm::Attribute::NoInline); F->addFnAttr(llvm::Attribute::AlwaysInline); + } // Generate the function. CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits