[LLVMdev] Structs as first class values.

Richard Pennington rich at pennware.com
Sun Jul 20 06:25:30 PDT 2008


Hi,

I'm trying to implement structs as first class values. If I assemble

; ModuleID = 't0022.s.bc'
target datalayout = 
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"
         %struct.foo = type { i32, i32, i32 }

define %struct.foo @main() nounwind  {
entry:
         %foo = alloca %struct.foo               ; <%struct.foo*> [#uses=1]
         %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
         br label %return

return:         ; preds = %entry
         %t = load %struct.foo* %foo             ; <%struct.foo> [#uses=1]
         ret %struct.foo %t
}

It assembles without complaint.

If I do llc I get an assert:

x86:
Return operand #2 has unhandled type i32
llc[0x8b5981e]
...

arm:
llc: /home/rich/llvm-trunk-new/lib/VMCore/ValueTypes.cpp:109: static 
llvm::MVT llvm::MVT::getMVT(const llvm::Type*, bool): Assertion `0 && 
"Unknown type!"' failed.
...

My questions are:

  Is this supposed to work? (I understand it may be a work in progress.)
  Is the LLVM well formed at the source level?

-Rich



More information about the llvm-dev mailing list