[PATCH] D11315: Regression test for simple devirtualization (microsoft abi)

Andrew Zhogin andrew.zhogin at gmail.com
Fri Jul 17 15:52:14 PDT 2015


andrew.zhogin created this revision.
andrew.zhogin added a reviewer: majnemer.
andrew.zhogin added subscribers: zinovy.nis, cfe-commits.

Clang generates aliases for vtable access getelementptr (microsoft ABI only). It breaks devirtualization due to constprop failing on GlobalAlias. Here is simple test aka "return ptr->f() + ptr->f_const()".

Linked with:
[[ http://reviews.llvm.org/D11306 | llvm patch for aliases constprop ]]


http://reviews.llvm.org/D11315

Files:
  test/Analysis/devirtualize-virtual-function-calls-constprop.cpp

Index: test/Analysis/devirtualize-virtual-function-calls-constprop.cpp
===================================================================
--- test/Analysis/devirtualize-virtual-function-calls-constprop.cpp
+++ test/Analysis/devirtualize-virtual-function-calls-constprop.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O3 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -O3 %s -triple x86_64-win32 -emit-llvm -o - | FileCheck %s
+ 
+struct A {
+  virtual int f() { return 7; }
+  virtual int f_const() const { return 3; }
+};
+
+// CHECK: ret i32 10
+int f() {
+  A *ptr = new A();
+   
+  int rv = ptr->f() + ptr->f_const();
+  delete ptr;
+  return rv;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11315.30047.patch
Type: text/x-patch
Size: 674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150717/81be2158/attachment.bin>


More information about the cfe-commits mailing list