Skip to content

Commit 1bce411

Browse files
authored
MIPS/Clang: Set HasUnalignedAccess false if +strict-align (#87257)
TargetInfo has HasUnalignedAccess support now. For MIPSr6, we should set it according strict-align. For pre-R6, we always set strict-align and HasUnalignedAccess to false.
1 parent ea88bb1 commit 1bce411

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang/lib/Basic/Targets/Mips.h

+8
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
318318
FPMode = isFP64Default() ? FP64 : FPXX;
319319
NoOddSpreg = false;
320320
bool OddSpregGiven = false;
321+
bool StrictAlign = false;
321322

322323
for (const auto &Feature : Features) {
323324
if (Feature == "+single-float")
@@ -330,6 +331,10 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
330331
IsMicromips = true;
331332
else if (Feature == "+mips32r6" || Feature == "+mips64r6")
332333
HasUnalignedAccess = true;
334+
// We cannot be sure that the order of strict-align vs mips32r6.
335+
// Thus we need an extra variable here.
336+
else if (Feature == "+strict-align")
337+
StrictAlign = true;
333338
else if (Feature == "+dsp")
334339
DspRev = std::max(DspRev, DSP1);
335340
else if (Feature == "+dspr2")
@@ -368,6 +373,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
368373
if (FPMode == FPXX && !OddSpregGiven)
369374
NoOddSpreg = true;
370375

376+
if (StrictAlign)
377+
HasUnalignedAccess = false;
378+
371379
setDataLayout();
372380

373381
return true;

0 commit comments

Comments
 (0)