[PATCH] D106017: [InstCombine] Look through invariant group intrinsics when removing malloc
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 14 14:02:29 PDT 2021
aeubanks created this revision.
aeubanks added reviewers: Prazek, rnk.
Herald added a subscriber: hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fixes some regressions with -fstrict-vtable-pointers in llvm-test-suite.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106017
Files:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/malloc-free-delete.ll
Index: llvm/test/Transforms/InstCombine/malloc-free-delete.ll
===================================================================
--- llvm/test/Transforms/InstCombine/malloc-free-delete.ll
+++ llvm/test/Transforms/InstCombine/malloc-free-delete.ll
@@ -149,7 +149,7 @@
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i8* [[FOO:%.*]], null
; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
; CHECK: if.then:
-; CHECK-NEXT: tail call void @_ZdlPv(i8* [[FOO]]) #[[ATTR8:[0-9]+]]
+; CHECK-NEXT: tail call void @_ZdlPv(i8* [[FOO]]) #[[ATTR10:[0-9]+]]
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: ret void
@@ -352,7 +352,7 @@
define void @test11() {
; CHECK-LABEL: @test11(
-; CHECK-NEXT: [[CALL:%.*]] = call dereferenceable(8) i8* @_Znwm(i64 8) #[[ATTR8]]
+; CHECK-NEXT: [[CALL:%.*]] = call dereferenceable(8) i8* @_Znwm(i64 8) #[[ATTR10]]
; CHECK-NEXT: call void @_ZdlPv(i8* nonnull [[CALL]])
; CHECK-NEXT: ret void
;
@@ -418,7 +418,7 @@
; TODO: free call marked no-free -> %foo must be null
define void @test15(i8* %foo) {
; CHECK-LABEL: @test15(
-; CHECK-NEXT: call void @free(i8* [[FOO:%.*]]) #[[ATTR6:[0-9]+]]
+; CHECK-NEXT: call void @free(i8* [[FOO:%.*]]) #[[ATTR7:[0-9]+]]
; CHECK-NEXT: ret void
;
call void @free(i8* %foo) nofree
@@ -434,3 +434,18 @@
call void @free(i8* %foo)
ret void
}
+
+declare i8* @llvm.launder.invariant.group(i8*)
+declare i8* @llvm.strip.invariant.group(i8*)
+
+define void @test17() {
+; CHECK-LABEL: @test17(
+; CHECK-NEXT: ret void
+;
+ %nw1 = call i8* @_Znwm(i64 32) builtin
+ %nw2 = call i8* @llvm.launder.invariant.group(i8* %nw1)
+ %nw3 = call i8* @llvm.strip.invariant.group(i8* %nw2)
+ store i8 1, i8* %nw3
+ call void @_ZdlPv(i8* %nw2) builtin
+ ret void
+}
Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2600,6 +2600,11 @@
case Intrinsic::objectsize:
Users.emplace_back(I);
continue;
+ case Intrinsic::launder_invariant_group:
+ case Intrinsic::strip_invariant_group:
+ Users.emplace_back(I);
+ Worklist.push_back(I);
+ continue;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106017.358743.patch
Type: text/x-patch
Size: 2420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210714/6491afa4/attachment.bin>
More information about the llvm-commits
mailing list