Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can you please upload the patch with full context (-U99999)?
llvm/lib/Transforms/Utils/DemoteRegToStack.cpp | ||
---|---|---|
100 | You can probably combine handlers and unwind dest by iterating over successors(CSI). | |
158 | Why does this insert a load before uses, rather than doing the same as in the previous function (insert load in each successor)? | |
llvm/test/Transforms/Reg2Mem/catchswitch-crach2.ll | ||
1 ↗ | (On Diff #477731) | Typo in file name: crach -> crash? |
8 ↗ | (On Diff #477731) | Can you please convert the test to use opaque pointers? This will remove these types. I'd also replace the invoke undef with an invoke of a real function, to avoid UB. Something like this: declare i32 @__CxxFrameHandler3(...) declare i64 @fn() define void @testreg2mem(ptr %_Val) personality ptr @__CxxFrameHandler3 { entry: %call.i166167 = invoke i64 @fn() to label %if.end56 unwind label %catch.dispatch if.end56: ; preds = %entry invoke void @"extfunc1"() to label %invoke.cont75 unwind label %catch.dispatch invoke.cont75: ; preds = %if.end56 unreachable catch.dispatch: ; preds = %if.end56, %entry %_State.3 = phi i32 [ undef, %if.end56 ], [ 0, %entry ] %0 = catchswitch within none [label %catch] unwind label %ehcleanup105 catch: ; preds = %catch.dispatch %1 = catchpad within %0 [ptr null, i32 64, ptr null] invoke void @"extfunc2"() [ "funclet"(token %1) ] to label %invoke.cont98 unwind label %ehcleanup105 invoke.cont98: ; preds = %catch catchret from %1 to label %if.end99 if.end99: ; preds = %invoke.cont98 %or.i = or i32 undef, %_State.3 unreachable ehcleanup105: ; preds = %catch, %catch.dispatch %2 = cleanuppad within none [] cleanupret from %2 unwind to caller } declare void @"extfunc1"() declare void @"extfunc2"() |
llvm/lib/Transforms/Utils/DemoteRegToStack.cpp | ||
---|---|---|
158 | Because otherwise we need another Map to record successor and the loadinst in it? |
Don't we need :
- Insert loadinst in each immediate successor, map each successor BasicBlock with the load inst
- For each user(which might not be inside the immediate successor), query the dominator tree, check which immediate successor dominates the user and replace the use with the loadinst in that block?
DemoteReg does the same already in U->replaceUsesOfWith(&I, V);, so I think we're all good here
LGTM with some nits.
llvm/lib/Transforms/Utils/DemoteRegToStack.cpp | ||
---|---|---|
100 | nit: Omit braces for single-line for. | |
152 | This should be just isa<>, you are not using CSI. | |
154 | nit: users -> Users. | |
158 | Okay, I get it now: If we insert in successor, we need to replace dominating uses. This is possible, but your way is much simpler. |
You can probably combine handlers and unwind dest by iterating over successors(CSI).