Skip to content

Commit c927226

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
1 parent e799dd5 commit c927226

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

llvm/docs/LangRef.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8381,7 +8381,7 @@ Example:
83818381

83828382
@global = global i32 1, !elf_section_properties !{i32 1879002126, i32 8}
83838383

8384-
This defines as global with type ``SHT_LLVM_CFI_JUMP_TABLE`` and entry
8384+
This defines a global with type ``SHT_LLVM_CFI_JUMP_TABLE`` and entry
83858385
size 8.
83868386

83878387

llvm/lib/IR/Verifier.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,22 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
763763
DL.getIntPtrType(GO->getType()),
764764
RangeLikeMetadataKind::AbsoluteSymbol);
765765
}
766+
767+
if (auto *Props = GO->getMetadata(LLVMContext::MD_elf_section_properties)) {
768+
Check(Props->getNumOperands() == 2,
769+
"elf_section_properties metadata must have two operands", GO, Props);
770+
if (Props->getNumOperands() == 2) {
771+
auto *Type = dyn_cast<ConstantAsMetadata>(Props->getOperand(0));
772+
Check(Type, "type field must be ConstantAsMetadata", GO, Props);
773+
auto *TypeInt = dyn_cast<ConstantInt>(Type->getValue());
774+
Check(TypeInt, "type field must be ConstantInt", GO, Props);
775+
776+
auto *Entsize = dyn_cast<ConstantAsMetadata>(Props->getOperand(1));
777+
Check(Entsize, "entsize field must be ConstantAsMetadata", GO, Props);
778+
auto *EntsizeInt = dyn_cast<ConstantInt>(Entsize->getValue());
779+
Check(EntsizeInt, "entsize field must be ConstantInt", GO, Props);
780+
}
781+
}
766782
}
767783

768784
Check(!GV.hasAppendingLinkage() || isa<GlobalVariable>(GV),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
2+
3+
; CHECK: elf_section_properties metadata must have two operands
4+
@g1 = global i32 0, !elf_section_properties !{i32 0}
5+
; CHECK: type field must be ConstantAsMetadata
6+
@g2 = global i32 0, !elf_section_properties !{!{}, i32 0}
7+
; CHECK: entsize field must be ConstantAsMetadata
8+
@g3 = global i32 0, !elf_section_properties !{i32 0, !{}}
9+
; CHECK: type field must be ConstantInt
10+
@g4 = global i32 0, !elf_section_properties !{float 0.0, i32 0}
11+
; CHECK: entsize field must be ConstantInt
12+
@g5 = global i32 0, !elf_section_properties !{i32 0, float 0.0}

0 commit comments

Comments
 (0)