iOS App launches then instantly closes in simulator/xcode - ios

any app I work on in Mavericks 10.9.1 / Xcode 5.0 / iOS Simulator 7.0.1 / SpriteKit seems to launch fine, but closes back to home as soon as it finishes loading the app.
This even happens on new projects I start in Xcode, using the basic "Hello, World!" template.
Using the basic SpriteKit template on a NEW project, I receive the following errors upon launch in iOS Simulator with no modifications to the code:
UPDATE #1: I'd also like to note, that after being forced to the Home Screen, all the other standard apps on iOS Simulator (Safari, Maps, etc.) function normally, implying that it may simply be the code itself. However, considering this happens on a brand new project straight out of the default Xcode 5.0.2 installation, I'm at a loss as to the cause.
System Log:
Marker - Feb 14, 2014, 2:07:00 PM
Feb 14 14:07:02 My-Mac-Pro.local SpringBoard[530] <Warning>: LICreateIconForImage passed NULL CGImageRef image
Feb 14 14:07:02 My-Mac-Pro com.apple.iphonesimulator.launchd.581ea05d[518] (UIKitApplication:MY.TestTestTest[0x871c][577]) <Warning>: Service exited with abnormal code: 1
Feb 14 14:07:02 My-Mac-Pro.local backboardd[520] <Warning>: Application 'UIKitApplication:MY.TestTestTest[0x871c]' exited abnormally with exit status 1
Console Log:
LLVM ERROR: Cannot select: 0xa4092b0: v16i8 = X86ISD::PSHUFB 0xa407bb8, 0xa408118 [ID=695]
0xa407bb8: v16i8 = llvm.x86.sse2.packuswb.128 0xa407b30, 0xa407a20, 0xa407aa8 [ORD=1594] [ID=694]
0xa407b30: i32 = TargetConstant<2543> [ORD=1594] [ID=37]
0xa407a20: v8i16 = llvm.x86.sse2.packssdw.128 0xa407998, 0xa407448, 0xa4075e0 [ORD=1592] [ID=693]
0xa407998: i32 = TargetConstant<2541> [ORD=1592] [ID=36]
0xa407448: v4i32 = llvm.x86.sse2.cvttps2dq 0xabe63e0, 0xa4073c0 [ORD=1582] [ID=691]
0xabe63e0: i32 = TargetConstant<2528> [ORD=1151] [ID=25]
0xa4073c0: v4f32 = fadd 0xa407338, 0xb3e70e8 [ORD=1581] [ID=688]
0xa407338: v4f32 = fmul 0xa406cc8, 0xa407e60 [ORD=1580] [ID=685]
0xa406cc8: v4f32 = llvm.x86.sse.min.ps 0xa3f4d78, 0xa406c40, 0xabf75e0 [ORD=1567] [ID=682]
0xa3f4d78: i32 = TargetConstant<2700> [ORD=1480] [ID=35]
0xa406c40: v4f32 = llvm.x86.sse.max.ps 0xa3f4b58, 0xa406bb8, 0xa407ee8 [ORD=1566] [ID=679]
0xa3f4b58: i32 = TargetConstant<2698> [ORD=1479] [ID=34]
0xa406bb8: v4f32,ch = load 0xa406b30, 0xabe62d0, 0xb3e4208<LD16[%604](tbaa=!"omnipotent char")> [ORD=1565] [ID=675]
0xabe62d0: i32 = FrameIndex<1> [ORD=978] [ID=4]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407ee8: v4f32 = bitcast 0xa4072b0 [ID=120]
0xa4072b0: v4i32 = BUILD_VECTOR 0xa407228, 0xa407228, 0xa407228, 0xa407228 [ID=100]
0xabf75e0: v4f32,ch = load 0x975facc, 0xa3f6118, 0xb3e4208<LD16[ConstantPool]> [ID=132]
0xa3f6118: i32 = add 0xb3e6978, 0xabf7f70 [ID=121]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xabf7f70: i32 = X86ISD::Wrapper 0xabe58a8 [ID=101]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407e60: v4f32,ch = load 0x975facc, 0xa408090, 0xb3e4208<LD16[ConstantPool]> [ID=135]
0xa408090: i32 = add 0xb3e6978, 0xa407f70 [ID=124]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xa407f70: i32 = X86ISD::Wrapper 0xa3f4be0 [ID=104]
0xa3f4be0: i32 = TargetConstantPool<<4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>> 0 [TF=2] [ID=67]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xb3e70e8: v4f32,ch = load 0x975facc, 0xa3f6338, 0xb3e4208<LD16[ConstantPool]> [ID=133]
0xa3f6338: i32 = add 0xb3e6978, 0xb3e43a0 [ID=122]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xb3e43a0: i32 = X86ISD::Wrapper 0xabe61c0 [ID=102]
0xabe61c0: i32 = TargetConstantPool<<4 x float> <float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01>> 0 [TF=2] [ID=65]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa4075e0: v4i32 = llvm.x86.sse2.cvttps2dq 0xabe63e0, 0xa407558 [ORD=1585] [ID=690]
0xabe63e0: i32 = TargetConstant<2528> [ORD=1151] [ID=25]
0xa407558: v4f32 = fadd 0xa4074d0, 0xb3e70e8 [ORD=1584] [ID=687]
0xa4074d0: v4f32 = fmul 0xa406e60, 0xa407e60 [ORD=1583] [ID=684]
0xa406e60: v4f32 = llvm.x86.sse.min.ps 0xa3f4d78, 0xa406dd8, 0xabf75e0 [ORD=1571] [ID=681]
0xa3f4d78: i32 = TargetConstant<2700> [ORD=1480] [ID=35]
0xa406dd8: v4f32 = llvm.x86.sse.max.ps 0xa3f4b58, 0xa406d50, 0xa407ee8 [ORD=1570] [ID=677]
0xa3f4b58: i32 = TargetConstant<2698> [ORD=1479] [ID=34]
0xa406d50: v4f32,ch = load 0xa406b30, 0xa405d50, 0xb3e4208<LD16[%608](tbaa=!"omnipotent char")> [ORD=1569] [ID=674]
0xa405d50: i32 = add 0xabe62d0, 0xb3dc798 [ORD=1465] [ID=73]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407ee8: v4f32 = bitcast 0xa4072b0 [ID=120]
0xa4072b0: v4i32 = BUILD_VECTOR 0xa407228, 0xa407228, 0xa407228, 0xa407228 [ID=100]
0xabf75e0: v4f32,ch = load 0x975facc, 0xa3f6118, 0xb3e4208<LD16[ConstantPool]> [ID=132]
0xa3f6118: i32 = add 0xb3e6978, 0xabf7f70 [ID=121]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xabf7f70: i32 = X86ISD::Wrapper 0xabe58a8 [ID=101]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407e60: v4f32,ch = load 0x975facc, 0xa408090, 0xb3e4208<LD16[ConstantPool]> [ID=135]
0xa408090: i32 = add 0xb3e6978, 0xa407f70 [ID=124]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xa407f70: i32 = X86ISD::Wrapper 0xa3f4be0 [ID=104]
0xa3f4be0: i32 = TargetConstantPool<<4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>> 0 [TF=2] [ID=67]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xb3e70e8: v4f32,ch = load 0x975facc, 0xa3f6338, 0xb3e4208<LD16[ConstantPool]> [ID=133]
0xa3f6338: i32 = add 0xb3e6978, 0xb3e43a0 [ID=122]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xb3e43a0: i32 = X86ISD::Wrapper 0xabe61c0 [ID=102]
0xabe61c0: i32 = TargetConstantPool<<4 x float> <float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01>> 0 [TF=2] [ID=65]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407aa8: v8i16 = llvm.x86.sse2.packssdw.128 0xa407998, 0xa407778, 0xa407910 [ORD=1593] [ID=692]
0xa407998: i32 = TargetConstant<2541> [ORD=1592] [ID=36]
0xa407778: v4i32 = llvm.x86.sse2.cvttps2dq 0xabe63e0, 0xa4076f0 [ORD=1588] [ID=689]
0xabe63e0: i32 = TargetConstant<2528> [ORD=1151] [ID=25]
0xa4076f0: v4f32 = fadd 0xa407668, 0xb3e70e8 [ORD=1587] [ID=686]
0xa407668: v4f32 = fmul 0xa407008, 0xa407e60 [ORD=1586] [ID=683]
0xa407008: v4f32 = llvm.x86.sse.min.ps 0xa3f4d78, 0xa406f70, 0xabf75e0 [ORD=1575] [ID=680]
0xa3f4d78: i32 = TargetConstant<2700> [ORD=1480] [ID=35]
0xa406f70: v4f32 = llvm.x86.sse.max.ps 0xa3f4b58, 0xa406ee8, 0xa407ee8 [ORD=1574] [ID=676]
0xa3f4b58: i32 = TargetConstant<2698> [ORD=1479] [ID=34]
0xa406ee8: v4f32,ch = load 0xa406b30, 0xa405e60, 0xb3e4208<LD16[%612](tbaa=!"omnipotent char")> [ORD=1573] [ID=673]
0xa405e60: i32 = add 0xabe62d0, 0xabe3fa0 [ORD=1467] [ID=75]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407ee8: v4f32 = bitcast 0xa4072b0 [ID=120]
0xa4072b0: v4i32 = BUILD_VECTOR 0xa407228, 0xa407228, 0xa407228, 0xa407228 [ID=100]
0xabf75e0: v4f32,ch = load 0x975facc, 0xa3f6118, 0xb3e4208<LD16[ConstantPool]> [ID=132]
0xa3f6118: i32 = add 0xb3e6978, 0xabf7f70 [ID=121]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xabf7f70: i32 = X86ISD::Wrapper 0xabe58a8 [ID=101]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407e60: v4f32,ch = load 0x975facc, 0xa408090, 0xb3e4208<LD16[ConstantPool]> [ID=135]
0xa408090: i32 = add 0xb3e6978, 0xa407f70 [ID=124]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xa407f70: i32 = X86ISD::Wrapper 0xa3f4be0 [ID=104]
0xa3f4be0: i32 = TargetConstantPool<<4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>> 0 [TF=2] [ID=67]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xb3e70e8: v4f32,ch = load 0x975facc, 0xa3f6338, 0xb3e4208<LD16[ConstantPool]> [ID=133]
0xa3f6338: i32 = add 0xb3e6978, 0xb3e43a0 [ID=122]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xb3e43a0: i32 = X86ISD::Wrapper 0xabe61c0 [ID=102]
0xabe61c0: i32 = TargetConstantPool<<4 x float> <float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01>> 0 [TF=2] [ID=65]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407910: v4i32 = llvm.x86.sse2.cvttps2dq 0xabe63e0, 0xa407888 [ORD=1591] [ID=672]
0xabe63e0: i32 = TargetConstant<2528> [ORD=1151] [ID=25]
0xa407888: v4f32 = fadd 0xa407800, 0xb3e70e8 [ORD=1590] [ID=670]
0xa407800: v4f32 = fmul 0xa4071a0, 0xa407e60 [ORD=1589] [ID=668]
0xa4071a0: v4f32 = llvm.x86.sse.min.ps 0xa3f4d78, 0xa407118, 0xabf75e0 [ORD=1579] [ID=666]
0xa3f4d78: i32 = TargetConstant<2700> [ORD=1480] [ID=35]
0xa407118: v4f32 = llvm.x86.sse.max.ps 0xa3f4b58, 0xa406888, 0xa407ee8 [ORD=1578] [ID=664]
0xa3f4b58: i32 = TargetConstant<2698> [ORD=1479] [ID=34]
0xa406888: v4f32 = fadd 0xa406800, 0xa3f5460 [ORD=1555] [ID=660]
0xa406800: v4f32 = fmul 0xa3f6dd8, 0xa406448 [ORD=1554] [ID=656]
0xa3f5460: v4f32 = llvm.x86.sse.min.ps 0xa3f4d78, 0xa3f53d8, 0xabf75e0 [ORD=1495] [ID=616]
0xa407ee8: v4f32 = bitcast 0xa4072b0 [ID=120]
0xa4072b0: v4i32 = BUILD_VECTOR 0xa407228, 0xa407228, 0xa407228, 0xa407228 [ID=100]
0xabf75e0: v4f32,ch = load 0x975facc, 0xa3f6118, 0xb3e4208<LD16[ConstantPool]> [ID=132]
0xa3f6118: i32 = add 0xb3e6978, 0xabf7f70 [ID=121]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xabf7f70: i32 = X86ISD::Wrapper 0xabe58a8 [ID=101]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa407e60: v4f32,ch = load 0x975facc, 0xa408090, 0xb3e4208<LD16[ConstantPool]> [ID=135]
0xa408090: i32 = add 0xb3e6978, 0xa407f70 [ID=124]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xa407f70: i32 = X86ISD::Wrapper 0xa3f4be0 [ID=104]
0xa3f4be0: i32 = TargetConstantPool<<4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>> 0 [TF=2] [ID=67]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xb3e70e8: v4f32,ch = load 0x975facc, 0xa3f6338, 0xb3e4208<LD16[ConstantPool]> [ID=133]
0xa3f6338: i32 = add 0xb3e6978, 0xb3e43a0 [ID=122]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xb3e43a0: i32 = X86ISD::Wrapper 0xabe61c0 [ID=102]
0xabe61c0: i32 = TargetConstantPool<<4 x float> <float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01>> 0 [TF=2] [ID=65]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
0xa408118: v16i8 = bitcast 0xa407d50 [ID=140]
0xa407d50: v2i64,ch = load 0x975facc, 0xa408228, 0xb3e4208<LD16[ConstantPool]> [ID=136]
0xa408228: i32 = add 0xb3e6978, 0xa4081a0 [ID=125]
0xb3e6978: i32 = X86ISD::GlobalBaseReg [ID=64]
0xa4081a0: i32 = X86ISD::Wrapper 0xb405660 [ID=105]
0xb405660: i32 = TargetConstantPool<<16 x i8> <i8 2, i8 1, i8 0, i8 3, i8 6, i8 5, i8 4, i8 7, i8 10, i8 9, i8 8, i8 11, i8 14, i8 13, i8 12, i8 15>> 0 [TF=2] [ID=68]
0xb3e4208: i32 = undef [ORD=977] [ID=3]
In function: gldLLVMFPTransform7

