diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -2656,6 +2656,10 @@ } } } else if (IsUnconditionalBranch) { + // Treat `call [offset fn_ref]` (or `jmp`) syntax as an error. + if (!PtrInOperand && SM.isOffsetOperator()) + return Error( + Start, "`OFFSET` operator cannot be used in an unconditional branch"); if (PtrInOperand || SM.isBracketUsed()) MaybeDirectBranchDest = false; } diff --git a/llvm/test/MC/X86/intel-syntax-branch.s b/llvm/test/MC/X86/intel-syntax-branch.s --- a/llvm/test/MC/X86/intel-syntax-branch.s +++ b/llvm/test/MC/X86/intel-syntax-branch.s @@ -61,6 +61,11 @@ .ifdef ERR + call [offset fn_ref] + // ERR-32: {{.*}}.s:[[#@LINE-1]]:8: error: `OFFSET` operator cannot be used in an unconditional branch + jmp [offset fn_ref] + // ERR-32: {{.*}}.s:[[#@LINE-1]]:7: error: `OFFSET` operator cannot be used in an unconditional branch + call offset fn_ref // ERR-32: {{.*}}.s:[[#@LINE-1]]:3: error: invalid operand for instruction jmp offset fn_ref