diff options
author | Eli Friedman <efriedma@quicinc.com> | 2025-06-09 13:51:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-09 13:51:03 -0700 |
commit | 9f82ac5738fced23716ac6f9c5744f99d6b6ba92 (patch) | |
tree | 7b73b889458d262ca48740245748607971852365 /llvm/lib/IR/Verifier.cpp | |
parent | f9b98e386ed2b2e2885b9e6dffceb1c915c282b8 (diff) | |
download | llvm-9f82ac5738fced23716ac6f9c5744f99d6b6ba92.zip llvm-9f82ac5738fced23716ac6f9c5744f99d6b6ba92.tar.gz llvm-9f82ac5738fced23716ac6f9c5744f99d6b6ba92.tar.bz2 |
Remove GlobalObject::getAlign/setAlignment (#143188)
Currently, GlobalObject has an "alignment" property... but it's
basically nonsense: alignment doesn't mean the same thing for variables
and functions, and it's completely meaningless for ifuncs.
This "removes" (actually marking protected) the methods from
GlobalObject, adds the relevant methods to Function and GlobalVariable,
and adjusts the code appropriately.
This should make future alignment-related cleanups easier.
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 2d03a7a..592bb6a 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -735,12 +735,6 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) { "Global is external, but doesn't have external or weak linkage!", &GV); if (const GlobalObject *GO = dyn_cast<GlobalObject>(&GV)) { - - if (MaybeAlign A = GO->getAlign()) { - Check(A->value() <= Value::MaximumAlignment, - "huge alignment values are unsupported", GO); - } - if (const MDNode *Associated = GO->getMetadata(LLVMContext::MD_associated)) { Check(Associated->getNumOperands() == 1, @@ -830,6 +824,11 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) { void Verifier::visitGlobalVariable(const GlobalVariable &GV) { Type *GVType = GV.getValueType(); + if (MaybeAlign A = GV.getAlign()) { + Check(A->value() <= Value::MaximumAlignment, + "huge alignment values are unsupported", &GV); + } + if (GV.hasInitializer()) { Check(GV.getInitializer()->getType() == GVType, "Global variable initializer type does not match global " @@ -2869,6 +2868,11 @@ void Verifier::visitFunction(const Function &F) { Check(!F.hasStructRetAttr() || F.getReturnType()->isVoidTy(), "Invalid struct return type!", &F); + if (MaybeAlign A = F.getAlign()) { + Check(A->value() <= Value::MaximumAlignment, + "huge alignment values are unsupported", &F); + } + AttributeList Attrs = F.getAttributes(); Check(verifyAttributeCount(Attrs, FT->getNumParams()), |