[PATCH] D99240: [ConstantFolding] Look through local aliases when simplify GEPs
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 24 00:15:32 PDT 2021
aeubanks created this revision.
Herald added subscribers: dexonsmith, hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
MSVC-style RTTI uses GEPs through local aliases for vtables.
With this patch, we can simplify the following C++ code into just one
function with a constant return value:
namespace {
struct A {
virtual int f() = 0;
virtual ~A() = default;
};
struct B: A {
virtual int f() override { return 41; }
virtual ~B() = default;
};
}
int foo() {
std::unique_ptr<A> a = std::make_unique<B>();
return a->f();
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99240
Files:
llvm/include/llvm/IR/Value.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/IR/Value.cpp
llvm/test/Transforms/InstSimplify/ConstProp/gep-alias.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99240.332878.patch
Type: text/x-patch
Size: 5663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210324/4a5d9226/attachment.bin>
More information about the llvm-commits
mailing list