[llvm] [DebugInfo] Make DIExpression inherit from Metadata and it always should be unique (PR #79335)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 09:31:28 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 56602a48c735a1c906a9ec4e03a64fd9c937def3 b577ea3a85367df9af067619b01ee2a0cca8894d -- llvm/include/llvm/AsmParser/LLParser.h llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h llvm/include/llvm/CodeGen/MachineInstrBuilder.h llvm/include/llvm/CodeGen/MachineOperand.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp llvm/lib/CodeGen/MIRParser/MIParser.cpp llvm/lib/CodeGen/MachineInstr.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/lib/IR/Verifier.cpp llvm/lib/Target/WebAssembly/WebAssemblyDebugFixup.cpp llvm/lib/Transforms/Utils/ValueMapper.cpp llvm/unittests/IR/MetadataTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
index c0c2a4ea4c..b62d43c8fe 100644
--- a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -250,9 +250,9 @@ public:
assert((MI->isDebugValueLike() ? static_cast<bool>(MI->getDebugVariable())
: true) &&
"first MDNode argument of a DBG_VALUE not a variable");
- assert((MI->isDebugLabel() ? static_cast<bool>(MI->getDebugLabel())
- : true) &&
- "first MDNode argument of a DBG_LABEL not a label");
+ assert(
+ (MI->isDebugLabel() ? static_cast<bool>(MI->getDebugLabel()) : true) &&
+ "first MDNode argument of a DBG_LABEL not a label");
return *this;
}
diff --git a/llvm/include/llvm/CodeGen/MachineOperand.h b/llvm/include/llvm/CodeGen/MachineOperand.h
index 9d5532c7d8..e5e80ebf11 100644
--- a/llvm/include/llvm/CodeGen/MachineOperand.h
+++ b/llvm/include/llvm/CodeGen/MachineOperand.h
@@ -174,7 +174,7 @@ private:
int64_t ImmVal; // For MO_Immediate.
const uint32_t *RegMask; // For MO_RegisterMask and MO_RegisterLiveOut.
const MDNode *MD; // For MO_Metadata.
- const Metadata* Expr;
+ const Metadata *Expr;
MCSymbol *Sym; // For MO_MCSymbol.
unsigned CFIIndex; // For MO_CFI.
Intrinsic::ID IntrinsicID; // For MO_IntrinsicID.
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 207deed8a7..ce4d0bc1f7 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -2671,12 +2671,13 @@ class DIExpression : public Metadata, ReplaceableMetadataImpl {
ArrayRef<uint64_t> Elements);
public:
- LLVMContext &getContext() const {
- return ReplaceableMetadataImpl::getContext();
- }
- static inline DIExpression *get(LLVMContext &Context, ArrayRef<uint64_t> Elements) {
- return getImpl(Context, Elements);
- }
+ LLVMContext &getContext() const {
+ return ReplaceableMetadataImpl::getContext();
+ }
+ static inline DIExpression *get(LLVMContext &Context,
+ ArrayRef<uint64_t> Elements) {
+ return getImpl(Context, Elements);
+ }
ArrayRef<uint64_t> getElements() const { return Elements; }
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index e7b06f8c5f..939171edeb 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -892,8 +892,8 @@ bool LLParser::parseNamedMetadata() {
if (Lex.getKind() != lltok::rbrace)
do {
MDNode *N = nullptr;
- if (Lex.getKind() == lltok::MetadataVar &&
- Lex.getStrVal() == "DIArgList") {
+ if (Lex.getKind() == lltok::MetadataVar &&
+ Lex.getStrVal() == "DIArgList") {
return tokError("found DIArgList outside of function");
} else if (parseToken(lltok::exclaim, "Expected '!' here") ||
parseMDNodeID(N)) {
@@ -5750,8 +5750,7 @@ bool LLParser::parseMetadata(Metadata *&MD, PerFunctionState *PFS) {
return true;
MD = AL;
return false;
- }
- else if (Lex.getStrVal() == "DIExpression") {
+ } else if (Lex.getStrVal() == "DIExpression") {
Metadata *Expr;
if (parseDIExpression(Expr))
return true;
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 6ee44110d4..2a24c3d009 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -2152,8 +2152,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
if (Error Err = upgradeDIExpression(Version, Elts, Buffer))
return Err;
- MetadataList.assignValue(DIExpression::get(Context, Elts),
- NextMetadataNo);
+ MetadataList.assignValue(DIExpression::get(Context, Elts), NextMetadataNo);
NextMetadataNo++;
break;
}
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index d545e21c3d..eb5a77c131 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -2439,9 +2439,9 @@ bool MIParser::parseDILocation(MDNode *&Loc) {
}
bool MIParser::parseMetadataOperand(MachineOperand &Dest) {
- Metadata *Meta = nullptr;
+ Metadata *Meta = nullptr;
if (Token.is(MIToken::exclaim)) {
- if (parseMDNode(reinterpret_cast<MDNode *&>(Meta)))
+ if (parseMDNode(reinterpret_cast<MDNode *&>(Meta)))
return true;
} else if (Token.is(MIToken::md_diexpr)) {
if (parseDIExpression(Meta))
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 740edf06eb..70d293bae4 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -2169,7 +2169,8 @@ MachineInstrBuilder llvm::BuildMI(MachineFunction &MF, const DebugLoc &DL,
MachineInstrBuilder llvm::BuildMI(MachineFunction &MF, const DebugLoc &DL,
const MCInstrDesc &MCID, bool IsIndirect,
ArrayRef<MachineOperand> DebugOps,
- const MDNode *Variable, const Metadata *Expr) {
+ const MDNode *Variable,
+ const Metadata *Expr) {
assert(isa<DILocalVariable>(Variable) && "not a variable");
assert(cast<DIExpression>(Expr)->isValid() && "not an expression");
assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
@@ -2200,23 +2201,21 @@ MachineInstrBuilder llvm::BuildMI(MachineFunction &MF, const DebugLoc &DL,
return MIB;
}
-MachineInstrBuilder llvm::BuildMI(MachineBasicBlock &BB,
- MachineBasicBlock::iterator I,
- const DebugLoc &DL, const MCInstrDesc &MCID,
- bool IsIndirect, Register Reg,
- const MDNode *Variable, const Metadata *Expr) {
+MachineInstrBuilder
+llvm::BuildMI(MachineBasicBlock &BB, MachineBasicBlock::iterator I,
+ const DebugLoc &DL, const MCInstrDesc &MCID, bool IsIndirect,
+ Register Reg, const MDNode *Variable, const Metadata *Expr) {
MachineFunction &MF = *BB.getParent();
MachineInstr *MI = BuildMI(MF, DL, MCID, IsIndirect, Reg, Variable, Expr);
BB.insert(I, MI);
return MachineInstrBuilder(MF, MI);
}
-MachineInstrBuilder llvm::BuildMI(MachineBasicBlock &BB,
- MachineBasicBlock::iterator I,
- const DebugLoc &DL, const MCInstrDesc &MCID,
- bool IsIndirect,
- ArrayRef<MachineOperand> DebugOps,
- const MDNode *Variable, const Metadata *Expr) {
+MachineInstrBuilder
+llvm::BuildMI(MachineBasicBlock &BB, MachineBasicBlock::iterator I,
+ const DebugLoc &DL, const MCInstrDesc &MCID, bool IsIndirect,
+ ArrayRef<MachineOperand> DebugOps, const MDNode *Variable,
+ const Metadata *Expr) {
MachineFunction &MF = *BB.getParent();
MachineInstr *MI =
BuildMI(MF, DL, MCID, IsIndirect, DebugOps, Variable, Expr);
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index d2a039876f..b8663305f7 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -1351,7 +1351,8 @@ DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
Metadata *Ops[] = {Scope, Name, File};
DEFINE_GETIMPL_STORE(DILabel, (Line), Ops);
}
-DIExpression *DIExpression::getImpl(LLVMContext &Context, ArrayRef<uint64_t> Elements) {
+DIExpression *DIExpression::getImpl(LLVMContext &Context,
+ ArrayRef<uint64_t> Elements) {
auto &DIExpressions = Context.pImpl->DIExpressions;
DIExpressionKeyInfo Key(Elements);
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index 37f1471bb5..e14734aef6 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -1354,7 +1354,8 @@ struct DIExpressionKeyInfo {
ArrayRef<uint64_t> Elements;
DIExpressionKeyInfo(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
- DIExpressionKeyInfo(const DIExpression *Expr) : Elements(Expr->getElements()) {}
+ DIExpressionKeyInfo(const DIExpression *Expr)
+ : Elements(Expr->getElements()) {}
bool isKeyOf(const DIExpression *RHS) const {
return Elements == RHS->getElements();
@@ -1376,9 +1377,7 @@ struct DIExpressionInfo {
return DenseMapInfo<DIExpression *>::getTombstoneKey();
}
- static unsigned getHashValue(const KeyTy &Key) {
- return Key.getHashValue();
- }
+ static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
static unsigned getHashValue(const DIExpression *Expr) {
return KeyTy(Expr).getHashValue();
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index eddc37d133..5a54e6555a 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -615,7 +615,8 @@ std::optional<Metadata *> MDNodeMapper::tryToMapOperand(const Metadata *Op) {
M.getVM().getMappedMD(Op)) &&
"Expected Value to be memoized");
else
- assert((isa<DIExpression>(Op) || isa<MDString>(Op) || M.getVM().getMappedMD(Op)) &&
+ assert((isa<DIExpression>(Op) || isa<MDString>(Op) ||
+ M.getVM().getMappedMD(Op)) &&
"Expected result to be memoized");
#endif
return *MappedOp;
@@ -811,8 +812,8 @@ void MDNodeMapper::mapNodesInPOT(UniquedGraph &G) {
// Handle MDNode
return &G.getFwdReference(*MDN);
} else if (isa<DIExpression>(Old)) {
- return Old;
- }
+ return Old;
+ }
});
auto *NewN = MDNode::replaceWithUniqued(std::move(ClonedN));
@@ -883,8 +884,8 @@ std::optional<Metadata *> Mapper::mapSimpleMetadata(const Metadata *MD) {
if (isa<MDString>(MD))
return const_cast<Metadata *>(MD);
-
- if(isa<DIExpression>(MD))
+
+ if (isa<DIExpression>(MD))
return const_cast<Metadata *>(MD);
// This is a module-level metadata. If nothing at the module level is
``````````
</details>
https://github.com/llvm/llvm-project/pull/79335
More information about the llvm-commits
mailing list