You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is ok, as the only use of MainInt0 is to compare its address to another:
for.cond.for.end_crit_edge: ; preds = %for.bod for.cond.for.end_crit_edge: ; preds = %for.bod
%conv6 = zext i8 %add to i32 %conv6 = zext i8 %add to i32
%cmp4 = icmp ne ptr %MainInt0, %2 %cmp4 = icmp ne ptr %MainInt0, %2
%conv.i = zext i1 %cmp4 to i8 %conv.i = zext i1 %cmp4 to i8
store ptr %MainInt0, ptr @GlobIntPtr, align 8, !tbaa !14 store ptr %MainInt0, ptr @GlobIntPtr, align 8, !tbaa !14
store i8 %conv.i, ptr @Res, align 1, !tbaa !4 store i8 %conv.i, ptr @Res, align 1, !tbaa !4
store i32 %conv6, ptr @b, align 4, !tbaa !7 store i32 %conv6, ptr @b, align 4, !tbaa !7
br label %for.end br label %for.end
It then seems to me that this leads to problems with StackColoring, which marks the stack slot as dead and seemingly just replaces the use of it with another one, which can't be good:
# *** IR Dump After Merge disjoint stack slots (stack-coloring) ***: # *** IR Dump After Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function main: IsSSA, TracksLiveness # Machine code for function main: IsSSA, TracksLiveness
Frame Objects: Frame Objects:
fi#0: dead | fi#0: size=4, align=4, at location [SP]
fi#1: size=8, align=8, at location [SP] fi#1: size=8, align=8, at location [SP]
fi#2: size=56, align=8, at location [SP] fi#2: size=56, align=8, at location [SP]
...
bb.2.for.body: bb.2.for.body:
; predecessors: %bb.1, %bb.2 ; predecessors: %bb.1, %bb.2
successors: %bb.2(0x7c000000), %bb.3(0x04000000); %bb.2(96.88%), % successors: %bb.2(0x7c000000), %bb.3(0x04000000); %bb.2(96.88%), %
%15:gr64bit = LA %stack.1.o, 0, $noreg %15:gr64bit = LA %stack.1.o, 0, $noreg
STG killed %15:gr64bit, %1:addr64bit, 0, $noreg :: (store (s64) in STG killed %15:gr64bit, %1:addr64bit, 0, $noreg :: (store (s64) in
%2:gr64bit = LG %stack.2.n, 0, $noreg :: (dereferenceable load (s6 %2:gr64bit = LG %stack.2.n, 0, $noreg :: (dereferenceable load (s6
TMLMux %0:grx32bit, 255, implicit-def $cc TMLMux %0:grx32bit, 255, implicit-def $cc
BRC 15, 8, %bb.2, implicit $cc BRC 15, 8, %bb.2, implicit $cc
J %bb.3 J %bb.3
bb.3.for.cond.for.end_crit_edge: bb.3.for.cond.for.end_crit_edge:
; predecessors: %bb.2 ; predecessors: %bb.2
successors: %bb.4(0x80000000); %bb.4(100.00%) successors: %bb.4(0x80000000); %bb.4(100.00%)
%16:gr32bit = LLCRMux %0:grx32bit %16:gr32bit = LLCRMux %0:grx32bit
%17:gr64bit = LA %stack.1.o, 0, $noreg | %17:gr64bit = LA %stack.0.MainInt0, 0, $noreg
CGR %17:gr64bit, %2:gr64bit, implicit-def $cc CGR %17:gr64bit, %2:gr64bit, implicit-def $cc
It seems FI#0 should not be marked dead as there is a use of it, even just for comparing the final address with another.
It seems that StackColoring marks a stack slot as dead even though it has its address taken and used.
The test case has enclosing braces and fails at -Os, but if I remove the braces the problem disapears:
wrong0.i: <> with braces removed
clang -march=z15 -Os wrong0.i -o a.out
The generated IRs are identical, except for the lifetime.end intrinsics at the end:
This difference causes DSEPass to remove the initialization of MainInt0 with the reduced lifetime:
This is ok, as the only use of MainInt0 is to compare its address to another:
It then seems to me that this leads to problems with StackColoring, which marks the stack slot as dead and seemingly just replaces the use of it with another one, which can't be good:
It seems FI#0 should not be marked dead as there is a use of it, even just for comparing the final address with another.
@mohammed-nurulhoque @kazutakahirata @nikic @uweigand @fhahn
The text was updated successfully, but these errors were encountered: