[LLVMdev] Simple question
Chuck Zhao
chuck.zhao at samsung.com
Fri Mar 15 15:38:37 PDT 2013
If you turn on the optimizer from clang (-O3), you will get:
store i32 12, i32* @var1, align 4, !tbaa !0
%var2 = 12
is not a valid LLVM IR.
Chuck
On 3/15/2013 3:08 PM, James Courtier-Dutton wrote:
> Hi,
>
> I think this is a very simple question, and it must just be missing something.
>
> I am looking for find out how to assign a constant integer value to
> the variable in llvm ir.
>
> The following returns 12, and %var2 = 12.
> ; ModuleID = 't.c'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> target triple = "x86_64-pc-linux-gnu"
>
> define i32 @test() nounwind readnone {
> %var1 = xor i32 0, 0
> %var2 = add i32 %var1, 12
> ret i32 %var2
> }
>
> Why can't I do?:
> ; ModuleID = 't.c'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> target triple = "x86_64-pc-linux-gnu"
>
> define i32 @test() nounwind readnone {
> %var2 = 12
> ret i32 %var2
> }
>
> What is the simplest way to make %var2 = 12 ?
>
> Kind Regards
>
> James
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list