Skip to content

Commit 116e14c

Browse files
malavikasamakisakhilesh
authored andcommitted
Case handling MachineOperandType address of a global value in SIFoldOperands
While `FoldingImmLike` accepts `MO_Immediate`, `MO_FrameIndex` and `MO_GlobalAddress`, the conditional block after it only covers the first 2, so I have added a case for the global value as well.
1 parent 2927050 commit 116e14c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7517,9 +7517,11 @@ the field it is attached to, and it may also lead to emission of automatic fix-i
75177517
hints which would help the user replace the use of unsafe functions(/fields) with safe
75187518
alternatives, though the attribute can be used even when the fix can't be automated.
75197519

7520-
* Attribute attached to functions: The attribute does not suppress
7521-
``-Wunsafe-buffer-usage`` inside the function to which it is attached.
7522-
These warnings still need to be addressed.
7520+
* Attribute attached to functions: The attribute suppresses all
7521+
``-Wunsafe-buffer-usage`` warnings within the function it is attached to, as the
7522+
function is now classified as unsafe. The attribute should be used carefully, as it
7523+
will silence all unsafe operation warnings inside the function; including any new
7524+
unsafe operations introduced in the future.
75237525

75247526
The attribute is warranted even if the only way a function can overflow
75257527
the buffer is by violating the function's preconditions. For example, it

llvm/lib/Target/AMDGPU/SIFoldOperands.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,10 @@ void SIFoldOperandsImpl::foldOperand(
11611161

11621162
if (OpToFold.isImm())
11631163
UseMI->getOperand(1).ChangeToImmediate(OpToFold.getImm());
1164-
else
1164+
else if(OpToFold.isFI())
11651165
UseMI->getOperand(1).ChangeToFrameIndex(OpToFold.getIndex());
1166+
else if(OpToFold.isGlobal())
1167+
return;
11661168
UseMI->removeOperand(2); // Remove exec read (or src1 for readlane)
11671169
return;
11681170
}

0 commit comments

Comments
 (0)