Revert "[OPENMP]Fix PR47621: Variable used by task inside a template function is not made firstprivate by default"
This reverts commit d1419c9fda to fix the
buffer overflow detected by address sanitiizer.
			
			
This commit is contained in:
		
							parent
							
								
									29ec5901c9
								
							
						
					
					
						commit
						cde7d90cc7
					
				| 
						 | 
					@ -159,7 +159,6 @@ private:
 | 
				
			||||||
    OpenMPDirectiveKind Directive = OMPD_unknown;
 | 
					    OpenMPDirectiveKind Directive = OMPD_unknown;
 | 
				
			||||||
    DeclarationNameInfo DirectiveName;
 | 
					    DeclarationNameInfo DirectiveName;
 | 
				
			||||||
    Scope *CurScope = nullptr;
 | 
					    Scope *CurScope = nullptr;
 | 
				
			||||||
    DeclContext *Context = nullptr;
 | 
					 | 
				
			||||||
    SourceLocation ConstructLoc;
 | 
					    SourceLocation ConstructLoc;
 | 
				
			||||||
    /// Set of 'depend' clauses with 'sink|source' dependence kind. Required to
 | 
					    /// Set of 'depend' clauses with 'sink|source' dependence kind. Required to
 | 
				
			||||||
    /// get the data (loop counters etc.) about enclosing loop-based construct.
 | 
					    /// get the data (loop counters etc.) about enclosing loop-based construct.
 | 
				
			||||||
