Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[PPC64/PPC64LE] Call of __attribute__((noreturn)) generates suboptimal code #38993

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR40021
Status NEW
Importance P enhancement
Reported by simonas+llvm.org@kazlauskas.me
Reported on 2018-12-14 04:44:09 -0800
Last modified on 2018-12-14 08:38:51 -0800
Version trunk
Hardware PC Linux
CC llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com, simonas+llvm.org@kazlauskas.me
Fixed by commit(s)
Attachments test.ll (1085 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 21223
LLVM-IR test case

The following C code

typedef long long unsigned int uint64_t;

void __attribute__((noreturn)) test(uint64_t a, uint64_t b, uint64_t
__attribute__((noreturn)) (*cb)(uint64_t, uint64_t)) {
    cb(a, b);
}

which generates the following LLVM-IR (clang 6)

define void @test(i64, i64, i64 (i64, i64)* nocapture) local_unnamed_addr #0 {
  %4 = tail call i64 %2(i64 %0, i64 %1) #1
  unreachable
}

results in unnecessary instructions after the call when ppc64le is targeted:

mtctr 5
mr 12, 5
std 2, 24(1) /* what for? */
bctrl
ld 2, 24(1)  /* what for? */

The full LLVM-IR is attached.
Quuxplusone commented 5 years ago

Attached test.ll (1085 bytes, text/plain): LLVM-IR test case