This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][ARM] add -Wunaligned-access only for clang
ClosedPublic

Authored by ychen on Feb 8 2022, 4:27 PM.

Diff Detail

Event Timeline

ychen created this revision.Feb 8 2022, 4:27 PM
ychen requested review of this revision.Feb 8 2022, 4:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2022, 4:27 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
lenary added a comment.Feb 9 2022, 2:06 PM

I don't fully understand the reasoning for the patch, and you haven't really explained it. I think what you are saying is that the IsAux argument to getTargetFeatures should be considered because it's true for offloading to another compiler, but I don't understand why we think the offload compiler is not clang-compatible, as the features added in getAArch64TargetFeatures and getARMTargetFeatures (and passed to the offloaded compiler) use the LLVM-specific internal names. I would like you to explain this further, and to document what IsAux implies in the code.

That all said code given here is not equivalent to the feature as originally landed, because you've only re-added the -Wunaligned-access flag for the AArch64 target - please make the same addition in Clang::AddARMTargetArgs as we want the warning on both. I think this also makes CmdArgs unused in both aarch64::getAArch64TargetFeatures and arm::getARMTargetFeatures as I think that you don't actually want us adding to CmdArgs in those functions (again, I hope the full reasoning behind this will be explained when you explain why the whole patch is necessary).

ychen updated this revision to Diff 407308.Feb 9 2022, 2:45 PM
  • add ARM64 tests
ychen added a comment.Feb 9 2022, 2:51 PM

I don't fully understand the reasoning for the patch, and you haven't really explained it. I think what you are saying is that the IsAux argument to getTargetFeatures should be considered because it's true for offloading to another compiler, but I don't understand why we think the offload compiler is not clang-compatible, as the features added in getAArch64TargetFeatures and getARMTargetFeatures (and passed to the offloaded compiler) use the LLVM-specific internal names. I would like you to explain this further, and to document what IsAux implies in the code.

Apologies for the lack of explanation. My point is that getAArch64TargetFeatures / getARMTargetFeatures should only get the TargetFeatures, not adding compiler flags as a side effect, which belongs to clang's job construction. This makes code reuse harder.

That all said code given here is not equivalent to the feature as originally landed, because you've only re-added the -Wunaligned-access flag for the AArch64 target - please make the same addition in Clang::AddARMTargetArgs as we want the warning on both. I think this also makes CmdArgs unused in both aarch64::getAArch64TargetFeatures and arm::getARMTargetFeatures as I think that you don't actually want us adding to CmdArgs in those functions (again, I hope the full reasoning behind this will be explained when you explain why the whole patch is necessary).

Will do the same thing for Clang::AddARMTargetArgs. Thanks. I've tested this patch but not sure why the original test still passing without a Clang::AddARMTargetArgs change.

ychen updated this revision to Diff 407313.Feb 9 2022, 2:53 PM
  • update
ychen added a comment.Feb 9 2022, 2:55 PM

I don't fully understand the reasoning for the patch, and you haven't really explained it. I think what you are saying is that the IsAux argument to getTargetFeatures should be considered because it's true for offloading to another compiler, but I don't understand why we think the offload compiler is not clang-compatible, as the features added in getAArch64TargetFeatures and getARMTargetFeatures (and passed to the offloaded compiler) use the LLVM-specific internal names. I would like you to explain this further, and to document what IsAux implies in the code.

Apologies for the lack of explanation. My point is that getAArch64TargetFeatures / getARMTargetFeatures should only get the TargetFeatures, not adding compiler flags as a side effect, which belongs to clang's job construction. This makes code reuse harder.

That all said code given here is not equivalent to the feature as originally landed, because you've only re-added the -Wunaligned-access flag for the AArch64 target - please make the same addition in Clang::AddARMTargetArgs as we want the warning on both. I think this also makes CmdArgs unused in both aarch64::getAArch64TargetFeatures and arm::getARMTargetFeatures as I think that you don't actually want us adding to CmdArgs in those functions (again, I hope the full reasoning behind this will be explained when you explain why the whole patch is necessary).

Will do the same thing for Clang::AddARMTargetArgs. Thanks. I've tested this patch but not sure why the original test still passing without a Clang::AddARMTargetArgs change.

NVM. I see why: there were no driver tests. I'll add those.

ychen updated this revision to Diff 407314.Feb 9 2022, 2:56 PM
  • update
ychen updated this revision to Diff 407336.Feb 9 2022, 4:20 PM
  • Handle ARM
  • Add driver tests
lenary accepted this revision.Feb 10 2022, 2:46 AM

Ah, I see.

Please can you also remove the CmdArgs parameter from arm::getARMTargetFeatures when you commit this? This would be useful, along with a comment at the top of getTargetFeatures to discourage targets adding to or using CmdArgs in their get<Target>TargetFeatures functions.

This revision is now accepted and ready to land.Feb 10 2022, 2:46 AM
ychen updated this revision to Diff 407571.Feb 10 2022, 9:25 AM
  • Remove CmdArgs from arm::getARMTargetFeatures
lenary accepted this revision.Feb 10 2022, 9:35 AM
This revision was landed with ongoing or failed builds.Feb 10 2022, 10:26 AM
This revision was automatically updated to reflect the committed changes.