[LLVMdev] New strict-aliasing warning?

Hal Finkel hfinkel at anl.gov
Sat Dec 3 15:44:17 PST 2011


On Sat, 2011-12-03 at 15:16 -0600, Hal Finkel wrote:
> When compiling trunk using gcc 4.1.2 on linux/ppc64, I now see a warning
> that I don't remember seeing previously:
> 
> llvm[2]: Compiling InlineSpiller.cpp for Release+Asserts build
> /src/llvm-trunk-dev/include/llvm/ADT/PointerIntPair.h: In member
> function ‘const PointerTy* llvm::PointerIntPair<PointerTy, IntBits,
> IntType, PtrTraits>::getAddrOfPointer() const [with PointerTy = void*,
> unsigned int IntBits = 1u, IntType = bool, PtrTraits =
> llvm::PointerUnionUIntTraits<llvm::VNInfo*,
> llvm::SmallVector<llvm::VNInfo*, 4u>*>]’:
> /src/llvm-trunk-dev/include/llvm/ADT/PointerUnion.h:153:   instantiated
> from ‘const PT1* llvm::PointerUnion<PT1, PT2>::getAddrOf() const [with T
> = llvm::VNInfo*, PT1 = llvm::VNInfo*, PT2 =
> llvm::SmallVector<llvm::VNInfo*, 4u>*]’
> /src/llvm-trunk-dev/include/llvm/ADT/TinyPtrVector.h:63:   instantiated
> from ‘const EltTy* llvm::TinyPtrVector<EltTy>::begin() const [with EltTy
> = llvm::VNInfo*]’
> /src/llvm-trunk-dev/lib/CodeGen/InlineSpiller.cpp:382:   instantiated
> from here
> /src/llvm-trunk-dev/include/llvm/ADT/PointerIntPair.h:98: warning:
> dereferencing type-punned pointer will break strict-aliasing rules
> 
> I think that this might be indicating some kind of problem because I am
> also currently seeing a crash in InlineSpiller on linux/ppc64. I am not
> yet sure if the crash and this warning are related. Does anyone know why
> this warning has appeared?

clang/Makefile has:
# Disable -fstrict-aliasing. Darwin disables it by default (and LLVM
doesn't
# work with it enabled with GCC), Clang/llvm-gcc don't support it yet,
and newer
# GCC's have false positive warnings with it on Linux (which prove a
pain to
# fix). For example:
#   http://gcc.gnu.org/PR41874
#   http://gcc.gnu.org/PR41838
#
# We can revisit this when LLVM/Clang support it.
CXX.Flags += -fno-strict-aliasing

llvm/Makefile.rules says:
  # Darwin requires -fstrict-aliasing to be explicitly enabled.
  # Avoid -fstrict-aliasing on Darwin for now, there are unresolved
issues
  # with -fstrict-aliasing and ipa-type-escape radr://6756684
  #ifeq ($(HOST_OS),Darwin)
  #  EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
  #endif

but I don't see anywhere where LLVM explicitly disables strict aliasing
(for non-Darwin systems where it may be enabled by default). Is this
intentional?

 -Hal

> 
> Thanks again,
> Hal
> 

-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory




More information about the llvm-dev mailing list