summaryrefslogtreecommitdiffstats
path: root/contrib/llvm
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-11-11 08:00:49 +0000
committerdim <dim@FreeBSD.org>2014-11-11 08:00:49 +0000
commit5947d7353b11a5651d6ea4d2a0f59787f2edc266 (patch)
treeeb60bcfd146806165591ffae8b5d14050d45dc8d /contrib/llvm
parentb67114480147049c9f71284457c6b16451f14e8b (diff)
downloadFreeBSD-src-5947d7353b11a5651d6ea4d2a0f59787f2edc266.zip
FreeBSD-src-5947d7353b11a5651d6ea4d2a0f59787f2edc266.tar.gz
MFC r274286:
Pull in r201784 from upstream llvm trunk (by Benjamin Kramer): AsmParser: Disable Darwin-style macro argument expansion on non-darwin targets. There is code in the wild that relies on $0 not being expanded. This fixes some cases of using $ signs in literals being incorrectly assembled. Reported by: Richard Henderson Upstream PR: http://llvm.org/PR21500 MFC r274294: Add llvm patch corresponding to r274286.
Diffstat (limited to 'contrib/llvm')
-rw-r--r--contrib/llvm/lib/MC/MCParser/AsmParser.cpp6
-rw-r--r--contrib/llvm/patches/patch-r274286-llvm-r201784-asm-dollar.diff55
2 files changed, 58 insertions, 3 deletions
diff --git a/contrib/llvm/lib/MC/MCParser/AsmParser.cpp b/contrib/llvm/lib/MC/MCParser/AsmParser.cpp
index 5eeb308..7f8e9df 100644
--- a/contrib/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/contrib/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -1695,7 +1695,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body,
const MCAsmMacroParameters &Parameters,
const MCAsmMacroArguments &A, const SMLoc &L) {
unsigned NParameters = Parameters.size();
- if (NParameters != 0 && NParameters != A.size())
+ if ((!IsDarwin || NParameters != 0) && NParameters != A.size())
return Error(L, "Wrong number of arguments");
// A macro without parameters is handled differently on Darwin:
@@ -1705,7 +1705,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body,
std::size_t End = Body.size(), Pos = 0;
for (; Pos != End; ++Pos) {
// Check for a substitution or escape.
- if (!NParameters) {
+ if (IsDarwin && !NParameters) {
// This macro has no parameters, look for $0, $1, etc.
if (Body[Pos] != '$' || Pos + 1 == End)
continue;
@@ -1728,7 +1728,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body,
if (Pos == End)
break;
- if (!NParameters) {
+ if (IsDarwin && !NParameters) {
switch (Body[Pos + 1]) {
// $$ => $
case '$':
diff --git a/contrib/llvm/patches/patch-r274286-llvm-r201784-asm-dollar.diff b/contrib/llvm/patches/patch-r274286-llvm-r201784-asm-dollar.diff
new file mode 100644
index 0000000..40dd5bd
--- /dev/null
+++ b/contrib/llvm/patches/patch-r274286-llvm-r201784-asm-dollar.diff
@@ -0,0 +1,55 @@
+Pull in r201784 from upstream llvm trunk (by Benjamin Kramer):
+
+ AsmParser: Disable Darwin-style macro argument expansion on non-darwin targets.
+
+ There is code in the wild that relies on $0 not being expanded.
+
+This fixes some cases of using $ signs in literals being incorrectly
+assembled.
+
+Reported by: Richard Henderson
+Upstream PR: http://llvm.org/PR21500
+
+Introduced here: http://svnweb.freebsd.org/changeset/base/274286
+
+Index: lib/MC/MCParser/AsmParser.cpp
+===================================================================
+--- lib/MC/MCParser/AsmParser.cpp
++++ lib/MC/MCParser/AsmParser.cpp
+@@ -1695,7 +1695,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
+ const MCAsmMacroParameters &Parameters,
+ const MCAsmMacroArguments &A, const SMLoc &L) {
+ unsigned NParameters = Parameters.size();
+- if (NParameters != 0 && NParameters != A.size())
++ if ((!IsDarwin || NParameters != 0) && NParameters != A.size())
+ return Error(L, "Wrong number of arguments");
+
+ // A macro without parameters is handled differently on Darwin:
+@@ -1705,7 +1705,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
+ std::size_t End = Body.size(), Pos = 0;
+ for (; Pos != End; ++Pos) {
+ // Check for a substitution or escape.
+- if (!NParameters) {
++ if (IsDarwin && !NParameters) {
+ // This macro has no parameters, look for $0, $1, etc.
+ if (Body[Pos] != '$' || Pos + 1 == End)
+ continue;
+@@ -1728,7 +1728,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
+ if (Pos == End)
+ break;
+
+- if (!NParameters) {
++ if (IsDarwin && !NParameters) {
+ switch (Body[Pos + 1]) {
+ // $$ => $
+ case '$':
+Index: test/MC/AsmParser/exprs.s
+===================================================================
+--- test/MC/AsmParser/exprs.s
++++ test/MC/AsmParser/exprs.s
+@@ -1,4 +1,4 @@
+-// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
++// RUN: llvm-mc -triple i386-apple-darwin %s
+
+ .macro check_expr
+ .if ($0) != ($1)
OpenPOWER on IntegriCloud