| 
						 | 
					@ -919,7 +918,6 @@ public:
 | 
				
			||||||
    const SharingMapTy *Top = getTopOfStackOrNull();
 | 
					    const SharingMapTy *Top = getTopOfStackOrNull();
 | 
				
			||||||
    return Top ? Top->CurScope : nullptr;
 | 
					    return Top ? Top->CurScope : nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  void setContext(DeclContext *DC) { getTopOfStack().Context = DC; }
 | 
					 | 
				
			||||||
  SourceLocation getConstructLoc() const {
 | 
					  SourceLocation getConstructLoc() const {
 | 
				
			||||||
    const SharingMapTy *Top = getTopOfStackOrNull();
 | 
					    const SharingMapTy *Top = getTopOfStackOrNull();
 | 
				
			||||||
    return Top ? Top->ConstructLoc : SourceLocation();
 | 
					    return Top ? Top->ConstructLoc : SourceLocation();
 | 
				
			||||||
| 
						 | 
					@ -1533,17 +1531,11 @@ bool DSAStackTy::isOpenMPLocal(VarDecl *D, const_iterator I) const {
 | 
				
			||||||
  for (const_iterator E = end(); I != E; ++I) {
 | 
					  for (const_iterator E = end(); I != E; ++I) {
 | 
				
			||||||
    if (isImplicitOrExplicitTaskingRegion(I->Directive) ||
 | 
					    if (isImplicitOrExplicitTaskingRegion(I->Directive) ||
 | 
				
			||||||
        isOpenMPTargetExecutionDirective(I->Directive)) {
 | 
					        isOpenMPTargetExecutionDirective(I->Directive)) {
 | 
				
			||||||
      if (I->CurScope) {
 | 
					      Scope *TopScope = I->CurScope ? I->CurScope->getParent() : nullptr;
 | 
				
			||||||
        Scope *TopScope = I->CurScope->getParent();
 | 
					      Scope *CurScope = getCurScope();
 | 
				
			||||||
        Scope *CurScope = getCurScope();
 | 
					      while (CurScope && CurScope != TopScope && !CurScope->isDeclScope(D))
 | 
				
			||||||
        while (CurScope && CurScope != TopScope && !CurScope->isDeclScope(D))
 | 
					        CurScope = CurScope->getParent();
 | 
				
			||||||
          CurScope = CurScope->getParent();
 | 
					      return CurScope != TopScope;
 | 
				
			||||||
        return CurScope != TopScope;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      for (DeclContext *DC = D->getDeclContext(); DC; DC = DC->getParent())
 | 
					 | 
				
			||||||
        if (I->Context == DC)
 | 
					 | 
				
			||||||
          return true;
 | 
					 | 
				
			||||||
      return false;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return false;
 | 
					  return false;
 | 
				
			||||||
| 
						 | 
					@ -4156,7 +4148,6 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
 | 
				
			||||||
  default:
 | 
					  default:
 | 
				
			||||||
    llvm_unreachable("Unknown OpenMP directive");
 | 
					    llvm_unreachable("Unknown OpenMP directive");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  DSAStack->setContext(CurContext);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int Sema::getNumberOfConstructScopes(unsigned Level) const {
 | 
					int Sema::getNumberOfConstructScopes(unsigned Level) const {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 | 
					// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 | 
				
			||||||
// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
 | 
					// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
 | 
				
			||||||
// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
 | 
					// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
 | 
				
			||||||
// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
 | 
					// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
 | 
				
			||||||
// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fexceptions -fcxx-exceptions -aux-triple powerpc64le-unknown-unknown -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
 | 
					// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fexceptions -fcxx-exceptions -aux-triple powerpc64le-unknown-unknown -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
 | 
				
			||||||
// expected-no-diagnostics
 | 
					// expected-no-diagnostics
 | 
				
			||||||
#ifndef HEADER
 | 
					#ifndef HEADER
 | 
				
			||||||
#define HEADER
 | 
					#define HEADER
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -389,49 +389,4 @@ struct S1 {
 | 
				
			||||||
// CHECK-LABEL: taskinit
 | 
					// CHECK-LABEL: taskinit
 | 
				
			||||||
// CHECK: call i8* @__kmpc_omp_task_alloc(
 | 
					// CHECK: call i8* @__kmpc_omp_task_alloc(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <typename T = void>
 | 
					 | 
				
			||||||
void foobar() {
 | 
					 | 
				
			||||||
  float a;
 | 
					 | 
				
			||||||
#pragma omp parallel
 | 
					 | 
				
			||||||
#pragma omp single
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    double b;
 | 
					 | 
				
			||||||
#pragma omp task
 | 
					 | 
				
			||||||
    a += b;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// CHECK: define void @{{.+}}xxxx{{.+}}()
 | 
					 | 
				
			||||||
void xxxx() {
 | 
					 | 
				
			||||||
  // CHECK: call void @{{.+}}foobar{{.+}}()
 | 
					 | 
				
			||||||
  foobar();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
// CHECK: define {{.*}}void @{{.+}}foobar{{.+}}()
 | 
					 | 
				
			||||||
// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, float*)* [[PAR_OUTLINED:@.+]] to void (i32*, i32*, ...)*), float* %{{.+}})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// CHECK: define internal void [[PAR_OUTLINED]](i32* {{.+}}, i32* {{.+}}, float* {{.*}}[[A_ADDR:%.+]])
 | 
					 | 
				
			||||||
// UNTIEDRT: [[A_ADDR_REF:%.+]] = alloca float*,
 | 
					 | 
				
			||||||
// CHECK: [[B_ADDR:%.+]] = alloca double,
 | 
					 | 
				
			||||||
// UNTIEDRT: [[A_ADDR:%.+]] = load float*, float** [[A_ADDR_REF]],
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Copy `a` to the list of shared variables
 | 
					 | 
				
			||||||
// CHECK: [[SHARED_A:%.+]] = getelementptr inbounds %{{.+}}, [[SHAREDS_TY:%.+]]* [[SHAREDS:%.+]], i32 0, i32 0
 | 
					 | 
				
			||||||
// CHECK: store float* [[A_ADDR]], float** [[SHARED_A]],
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Allocate task.
 | 
					 | 
				
			||||||
// CHECK: [[RES:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* {{.+}}, i32 {{.+}}, i32 1, i64 48, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[T_TASK_TY:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
 | 
					 | 
				
			||||||
// CHECK: [[TD:%.+]] = bitcast i8* [[RES]] to [[T_TASK_TY]]*
 | 
					 | 
				
			||||||
// Copy shared vars.
 | 
					 | 
				
			||||||
// CHECK: [[TD_TASK:%.+]] = getelementptr inbounds [[T_TASK_TY]], [[T_TASK_TY]]* [[TD]], i32 0, i32 0
 | 
					 | 
				
			||||||
// CHECK: [[TD_TASK_SHARES_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[TD_TASK]], i32 0, i32 0
 | 
					 | 
				
			||||||
// CHECK: [[TD_TASK_SHARES:%.+]] = load i8*, i8** [[TD_TASK_SHARES_REF]],
 | 
					 | 
				
			||||||
// CHECK: [[SHAREDS_BC:%.+]] = bitcast [[SHAREDS_TY]]* [[SHAREDS]] to i8*
 | 
					 | 
				
			||||||
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[TD_TASK_SHARES]], i8* align 8 [[SHAREDS_BC]], i64 8, i1 false)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Copy firstprivate value of `b`.
 | 
					 | 
				
			||||||
// CHECK: [[TD_TASK_PRIVS:%.+]] = getelementptr inbounds [[T_TASK_TY]], [[T_TASK_TY]]* [[TD]], i32 0, i32 1
 | 
					 | 
				
			||||||
// CHECK: [[TD_TASK_PRIVS_B:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[TD_TASK_PRIVS]], i32 0, i32 0
 | 
					 | 
				
			||||||
// CHECK: [[B_VAL:%.+]] = load double, double* [[B_ADDR]],
 | 
					 | 
				
			||||||
// CHECK: store double [[B_VAL]], double* [[TD_TASK_PRIVS_B]],
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue