Do not use '.' in subfunction names

Certain backends, e.g. NVPTX, do not support '.' in function names. Hence,
we ensure all '.' are replaced by '_' when generating function names for
subfunctions. For the current OpenMP code generation, this is not strictly
necessary, but future uses cases (e.g. GPU offloading) need this issue to be
fixed.

llvm-svn: 246980
This commit is contained in:
Tobias Grosser 2015-09-08 06:22:17 +00:00
parent 2f9aa57927
commit a89dc57b41
11 changed files with 25 additions and 19 deletions

View File

@ -259,7 +259,13 @@ Function *ParallelLoopGenerator::createSubFnDefinition() {
std::vector<Type *> Arguments(1, Builder.getInt8PtrTy()); std::vector<Type *> Arguments(1, Builder.getInt8PtrTy());
FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false); FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false);
Function *SubFn = Function::Create(FT, Function::InternalLinkage, Function *SubFn = Function::Create(FT, Function::InternalLinkage,
F->getName() + ".polly.subfn", M); F->getName() + "_polly_subfn", M);
// Certain backends (e.g., NVPTX) do not support '.'s in function names.
// Hence, we ensure that all '.'s are replaced by '_'s.
std::string FunctionName = SubFn->getName();
std::replace(FunctionName.begin(), FunctionName.end(), '.', '_');
SubFn->setName(FunctionName);
// Do not run any polly pass on the new function. // Do not run any polly pass on the new function.
SubFn->addFnAttr(PollySkipFnAttr); SubFn->addFnAttr(PollySkipFnAttr);

View File

