[PATCH] D96881: Avoid Bitcast-GEP fusion for void pointers
mohammad hadi jooybar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 9 13:37:28 PST 2021
hjooybar2 added a comment.
@nikic By making a little modification in my changeset, now none of existing tests are failing. I added a new test to show how the code is supposed to look like.
Here is how newly added test would have looked like with the main branch:
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CALL:%.*]] = call noalias dereferenceable_or_null(16) i8* @malloc(i64 16)
; CHECK-NEXT: [[G3:%.*]] = getelementptr i8, i8* [[CALL]], i64 12
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i8* [[G3]] to i32*
; CHECK-NEXT: [[A_C:%.*]] = load i32, i32* [[TMP0]], align 4
; CHECK-NEXT: ret i32 [[A_C]]
;
My modification causes the `InstCombine` to behave differently between `Alloca` and `malloc` like functions. It actually makes sense, since `Alloca` usually has type but `malloc` is always `void*`
In conclusion, by latest update, all tests passed successfully and a new test is added to show how the optimization looks like.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96881/new/
https://reviews.llvm.org/D96881
More information about the llvm-commits
mailing list