Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

Open
wants to merge 7 commits into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Style fixes
  • Loading branch information
Aman Sharma committed May 14, 2025
commit 3e4b6dd04e067b7e1700a469cda3e44e65d39868
17 changes: 9 additions & 8 deletions 17 llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ bool AMDGPULegalizerInfo::legalizeCustom(
case TargetOpcode::G_TRAP:
return legalizeTrap(MI, MRI, B);
case TargetOpcode::G_DEBUGTRAP:
return legalizeDebugUbsanTrap(MI, MRI, B, TargetOpcode::G_DEBUGTRAP);
return legalizeDebugUbsanTrap(MI, MRI, B, TargetOpcode::G_DEBUGTRAP);
case TargetOpcode::G_UBSANTRAP:
return legalizeDebugUbsanTrap(MI, MRI, B, TargetOpcode::G_UBSANTRAP);
default:
Expand Down Expand Up @@ -7026,22 +7026,23 @@ bool AMDGPULegalizerInfo::legalizeTrapHsa(MachineInstr &MI,
}

bool AMDGPULegalizerInfo::legalizeDebugUbsanTrap(MachineInstr &MI,
MachineRegisterInfo &MRI,
MachineIRBuilder &B, unsigned int Opcode) const {
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/ubsantrap handler not supported",
MI.getDebugLoc(), DS_Warning);
DiagnosticInfoUnsupported NoTrap(
B.getMF().getFunction(), "debugtrap/ubsantrap handler not supported",
MI.getDebugLoc(), DS_Warning);
LLVMContext &Ctx = B.getMF().getFunction().getContext();
Ctx.diagnose(NoTrap);
} else if (Opcode == TargetOpcode::G_DEBUGTRAP){
} 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){
} else if (Opcode == TargetOpcode::G_UBSANTRAP) {
B.buildInstr(AMDGPU::S_TRAP)
.addImm(static_cast<unsigned>(GCNSubtarget::TrapID::LLVMAMDHSATrap));
}
Expand Down
2 changes: 1 addition & 1 deletion 2 llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class AMDGPULegalizerInfo final : public LegalizerInfo {
bool legalizeTrapHsa(MachineInstr &MI, MachineRegisterInfo &MRI,
MachineIRBuilder &B) const;
bool legalizeDebugUbsanTrap(MachineInstr &MI, MachineRegisterInfo &MRI,
MachineIRBuilder &B, unsigned int Opcode) const;
MachineIRBuilder &B, unsigned int Opcode) const;

bool legalizeIntrinsic(LegalizerHelper &Helper,
MachineInstr &MI) const override;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.