From edf0d38c9d3ef522a43d2cb514c90794eaa50dfd Mon Sep 17 00:00:00 2001 From: Mark Seaborn Date: Wed, 24 Jul 2013 16:25:13 +0000 Subject: Use ARM-style representation for C++ method pointers under PNaCl/Emscripten Before this change, Clang uses the x86 representation for C++ method pointers when generating code for PNaCl. However, the resulting code will assume that function pointers are 0 mod 2. This assumption is not safe for PNaCl, where function pointers could have any value (especially in future sandboxing models). So, switch to using the ARM representation for PNaCl code, which makes no assumptions about the alignment of function pointers. Since we're changing the "le32" target, this change also applies to Emscripten. The change is beneficial for Emscripten too. Emscripten has a workaround to make function pointers 0 mod 2. This change would allow the workaround to be removed. See: https://code.google.com/p/nativeclient/issues/detail?id=3450 llvm-svn: 187051 --- clang/test/CodeGenCXX/member-function-pointers.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/test/CodeGenCXX/member-function-pointers.cpp') diff --git a/clang/test/CodeGenCXX/member-function-pointers.cpp b/clang/test/CodeGenCXX/member-function-pointers.cpp index 84b54b6..23a7b00 100644 --- a/clang/test/CodeGenCXX/member-function-pointers.cpp +++ b/clang/test/CodeGenCXX/member-function-pointers.cpp @@ -4,6 +4,9 @@ // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s // RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-ARM %s +// PNaCl uses the same representation of method pointers as ARM. +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=le32-unknown-nacl | FileCheck -check-prefix GLOBAL-ARM %s + struct A { int a; void f(); virtual void vf1(); virtual void vf2(); }; struct B { int b; virtual void g(); }; struct C : B, A { }; -- cgit v1.1