Skip to content

Commit

Permalink
Revert "[SCCP] Do not replace deref'able ptr with un-deref'able one."
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fhahn committed Sep 3, 2020
1 parent 3542fee commit 4c5e4aa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
11 changes: 0 additions & 11 deletions llvm/lib/Transforms/Scalar/SCCP.cpp
Expand Up @@ -31,7 +31,6 @@
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueLattice.h"
#include "llvm/Analysis/ValueLatticeUtils.h"
Expand Down Expand Up @@ -178,8 +177,6 @@ class SCCPSolver : public InstVisitor<SCCPSolver> {
LLVMContext &Ctx;

public:
const DataLayout &getDataLayout() const { return DL; }

void addAnalysis(Function &F, AnalysisResultsForFn A) {
AnalysisResults.insert({&F, std::move(A)});
}
Expand Down Expand Up @@ -1633,14 +1630,6 @@ static bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V) {
return false;
}

// Do not propagate equality of a un-dereferenceable pointer.
// FIXME: Currently this only treats pointers one past the last element
// for array types. Should probably be much stricter.
if (Const->getType()->isPointerTy() &&
!canReplacePointersIfEqual(V, Const, Solver.getDataLayout(),
dyn_cast<Instruction>(V)))
return false;

LLVM_DEBUG(dbgs() << " Constant: " << *Const << " = " << *V << '\n');

// Replaces all of the uses of a variable with uses of the constant.
Expand Down
6 changes: 2 additions & 4 deletions llvm/test/Transforms/SCCP/apint-bigint2.ll
Expand Up @@ -51,10 +51,8 @@ define i101 @large_aggregate_2() {
}

; CHECK-LABEL: @index_too_large
; CHECK-NEXT: %ptr1 = getelementptr [6 x i101], [6 x i101]* @Y, i32 0, i32 -1
; CHECK-NEXT: %ptr2 = getelementptr i101, i101* %ptr1, i101 9224497936761618431
; CHECK-NEXT: store i101* %ptr2, i101** undef
; CHECK-NEXT: ret void
; CHECK-NEXT: store i101* getelementptr (i101, i101* getelementptr ([6 x i101], [6 x i101]* @Y, i32 0, i32 -1), i101 9224497936761618431), i101** undef
; CHECK-NEXT: ret void
define void @index_too_large() {
%ptr1 = getelementptr [6 x i101], [6 x i101]* @Y, i32 0, i32 -1
%ptr2 = getelementptr i101, i101* %ptr1, i101 9224497936761618431
Expand Down
4 changes: 1 addition & 3 deletions llvm/test/Transforms/SCCP/indirectbr.ll
Expand Up @@ -31,9 +31,7 @@ BB1:
define void @indbrtest2() {
; CHECK-LABEL: @indbrtest2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[B:%.*]] = inttoptr i64 ptrtoint (i8* blockaddress(@indbrtest2, [[BB1:%.*]]) to i64) to i8*
; CHECK-NEXT: [[C:%.*]] = bitcast i8* [[B]] to i8*
; CHECK-NEXT: br label [[BB1]]
; CHECK-NEXT: br label [[BB1:%.*]]
; CHECK: BB1:
; CHECK-NEXT: call void @BB1_f()
; CHECK-NEXT: ret void
Expand Down
Expand Up @@ -11,7 +11,7 @@ define i32 @eq_undereferenceable(i32* %p) {
; 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)
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: store i32 2, i32* [[P]], align 4
; 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
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @y, i64 0, i64 0), align 4
Expand Down Expand Up @@ -65,7 +65,7 @@ define i1 @eq_undereferenceable_cmp_simp(i32* %p) {
; 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)
; CHECK-NEXT: br i1 [[CMP_0]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: store i32 2, i32* [[P]], align 4
; 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
; CHECK-NEXT: ret i1 true
; CHECK: if.end:
; 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)
Expand Down

0 comments on commit 4c5e4aa

Please sign in to comment.