Skip to content

Commit 41ba801

Browse files
[CallSite Removal] a CallBase is never an IndirectCall for isInlineAsm
Summary: Thanks to Bill Wendling (void) for the report and steps to reproduce. It looks like this was missed during r350508's cleanup of the CallSite split into CallBase, CallInst, and CallBrInst. This was exposed by running pgo on a callbr, which was creating a ptrtoint to the inline asm thinking it was an indirect call. The relevant callchain looks like: IndirectCallPromotionPlugin::run() -> PGOIndirectCallVisitor::findIndirectCalls() -> PGOIndirectCallVisitor::visitCallBase() -> CallBase::isIndirectCall() Reviewers: void, chandlerc Reviewed By: void Subscribers: hiraditya, llvm-commits, craig.topper, srhines Tags: #llvm Differential Revision: https://reviews.llvm.org/D77600
1 parent 29beabb commit 41ba801

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

llvm/lib/IR/Instructions.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,7 @@ bool CallBase::isIndirectCall() const {
267267
const Value *V = getCalledValue();
268268
if (isa<Function>(V) || isa<Constant>(V))
269269
return false;
270-
if (const CallInst *CI = dyn_cast<CallInst>(this))
271-
if (CI->isInlineAsm())
272-
return false;
273-
return true;
270+
return !isInlineAsm();
274271
}
275272

276273
/// Tests if this call site must be tail call optimized. Only a CallInst can
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: opt -pgo-instr-gen -S 2>&1 < %s | FileCheck %s
2+
3+
define i32 @a() {
4+
entry:
5+
; CHECK-NOT: ptrtoint void (i8*)* asm sideeffect
6+
; CHECK: callbr void asm sideeffect
7+
%retval = alloca i32, align 4
8+
callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@a, %b)) #1
9+
to label %asm.fallthrough [label %b]
10+
11+
asm.fallthrough:
12+
br label %b
13+
14+
b:
15+
%0 = load i32, i32* %retval, align 4
16+
ret i32 %0
17+
}

0 commit comments

Comments
 (0)