Skip to content

Commit 3aec4b3

Browse files
committed
Revert "Unaligned Access Warning Added"
This reverts commits: - 2cd2600 - 11c67e5 Due to test failures on Windows.
1 parent 5d46263 commit 3aec4b3

File tree

9 files changed

+10
-817
lines changed

9 files changed

+10
-817
lines changed

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,4 @@ def warn_padded_struct_size : Warning<
590590
InGroup<Padded>, DefaultIgnore;
591591
def warn_unnecessary_packed : Warning<
592592
"packed attribute is unnecessary for %0">, InGroup<Packed>, DefaultIgnore;
593-
594-
// -Wunaligned-access
595-
def warn_unaligned_access : Warning<
596-
"field %1 within its parent %0 has an alignment greater than its parent "
597-
"this may be caused by %0 being packed and can lead to unaligned accesses">, InGroup<UnalignedAccess>, DefaultIgnore;
598593
}

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ def ExplicitInitializeCall : DiagGroup<"explicit-initialize-call">;
542542
def OrderedCompareFunctionPointers : DiagGroup<"ordered-compare-function-pointers">;
543543
def Packed : DiagGroup<"packed">;
544544
def Padded : DiagGroup<"padded">;
545-
def UnalignedAccess : DiagGroup<"unaligned-access">;
546545

547546
def PessimizingMove : DiagGroup<"pessimizing-move">;
548547
def ReturnStdMove : DiagGroup<"return-std-move">;

clang/lib/AST/RecordLayoutBuilder.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,6 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
20212021
CharUnits UnpackedFieldAlign =
20222022
!DefaultsToAIXPowerAlignment ? FieldAlign : PreferredAlign;
20232023
CharUnits UnpackedFieldOffset = FieldOffset;
2024-
CharUnits OriginalFieldAlign = UnpackedFieldAlign;
20252024

20262025
if (FieldPacked) {
20272026
FieldAlign = CharUnits::One();
@@ -2106,22 +2105,6 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
21062105
// Remember max struct/class ABI-specified alignment.
21072106
UnadjustedAlignment = std::max(UnadjustedAlignment, FieldAlign);
21082107
UpdateAlignment(FieldAlign, UnpackedFieldAlign, PreferredAlign);
2109-
2110-
// For checking the alignment of inner fields against
2111-
// the alignment of its parent record.
2112-
if (const RecordDecl *RD = D->getParent()) {
2113-
// Check if packed attribute or pragma pack is present.
2114-
if (RD->hasAttr<PackedAttr>() || !MaxFieldAlignment.isZero())
2115-
if (FieldAlign < OriginalFieldAlign)
2116-
if (D->getType()->isRecordType()) {
2117-
// If the offset is a multiple of the alignment of
2118-
// the type, raise the warning.
2119-
// TODO: Takes no account the alignment of the outer struct
2120-
if (FieldOffset % OriginalFieldAlign != 0)
2121-
Diag(D->getLocation(), diag::warn_unaligned_access)
2122-
<< Context.getTypeDeclType(RD) << D->getName();
2123-
}
2124-
}
21252108
}
21262109

21272110
void ItaniumRecordLayoutBuilder::FinishLayout(const NamedDecl *D) {

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ getAArch64MicroArchFeaturesFromMcpu(const Driver &D, StringRef Mcpu,
221221
void aarch64::getAArch64TargetFeatures(const Driver &D,
222222
const llvm::Triple &Triple,
223223
const ArgList &Args,
224-
llvm::opt::ArgStringList &CmdArgs,
225224
std::vector<StringRef> &Features,
226225
bool ForAS) {
227226
Arg *A;
@@ -465,16 +464,10 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
465464

466465
if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
467466
options::OPT_munaligned_access)) {
468-
if (A->getOption().matches(options::OPT_mno_unaligned_access)) {
467+
if (A->getOption().matches(options::OPT_mno_unaligned_access))
469468
Features.push_back("+strict-align");
470-
if (!ForAS)
471-
CmdArgs.push_back("-Wunaligned-access");
472-
}
473-
} else if (Triple.isOSOpenBSD()) {
469+
} else if (Triple.isOSOpenBSD())
474470
Features.push_back("+strict-align");
475-
if (!ForAS)
476-
CmdArgs.push_back("-Wunaligned-access");
477-
}
478471

479472
if (Args.hasArg(options::OPT_ffixed_x1))
480473
Features.push_back("+reserve-x1");

clang/lib/Driver/ToolChains/Arch/AArch64.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace aarch64 {
2222

2323
void getAArch64TargetFeatures(const Driver &D, const llvm::Triple &Triple,
2424
const llvm::opt::ArgList &Args,
25-
llvm::opt::ArgStringList &CmdArgs,
2625
std::vector<llvm::StringRef> &Features,
2726
bool ForAS);
2827

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -769,12 +769,10 @@ void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
769769
}
770770

771771
// Kernel code has more strict alignment requirements.
772-
if (KernelOrKext) {
772+
if (KernelOrKext)
773773
Features.push_back("+strict-align");
774-
if (!ForAS)
775-
CmdArgs.push_back("-Wunaligned-access");
776-
} else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
777-
options::OPT_munaligned_access)) {
774+
else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
775+
options::OPT_munaligned_access)) {
778776
if (A->getOption().matches(options::OPT_munaligned_access)) {
779777
// No v6M core supports unaligned memory access (v6M ARM ARM A3.2).
780778
if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
@@ -783,11 +781,8 @@ void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
783781
// access either.
784782
else if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
785783
D.Diag(diag::err_target_unsupported_unaligned) << "v8m.base";
786-
} else {
784+
} else
787785
Features.push_back("+strict-align");
788-
if (!ForAS)
789-
CmdArgs.push_back("-Wunaligned-access");
790-
}
791786
} else {
792787
// Assume pre-ARMv6 doesn't support unaligned accesses.
793788
//
@@ -806,23 +801,14 @@ void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
806801
int VersionNum = getARMSubArchVersionNumber(Triple);
807802
if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
808803
if (VersionNum < 6 ||
809-
Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) {
804+
Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
810805
Features.push_back("+strict-align");
811-
if (!ForAS)
812-
CmdArgs.push_back("-Wunaligned-access");
813-
}
814806
} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
815807
Triple.isOSWindows()) {
816-
if (VersionNum < 7) {
808+
if (VersionNum < 7)
817809
Features.push_back("+strict-align");
818-
if (!ForAS)
819-
CmdArgs.push_back("-Wunaligned-access");
820-
}
821-
} else {
810+
} else
822811
Features.push_back("+strict-align");
823-
if (!ForAS)
824-
CmdArgs.push_back("-Wunaligned-access");
825-
}
826812
}
827813

828814
// llvm does not support reserving registers in general. There is support

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple,
346346
case llvm::Triple::aarch64:
347347
case llvm::Triple::aarch64_32:
348348
case llvm::Triple::aarch64_be:
349-
aarch64::getAArch64TargetFeatures(D, Triple, Args, CmdArgs, Features,
350-
ForAS);
349+
aarch64::getAArch64TargetFeatures(D, Triple, Args, Features, ForAS);
351350
break;
352351
case llvm::Triple::x86:
353352
case llvm::Triple::x86_64:

0 commit comments

Comments
 (0)