[X86][MS-InlineAsm] Use exact conditions to recognize MS global variables

D115225 tried to roll back the effects on symbols of MS inline asm
introduced by D113096. But the combination of the conditions cannot
match all the changes. As a result, there are still fails after the
patch.

This patch fixes the problem by checking the exact conditions for MS
global variables, i.e., variable (by FrontendSize != 0) + non rip/eip
(by DefaultBaseReg == 0), so that we can fully roll back for D113096.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D116090
This commit is contained in:
Phoebe Wang 2021-12-23 10:35:46 +08:00
parent da41cfddca
commit 682d01a1c1
3 changed files with 6 additions and 6 deletions

View File

@ -39,7 +39,7 @@ int bar() {
int baz() {
// CHECK-LABEL: _baz:
__asm mov eax, k;
// CHECK: movl k, %eax
// CHECK: movl _k, %eax
__asm mov eax, kptr;
// CHECK: movl _kptr, %eax
}

View File

@ -1759,7 +1759,8 @@ bool X86AsmParser::CreateMemForMSInlineAsm(
// registers in a mmory expression, and though unaccessible via rip/eip.
if (IsGlobalLV && (BaseReg || IndexReg)) {
Operands.push_back(X86Operand::CreateMem(getPointerWidth(), Disp, Start,
End, Size, Identifier, Decl));
End, Size, Identifier, Decl,
FrontendSize));
return false;
}
// Otherwise, we set the base register to a non-zero value

View File

@ -286,10 +286,9 @@ struct X86Operand final : public MCParsedAsmOperand {
bool isOffsetOfLocal() const override { return isImm() && Imm.LocalRef; }
bool isMemPlaceholder(const MCInstrDesc &Desc) const override {
// Add more restrictions to avoid the use of global symbols. This helps
// with reducing the code size.
return !Desc.isRematerializable() && !Desc.isCall() && isMem() &&
!Mem.BaseReg && !Mem.IndexReg;
// Only MS InlineAsm uses global variables with registers rather than
// rip/eip.
return !Mem.DefaultBaseReg && Mem.FrontendSize;
}
bool needAddressOf() const override { return AddressOf; }