[LLVMdev] alloca not in first bb behaving differently

Sanjoy Das sanjoy at playingwithpointers.com
Sun Apr 5 15:10:47 PDT 2015


> This segfaults for me. The IR passes the function verifier. Can someone spot
> an error? I don't see any.

Does it segfault the optimizer or when run?  If I run your fragment
through opt -O3 (on LLVM trunk) after correcting for syntax (due to
the unified pointer type changes), I get

define i32 @M() #0 {
entry:
  ret i32 3
}

attributes #0 = { nounwind readnone }

which looks like what you'd want.

Just running it through llc (no -O3) gives me

.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 14, 1
.globl _M
.align 4, 0x90
_M:                                     ## @M
.cfi_startproc
## BB#0:                                ## %if.then
movl $333, -4(%rsp)          ## imm = 0x14D
movl $3, -8(%rsp)
movl $3, %eax
retq
.cfi_endproc


.subsections_via_symbols


which also looks correct.

-- Sanjoy



More information about the llvm-dev mailing list