Skip to content

Commit 5d90a01

Browse files
committed
Some refactorings to make use of the new helper.
`LibCallsShrinkWrap::perform`: This uses the potentially `nullptr` value inside the loop in a debug statement before asserting on it. Move the assertion outside `perform(CallInst &)`. Some other arbitrary uses to replace `getCalledFunction()->getName()`.
1 parent 065431f commit 5d90a01

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ class VFDatabase {
4141
/// a vector Function ABI.
4242
static void getVFABIMappings(const CallInst &CI,
4343
SmallVectorImpl<VFInfo> &Mappings) {
44-
if (!CI.getCalledFunction())
44+
const auto ScalarName = CI.getCalledFunctionName();
45+
if (!ScalarName.has_value())
4546
return;
4647

47-
const StringRef ScalarName = CI.getCalledFunction()->getName();
48-
4948
SmallVector<std::string, 8> ListOfStrings;
5049
// The check for the vector-function-abi-variant attribute is done when
5150
// retrieving the vector variant names here.
@@ -59,7 +58,7 @@ class VFDatabase {
5958
// ensuring that the variant described in the attribute has a
6059
// corresponding definition or declaration of the vector
6160
// function in the Module M.
62-
if (Shape && (Shape->ScalarName == ScalarName)) {
61+
if (Shape && (Shape->ScalarName == *ScalarName)) {
6362
assert(CI.getModule()->getFunction(Shape->VectorName) &&
6463
"Vector function is missing.");
6564
Mappings.push_back(*Shape);

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,7 @@ static void trackInlinedStores(Function::iterator Start, Function::iterator End,
19831983
const CallBase &CB) {
19841984
LLVM_DEBUG(errs() << "trackInlinedStores into "
19851985
<< Start->getParent()->getName() << " from "
1986-
<< CB.getCalledFunction()->getName() << "\n");
1986+
<< *CB.getCalledFunctionName() << "\n");
19871987
const DataLayout &DL = CB.getDataLayout();
19881988
at::trackAssignments(Start, End, collectEscapedLocals(DL, CB), DL);
19891989
}

llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ class LibCallsShrinkWrap : public InstVisitor<LibCallsShrinkWrap> {
5858
bool perform() {
5959
bool Changed = false;
6060
for (auto &CI : WorkList) {
61-
LLVM_DEBUG(dbgs() << "CDCE calls: " << CI->getCalledFunction()->getName()
62-
<< "\n");
61+
auto CalleeName = CI->getCalledFunctionName();
62+
assert(CalleeName.has_value() &&
63+
"perform() should apply to a non-empty callee");
64+
65+
LLVM_DEBUG(dbgs() << "CDCE calls: " << *CalleeName << "\n");
6366
if (perform(CI)) {
6467
Changed = true;
6568
LLVM_DEBUG(dbgs() << "Transformed\n");
@@ -487,7 +490,6 @@ void LibCallsShrinkWrap::shrinkWrapCI(CallInst *CI, Value *Cond) {
487490
bool LibCallsShrinkWrap::perform(CallInst *CI) {
488491
LibFunc Func;
489492
Function *Callee = CI->getCalledFunction();
490-
assert(Callee && "perform() should apply to a non-empty callee");
491493
TLI.getLibFunc(*Callee, Func);
492494
assert(Func && "perform() is not expecting an empty function");
493495

0 commit comments

Comments
 (0)