Skip to content
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

[ARM] musttail attribute fails with LTO and mismatched -ffast-math options #109929

Open
ostannard opened this issue Sep 25, 2024 · 1 comment
Open

Comments

@ostannard
Copy link
Collaborator

This code causes an error in the ARM backend when built with LTO, and one part is build with -ffast-math, and the other with UBSan:

struct function_pointers {
  double (*F95)(void);
};

void init_0(struct function_pointers *p);

double F93(void);

#ifdef PART1
struct function_pointers actual_fptrs;

[[clang::noinline]] double F90(void) {
  [[clang::musttail]] return F93();
}

double F95(void) { return 0.0; }

signed int main(void) {
  actual_fptrs.F95 = &F95;
  init_0(&actual_fptrs);
  F90();

  return 0;
}
#endif

#ifdef PART2
static struct function_pointers *fptrs;

void init_0(struct function_pointers *p) { fptrs = p; }

double F93(void) {
  [[clang::musttail]] return fptrs->F95();
}
#endif
#!/bin/bash -xe

/work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part1.bc -O1 -flto -DPART1 -ffast-math
/work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part2.bc -O1 -flto -DPART2 -fsanitize=undefined -fsanitize-trap=undefined
/work/llvm/install/bin/llvm-lto2 run part1.bc part2.bc -o test.o \
  -r part1.bc,F90,pl \
  -r part1.bc,F93,l \
  -r part1.bc,F95,pl \
  -r part1.bc,main,px \
  -r part1.bc,init_0,l \
  -r part1.bc,actual_fptrs,pl \
  -r part2.bc,init_0,pl \
  -r part2.bc,F93,pl
$ ./run.sh 
+ /work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part1.bc -O1 -flto -DPART1 -ffast-math
+ /work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part2.bc -O1 -flto -DPART2 -fsanitize=undefined -fsanitize-trap=undefined
+ /work/llvm/install/bin/llvm-lto2 run part1.bc part2.bc -o test.o -r part1.bc,F90,pl -r part1.bc,F93,l -r part1.bc,F95,pl -r part1.bc,main,px -r part1.bc,init_0,l -r part1.bc,actual_fptrs,pl -r part2.bc,init_0,pl -r part2.bc,F93,pl
LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /work/llvm/install/bin/llvm-lto2 /work/llvm/install/bin/llvm-lto2 part1.bc part2.bc -o test.o -r part1.bc,F90,pl -r part1.bc,F93,l -r part1.bc,F95,pl -r part1.bc,main,px -r part1.bc,init_0,l -r part1.bc,actual_fptrs,pl -r part2.bc,init_0,pl -r part2.bc,F93,pl
1.      Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.      Running pass 'ARM Instruction Selection' on function '@F90'
 #0 0x00005566b41c38a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/llvm/install/bin/llvm-lto2+0x64158a7)
 #1 0x00005566b41c148e llvm::sys::RunSignalHandlers() (/work/llvm/install/bin/llvm-lto2+0x641348e)
 #2 0x00005566b41c3f7a SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f1223242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f12232969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f12232969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f12232969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f1223242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f12232287f3 abort ./stdlib/abort.c:81:7
 #9 0x00005566b4123733 llvm::report_fatal_error(llvm::Twine const&, bool) (/work/llvm/install/bin/llvm-lto2+0x6375733)