Try updating to Xcode 5.1 (The beta version is pretty stable) and as above - reset the content settings of the iOS simulator. It can be fussy at times.

Have you tried resetting the simulator? ('iOS Simulator menu' > 'Reset Content And Settings...')
It's not uncommon for the simulator to act funny at some point.

In finder select .xcodeproject file. Right click and select Show Package content.Then delete "xcuserdata"It usually store status of last execution.

Related

Got error during orelse 2 "var optinal integer"

I'm a fresh new in Zig who test a few codes with "orelse".
I tried to create 2 optional unsigned integer variables as following code and use orelse with them.
const std = #import("std");
pub fn main() !void {
var value1: ?u32 = 123;
var value2: ?u32 = 222;
std.debug.print("value1 orelse value2: {}\n", .{value1 orelse value2});
}
My expectation, it should print "123". But I got an runtime error (or at least I understand it's):
zig run main.zig
broken LLVM module found: Instruction does not dominate all uses!
%7 = getelementptr inbounds %"struct:26:52", %"struct:26:52"* %1, i32 0, i32 0, !dbg !2021
%12 = getelementptr inbounds %"?u32", %"?u32"* %7, i32 0, i32 1, !dbg !2020
Instruction does not dominate all uses!
%7 = getelementptr inbounds %"struct:26:52", %"struct:26:52"* %1, i32 0, i32 0, !dbg !2021
%13 = getelementptr inbounds %"?u32", %"?u32"* %7, i32 0, i32 0, !dbg !2020
This is a bug in the Zig compiler.thread 1856201 panic:
Unable to dump stack trace: debug info stripped
make: *** [run] Abort trap: 6
So is it the correct expectation or it's a bug? If it's a bug, where should I post it (sorry I'm a newbie).
I'm using zig 0.9.1. Run on MacOS 12.5 (21G72)
Thanks for your taking time
UPDATE:
Tried with suggestions:
v0.9.1: Define 3rd variable: value3 = value1 orelse value2; and print it
v0.10: upgrade and don't see this error anymore.
Tried with suggestions:
v0.9.1: Define 3rd variable: value3 = value1 orelse value2; and print it
v0.10: upgrade and don't see this error anymore.

How to get pointer to pointer in LLVM?

C++ code:
int main() {
int* k = new int(0);
int* j = k;
return 0;
}
clang++ -S -emit-llvm :
define dso_local i32 #main() #0 {
%1 = alloca i32, align 4
%2 = alloca i32*, align 8
%3 = alloca i32*, align 8
store i32 0, i32 *%1, align 4
%4 = call i8* #_Znwm(i64 4) #2
%5 = bitcast i8* %4 to i32*
store i32 0, i32* %5, align 4
store i32* %5, i32** %2, align 8
%6 = load i32*, i32** %2, align 8
store i32 *%6, i32** %3, align 8
ret i32 0
}
The question is about
store i32* %5, i32** %2, align 8
How is it possible to get i32** from %2(i32*) without generating additional LLVMValue like (pseudocode):
%starstar = alloca(i32**)
store(%2, %starstar)
I do not see any bitcasts or something like this either.
%2 was i32* and then it is i32** in the store instruction.
I would like to know how.
Any help is appreciated.
%2 was i32* and then it is i32** in the store instruction.
%2 was never i32*. alloca T allocates memory for a value of type T and then returns a pointer to that memory. So the type of alloca T is T*, meaning the type of %2 in your code is i32** and the type of %1 is i32*.

How to save the variable name when use clang to generate llvm ir?

I generate ir by use 'clang -S -emit-llvm test.c'.
int main(int argc, char **argv)
{
int* a=0;
a=(int *)malloc(sizeof(int));
printf("hello world\n");
return 0;
}
and this is the ir:
define i32 #main(i32, i8**) #0 {
%3 = alloca i32, align 4
%4 = alloca i32, align 4
%5 = alloca i8**, align 8
%6 = alloca i32*, align 8
store i32 0, i32* %3, align 4
store i32 %0, i32* %4, align 4
store i8** %1, i8*** %5, align 8
store i32* null, i32** %6, align 8
%7 = call noalias i8* #malloc(i64 4) #3
%8 = bitcast i8* %7 to i32*
store i32* %8, i32** %6, align 8
%9 = call i32 (i8*, ...) #printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* #.str, i32 0, i32 0))
ret i32 0
}
how can I make the variable name remain unchanged,like a still %a ,not %3?
Actually dropping of variable names is a feature and needs to be activated with -discard-value-names. Clang in a release build does this by its own (a self compiled clang in debug mode not).
You can circumvent it with
clang <your-command-line> -###
Then copy the output and drop -discard-value-names.
Newer clang version (since 7) expose the flag to the normal command line:
clang -fno-discard-value-names <your-command-line>
Source
There is not such way. The variable names in LLVM IR are merely for debugging only and also there is certainly no way to preserve them when the code is converted to full SSA form.
If you need to preserve source code information consider using debug info.

