[clang] [clang] Add per-global code model attribute (PR #72078)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 6 21:25:12 PST 2023


================
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -triple loongarch64 %s -o - | FileCheck %s
+
+// CHECK: @normal ={{.*}} global i32 0, code_model "small"
+int normal __attribute__((model("normal")));
+
+// CHECK: @medium ={{.*}} global i32 0, code_model "medium"
+int medium __attribute__((model("medium")));
+
+// CHECK: @extreme ={{.*}} global i32 0, code_model "large"
+int extreme __attribute__((model("extreme")));
----------------
MaskRay wrote:

You can add `static` to one of the variables to add some variance, and add a `void use() { ... }` to use the variable.

Consider testing a C++ variable template, a TLS variable, a function, and a struct.

https://github.com/llvm/llvm-project/pull/72078


More information about the cfe-commits mailing list