#10 0x00005566b4123586 (/work/llvm/install/bin/llvm-lto2+0x6375586)
#11 0x00005566b26d48c6 llvm::ARMTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const ARMISelLowering.cpp:0:0
#12 0x00005566b44ef594 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/work/llvm/install/bin/llvm-lto2+0x6741594)
#13 0x00005566b45108e2 llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (/work/llvm/install/bin/llvm-lto2+0x67628e2)
#14 0x00005566b44f7cd5 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) (/work/llvm/install/bin/llvm-lto2+0x6749cd5)
#15 0x00005566b44e0a0e llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/work/llvm/install/bin/llvm-lto2+0x6732a0e)
#16 0x00005566b44d363c llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/work/llvm/install/bin/llvm-lto2+0x672563c)
#17 0x00005566b45926c6 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (/work/llvm/install/bin/llvm-lto2+0x67e46c6)
#18 0x00005566b4591e3c llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/work/llvm/install/bin/llvm-lto2+0x67e3e3c)
#19 0x00005566b458f132 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/work/llvm/install/bin/llvm-lto2+0x67e1132)
#20 0x00005566b27dfbc1 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) ARMISelDAGToDAG.cpp:0:0
#21 0x00005566b458ca46 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/work/llvm/install/bin/llvm-lto2+0x67dea46)
#22 0x00005566b37c20d4 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/work/llvm/install/bin/llvm-lto2+0x5a140d4)
#23 0x00005566b3d30999 llvm::FPPassManager::runOnFunction(llvm::Function&) (/work/llvm/install/bin/llvm-lto2+0x5f82999)
#24 0x00005566b3d38791 llvm::FPPassManager::runOnModule(llvm::Module&) (/work/llvm/install/bin/llvm-lto2+0x5f8a791)
#25 0x00005566b3d3141f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/work/llvm/install/bin/llvm-lto2+0x5f8341f)
#26 0x00005566b3e14659 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) LTOBackend.cpp:0:0
#27 0x00005566b3e134da llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/work/llvm/install/bin/llvm-lto2+0x60654da)
#28 0x00005566b3df5547 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (/work/llvm/install/bin/llvm-lto2+0x6047547)
#29 0x00005566b3df4aea llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) (/work/llvm/install/bin/llvm-lto2+0x6046aea)
#30 0x00005566b1e07cf3 run(int, char**) llvm-lto2.cpp:0:0
#31 0x00005566b1e02644 main (/work/llvm/install/bin/llvm-lto2+0x4054644)
#32 0x00007f1223229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#33 0x00007f1223229e40 call_init ./csu/../csu/libc-start.c:128:20
#34 0x00007f1223229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#35 0x00005566b1dfed25 _start (/work/llvm/install/bin/llvm-lto2+0x4050d25)
./run.sh: line 13: 1466542 Aborted                 (core dumped) /work/llvm/install/bin/llvm-lto2 run part1.bc part2.bc -o test.o -r part1.bc,F90,pl -r part1.bc,F93,l -r part1.bc,F95,pl -r part1.bc,main,px -r part1.bc,init_0,l -r part1.bc,actual_fptrs,pl -r part2.bc,init_0,pl -r part2.bc,F93,pl

I think what's causing this to fail is that, going into the backend, @F90 has a nofpclass(nan inf) attribute on its return value, but has a musttail call without that attribute. Removing the attribute from @F90 or adding it to the call site causes the compile to succeed.

define internal nofpclass(nan inf) double @F90() unnamed_addr #0 {
entry:
  %0 = load ptr, ptr @fptrs, align 4, !tbaa !6
  %1 = icmp ne ptr %0, null, !nosanitize !10
  %2 = ptrtoint ptr %0 to i32, !nosanitize !10
  %3 = and i32 %2, 3, !nosanitize !10
  %4 = icmp eq i32 %3, 0, !nosanitize !10
  %5 = and i1 %1, %4, !nosanitize !10
  br i1 %5, label %cont1.i, label %trap.i, !nosanitize !10

trap.i:                                           ; preds = %entry
  tail call void @llvm.ubsantrap(i8 22) #4, !nosanitize !10
  unreachable, !nosanitize !10

cont1.i:                                          ; preds = %entry
  %6 = load ptr, ptr @actual_fptrs, align 4, !tbaa !11
  %7 = ptrtoint ptr %6 to i32, !nosanitize !10
  %8 = and i32 %7, -2, !nosanitize !10
  %9 = inttoptr i32 %8 to ptr, !nosanitize !10
  %10 = getelementptr i8, ptr %9, i32 -8
  %11 = load i32, ptr %10, align 4, !nosanitize !10
  %12 = icmp eq i32 %11, -1056584962, !nosanitize !10
  br i1 %12, label %typecheck.i, label %cont4.i, !nosanitize !10

typecheck.i:                                      ; preds = %cont1.i
  %13 = getelementptr i8, ptr %9, i32 -4
  %14 = load i32, ptr %13, align 4, !nosanitize !10
  %15 = icmp eq i32 %14, -166727886, !nosanitize !10
  br i1 %15, label %cont4.i, label %trap2.i, !nosanitize !10

