Skip to content

[lld][RISCV] Add break to nested switch in mergeAtomic #99762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

4vtomat
Copy link
Member

@4vtomat 4vtomat commented Jul 20, 2024

This prevent the warnings from compiler.

This prevent the warnings from compiler.
@llvmbot
Copy link
Member

llvmbot commented Jul 20, 2024

@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-elf

Author: Brandon Wu (4vtomat)

Changes

This prevent the warnings from compiler.


Full diff: https://github.com/llvm/llvm-project/pull/99762.diff

1 Files Affected:

  • (modified) lld/ELF/Arch/RISCV.cpp (+3)
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 6af89ce3517b7..56759c28dcf41 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -1131,6 +1131,7 @@ static void mergeAtomic(DenseMap<unsigned, unsigned>::iterator it,
     case RISCVAttrs::RISCVAtomicAbiTag::A6C:
       return;
     };
+    break;
 
   case RISCVAtomicAbiTag::A6S:
     switch (newTag) {
@@ -1144,6 +1145,7 @@ static void mergeAtomic(DenseMap<unsigned, unsigned>::iterator it,
     case RISCVAttrs::RISCVAtomicAbiTag::A6S:
       return;
     };
+    break;
 
   case RISCVAtomicAbiTag::A7:
     switch (newTag) {
@@ -1157,6 +1159,7 @@ static void mergeAtomic(DenseMap<unsigned, unsigned>::iterator it,
     case RISCVAttrs::RISCVAtomicAbiTag::A7:
       return;
     };
+    break;
   };
 
   // If we get here, then we have an invalid tag, so report it.

Copy link
Contributor

@ilovepi ilovepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change seems fine, but what compiler is warning about this? lld was compiling without warning for me recently with ToT clang.

@4vtomat
Copy link
Member Author

4vtomat commented Jul 20, 2024

The change seems fine, but what compiler is warning about this? lld was compiling without warning for me recently with ToT clang.

The warning is

llvm-project/lld/ELF/Arch/RISCV.cpp: In function ‘void mergeAtomic(llvm::DenseMapBase<llvm::DenseMap<unsigned int, unsigned int>, unsigned int, unsigned int, llvm
::DenseMapInfo<unsigned int>, llvm::detail::DenseMapPair<unsigned int, unsigned int> >::iterator, const lld::elf::InputSectionBase*, const lld::elf::InputSectionBase*, llvm::RISCVA
ttrs::RISCVAtomicAbiTag, llvm::RISCVAttrs::RISCVAtomicAbiTag)’:
llvm-project/lld/ELF/Arch/RISCV.cpp:1123:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     switch (newTag) {
     ^~~~~~
llvm-project/lld/ELF/Arch/RISCV.cpp:1135:3: note: here
   case RISCVAtomicAbiTag::A6S:
   ^~~~
llvm-project/lld/ELF/Arch/RISCV.cpp:1136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     switch (newTag) {
     ^~~~~~
llvm-project/lld/ELF/Arch/RISCV.cpp:1148:3: note: here
   case RISCVAtomicAbiTag::A7:
   ^~~~

@ilovepi
Copy link
Contributor

ilovepi commented Jul 20, 2024

Right, but I don’t recall seeing that with a pretty recent clang, and I want to know if you’re using gcc or another compiler so I know if I should see if we should fix that in clang.

@4vtomat
Copy link
Member Author

4vtomat commented Jul 20, 2024

Right, but I don’t recall seeing that with a pretty recent clang, and I want to know if you’re using gcc or another compiler so I know if I should see if we should fix that in clang.

Actually it's during compiling the lld itself lol~

@ilovepi
Copy link
Contributor

ilovepi commented Jul 20, 2024

Right, but I don’t recall seeing that with a pretty recent clang, and I want to know if you’re using gcc or another compiler so I know if I should see if we should fix that in clang.

Actually it's during compiling the lld itself lol~

Yes, but are you compiling with clang as the compiler or something else? Because if it’s clang then I don’t need to file a bug and try to run down why we’re not handling that. If you’re using something else, then I do.

@4vtomat
Copy link
Member Author

4vtomat commented Jul 20, 2024

Right, but I don’t recall seeing that with a pretty recent clang, and I want to know if you’re using gcc or another compiler so I know if I should see if we should fix that in clang.

Actually it's during compiling the lld itself lol~

Yes, but are you compiling with clang as the compiler or something else? Because if it’s clang then I don’t need to file a bug and try to run down why we’re not handling that. If you’re using something else, then I do.

Oh, I got your point, I was using gcc.

@ilovepi
Copy link
Contributor

ilovepi commented Jul 20, 2024

Thanks I’ll take a look at top of tree clang again, and file a bug if we’re missing warnings in that case.

@4vtomat 4vtomat merged commit 2873edd into llvm:main Jul 22, 2024
10 checks passed
@4vtomat 4vtomat deleted the add_default_case branch July 22, 2024 06:31
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary: This prevent the warnings from compiler.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251271
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants