Skip to content
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

[IROutliner] Crash due to missing GVN #62876

Closed
lanza opened this issue May 23, 2023 · 4 comments · Fixed by #72945
Closed

[IROutliner] Crash due to missing GVN #62876

lanza opened this issue May 23, 2023 · 4 comments · Fixed by #72945
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] ipo Interprocedural optimizations

Comments

@lanza
Copy link
Member

lanza commented May 23, 2023

When building the following source:

# 2 "" 3
typedef a;
typedef struct {
  int b;
  a c;
  a d
} e;
typedef struct {
  int f;
  e g
} h;
typedef struct {
  h ac;
  void *i
} j;
typedef (*k)();
typedef (*l)();
typedef (*m)();
n;
typedef (*ad)();
typedef (*o)();
p(j);
j q();
r() {
  j s = q();
  if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
      k a = s.i;
      a();
    }
  }
}
u() {
  j s = q();
  if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
      l b = s.i;
      b(u);
    }
  }
}
v() {
  j s = q();
  if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
      m c = s.i;
      c(n);
    }
  }
}
w() {
  j s = q();
  if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
      ad d = s.i;
      return d(t);
    }
  }
  return 0;
}
x() {
  j s = q();
  if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
      o e = s.i;
      return e(t, 0);
    }
  }
  return 0;
}

with the following flags:

-mthumb
-target
armv7-none-linux-androideabi19
-g3
-mllvm
-ir-outliner
-Oz
-ftrivial-auto-var-init=zero
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
-c
here2.c

We reach a crash here: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/IPO/IROutliner.cpp#L190.

Here is a link to a Godbolt repro: https://godbolt.org/z/7Kzf37P4b

@lanza
Copy link
Member Author

lanza commented May 23, 2023

cc @ornata @AndrewLitteken

BTW I have no need for this to be fixed any time soon. We aren't planning to use it for this code (at least not yet?). Just known about it for awhile and figured I'd share the reduced crash.

@EugeneZelenko EugeneZelenko added llvm:optimizations crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels May 23, 2023
dcci added a commit to dcci/llvm-project that referenced this issue Nov 21, 2023
dbg value don't really have a value number associated as they
have no semantic value associated, i.e. they don't change the
code being generated. Use the correct API to go over them.

Fixes llvm#62876
@dcci
Copy link
Member

dcci commented Nov 21, 2023

Proposed fix in #72945

@EugeneZelenko EugeneZelenko added ipo Interprocedural optimizations and removed llvm:optimizations labels Nov 21, 2023
@lanza
Copy link
Member Author

lanza commented Nov 22, 2023

Can confirm that this is the fix for the previously observed crash!

@lanza lanza closed this as completed Nov 22, 2023
@EugeneZelenko
Copy link
Contributor

@lanza: Fix is not merged yet.

@EugeneZelenko EugeneZelenko reopened this Nov 22, 2023
dcci added a commit that referenced this issue Nov 22, 2023
dbg value don't really have a value number associated as they have no
semantic value associated, i.e. they don't change the code being
generated. Use the correct API to go over them.

Fixes #62876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] ipo Interprocedural optimizations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants