forked from OSchip/llvm-project
[OPENMP]Use the attributes for dso locality when building for device.
Currently, we ignore all dso locality attributes/info when building for the device and thus all symblos are externally visible and can be preemted at the runtime. It may lead to incorrect results. We need to follow the same logic, compiler uses for static/pie builds. llvm-svn: 361283
This commit is contained in:
parent
c1b6b9a177
commit
6b21c4a4ee
|
@ -798,7 +798,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
|
||||||
const auto &CGOpts = CGM.getCodeGenOpts();
|
const auto &CGOpts = CGM.getCodeGenOpts();
|
||||||
llvm::Reloc::Model RM = CGOpts.RelocationModel;
|
llvm::Reloc::Model RM = CGOpts.RelocationModel;
|
||||||
const auto &LOpts = CGM.getLangOpts();
|
const auto &LOpts = CGM.getLangOpts();
|
||||||
if (RM != llvm::Reloc::Static && !LOpts.PIE)
|
if (RM != llvm::Reloc::Static && !LOpts.PIE && !LOpts.OpenMPIsDevice)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// A definition cannot be preempted from an executable.
|
// A definition cannot be preempted from an executable.
|
||||||
|
|
|
@ -16,22 +16,22 @@
|
||||||
// CHECK-DAG: Bake
|
// CHECK-DAG: Bake
|
||||||
// CHECK-NOT: @{{hhh|ggg|fff|eee}} =
|
// CHECK-NOT: @{{hhh|ggg|fff|eee}} =
|
||||||
// CHECK-DAG: @aaa = external global i32,
|
// CHECK-DAG: @aaa = external global i32,
|
||||||
// CHECK-DAG: @bbb = global i32 0,
|
// CHECK-DAG: @bbb ={{ dso_local | }}global i32 0,
|
||||||
// CHECK-DAG: weak constant %struct.__tgt_offload_entry { i8* bitcast (i32* @bbb to i8*),
|
// CHECK-DAG: weak constant %struct.__tgt_offload_entry { i8* bitcast (i32* @bbb to i8*),
|
||||||
// CHECK-DAG: @ccc = external global i32,
|
// CHECK-DAG: @ccc = external global i32,
|
||||||
// CHECK-DAG: @ddd = global i32 0,
|
// CHECK-DAG: @ddd ={{ dso_local | }}global i32 0,
|
||||||
// CHECK-DAG: @hhh_decl_tgt_link_ptr = common global i32* null
|
// CHECK-DAG: @hhh_decl_tgt_link_ptr = common global i32* null
|
||||||
// CHECK-DAG: @ggg_decl_tgt_link_ptr = common global i32* null
|
// CHECK-DAG: @ggg_decl_tgt_link_ptr = common global i32* null
|
||||||
// CHECK-DAG: @fff_decl_tgt_link_ptr = common global i32* null
|
// CHECK-DAG: @fff_decl_tgt_link_ptr = common global i32* null
|
||||||
// CHECK-DAG: @eee_decl_tgt_link_ptr = common global i32* null
|
// CHECK-DAG: @eee_decl_tgt_link_ptr = common global i32* null
|
||||||
// CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
|
// CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
|
||||||
// CHECK-DAG: @b = global i32 15,
|
// CHECK-DAG: @b ={{ dso_local | }}global i32 15,
|
||||||
// CHECK-DAG: @d = global i32 0,
|
// CHECK-DAG: @d ={{ dso_local | }}global i32 0,
|
||||||
// CHECK-DAG: @c = external global i32,
|
// CHECK-DAG: @c = external global i32,
|
||||||
// CHECK-DAG: @globals = global %struct.S zeroinitializer,
|
// CHECK-DAG: @globals ={{ dso_local | }}global %struct.S zeroinitializer,
|
||||||
// CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
|
// CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
|
||||||
// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
|
// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
|
||||||
// CHECK-DAG: @out_decl_target = global i32 0,
|
// CHECK-DAG: @out_decl_target ={{ dso_local | }}global i32 0,
|
||||||
// CHECK-DAG: @llvm.used = appending global [6 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+80]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+81]]_ctor to i8*),
|
// CHECK-DAG: @llvm.used = appending global [6 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+80]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+81]]_ctor to i8*),
|
||||||
// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
|
// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ extern const omp_allocator_handle_t omp_pteam_mem_alloc;
|
||||||
extern const omp_allocator_handle_t omp_thread_mem_alloc;
|
extern const omp_allocator_handle_t omp_thread_mem_alloc;
|
||||||
|
|
||||||
// CHECK-DAG: @{{.+}}St1{{.+}}b{{.+}} = external global i32,
|
// CHECK-DAG: @{{.+}}St1{{.+}}b{{.+}} = external global i32,
|
||||||
// CHECK-DAG: @a = global i32 0,
|
// CHECK-DAG: @a ={{ dso_local | }}global i32 0,
|
||||||
// CHECK-DAG: @b = addrspace(4) global i32 0,
|
// CHECK-DAG: @b ={{ dso_local | }}addrspace(4) global i32 0,
|
||||||
// CHECK-DAG: @c = global i32 0,
|
// CHECK-DAG: @c ={{ dso_local | }}global i32 0,
|
||||||
// CHECK-DAG: @d = global %struct.St1 zeroinitializer,
|
// CHECK-DAG: @d ={{ dso_local | }}global %struct.St1 zeroinitializer,
|
||||||
// CHECK-DAG: @{{.+}}ns{{.+}}a{{.+}} = addrspace(3) global i32 0,
|
// CHECK-DAG: @{{.+}}ns{{.+}}a{{.+}} ={{ dso_local | }}addrspace(3) global i32 0,
|
||||||
// CHECK-DAG: @{{.+}}main{{.+}}a{{.*}} = internal global i32 0,
|
// CHECK-DAG: @{{.+}}main{{.+}}a{{.*}} = internal global i32 0,
|
||||||
// CHECK-DAG: @{{.+}}ST{{.+}}m{{.+}} = external global i32,
|
// CHECK-DAG: @{{.+}}ST{{.+}}m{{.+}} = external global i32,
|
||||||
// CHECK-DAG: @bar_c = internal global i32 0,
|
// CHECK-DAG: @bar_c = internal global i32 0,
|
||||||
|
@ -79,7 +79,7 @@ extern template int ST<int>::m;
|
||||||
|
|
||||||
void baz(float &);
|
void baz(float &);
|
||||||
|
|
||||||
// CHECK: define void @{{.+}}bar{{.+}}()
|
// CHECK: define{{ dso_local | }}void @{{.+}}bar{{.+}}()
|
||||||
void bar() {
|
void bar() {
|
||||||
// CHECK: alloca float,
|
// CHECK: alloca float,
|
||||||
float bar_a;
|
float bar_a;
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
// SIMD-ONLY-NOT: {{__kmpc|__tgt}}
|
// SIMD-ONLY-NOT: {{__kmpc|__tgt}}
|
||||||
|
|
||||||
// DEVICE-DAG: [[C_ADDR:.+]] = internal global i32 0,
|
// DEVICE-DAG: [[C_ADDR:.+]] = internal global i32 0,
|
||||||
// DEVICE-DAG: [[CD_ADDR:@.+]] = global %struct.S zeroinitializer,
|
// DEVICE-DAG: [[CD_ADDR:@.+]] ={{ dso_local | }}global %struct.S zeroinitializer,
|
||||||
// HOST-DAG: @[[C_ADDR:.+]] = internal global i32 0,
|
// HOST-DAG: @[[C_ADDR:.+]] = internal global i32 0,
|
||||||
// HOST-DAG: @[[CD_ADDR:.+]] = global %struct.S zeroinitializer,
|
// HOST-DAG: @[[CD_ADDR:.+]] ={{ dso_local | }}global %struct.S zeroinitializer,
|
||||||
|
|
||||||
#pragma omp declare target
|
#pragma omp declare target
|
||||||
int foo() { return 0; }
|
int foo() { return 0; }
|
||||||
|
@ -34,12 +34,12 @@ int car() { return 0; }
|
||||||
#pragma omp declare target (bar)
|
#pragma omp declare target (bar)
|
||||||
int caz() { return 0; }
|
int caz() { return 0; }
|
||||||
|
|
||||||
// DEVICE-DAG: define i32 [[FOO:@.*foo.*]]()
|
// DEVICE-DAG: define{{ dso_local | }}i32 [[FOO:@.*foo.*]]()
|
||||||
// DEVICE-DAG: define i32 [[BAR:@.*bar.*]]()
|
// DEVICE-DAG: define{{ dso_local | }}i32 [[BAR:@.*bar.*]]()
|
||||||
// DEVICE-DAG: define i32 [[BAZ:@.*baz.*]]()
|
// DEVICE-DAG: define{{ dso_local | }}i32 [[BAZ:@.*baz.*]]()
|
||||||
// DEVICE-DAG: define i32 [[DOO:@.*doo.*]]()
|
// DEVICE-DAG: define{{ dso_local | }}i32 [[DOO:@.*doo.*]]()
|
||||||
// DEVICE-DAG: define i32 [[CAR:@.*car.*]]()
|
// DEVICE-DAG: define{{ dso_local | }}i32 [[CAR:@.*car.*]]()
|
||||||
// DEVICE-DAG: define i32 [[CAZ:@.*caz.*]]()
|
// DEVICE-DAG: define{{ dso_local | }}i32 [[CAZ:@.*caz.*]]()
|
||||||
|
|
||||||
static int c = foo() + bar() + baz();
|
static int c = foo() + bar() + baz();
|
||||||
#pragma omp declare target (c)
|
#pragma omp declare target (c)
|
||||||
|
|
|
@ -573,7 +573,7 @@ int baz(int f, double &a) {
|
||||||
// CHECK: [[EXIT]]
|
// CHECK: [[EXIT]]
|
||||||
// CHECK: ret void
|
// CHECK: ret void
|
||||||
|
|
||||||
// CHECK: define i32 [[BAZ]](i32 [[F:%.*]], double* dereferenceable{{.*}})
|
// CHECK: define{{ dso_local | }}i32 [[BAZ]](i32 [[F:%.*]], double* dereferenceable{{.*}})
|
||||||
// CHECK: alloca i32,
|
// CHECK: alloca i32,
|
||||||
// CHECK: [[LOCAL_F_PTR:%.+]] = alloca i32,
|
// CHECK: [[LOCAL_F_PTR:%.+]] = alloca i32,
|
||||||
// CHECK: [[ZERO_ADDR:%.+]] = alloca i32,
|
// CHECK: [[ZERO_ADDR:%.+]] = alloca i32,
|
||||||
|
|
|
@ -26,18 +26,18 @@ struct T1 {
|
||||||
#pragma omp declare target
|
#pragma omp declare target
|
||||||
T a = T();
|
T a = T();
|
||||||
T f = a;
|
T f = a;
|
||||||
// CHECK: define void @{{.+}}foo{{.+}}([[T]]* byval align {{.+}})
|
// CHECK: define{{ dso_local | }}void @{{.+}}foo{{.+}}([[T]]* byval align {{.+}})
|
||||||
void foo(T a = T()) {
|
void foo(T a = T()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CHECK: define [6 x i64] @{{.+}}bar{{.+}}()
|
// CHECK: define{{ dso_local | }}[6 x i64] @{{.+}}bar{{.+}}()
|
||||||
T bar() {
|
T bar() {
|
||||||
// CHECK: bitcast [[T]]* %{{.+}} to [6 x i64]*
|
// CHECK: bitcast [[T]]* %{{.+}} to [6 x i64]*
|
||||||
// CHECK-NEXT: load [6 x i64], [6 x i64]* %{{.+}},
|
// CHECK-NEXT: load [6 x i64], [6 x i64]* %{{.+}},
|
||||||
// CHECK-NEXT: ret [6 x i64]
|
// CHECK-NEXT: ret [6 x i64]
|
||||||
return T();
|
return T();
|
||||||
}
|
}
|
||||||
// CHECK: define void @{{.+}}baz{{.+}}()
|
// CHECK: define{{ dso_local | }}void @{{.+}}baz{{.+}}()
|
||||||
void baz() {
|
void baz() {
|
||||||
// CHECK: call [6 x i64] @{{.+}}bar{{.+}}()
|
// CHECK: call [6 x i64] @{{.+}}bar{{.+}}()
|
||||||
// CHECK-NEXT: bitcast [[T]]* %{{.+}} to [6 x i64]*
|
// CHECK-NEXT: bitcast [[T]]* %{{.+}} to [6 x i64]*
|
||||||
|
@ -46,17 +46,17 @@ void baz() {
|
||||||
}
|
}
|
||||||
T1 a1 = T1();
|
T1 a1 = T1();
|
||||||
T1 f1 = a1;
|
T1 f1 = a1;
|
||||||
// CHECK: define void @{{.+}}foo1{{.+}}([[T1]]* byval align {{.+}})
|
// CHECK: define{{ dso_local | }}void @{{.+}}foo1{{.+}}([[T1]]* byval align {{.+}})
|
||||||
void foo1(T1 a = T1()) {
|
void foo1(T1 a = T1()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CHECK: define [[T1]] @{{.+}}bar1{{.+}}()
|
// CHECK: define{{ dso_local | }}[[T1]] @{{.+}}bar1{{.+}}()
|
||||||
T1 bar1() {
|
T1 bar1() {
|
||||||
// CHECK: load [[T1]], [[T1]]*
|
// CHECK: load [[T1]], [[T1]]*
|
||||||
// CHECK-NEXT: ret [[T1]]
|
// CHECK-NEXT: ret [[T1]]
|
||||||
return T1();
|
return T1();
|
||||||
}
|
}
|
||||||
// CHECK: define void @{{.+}}baz1{{.+}}()
|
// CHECK: define{{ dso_local | }}void @{{.+}}baz1{{.+}}()
|
||||||
void baz1() {
|
void baz1() {
|
||||||
// CHECK: call [[T1]] @{{.+}}bar1{{.+}}()
|
// CHECK: call [[T1]] @{{.+}}bar1{{.+}}()
|
||||||
T1 t = bar1();
|
T1 t = bar1();
|
||||||
|
|
Loading…
Reference in New Issue