[llvm] [AMDGPU] Add disassembler diagnostics for invalid kernel descriptors (PR #87400)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 06:49:12 PDT 2024
================
@@ -2051,33 +2051,30 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
for (size_t SHI = 0; SHI < SymbolsHere.size(); ++SHI) {
SymbolInfoTy Symbol = SymbolsHere[SHI];
- Error Err = Error::success();
- bool Responded = DT->DisAsm->onSymbolStart(
- Symbol, Size, Bytes.slice(Start, End - Start), SectionAddr + Start,
- Err);
+ Expected<bool> RespondedOrErr = DT->DisAsm->onSymbolStart(
+ Symbol, Size, Bytes.slice(Start, End - Start), SectionAddr + Start);
- if (!Responded) {
+ if (RespondedOrErr && !*RespondedOrErr) {
// This symbol didn't trigger any interesting handling. Try the other
- // symbols defined at this address. Errors can only be returned if the
- // disassembler responds.
- cantFail(std::move(Err));
+ // symbols defined at this address.
continue;
}
- // If onSymbolStart responded and set Err, that means it identified some
+ // If onSymbolStart returned an Error, that means it identified some
// kind of special data at this address, but wasn't able to disassemble
// it meaningfully. So we fall back to printing the error out and
// disassembling the failed region as bytes, assuming that the target
// detected the failure before printing anything.
//
- // Either way, 'Size' will have been set to the amount of data covered
- // by whatever prologue the target identified. So we advance our own
- // position to beyond that. Sometimes that will be the entire distance
- // to the next symbol, and sometimes it will be just a prologue and we
- // should start disassembling instructions from where it left off.
-
- if (Err) {
- std::string ErrMsgStr = toString(std::move(Err));
+ // Regardless of whether onSymbolStart returned an Error or true, 'Size'
+ // will have been set to the amount of data covered by whatever prologue
+ // the target identified. So we advance our own position to beyond that.
+ // Sometimes that will be the entire distance to the next symbol, and
+ // sometimes it will be just a prologue and we should start
+ // disassembling instructions from where it left off.
+
+ if (!RespondedOrErr) {
+ std::string ErrMsgStr = toString(RespondedOrErr.takeError());
----------------
arsenm wrote:
Defer the toString until printing. Can the << directly consume the error without it?
https://github.com/llvm/llvm-project/pull/87400
More information about the llvm-commits
mailing list