]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/llvm/patches/patch-r274286-llvm-r201784-asm-dollar.diff
MFC r281775:
[FreeBSD/stable/10.git] / contrib / llvm / patches / patch-r274286-llvm-r201784-asm-dollar.diff
1 Pull in r201784 from upstream llvm trunk (by Benjamin Kramer):
2
3   AsmParser: Disable Darwin-style macro argument expansion on non-darwin targets.
4
5   There is code in the wild that relies on $0 not being expanded.
6
7 This fixes some cases of using $ signs in literals being incorrectly
8 assembled.
9
10 Reported by:    Richard Henderson
11 Upstream PR:    http://llvm.org/PR21500
12
13 Introduced here: http://svnweb.freebsd.org/changeset/base/274286
14
15 Index: lib/MC/MCParser/AsmParser.cpp
16 ===================================================================
17 --- lib/MC/MCParser/AsmParser.cpp
18 +++ lib/MC/MCParser/AsmParser.cpp
19 @@ -1695,7 +1695,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
20                              const MCAsmMacroParameters &Parameters,
21                              const MCAsmMacroArguments &A, const SMLoc &L) {
22    unsigned NParameters = Parameters.size();
23 -  if (NParameters != 0 && NParameters != A.size())
24 +  if ((!IsDarwin || NParameters != 0) && NParameters != A.size())
25      return Error(L, "Wrong number of arguments");
26  
27    // A macro without parameters is handled differently on Darwin:
28 @@ -1705,7 +1705,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
29      std::size_t End = Body.size(), Pos = 0;
30      for (; Pos != End; ++Pos) {
31        // Check for a substitution or escape.
32 -      if (!NParameters) {
33 +      if (IsDarwin && !NParameters) {
34          // This macro has no parameters, look for $0, $1, etc.
35          if (Body[Pos] != '$' || Pos + 1 == End)
36            continue;
37 @@ -1728,7 +1728,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
38      if (Pos == End)
39        break;
40  
41 -    if (!NParameters) {
42 +    if (IsDarwin && !NParameters) {
43        switch (Body[Pos + 1]) {
44        // $$ => $
45        case '$':
46 Index: test/MC/AsmParser/exprs.s
47 ===================================================================
48 --- test/MC/AsmParser/exprs.s
49 +++ test/MC/AsmParser/exprs.s
50 @@ -1,4 +1,4 @@
51 -// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
52 +// RUN: llvm-mc -triple i386-apple-darwin %s
53  
54  .macro check_expr
55    .if ($0) != ($1)