[PATCH] D56990: Bugfix for Replacement of tied operand of inline asm
Xiang Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 18:37:51 PST 2019
xiangzhangllvm updated this revision to Diff 189979.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56990/new/
https://reviews.llvm.org/D56990
Files:
lib/CodeGen/CGStmt.cpp
test/CodeGen/asm-inout.c
Index: test/CodeGen/asm-inout.c
===================================================================
--- test/CodeGen/asm-inout.c
+++ test/CodeGen/asm-inout.c
@@ -46,3 +46,12 @@
asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
return __A;
}
+
+// CHECK: @test6
+int test6(void) {
+ typedef unsigned char __attribute__((vector_size(8))) _m64u8;
+ _m64u8 __attribute__((aligned(16))) Mu8_0, __attribute__((aligned(16))) Mu8_1;
+ // CHECK: call x86_mmx asm "nop", "=y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %1)
+ asm ("nop" : "=y"(Mu8_1 ) : "0"(Mu8_0 ));
+ return 0;
+}
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1932,6 +1932,9 @@
std::vector<llvm::Value*> InOutArgs;
std::vector<llvm::Type*> InOutArgTypes;
+ // Keep track of out constraints for tied input operand.
+ std::vector<std::string> OutputConstraints;
+
// An inline asm can be marked readonly if it meets the following conditions:
// - it doesn't have any sideeffects
// - it doesn't clobber memory
@@ -1954,7 +1957,7 @@
OutputConstraint = AddVariableConstraints(OutputConstraint, *OutExpr,
getTarget(), CGM, S,
Info.earlyClobber());
-
+ OutputConstraints.push_back(OutputConstraint);
LValue Dest = EmitLValue(OutExpr);
if (!Constraints.empty())
Constraints += ',';
@@ -2072,6 +2075,7 @@
InputConstraint, *InputExpr->IgnoreParenNoopCasts(getContext()),
getTarget(), CGM, S, false /* No EarlyClobber */);
+ std::string ReplaceConstraint (InputConstraint);
llvm::Value *Arg = EmitAsmInput(Info, InputExpr, Constraints);
// If this input argument is tied to a larger output result, extend the
@@ -2099,9 +2103,11 @@
Arg = Builder.CreateFPExt(Arg, OutputTy);
}
}
+ // Deal with the tied operands' constraint code in adjustInlineAsmType.
+ ReplaceConstraint = OutputConstraints[Output];
}
if (llvm::Type* AdjTy =
- getTargetHooks().adjustInlineAsmType(*this, InputConstraint,
+ getTargetHooks().adjustInlineAsmType(*this, ReplaceConstraint,
Arg->getType()))
Arg = Builder.CreateBitCast(Arg, AdjTy);
else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56990.189979.patch
Type: text/x-patch
Size: 2394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190309/5cac62ff/attachment.bin>
More information about the cfe-commits
mailing list