[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Nathan Chancellor via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 18:02:24 PST 2023


nathanchance wrote:

For what it's worth, I see a new crash on the latest version of this PR, in case it is not known.

```
$ make -skj"$(nproc)" ARCH=arm64 LLVM=1 mrproper allmodconfig net/ipv4/udp_tunnel_nic.o
clang: /home/nathan/cbl/src/llvm-project/llvm/lib/IR/Instructions.cpp:3342: static CastInst *llvm::CastInst::Create(Instruction::CastOps, Value *, Type *, const Twine &, Instruction *): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /mnt/nvme/tmp/build/llvm-bisect/final/bin/clang --target=aarch64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -mlittle-endian -fmacro-prefix-map== -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mgeneral-regs-only -Wno-psabi -fasynchronous-unwind-tables -mbranch-protection=pac-ret+bti -ffixed-x18 -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=pattern -fno-stack-clash-protection -fzero-call-used-regs=used-gpr -fpatchable-function-entry=2 -fsanitize=kcfi -falign-functions=64 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-format-overflow -Wno-format-truncation -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -frandomize-layout-seed-file=./scripts/basic/randstruct.seed -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=10432 -fsanitize=array-bounds -fsanitize=shift -fsanitize=unreachable -fsanitize=bool -fsanitize=enum -fsanitize-coverage=trace-pc -fsanitize-coverage=trace-cmp -fsanitize=thread -fno-optimize-sibling-calls -mllvm -tsan-compound-read-before-write=1 -mllvm -tsan-distinguish-volatile=1 -Werror -Wa,-march=armv8.5-a -nostdinc -Iarch/arm64/include -I./arch/arm64/include/generated -Iinclude -I./include -Iarch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -Iinclude/uapi -I./include/generated/uapi -include include/linux/compiler-version.h -include include/linux/kconfig.h -include include/linux/compiler_types.h -D__KERNEL__ -DCC_USING_PATCHABLE_FUNCTION_ENTRY -DKASAN_SHADOW_SCALE_SHIFT= -DCONFIG_CC_HAS_K_CONSTRAINT=1 -DARM64_ASM_ARCH=\"armv8.5-a\" -DKASAN_SHADOW_SCALE_SHIFT= -DRANDSTRUCT -I net/ipv4 -I ./net/ipv4 -DMODULE -DKBUILD_BASENAME=\"udp_tunnel_nic\" -DKBUILD_MODNAME=\"udp_tunnel\" -D__KBUILD_MODNAME=kmod_udp_tunnel -c -Wp,-MMD,net/ipv4/.udp_tunnel_nic.o.d -fcolor-diagnostics -o net/ipv4/udp_tunnel_nic.o net/ipv4/udp_tunnel_nic.c
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	net/ipv4/udp_tunnel_nic.c:345:1: Generating code for declaration 'udp_tunnel_nic_has_collision'
4.	net/ipv4/udp_tunnel_nic.c:353:51: LLVM IR generation of compound statement ('{}')
 #0 0x00005574960f5698 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4153698)
 #1 0x00005574960f32ce llvm::sys::RunSignalHandlers() (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x41512ce)
 #2 0x0000557496077e26 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f1682eaf710 (/usr/lib/libc.so.6+0x3e710)
 #4 0x00007f1682eff83c (/usr/lib/libc.so.6+0x8e83c)
 #5 0x00007f1682eaf668 gsignal (/usr/lib/libc.so.6+0x3e668)
 #6 0x00007f1682e974b8 abort (/usr/lib/libc.so.6+0x264b8)
 #7 0x00007f1682e973dc (/usr/lib/libc.so.6+0x263dc)
 #8 0x00007f1682ea7d26 (/usr/lib/libc.so.6+0x36d26)
 #9 0x0000557495c1c9d3 llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::Instruction*) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x3c7a9d3)
#10 0x0000557494d032f2 llvm::IRBuilderBase::CreateIntCast(llvm::Value*, llvm::Type*, bool, llvm::Twine const&) AArch64TargetTransformInfo.cpp:0:0
#11 0x0000557496437dbf clang::CodeGen::CodeGenFunction::EmitBoundsCheck(clang::Expr const*, clang::Expr const*, llvm::Value*, clang::QualType, bool) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4495dbf)
#12 0x000055749644c893 clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(clang::ArraySubscriptExpr const*, bool)::$_0::operator()(bool) const CGExpr.cpp:0:0
#13 0x000055749643a7e6 clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(clang::ArraySubscriptExpr const*, bool) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x44987e6)
#14 0x0000557496439713 clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4497713)
#15 0x0000557496465e1e (anonymous namespace)::ScalarExprEmitter::VisitArraySubscriptExpr(clang::ArraySubscriptExpr*) CGExprScalar.cpp:0:0
#16 0x000055749645546b (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#17 0x0000557496471a8c (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#18 0x00005574964553fd clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x44b33fd)
#19 0x00005574964388a8 EmitPointerWithAlignment(clang::Expr const*, clang::CodeGen::LValueBaseInfo*, clang::CodeGen::TBAAAccessInfo*, clang::CodeGen::KnownNonNull_t, clang::CodeGen::CodeGenFunction&) CGExpr.cpp:0:0
#20 0x000055749643a60a clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(clang::ArraySubscriptExpr const*, bool) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x449860a)
#21 0x000055749643b09a clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x449909a)
#22 0x000055749642cf7d clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x448af7d)
#23 0x0000557496462c72 (anonymous namespace)::ScalarExprEmitter::VisitUnaryAddrOf(clang::UnaryOperator const*) CGExprScalar.cpp:0:0
#24 0x0000557496461b49 (anonymous namespace)::ScalarExprEmitter::VisitBinAssign(clang::BinaryOperator const*) CGExprScalar.cpp:0:0
#25 0x00005574964553fd clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x44b33fd)
#26 0x000055749642c7a3 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x448a7a3)
#27 0x000055749642c72c clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x448a72c)
#28 0x00005574965129fb clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x45709fb)
#29 0x00005574965133c1 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x45713c1)
#30 0x000055749651291b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x457091b)
#31 0x0000557496515956 clang::CodeGen::CodeGenFunction::EmitForStmt(clang::ForStmt const&, llvm::ArrayRef<clang::Attr const*>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4573956)
#32 0x0000557496512d85 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4570d85)
#33 0x0000557496515956 clang::CodeGen::CodeGenFunction::EmitForStmt(clang::ForStmt const&, llvm::ArrayRef<clang::Attr const*>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4573956)
#34 0x0000557496512d85 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4570d85)
#35 0x0000557496520340 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x457e340)
#36 0x0000557496419b30 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4477b30)
#37 0x000055749641a7bb clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x44787bb)
#38 0x00005574962f74ec clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x43554ec)
#39 0x00005574962ef243 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x434d243)
#40 0x00005574962df460 clang::CodeGen::CodeGenModule::EmitDeferred() (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x433d460)
#41 0x00005574962df48c clang::CodeGen::CodeGenModule::EmitDeferred() (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x433d48c)
#42 0x00005574962df48c clang::CodeGen::CodeGenModule::EmitDeferred() (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x433d48c)
#43 0x00005574962df48c clang::CodeGen::CodeGenModule::EmitDeferred() (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x433d48c)
#44 0x00005574962dcb8a clang::CodeGen::CodeGenModule::Release() (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x433ab8a)
#45 0x00005574968bae48 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#46 0x00005574968b1c86 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x490fc86)
#47 0x0000557497ba3cd6 clang::ParseAST(clang::Sema&, bool, bool) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x5c01cd6)
#48 0x0000557496cb115f clang::FrontendAction::Execute() (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4d0f15f)
#49 0x0000557496c21ebd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4c7febd)
#50 0x0000557496d7b1a8 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4dd91a8)
#51 0x0000557494a7b6c2 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x2ad96c2)
#52 0x0000557494a77afd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#53 0x0000557496a7eb19 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#54 0x0000557496077ba6 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x40d5ba6)
#55 0x0000557496a7e222 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4adc222)
#56 0x0000557496a39387 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4a97387)
#57 0x0000557496a398c7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4a978c7)
#58 0x0000557496a598b9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4ab78b9)
#59 0x0000557494a76fb6 clang_main(int, char**, llvm::ToolContext const&) (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x2ad4fb6)
#60 0x0000557494a87de1 main (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x2ae5de1)
#61 0x00007f1682e98cd0 (/usr/lib/libc.so.6+0x27cd0)
#62 0x00007f1682e98d8a __libc_start_main (/usr/lib/libc.so.6+0x27d8a)
#63 0x0000557494a740a5 _start (/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x2ad20a5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 18.0.0git (https://github.com/llvm/llvm-project 8f9aac44279dbc1e7fdc5e4263da2b237db0cfc1)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /mnt/nvme/tmp/build/llvm-bisect/final/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/udp_tunnel_nic-2661f6.c
clang: note: diagnostic msg: /tmp/udp_tunnel_nic-2661f6.sh
clang: note: diagnostic msg: 

********************
make[6]: *** [scripts/Makefile.build:243: net/ipv4/udp_tunnel_nic.o] Error 1
make[5]: *** [scripts/Makefile.build:480: net/ipv4] Error 2
make[5]: Target 'net/ipv4/udp_tunnel_nic.o' not remade because of errors.
make[4]: *** [scripts/Makefile.build:480: net] Error 2
make[4]: Target 'net/ipv4/udp_tunnel_nic.o' not remade because of errors.
make[3]: *** [Makefile:1911: .] Error 2
make[3]: Target 'net/ipv4/udp_tunnel_nic.o' not remade because of errors.
make[2]: *** [Makefile:350: __build_one_by_one] Error 2
make[2]: Target 'mrproper' not remade because of errors.
make[2]: Target 'allmodconfig' not remade because of errors.
make[2]: Target 'net/ipv4/udp_tunnel_nic.o' not remade because of errors.
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Target 'mrproper' not remade because of errors.
make[1]: Target 'allmodconfig' not remade because of errors.
make[1]: Target 'net/ipv4/udp_tunnel_nic.o' not remade because of errors.
make: *** [Makefile:234: __sub-make] Error 2
make: Target 'mrproper' not remade because of errors.
make: Target 'allmodconfig' not remade because of errors.
make: Target 'net/ipv4/udp_tunnel_nic.o' not remade because of errors.
```

I can reduce something out if it is not immediately obvious what the issue is.

https://github.com/llvm/llvm-project/pull/73730


More information about the cfe-commits mailing list