[LLVMdev] When is getelementptr on an unsized type legal? (type system rewrite regression)

Eli Friedman eli.friedman at gmail.com
Mon Jul 11 11:55:31 PDT 2011


Consider the following test case:

%struct.A = type opaque
@g = external global [0 x %struct.A]
declare void @foo(%struct.A*)
define void @f() uwtable ssp align 64 {
  %x = getelementptr [0 x %struct.A]* @g, i32 0, i32 0
  call void @foo(%struct.A* %x)
  ret void
}

Before the type system rewrite, we would accept this construct; now,
we reject it.  (This leads to clang/opt crashing on certain
testcases.)

Note that this is the natural way to represent the following C++ code
(which now crashes clang):

struct A;
extern A g[];
void foo(A*);
void f(void) {
  foo(g);
}

The question is, is should we accept the given IR?  If so, what rule
do we use to accept it?  If not, do we care about upgrading 2.9
bitcode files with this construct?

-Eli



More information about the llvm-dev mailing list