@ -8,7 +8,7 @@
; ;
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
; CHECK: define internal void @foo.polly.subfn ; CHECK: define internal void @foo_polly_subfn
define void @foo(float* %A, float* %B) { define void @foo(float* %A, float* %B) {
bb: bb:

View File

@ -9,7 +9,7 @@
; AST: for (int c0 = 0; c0 <= 1023; c0 += 1) ; AST: for (int c0 = 0; c0 <= 1023; c0 += 1)
; AST: Stmt_for_j(c0); ; AST: Stmt_for_j(c0);
; IR: @single_parallel_loop.polly.subfn ; IR: @single_parallel_loop_polly_subfn
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"

View File

@ -12,7 +12,7 @@
; AST: for (int c0 = 0; c0 < cols; c0 += 1) ; AST: for (int c0 = 0; c0 < cols; c0 += 1)
; AST: Stmt_for_body(c0); ; AST: Stmt_for_body(c0);
; IR: @foo.polly.subfn ; IR: @foo_polly_subfn
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@ -42,7 +42,7 @@ end:
; AST: for (int c0 = 0; c0 < cols; c0 += 1) ; AST: for (int c0 = 0; c0 < cols; c0 += 1)
; AST: Stmt_for_body(c0); ; AST: Stmt_for_body(c0);
; IR: @bar.polly.subfn ; IR: @bar_polly_subfn
define void @bar(i64 %cols, i8* noalias %call) { define void @bar(i64 %cols, i8* noalias %call) {
entry: entry:

View File

@ -32,7 +32,7 @@
; IR-NEXT: store i64 %polly.indvar, i64* %[[R2]] ; IR-NEXT: store i64 %polly.indvar, i64* %[[R2]]
; IR-NEXT: %polly.par.userContext1 = bitcast { i64, i64 }* %polly.par.userContext to i8* ; IR-NEXT: %polly.par.userContext1 = bitcast { i64, i64 }* %polly.par.userContext to i8*
; IR-LABEL: @loop_references_outer_ids.polly.subfn(i8* %polly.par.userContext) ; IR-LABEL: @loop_references_outer_ids_polly_subfn(i8* %polly.par.userContext)
; IR: %polly.par.userContext1 = bitcast i8* %polly.par.userContext to { i64, i64 }* ; IR: %polly.par.userContext1 = bitcast i8* %polly.par.userContext to { i64, i64 }*
; IR-NEXT: %[[R3:[0-9a-z.]+]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* %polly.par.userContext1, i32 0, i32 0 ; IR-NEXT: %[[R3:[0-9a-z.]+]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* %polly.par.userContext1, i32 0, i32 0
; IR-NEXT: %[[R4:[0-9a-z.]+]] = load i64, i64* %[[R3]] ; IR-NEXT: %[[R4:[0-9a-z.]+]] = load i64, i64* %[[R3]]

View File

@ -1,6 +1,6 @@
; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-codegen -S -verify-dom-info < %s | FileCheck %s -check-prefix=IR ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-codegen -S -verify-dom-info < %s | FileCheck %s -check-prefix=IR
; IR: @foo.polly.subfn ; IR: @foo_polly_subfn
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
define void @foo(i32 %sendcount, i8* %recvbuf) { define void @foo(i32 %sendcount, i8* %recvbuf) {

View File

@ -17,8 +17,8 @@
; AST-NEXT: for (int c0 = 0; c0 <= p_0 + p_2; c0 += 1) ; AST-NEXT: for (int c0 = 0; c0 <= p_0 + p_2; c0 += 1)
; AST-NEXT: Stmt_while_body(c0); ; AST-NEXT: Stmt_while_body(c0);
; IR: @update_model.polly.subfn ; IR: @update_model_polly_subfn
; IR: @update_model.polly.subfn.1 ; IR: @update_model_polly_subfn_1
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -36,14 +36,14 @@
; IR-NEXT: %0 = bitcast {}* %polly.par.userContext to i8* ; IR-NEXT: %0 = bitcast {}* %polly.par.userContext to i8*
; IR-NEXT: call void @llvm.lifetime.start(i64 0, i8* %0) ; IR-NEXT: call void @llvm.lifetime.start(i64 0, i8* %0)
; IR-NEXT: %polly.par.userContext1 = bitcast {}* %polly.par.userContext to i8* ; IR-NEXT: %polly.par.userContext1 = bitcast {}* %polly.par.userContext to i8*
; IR-NEXT: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop.polly.subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 1) ; IR-NEXT: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop_polly_subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 1)
; IR-NEXT: call void @single_parallel_loop.polly.subfn(i8* %polly.par.userContext1) ; IR-NEXT: call void @single_parallel_loop_polly_subfn(i8* %polly.par.userContext1)
; IR-NEXT: call void @GOMP_parallel_end() ; IR-NEXT: call void @GOMP_parallel_end()
; IR-NEXT: %1 = bitcast {}* %polly.par.userContext to i8* ; IR-NEXT: %1 = bitcast {}* %polly.par.userContext to i8*
; IR-NEXT: call void @llvm.lifetime.end(i64 8, i8* %1) ; IR-NEXT: call void @llvm.lifetime.end(i64 8, i8* %1)
; IR-NEXT: br label %polly.merge_new_and_old ; IR-NEXT: br label %polly.merge_new_and_old
; IR: define internal void @single_parallel_loop.polly.subfn(i8* %polly.par.userContext) #2 ; IR: define internal void @single_parallel_loop_polly_subfn(i8* %polly.par.userContext) #2
; IR-LABEL: polly.par.setup: ; IR-LABEL: polly.par.setup:
; IR-NEXT: %polly.par.LBPtr = alloca i64 ; IR-NEXT: %polly.par.LBPtr = alloca i64
; IR-NEXT: %polly.par.UBPtr = alloca i64 ; IR-NEXT: %polly.par.UBPtr = alloca i64
@ -85,7 +85,7 @@
; IR: attributes #2 = { "polly.skip.fn" } ; IR: attributes #2 = { "polly.skip.fn" }
; IR-STRIDE4: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop.polly.subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 4) ; IR-STRIDE4: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop_polly_subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 4)
; IR-STRIDE4: add nsw i64 %polly.indvar, 3 ; IR-STRIDE4: add nsw i64 %polly.indvar, 3
; IR-STRIDE4: %polly.indvar_next = add nsw i64 %polly.indvar, 4 ; IR-STRIDE4: %polly.indvar_next = add nsw i64 %polly.indvar, 4
; IR-STRIDE4 %polly.adjust_ub = sub i64 %polly.par.UBAdjusted, 4 ; IR-STRIDE4 %polly.adjust_ub = sub i64 %polly.par.UBAdjusted, 4

View File

@ -15,7 +15,7 @@
; AST: for (int c0 = 0; c0 <= 1023; c0 += 1) ; AST: for (int c0 = 0; c0 <= 1023; c0 += 1)
; AST: Stmt_S(c0); ; AST: Stmt_S(c0);
; IR: @single_parallel_loop.polly.subfn ; IR: @single_parallel_loop_polly_subfn
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
define void @single_parallel_loop(float** %A) nounwind { define void @single_parallel_loop(float** %A) nounwind {

View File

@ -15,8 +15,8 @@
; AST: for (int c0 = 0; c0 <= p_0 + p_2; c0 += 1) ; AST: for (int c0 = 0; c0 <= p_0 + p_2; c0 += 1)
; AST: Stmt_for_body35(c0); ; AST: Stmt_for_body35(c0);
; IR: @foo.polly.subfn ; IR: @foo_polly_subfn
; IR: @foo.polly.subfn.1 ; IR: @foo_polly_subfn_1
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -2,9 +2,9 @@
; RUN: opt %loadPolly -polly-detect-unprofitable -polly-codegen -polly-parallel -polly-num-threads=1 -S < %s | FileCheck %s --check-prefix=ONE ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-codegen -polly-parallel -polly-num-threads=1 -S < %s | FileCheck %s --check-prefix=ONE
; RUN: opt %loadPolly -polly-detect-unprofitable -polly-codegen -polly-parallel -polly-num-threads=4 -S < %s | FileCheck %s --check-prefix=FOUR ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-codegen -polly-parallel -polly-num-threads=4 -S < %s | FileCheck %s --check-prefix=FOUR
; ;
; AUTO: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd.polly.subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 0, i64 0, i64 1024, i64 1) ; AUTO: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 0, i64 0, i64 1024, i64 1)
; ONE: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd.polly.subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 1, i64 0, i64 1024, i64 1) ; ONE: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 1, i64 0, i64 1024, i64 1)
; FOUR: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd.polly.subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 4, i64 0, i64 1024, i64 1) ; FOUR: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 4, i64 0, i64 1024, i64 1)
; ;
; void jd(int *A) { ; void jd(int *A) {
; for (int i = 0; i < 1024; i++) ; for (int i = 0; i < 1024; i++)