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 34992 - Fatal error: Offset not zero at the point of scalar access
Summary: Fatal error: Offset not zero at the point of scalar access
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Ivan Kosarev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-18 10:18 PDT by Douglas Yung
Modified: 2017-10-31 14:39 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s): rL316211


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Yung 2017-10-18 10:18:46 PDT
Following r315984, one of our internal tests started to fail with the following error from the compiler:

Offset not zero at the point of scalar access
  %2 = load float, float* %india, align 4, !tbaa !6
!6 = !{!7, !9, i64 4}
4
fatal error: error in backend: Broken function found, compilation aborted!

You can reproduce this by compiling the following code with optimization’s enabled:

Clang -cc1 -emit-obj -O2 reduced.cpp

Where reduced.cpp is the following code:

/* reduced.cpp */
class alpha;
namespace bravo {
  namespace charlie { 
    void delta(alpha* element, char* name, float var); 
  }

  namespace foxtrot {
    class gulf { public: float hotel; float india; };
    class juliet { public: gulf kilo[4]; };
  }

  namespace charlie {
    class lima { public: bravo::foxtrot::juliet mike; };
    void november( alpha* oscar, lima * papa ) {
      alpha* quebec ;
      delta(quebec, "romeo", papa->mike.kilo->india);
    }
  }
}

Thanks to Sunil for helping reduce this test for me.
Comment 1 Ivan Kosarev 2017-10-18 12:59:18 PDT
A minimized test:

struct A { int x; };
struct B { A a[1]; };

int bar(B *b) {
  return b->a->x;
}

Apparently the problem is how we handle array-to-pointer decays.
Comment 2 Ivan Kosarev 2017-10-19 02:04:09 PDT
The patch:
https://reviews.llvm.org/D39083
Comment 3 Ivan Kosarev 2017-10-20 05:45:13 PDT
Resolved in:
[CodeGen] Fix generation of TBAA info for array-to-pointer conversions
https://reviews.llvm.org/rL316211
Comment 4 Ivan Kosarev 2017-10-30 12:56:09 PDT
Douglas, can you please confirm the fix works for you?
Comment 5 Douglas Yung 2017-10-31 14:39:56 PDT
(In reply to Ivan Kosarev from comment #4)
> Douglas, can you please confirm the fix works for you?

Hi Ivam, I can confirm that this fixes the internal test that uncovered the issue. Thanks for fixing it!