cbalint13 commented on PR #15761: URL: https://github.com/apache/tvm/pull/15761#issuecomment-1765115891
> Hey @cbalint13, I got a compiler warning from this commit saying: > > ``` > /Users/jshao/Projects/tvm-dev/src/target/llvm/llvm_instance.cc:76:81: warning: reference to stack memory associated with parameter 'Obj' returned [-Wreturn-stack-address] > 76 | friend ArrayRef<SubtargetSubTypeKV>& archViewer(MCSubtargetInfo Obj) { return Obj.*Member; } > | ^~~ > /Users/jshao/Projects/tvm-dev/src/target/llvm/llvm_instance.cc:84:81: warning: reference to stack memory associated with parameter 'Obj' returned [-Wreturn-stack-address] > 84 | friend ArrayRef<SubtargetFeatureKV>& featViewer(MCSubtargetInfo Obj) { return Obj.*Member; } > | ^~~ > /Users/jshao/Projects/tvm-dev/src/target/llvm/llvm_instance.cc:763:49: warning: cast from 'const llvm::MCSubtargetInfo *' to 'llvm::MCSubtargetInfo *' drops const qualifier [-Wcast-qual] > 763 | llvm::archViewer(*(llvm::MCSubtargetInfo*)MCInfo); > | ^ > /Users/jshao/Projects/tvm-dev/src/target/llvm/llvm_instance.cc:784:49: warning: cast from 'const llvm::MCSubtargetInfo *' to 'llvm::MCSubtargetInfo *' drops const qualifier [-Wcast-qual] > 784 | llvm::featViewer(*(llvm::MCSubtargetInfo*)MCInfo); > | ^ > ``` > > I am a bit confused by the warning message, not completely sure if it is false positive from the compiler, so am following up here to double check Hi @junrushao , Hmm, I used (my side) gcc13 and VStudio 2019 only. For gcc13 I am sure that there are no warnings at all. --- Some notes: * By the way it is a *very* tricky piece of code to access a private (yes!) member within LLVM. * I doubt it can take different forms (can try), but we could suppress warnings with pragmas. https://github.com/llvm/llvm-project/blob/release/17.x/llvm/include/llvm/MC/MCSubtargetInfo.h#L80-L81 Now, * Starting with LLVM>=16 one of it is public (have a getter, tvm is aware of this). * Starting with LLVM>=18 now booth are public (have a getters, tvm is also aware of this). Wanted is to make sure will work down to very early versions of LLVM, since I think it is quite trivial useful thing to have in the relationship with the LLVM backend. There is a similar attempt of @ajtulloch , [here some early 2019](https://github.com/apache/tvm/pull/15761/files#diff-1cf0e6a89e0e7f281f1e234eccc69885f6fb3ea30e9f1dc1876bdfc648c24c55L47-L77). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org