Can LLVM execute bitcode on ios (arm64)?

I'm trying to execute LLVM bitcode on ios device.
I've compiled bitcode file using clang -emit-llvm -S -c ./test.cpp -o .test.ll -target arm64-apple-ios7.1 targeted to arm64 device. Starting LLVM/Clang release 3.5 supports ios arm64 devices. Then i'm trying to invoke the code using MCJit'ter and getting exception:
http://llvm.org/bugs/show_bug.cgi?id=21012
Is it ios OS/device restriction or LLVM/Clang bug?
I'm testing on iPad Air with ios 7.1.
PS. Bitcode looks correct and targeted to correct target:
; ModuleID = './test.cpp'
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple0ios7.1"
#.str = private unnamed_addr constant [12 x i8] c"hello world\00", align 1
; Function Attrs: nounwind
define i32 #main(i32 %argc, i8** %argv) #0 {
entry:
%retval = alloca i32, align 4
%argc.addr = alloca i32, align 4
%argv.addr = alloca i8**, align 8
%c = alloca i8*, align 8
%a = alloca i32, align 4
%b = alloca i32, align 4
store i32 0, i32* %retval
store i32 %argc, i32* %argc.addr, align 4
store i8** %argv, i8*** %argv.addr, align 8
store i8* getelementptr inbounds ([12 x i8]* #.str, i32 0, i32 0), i8** %c, align 8
store i32 1, i32* %a, align 4
%0 = load i32* %a, align 4
%add = add nsw i32 %0, 6
store i32 %add, i32* %b, align 4
ret i32 3
}
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.ident = !{!0}
!0 = metadata !{metadata !"clang version 3.6.0 (trunk 218116) (llvm/trunk 218115)"}
It was compiled by LLVM/Clang (trunk after 3.5 release) from simple source code:
int main(int argc, const char **argv) {
const char *c = "hello world";
int a = 1;
int b = a + 6;
return 3;
}
PPS. Interpreter code is almost lli tool code with the next arguments:
return llvm_interpret(
InputFile,
std::vector<std::string>(), // argv
false, // ForceInterpreter
true, // UseMCJIT
false, // DebugIR
false, // RemoteMCJIT
"", // ChildExecPath
' ', // OptLevel
std::string(/*"arm64-apple-ios7.1"*/), // TargetTriple
std::string(/*"arm64"*/), // MArch
std::string("generic"), // MCPU
std::vector<std::string>(), // MAttrs
"main", // EntryFunc
std::vector<std::string>(), // ExtraModules
std::vector<std::string>(), // ExtraObjects
std::vector<std::string>(), // ExtraArchives
false, // EnableCacheManager
std::string(), // ObjectCacheDir
std::string(), // FakeArgv0
false, // DisableCoreFiles
false, // NoLazyCompilation
Reloc::Static, // RelocModel (default is Reloc::PIC_)
CodeModel::JITDefault, // CMModel (default is CodeModel::JITDefault)
false, // GenerateSoftFloatCalls
FloatABI::Default, // FloatABIForCalls
false, // EmitJitDebugInfo
false // EmitJitDebugInfoToDisk
);
Exception:
rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue(),
(char **)GVTOP(ArgValues[1])));
0x4a18000: .long 0xd10083ff ; unknown opcode
0x4a18004: stmdbhs r3, {r5, r6, r7, r8, r9, r10, r11, r12, sp, lr}
0x4a18008: .long 0xf9000be1 ; unknown opcode
0x4a1800c: andls r0, r0, r8
0x4a18010: .long 0xf9401908 ; unknown opcode
0x4a18014: andlo r0, r0, #0xa4000003
0x4a18018: andlo r0, r0, #0x3a800
0x4a1801c: andlo r0, r0, #0x3800000

Compile with no optimization in clang

Short question: how to compile with clang with no code optimization? -O0 is not working.
Long question:
I'm learning code optimization and LLVM in particular. I'm writing small examples, compiling them and then running just one optimization at a time, to analyze what it changes. For example, to test Dead Code Elimination, I tried this:
int main() {
int a = 20 + 30;
int b = 25; /* Assignment to dead variable */
int c;
c = a << 2;
return c;
b = 24; /* Unreachable code */
return 0;
}
However, when I compile it with
clang -S -O0 -emit-llvm foo.c
The last two lines of my C code do not show up in the IR code (below). Also, the 20 + 30 is already being calculated to 50. So there's some optimization going on here, even though I'm using -O0.
; ModuleID = 'hello.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-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define i32 #main() #0 {
entry:
%retval = alloca i32, align 4
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
store i32 0, i32* %retval
store i32 50, i32* %a, align 4
store i32 25, i32* %b, align 4
%0 = load i32* %a, align 4
%shl = shl i32 %0, 2
store i32 %shl, i32* %c, align 4
%1 = load i32* %c, align 4
ret i32 %1
}
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.ident = !{!0}
!0 = metadata !{metadata !"clang version 3.4 (trunk 192936)"}

Resources