mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Include a source location when complaining about bad inline assembly.
Add a MI->emitError() method that the backend can use to report errors related to inline assembly. Call it from X86FloatingPoint.cpp when the constraints are wrong. This enables proper clang diagnostics from the backend: $ clang -c pr30848.c pr30848.c:5:12: error: Inline asm output regs must be last on the x87 stack __asm__ ("" : "=u" (d)); /* { dg-error "output regs" } */ ^ 1 error generated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134307 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -15,13 +15,16 @@
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/Metadata.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/Value.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineMemOperand.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/PseudoSourceValue.h"
|
||||
#include "llvm/MC/MCInstrDesc.h"
|
||||
@ -1712,3 +1715,24 @@ MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) {
|
||||
}
|
||||
return Hash;
|
||||
}
|
||||
|
||||
void MachineInstr::emitError(StringRef Msg) const {
|
||||
// Find the source location cookie.
|
||||
unsigned LocCookie = 0;
|
||||
const MDNode *LocMD = 0;
|
||||
for (unsigned i = getNumOperands(); i != 0; --i) {
|
||||
if (getOperand(i-1).isMetadata() &&
|
||||
(LocMD = getOperand(i-1).getMetadata()) &&
|
||||
LocMD->getNumOperands() != 0) {
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(LocMD->getOperand(0))) {
|
||||
LocCookie = CI->getZExtValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (const MachineBasicBlock *MBB = getParent())
|
||||
if (const MachineFunction *MF = MBB->getParent())
|
||||
return MF->getMMI().getModule()->getContext().emitError(LocCookie, Msg);
|
||||
report_fatal_error(Msg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user