Author: Phoebe Wang Date: 2021-12-24T17:42:51+08:00 New Revision: 24c68ea1eb4fc0d0e782424ddb02da9e8c53ddf5
URL: https://github.com/llvm/llvm-project/commit/24c68ea1eb4fc0d0e782424ddb02da9e8c53ddf5 DIFF: https://github.com/llvm/llvm-project/commit/24c68ea1eb4fc0d0e782424ddb02da9e8c53ddf5.diff LOG: Reland "[X86][MS-InlineAsm] Use exact conditions to recognize MS global variables" This reverts commit a954558e878ed9e97e99036229e99af8c6b6c881. Thanks Yuanfang's help. I think I found the root cause of the buildbot fail. The failed test has both Memory and Immediate X86Operand. All data of different operand kinds share the same memory space by a union definition. So it has chance we get the wrong result if we don't check the operand kind. It's probably it happen to be the correct value in my local environment so that I can't reproduce the fail. Differential Revision: https://reviews.llvm.org/D116090 Added: Modified: clang/test/CodeGen/ms-inline-asm-functions.c llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp llvm/lib/Target/X86/AsmParser/X86Operand.h Removed: ################################################################################ diff --git a/clang/test/CodeGen/ms-inline-asm-functions.c b/clang/test/CodeGen/ms-inline-asm-functions.c index c958d88038716..1a6ead9286dff 100644 --- a/clang/test/CodeGen/ms-inline-asm-functions.c +++ b/clang/test/CodeGen/ms-inline-asm-functions.c @@ -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 } diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 6bae55695f3d8..2ba0b97229cc6 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -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 diff --git a/llvm/lib/Target/X86/AsmParser/X86Operand.h b/llvm/lib/Target/X86/AsmParser/X86Operand.h index 6d20c6af5fd2c..67b1244708a8c 100644 --- a/llvm/lib/Target/X86/AsmParser/X86Operand.h +++ b/llvm/lib/Target/X86/AsmParser/X86Operand.h @@ -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 isMem() && !Mem.DefaultBaseReg && Mem.FrontendSize; } bool needAddressOf() const override { return AddressOf; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits