Problems about insert a call in MIR Lower Phase

When I try to insert a call in MIR Lower phase, the compile process failed.

The message is follows:

Phoenix Assertion Failure: d:\phoenixrdkmarch2007\src\phx\ir\ir-safety.cpp, Line
2183
(this->Opcode->Exceptions == Safety::Exceptions::None) || this->IsSafetyOptimi
zed : Safety info missing on instruction
CALL __imp__testcall,
&?p@@3HA, 4, 761(0x000002f9) #23

and sometimes, here's another associated assertion like follows:
Phoenix Assertion Failure:

d:\phoenixrdkmarch2007\src\phx\eh\eh.cpp, Line 259
isChanged == false : Instruction didn't have a handler label
CALL __imp__testcall, tv423-, 8, 705(0x000002c1), $L5(EH)

Noted these problems seems only occured when there are exception handling in the source code(such as try...catch...), I think it may be something wrong with the SafeTag and the ExceptionHandler.

My code is like this:

//Is it right to set safetyTag like this?

Phx.Safety.Tag safetyTag = funcUnit.SafetyInfo.SafeTag;

Phx.IR.MemoryOperand opndCallTgt = Phx.IR.MemoryOperand.New

(funcUnit,funcSym.Type,funcSym, null,0,align, funcUnit.AliasInfo.NotAliasedMemoryTag, safetyTag);
Phx.IR.CallInstruction callInstr = Phx.IR.CallInstruction.New(funcUnit, Phx.Common.Opcode.Call, opndCallTgt);

//Should I set the EHHandler? And which value I should set?

Thanks very much.

[2015 byte] By [sunnymonkey] at [2008-2-5]
# 1

I'm following up with some people on the team. Will get back to you shortly.

Thanks,

KangSuGatlin at 2007-10-3 > top of Msdn Tech,Visual Studio,Phoenix...
# 2

Hi, I was able to get some response to this good question.

Here is the response:

We don't allow instructions to be inserted without making sure that safety information is current (especially instructions that can throw, like calls). SafeTag doesn’t have IsSafetyOptimized checked. He needs to set that bit manually. We expect call to always have info saying it can throw, so you need the bit otherwise. Once that is set, he should not have any EH handler problems (i.e. he shouldn't have any handlers on that instruction, unless they are for memory operands).

The second assert is related and is because the EH edge was added since the bit wasn’t there. Basically, I don't know why he has $L5 on the last call instruction listed.

Thanks,

KangSuGatlin at 2007-10-3 > top of Msdn Tech,Visual Studio,Phoenix...
# 3

Thanks for your reply. Smile

And I have sloved my problem by another way.

I construct the flowgraph without SSA Info, and find the related exception handler, and set the EH handler the right value.

Notice that there should be no SSA Info , otherwise more changes are needed. Maintain the coherence of the SSAInfo is very difficult.

sunnymonkey at 2007-10-3 > top of Msdn Tech,Visual Studio,Phoenix...

Visual Studio

Site Classified