-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[DropUnnecessaryAssumes] Don't drop public_type_test intrinsic #166034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-llvm-transforms Author: Hassnaa Hamdi (hassnaaHamdi) ChangesFull diff: https://github.com/llvm/llvm-project/pull/166034.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/DropUnnecessaryAssumes.cpp b/llvm/lib/Transforms/Scalar/DropUnnecessaryAssumes.cpp
index 89980d54ee897..a577f517d1e89 100644
--- a/llvm/lib/Transforms/Scalar/DropUnnecessaryAssumes.cpp
+++ b/llvm/lib/Transforms/Scalar/DropUnnecessaryAssumes.cpp
@@ -122,7 +122,8 @@ DropUnnecessaryAssumesPass::run(Function &F, FunctionAnalysisManager &FAM) {
Value *Cond = Assume->getArgOperand(0);
// Don't drop type tests, which have special semantics.
- if (match(Cond, m_Intrinsic<Intrinsic::type_test>()))
+ if (match(Cond, m_Intrinsic<Intrinsic::type_test>()) ||
+ match(Cond, m_Intrinsic<Intrinsic::public_type_test>()))
continue;
SmallVector<Value *> Affected;
diff --git a/llvm/test/Transforms/DropUnnecessaryAssumes/basic.ll b/llvm/test/Transforms/DropUnnecessaryAssumes/basic.ll
index 8a6f60ba7a204..87aed77d06ef8 100644
--- a/llvm/test/Transforms/DropUnnecessaryAssumes/basic.ll
+++ b/llvm/test/Transforms/DropUnnecessaryAssumes/basic.ll
@@ -184,6 +184,18 @@ define void @type_test(ptr %x) {
ret void
}
+define void @public_type_test(ptr %x) {
+; CHECK-LABEL: define void @public_type_test(
+; CHECK-SAME: ptr [[X:%.*]]) {
+; CHECK-NEXT: [[TEST:%.*]] = call i1 @llvm.public.type.test(ptr [[X]], metadata !"typeid")
+; CHECK-NEXT: call void @llvm.assume(i1 [[TEST]])
+; CHECK-NEXT: ret void
+;
+ %test = call i1 @llvm.public.type.test(ptr %x, metadata !"typeid")
+ call void @llvm.assume(i1 %test)
+ ret void
+}
+
define void @multiple_dead_conds(i32 %x) {
; CHECK-LABEL: define void @multiple_dead_conds(
; CHECK-SAME: i32 [[X:%.*]]) {
|
|
@nikic Doesn't the name of 'basic.ll' file seem a bit weird? :'D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It is fine for a newly added pass :)
|
|
@dtcxzyw Thanks for the clarification and the review :)) |
…166034) Don't drop `assume` intrinsic when it's using `public_type_test ` intrinsic, as it could be used by devirtualization.
Don't drop
assumeintrinsic when it's usingpublic_type_testintrinsic,as it could be used by devirtualization.