trap2.i:                                          ; preds = %typecheck.i
  tail call void @llvm.ubsantrap(i8 6) #4, !nosanitize !10
  unreachable, !nosanitize !10

cont4.i:                                          ; preds = %typecheck.i, %cont1.i
  %call.i = musttail call double %6() #5
  ret double %call.i
}
@llvmbot
Copy link
Member

llvmbot commented Sep 25, 2024

@llvm/issue-subscribers-backend-arm

Author: Oliver Stannard (ostannard)

This code causes an error in the ARM backend when built with LTO, and one part is build with -ffast-math, and the other with UBSan: ```c struct function_pointers { double (*F95)(void); };

void init_0(struct function_pointers *p);

double F93(void);

#ifdef PART1
struct function_pointers actual_fptrs;

[[clang::noinline]] double F90(void) {
[[clang::musttail]] return F93();
}

double F95(void) { return 0.0; }

signed int main(void) {
actual_fptrs.F95 = &F95;
init_0(&actual_fptrs);
F90();

return 0;
}
#endif

#ifdef PART2
static struct function_pointers *fptrs;

void init_0(struct function_pointers *p) { fptrs = p; }

double F93(void) {
[[clang::musttail]] return fptrs->F95();
}
#endif


```sh
#!/bin/bash -xe

/work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part1.bc -O1 -flto -DPART1 -ffast-math
/work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part2.bc -O1 -flto -DPART2 -fsanitize=undefined -fsanitize-trap=undefined
/work/llvm/install/bin/llvm-lto2 run part1.bc part2.bc -o test.o \
  -r part1.bc,F90,pl \
  -r part1.bc,F93,l \
  -r part1.bc,F95,pl \
  -r part1.bc,main,px \
  -r part1.bc,init_0,l \
  -r part1.bc,actual_fptrs,pl \
  -r part2.bc,init_0,pl \
  -r part2.bc,F93,pl
$ ./run.sh 
+ /work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part1.bc -O1 -flto -DPART1 -ffast-math
+ /work/llvm/install/bin/clang --target=arm-none-eabi -march=armv7-a -c test.c -o part2.bc -O1 -flto -DPART2 -fsanitize=undefined -fsanitize-trap=undefined
+ /work/llvm/install/bin/llvm-lto2 run part1.bc part2.bc -o test.o -r part1.bc,F90,pl -r part1.bc,F93,l -r part1.bc,F95,pl -r part1.bc,main,px -r part1.bc,init_0,l -r part1.bc,actual_fptrs,pl -r part2.bc,init_0,pl -r part2.bc,F93,pl
LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /work/llvm/install/bin/llvm-lto2 /work/llvm/install/bin/llvm-lto2 part1.bc part2.bc -o test.o -r part1.bc,F90,pl -r part1.bc,F93,l -r part1.bc,F95,pl -r part1.bc,main,px -r part1.bc,init_0,l -r part1.bc,actual_fptrs,pl -r part2.bc,init_0,pl -r part2.bc,F93,pl
1.      Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.      Running pass 'ARM Instruction Selection' on function '@<!-- -->F90'
 #<!-- -->0 0x00005566b41c38a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/work/llvm/install/bin/llvm-lto2+0x64158a7)
 #<!-- -->1 0x00005566b41c148e llvm::sys::RunSignalHandlers() (/work/llvm/install/bin/llvm-lto2+0x641348e)
 #<!-- -->2 0x00005566b41c3f7a SignalHandler(int) Signals.cpp:0:0
 #<!-- -->3 0x00007f1223242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007f12232969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007f12232969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007f12232969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007f1223242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007f12232287f3 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x00005566b4123733 llvm::report_fatal_error(llvm::Twine const&amp;, bool) (/work/llvm/install/bin/llvm-lto2+0x6375733)
