[AssumeBundles] preserve knowledge in DCE

Reviewers: jdoerfert

Reviewed By: jdoerfert

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77403
This commit is contained in:
Tyker 2020-04-14 11:57:19 +02:00
parent 086de7673e
commit 3bdfa966ec
2 changed files with 13 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/AssumeBundleBuilder.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
using namespace llvm;
@ -127,6 +128,7 @@ static bool DCEInstruction(Instruction *I,
return false;
salvageDebugInfo(*I);
salvageKnowledge(I);
// Null out all of the instruction's operands to see if any operand becomes
// dead as we go.

View File

@ -0,0 +1,11 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -dce -S --enable-knowledge-retention < %s | FileCheck %s
define void @test(i32* %P) {
; CHECK-LABEL: @test(
; CHECK-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[P:%.*]], i64 4), "nonnull"(i32* [[P]]) ]
; CHECK-NEXT: ret void
;
%a = load i32, i32* %P
ret void
}