[compiler-rt] Support MemProf on darwin (PR #69640)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 20:17:51 PDT 2023


================
@@ -0,0 +1,83 @@
+// UNSUPPORTED: ios
+
+// RUN: %clangxx_memprof -O0 %s -o %t
+// RUN: %env_memprof_opts=print_binary_refs=true:print_text=true:log_path=stdout:verbosity=2 %run %t &> %t.log
+// RUN: llvm-nm %t &> %t2.log
+// RUN: cat %t2.log %t.log | FileCheck %s
+
+#include <sanitizer/memprof_interface.h>
+struct __attribute__((visibility("default"))) A {
+  virtual void foo() {}
+};
+
+void test_1(A *p) {
+  // A has default visibility, so no need for type.checked.load.
+  p->foo();
+}
+
+struct __attribute__((visibility("hidden")))
+[[clang::lto_visibility_public]] B {
+  virtual void foo() {}
+};
+
+void test_2(B *p) {
+  // B has public LTO visibility, so no need for type.checked.load.
+  p->foo();
+}
+
+struct __attribute__((visibility("hidden"))) C {
+  virtual void foo() {}
+  virtual void bar() {}
+};
+
+void test_3(C *p) {
+  // C has hidden visibility, so we generate type.checked.load to allow VFE.
+  p->foo();
+}
+
+void test_4(C *p) {
+  // When using type.checked.load, we pass the vtable offset to the intrinsic,
+  // rather than adding it to the pointer with a GEP.
+  p->bar();
+}
+
+void test_5(C *p, void (C::*q)(void)) {
+  // We also use type.checked.load for the virtual side of member function
----------------
teresajohnson wrote:

I'm confused by all the comments about type.checked.load - this isn't being built with the necessary options.

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


More information about the llvm-commits mailing list