
Following up #72078, on x86-64 this allows a global to be considered small or large regardless of the code model. For example, x86-64's medium code model by default classifies globals as small or large depending on their size relative to -mlarge-data-threshold. GPU compilations compile the same TU for both the host and device, but only codegen the host or device portions of it depending on attributes. However, we still Sema the TU, and will warn on an unknown attribute for the device compilation since this attribute is target-specific. Since they're intended for the host, accept but ignore this attribute for device compilations where the host is either unknown or known to support the attribute. Co-authored-by: @pranavk
28 lines
636 B
C++
28 lines
636 B
C++
// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown %s -o - | FileCheck %s
|
|
|
|
// CHECK: @_ZL2v1 ={{.*}} global i32 0, code_model "small"
|
|
static int v1 __attribute__((model("small")));
|
|
|
|
void use1() {
|
|
v1 = 1;
|
|
}
|
|
|
|
// CHECK: @v2 ={{.*}} global float 0.000000e+00, code_model "large"
|
|
float v2 __attribute__((model("large")));
|
|
|
|
// CHECK: @_ZL2v3IiE ={{.*}} global i32 0, code_model "small"
|
|
template <typename T>
|
|
static T v3 __attribute__((model("small")));
|
|
|
|
void use2() {
|
|
v3<int> = 1;
|
|
}
|
|
struct S {
|
|
double d;
|
|
};
|
|
|
|
typedef void (*F)();
|
|
|
|
// CHECK: @v4 ={{.*}} global ptr null, code_model "large"
|
|
F v4 __attribute__((model("large")));
|