Skip to content

Instantly share code, notes, and snippets.

@Aatch
Last active December 18, 2015 21:29
Show Gist options
  • Save Aatch/5847420 to your computer and use it in GitHub Desktop.
Save Aatch/5847420 to your computer and use it in GitHub Desktop.
Optimization issues
; Function Attrs: uwtable
define internal fastcc void @_ZN4main16_d7d397690bb61803_00E() #1 {
static_allocas:
%tmp.i = alloca { i64, %tydesc*, {}*, {}*, { i64* } }, align 8
%tmp5 = alloca i64, align 8
%tmp13 = bitcast i64* %tmp5 to i8*
call void @llvm.lifetime.start(i64 8, i8* %tmp13)
store i64 543210, i64* %tmp5, align 8
%0 = bitcast { i64, %tydesc*, {}*, {}*, { i64* } }* %tmp.i to i8*
call void @llvm.lifetime.start(i64 40, i8* %0)
%tmp6.i = bitcast { i64, %tydesc*, {}*, {}*, { i64* } }* %tmp.i to { i64, %tydesc*, i8*, i8*, i8 }*
%tmp7.i = getelementptr inbounds { i64, %tydesc*, {}*, {}*, { i64* } }* %tmp.i, i64 0, i32 0
store i64 305419896, i64* %tmp7.i, align 8
%tmp8.i1 = getelementptr inbounds { i64, %tydesc*, {}*, {}*, { i64* } }* %tmp.i, i64 0, i32 4, i32 0
store i64* %tmp5, i64** %tmp8.i1, align 8
call void @llvm.lifetime.end(i64 40, i8* %0)
%tmp12.i = call {} @_ZN4test4anon4anon12expr_fn_2958E({ i64, %tydesc*, i8*, i8*, i8 }* %tmp6.i)
call void @llvm.lifetime.end(i64 8, i8* %tmp13)
ret void
}
;*** IR Dump After Dead Store Elimination ***
; Function Attrs: uwtable
define internal fastcc void @_ZN4main16_d7d397690bb61803_00E() #1 {
static_allocas:
%tmp.i = alloca { i64, %tydesc*, {}*, {}*, { i64* } }, align 8
%tmp5 = alloca i64, align 8
%tmp13 = bitcast i64* %tmp5 to i8*
call void @llvm.lifetime.start(i64 8, i8* %tmp13)
%0 = bitcast { i64, %tydesc*, {}*, {}*, { i64* } }* %tmp.i to i8*
call void @llvm.lifetime.start(i64 40, i8* %0)
%tmp6.i = bitcast { i64, %tydesc*, {}*, {}*, { i64* } }* %tmp.i to { i64, %tydesc*, i8*, i8*, i8 }*
call void @llvm.lifetime.end(i64 40, i8* %0)
%tmp12.i = call {} @_ZN4test4anon4anon12expr_fn_2958E({ i64, %tydesc*, i8*, i8*, i8 }* %tmp6.i)
call void @llvm.lifetime.end(i64 8, i8* %tmp13)
ret void
}
; So for some reason, the store to %tmp5 and the store to the ref-count are eliminated as dead.
; I can't see why though.
;*** IR Dump After Simplify the CFG ***
; Function Attrs: uwtable
define internal fastcc void @_ZN4main16_d7d397690bb61803_00E() #1 {
static_allocas:
%0 = alloca {}, align 8
%1 = bitcast {}* %0 to i8*
call void @llvm.lifetime.start(i64 0, i8* %1)
%2 = load i64** undef, align 8
store i64 1, i64* %2, align 8
call void @llvm.lifetime.end(i64 0, i8* %1)
ret void
}
;*** IR Dump After Combine redundant instructions ***
; Function Attrs: uwtable
define internal fastcc void @_ZN4main16_d7d397690bb61803_00E() #1 {
static_allocas:
store i64* undef, i64** null, align 536870912 ; How does it get this? (536870912 = 0x20000000)
store i64 1, i64* undef, align 8
ret void
}
;*** IR Dump After Tail Call Elimination ***
; Function Attrs: uwtable
define internal fastcc void @_ZN4main16_d7d397690bb61803_00E() #1 {
static_allocas:
store i64* undef, i64** null, align 536870912
store i64 1, i64* undef, align 8
ret void
}
;*** IR Dump After Simplify the CFG ***
; Function Attrs: uwtable
define internal fastcc void @_ZN4main16_d7d397690bb61803_00E() #1 {
static_allocas:
call void @llvm.trap()
unreachable
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment