mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-20 12:31:40 +00:00
Fix memcmp code-gen to honor -fno-builtin.
I noticed that SelectionDAGBuilder::visitCall was missing a check for memcmp in TargetLibraryInfo, so that it would use custom code for memcmp calls even with -fno-builtin. I also had to add a new -disable-simplify-libcalls option to llc so that I could write a test for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b2beac2b96
commit
772af92cb1
@ -5682,7 +5682,7 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
|
|||||||
Tmp.getValueType(), Tmp));
|
Tmp.getValueType(), Tmp));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (Name == "memcmp") {
|
} else if ((LibInfo->has(LibFunc::memcmp) && Name == "memcmp")) {
|
||||||
if (visitMemCmpCall(I))
|
if (visitMemCmpCall(I))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s
|
; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s
|
||||||
|
; RUN: llc < %s -disable-simplify-libcalls -mtriple=x86_64-linux | FileCheck %s --check-prefix=NOBUILTIN
|
||||||
; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s
|
; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s
|
||||||
|
|
||||||
; This tests codegen time inlining/optimization of memcmp
|
; This tests codegen time inlining/optimization of memcmp
|
||||||
@ -23,6 +24,8 @@ return: ; preds = %entry
|
|||||||
; CHECK: memcmp2:
|
; CHECK: memcmp2:
|
||||||
; CHECK: movw ([[A0:%rdi|%rcx]]), %ax
|
; CHECK: movw ([[A0:%rdi|%rcx]]), %ax
|
||||||
; CHECK: cmpw ([[A1:%rsi|%rdx]]), %ax
|
; CHECK: cmpw ([[A1:%rsi|%rdx]]), %ax
|
||||||
|
; NOBUILTIN: memcmp2:
|
||||||
|
; NOBUILTIN: callq
|
||||||
}
|
}
|
||||||
|
|
||||||
define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind {
|
define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind {
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Support/TargetSelect.h"
|
#include "llvm/Support/TargetSelect.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
|
#include "llvm/Target/TargetLibraryInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -213,6 +214,11 @@ DontPlaceZerosInBSS("nozero-initialized-in-bss",
|
|||||||
cl::desc("Don't place zero-initialized symbols into bss section"),
|
cl::desc("Don't place zero-initialized symbols into bss section"),
|
||||||
cl::init(false));
|
cl::init(false));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
DisableSimplifyLibCalls("disable-simplify-libcalls",
|
||||||
|
cl::desc("Disable simplify-libcalls"),
|
||||||
|
cl::init(false));
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
EnableGuaranteedTailCallOpt("tailcallopt",
|
EnableGuaranteedTailCallOpt("tailcallopt",
|
||||||
cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
|
cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
|
||||||
@ -487,6 +493,12 @@ int main(int argc, char **argv) {
|
|||||||
// Build up all of the passes that we want to do to the module.
|
// Build up all of the passes that we want to do to the module.
|
||||||
PassManager PM;
|
PassManager PM;
|
||||||
|
|
||||||
|
// Add an appropriate TargetLibraryInfo pass for the module's triple.
|
||||||
|
TargetLibraryInfo *TLI = new TargetLibraryInfo(TheTriple);
|
||||||
|
if (DisableSimplifyLibCalls)
|
||||||
|
TLI->disableAllFunctions();
|
||||||
|
PM.add(TLI);
|
||||||
|
|
||||||
// Add the target data from the target machine, if it exists, or the module.
|
// Add the target data from the target machine, if it exists, or the module.
|
||||||
if (const TargetData *TD = Target.getTargetData())
|
if (const TargetData *TD = Target.getTargetData())
|
||||||
PM.add(new TargetData(*TD));
|
PM.add(new TargetData(*TD));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user