Displaying 4 results from an estimated 4 matches for "sp_1_ptr".
2016 Feb 10
4
Memory Store/Load Optimization Issue (Emulating stack)
Thank you for the hint.
I adjusted the code and it works:
The code after replacing inttoptr with getelementptr:
define { i32, i32, i8* } @test(i32 %foo, i32 %bar, i8* %sp) {
entry:
; push foo (On "stack")
%sp_1 = getelementptr i8, i8* %sp, i32 -4
%sp_1_ptr = bitcast i8* %sp_1 to i32*
store i32 %foo, i32* %sp_1_ptr, align 4
; push bar
%sp_2 = getelementptr i8, i8* %sp_1, i32 -4
%sp_2_ptr = bitcast i8* %sp_2 to i32*
store i32 %bar, i32* %sp_2_ptr, align 4
; val1 = pop (val1 = bar)
%sp_3_ptr = bitcast i8* %sp_2 to i32*
%val1 = load i32...
2016 Feb 08
2
Memory Store/Load Optimization Issue (Emulating stack)
...emulate the "stack" as like on x86 when using push/pop so
afterwards I can use LLVM's optimizer passes to simplify (reduce junk) the
code.
The LLVM IR code:
define { i32, i32, i32 } @test(i32 %foo, i32 %bar, i32 %sp) {
; push foo (On "stack")
%sp_1 = sub i32 %sp, 4
%sp_1_ptr = inttoptr i32 %sp_1 to i32*
store i32 %foo, i32* %sp_1_ptr, align 4
; push bar
%sp_2 = sub i32 %sp_1, 4
%sp_2_ptr = inttoptr i32 %sp_2 to i32*
store i32 %bar, i32* %sp_2_ptr, align 4
; val1 = pop (val1 = bar)
%sp_3_ptr = inttoptr i32 %sp_2 to i32*
%val1 = load i32, i32* %sp_3_ptr...
2016 Feb 10
2
Memory Store/Load Optimization Issue (Emulating stack)
...x86 instructions with llvm-ir but as far as I understand that aliasing
rule, I am not sure if I am breaking that rule.
For example when translating this x86 code to llvm ir:
push eax
add esp, 2
push ecx
...
; push foo (On "stack")
%sp_1 = getelementptr i8, i8* %sp, i32 -4
%sp_1_ptr = bitcast i8* %sp_1 to i32*
store i32 %foo, i32* %sp_1_ptr, align 4
%sp_x = getelementptr i8, i8* %sp_1, i32 2
; push bar
%sp_2 = getelementptr i8, i8* %sp_x, i32 -4
%sp_2_ptr = bitcast i8* %sp_2 to i32*
store i32 %bar, i32* %sp_2_ptr, align 4
Both objects (eax, ecx) will overlap bec...
2016 Feb 12
2
Memory Store/Load Optimization Issue (Emulating stack)
...he code and it works:
>>
>> The code after replacing inttoptr with getelementptr:
>>
>> define { i32, i32, i8* } @test(i32 %foo, i32 %bar, i8* %sp) {
>> entry:
>> ; push foo (On "stack")
>> %sp_1 = getelementptr i8, i8* %sp, i32 -4
>> %sp_1_ptr = bitcast i8* %sp_1 to i32*
>> store i32 %foo, i32* %sp_1_ptr, align 4
>>
>> ; push bar
>> %sp_2 = getelementptr i8, i8* %sp_1, i32 -4
>> %sp_2_ptr = bitcast i8* %sp_2 to i32*
>> store i32 %bar, i32* %sp_2_ptr, align 4
>>
>> ; val1 = pop (...