[llvm] [Inline] Remove bitcast handling in `CallAnalyzer::stripAndComputeInBoundsConstantOffsets` (PR #97988)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 7 22:08:29 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Yingwei Zheng (dtcxzyw)
<details>
<summary>Changes</summary>
As we are now using opaque pointers, bitcast handling is no longer needed.
Closes https://github.com/llvm/llvm-project/issues/97590.
---
Full diff: https://github.com/llvm/llvm-project/pull/97988.diff
2 Files Affected:
- (modified) llvm/lib/Analysis/InlineCost.cpp (-2)
- (added) llvm/test/Transforms/Inline/pr97590.ll (+28)
``````````diff
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 94aa8ecf6f558..345e5a0195201 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2644,8 +2644,6 @@ ConstantInt *CallAnalyzer::stripAndComputeInBoundsConstantOffsets(Value *&V) {
if (!GEP->isInBounds() || !accumulateGEPOffset(*GEP, Offset))
return nullptr;
V = GEP->getPointerOperand();
- } else if (Operator::getOpcode(V) == Instruction::BitCast) {
- V = cast<Operator>(V)->getOperand(0);
} else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
if (GA->isInterposable())
break;
diff --git a/llvm/test/Transforms/Inline/pr97590.ll b/llvm/test/Transforms/Inline/pr97590.ll
new file mode 100644
index 0000000000000..2c2aeb486c49f
--- /dev/null
+++ b/llvm/test/Transforms/Inline/pr97590.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=inline < %s | FileCheck %s
+
+; Check that we don't crash when computing the
+; base pointer of `bitcast <1 x ptr> to ptr`
+
+define void @caller(<1 x ptr> %x) {
+; CHECK-LABEL: define void @caller(
+; CHECK-SAME: <1 x ptr> [[X:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: [[P:%.*]] = bitcast <1 x ptr> [[X]] to ptr
+; CHECK-NEXT: ret void
+;
+entry:
+ %p = bitcast <1 x ptr> %x to ptr
+ call void @callee(ptr %p)
+ ret void
+}
+
+define void @callee(ptr %p) {
+; CHECK-LABEL: define void @callee(
+; CHECK-SAME: ptr [[P:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: ret void
+;
+entry:
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/97988
More information about the llvm-commits
mailing list