diff options
author | Sander de Smalen <sander.desmalen@arm.com> | 2023-11-22 08:52:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 08:52:53 +0000 |
commit | 81b7f115fb272ef6fd6967f4121b64814b4bcf10 (patch) | |
tree | f62cd768f7932064b190300e2ddb5a497e03a9c9 /llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp | |
parent | 03f05a4e72891237264ab48adf62034aaac8bd46 (diff) | |
download | llvm-81b7f115fb272ef6fd6967f4121b64814b4bcf10.zip llvm-81b7f115fb272ef6fd6967f4121b64814b4bcf10.tar.gz llvm-81b7f115fb272ef6fd6967f4121b64814b4bcf10.tar.bz2 |
[llvm][TypeSize] Fix addition/subtraction in TypeSize. (#72979)
It seems TypeSize is currently broken in the sense that:
TypeSize::Fixed(4) + TypeSize::Scalable(4) => TypeSize::Fixed(8)
without failing its assert that explicitly tests for this case:
assert(LHS.Scalable == RHS.Scalable && ...);
The reason this fails is that `Scalable` is a static method of class
TypeSize,
and LHS and RHS are both objects of class TypeSize. So this is
evaluating
if the pointer to the function Scalable == the pointer to the function
Scalable,
which is always true because LHS and RHS have the same class.
This patch fixes the issue by renaming `TypeSize::Scalable` ->
`TypeSize::getScalable`, as well as `TypeSize::Fixed` to
`TypeSize::getFixed`,
so that it no longer clashes with the variable in
FixedOrScalableQuantity.
The new methods now also better match the coding standard, which
specifies that:
* Variable names should be nouns (as they represent state)
* Function names should be verb phrases (as they represent actions)
Diffstat (limited to 'llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp')
-rw-r--r-- | llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp index e1375f0..605a540 100644 --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -92,7 +92,7 @@ void RISCVDAGToDAGISel::PreprocessISelDAG() { // Create temporary stack for each expanding node. SDValue StackSlot = - CurDAG->CreateStackTemporary(TypeSize::Fixed(8), Align(8)); + CurDAG->CreateStackTemporary(TypeSize::getFixed(8), Align(8)); int FI = cast<FrameIndexSDNode>(StackSlot.getNode())->getIndex(); MachinePointerInfo MPI = MachinePointerInfo::getFixedStack(MF, FI); @@ -100,7 +100,7 @@ void RISCVDAGToDAGISel::PreprocessISelDAG() { Lo = CurDAG->getStore(Chain, DL, Lo, StackSlot, MPI, Align(8)); SDValue OffsetSlot = - CurDAG->getMemBasePlusOffset(StackSlot, TypeSize::Fixed(4), DL); + CurDAG->getMemBasePlusOffset(StackSlot, TypeSize::getFixed(4), DL); Hi = CurDAG->getStore(Chain, DL, Hi, OffsetSlot, MPI.getWithOffset(4), Align(8)); |