#<!-- -->10 0x00005566b4123586 (/work/llvm/install/bin/llvm-lto2+0x6375586)
#<!-- -->11 0x00005566b26d48c6 llvm::ARMTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&amp;, llvm::SmallVectorImpl&lt;llvm::SDValue&gt;&amp;) const ARMISelLowering.cpp:0:0
#<!-- -->12 0x00005566b44ef594 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&amp;) const (/work/llvm/install/bin/llvm-lto2+0x6741594)
#<!-- -->13 0x00005566b45108e2 llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&amp;, llvm::BasicBlock const*) (/work/llvm/install/bin/llvm-lto2+0x67628e2)
#<!-- -->14 0x00005566b44f7cd5 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&amp;, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) (/work/llvm/install/bin/llvm-lto2+0x6749cd5)
#<!-- -->15 0x00005566b44e0a0e llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&amp;) (/work/llvm/install/bin/llvm-lto2+0x6732a0e)
#<!-- -->16 0x00005566b44d363c llvm::SelectionDAGBuilder::visit(llvm::Instruction const&amp;) (/work/llvm/install/bin/llvm-lto2+0x672563c)
#<!-- -->17 0x00005566b45926c6 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits&lt;llvm::ilist_detail::node_options&lt;llvm::Instruction, true, false, void, true, llvm::BasicBlock&gt;, false, true&gt;, llvm::ilist_iterator_w_bits&lt;llvm::ilist_detail::node_options&lt;llvm::Instruction, true, false, void, true, llvm::BasicBlock&gt;, false, true&gt;, bool&amp;) (/work/llvm/install/bin/llvm-lto2+0x67e46c6)
#<!-- -->18 0x00005566b4591e3c llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&amp;) (/work/llvm/install/bin/llvm-lto2+0x67e3e3c)
#<!-- -->19 0x00005566b458f132 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&amp;) (/work/llvm/install/bin/llvm-lto2+0x67e1132)
#<!-- -->20 0x00005566b27dfbc1 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&amp;) ARMISelDAGToDAG.cpp:0:0
#<!-- -->21 0x00005566b458ca46 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&amp;) (/work/llvm/install/bin/llvm-lto2+0x67dea46)
#<!-- -->22 0x00005566b37c20d4 llvm::MachineFunctionPass::runOnFunction(llvm::Function&amp;) (/work/llvm/install/bin/llvm-lto2+0x5a140d4)
#<!-- -->23 0x00005566b3d30999 llvm::FPPassManager::runOnFunction(llvm::Function&amp;) (/work/llvm/install/bin/llvm-lto2+0x5f82999)
#<!-- -->24 0x00005566b3d38791 llvm::FPPassManager::runOnModule(llvm::Module&amp;) (/work/llvm/install/bin/llvm-lto2+0x5f8a791)
#<!-- -->25 0x00005566b3d3141f llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (/work/llvm/install/bin/llvm-lto2+0x5f8341f)
#<!-- -->26 0x00005566b3e14659 codegen(llvm::lto::Config const&amp;, llvm::TargetMachine*, std::function&lt;llvm::Expected&lt;std::unique_ptr&lt;llvm::CachedFileStream, std::default_delete&lt;llvm::CachedFileStream&gt;&gt;&gt; (unsigned int, llvm::Twine const&amp;)&gt;, unsigned int, llvm::Module&amp;, llvm::ModuleSummaryIndex const&amp;) LTOBackend.cpp:0:0
#<!-- -->27 0x00005566b3e134da llvm::lto::backend(llvm::lto::Config const&amp;, std::function&lt;llvm::Expected&lt;std::unique_ptr&lt;llvm::CachedFileStream, std::default_delete&lt;llvm::CachedFileStream&gt;&gt;&gt; (unsigned int, llvm::Twine const&amp;)&gt;, unsigned int, llvm::Module&amp;, llvm::ModuleSummaryIndex&amp;) (/work/llvm/install/bin/llvm-lto2+0x60654da)
#<!-- -->28 0x00005566b3df5547 llvm::lto::LTO::runRegularLTO(std::function&lt;llvm::Expected&lt;std::unique_ptr&lt;llvm::CachedFileStream, std::default_delete&lt;llvm::CachedFileStream&gt;&gt;&gt; (unsigned int, llvm::Twine const&amp;)&gt;) (/work/llvm/install/bin/llvm-lto2+0x6047547)
#<!-- -->29 0x00005566b3df4aea llvm::lto::LTO::run(std::function&lt;llvm::Expected&lt;std::unique_ptr&lt;llvm::CachedFileStream, std::default_delete&lt;llvm::CachedFileStream&gt;&gt;&gt; (unsigned int, llvm::Twine const&amp;)&gt;, std::function&lt;llvm::Expected&lt;std::function&lt;llvm::Expected&lt;std::unique_ptr&lt;llvm::CachedFileStream, std::default_delete&lt;llvm::CachedFileStream&gt;&gt;&gt; (unsigned int, llvm::Twine const&amp;)&gt;&gt; (unsigned int, llvm::StringRef, llvm::Twine const&amp;)&gt;) (/work/llvm/install/bin/llvm-lto2+0x6046aea)
#<!-- -->30 0x00005566b1e07cf3 run(int, char**) llvm-lto2.cpp:0:0
#<!-- -->31 0x00005566b1e02644 main (/work/llvm/install/bin/llvm-lto2+0x4054644)
#<!-- -->32 0x00007f1223229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->33 0x00007f1223229e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->34 0x00007f1223229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->35 0x00005566b1dfed25 _start (/work/llvm/install/bin/llvm-lto2+0x4050d25)
./run.sh: line 13: 1466542 Aborted                 (core dumped) /work/llvm/install/bin/llvm-lto2 run part1.bc part2.bc -o test.o -r part1.bc,F90,pl -r part1.bc,F93,l -r part1.bc,F95,pl -r part1.bc,main,px -r part1.bc,init_0,l -r part1.bc,actual_fptrs,pl -r part2.bc,init_0,pl -r part2.bc,F93,pl

