[clang] 625fa47 - Revert "[clang] Improve handling of physical registers in inline assembly operands."
Jonas Paulsson via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 13 23:44:17 PDT 2020
Author: Jonas Paulsson
Date: 2020-10-14T08:42:51+02:00
New Revision: 625fa47617022b2d1ed7b940f9621162874175ee
URL: https://github.com/llvm/llvm-project/commit/625fa47617022b2d1ed7b940f9621162874175ee
DIFF: https://github.com/llvm/llvm-project/commit/625fa47617022b2d1ed7b940f9621162874175ee.diff
LOG: Revert "[clang] Improve handling of physical registers in inline assembly operands."
This reverts commit c78da037783bda0f27f4d82060149166e6f0c796.
Temporarily reverted due to https://bugs.llvm.org/show_bug.cgi?id=47837.
Added:
Modified:
clang/lib/CodeGen/CGStmt.cpp
clang/test/CodeGen/systemz-inline-asm.c
Removed:
clang/test/CodeGen/systemz-inline-asm-02.c
################################################################################
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index a69007e67b26..c9e6ce2df2c0 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -21,7 +21,6 @@
#include "clang/Basic/PrettyStackTrace.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
-#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InlineAsm.h"
@@ -1837,8 +1836,7 @@ SimplifyConstraint(const char *Constraint, const TargetInfo &Target,
static std::string
AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
const TargetInfo &Target, CodeGenModule &CGM,
- const AsmStmt &Stmt, const bool EarlyClobber,
- std::string *GCCReg = nullptr) {
+ const AsmStmt &Stmt, const bool EarlyClobber) {
const DeclRefExpr *AsmDeclRef = dyn_cast<DeclRefExpr>(&AsmExpr);
if (!AsmDeclRef)
return Constraint;
@@ -1863,8 +1861,6 @@ AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
}
// Canonicalize the register here before returning it.
Register = Target.getNormalizedGCCRegisterName(Register);
- if (GCCReg != nullptr)
- *GCCReg = Register.str();
return (EarlyClobber ? "&{" : "{") + Register.str() + "}";
}
@@ -2063,9 +2059,6 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
// Keep track of out constraints for tied input operand.
std::vector<std::string> OutputConstraints;
- // Keep track of defined physregs.
- llvm::SmallSet<std::string, 8> PhysRegOutputs;
-
// An inline asm can be marked readonly if it meets the following conditions:
// - it doesn't have any sideeffects
// - it doesn't clobber memory
@@ -2085,15 +2078,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
const Expr *OutExpr = S.getOutputExpr(i);
OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
- std::string GCCReg;
OutputConstraint = AddVariableConstraints(OutputConstraint, *OutExpr,
getTarget(), CGM, S,
- Info.earlyClobber(),
- &GCCReg);
- // Give an error on multiple outputs to same physreg.
- if (!GCCReg.empty() && !PhysRegOutputs.insert(GCCReg).second)
- CGM.Error(S.getAsmLoc(), "multiple outputs to hard register: " + GCCReg);
-
+ Info.earlyClobber());
OutputConstraints.push_back(OutputConstraint);
LValue Dest = EmitLValue(OutExpr);
if (!Constraints.empty())
@@ -2180,8 +2167,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
LargestVectorWidth =
std::max((uint64_t)LargestVectorWidth,
VT->getPrimitiveSizeInBits().getKnownMinSize());
- // Don't tie physregs.
- if (Info.allowsRegister() && GCCReg.empty())
+ if (Info.allowsRegister())
InOutConstraints += llvm::utostr(i);
else
InOutConstraints += OutputConstraint;
diff --git a/clang/test/CodeGen/systemz-inline-asm-02.c b/clang/test/CodeGen/systemz-inline-asm-02.c
deleted file mode 100644
index 754d7e66f04b..000000000000
--- a/clang/test/CodeGen/systemz-inline-asm-02.c
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: not %clang_cc1 -triple s390x-linux-gnu -O2 -emit-llvm -o - %s 2>&1 \
-// RUN: | FileCheck %s
-// REQUIRES: systemz-registered-target
-
-// Test that an error is given if a physreg is defined by multiple operands.
-int test_physreg_defs(void) {
- register int l __asm__("r7") = 0;
-
- // CHECK: error: multiple outputs to hard register: r7
- __asm__("" : "+r"(l), "=r"(l));
-
- return l;
-}
diff --git a/clang/test/CodeGen/systemz-inline-asm.c b/clang/test/CodeGen/systemz-inline-asm.c
index 19ab9d092afc..2dc5023c55cb 100644
--- a/clang/test/CodeGen/systemz-inline-asm.c
+++ b/clang/test/CodeGen/systemz-inline-asm.c
@@ -129,17 +129,3 @@ long double test_f128(long double f, long double g) {
// CHECK: [[RESULT:%.*]] = tail call fp128 asm "axbr $0, $2", "=f,0,f"(fp128 %f, fp128 %g)
// CHECK: store fp128 [[RESULT]], fp128* [[DEST]]
}
-
-// Test that there are no tied physreg uses. TwoAddress pass cannot deal with them.
-int test_physregs(void) {
- // CHECK-LABEL: define signext i32 @test_physregs()
- register int l __asm__("r7") = 0;
-
- // CHECK: call i32 asm "lr $0, $1", "={r7},{r7}"
- __asm__("lr %0, %1" : "+r"(l));
-
- // CHECK: call i32 asm "$0 $1 $2", "={r7},{r7},{r7}"
- __asm__("%0 %1 %2" : "+r"(l) : "r"(l));
-
- return l;
-}
More information about the cfe-commits
mailing list