-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AMDGPU] Handled G_UBSANTRAP GlobalIsel #134492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
515510f
b92d165
626119a
3445c01
7835b11
8322f92
3e4b6dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2103,7 +2103,7 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_, | |||||
| getActionDefinitionsBuilder({G_MEMCPY, G_MEMCPY_INLINE, G_MEMMOVE, G_MEMSET}) | ||||||
| .lower(); | ||||||
|
|
||||||
| getActionDefinitionsBuilder({G_TRAP, G_DEBUGTRAP}).custom(); | ||||||
| getActionDefinitionsBuilder({G_TRAP, G_DEBUGTRAP, G_UBSANTRAP}).custom(); | ||||||
|
|
||||||
| getActionDefinitionsBuilder({G_VASTART, G_VAARG, G_BRJT, G_JUMP_TABLE, | ||||||
| G_INDEXED_LOAD, G_INDEXED_SEXTLOAD, | ||||||
|
|
@@ -2221,7 +2221,9 @@ bool AMDGPULegalizerInfo::legalizeCustom( | |||||
| case TargetOpcode::G_TRAP: | ||||||
| return legalizeTrap(MI, MRI, B); | ||||||
| case TargetOpcode::G_DEBUGTRAP: | ||||||
| return legalizeDebugTrap(MI, MRI, B); | ||||||
| return legalizeDebugUbsanTrap(MI, MRI, B, TargetOpcode::G_DEBUGTRAP); | ||||||
| case TargetOpcode::G_UBSANTRAP: | ||||||
| return legalizeDebugUbsanTrap(MI, MRI, B, TargetOpcode::G_UBSANTRAP); | ||||||
| default: | ||||||
| return false; | ||||||
| } | ||||||
|
|
@@ -7023,22 +7025,26 @@ bool AMDGPULegalizerInfo::legalizeTrapHsa(MachineInstr &MI, | |||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| bool AMDGPULegalizerInfo::legalizeDebugTrap(MachineInstr &MI, | ||||||
| MachineRegisterInfo &MRI, | ||||||
| MachineIRBuilder &B) const { | ||||||
| bool AMDGPULegalizerInfo::legalizeDebugUbsanTrap(MachineInstr &MI, | ||||||
| MachineRegisterInfo &MRI, | ||||||
| MachineIRBuilder &B, | ||||||
| unsigned int Opcode) const { | ||||||
| // Is non-HSA path or trap-handler disabled? Then, report a warning | ||||||
| // accordingly | ||||||
| if (!ST.isTrapHandlerEnabled() || | ||||||
| ST.getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) { | ||||||
| DiagnosticInfoUnsupported NoTrap(B.getMF().getFunction(), | ||||||
| "debugtrap handler not supported", | ||||||
| MI.getDebugLoc(), DS_Warning); | ||||||
| DiagnosticInfoUnsupported NoTrap( | ||||||
| B.getMF().getFunction(), "debugtrap/ubsantrap handler not supported", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| MI.getDebugLoc(), DS_Warning); | ||||||
| LLVMContext &Ctx = B.getMF().getFunction().getContext(); | ||||||
| Ctx.diagnose(NoTrap); | ||||||
| } else { | ||||||
| } else if (Opcode == TargetOpcode::G_DEBUGTRAP) { | ||||||
| // Insert debug-trap instruction | ||||||
| B.buildInstr(AMDGPU::S_TRAP) | ||||||
| .addImm(static_cast<unsigned>(GCNSubtarget::TrapID::LLVMAMDHSADebugTrap)); | ||||||
| } else if (Opcode == TargetOpcode::G_UBSANTRAP) { | ||||||
| B.buildInstr(AMDGPU::S_TRAP) | ||||||
| .addImm(static_cast<unsigned>(GCNSubtarget::TrapID::LLVMAMDHSATrap)); | ||||||
| } | ||||||
|
|
||||||
| MI.eraseFromParent(); | ||||||
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7283,9 +7283,9 @@ SDValue SITargetLowering::lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const { | |||||
|
|
||||||
| if (!Subtarget->isTrapHandlerEnabled() || | ||||||
| Subtarget->getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) { | ||||||
| DiagnosticInfoUnsupported NoTrap(MF.getFunction(), | ||||||
| "debugtrap handler not supported", | ||||||
| Op.getDebugLoc(), DS_Warning); | ||||||
| DiagnosticInfoUnsupported NoTrap( | ||||||
| MF.getFunction(), "debugtrap/ubsantrap handler not supported", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're apparently missing test coverage for this error. But probably should avoid using a / in an error string (and just ignore naming ubsan)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Op.getDebugLoc(), DS_Warning); | ||||||
| LLVMContext &Ctx = MF.getFunction().getContext(); | ||||||
| Ctx.diagnose(NoTrap); | ||||||
| return Chain; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should add the default lower() action to LegalizerHelper for G_DEBUGTRAP and G_UBSANTRAP, which just replace the opcode with G_TRAP (this is what LegalizeDAG does as the default action)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should we replace the custom() call to lower() or add lower() as a fallback option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly. G_TRAP would still be custom, G_DEBUGTRAP and G_UBSANTRAP would lower. The default lowering would just replace those with regular G_TRAP