Skip to content

Commit 4c5e4aa

Browse files
committed
Revert "[SCCP] Do not replace deref'able ptr with un-deref'able one."
This reverts commit 3542fee. This seems to be causing issues with a sanitizer build http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/21677
1 parent 3542fee commit 4c5e4aa

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

llvm/lib/Transforms/Scalar/SCCP.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "llvm/Analysis/DomTreeUpdater.h"
3232
#include "llvm/Analysis/GlobalsModRef.h"
3333
#include "llvm/Analysis/InstructionSimplify.h"
34-
#include "llvm/Analysis/Loads.h"
3534
#include "llvm/Analysis/TargetLibraryInfo.h"
3635
#include "llvm/Analysis/ValueLattice.h"
3736
#include "llvm/Analysis/ValueLatticeUtils.h"
@@ -178,8 +177,6 @@ class SCCPSolver : public InstVisitor<SCCPSolver> {
178177
LLVMContext &Ctx;
179178

180179
public:
181-
const DataLayout &getDataLayout() const { return DL; }
182-
183180
void addAnalysis(Function &F, AnalysisResultsForFn A) {
184181
AnalysisResults.insert({&F, std::move(A)});
185182
}
@@ -1633,14 +1630,6 @@ static bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V) {
16331630
return false;
16341631
}
16351632

1636-
// Do not propagate equality of a un-dereferenceable pointer.
1637-
// FIXME: Currently this only treats pointers one past the last element
1638-
// for array types. Should probably be much stricter.
1639-
if (Const->getType()->isPointerTy() &&
1640-
!canReplacePointersIfEqual(V, Const, Solver.getDataLayout(),
1641-
dyn_cast<Instruction>(V)))
1642-
return false;
1643-
16441633
LLVM_DEBUG(dbgs() << " Constant: " << *Const << " = " << *V << '\n');
16451634

16461635
// Replaces all of the uses of a variable with uses of the constant.

llvm/test/Transforms/SCCP/apint-bigint2.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ define i101 @large_aggregate_2() {
5151
}
5252

5353
; CHECK-LABEL: @index_too_large
54-
; CHECK-NEXT: %ptr1 = getelementptr [6 x i101], [6 x i101]* @Y, i32 0, i32 -1
55-
; CHECK-NEXT: %ptr2 = getelementptr i101, i101* %ptr1, i101 9224497936761618431
56-
; CHECK-NEXT: store i101* %ptr2, i101** undef
57-
; CHECK-NEXT: ret void
54+
; CHECK-NEXT: store i101* getelementptr (i101, i101* getelementptr ([6 x i101], [6 x i101]* @Y, i32 0, i32 -1), i101 9224497936761618431), i101** undef
55+
; CHECK-NEXT: ret void
5856
define void @index_too_large() {
5957
%ptr1 = getelementptr [6 x i101], [6 x i101]* @Y, i32 0, i32 -1
6058
%ptr2 = getelementptr i101, i101* %ptr1, i101 9224497936761618431

llvm/test/Transforms/SCCP/indirectbr.ll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ BB1:
3131
define void @indbrtest2() {
3232
; CHECK-LABEL: @indbrtest2(
3333
; CHECK-NEXT: entry:
34-
; CHECK-NEXT: [[B:%.*]] = inttoptr i64 ptrtoint (i8* blockaddress(@indbrtest2, [[BB1:%.*]]) to i64) to i8*
35-
; CHECK-NEXT: [[C:%.*]] = bitcast i8* [[B]] to i8*
36-
; CHECK-NEXT: br label [[BB1]]
34+
; CHECK-NEXT: br label [[BB1:%.*]]
3735
; CHECK: BB1:
3836
; CHECK-NEXT: call void @BB1_f()
3937
; CHECK-NEXT: ret void

llvm/test/Transforms/SCCP/replace-dereferenceable-ptr-with-undereferenceable.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define i32 @eq_undereferenceable(i32* %p) {
1111
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[P:%.*]], getelementptr inbounds (i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @x, i64 0, i64 0), i64 1)
1212
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
1313
; CHECK: if.then:
14-
; CHECK-NEXT: store i32 2, i32* [[P]], align 4
14+
; CHECK-NEXT: store i32 2, i32* getelementptr inbounds (i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @x, i64 0, i64 0), i64 1), align 4
1515
; CHECK-NEXT: br label [[IF_END]]
1616
; CHECK: if.end:
1717
; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @y, i64 0, i64 0), align 4
@@ -65,7 +65,7 @@ define i1 @eq_undereferenceable_cmp_simp(i32* %p) {
6565
; CHECK-NEXT: [[CMP_0:%.*]] = icmp eq i32* [[P:%.*]], getelementptr inbounds (i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @x, i64 0, i64 0), i64 1)
6666
; CHECK-NEXT: br i1 [[CMP_0]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
6767
; CHECK: if.then:
68-
; CHECK-NEXT: store i32 2, i32* [[P]], align 4
68+
; CHECK-NEXT: store i32 2, i32* getelementptr inbounds (i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @x, i64 0, i64 0), i64 1), align 4
6969
; CHECK-NEXT: ret i1 true
7070
; CHECK: if.end:
7171
; CHECK-NEXT: [[CMP_2:%.*]] = icmp eq i32* [[P]], getelementptr inbounds (i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @x, i64 0, i64 0), i64 1)

0 commit comments

Comments
 (0)