-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a pass which, given a class with bases, tries to replace uses of it with uses of it's bases #261
Comments
yes that would be desirable. I'll just add that we're not too likely to get to this anytime soon since we don't have people working on C-Reduce at the moment. |
There is already a very similar pass, currently restricted to base class templates:
@regehr what do you think of making this pass more generic? Or would you prefer a separate pass? |
if there's no loss of reduction power, I think keeping it all in the same pass is great. thanks! |
Yesterday I actually overlooked that there is already another pass removing base classes: creduce/clang_delta/RemoveBaseClass.cpp Line 26 in 9250247
On the example above it does remove @mizvekov could you try to run c-reduce again on your example? I'm surprised that it didn't manage to produce a slightly smaller file based on the pass I found. Could it be that your interestingness test is actually preventing it from getting smaller? |
I have used creduce 2.11.0, provided by the msys2 environment. Here is the full resulting reduced file: template <bool, class> using a = int;
template <int b> struct c {
static const int d = b;
};
template <size_t> struct e {};
template <size_t f> e<f> g;
struct h {
template <class ak> static auto j(ak) {
auto a = l<ak>;
a();
}
template <class> static auto l() {}
};
class m {
public:
template <size_t i> m(e<i>) {}
};
class n : m {
using bj = m;
public:
using bj::bj;
~n() {
h::j([] {});
}
};
class o : n {
using bj = n;
using bj::bj;
};
class p : o {
using bj = o;
using bj::bj;
};
class J : p {
using bj = p;
using bj::bj;
};
class q : J {
using bj = J;
using bj::bj;
};
class r : q {
using bj = q;
using bj::bj;
};
class s : r {
using bj = r;
using bj::bj;
};
class t : s {
using bj = s;
using bj::bj;
};
class F {
public:
template <a<c<1>::d, int> = 0> F() : bt(g<0>) {}
t bt;
};
int main() { F k; } Running creduce another time on it produces no changes. Here is the full output of that:
You can see that it produced a single failure on Here is my interestingness test: #!/usr/bin/fish
export LLVM_SYMBOLIZER_PATH=/usr/bin/true
set -l clang "C:/PROGRA~1/LLVM/bin/CLANG_~1.EXE"
set -l args "-D_LIBCPP_NO_AUTO_LINK" "-std=gnu++23" "--target=x86_64-pc-windows-msvc" "-fno-exceptions" "-fsanitize=function" "-flto=thin" "-ggdb3" "-O0" "-fuse-ld=lld" "-o" "test.exe"
if ! $clang $args "test.cc" 2>&1;
exit 1
end
set output (./test.exe 2>&1)
if test $status != 0;
exit 1
end
if ! string match --quiet --regex "through pointer to incorrect function type" "$output";
exit 1
end This is running on llvm 17.0.1, but the bug this is looking for is present on llvm master as of today. FWIW, I reduced this further manually to: static auto l() {}
int main() {
auto a = l;
a();
} And this is the MR that fixes this bug: llvm/llvm-project#66816 |
let's tag in @chenyang78 here on the off chance he has a minute to think about this! |
Hi folks, thank you for the discussion! It's probably due to that |
I found one bug in the Since I currently don't have a Windows setup ready with c-reduce I could not test if that also improves the reduction result in the case above. |
I tested again with newer version including #263 , but I get the same results. |
I have observed that sometimes reduction results in deep class hierarchies:
I think the simplest thing here would be to try replacing uses of a class with uses of the bases of that class.
The text was updated successfully, but these errors were encountered: