Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 12db936

Browse files
author
Krzysztof Parzyszek
committed
[RDF] Handle undefined registers in RDF copy propagation
When updating the graph, make sure that new uses without reaching defs are handled correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267891 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 629af37 commit 12db936

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

lib/Target/Hexagon/RDFCopy.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,12 @@ bool CopyPropagation::run() {
218218
Op.setReg(SR.Reg);
219219
Op.setSubReg(SR.Sub);
220220
DFG.unlinkUse(UA, false);
221-
UA.Addr->linkToDef(UA.Id, DFG.addr<DefNode*>(RDefSR_SA));
221+
if (RDefSR_SA != 0) {
222+
UA.Addr->linkToDef(UA.Id, DFG.addr<DefNode*>(RDefSR_SA));
223+
} else {
224+
UA.Addr->setReachingDef(0);
225+
UA.Addr->setSibling(0);
226+
}
222227

223228
Changed = true;
224229
#ifndef NDEBUG
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
; RUN: llc -march=hexagon < %s
2+
; REQUIRES: asserts
3+
4+
target triple = "hexagon"
5+
6+
declare void @llvm.lifetime.start(i64, i8* nocapture) #0
7+
declare void @llvm.lifetime.end(i64, i8* nocapture) #0
8+
declare signext i16 @cat(i16 signext) #1
9+
declare void @danny(i16 signext, i16 signext, i16 signext, i16* nocapture readonly, i16 signext, i16* nocapture) #1
10+
declare void @sammy(i16* nocapture readonly, i16* nocapture readonly, i16* nocapture readonly, i32* nocapture, i16* nocapture, i16 signext, i16 signext, i16 signext) #1
11+
declare i8* @llvm.stacksave() #2
12+
declare void @llvm.stackrestore(i8*) #2
13+
14+
define i32 @fred(i16 signext %p0, i16 signext %p1, i16* nocapture readonly %p2, i16 signext %p3, i16* nocapture readonly %p4, i16* nocapture %p5) #1 {
15+
entry:
16+
%0 = tail call i8* @llvm.stacksave()
17+
%vla = alloca i16, i32 undef, align 8
18+
%call17 = call signext i16 @cat(i16 signext 1) #1
19+
br i1 undef, label %for.cond23.preheader, label %for.end47
20+
21+
for.cond23.preheader: ; preds = %for.end40, %entry
22+
%i.190 = phi i16 [ %inc46, %for.end40 ], [ 0, %entry ]
23+
br i1 undef, label %for.body27, label %for.end40
24+
25+
for.body27: ; preds = %for.body27, %for.cond23.preheader
26+
%indvars.iv = phi i32 [ %indvars.iv.next, %for.body27 ], [ 0, %for.cond23.preheader ]
27+
%call30 = call signext i16 @cat(i16 signext 7) #1
28+
%arrayidx32 = getelementptr inbounds i16, i16* %vla, i32 %indvars.iv
29+
store i16 %call30, i16* %arrayidx32, align 2
30+
%arrayidx37 = getelementptr inbounds i16, i16* undef, i32 %indvars.iv
31+
%indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
32+
%exitcond = icmp eq i16 undef, %p3
33+
br i1 %exitcond, label %for.end40, label %for.body27
34+
35+
for.end40: ; preds = %for.body27, %for.cond23.preheader
36+
call void @sammy(i16* nonnull undef, i16* undef, i16* %p4, i32* null, i16* undef, i16 signext undef, i16 signext undef, i16 signext undef) #1
37+
%inc46 = add nuw nsw i16 %i.190, 1
38+
%exitcond94 = icmp eq i16 %inc46, %call17
39+
br i1 %exitcond94, label %for.end47.loopexit, label %for.cond23.preheader
40+
41+
for.end47.loopexit: ; preds = %for.end40
42+
%.pre = load i16, i16* undef, align 2
43+
br label %for.end47
44+
45+
for.end47: ; preds = %for.end47.loopexit, %entry
46+
%1 = phi i16 [ %.pre, %for.end47.loopexit ], [ 0, %entry ]
47+
call void @danny(i16 signext %1, i16 signext %p0, i16 signext %p1, i16* %p2, i16 signext %p3, i16* %p5) #1
48+
call void @llvm.stackrestore(i8* %0)
49+
ret i32 undef
50+
}
51+
52+
53+
attributes #0 = { argmemonly nounwind }
54+
attributes #1 = { optsize }
55+
attributes #2 = { nounwind }

0 commit comments

Comments
 (0)