I think what's causing this to fail is that, going into the backend, @<!-- -->F90 has a nofpclass(nan inf) attribute on its return value, but has a musttail call without that attribute. Removing the attribute from @<!-- -->F90 or adding it to the call site causes the compile to succeed.

define internal nofpclass(nan inf) double @<!-- -->F90() unnamed_addr #<!-- -->0 {
entry:
  %0 = load ptr, ptr @<!-- -->fptrs, align 4, !tbaa !6
  %1 = icmp ne ptr %0, null, !nosanitize !10
  %2 = ptrtoint ptr %0 to i32, !nosanitize !10
  %3 = and i32 %2, 3, !nosanitize !10
  %4 = icmp eq i32 %3, 0, !nosanitize !10
  %5 = and i1 %1, %4, !nosanitize !10
  br i1 %5, label %cont1.i, label %trap.i, !nosanitize !10

trap.i:                                           ; preds = %entry
  tail call void @<!-- -->llvm.ubsantrap(i8 22) #<!-- -->4, !nosanitize !10
  unreachable, !nosanitize !10

cont1.i:                                          ; preds = %entry
  %6 = load ptr, ptr @<!-- -->actual_fptrs, align 4, !tbaa !11
  %7 = ptrtoint ptr %6 to i32, !nosanitize !10
  %8 = and i32 %7, -2, !nosanitize !10
  %9 = inttoptr i32 %8 to ptr, !nosanitize !10
  %10 = getelementptr i8, ptr %9, i32 -8
  %11 = load i32, ptr %10, align 4, !nosanitize !10
  %12 = icmp eq i32 %11, -1056584962, !nosanitize !10
  br i1 %12, label %typecheck.i, label %cont4.i, !nosanitize !10

typecheck.i:                                      ; preds = %cont1.i
  %13 = getelementptr i8, ptr %9, i32 -4
  %14 = load i32, ptr %13, align 4, !nosanitize !10
  %15 = icmp eq i32 %14, -166727886, !nosanitize !10
  br i1 %15, label %cont4.i, label %trap2.i, !nosanitize !10

trap2.i:                                          ; preds = %typecheck.i
  tail call void @<!-- -->llvm.ubsantrap(i8 6) #<!-- -->4, !nosanitize !10
  unreachable, !nosanitize !10

cont4.i:                                          ; preds = %typecheck.i, %cont1.i
  %call.i = musttail call double %6() #<!-- -->5
  ret double %call.i
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants