[opaque pointer types] Add a FunctionCallee wrapper type, and use it.
authorJames Y Knight <jyknight@google.com>
Fri, 1 Feb 2019 02:28:03 +0000 (02:28 +0000)
committerJames Y Knight <jyknight@google.com>
Fri, 1 Feb 2019 02:28:03 +0000 (02:28 +0000)
commit13680223b9d80bb01e17372f0907cf215e424cce
tree774a79c2eef0e125cf5beb33a7515f581397c398
parentb4744d306c0a21933d4339fa4fb497866a36ee49
[opaque pointer types] Add a FunctionCallee wrapper type, and use it.

Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc
doesn't choke on it, hopefully.

Original Message:
The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.

Then:
- update the CallInst/InvokeInst instruction creation functions to
  take a Callee,
- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.

One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.

However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)

Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.

Differential Revision: https://reviews.llvm.org/D57315

llvm-svn: 352827
70 files changed:
clang/lib/CodeGen/CGExpr.cpp
llvm/docs/ProgrammersManual.rst
llvm/examples/BrainF/BrainF.cpp
llvm/examples/BrainF/BrainF.h
llvm/examples/BrainF/BrainFDriver.cpp
llvm/examples/Fibonacci/fibonacci.cpp
llvm/examples/HowToUseJIT/HowToUseJIT.cpp
llvm/examples/ParallelJIT/ParallelJIT.cpp
llvm/include/llvm/CodeGen/IntrinsicLowering.h
llvm/include/llvm/IR/DerivedTypes.h
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/IR/InstrTypes.h
llvm/include/llvm/IR/Instructions.h
llvm/include/llvm/IR/Module.h
llvm/include/llvm/Transforms/Utils/ModuleUtils.h
llvm/lib/CodeGen/AtomicExpandPass.cpp
llvm/lib/CodeGen/DwarfEHPrepare.cpp
llvm/lib/CodeGen/IntrinsicLowering.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineOutliner.cpp
llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
llvm/lib/CodeGen/SafeStack.cpp
llvm/lib/CodeGen/SjLjEHPrepare.cpp
llvm/lib/CodeGen/StackProtector.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/WasmEHPrepare.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/Module.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
llvm/lib/Target/AMDGPU/AMDGPULibFunc.h
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
llvm/lib/Target/Mips/Mips16HardFloat.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLowerGlobalDtors.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86WinEHState.cpp
llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
llvm/lib/Transforms/Utils/ModuleUtils.cpp
llvm/lib/Transforms/Utils/PredicateInfo.cpp
llvm/lib/Transforms/Utils/SanitizerStats.cpp
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/tools/bugpoint/Miscompilation.cpp
llvm/tools/lli/lli.cpp
llvm/unittests/Analysis/AliasAnalysisTest.cpp
llvm/unittests/Analysis/DivergenceAnalysisTest.cpp
llvm/unittests/Analysis/OrderedInstructionsTest.cpp
llvm/unittests/Analysis/PhiValuesTest.cpp
llvm/unittests/Analysis/ScalarEvolutionTest.cpp
llvm/unittests/Analysis/TBAATest.cpp
llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
llvm/unittests/IR/CFGBuilder.cpp
llvm/unittests/IR/MetadataTest.cpp
llvm/unittests/IR/VerifierTest.cpp