LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 28295 - Regression (r273545): Bad machine code: Using an undefined physical register
Summary: Regression (r273545): Bad machine code: Using an undefined physical register
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL: http://reviews.llvm.org/D20907
Keywords:
Depends on:
Blocks: 32146
  Show dependency tree
 
Reported: 2016-06-24 13:55 PDT by Peter Collingbourne
Modified: 2017-05-15 11:53 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Collingbourne 2016-06-24 13:55:10 PDT
e.g.
https://build.chromium.org/p/chromium.fyi/builders/ClangToTAndroidASan/builds/3365

Working on a reproducer.
Comment 1 Peter Collingbourne 2016-06-24 15:01:21 PDT
$ cat test.cpp
class A {};
class B {
public:
  A m_fn1();
};
class C {
public:
  C();
  void operator&(A);
};
using InterfaceId = int;
class D;
class F {
  class G;
  enum ClientCallBehavior {};
  bool m_fn2(D *, ClientCallBehavior *);
  void m_fn3();
  G *m_fn4(InterfaceId, bool);
};
class F::G {
public:
  bool m_fn5() { return closed_; }
  bool closed_;
};

bool a;
bool F::m_fn2(D *p1, ClientCallBehavior *) {
  A b;
  InterfaceId c = 0;
  G *d = m_fn4(c, a);
  if (d->m_fn5())
    return true;
  if (d)
    return false;
  B().m_fn1();
  C() & b;
  if (p1)
    m_fn3();
  return true;
}

$ clang++ -fstack-protector --target=arm-linux-androideabi -march=armv7-a -mthumb -Os -fsanitize=address -std=gnu++11 -c test.cpp
[...]
*** Bad machine code: MBB exits via unconditional fall-through but its successor differs from its CFG successor! ***
- function:    _ZN1F5m_fn2EP1DPNS_18ClientCallBehaviorE
- basic block: BB#6 (null) (0x4fb3df0)

*** Bad machine code: MBB exits via unconditional fall-through but its successor differs from its CFG successor! ***
- function:    _ZN1F5m_fn2EP1DPNS_18ClientCallBehaviorE
- basic block: BB#8 (null) (0x4fb3ea0)

*** Bad machine code: Using an undefined physical register ***
- function:    _ZN1F5m_fn2EP1DPNS_18ClientCallBehaviorE
- basic block: BB#9 if.end5 (0x4f98b88)
- instruction: BUNDLE
- operand 166:   %R0_R1<imp-use,kill>

*** Bad machine code: Using an undefined physical register ***
- function:    _ZN1F5m_fn2EP1DPNS_18ClientCallBehaviorE
- basic block: BB#9 if.end5 (0x4f98b88)
- instruction: %R0<def> = tMOVr
- operand 4:   %R0<imp-use>

*** Bad machine code: Using an undefined physical register ***
- function:    _ZN1F5m_fn2EP1DPNS_18ClientCallBehaviorE
- basic block: BB#9 if.end5 (0x4f98b88)
- instruction: tBL
- operand 11:   %R0_R1<imp-use,kill>
fatal error: error in backend: Found 5 machine code errors.
Comment 2 Jonas Paulsson 2016-06-30 02:05:35 PDT
I have reopened the Phabricator revision for this patch. Go there for a first analysis of the provided test case.

http://reviews.llvm.org/D20907
Comment 3 Quentin Colombet 2016-07-01 18:34:48 PDT
(In reply to comment #2)
> I have reopened the Phabricator revision for this patch. Go there for a
> first analysis of the provided test case.
> 
> http://reviews.llvm.org/D20907

Commented there. For tracking purposes summarizing what I said.
I believe the patch itself is correct but the liveness information we get within IfConversion is incorrect and we need to figure out why.
Comment 4 Jonas Paulsson 2016-08-03 02:07:02 PDT
I reran this test case after re-commiting the bug fix for IfConversion. The live-in lists are indeed more reasonable (thanks to Matthias' fix on https://reviews.llvm.org/D22027), and the particular error we saw before here is now gone :-)

However, this test case gets stopped by the verifier at a later stage, after "Unpack machine instruction bundles". Not sure what is going on there...